remove bugged PlacedItem tile entities properly (#55)

This commit is contained in:
Alexdoru authored and GitHub committed 2024-10-24 20:09:15 +02:00
1 parent d829c2f95f
commit 041fefe81a
1 file changed
+8 -2
@@ -1,5 +1,6 @@
package com.brandon3055.draconicevolution.common.tileentities;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager;
@@ -9,6 +10,7 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Vec3;
import com.brandon3055.draconicevolution.common.ModBlocks;
import com.brandon3055.draconicevolution.common.utills.LogHelper;
/**
* Created by Brandon on 14/08/2014.
@@ -67,10 +69,14 @@ public class TilePlacedItem extends TileEntity {
tag[0] = compound.getCompoundTag("Item" + 0);
stack = ItemStack.loadItemStackFromNBT(tag[0]);
if (stack == null) {
throw new NullPointerException(
// the stack can be null if the placed item was
// an item that got removed in between mod updates
stack = new ItemStack(Blocks.stone);
this.invalidate();
LogHelper.error(
"Cannot load the Placed Item at location "
+ Vec3.createVectorHelper(this.xCoord, this.yCoord, this.zCoord)
+ " because the associated item is null!");
+ " because the associated item is null, it will be removed.");
}
rotation = compound.getFloat("Rotation");
}