From 6a1b45f2be752afd77db32e011bbd1118949b8ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9a=20Gris?= Date: Sun, 7 Oct 2018 18:10:35 +0200 Subject: [PATCH] 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. --- .../common/blocks/GT_Block_Machines.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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 fa8c5eb8..9d4123af 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Machines.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Machines.java @@ -365,6 +365,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))) {