From 041fefe81ab873ae02d912e612d94dce676fa000 Mon Sep 17 00:00:00 2001 From: Alexdoru <57050655+Alexdoru@users.noreply.github.com> Date: Thu, 24 Oct 2024 20:09:15 +0200 Subject: [PATCH] remove bugged PlacedItem tile entities properly (#55) --- .../common/tileentities/TilePlacedItem.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TilePlacedItem.java b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TilePlacedItem.java index 996361cb..be9994e1 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TilePlacedItem.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TilePlacedItem.java @@ -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"); }