From 959d878c629c6d90d7ba1be52ccc84a1498b69a3 Mon Sep 17 00:00:00 2001 From: David Vierra Date: Wed, 18 Jan 2017 16:22:11 -1000 Subject: [PATCH 01/10] Fix Charcoal Pile Igniter incorrectly comparing Blocks against IBlockStates --- .../multi/GT_MetaTileEntity_Charcoal_Pit.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_Charcoal_Pit.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_Charcoal_Pit.java index 18ea0a4f..3dbf7092 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_Charcoal_Pit.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_Charcoal_Pit.java @@ -11,6 +11,7 @@ import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_Recipe; import gregtech.common.tools.GT_Tool; import gregtech.common.GT_Pollution; +import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.EntityPlayer; @@ -140,7 +141,7 @@ public class GT_MetaTileEntity_Charcoal_Pit extends GT_MetaTileEntity_MultiBlock if (aX + 1 < 6 && (isWoodLog(tBlock))) { if (!aList1.contains(new BlockPos(aX + 1, aY, aZ)) && (!aList2.contains(new BlockPos(aX + 1, aY, aZ)))) p1 = true; - } else if (!(tBlock == Blocks.DIRT || tBlock == Blocks.GRASS)) { + } else if (!isDirt(tBlock)) { return false; } @@ -148,7 +149,7 @@ public class GT_MetaTileEntity_Charcoal_Pit extends GT_MetaTileEntity_MultiBlock if (aX - 1 > -6 && (isWoodLog(tBlock))) { if (!aList1.contains(new BlockPos(aX - 1, aY, aZ)) && (!aList2.contains(new BlockPos(aX - 1, aY, aZ)))) p2 = true; - } else if (!(tBlock == Blocks.DIRT || tBlock == Blocks.GRASS)) { + } else if (!isDirt(tBlock)) { return false; } @@ -156,7 +157,7 @@ public class GT_MetaTileEntity_Charcoal_Pit extends GT_MetaTileEntity_MultiBlock if (aY + 1 < 1 && (isWoodLog(tBlock))) { if (!aList1.contains(new BlockPos(aX, aY + 1, aZ)) && (!aList2.contains(new BlockPos(aX, aY + 1, aZ)))) p3 = true; - } else if (!(tBlock == Blocks.DIRT || tBlock == Blocks.GRASS || (aX == 0 && aY == -1 && aZ == 0 && tBlock == GregTech_API.sBlockMachines))) { + } else if (!(isDirt(tBlock) || (aX == 0 && aY == -1 && aZ == 0 && tBlock.getBlock() == GregTech_API.sBlockMachines))) { return false; } @@ -164,7 +165,7 @@ public class GT_MetaTileEntity_Charcoal_Pit extends GT_MetaTileEntity_MultiBlock if (aY - 1 > -6 && (isWoodLog(tBlock))) { if (!aList1.contains(new BlockPos(aX, aY - 1, aZ)) && (!aList2.contains(new BlockPos(aX, aY - 1, aZ)))) p4 = true; - } else if (tBlock != Blocks.BRICK_BLOCK) { + } else if (tBlock.getBlock() != Blocks.BRICK_BLOCK) { return false; } @@ -172,7 +173,7 @@ public class GT_MetaTileEntity_Charcoal_Pit extends GT_MetaTileEntity_MultiBlock if (aZ + 1 < 6 && (isWoodLog(tBlock))) { if (!aList1.contains(new BlockPos(aX, aY, aZ + 1)) && (!aList2.contains(new BlockPos(aX, aY, aZ + 1)))) p5 = true; - } else if (!(tBlock == Blocks.DIRT || tBlock == Blocks.GRASS)) { + } else if (!isDirt(tBlock)) { return false; } @@ -180,7 +181,7 @@ public class GT_MetaTileEntity_Charcoal_Pit extends GT_MetaTileEntity_MultiBlock if (aZ - 1 > -6 && (isWoodLog(tBlock))) { if (!aList1.contains(new BlockPos(aX, aY, aZ - 1)) && (!aList2.contains(new BlockPos(aX, aY, aZ - 1)))) p6 = true; - } else if (!(tBlock == Blocks.DIRT || tBlock == Blocks.GRASS)) { + } else if (!isDirt(tBlock)) { return false; } aList1.add(new BlockPos(aX, aY, aZ)); @@ -200,6 +201,11 @@ public class GT_MetaTileEntity_Charcoal_Pit extends GT_MetaTileEntity_MultiBlock (log.getMaterial() == Material.WOOD); } + private boolean isDirt(IBlockState dirt) { + Block b = dirt.getBlock(); + return (b == Blocks.DIRT || b == Blocks.GRASS); + } + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { mWrench = true; mScrewdriver = true; From 340c617797a91b86e94f94bf720c4bda5ce6c2bc Mon Sep 17 00:00:00 2001 From: David Vierra Date: Fri, 20 Jan 2017 21:18:49 -1000 Subject: [PATCH 02/10] Fix tool colors --- src/main/java/gregtech/api/items/GT_MetaGenerated_Tool.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/gregtech/api/items/GT_MetaGenerated_Tool.java b/src/main/java/gregtech/api/items/GT_MetaGenerated_Tool.java index c7d2925d..b80a4e30 100644 --- a/src/main/java/gregtech/api/items/GT_MetaGenerated_Tool.java +++ b/src/main/java/gregtech/api/items/GT_MetaGenerated_Tool.java @@ -712,7 +712,7 @@ public abstract class GT_MetaGenerated_Tool extends GT_MetaBase_Item implements @SideOnly(Side.CLIENT) public int getColorFromItemStack(ItemStack stack, int tintIndex) { IToolStats toolStats = getToolStats(stack); - if(tintIndex == 1) { + if(tintIndex > 1) { short[] colorsHead = toolStats.getRGBa(true, stack); if(colorsHead != null) return ITexture.color(colorsHead, true); From 2b80c158bc3ab209f496faed1bd0c8bac9475922 Mon Sep 17 00:00:00 2001 From: David Vierra Date: Fri, 20 Jan 2017 21:18:42 -1000 Subject: [PATCH 03/10] Fix crash rendering empty electric tool --- src/main/java/gregtech/api/items/GT_MetaGenerated_Tool.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main/java/gregtech/api/items/GT_MetaGenerated_Tool.java b/src/main/java/gregtech/api/items/GT_MetaGenerated_Tool.java index b80a4e30..84944153 100644 --- a/src/main/java/gregtech/api/items/GT_MetaGenerated_Tool.java +++ b/src/main/java/gregtech/api/items/GT_MetaGenerated_Tool.java @@ -511,10 +511,8 @@ public abstract class GT_MetaGenerated_Tool extends GT_MetaBase_Item implements } public IToolStats getToolStats(ItemStack aStack) { - if(isItemStackUsable(aStack)) { - return getToolStatsInternal(aStack); - } - return null; + // if(isItemStackUsable(aStack)) { // why? + return getToolStatsInternal(aStack); } private IToolStats getToolStatsInternal(ItemStack aStack) { From a6b4cfa3f47436dfc7169930d2017355c9f38f0a Mon Sep 17 00:00:00 2001 From: David Vierra Date: Wed, 18 Jan 2017 22:05:01 -1000 Subject: [PATCH 04/10] Remove spam in GregTech_API.registerCover --- src/main/java/gregtech/api/GregTech_API.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/gregtech/api/GregTech_API.java b/src/main/java/gregtech/api/GregTech_API.java index 97692443..b0896072 100644 --- a/src/main/java/gregtech/api/GregTech_API.java +++ b/src/main/java/gregtech/api/GregTech_API.java @@ -373,7 +373,6 @@ public class GregTech_API { GT_ItemStack stack = new GT_ItemStack(aStack); int coverId = stack.hashCode(); sCoverItems.put(stack, coverId); - System.out.println(); sCovers.put(coverId, aCover == null || !aCover.isValidTexture() ? Textures.BlockIcons.ERROR_RENDERING[0] : aCover); if (aBehavior != null) sCoverBehaviors.put(coverId, aBehavior); } From 9353ef19bdba650b4e5ac486abe89e5d2b90f12c Mon Sep 17 00:00:00 2001 From: David Vierra Date: Mon, 23 Jan 2017 02:46:21 -1000 Subject: [PATCH 05/10] Fix OilDrill and AdvMiner drilling through bedrock IC2 doesn't allow us to get an ItemStack for the mining_pipe_tip, so we grab the IBlockState instead. --- .../multi/GT_MetaTileEntity_AdvMiner2.java | 48 +++++++++--------- .../multi/GT_MetaTileEntity_OilDrill.java | 49 ++++++++++--------- 2 files changed, 49 insertions(+), 48 deletions(-) diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AdvMiner2.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AdvMiner2.java index 4784a015..e37a6949 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AdvMiner2.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AdvMiner2.java @@ -34,8 +34,9 @@ import java.util.List; public class GT_MetaTileEntity_AdvMiner2 extends GT_MetaTileEntity_MultiBlockBase { - private static final ItemStack mining_pipe = GT_ModHandler.getIC2Item(BlockName.mining_pipe, BlockMiningPipe.MiningPipeType.pipe, 1); - private static final ItemStack mining_pipe_tip = GT_ModHandler.getIC2Item(BlockName.mining_pipe, BlockMiningPipe.MiningPipeType.tip, 1); + private static final ItemStack mining_pipe_item = GT_ModHandler.getIC2Item(BlockName.mining_pipe, BlockMiningPipe.MiningPipeType.pipe, 1); + private static final IBlockState mining_pipe = GT_ModHandler.getIC2BlockState(BlockName.mining_pipe, BlockMiningPipe.MiningPipeType.pipe); + private static final IBlockState mining_pipe_tip = GT_ModHandler.getIC2BlockState(BlockName.mining_pipe, BlockMiningPipe.MiningPipeType.tip); private final ArrayList mMineList = new ArrayList(); @@ -74,15 +75,15 @@ public class GT_MetaTileEntity_AdvMiner2 extends GT_MetaTileEntity_MultiBlockBas @Override public boolean checkRecipe(ItemStack aStack) { - if (mInventory[1] == null || (mInventory[1].isItemEqual(mining_pipe) && mInventory[1].stackSize < mInventory[1].getMaxStackSize())) { + if (mInventory[1] == null || (mInventory[1].isItemEqual(mining_pipe_item) && mInventory[1].stackSize < mInventory[1].getMaxStackSize())) { ArrayList tItems = getStoredInputs(); for (ItemStack tStack : tItems) { - if (tStack.isItemEqual(mining_pipe)) { + if (tStack.isItemEqual(mining_pipe_item)) { tStack.stackSize--; if (tStack.stackSize < 1) { } if (mInventory[1] == null) { - mInventory[1] = mining_pipe; + mInventory[1] = mining_pipe_item; } else { mInventory[1].stackSize++; } @@ -225,7 +226,7 @@ public class GT_MetaTileEntity_AdvMiner2 extends GT_MetaTileEntity_MultiBlockBas private boolean moveOneDown() { if ((this.mInventory[1] == null) || (this.mInventory[1].stackSize < 1) - || (!GT_Utility.areStacksEqual(this.mInventory[1], mining_pipe))) { + || (!GT_Utility.areStacksEqual(this.mInventory[1], mining_pipe_item))) { stopMachine(); return false; } @@ -241,39 +242,38 @@ public class GT_MetaTileEntity_AdvMiner2 extends GT_MetaTileEntity_MultiBlockBas return false; } if (!(getBaseMetaTileEntity().getWorldObj().setBlockState( - new BlockPos(getBaseMetaTileEntity().getXCoord() + xDir, yHead - 1, getBaseMetaTileEntity().getZCoord() + zDir), - GT_Utility.getBlockFromStack(mining_pipe_tip).getDefaultState()))) { + new BlockPos(getBaseMetaTileEntity().getXCoord() + xDir, yHead - 1, getBaseMetaTileEntity().getZCoord() + zDir), mining_pipe_tip))) { stopMachine(); return false; } if (yHead != getBaseMetaTileEntity().getYCoord()) { getBaseMetaTileEntity().getWorldObj().setBlockState( - new BlockPos(getBaseMetaTileEntity().getXCoord() + xDir, yHead, getBaseMetaTileEntity().getZCoord() + zDir), - GT_Utility.getBlockFromStack(mining_pipe).getDefaultState()); + new BlockPos(getBaseMetaTileEntity().getXCoord() + xDir, yHead, getBaseMetaTileEntity().getZCoord() + zDir), mining_pipe); } getBaseMetaTileEntity().decrStackSize(1, 1); return true; } private int getYOfPumpHead() { - int xDir = EnumFacing.VALUES[getBaseMetaTileEntity().getBackFacing()].getFrontOffsetX(); - int zDir = EnumFacing.VALUES[getBaseMetaTileEntity().getBackFacing()].getFrontOffsetZ(); - int y = getBaseMetaTileEntity().getYCoord() - 1; - while (getBaseMetaTileEntity().getBlock(getBaseMetaTileEntity().getXCoord() + xDir, y, getBaseMetaTileEntity().getZCoord() + zDir) == GT_Utility.getBlockFromStack(mining_pipe)) { - y--; + BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos(getBaseMetaTileEntity().getWorldPos()); + pos.move(EnumFacing.VALUES[getBaseMetaTileEntity().getBackFacing()]); + pos.move(EnumFacing.DOWN); + + while (getBaseMetaTileEntity().getBlockState(pos).equals(mining_pipe)) { + pos.move(EnumFacing.DOWN); } - if (y == getBaseMetaTileEntity().getYCoord() - 1) { - if (getBaseMetaTileEntity().getBlock(getBaseMetaTileEntity().getXCoord() + xDir, y, getBaseMetaTileEntity().getZCoord() + zDir) != GT_Utility.getBlockFromStack(mining_pipe_tip)) { - return y + 1; + if (pos.getY() == getBaseMetaTileEntity().getYCoord() - 1) { + if (!getBaseMetaTileEntity().getBlockState(pos).equals(mining_pipe_tip)) { + return pos.getY() + 1; } - } else if (getBaseMetaTileEntity().getBlock(getBaseMetaTileEntity().getXCoord() + xDir, y, getBaseMetaTileEntity().getZCoord() + zDir) != GT_Utility - .getBlockFromStack(mining_pipe_tip) && this.mInventory[1] != null && this.mInventory[1].stackSize > 0 && GT_Utility.areStacksEqual(this.mInventory[1], mining_pipe)) { - getBaseMetaTileEntity().getWorldObj().setBlockState( - new BlockPos(getBaseMetaTileEntity().getXCoord() + xDir, y, getBaseMetaTileEntity().getZCoord() + zDir), - GT_Utility.getBlockFromStack(mining_pipe_tip).getDefaultState()); + } else if (!getBaseMetaTileEntity().getBlockState(pos).equals(mining_pipe_tip) + && this.mInventory[1] != null + && this.mInventory[1].stackSize > 0 + && GT_Utility.areStacksEqual(this.mInventory[1], mining_pipe_item)) { + getBaseMetaTileEntity().getWorldObj().setBlockState(pos, mining_pipe_tip); getBaseMetaTileEntity().decrStackSize(0, 1); } - return y; + return pos.getY(); } @Override diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrill.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrill.java index 4bc30c9e..e2cb8bae 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrill.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrill.java @@ -12,6 +12,7 @@ import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_Utility; import ic2.core.block.machine.BlockMiningPipe; import ic2.core.ref.BlockName; +import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; @@ -23,8 +24,9 @@ import java.util.ArrayList; public class GT_MetaTileEntity_OilDrill extends GT_MetaTileEntity_MultiBlockBase { - private static final ItemStack mining_pipe = GT_ModHandler.getIC2Item(BlockName.mining_pipe, BlockMiningPipe.MiningPipeType.pipe, 1); - private static final ItemStack mining_pipe_tip = GT_ModHandler.getIC2Item(BlockName.mining_pipe, BlockMiningPipe.MiningPipeType.tip, 1); + private static final ItemStack mining_pipe_item = GT_ModHandler.getIC2Item(BlockName.mining_pipe, BlockMiningPipe.MiningPipeType.pipe, 1); + private static final IBlockState mining_pipe = GT_ModHandler.getIC2BlockState(BlockName.mining_pipe, BlockMiningPipe.MiningPipeType.pipe); + private static final IBlockState mining_pipe_tip = GT_ModHandler.getIC2BlockState(BlockName.mining_pipe, BlockMiningPipe.MiningPipeType.tip); private boolean completedCycle = false; @@ -61,10 +63,10 @@ public class GT_MetaTileEntity_OilDrill extends GT_MetaTileEntity_MultiBlockBase @Override public boolean checkRecipe(ItemStack aStack) { - if (mInventory[1] == null || (mInventory[1].isItemEqual(mining_pipe) && mInventory[1].stackSize < mInventory[1].getMaxStackSize())) { + if (mInventory[1] == null || (mInventory[1].isItemEqual(mining_pipe_item) && mInventory[1].stackSize < mInventory[1].getMaxStackSize())) { ArrayList tItems = getStoredInputs(); for (ItemStack tStack : tItems) { - if (tStack.isItemEqual(mining_pipe)) { + if (tStack.isItemEqual(mining_pipe_item)) { if (tStack.stackSize < 2) { tStack = null; } else { @@ -73,7 +75,7 @@ public class GT_MetaTileEntity_OilDrill extends GT_MetaTileEntity_MultiBlockBase } if (mInventory[1] == null) { - mInventory[1] = mining_pipe; + mInventory[1] = mining_pipe_item; } else { mInventory[1].stackSize++; } @@ -126,7 +128,7 @@ public class GT_MetaTileEntity_OilDrill extends GT_MetaTileEntity_MultiBlockBase private boolean moveOneDown() { if ((this.mInventory[1] == null) || (this.mInventory[1].stackSize < 1) - || (!GT_Utility.areStacksEqual(this.mInventory[1], mining_pipe))) { + || (!GT_Utility.areStacksEqual(this.mInventory[1], mining_pipe_item))) { return false; } int xDir = EnumFacing.VALUES[getBaseMetaTileEntity().getBackFacing()].getFrontOffsetX(); @@ -139,38 +141,37 @@ public class GT_MetaTileEntity_OilDrill extends GT_MetaTileEntity_MultiBlockBase return false; } if (!(getBaseMetaTileEntity().getWorldObj().setBlockState( - new BlockPos(getBaseMetaTileEntity().getXCoord() + xDir, yHead - 1, getBaseMetaTileEntity().getZCoord() + zDir), - GT_Utility.getBlockFromStack(mining_pipe_tip).getDefaultState()))) { + new BlockPos(getBaseMetaTileEntity().getXCoord() + xDir, yHead - 1, getBaseMetaTileEntity().getZCoord() + zDir), mining_pipe_tip))) { return false; } if (yHead != getBaseMetaTileEntity().getYCoord()) { getBaseMetaTileEntity().getWorldObj().setBlockState( - new BlockPos(getBaseMetaTileEntity().getXCoord() + xDir, yHead, getBaseMetaTileEntity().getZCoord() + zDir), - GT_Utility.getBlockFromStack(mining_pipe).getDefaultState()); + new BlockPos(getBaseMetaTileEntity().getXCoord() + xDir, yHead, getBaseMetaTileEntity().getZCoord() + zDir), mining_pipe); } getBaseMetaTileEntity().decrStackSize(1, 1); return true; } private int getYOfPumpHead() { - int xDir = EnumFacing.VALUES[getBaseMetaTileEntity().getBackFacing()].getFrontOffsetX(); - int zDir = EnumFacing.VALUES[getBaseMetaTileEntity().getBackFacing()].getFrontOffsetZ(); - int y = getBaseMetaTileEntity().getYCoord() - 1; - while (getBaseMetaTileEntity().getBlock(getBaseMetaTileEntity().getXCoord() + xDir, y, getBaseMetaTileEntity().getZCoord() + zDir) == GT_Utility.getBlockFromStack(mining_pipe)) { - y--; + BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos(getBaseMetaTileEntity().getWorldPos()); + pos.move(EnumFacing.VALUES[getBaseMetaTileEntity().getBackFacing()]); + pos.move(EnumFacing.DOWN); + + while (getBaseMetaTileEntity().getBlockState(pos).equals(mining_pipe)) { + pos.move(EnumFacing.DOWN); } - if (y == getBaseMetaTileEntity().getYCoord() - 1) { - if (getBaseMetaTileEntity().getBlock(getBaseMetaTileEntity().getXCoord() + xDir, y, getBaseMetaTileEntity().getZCoord() + zDir) != GT_Utility.getBlockFromStack(mining_pipe_tip)) { - return y + 1; + if (pos.getY() == getBaseMetaTileEntity().getYCoord() - 1) { + if (!getBaseMetaTileEntity().getBlockState(pos).equals(mining_pipe_tip)) { + return pos.getY() + 1; } - } else if (getBaseMetaTileEntity().getBlock(getBaseMetaTileEntity().getXCoord() + xDir, y, getBaseMetaTileEntity().getZCoord() + zDir) != GT_Utility - .getBlockFromStack(mining_pipe_tip) && this.mInventory[1] != null && this.mInventory[1].stackSize > 0 && GT_Utility.areStacksEqual(this.mInventory[1], mining_pipe)) { - getBaseMetaTileEntity().getWorldObj().setBlockState( - new BlockPos(getBaseMetaTileEntity().getXCoord() + xDir, y, getBaseMetaTileEntity().getZCoord() + zDir), - GT_Utility.getBlockFromStack(mining_pipe_tip).getDefaultState()); + } else if (!getBaseMetaTileEntity().getBlockState(pos).equals(mining_pipe_tip) + && this.mInventory[1] != null + && this.mInventory[1].stackSize > 0 + && GT_Utility.areStacksEqual(this.mInventory[1], mining_pipe_item)) { + getBaseMetaTileEntity().getWorldObj().setBlockState(pos, mining_pipe_tip); getBaseMetaTileEntity().decrStackSize(0, 1); } - return y; + return pos.getY(); } @Override From 52c42c2d63a859ce1331d8135d3d083c0cfefc94 Mon Sep 17 00:00:00 2001 From: David Vierra Date: Mon, 23 Jan 2017 03:18:21 -1000 Subject: [PATCH 06/10] Fix position logic in AdvMiner.checkRecipe (again) --- .../multi/GT_MetaTileEntity_AdvMiner2.java | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AdvMiner2.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AdvMiner2.java index e37a6949..9e685023 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AdvMiner2.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AdvMiner2.java @@ -140,7 +140,6 @@ public class GT_MetaTileEntity_AdvMiner2 extends GT_MetaTileEntity_MultiBlockBas List tDrops = new ArrayList(); Block tMineBlock = null; BlockPos mle = null; - int posX, posY, posZ, offX, offY, offZ; while ((tMineBlock==null || tMineBlock == Blocks.AIR) && !mMineList.isEmpty()) { mle = mMineList.get(0); mMineList.remove(0); @@ -148,26 +147,24 @@ public class GT_MetaTileEntity_AdvMiner2 extends GT_MetaTileEntity_MultiBlockBas } if (tMineBlock!=null && tMineBlock!=Blocks.AIR) { - posX = mle.getX() + getBaseMetaTileEntity().getXCoord(); - posY = mle.getY() + getBaseMetaTileEntity().getYCoord(); - posZ = mle.getZ() + getBaseMetaTileEntity().getZCoord(); - offX = mle.getX(); - offY = mle.getY(); - offZ = mle.getZ(); + BlockPos pos = new BlockPos(mle.getX() + getBaseMetaTileEntity().getXCoord(), + mle.getY() + getBaseMetaTileEntity().getYCoord(), + mle.getZ() + getBaseMetaTileEntity().getZCoord()); - IBlockState metadata = getBaseMetaTileEntity().getWorldObj().getBlockState(mle); - boolean silkTouch = tMineBlock.canSilkHarvest(getBaseMetaTileEntity().getWorldObj(), new BlockPos(posX, posY, posZ), metadata, null); + + IBlockState blockState = getBaseMetaTileEntity().getWorldObj().getBlockState(pos); + boolean silkTouch = tMineBlock.canSilkHarvest(getBaseMetaTileEntity().getWorldObj(), pos, blockState, null); if (silkTouch){ ItemStack IS = new ItemStack(tMineBlock); - IS.setItemDamage(metadata.getBlock().getMetaFromState(metadata)); + IS.setItemDamage(blockState.getBlock().getMetaFromState(blockState)); IS.stackSize=1; tDrops.add(IS); } else{ - tDrops = tMineBlock.getDrops(getBaseMetaTileEntity().getWorldObj(), new BlockPos(posX, posY, posZ), metadata, 1); + tDrops = tMineBlock.getDrops(getBaseMetaTileEntity().getWorldObj(), pos, blockState, 1); } - getBaseMetaTileEntity().getWorldObj().setBlockToAir(getBaseMetaTileEntity().getWorldPos().add(posX, posY, posZ)); + getBaseMetaTileEntity().getWorldObj().setBlockToAir(pos); if (!tDrops.isEmpty()) { ItemData tData = GT_OreDictUnificator.getItemData(tDrops.get(0).copy()); if (tData.mPrefix != OrePrefixes.crushed && tData.mMaterial.mMaterial != Materials.Oilsands) { From bf3954e03181c09f1c22c5ba86f0a5b4879e012e Mon Sep 17 00:00:00 2001 From: David Vierra Date: Mon, 23 Jan 2017 21:27:54 -1000 Subject: [PATCH 07/10] Muffle an error when ItemRenderer is called with the wrong itemstack Occurs with RefinedStorage Patterns when holding shift to show pattern output, where the output is a GT generic item. The Pattern renderer can only replace the IBlockModel and not the ItemStack, so the ItemRenderer gets called with a stack of ItemPattern. Fixes raoulvdberge/refinedstorage/#914 --- src/main/java/gregtech/common/render/ItemRenderer.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/gregtech/common/render/ItemRenderer.java b/src/main/java/gregtech/common/render/ItemRenderer.java index 5fd05052..a9832de3 100644 --- a/src/main/java/gregtech/common/render/ItemRenderer.java +++ b/src/main/java/gregtech/common/render/ItemRenderer.java @@ -294,11 +294,13 @@ public class ItemRenderer { public void renderItem(ItemStack item) { if(item.getItem() instanceof ItemBlock) { renderItem(item, 0); - } else { + } else if (item.getItem() instanceof GT_Generic_Item) { GT_Generic_Item generic_item = (GT_Generic_Item) item.getItem(); for(int i = 0; i < generic_item.getRenderPasses(item); i++) { renderItem(item, i); } + } else { + return; } } From bd274f64b801f4f725acf97e121e11f103c73e37 Mon Sep 17 00:00:00 2001 From: David Vierra Date: Sun, 22 Jan 2017 23:01:12 -1000 Subject: [PATCH 08/10] Fix redstone behavior for covers Tested with Machine Controller and Energy Detector, should work for the rest too. --- .../api/interfaces/tileentity/IRedstoneEmitter.java | 6 ++++++ .../api/metatileentity/BaseMetaPipeEntity.java | 10 ++++++++-- .../api/metatileentity/BaseMetaTileEntity.java | 10 ++++++++-- .../gregtech/common/blocks/GT_Block_Machines.java | 12 +++++++++--- 4 files changed, 31 insertions(+), 7 deletions(-) diff --git a/src/main/java/gregtech/api/interfaces/tileentity/IRedstoneEmitter.java b/src/main/java/gregtech/api/interfaces/tileentity/IRedstoneEmitter.java index 5be185b4..97a2a12b 100644 --- a/src/main/java/gregtech/api/interfaces/tileentity/IRedstoneEmitter.java +++ b/src/main/java/gregtech/api/interfaces/tileentity/IRedstoneEmitter.java @@ -34,4 +34,10 @@ public interface IRedstoneEmitter extends IHasWorldObjectAndCoords { * Gets the Output for the comparator on the given Side */ byte getComparatorValue(byte aSide); + + /** + * Return whether the TileEntity can output redstone to the given side. Used to visually connect + * vanilla redstone wires. + */ + boolean canOutputRedstone(byte aSide); } \ No newline at end of file diff --git a/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java b/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java index e12826e2..f43bd60f 100644 --- a/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java +++ b/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java @@ -293,7 +293,7 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE } if (mNeedsBlockUpdate) { - worldObj.notifyBlockOfStateChange(getPos(), getBlockType()); + worldObj.notifyNeighborsOfStateChange(getPos(), getBlockType()); mNeedsBlockUpdate = false; } } @@ -494,6 +494,12 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE return getInternalInputRedstoneSignal(aSide) > 0; } + @Override + public boolean canOutputRedstone(byte aSide) { + return (getCoverBehaviorAtSide(aSide).manipulatesSidedRedstoneOutput(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this) + || getCoverBehaviorAtSide(aSide).letsRedstoneGoOut(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this)); + } + public ITexture getCoverTexture(byte aSide) { return GregTech_API.sCovers.get(getCoverIDAtSide(aSide)); } @@ -1017,7 +1023,7 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE @Override public byte getInputRedstoneSignal(byte aSide) { - return (byte) (worldObj.getRedstonePower(getPos(), EnumFacing.VALUES[aSide]) & 15); + return (byte) (worldObj.getRedstonePower(getPos().offset(EnumFacing.VALUES[aSide]), EnumFacing.VALUES[aSide]) & 15); } @Override diff --git a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java index ba85b835..87eb8191 100644 --- a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java @@ -557,7 +557,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE } if (mNeedsBlockUpdate) { - worldObj.notifyBlockOfStateChange(getPos(), getBlockOffset(0, 0, 0)); + worldObj.notifyNeighborsOfStateChange(getPos(), getBlockOffset(0, 0, 0)); mNeedsBlockUpdate = false; } } @@ -734,6 +734,12 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE return getInternalInputRedstoneSignal(aSide) > 0; } + @Override + public boolean canOutputRedstone(byte aSide) { + return (getCoverBehaviorAtSide(aSide).manipulatesSidedRedstoneOutput(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this) + || getCoverBehaviorAtSide(aSide).letsRedstoneGoOut(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this)); + } + public ITexture getCoverTexture(byte aSide) { return GregTech_API.sCovers.get(getCoverIDAtSide(aSide)); } @@ -1437,7 +1443,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE @Override public byte getInputRedstoneSignal(byte aSide) { - return (byte) (worldObj.getRedstonePower(getPos(), EnumFacing.VALUES[aSide]) & 15); + return (byte) (worldObj.getRedstonePower(getPos().offset(EnumFacing.VALUES[aSide]), EnumFacing.VALUES[aSide]) & 15); } @Override 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 09ead87a..6eeed06f 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Machines.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Machines.java @@ -137,9 +137,15 @@ public class GT_Block_Machines extends GT_Generic_Block implements IDebugableBlo return false; } + /** + * NB: Vanilla redstone behavior is that wires will connect to redstone emitters but not consumers. + * Thus we only say we can connect if we are an emitter. (This is usually delegated to a cover behavior.) + * + */ @Override public boolean canConnectRedstone(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing side) { - return true; + IGregTechTileEntity gregTechTileEntity = getGregTile(world, pos); + return gregTechTileEntity != null && gregTechTileEntity.canOutputRedstone((byte) side.getOpposite().getIndex()); } @Override @@ -356,7 +362,7 @@ public class GT_Block_Machines extends GT_Generic_Block implements IDebugableBlo public int getWeakPower(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) { IGregTechTileEntity gregTechTileEntity = getGregTile(blockAccess, pos); if(gregTechTileEntity != null) { - gregTechTileEntity.getOutputRedstoneSignal((byte) side.getIndex()); + return gregTechTileEntity.getOutputRedstoneSignal((byte) side.getOpposite().getIndex()); } return 0; } @@ -365,7 +371,7 @@ public class GT_Block_Machines extends GT_Generic_Block implements IDebugableBlo public int getStrongPower(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) { IGregTechTileEntity gregTechTileEntity = getGregTile(blockAccess, pos); if(gregTechTileEntity != null) { - gregTechTileEntity.getStrongOutputRedstoneSignal((byte) side.getIndex()); + return gregTechTileEntity.getStrongOutputRedstoneSignal((byte) side.getOpposite().getIndex()); } return 0; } From 721f417a7c743932e798002d0df686dea160b599 Mon Sep 17 00:00:00 2001 From: David Vierra Date: Wed, 18 Jan 2017 23:08:59 -1000 Subject: [PATCH 09/10] Fixed machine sounds --- src/main/java/gregtech/api/GregTech_API.java | 60 ++++++++++++------- .../api/metatileentity/BaseTileEntity.java | 10 +++- .../gregtech/api/net/GT_PacketHandler.java | 1 + .../api/net/GT_Packet_Block_Event.java | 55 +++++++++++++++++ .../api/threads/GT_Runnable_Sound.java | 3 +- 5 files changed, 103 insertions(+), 26 deletions(-) create mode 100644 src/main/java/gregtech/api/net/GT_Packet_Block_Event.java diff --git a/src/main/java/gregtech/api/GregTech_API.java b/src/main/java/gregtech/api/GregTech_API.java index b0896072..f00570e2 100644 --- a/src/main/java/gregtech/api/GregTech_API.java +++ b/src/main/java/gregtech/api/GregTech_API.java @@ -23,6 +23,8 @@ import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.SoundEvent; import net.minecraft.world.World; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fml.relauncher.Side; @@ -219,8 +221,11 @@ public class GregTech_API { /** * Adds Biomes to the Biome Lists for World Generation */ + + private static int size = 0; /* Used to assign Minecraft IDs to our SoundEvents. We don't use them. */ static { sItemStackMappings.add(sCoverItems); + size = SoundEvent.REGISTRY.getKeys().size(); sDimensionalList.add(-1); sDimensionalList.add(0); @@ -230,33 +235,42 @@ public class GregTech_API { sSoundList.put(1, "block.anvil.use");//SoundEvents.BLOCK_ANVIL_USE.getSoundName().toString()); sSoundList.put(2, "block.anvil.break");//SoundEvents.BLOCK_ANVIL_BREAK.getSoundName().toString()); sSoundList.put(3, "block.stone_button.click_on");//SoundEvents.BLOCK_STONE_BUTTON_CLICK_ON.getSoundName().toString()); - sSoundList.put(4, "entity.item.break");//SoundEvents.ENTITY_ITEM_BREAK.getSoundName().toString()); + sSoundList.put(4, "block.fire.extinguish");//SoundEvents.ENTITY_ITEM_BREAK.getSoundName().toString()); sSoundList.put(5, "entity.generic.explode");//SoundEvents.ENTITY_GENERIC_EXPLODE.getSoundName().toString()); sSoundList.put(6, "item.firecharge.use");//SoundEvents.ITEM_FIRECHARGE_USE.getSoundName().toString()); - sSoundList.put(100, aTextIC2Lower + ":" + "tools.Wrench"); - sSoundList.put(101, aTextIC2Lower + ":" + "tools.RubberTrampoline"); - sSoundList.put(102, aTextIC2Lower + ":" + "tools.Painter"); - sSoundList.put(103, aTextIC2Lower + ":" + "tools.BatteryUse"); - sSoundList.put(104, aTextIC2Lower + ":" + "tools.chainsaw.ChainsawUseOne"); - sSoundList.put(105, aTextIC2Lower + ":" + "tools.chainsaw.ChainsawUseTwo"); - sSoundList.put(106, aTextIC2Lower + ":" + "tools.drill.DrillSoft"); - sSoundList.put(107, aTextIC2Lower + ":" + "tools.drill.DrillHard"); - sSoundList.put(108, aTextIC2Lower + ":" + "tools.ODScanner"); + registerSound(100, aTextIC2Lower + ":" + "tools.Wrench"); + registerSound(101, aTextIC2Lower + ":" + "tools.RubberTrampoline"); + registerSound(102, aTextIC2Lower + ":" + "tools.Painter"); + registerSound(103, aTextIC2Lower + ":" + "tools.BatteryUse"); + registerSound(104, aTextIC2Lower + ":" + "tools.chainsaw.ChainsawUseOne"); + registerSound(105, aTextIC2Lower + ":" + "tools.chainsaw.ChainsawUseTwo"); + registerSound(106, aTextIC2Lower + ":" + "tools.drill.DrillSoft"); + registerSound(107, aTextIC2Lower + ":" + "tools.drill.DrillHard"); + registerSound(108, aTextIC2Lower + ":" + "tools.ODScanner"); - sSoundList.put(200, aTextIC2Lower + ":" + "machines.ExtractorOp"); - sSoundList.put(201, aTextIC2Lower + ":" + "machines.MaceratorOp"); - sSoundList.put(202, aTextIC2Lower + ":" + "machines.InductionLoop"); - sSoundList.put(203, aTextIC2Lower + ":" + "machines.CompressorOp"); - sSoundList.put(204, aTextIC2Lower + ":" + "machines.RecyclerOp"); - sSoundList.put(205, aTextIC2Lower + ":" + "machines.MinerOp"); - sSoundList.put(206, aTextIC2Lower + ":" + "machines.PumpOp"); - sSoundList.put(207, aTextIC2Lower + ":" + "machines.ElectroFurnaceLoop"); - sSoundList.put(208, aTextIC2Lower + ":" + "machines.InductionLoop"); - sSoundList.put(209, aTextIC2Lower + ":" + "machines.MachineOverload"); - sSoundList.put(210, aTextIC2Lower + ":" + "machines.InterruptOne"); - sSoundList.put(211, aTextIC2Lower + ":" + "machines.KaChing"); - sSoundList.put(212, aTextIC2Lower + ":" + "machines.MagnetizerLoop"); + registerSound(200, aTextIC2Lower + ":" + "machines.ExtractorOp"); + registerSound(201, aTextIC2Lower + ":" + "machines.MaceratorOp"); + registerSound(202, aTextIC2Lower + ":" + "machines.InductionLoop"); + registerSound(203, aTextIC2Lower + ":" + "machines.CompressorOp"); + registerSound(204, aTextIC2Lower + ":" + "machines.RecyclerOp"); + registerSound(205, aTextIC2Lower + ":" + "machines.MinerOp"); + registerSound(206, aTextIC2Lower + ":" + "machines.PumpOp"); + registerSound(207, aTextIC2Lower + ":" + "machines.ElectroFurnaceLoop"); + registerSound(208, aTextIC2Lower + ":" + "machines.InductionLoop"); + registerSound(209, aTextIC2Lower + ":" + "machines.MachineOverload"); + registerSound(210, aTextIC2Lower + ":" + "machines.InterruptOne"); + registerSound(211, aTextIC2Lower + ":" + "machines.KaChing"); + registerSound(212, aTextIC2Lower + ":" + "machines.MagnetizerLoop"); + } + + public static void registerSound(int id, String name) { + ResourceLocation loc = new ResourceLocation(name); + SoundEvent e = new SoundEvent(loc); + if(!SoundEvent.REGISTRY.containsKey(loc)) { + SoundEvent.REGISTRY.register(size++, loc, e); + } + sSoundList.put(id, name); } /** diff --git a/src/main/java/gregtech/api/metatileentity/BaseTileEntity.java b/src/main/java/gregtech/api/metatileentity/BaseTileEntity.java index e31d96cc..503cc4cf 100644 --- a/src/main/java/gregtech/api/metatileentity/BaseTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/BaseTileEntity.java @@ -2,6 +2,7 @@ package gregtech.api.metatileentity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.interfaces.tileentity.IHasWorldObjectAndCoords; +import gregtech.api.net.GT_Packet_Block_Event; import gregtech.api.util.GT_Utility; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; @@ -472,7 +473,14 @@ public abstract class BaseTileEntity extends TileEntity implements IHasWorldObje @Override public final void sendBlockEvent(byte aID, byte aValue) { - //NW.sendPacketToAllPlayersInRange(worldObj, new GT_Packet_Block_Event(getXCoord(), (short) getYCoord(), getZCoord(), aID, aValue), getXCoord(), getZCoord()); + NW.sendToAllAround(worldObj, new GT_Packet_Block_Event(getXCoord(), + (short) getYCoord(), + getZCoord(), + aID, + aValue), + getXCoord(), + getYCoord(), + getZCoord()); } private boolean crossedChunkBorder(int aX, int aZ) { diff --git a/src/main/java/gregtech/api/net/GT_PacketHandler.java b/src/main/java/gregtech/api/net/GT_PacketHandler.java index c68fa97f..4976411d 100644 --- a/src/main/java/gregtech/api/net/GT_PacketHandler.java +++ b/src/main/java/gregtech/api/net/GT_PacketHandler.java @@ -14,6 +14,7 @@ public class GT_PacketHandler extends SimpleNetworkWrapper { super("gregtech_network"); registerMessage(0, GT_Packet_TileEntity.class, Side.CLIENT); registerMessage(2, GT_Packet_Sound.class, Side.CLIENT); + registerMessage(3, GT_Packet_Block_Event.class, Side.CLIENT); } public void registerMessage(int discriminator, Class packet, Side handleSide) { diff --git a/src/main/java/gregtech/api/net/GT_Packet_Block_Event.java b/src/main/java/gregtech/api/net/GT_Packet_Block_Event.java new file mode 100644 index 00000000..23c90ca4 --- /dev/null +++ b/src/main/java/gregtech/api/net/GT_Packet_Block_Event.java @@ -0,0 +1,55 @@ +package gregtech.api.net; + +import com.google.common.io.ByteArrayDataInput; +import com.google.common.io.ByteArrayDataOutput; +import com.google.common.io.ByteStreams; +import io.netty.buffer.ByteBuf; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +/** + * Used to transfer Block Events in a much better fashion + */ +public class GT_Packet_Block_Event extends GT_Packet { + private int mX, mZ; + private short mY; + private byte mID, mValue; + + public GT_Packet_Block_Event() {} + + public GT_Packet_Block_Event(int aX, short aY, int aZ, byte aID, byte aValue) { + mX = aX; + mY = aY; + mZ = aZ; + mID = aID; + mValue = aValue; + } + + @Override + public void encode(ByteBuf buf) { + buf.writeInt(mX); + buf.writeShort(mY); + buf.writeInt(mZ); + buf.writeByte(mID); + buf.writeByte(mValue); + } + + @Override + public void decode(ByteBuf buf) { + mX = buf.readInt(); + mY = buf.readShort(); + mZ = buf.readInt(); + mID = buf.readByte(); + mValue = buf.readByte(); + } + + @Override + public void process(World aWorld) { + if (aWorld != null) { + TileEntity tTileEntity = aWorld.getTileEntity(new BlockPos(mX, mY, mZ)); + if (tTileEntity != null) tTileEntity.receiveClientEvent(mID, mValue); + } + } +} \ No newline at end of file diff --git a/src/main/java/gregtech/api/threads/GT_Runnable_Sound.java b/src/main/java/gregtech/api/threads/GT_Runnable_Sound.java index ec025435..5baebcdc 100644 --- a/src/main/java/gregtech/api/threads/GT_Runnable_Sound.java +++ b/src/main/java/gregtech/api/threads/GT_Runnable_Sound.java @@ -33,8 +33,7 @@ public class GT_Runnable_Sound implements Runnable { public void run() { SoundEvent soundEvent = SoundEvent.REGISTRY.getObject(mSoundLocation); if(soundEvent != null) { - PositionedSound sound = new PositionedSound(soundEvent, SoundCategory.BLOCKS) {}; - Minecraft.getMinecraft().getSoundHandler().playSound(sound); + mWorld.playSound((double)mX, (double)mY, (double)mZ, soundEvent, SoundCategory.BLOCKS, 1.0f, 1.0f, false); } } From 210504462cefc104ce606377d4e6cc3ddf033aab Mon Sep 17 00:00:00 2001 From: David Vierra Date: Sun, 22 Jan 2017 19:42:17 -1000 Subject: [PATCH 10/10] Make GT packets process on the server/client thread instead of netty --- .../java/gregtech/api/net/GT_PacketHandler.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/main/java/gregtech/api/net/GT_PacketHandler.java b/src/main/java/gregtech/api/net/GT_PacketHandler.java index 4976411d..c17a1127 100644 --- a/src/main/java/gregtech/api/net/GT_PacketHandler.java +++ b/src/main/java/gregtech/api/net/GT_PacketHandler.java @@ -1,6 +1,8 @@ package gregtech.api.net; import gregtech.GT_Mod; +import net.minecraft.client.Minecraft; +import net.minecraft.util.IThreadListener; import net.minecraft.world.World; import net.minecraftforge.fml.common.network.NetworkRegistry; import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler; @@ -33,11 +35,19 @@ public class GT_PacketHandler extends SimpleNetworkWrapper { @Override public GT_Packet onMessage(GT_Packet message, MessageContext ctx) { + IThreadListener listener; + World world; if(ctx.side == Side.SERVER) { - message.process(ctx.getServerHandler().playerEntity.worldObj); + world = ctx.getServerHandler().playerEntity.worldObj; + listener = world.getMinecraftServer(); } else { - message.process(GT_Mod.gregtechproxy.getThePlayer().worldObj); + world = GT_Mod.gregtechproxy.getThePlayer().worldObj; + listener = Minecraft.getMinecraft(); } + listener.addScheduledTask(() -> { + message.process(world); + }); + return null; } }