Skip to content

Commit

Permalink
Added the NBT from TileEntities to the ItemStack when they drop in th…
Browse files Browse the repository at this point in the history
…e world. There may be a better fix, but until we refactor the protection it should work.
  • Loading branch information
MuresanSergiu committed Jul 20, 2015
1 parent 4f0ba2b commit d120bef
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/main/java/mytown/protection/Protections.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.server.MinecraftServer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumChatFormatting;
Expand Down Expand Up @@ -140,7 +141,11 @@ public void worldTick(TickEvent.WorldTickEvent ev) {
for (TileEntity te : (Iterable<TileEntity>) ev.world.loadedTileEntityList) {
for (Protection prot : protectionList) {
if (prot.isTileTracked(te.getClass()) && prot.checkTileEntity(te)) {
WorldUtils.dropAsEntity(te.getWorldObj(), te.xCoord, te.yCoord, te.zCoord, new ItemStack(te.getBlockType(), 1, te.getBlockMetadata()));
ItemStack itemStack = new ItemStack(te.getBlockType(), 1, te.getBlockMetadata());
NBTTagCompound nbt = new NBTTagCompound();
te.writeToNBT(nbt);
itemStack.setTagCompound(nbt);
WorldUtils.dropAsEntity(te.getWorldObj(), te.xCoord, te.yCoord, te.zCoord, itemStack);
te.getWorldObj().setBlock(te.xCoord, te.yCoord, te.zCoord, Blocks.air);
te.invalidate();
MyTown.instance.LOG.info("TileEntity {} was ATOMICALLY DISINTEGRATED!", te.toString());
Expand Down

0 comments on commit d120bef

Please sign in to comment.