Some NBT tags require the correct suffix
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
2017-01-05, 03:18 AM
2024-07-23, 11:18 AM
2024-07-23, 11:18 AM
16
9