mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
More NBT consistency
Normalize empty NBT to null NBT. Fixes stackability for empty inventories, as usual.
This commit is contained in:
parent
51ad12d51a
commit
e9888a8634
@ -38,49 +38,52 @@ public abstract class ItemInventory implements IInventory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public NBTTagCompound checkNBT(NBTTagCompound nbt) {
|
public NBTTagCompound checkNBT(NBTTagCompound nbt) {
|
||||||
if(nbt != null && !nbt.hasNoTags()) {
|
|
||||||
Random random = new Random();
|
if(nbt == null || nbt.hasNoTags())
|
||||||
|
return null;
|
||||||
|
|
||||||
try {
|
Random random = new Random();
|
||||||
byte[] abyte = CompressedStreamTools.compress(nbt);
|
|
||||||
|
|
||||||
if (abyte.length > 6000) {
|
try {
|
||||||
player.addChatComponentMessage(new ChatComponentText(EnumChatFormatting.RED + "Warning: Container NBT exceeds 6kB, contents will be ejected!"));
|
byte[] abyte = CompressedStreamTools.compress(nbt);
|
||||||
for (int i1 = 0; i1 < this.getSizeInventory(); ++i1) {
|
|
||||||
ItemStack itemstack = this.getStackInSlot(i1);
|
|
||||||
|
|
||||||
if (itemstack != null) {
|
if (abyte.length > 6000) {
|
||||||
float f = random.nextFloat() * 0.8F + 0.1F;
|
player.addChatComponentMessage(new ChatComponentText(EnumChatFormatting.RED + "Warning: Container NBT exceeds 6kB, contents will be ejected!"));
|
||||||
float f1 = random.nextFloat() * 0.8F + 0.1F;
|
for (int i1 = 0; i1 < this.getSizeInventory(); ++i1) {
|
||||||
float f2 = random.nextFloat() * 0.8F + 0.1F;
|
ItemStack itemstack = this.getStackInSlot(i1);
|
||||||
|
|
||||||
while (itemstack.stackSize > 0) {
|
if (itemstack != null) {
|
||||||
int j1 = random.nextInt(21) + 10;
|
float f = random.nextFloat() * 0.8F + 0.1F;
|
||||||
|
float f1 = random.nextFloat() * 0.8F + 0.1F;
|
||||||
|
float f2 = random.nextFloat() * 0.8F + 0.1F;
|
||||||
|
|
||||||
if (j1 > itemstack.stackSize) {
|
while (itemstack.stackSize > 0) {
|
||||||
j1 = itemstack.stackSize;
|
int j1 = random.nextInt(21) + 10;
|
||||||
}
|
|
||||||
|
|
||||||
itemstack.stackSize -= j1;
|
if (j1 > itemstack.stackSize) {
|
||||||
EntityItem entityitem = new EntityItem(player.worldObj, player.posX + f, player.posY + f1, player.posZ + f2, new ItemStack(itemstack.getItem(), j1, itemstack.getItemDamage()));
|
j1 = itemstack.stackSize;
|
||||||
|
|
||||||
if (itemstack.hasTagCompound()) {
|
|
||||||
entityitem.getEntityItem().setTagCompound((NBTTagCompound) itemstack.getTagCompound().copy());
|
|
||||||
}
|
|
||||||
|
|
||||||
float f3 = 0.05F;
|
|
||||||
entityitem.motionX = (float) random.nextGaussian() * f3 + player.motionX;
|
|
||||||
entityitem.motionY = (float) random.nextGaussian() * f3 + 0.2F + player.motionY;
|
|
||||||
entityitem.motionZ = (float) random.nextGaussian() * f3 + player.motionZ;
|
|
||||||
player.worldObj.spawnEntityInWorld(entityitem);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
itemstack.stackSize -= j1;
|
||||||
|
EntityItem entityitem = new EntityItem(player.worldObj, player.posX + f, player.posY + f1, player.posZ + f2, new ItemStack(itemstack.getItem(), j1, itemstack.getItemDamage()));
|
||||||
|
|
||||||
|
if (itemstack.hasTagCompound()) {
|
||||||
|
entityitem.getEntityItem().setTagCompound((NBTTagCompound) itemstack.getTagCompound().copy());
|
||||||
|
}
|
||||||
|
|
||||||
|
float f3 = 0.05F;
|
||||||
|
entityitem.motionX = (float) random.nextGaussian() * f3 + player.motionX;
|
||||||
|
entityitem.motionY = (float) random.nextGaussian() * f3 + 0.2F + player.motionY;
|
||||||
|
entityitem.motionZ = (float) random.nextGaussian() * f3 + player.motionZ;
|
||||||
|
player.worldObj.spawnEntityInWorld(entityitem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new NBTTagCompound(); // Reset.
|
|
||||||
}
|
}
|
||||||
} catch (IOException ignored) {}
|
|
||||||
}
|
return null; // Reset.
|
||||||
|
}
|
||||||
|
} catch (IOException ignored) {}
|
||||||
|
|
||||||
return nbt;
|
return nbt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user