From 364d417a3eea8d79f7c5102dd13aabaaa809b525 Mon Sep 17 00:00:00 2001 From: Dream-Master Date: Sun, 7 Oct 2018 20:54:08 +0200 Subject: cherry pick 6a1b45f2be752afd77db32e011bbd1118949b8ae [6a1b45f] fix(blockmachines): persistency on harvest (#1498) This patch fixes persistency of NBT tags in machine item when machine block is harvested. Machines with an @Override on setItemNBT will now persist data correctly when harvested? Change fixes intended persistency behaviour of following machines: - Item buffers will persist screwdriver configured output stack size when harvested. - Item distributors will persist setings of items per face. --- .../java/gregtech/common/blocks/GT_Block_Machines.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src') diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Machines.java b/src/main/java/gregtech/common/blocks/GT_Block_Machines.java index e1c11e05df..36d32bca6d 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Machines.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Machines.java @@ -372,7 +372,22 @@ public class GT_Block_Machines } return mTemporaryTileEntity.get() == null ? new ArrayList() : ((IGregTechTileEntity) mTemporaryTileEntity.get()).getDrops(); } + @Override + public boolean removedByPlayer(World aWorld, EntityPlayer aPlayer, int aX, int aY, int aZ, boolean aWillHarvest) { + if (aWillHarvest) { + return true; // This delays deletion of the block until after getDrops + } else { + return super.removedByPlayer(aWorld, aPlayer, aX, aY, aZ, false); + } + } + @Override + public void harvestBlock(World aWorld, EntityPlayer aPlayer, int aX, int aY, int aZ, int aMeta) + { + super.harvestBlock(aWorld, aPlayer, aX, aY, aZ, aMeta); + aWorld.setBlockToAir(aX, aY, aZ); + } + public int getComparatorInputOverride(World aWorld, int aX, int aY, int aZ, int aSide) { TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); if (((tTileEntity instanceof IGregTechTileEntity))) { -- cgit