NBT CanPickUpLoot requires byte suffix, but most other NBTs don't.
Steps to reproduce
/summon zombie ~ ~ ~ {CanPickUpLoot:1}
Throw an item at the zombie
The zombie will not pickup the item
If you use
/summon zombie ~ ~ ~ {CanPickUpLoot:1b}
it will work.
Possible fix
Based on the decompiled code of 1.10.2 using forge the issue comes from here:
net.minecraft.entity.EntityLiving.readEntityFromNBT(NBTTagCompound):511
/**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
public void readEntityFromNBT(NBTTagCompound compound)
{
super.readEntityFromNBT(compound);
if (compound.hasKey("CanPickUpLoot", 1))
{
this.setCanPickUpLoot(compound.getBoolean("CanPickUpLoot"));
}
Instead of compound.hasKey("CanPickUpLoot", 1)
, it should be compound.hasKey("CanPickUpLoot", 99)
to work with all primitive types.
net.minecraft.nbt.NBTTagCompound.hasKey(String, int):215
/**
* Returns whether the given string has been previously stored as a key in this tag compound as a particular type,
* denoted by a parameter in the form of an ordinal. If the provided ordinal is 99, this method will match tag types
* representing numbers.
*/
public boolean hasKey(String key, int type)
{
int i = this.getTagId(key);
return i == type ? true : (type != 99 ? false : i == 1 || i == 2 || i == 3 || i == 4 || i == 5 || i == 6);
}
Here are some other affected nbts:
color: net.minecraft.item.ItemArmor.getColor(ItemStack):161
RepairCost: net.minecraft.item.ItemStack.getRepairCost():1001
ShowParticles: net.minecraft.potion.PotionEffect.readCustomPotionEffectFromNBT(NBTTagCompound):241
rewardExp: net.minecraft.village.MerchantRecipe.readFromTags(NBTTagCompound):152
Linked issues
is duplicated by 1
relates to 2
Attachments
Comments 17
@FVbico I think it would be better to change all affected nbt, even those that can not be touched by commands. That has the advantage of beeing consistent and it is better for mods. I actually reported this bug because I am writing a mod.
The thing is, your ticket is about requiring the correct suffix for some tags (none for some int tags) but editing those 2 requires third party software and the use of that is not supported.
@FBbico. So it's a bug since it's not consistent in the vanilla code, additionally he's showing it in the case for modding that it causes issues. It still causes issues in vanilla with commands as you require the "1b" part unlike most nbt tags with only needs an integer (like "NoGravity:1").
Armor Color no longer seems to use key 1, it uses 99
Updated Names: (yarn 1.17.1)
ShowParticles + ShowIcon: net.minecraft.entity.effect.StatusEffectInstance.fromNbt()
rewardExp + xp + priceMultiplier: net.minecraft.village.TradeOffer
repairCost did not change at all
removed the following:
trackingPosition: net.minecraft.world.storage.MapData.readFromNBT(NBTTagCompound):69
DifficultyLocked: net.minecraft.world.storage.WorldInfo.WorldInfo(NBTTagCompound):217
These 2 can't be touched by commands.