diff options
Diffstat (limited to 'src/main/java/gregtech/common')
3 files changed, 72 insertions, 41 deletions
diff --git a/src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_InputBus_ME.java b/src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_InputBus_ME.java index 11c219aee9..36b20acc55 100644 --- a/src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_InputBus_ME.java +++ b/src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_InputBus_ME.java @@ -61,6 +61,7 @@ import appeng.util.item.AEItemStack; import gregtech.api.enums.ItemList; import gregtech.api.gui.modularui.GT_UITextures; import gregtech.api.interfaces.IConfigurationCircuitSupport; +import gregtech.api.interfaces.IDataCopyable; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.modularui.IAddGregtechLogo; import gregtech.api.interfaces.modularui.IAddUIWidgets; @@ -80,9 +81,10 @@ import mcp.mobius.waila.api.IWailaDataAccessor; public class GT_MetaTileEntity_Hatch_InputBus_ME extends GT_MetaTileEntity_Hatch_InputBus implements IConfigurationCircuitSupport, IRecipeProcessingAwareHatch, IAddGregtechLogo, IAddUIWidgets, - IPowerChannelState, ISmartInputHatch { + IPowerChannelState, ISmartInputHatch, IDataCopyable { private static final int SLOT_COUNT = 16; + public static final String COPIED_DATA_IDENTIFIER = "stockingBus"; private BaseActionSource requestSource = null; private @Nullable AENetworkProxy gridProxy = null; private final ItemStack[] shadowInventory = new ItemStack[SLOT_COUNT]; @@ -318,12 +320,35 @@ public class GT_MetaTileEntity_Hatch_InputBus_ME extends GT_MetaTileEntity_Hatch ItemStack dataStick = aPlayer.inventory.getCurrentItem(); if (!ItemList.Tool_DataStick.isStackEqual(dataStick, false, true)) return super.onRightclick(aBaseMetaTileEntity, aPlayer, side, aX, aY, aZ); - if (!dataStick.hasTagCompound() || !"stockingBus".equals(dataStick.stackTagCompound.getString("type"))) - return false; - NBTTagCompound nbt = dataStick.stackTagCompound; + if (!pasteCopiedData(aPlayer, dataStick.stackTagCompound)) return false; - ItemStack circuit = GT_Utility.loadItem(dataStick.stackTagCompound, "circuit"); + updateValidGridProxySides(); + aPlayer.addChatMessage(new ChatComponentTranslation("GT5U.machines.stocking_bus.loaded")); + return true; + } + + @Override + public void onLeftclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (!(aPlayer instanceof EntityPlayerMP)) return; + + ItemStack dataStick = aPlayer.inventory.getCurrentItem(); + if (!ItemList.Tool_DataStick.isStackEqual(dataStick, false, true)) return; + + dataStick.stackTagCompound = getCopiedData(aPlayer); + dataStick.setStackDisplayName("Stocking Input Bus Configuration"); + aPlayer.addChatMessage(new ChatComponentTranslation("GT5U.machines.stocking_bus.saved")); + } + + @Override + public String getCopiedDataIdentifier(EntityPlayer player) { + return COPIED_DATA_IDENTIFIER; + } + + @Override + public boolean pasteCopiedData(EntityPlayer player, NBTTagCompound nbt) { + if (nbt == null || !COPIED_DATA_IDENTIFIER.equals(nbt.getString("type"))) return false; + ItemStack circuit = GT_Utility.loadItem(nbt, "circuit"); if (GT_Utility.isStackInvalid(circuit)) circuit = null; if (autoPullAvailable) { @@ -344,20 +369,13 @@ public class GT_MetaTileEntity_Hatch_InputBus_ME extends GT_MetaTileEntity_Hatch } } setInventorySlotContents(getCircuitSlot(), circuit); - updateValidGridProxySides(); - aPlayer.addChatMessage(new ChatComponentTranslation("GT5U.machines.stocking_bus.loaded")); return true; } @Override - public void onLeftclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { - if (!(aPlayer instanceof EntityPlayerMP)) return; - - ItemStack dataStick = aPlayer.inventory.getCurrentItem(); - if (!ItemList.Tool_DataStick.isStackEqual(dataStick, false, true)) return; - + public NBTTagCompound getCopiedData(EntityPlayer player) { NBTTagCompound tag = new NBTTagCompound(); - tag.setString("type", "stockingBus"); + tag.setString("type", COPIED_DATA_IDENTIFIER); tag.setBoolean("autoPull", autoPullItemList); tag.setInteger("minStackSize", minAutoPullStackSize); tag.setInteger("refreshTime", autoPullRefreshTime); @@ -372,9 +390,7 @@ public class GT_MetaTileEntity_Hatch_InputBus_ME extends GT_MetaTileEntity_Hatch } tag.setTag("itemsToStock", stockingItems); } - dataStick.stackTagCompound = tag; - dataStick.setStackDisplayName("Stocking Input Bus Configuration"); - aPlayer.addChatMessage(new ChatComponentTranslation("GT5U.machines.stocking_bus.saved")); + return tag; } private int getManualSlot() { diff --git a/src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_Input_ME.java b/src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_Input_ME.java index b4266caa47..d59dbb9ce8 100644 --- a/src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_Input_ME.java +++ b/src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_Input_ME.java @@ -65,6 +65,7 @@ import appeng.me.helpers.IGridProxyable; import appeng.util.item.AEFluidStack; import gregtech.api.enums.ItemList; import gregtech.api.gui.modularui.GT_UITextures; +import gregtech.api.interfaces.IDataCopyable; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.modularui.IAddGregtechLogo; import gregtech.api.interfaces.modularui.IAddUIWidgets; @@ -81,10 +82,11 @@ import gregtech.api.util.shutdown.ShutDownReasonRegistry; import mcp.mobius.waila.api.IWailaConfigHandler; import mcp.mobius.waila.api.IWailaDataAccessor; -public class GT_MetaTileEntity_Hatch_Input_ME extends GT_MetaTileEntity_Hatch_Input - implements IPowerChannelState, IAddGregtechLogo, IAddUIWidgets, IRecipeProcessingAwareHatch, ISmartInputHatch { +public class GT_MetaTileEntity_Hatch_Input_ME extends GT_MetaTileEntity_Hatch_Input implements IPowerChannelState, + IAddGregtechLogo, IAddUIWidgets, IRecipeProcessingAwareHatch, ISmartInputHatch, IDataCopyable { private static final int SLOT_COUNT = 16; + public static final String COPIED_DATA_IDENTIFIER = "stockingHatch"; protected final FluidStack[] storedFluids = new FluidStack[SLOT_COUNT]; protected final FluidStack[] storedInformationFluids = new FluidStack[SLOT_COUNT]; @@ -565,17 +567,13 @@ public class GT_MetaTileEntity_Hatch_Input_ME extends GT_MetaTileEntity_Hatch_In } @Override - public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, ForgeDirection side, - float aX, float aY, float aZ) { - if (!(aPlayer instanceof EntityPlayerMP)) - return super.onRightclick(aBaseMetaTileEntity, aPlayer, side, aX, aY, aZ); - ItemStack dataStick = aPlayer.inventory.getCurrentItem(); - if (!ItemList.Tool_DataStick.isStackEqual(dataStick, false, true)) - return super.onRightclick(aBaseMetaTileEntity, aPlayer, side, aX, aY, aZ); - if (!dataStick.hasTagCompound() || !"stockingHatch".equals(dataStick.stackTagCompound.getString("type"))) - return false; + public String getCopiedDataIdentifier(EntityPlayer player) { + return COPIED_DATA_IDENTIFIER; + } - NBTTagCompound nbt = dataStick.stackTagCompound; + @Override + public boolean pasteCopiedData(EntityPlayer player, NBTTagCompound nbt) { + if (nbt == null || !COPIED_DATA_IDENTIFIER.equals(nbt.getString("type"))) return false; if (autoPullAvailable) { setAutoPullFluidList(nbt.getBoolean("autoPull")); @@ -590,21 +588,13 @@ public class GT_MetaTileEntity_Hatch_Input_ME extends GT_MetaTileEntity_Hatch_In storedFluids[i] = GT_Utility.loadFluid(stockingFluids.getCompoundTagAt(i)); } } - - updateValidGridProxySides(); - aPlayer.addChatMessage(new ChatComponentTranslation("GT5U.machines.stocking_bus.loaded")); return true; } @Override - public void onLeftclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { - if (!(aPlayer instanceof EntityPlayerMP)) return; - - ItemStack dataStick = aPlayer.inventory.getCurrentItem(); - if (!ItemList.Tool_DataStick.isStackEqual(dataStick, false, true)) return; - + public NBTTagCompound getCopiedData(EntityPlayer player) { NBTTagCompound tag = new NBTTagCompound(); - tag.setString("type", "stockingHatch"); + tag.setString("type", COPIED_DATA_IDENTIFIER); tag.setBoolean("autoPull", autoPullFluidList); tag.setInteger("minAmount", minAutoPullAmount); tag.setBoolean("additionalConnection", additionalConnection); @@ -621,7 +611,33 @@ public class GT_MetaTileEntity_Hatch_Input_ME extends GT_MetaTileEntity_Hatch_In } tag.setTag("fluidsToStock", stockingFluids); } - dataStick.stackTagCompound = tag; + return tag; + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, ForgeDirection side, + float aX, float aY, float aZ) { + if (!(aPlayer instanceof EntityPlayerMP)) + return super.onRightclick(aBaseMetaTileEntity, aPlayer, side, aX, aY, aZ); + ItemStack dataStick = aPlayer.inventory.getCurrentItem(); + if (!ItemList.Tool_DataStick.isStackEqual(dataStick, false, true)) + return super.onRightclick(aBaseMetaTileEntity, aPlayer, side, aX, aY, aZ); + + if (!pasteCopiedData(aPlayer, dataStick.stackTagCompound)) return false; + + updateValidGridProxySides(); + aPlayer.addChatMessage(new ChatComponentTranslation("GT5U.machines.stocking_bus.loaded")); + return true; + } + + @Override + public void onLeftclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (!(aPlayer instanceof EntityPlayerMP)) return; + + ItemStack dataStick = aPlayer.inventory.getCurrentItem(); + if (!ItemList.Tool_DataStick.isStackEqual(dataStick, false, true)) return; + + dataStick.stackTagCompound = getCopiedData(aPlayer); dataStick.setStackDisplayName("Stocking Input Hatch Configuration"); aPlayer.addChatMessage(new ChatComponentTranslation("GT5U.machines.stocking_bus.saved")); } diff --git a/src/main/java/gregtech/common/tools/GT_Tool_Wrench.java b/src/main/java/gregtech/common/tools/GT_Tool_Wrench.java index ae9f705b62..fbca109f21 100644 --- a/src/main/java/gregtech/common/tools/GT_Tool_Wrench.java +++ b/src/main/java/gregtech/common/tools/GT_Tool_Wrench.java @@ -212,7 +212,6 @@ public class GT_Tool_Wrench extends GT_Tool { try { LastEventFromThis = true; player.setSneaking(true); - final MovingObjectPosition movObjPosition = Platform.rayTrace(player, true, false); if (movObjPosition == null) { event.setCanceled(true); |