diff options
19 files changed, 1179 insertions, 99 deletions
diff --git a/changelogcurse.mustache b/changelogcurse.mustache index e4c3c66274..9d6ebd8572 100644 --- a/changelogcurse.mustache +++ b/changelogcurse.mustache @@ -4,6 +4,7 @@ {{#tags}} <br /> {{#commits}} +<br /> <p> [{{hash}}] | {{authorName}} | {{commitTime}} <br /> @@ -11,6 +12,7 @@ <br /> {{#messageBodyItems}} {{.}} +<br /> {{/messageBodyItems}} </p> {{/commits}} diff --git a/src/Java/gtPlusPlus/GTplusplus.java b/src/Java/gtPlusPlus/GTplusplus.java index 4d7643e0b0..6ea182f472 100644 --- a/src/Java/gtPlusPlus/GTplusplus.java +++ b/src/Java/gtPlusPlus/GTplusplus.java @@ -43,7 +43,9 @@ import gtPlusPlus.core.util.minecraft.*; import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.core.util.sys.GeoUtils; import gtPlusPlus.core.util.sys.NetworkUtils; +import gtPlusPlus.core.util.sys.SystemUtils; import gtPlusPlus.plugin.manager.Core_Manager; +import gtPlusPlus.xmod.gregtech.api.objects.GregtechBufferThread; import gtPlusPlus.xmod.gregtech.common.Meta_GT_Proxy; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtTools; @@ -160,19 +162,26 @@ public class GTplusplus implements ActionListener { } @EventHandler - public void serverStarting(final FMLServerStartingEvent event) { + public synchronized void serverStarting(final FMLServerStartingEvent event) { event.registerServerCommand(new CommandMath()); tryPatchTurbineTextures(); } @Mod.EventHandler - public void serverStopping(final FMLServerStoppingEvent event) { + public synchronized void serverStopping(final FMLServerStoppingEvent event) { //Chunkload Handler if (ChunkManager.mChunkLoaderManagerMap.size() > 0) { Logger.INFO("Clearing Chunk Loaders."); ChunkManager.clearInternalMaps(); } + if (GregtechBufferThread.mBufferThreadAllocation.size() > 0) { + for (GregtechBufferThread i : GregtechBufferThread.mBufferThreadAllocation.values()) { + i.destroy(); + } + SystemUtils.invokeGC(); + } + } @Override @@ -300,7 +309,7 @@ public class GTplusplus implements ActionListener { } String[] machineName = new String[] {"Centrifuge", "Electrolyzer", "Vacuum Freezer"}; for (int i=0;i<3;i++) { - Logger.INFO("[Recipe] Generated "+mValidCount[i]+" recipes for the Industrial "+machineName+". The original machine can process "+mOriginalCount[i]+" recipes, meaning "+mInvalidCount[i]+" are invalid for this Multiblock's processing in some way."); + Logger.INFO("[Recipe] Generated "+mValidCount[i]+" recipes for the Industrial "+machineName[i]+". The original machine can process "+mOriginalCount[i]+" recipes, meaning "+mInvalidCount[i]+" are invalid for this Multiblock's processing in some way."); } } diff --git a/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java b/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java index 1d4ebaaa0c..a274ccd378 100644 --- a/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java +++ b/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java @@ -106,7 +106,7 @@ public class COMPAT_HANDLER { //GregtechMiniRaFusion.run(); GregtechComponentAssembler.run(); GregtechTeslaTower.run(); - GregtechSuperTanks.run(); + GregtechSuperChests.run(); GregtechIndustrialFishPond.run(); GregtechTieredChunkloaders.run(); GregtechIndustrialExtruder.run(); @@ -116,6 +116,7 @@ public class COMPAT_HANDLER { GregtechAmazonWarehouse.run(); GregtechIndustrialCryogenicFreezer.run(); GregtechThaumcraftDevices.run(); + GregtechThreadedBuffers.run(); //New Horizons Content NewHorizonsAccelerator.run(); diff --git a/src/Java/gtPlusPlus/core/util/data/ArrayUtils.java b/src/Java/gtPlusPlus/core/util/data/ArrayUtils.java index 0c752c20e0..52316c8a43 100644 --- a/src/Java/gtPlusPlus/core/util/data/ArrayUtils.java +++ b/src/Java/gtPlusPlus/core/util/data/ArrayUtils.java @@ -8,13 +8,13 @@ import gtPlusPlus.api.objects.data.AutoMap; public class ArrayUtils { - public static Object[] expandArray(final Object[] someArray, final Object newValueToAdd) { - Object[] series = someArray; + public static <V> V[] expandArray(final V[] someArray, final V newValueToAdd) { + V[] series = someArray; series = addElement(series, newValueToAdd); return series; } - private static Object[] addElement(Object[] series, final Object newValueToAdd) { + private static <V> V[] addElement(V[] series, final V newValueToAdd) { series = Arrays.copyOf(series, series.length + 1); series[series.length - 1] = newValueToAdd; return series; diff --git a/src/Java/gtPlusPlus/core/util/sys/KeyboardUtils.java b/src/Java/gtPlusPlus/core/util/sys/KeyboardUtils.java index ba834e345e..ea87677ee2 100644 --- a/src/Java/gtPlusPlus/core/util/sys/KeyboardUtils.java +++ b/src/Java/gtPlusPlus/core/util/sys/KeyboardUtils.java @@ -7,17 +7,33 @@ import net.minecraft.client.Minecraft; public class KeyboardUtils { public static boolean isCtrlKeyDown(){ - // prioritize CONTROL, but allow OPTION as well on Mac (note: GuiScreen's isCtrlKeyDown only checks for the OPTION key on Mac) - boolean isCtrlKeyDown = Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) || Keyboard.isKeyDown(Keyboard.KEY_RCONTROL); - if (!isCtrlKeyDown && Minecraft.isRunningOnMac) - isCtrlKeyDown = Keyboard.isKeyDown(Keyboard.KEY_LMETA) || Keyboard.isKeyDown(Keyboard.KEY_RMETA); - - return isCtrlKeyDown; + try { + if (!Keyboard.isCreated()) { + return false; + } + // prioritize CONTROL, but allow OPTION as well on Mac (note: GuiScreen's isCtrlKeyDown only checks for the OPTION key on Mac) + boolean isCtrlKeyDown = Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) || Keyboard.isKeyDown(Keyboard.KEY_RCONTROL); + if (!isCtrlKeyDown && Minecraft.isRunningOnMac) + isCtrlKeyDown = Keyboard.isKeyDown(Keyboard.KEY_LMETA) || Keyboard.isKeyDown(Keyboard.KEY_RMETA); + + return isCtrlKeyDown; + } + catch (Throwable t) { + return false; + } } public static boolean isShiftKeyDown(){ - return Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT); - + try { + if (!Keyboard.isCreated()) { + return false; + } + return Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT); + } + catch (Throwable t) { + return false; + } + } - + } diff --git a/src/Java/gtPlusPlus/core/util/sys/SystemUtils.java b/src/Java/gtPlusPlus/core/util/sys/SystemUtils.java index efcfaf8d04..2788ba688e 100644 --- a/src/Java/gtPlusPlus/core/util/sys/SystemUtils.java +++ b/src/Java/gtPlusPlus/core/util/sys/SystemUtils.java @@ -14,6 +14,19 @@ public class SystemUtils { } } + /** + * Try invoke the runtime's Garbage Collector. + */ + public static void invokeGC() { + try { + Runtime r = Runtime.getRuntime(); + r.gc(); + } + catch (Throwable t) { + //Do nothing. + } + } + public static boolean isWindows() { return (getOSString().indexOf("win") >= 0); } diff --git a/src/Java/gtPlusPlus/xmod/eio/handler/HandlerTooltip_EIO.java b/src/Java/gtPlusPlus/xmod/eio/handler/HandlerTooltip_EIO.java index 788e4d6d9f..6d50f64e6d 100644 --- a/src/Java/gtPlusPlus/xmod/eio/handler/HandlerTooltip_EIO.java +++ b/src/Java/gtPlusPlus/xmod/eio/handler/HandlerTooltip_EIO.java @@ -17,15 +17,9 @@ import net.minecraftforge.event.entity.player.ItemTooltipEvent; public class HandlerTooltip_EIO { - private static volatile Item mIngot; - private static volatile ItemStack mPulsatingIron; - private static volatile ItemStack mConductiveIron; - private static volatile ItemStack mRedstoneAlloy; - private static volatile ItemStack mElectricalSteel; - private static volatile ItemStack mEnergeticAlloy; - private static volatile ItemStack mVibrantAlloy; - private static volatile ItemStack mSoularium; - private static volatile ItemStack mDarkIron; + private static Item mIngot; + Class oMainClass; + Class oIngotClass; @SubscribeEvent public void onItemTooltip(ItemTooltipEvent event){ @@ -36,19 +30,16 @@ public class HandlerTooltip_EIO { //If it is, reflect in. if (mIngot == null){ try { - Class<?> oMainClass = Class.forName("crazypants.enderio.EnderIO"); - Class<?> oIngotClass = Class.forName("crazypants.enderio.material.ItemAlloy"); + oMainClass = Class.forName("crazypants.enderio.EnderIO"); + oIngotClass = Class.forName("crazypants.enderio.material.ItemAlloy"); if (oMainClass != null && oIngotClass != null){ - Field oAlloyField = oMainClass.getDeclaredField("itemAlloy"); oAlloyField.setAccessible(true); Object oAlloy = oAlloyField.get(oMainClass); - if (oAlloy != null){ if (oIngotClass.isInstance(oAlloy) || Item.class.isInstance(oAlloy)){ mIngot = (Item) oAlloy; } - } } } @@ -56,77 +47,41 @@ public class HandlerTooltip_EIO { } } - try { - if (mIngot != null){ - //If the Item is an instance of ItemAlloy.class then proceed - if (Class.forName("crazypants.enderio.material.ItemAlloy").isInstance(event.itemStack.getItem()) || event.itemStack.getUnlocalizedName().toLowerCase().contains("item.itemAlloy")){ - - //If EIO Item Is not Null, see if the ItemStacks for the ingots are null - //if they stacks are null, set the stack using the item set via reflection. - //The meta data is based on the oridinals of the materials in the EIO enum. - - if (mElectricalSteel == null){ - mElectricalSteel = ItemUtils.simpleMetaStack(mIngot, 0, 1); - } - if (mEnergeticAlloy == null){ - mEnergeticAlloy = ItemUtils.simpleMetaStack(mIngot, 1, 1); - } - if (mVibrantAlloy == null){ - mVibrantAlloy = ItemUtils.simpleMetaStack(mIngot, 2, 1); - } - if (mRedstoneAlloy == null){ - mRedstoneAlloy = ItemUtils.simpleMetaStack(mIngot, 3, 1); - } - if (mConductiveIron == null){ - mConductiveIron = ItemUtils.simpleMetaStack(mIngot, 4, 1); - } - if (mPulsatingIron == null){ - mPulsatingIron = ItemUtils.simpleMetaStack(mIngot, 5, 1); - } - if (mDarkIron == null){ - mDarkIron = ItemUtils.simpleMetaStack(mIngot, 6, 1); - } - if (mSoularium == null){ - mSoularium = ItemUtils.simpleMetaStack(mIngot, 7, 1); - } + if (mIngot != null){ + //If the Item is an instance of ItemAlloy.class then proceed + if (event.itemStack.getItem() == mIngot || oIngotClass.isInstance(event.itemStack.getItem()) || event.itemStack.getUnlocalizedName().toLowerCase().contains("item.itemAlloy")){ - - //If stacks match, add a tooltip. - if (mIngot != null){ - if (event.itemStack.getItem() == mIngot){ - if (event.itemStack.getItemDamage() == 0){ - event.toolTip.add(MaterialEIO.ELECTRICAL_STEEL.vChemicalFormula); - } - else if (event.itemStack.getItemDamage() == 1){ - event.toolTip.add(MaterialEIO.ENERGETIC_ALLOY.vChemicalFormula); - } - else if (event.itemStack.getItemDamage() == 2){ - event.toolTip.add(MaterialEIO.VIBRANT_ALLOY.vChemicalFormula); - } - else if (event.itemStack.getItemDamage() == 3){ - event.toolTip.add(MaterialEIO.REDSTONE_ALLOY.vChemicalFormula); - } - else if (event.itemStack.getItemDamage() == 4){ - event.toolTip.add(MaterialEIO.CONDUCTIVE_IRON.vChemicalFormula); - } - else if (event.itemStack.getItemDamage() == 5){ - event.toolTip.add(MaterialEIO.PULSATING_IRON.vChemicalFormula); - } - else if (event.itemStack.getItemDamage() == 6){ - event.toolTip.add(Materials.DarkSteel.mChemicalFormula); - } - else if (event.itemStack.getItemDamage() == 7){ - event.toolTip.add(MaterialEIO.SOULARIUM.vChemicalFormula); - } + //If stacks match, add a tooltip. + if (mIngot != null){ + if (event.itemStack.getItem() == mIngot){ + if (event.itemStack.getItemDamage() == 0){ + event.toolTip.add(MaterialEIO.ELECTRICAL_STEEL.vChemicalFormula); + } + else if (event.itemStack.getItemDamage() == 1){ + event.toolTip.add(MaterialEIO.ENERGETIC_ALLOY.vChemicalFormula); + } + else if (event.itemStack.getItemDamage() == 2){ + event.toolTip.add(MaterialEIO.VIBRANT_ALLOY.vChemicalFormula); + } + else if (event.itemStack.getItemDamage() == 3){ + event.toolTip.add(MaterialEIO.REDSTONE_ALLOY.vChemicalFormula); + } + else if (event.itemStack.getItemDamage() == 4){ + event.toolTip.add(MaterialEIO.CONDUCTIVE_IRON.vChemicalFormula); + } + else if (event.itemStack.getItemDamage() == 5){ + event.toolTip.add(MaterialEIO.PULSATING_IRON.vChemicalFormula); } - } - } + else if (event.itemStack.getItemDamage() == 6){ + event.toolTip.add(Materials.DarkSteel.mChemicalFormula); + } + else if (event.itemStack.getItemDamage() == 7){ + event.toolTip.add(MaterialEIO.SOULARIUM.vChemicalFormula); + } + } + } } } - catch (ClassNotFoundException e) { - } } - } - } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java index 81b40cc301..76ebac2cae 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java @@ -340,7 +340,13 @@ public enum GregtechItemList implements GregtechItemContainer { //Crate Box CrateStorage, - Thaumcraft_Researcher, + Thaumcraft_Researcher, + + Automation_Threaded_SuperBuffer_ULV, Automation_Threaded_SuperBuffer_LV, Automation_Threaded_SuperBuffer_MV, Automation_Threaded_SuperBuffer_HV, Automation_Threaded_SuperBuffer_EV, + Automation_Threaded_SuperBuffer_IV, Automation_Threaded_SuperBuffer_LuV, Automation_Threaded_SuperBuffer_ZPM, Automation_Threaded_SuperBuffer_UV, Automation_Threaded_SuperBuffer_MAX, + + Infinite_Item_Chest, + ; diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_ThreadedSuperBuffer.java b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_ThreadedSuperBuffer.java new file mode 100644 index 0000000000..51ad334a01 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_ThreadedSuperBuffer.java @@ -0,0 +1,86 @@ +package gtPlusPlus.xmod.gregtech.api.gui; + +import gregtech.api.util.GT_Utility; + +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_ThreadedBuffer; +import gtPlusPlus.xmod.gregtech.common.tileentities.automation.GT_MetaTileEntity_ThreadedChestBuffer; + +import net.minecraft.item.ItemStack; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Slot; +import net.minecraft.inventory.IInventory; +import gregtech.api.gui.GT_Slot_Holo; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import net.minecraft.entity.player.InventoryPlayer; +import gregtech.api.gui.GT_ContainerMetaTile_Machine; + +public class CONTAINER_ThreadedSuperBuffer extends GT_ContainerMetaTile_Machine { + + protected int cacheTime = 0; + + public CONTAINER_ThreadedSuperBuffer(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity) { + super(aInventoryPlayer, aTileEntity); + cacheTime = ((GT_MetaTileEntity_ThreadedBuffer)aTileEntity.getMetaTileEntity()).mThreadTimeLeft; + } + + public void addSlots(final InventoryPlayer aInventoryPlayer) { + this.addSlotToContainer((Slot) new GT_Slot_Holo((IInventory) this.mTileEntity, 256, 8, 63, false, true, 1)); + this.addSlotToContainer((Slot) new GT_Slot_Holo((IInventory) this.mTileEntity, 256, 26, 63, false, true, 1)); + this.addSlotToContainer((Slot) new GT_Slot_Holo((IInventory) this.mTileEntity, 256, 44, 63, false, true, 1)); + } + + public ItemStack slotClick(final int aSlotIndex, final int aMouseclick, final int aShifthold, + final EntityPlayer aPlayer) { + if (aSlotIndex < 0) { + return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); + } + final Slot tSlot = (Slot) this.inventorySlots.get(aSlotIndex); + if (tSlot != null) { + if (this.mTileEntity.getMetaTileEntity() == null) { + return null; + } + if (aSlotIndex == 0) { + ((GT_MetaTileEntity_ThreadedChestBuffer) this.mTileEntity + .getMetaTileEntity()).bOutput = !((GT_MetaTileEntity_ThreadedChestBuffer) this.mTileEntity + .getMetaTileEntity()).bOutput; + if (((GT_MetaTileEntity_ThreadedChestBuffer) this.mTileEntity.getMetaTileEntity()).bOutput) { + GT_Utility.sendChatToPlayer(aPlayer, this.trans("116", "Emit Energy to Outputside")); + } else { + GT_Utility.sendChatToPlayer(aPlayer, this.trans("117", "Don't emit Energy")); + } + return null; + } + if (aSlotIndex == 1) { + ((GT_MetaTileEntity_ThreadedChestBuffer) this.mTileEntity + .getMetaTileEntity()).bRedstoneIfFull = !((GT_MetaTileEntity_ThreadedChestBuffer) this.mTileEntity + .getMetaTileEntity()).bRedstoneIfFull; + if (((GT_MetaTileEntity_ThreadedChestBuffer) this.mTileEntity.getMetaTileEntity()).bRedstoneIfFull) { + GT_Utility.sendChatToPlayer(aPlayer, this.trans("118", "Emit Redstone if no Slot is free")); + } else { + GT_Utility.sendChatToPlayer(aPlayer, this.trans("119", "Don't emit Redstone")); + } + return null; + } + if (aSlotIndex == 2) { + ((GT_MetaTileEntity_ThreadedChestBuffer) this.mTileEntity + .getMetaTileEntity()).bInvert = !((GT_MetaTileEntity_ThreadedChestBuffer) this.mTileEntity + .getMetaTileEntity()).bInvert; + if (((GT_MetaTileEntity_ThreadedChestBuffer) this.mTileEntity.getMetaTileEntity()).bInvert) { + GT_Utility.sendChatToPlayer(aPlayer, this.trans("120", "Invert Redstone")); + } else { + GT_Utility.sendChatToPlayer(aPlayer, this.trans("121", "Don't invert Redstone")); + } + return null; + } + } + return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); + } + + public int getSlotCount() { + return 0; + } + + public int getShiftClickSlotCount() { + return 0; + } +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/GUI_ThreadedSuperBuffer.java b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/GUI_ThreadedSuperBuffer.java new file mode 100644 index 0000000000..2ca0b25e23 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/GUI_ThreadedSuperBuffer.java @@ -0,0 +1,32 @@ +package gtPlusPlus.xmod.gregtech.api.gui; + +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import net.minecraft.entity.player.InventoryPlayer; +import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; + +public class GUI_ThreadedSuperBuffer extends GT_GUIContainerMetaTile_Machine { + + int cacheTime = 0; + + public GUI_ThreadedSuperBuffer(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity) { + super(new CONTAINER_ThreadedSuperBuffer(aInventoryPlayer, aTileEntity), "gregtech:textures/gui/SuperBuffer.png"); + } + + private void updateVars(){ + this.cacheTime = ((CONTAINER_ThreadedSuperBuffer)this.mContainer).cacheTime; + } + + @Override + protected void drawGuiContainerForegroundLayer(final int par1, final int par2){ + this.updateVars(); + this.fontRendererObj.drawString("Time Remaining: "+cacheTime, 76, 61, 4210752); + } + + @Override + protected void drawGuiContainerBackgroundLayer(final float par1, final int par2, final int par3) { + super.drawGuiContainerBackgroundLayer(par1, par2, par3); + final int x = (this.width - this.xSize) / 2; + final int y = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); + } +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_ThreadedBuffer.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_ThreadedBuffer.java new file mode 100644 index 0000000000..9642ff63ee --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_ThreadedBuffer.java @@ -0,0 +1,418 @@ +package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations; + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.entity.player.EntityPlayer; +import gregtech.api.enums.GT_Values; +import gregtech.api.util.GT_Utility; + +import gtPlusPlus.api.objects.minecraft.BlockPos; +import gtPlusPlus.core.util.data.ArrayUtils; +import gtPlusPlus.xmod.gregtech.api.objects.GregtechBufferThread; + +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Buffer; +import gregtech.api.interfaces.IIconContainer; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; + +public abstract class GT_MetaTileEntity_ThreadedBuffer extends GT_MetaTileEntity_Buffer { + + protected GregtechBufferThread mLogicThread; + protected BlockPos mPos; + public final ItemStack[] mInventorySynchro; + public int mThreadTimeLeft = 0; + + public GT_MetaTileEntity_ThreadedBuffer(final int aID, final String aName, final String aNameRegional, final int aTier, + final int aInvSlotCount, final String aDescription) { + super(aID, aName, aNameRegional, aTier, aInvSlotCount, aDescription); + this.bOutput = false; + this.bRedstoneIfFull = false; + this.bInvert = false; + this.mSuccess = 0; + this.mTargetStackSize = 0; + this.mInventorySynchro = new ItemStack[aInvSlotCount]; + } + + public GT_MetaTileEntity_ThreadedBuffer(final int aID, final String aName, final String aNameRegional, final int aTier, + final int aInvSlotCount, final String[] aDescription) { + super(aID, aName, aNameRegional, aTier, aInvSlotCount, aDescription); + this.bOutput = false; + this.bRedstoneIfFull = false; + this.bInvert = false; + this.mSuccess = 0; + this.mTargetStackSize = 0; + this.mInventorySynchro = new ItemStack[aInvSlotCount]; + } + + public GT_MetaTileEntity_ThreadedBuffer(final String aName, final int aTier, final int aInvSlotCount, + final String aDescription, final ITexture[][][] aTextures) { + super(aName, aTier, aInvSlotCount, aDescription, aTextures); + this.bOutput = false; + this.bRedstoneIfFull = false; + this.bInvert = false; + this.mSuccess = 0; + this.mTargetStackSize = 0; + this.mInventorySynchro = new ItemStack[aInvSlotCount]; + } + + public GT_MetaTileEntity_ThreadedBuffer(final String aName, final int aTier, final int aInvSlotCount, + final String[] aDescription, final ITexture[][][] aTextures) { + super(aName, aTier, aInvSlotCount, aDescription, aTextures); + this.bOutput = false; + this.bRedstoneIfFull = false; + this.bInvert = false; + this.mSuccess = 0; + this.mTargetStackSize = 0; + this.mInventorySynchro = new ItemStack[aInvSlotCount]; + } + + public synchronized final GregtechBufferThread getLogicThread() { + if (mLogicThread != null) { + return mLogicThread; + } + else { + return this.mLogicThread = GregtechBufferThread.getBufferThread(mPos); + } + } + + public ITexture[][][] getTextureSet(final ITexture[] aTextures) { + final ITexture[][][] rTextures = new ITexture[6][17][]; + final ITexture tIcon = this.getOverlayIcon(); + final ITexture tOut = (ITexture) new GT_RenderedTexture((IIconContainer) Textures.BlockIcons.OVERLAY_PIPE_OUT); + final ITexture tUp = (ITexture) new GT_RenderedTexture((IIconContainer) Textures.BlockIcons.ARROW_UP); + final ITexture tDown = (ITexture) new GT_RenderedTexture((IIconContainer) Textures.BlockIcons.ARROW_DOWN); + final ITexture tLeft = (ITexture) new GT_RenderedTexture((IIconContainer) Textures.BlockIcons.ARROW_LEFT); + final ITexture tRight = (ITexture) new GT_RenderedTexture((IIconContainer) Textures.BlockIcons.ARROW_RIGHT); + for (byte i = -1; i < 16; ++i) { + rTextures[0][i + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][i + 1], tOut}; + rTextures[1][i + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][i + 1], tRight, tIcon}; + rTextures[2][i + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][i + 1], tDown, tIcon}; + rTextures[3][i + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][i + 1], tLeft, tIcon}; + rTextures[4][i + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][i + 1], tUp, tIcon}; + rTextures[5][i + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][i + 1], tIcon}; + } + return rTextures; + } + + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, + final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + if (aSide == aFacing) { + return this.mTextures[5][aColorIndex + 1]; + } + if (GT_Utility.getOppositeSide((int) aSide) == aFacing) { + return this.mTextures[0][aColorIndex + 1]; + } + Label_0356 : { + switch (aFacing) { + case 0 : { + return this.mTextures[4][aColorIndex + 1]; + } + case 1 : { + return this.mTextures[2][aColorIndex + 1]; + } + case 2 : { + switch (aSide) { + case 0 : { + return this.mTextures[2][aColorIndex + 1]; + } + case 1 : { + return this.mTextures[2][aColorIndex + 1]; + } + case 4 : { + return this.mTextures[1][aColorIndex + 1]; + } + case 5 : { + return this.mTextures[3][aColorIndex + 1]; + } + default : { + break Label_0356; + } + } + } + case 3 : { + switch (aSide) { + case 0 : { + return this.mTextures[4][aColorIndex + 1]; + } + case 1 : { + return this.mTextures[4][aColorIndex + 1]; + } + case 4 : { + return this.mTextures[3][aColorIndex + 1]; + } + case 5 : { + return this.mTextures[1][aColorIndex + 1]; + } + default : { + break Label_0356; + } + } + } + case 4 : { + switch (aSide) { + case 0 : { + return this.mTextures[3][aColorIndex + 1]; + } + case 1 : { + return this.mTextures[1][aColorIndex + 1]; + } + case 2 : { + return this.mTextures[3][aColorIndex + 1]; + } + case 3 : { + return this.mTextures[1][aColorIndex + 1]; + } + default : { + break Label_0356; + } + } + } + case 5 : { + switch (aSide) { + case 0 : { + return this.mTextures[1][aColorIndex + 1]; + } + case 1 : { + return this.mTextures[3][aColorIndex + 1]; + } + case 2 : { + return this.mTextures[1][aColorIndex + 1]; + } + case 3 : { + return this.mTextures[3][aColorIndex + 1]; + } + default : { + break Label_0356; + } + } + } + } + } + return this.mTextures[5][aColorIndex + 1]; + } + + public boolean isSimpleMachine() { + return false; + } + + public boolean isValidSlot(final int aIndex) { + return aIndex < this.mInventorySynchro.length - 1; + } + + public boolean isFacingValid(final byte aFacing) { + return true; + } + + public boolean isEnetInput() { + return true; + } + + public boolean isEnetOutput() { + return true; + } + + public boolean isInputFacing(final byte aSide) { + return !this.isOutputFacing(aSide); + } + + public boolean isOutputFacing(final byte aSide) { + return this.getBaseMetaTileEntity().getBackFacing() == aSide; + } + + public boolean isTeleporterCompatible() { + return false; + } + + public long getMinimumStoredEU() { + return 512L; + } + + public long maxEUStore() { + return 512L + GT_Values.V[this.mTier] * 50L; + } + + public long maxEUInput() { + return GT_Values.V[this.mTier]; + } + + public long maxEUOutput() { + return this.bOutput ? GT_Values.V[this.mTier] : 0L; + } + + public long maxAmperesIn() { + return 2L; + } + + public long maxAmperesOut() { + return 2L; + } + + public boolean isAccessAllowed(final EntityPlayer aPlayer) { + return true; + } + + public abstract ITexture getOverlayIcon(); + + public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) { + return true; + } + aBaseMetaTileEntity.openGUI(aPlayer); + return true; + } + + public void saveNBTData(final NBTTagCompound aNBT) { + aNBT.setBoolean("bInvert", this.bInvert); + aNBT.setBoolean("bOutput", this.bOutput); + aNBT.setBoolean("bRedstoneIfFull", this.bRedstoneIfFull); + aNBT.setInteger("mTargetStackSize", this.mTargetStackSize); + } + + public void loadNBTData(final NBTTagCompound aNBT) { + this.bInvert = aNBT.getBoolean("bInvert"); + this.bOutput = aNBT.getBoolean("bOutput"); + this.bRedstoneIfFull = aNBT.getBoolean("bRedstoneIfFull"); + this.mTargetStackSize = aNBT.getInteger("mTargetStackSize"); + } + + public void setItemNBT(final NBTTagCompound aNBT) { + super.setItemNBT(aNBT); + if (this.mTargetStackSize > 0) { + aNBT.setInteger("mTargetStackSize", this.mTargetStackSize); + } + } + + public void onScrewdriverRightClick(final byte aSide, final EntityPlayer aPlayer, final float aX, final float aY, + final float aZ) { + if (aSide == this.getBaseMetaTileEntity().getBackFacing()) { + this.mTargetStackSize = (byte) ((this.mTargetStackSize + (aPlayer.isSneaking() ? -1 : 1)) % 65); + if (this.mTargetStackSize < 0) { + this.mTargetStackSize = 64; + } + if (this.mTargetStackSize == 0) { + GT_Utility.sendChatToPlayer(aPlayer, this.trans("098", "Do not regulate Item Stack Size")); + } else { + GT_Utility.sendChatToPlayer(aPlayer, + this.trans("099", "Regulate Item Stack Size to: ") + this.mTargetStackSize); + } + } + } + + public synchronized void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTimer) { + if (aBaseMetaTileEntity.isServerSide()) { + if (mPos == null) { + mPos = new BlockPos(this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getYCoord(), this.getBaseMetaTileEntity().getZCoord(), this.getBaseMetaTileEntity().getWorld()); + } + if (mLogicThread == null) { + mLogicThread = GregtechBufferThread.getBufferThread(mPos); + } + if (mLogicThread!= null) { + getLogicThread().onPostTick(aBaseMetaTileEntity, aTimer, this); + this.mThreadTimeLeft = this.mLogicThread.getTimeLeft(); + } + } + } + + public void onFirstTick(final IGregTechTileEntity aBaseMetaTileEntity) { + for (byte b = 0; b < 6; ++b) { + aBaseMetaTileEntity.setInternalOutputRedstoneSignal(b, (byte) 0); + } + } + + protected synchronized void moveItems(final IGregTechTileEntity aBaseMetaTileEntity, final long aTimer) { + if (aBaseMetaTileEntity.isServerSide()) + getLogicThread().moveItems(aBaseMetaTileEntity, aTimer, this); + } + + public boolean allowPullStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, + final ItemStack aStack) { + return true; + } + + public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, + final ItemStack aStack) { + return aSide != aBaseMetaTileEntity.getBackFacing(); + } + + public boolean allowGeneralRedstoneOutput() { + return true; + } + + //Custom inventory handler + + @Override + public synchronized ItemStack[] getRealInventory() { + return this.mInventorySynchro; + } + + @Override + public synchronized boolean canInsertItem(final int aIndex, final ItemStack aStack, final int aSide) { + return this.isValidSlot(aIndex) && aStack != null && aIndex < getSizeInventory() + && (this.mInventorySynchro[aIndex] == null || GT_Utility.areStacksEqual(aStack, this.mInventorySynchro[aIndex])) + && this.allowPutStack(this.getBaseMetaTileEntity(), aIndex, (byte) aSide, aStack); + } + + @Override + public synchronized boolean canExtractItem(final int aIndex, final ItemStack aStack, final int aSide) { + return this.isValidSlot(aIndex) && aStack != null && aIndex < getSizeInventory() + && this.allowPullStack(this.getBaseMetaTileEntity(), aIndex, (byte) aSide, aStack); + } + + @Override + public synchronized int getSizeInventory() { + return this.mInventorySynchro.length; + } + + @Override + public synchronized ItemStack getStackInSlot(final int aIndex) { + if (aIndex >= 0 && aIndex < getSizeInventory()) { + return this.mInventorySynchro[aIndex]; + } + return null; + } + + @Override + public synchronized void setInventorySlotContents(final int aIndex, final ItemStack aStack) { + if (aIndex >= 0 && aIndex < getSizeInventory()) { + this.mInventorySynchro[aIndex] = aStack; + } + } + + private synchronized void cleanup() { + if (this.mLogicThread != null) { + this.mLogicThread.destroy(); + this.mLogicThread = null; + } + } + + @Override + public void onExplosion() { + cleanup(); + super.onExplosion(); + } + + @Override + public void onRemoval() { + cleanup(); + super.onRemoval(); + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public String[] getInfoData() { + String mResult[] = super.getInfoData(); + String mAdditive[] = new String[] { + "info" + }; + for (String s : mAdditive) { + ArrayUtils.expandArray(mResult, s); + } + return mResult; + } +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/objects/GregtechBufferThread.java b/src/Java/gtPlusPlus/xmod/gregtech/api/objects/GregtechBufferThread.java new file mode 100644 index 0000000000..1e7d73bacd --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/objects/GregtechBufferThread.java @@ -0,0 +1,242 @@ +package gtPlusPlus.xmod.gregtech.api.objects; + +import java.util.List; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; + +import net.minecraft.init.Items; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; + +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.util.GT_Utility; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.minecraft.BlockPos; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_ThreadedBuffer; +import gtPlusPlus.xmod.gregtech.common.tileentities.automation.GT_MetaTileEntity_ThreadedChestBuffer; + +public class GregtechBufferThread extends Thread { + + public static final ConcurrentMap<String, GregtechBufferThread> mBufferThreadAllocation = new ConcurrentHashMap<String, GregtechBufferThread>(); + private final BlockPos mBlockPos; + private final int mMaxLife = 300; + private int mLifeCycleTime = mMaxLife; + private final String mID; + + public static synchronized final GregtechBufferThread getBufferThread(BlockPos pos) { + if (pos != null && mBufferThreadAllocation.containsKey(""+pos.getUniqueIdentifier())){ + Logger.INFO("[SB] Found an existing thread for this Buffer."); + return mBufferThreadAllocation.get(""+pos.getUniqueIdentifier()); + } + else { + return new GregtechBufferThread(pos); + } + } + + public GregtechBufferThread(BlockPos pos) { + super(); + String aID = pos != null ? pos.getUniqueIdentifier() : ""+Short.MIN_VALUE; + this.mID = aID; + if (pos != null && !mBufferThreadAllocation.containsKey(mID)){ + mBlockPos = pos; + mBufferThreadAllocation.put(mID, this); + } + else { + this.mLifeCycleTime = 1; + mBlockPos = null; + } + this.setName("GTPP-SuperBuffer("+mID+")"); + this.setDaemon(true); + if (mBlockPos != null && !this.isAlive()) { + try { + start(); + Logger.INFO("[SB] Created a SuperBuffer Thread for dimension "+mID+"."); + } + catch (Throwable t_) { + //Do nothing. + } + } + } + + public synchronized int getTimeLeft() { + return this.mLifeCycleTime; + } + + public synchronized void fillStacksIntoFirstSlots(GT_MetaTileEntity_ThreadedChestBuffer mBuffer) { + for (int i = 0; i < mBuffer.mInventorySynchro.length - 1; ++i) { + for (int j = i + 1; j < mBuffer.mInventorySynchro.length - 1; ++j) { + if (mBuffer.mInventorySynchro[j] != null && (mBuffer.mInventorySynchro[i] == null + || areStacksEqual(mBuffer.mInventorySynchro[i], mBuffer.mInventorySynchro[j]))) { + moveStackFromSlotAToSlotB((IInventory) mBuffer.getBaseMetaTileEntity(), + (IInventory) mBuffer.getBaseMetaTileEntity(), j, i, (byte) 64, (byte) 1, (byte) 64, (byte) 1); + } + } + } + } + + public synchronized boolean moveItems(final IGregTechTileEntity aBaseMetaTileEntity, final long aTimer, GT_MetaTileEntity_ThreadedBuffer mBuffer) { + final byte mTargetStackSize = (byte) mBuffer.mTargetStackSize; + final int tCost = GT_Utility.moveOneItemStack((Object) aBaseMetaTileEntity, + (Object) aBaseMetaTileEntity.getTileEntityAtSide(aBaseMetaTileEntity.getBackFacing()), + aBaseMetaTileEntity.getBackFacing(), aBaseMetaTileEntity.getFrontFacing(), (List<ItemStack>) null, false, + (byte) ((mTargetStackSize == 0) ? 64 : ((byte) mTargetStackSize)), + (byte) ((mTargetStackSize == 0) ? 1 : ((byte) mTargetStackSize)), (byte) 64, (byte) 1); + if (tCost > 0 || aBaseMetaTileEntity.hasInventoryBeenModified()) { + mBuffer.mSuccess = 50; + aBaseMetaTileEntity.decreaseStoredEnergyUnits((long) Math.abs(tCost), true); + return true; + } + return false; + } + + public synchronized void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTimer, GT_MetaTileEntity_ThreadedBuffer mBuffer) { + if (aBaseMetaTileEntity.isAllowedToWork() && aBaseMetaTileEntity.isServerSide() + && aBaseMetaTileEntity.isUniversalEnergyStored(mBuffer.getMinimumStoredEU()) + && (aBaseMetaTileEntity.hasWorkJustBeenEnabled() || aBaseMetaTileEntity.hasInventoryBeenModified() + || aTimer % 200L == 0L || mBuffer.mSuccess > 0)) { + --mBuffer.mSuccess; + if (mLifeCycleTime < (mMaxLife-1)){ + mLifeCycleTime += 1; + } + //Logger.INFO("Ticking SB @ "+mBuffer.getLogicThread().mBlockPos.getUniqueIdentifier() + " | Time Left: "+mLifeCycleTime); + moveItems(aBaseMetaTileEntity, aTimer, mBuffer); + for (byte b = 0; b < 6; ++b) { + aBaseMetaTileEntity.setInternalOutputRedstoneSignal(b, (byte) (mBuffer.bInvert ? 15 : 0)); + } + if (mBuffer.bRedstoneIfFull) { + for (byte b = 0; b < 6; ++b) { + aBaseMetaTileEntity.setInternalOutputRedstoneSignal(b, (byte) (mBuffer.bInvert ? 0 : 15)); + } + for (int i = 0; i < mBuffer.mInventorySynchro.length; ++i) { + if (mBuffer.isValidSlot(i) && mBuffer.mInventorySynchro[i] == null) { + for (byte b2 = 0; b2 < 6; ++b2) { + aBaseMetaTileEntity.setInternalOutputRedstoneSignal(b2, (byte) (mBuffer.bInvert ? 15 : 0)); + } + aBaseMetaTileEntity.decreaseStoredEnergyUnits(1L, true); + break; + } + } + } + } + } + + /** + * Some GT logic we'd like to move off thread + */ + + public synchronized boolean areStacksEqual(final ItemStack aStack1, final ItemStack aStack2) { + return areStacksEqual(aStack1, aStack2, false); + } + + public synchronized boolean areStacksEqual(final ItemStack aStack1, final ItemStack aStack2, final boolean aIgnoreNBT) { + return aStack1 != null && aStack2 != null && aStack1.getItem() == aStack2.getItem() + && (aIgnoreNBT || (aStack1.getTagCompound() == null == (aStack2.getTagCompound() == null) + && (aStack1.getTagCompound() == null + || aStack1.getTagCompound().equals((Object) aStack2.getTagCompound())))) + && (Items.feather.getDamage(aStack1) == Items.feather.getDamage(aStack2) + || Items.feather.getDamage(aStack1) == 32767 || Items.feather.getDamage(aStack2) == 32767); + } + + public synchronized byte moveStackFromSlotAToSlotB(final IInventory aTileEntity1, final IInventory aTileEntity2, + final int aGrabFrom, final int aPutTo, byte aMaxTargetStackSize, final byte aMinTargetStackSize, + final byte aMaxMoveAtOnce, final byte aMinMoveAtOnce) { + if (aTileEntity1 == null || aTileEntity2 == null || aMaxTargetStackSize <= 0 || aMinTargetStackSize <= 0 + || aMinTargetStackSize > aMaxTargetStackSize || aMaxMoveAtOnce <= 0 + || aMinMoveAtOnce > aMaxMoveAtOnce) { + return 0; + } + final ItemStack tStack1 = aTileEntity1.getStackInSlot(aGrabFrom); + final ItemStack tStack2 = aTileEntity2.getStackInSlot(aPutTo); + ItemStack tStack3 = null; + if (tStack1 != null) { + if (tStack2 != null && !areStacksEqual(tStack1, tStack2)) { + return 0; + } + tStack3 = GT_Utility.copy(tStack1); + aMaxTargetStackSize = (byte) Math.min(aMaxTargetStackSize, + Math.min(tStack3.getMaxStackSize(), + Math.min((tStack2 == null) ? Integer.MAX_VALUE : tStack2.getMaxStackSize(), + aTileEntity2.getInventoryStackLimit()))); + tStack3.stackSize = Math.min(tStack3.stackSize, + aMaxTargetStackSize - ((tStack2 == null) ? 0 : tStack2.stackSize)); + if (tStack3.stackSize > aMaxMoveAtOnce) { + tStack3.stackSize = aMaxMoveAtOnce; + } + if (tStack3.stackSize + ((tStack2 == null) ? 0 : tStack2.stackSize) >= Math.min(tStack3.getMaxStackSize(), + aMinTargetStackSize) && tStack3.stackSize >= aMinMoveAtOnce) { + tStack3 = aTileEntity1.decrStackSize(aGrabFrom, tStack3.stackSize); + aTileEntity1.markDirty(); + if (tStack3 != null) { + if (tStack2 == null) { + aTileEntity2.setInventorySlotContents(aPutTo, GT_Utility.copy(tStack3)); + aTileEntity2.markDirty(); + } else { + final ItemStack itemStack = tStack2; + itemStack.stackSize += tStack3.stackSize; + aTileEntity2.markDirty(); + } + return (byte) tStack3.stackSize; + } + } + } + return 0; + } + + //Logic Vars + private boolean mRunning = true; + + @Override + public void run() { + //While thread is alive. + run: while (mRunning) { + //While thread is active, lets tick it's life down. + life: while (mLifeCycleTime > 0) { + if (!mRunning) { + break life; + } + + //Remove invalid threads + if (this.mBlockPos.world == null || this.mBlockPos.getBlockAtPos() == null) { + destroy(); + break run; + } + //Prevent Overflows + if (mLifeCycleTime > mMaxLife) { + mLifeCycleTime = mMaxLife; + } + try { + sleep(1000); + mLifeCycleTime--; + Logger.WARNING("[SB] Ticking Thread "+mID+" | Remaining: "+mLifeCycleTime+"s"); + } + catch (InterruptedException e) { + mLifeCycleTime = 0; + } + } + if (mLifeCycleTime <= 0) { + destroy(); + break run; + } + } + } + + @SuppressWarnings("deprecation") + @Override + public void destroy() { + mRunning = false; + GregtechBufferThread.mBufferThreadAllocation.remove(mID, this); + Logger.INFO("[SB] Removing Thread "+mID); + try { + stop(); + this.finalize(); + } + catch (Throwable t) { + //Do nothing. + } + } + + + + +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java index 7acefa104c..d84e89619e 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java @@ -352,6 +352,10 @@ public class TexturesGtBlock { private static final CustomIcon Internal_Overlay_UU_Matter = new CustomIcon("TileEntities/adv_machine_uum"); public static final CustomIcon Overlay_UU_Matter = Internal_Overlay_UU_Matter; + //Buffer Overlays + private static final CustomIcon Internal_OVERLAY_AUTOMATION_SUPERBUFFER = new CustomIcon("iconsets/AUTOMATION_SUPERBUFFER"); + public static final CustomIcon OVERLAY_AUTOMATION_SUPERBUFFER = Internal_OVERLAY_AUTOMATION_SUPERBUFFER; + //Metroid related public static final CustomIcon TEXTURE_METAL_PANEL_A = new CustomIcon("metro/TEXTURE_METAL_PANEL_A"); @@ -494,5 +498,8 @@ public class TexturesGtBlock { TEXTURE_CASING_FUSION_COIL_II_7, TEXTURE_CASING_FUSION_COIL_II_8, TEXTURE_CASING_FUSION_COIL_II_9, TEXTURE_CASING_FUSION_COIL_II_10, TEXTURE_CASING_FUSION_COIL_II_11, TEXTURE_CASING_FUSION_COIL_II_12}; + + + } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/GT_MetaTileEntity_ThreadedChestBuffer.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/GT_MetaTileEntity_ThreadedChestBuffer.java new file mode 100644 index 0000000000..022dfcb40a --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/GT_MetaTileEntity_ThreadedChestBuffer.java @@ -0,0 +1,75 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.automation; + +import gregtech.common.gui.GT_GUIContainer_ChestBuffer; + +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_ThreadedBuffer; + +import gregtech.common.gui.GT_Container_ChestBuffer; +import net.minecraft.entity.player.InventoryPlayer; +import gregtech.api.interfaces.IIconContainer; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.interfaces.ITexture; + +public class GT_MetaTileEntity_ThreadedChestBuffer extends GT_MetaTileEntity_ThreadedBuffer { + public GT_MetaTileEntity_ThreadedChestBuffer(final int aID, final String aName, final String aNameRegional, + final int aTier) { + super(aID, aName, aNameRegional, aTier, 28, new String[]{"Buffers up to 27 Item Stacks", + "Use Screwdriver to regulate output stack size", "Consumes 1EU per moved Item"}); + } + + public GT_MetaTileEntity_ThreadedChestBuffer(final int aID, final String aName, final String aNameRegional, final int aTier, + final int aInvSlotCount, final String aDescription) { + super(aID, aName, aNameRegional, aTier, aInvSlotCount, aDescription); + } + + public GT_MetaTileEntity_ThreadedChestBuffer(final int aID, final String aName, final String aNameRegional, final int aTier, + final int aInvSlotCount, final String[] aDescription) { + super(aID, aName, aNameRegional, aTier, aInvSlotCount, aDescription); + } + + public GT_MetaTileEntity_ThreadedChestBuffer(final String aName, final int aTier, final int aInvSlotCount, + final String aDescription, final ITexture[][][] aTextures) { + super(aName, aTier, aInvSlotCount, aDescription, aTextures); + } + + public GT_MetaTileEntity_ThreadedChestBuffer(final String aName, final int aTier, final int aInvSlotCount, + final String[] aDescription, final ITexture[][][] aTextures) { + super(aName, aTier, aInvSlotCount, aDescription, aTextures); + } + + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return (IMetaTileEntity) new GT_MetaTileEntity_ThreadedChestBuffer(this.mName, this.mTier, this.mInventorySynchro.length, + this.mDescriptionArray, this.mTextures); + } + + public ITexture getOverlayIcon() { + return (ITexture) new GT_RenderedTexture((IIconContainer) Textures.BlockIcons.AUTOMATION_CHESTBUFFER); + } + + public boolean isValidSlot(final int aIndex) { + return aIndex < this.mInventorySynchro.length - 1; + } + + protected void moveItems(final IGregTechTileEntity aBaseMetaTileEntity, final long aTimer) { + this.fillStacksIntoFirstSlots(); + super.moveItems(aBaseMetaTileEntity, aTimer); + this.fillStacksIntoFirstSlots(); + } + + protected synchronized void fillStacksIntoFirstSlots() { + this.mLogicThread.fillStacksIntoFirstSlots(this); + } + + public Object getServerGUI(final int aID, final InventoryPlayer aPlayerInventory, + final IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_Container_ChestBuffer(aPlayerInventory, aBaseMetaTileEntity); + } + + public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, + final IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_ChestBuffer(aPlayerInventory, aBaseMetaTileEntity); + } +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/GT_MetaTileEntity_ThreadedSuperBuffer.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/GT_MetaTileEntity_ThreadedSuperBuffer.java new file mode 100644 index 0000000000..862637a6e3 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/GT_MetaTileEntity_ThreadedSuperBuffer.java @@ -0,0 +1,55 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.automation; + +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.xmod.gregtech.api.gui.CONTAINER_ThreadedSuperBuffer; +import gtPlusPlus.xmod.gregtech.api.gui.GUI_ThreadedSuperBuffer; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; + +import net.minecraft.entity.player.InventoryPlayer; +import gregtech.api.interfaces.IIconContainer; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.interfaces.ITexture; + +public class GT_MetaTileEntity_ThreadedSuperBuffer extends GT_MetaTileEntity_ThreadedChestBuffer { + + public GT_MetaTileEntity_ThreadedSuperBuffer(final int aID, final String aName, final String aNameRegional, + final int aTier) { + super(aID, aName, aNameRegional, aTier, 257, new String[]{ + "Server friendly", + "Buffers up to 256 Item Stacks", + "Use Screwdriver to regulate output stack size", + "Consumes 1EU per moved Item", + CORE.GT_Tooltip}); + } + + public GT_MetaTileEntity_ThreadedSuperBuffer(final String aName, final int aTier, final int aInvSlotCount, + final String aDescription, final ITexture[][][] aTextures) { + super(aName, aTier, aInvSlotCount, aDescription, aTextures); + } + + public GT_MetaTileEntity_ThreadedSuperBuffer(final String aName, final int aTier, final int aInvSlotCount, + final String[] aDescription, final ITexture[][][] aTextures) { + super(aName, aTier, aInvSlotCount, aDescription, aTextures); + } + + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return (IMetaTileEntity) new GT_MetaTileEntity_ThreadedSuperBuffer(this.mName, this.mTier, this.mInventorySynchro.length, + this.mDescriptionArray, this.mTextures); + } + + public ITexture getOverlayIcon() { + return (ITexture) new GT_RenderedTexture((IIconContainer) TexturesGtBlock.OVERLAY_AUTOMATION_SUPERBUFFER); + } + + public Object getServerGUI(final int aID, final InventoryPlayer aPlayerInventory, + final IGregTechTileEntity aBaseMetaTileEntity) { + return new CONTAINER_ThreadedSuperBuffer(aPlayerInventory, aBaseMetaTileEntity); + } + + public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, + final IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_ThreadedSuperBuffer(aPlayerInventory, aBaseMetaTileEntity); + } +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/creative/GT_MetaTileEntity_InfiniteItemHolder.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/creative/GT_MetaTileEntity_InfiniteItemHolder.java new file mode 100644 index 0000000000..529a0b79f6 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/creative/GT_MetaTileEntity_InfiniteItemHolder.java @@ -0,0 +1,98 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.storage.creative; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; + +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; + +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import gtPlusPlus.core.util.sys.KeyboardUtils; +import gtPlusPlus.xmod.gregtech.common.tileentities.storage.GT_MetaTileEntity_TieredChest; + +public class GT_MetaTileEntity_InfiniteItemHolder extends GT_MetaTileEntity_TieredChest { + + public GT_MetaTileEntity_InfiniteItemHolder(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier); + } + + public GT_MetaTileEntity_InfiniteItemHolder(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.getWorld().isRemote) { + return false; + } + + if (!KeyboardUtils.isShiftKeyDown()) { + if (this.mItemStack == null) { + if (aPlayer.getHeldItem() != null) { + this.mItemStack = aPlayer.getHeldItem().copy(); + this.mItemCount = Short.MAX_VALUE; + aPlayer.setCurrentItemOrArmor(0, null); + PlayerUtils.messagePlayer(aPlayer, "Now holding "+this.mItemStack.getDisplayName()+" x"+Short.MAX_VALUE+"."); + return true; + } + } + else { + if (aPlayer.getHeldItem() == null) { + aPlayer.entityDropItem(mItemStack, 1); + this.mItemStack = null; + this.mItemCount = 0; + PlayerUtils.messagePlayer(aPlayer, "Emptying."); + return true; + } + } + } + + PlayerUtils.messagePlayer(aPlayer, "Currently holding: "+(this.mItemStack != null ? this.mItemStack.getDisplayName() : "Nothing")+" x"+this.mItemCount); + return true; + //return super.onRightclick(aBaseMetaTileEntity, aPlayer); + } + + @Override + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return null; + } + + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return null; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { + if (mItemStack != null) { + setItemCount(0); + } + super.onPostTick(aBaseMetaTileEntity, aTimer); + } + + @Override + public void setItemCount(int aCount) { + super.setItemCount(Short.MAX_VALUE); + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return true; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return false; + } + + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_InfiniteItemHolder(this.mName, this.mTier, this.mDescription, this.mTextures); + } + + + + + +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechSuperTanks.java b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechSuperChests.java index eafed2653a..84de99a368 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechSuperTanks.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechSuperChests.java @@ -11,7 +11,7 @@ import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; import gtPlusPlus.xmod.gregtech.common.tileentities.storage.GT_MetaTileEntity_ConnectableCrate; import gtPlusPlus.xmod.gregtech.common.tileentities.storage.GT_MetaTileEntity_TieredChest; -public class GregtechSuperTanks { +public class GregtechSuperChests { public static void run() { int mId = 946; diff --git a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechThreadedBuffers.java b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechThreadedBuffers.java new file mode 100644 index 0000000000..7c16eb351b --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechThreadedBuffers.java @@ -0,0 +1,65 @@ +package gtPlusPlus.xmod.gregtech.registration.gregtech; + +import static gtPlusPlus.core.recipe.common.CI.bitsd; + +import gregtech.api.enums.ItemList; +import gregtech.api.util.GT_ModHandler; + +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.common.tileentities.automation.GT_MetaTileEntity_ThreadedSuperBuffer; +import gtPlusPlus.xmod.gregtech.common.tileentities.storage.creative.GT_MetaTileEntity_InfiniteItemHolder; + +public class GregtechThreadedBuffers { + + public static void run() { + run2(); + } + + private static void run2() { + + GregtechItemList.Infinite_Item_Chest.set((new GT_MetaTileEntity_InfiniteItemHolder(31010, "infinite.chest.tier.01", "Infinite Item Chest", 1)).getStackForm(1L)); + + GregtechItemList.Automation_Threaded_SuperBuffer_ULV.set(new GT_MetaTileEntity_ThreadedSuperBuffer(31000,"automation.superbuffer.threaded.tier.00", + "ULV Super Buffer [Threaded]", 0).getStackForm(1L)); + GregtechItemList.Automation_Threaded_SuperBuffer_LV.set(new GT_MetaTileEntity_ThreadedSuperBuffer(31001, "automation.superbuffer.threaded.tier.01", + "LV Super Buffer [Threaded]", 1).getStackForm(1L)); + GregtechItemList.Automation_Threaded_SuperBuffer_MV.set(new GT_MetaTileEntity_ThreadedSuperBuffer(31002, "automation.superbuffer.threaded.tier.02", + "MV Super Buffer [Threaded]", 2).getStackForm(1L)); + GregtechItemList.Automation_Threaded_SuperBuffer_HV.set(new GT_MetaTileEntity_ThreadedSuperBuffer(31003, "automation.superbuffer.threaded.tier.03", + "HV Super Buffer [Threaded]", 3).getStackForm(1L)); + GregtechItemList.Automation_Threaded_SuperBuffer_EV.set(new GT_MetaTileEntity_ThreadedSuperBuffer(31004, "automation.superbuffer.threaded.tier.04", + "EV Super Buffer [Threaded]", 4).getStackForm(1L)); + GregtechItemList.Automation_Threaded_SuperBuffer_IV.set(new GT_MetaTileEntity_ThreadedSuperBuffer(31005, "automation.superbuffer.threaded.tier.05", + "IV Super Buffer [Threaded]", 5).getStackForm(1L)); + GregtechItemList.Automation_Threaded_SuperBuffer_LuV.set(new GT_MetaTileEntity_ThreadedSuperBuffer(31006, "automation.superbuffer.threaded.tier.06", + "LuV Super Buffer [Threaded]", 6).getStackForm(1L)); + GregtechItemList.Automation_Threaded_SuperBuffer_ZPM.set(new GT_MetaTileEntity_ThreadedSuperBuffer(31007, "automation.superbuffer.threaded.tier.07", + "ZPM Super Buffer [Threaded]", 7).getStackForm(1L)); + GregtechItemList.Automation_Threaded_SuperBuffer_UV.set(new GT_MetaTileEntity_ThreadedSuperBuffer(31008, "automation.superbuffer.threaded.tier.08", + "UV Super Buffer [Threaded]", 8).getStackForm(1L)); + GregtechItemList.Automation_Threaded_SuperBuffer_MAX.set(new GT_MetaTileEntity_ThreadedSuperBuffer(31009, "automation.superbuffer.threaded.tier.09", + "MAX Super Buffer [Threaded]", 9).getStackForm(1L)); + + GT_ModHandler.addCraftingRecipe(GregtechItemList.Automation_Threaded_SuperBuffer_ULV.get(1L, new Object[0]), bitsd, new Object[]{ + "DMV", 'M', ItemList.Automation_SuperBuffer_ULV, 'V', ItemList.Conveyor_Module_LV, 'D', ItemList.Tool_DataOrb}); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Automation_Threaded_SuperBuffer_LV.get(1L, new Object[0]), bitsd, new Object[]{ + "DMV", 'M', ItemList.Automation_SuperBuffer_LV, 'V', ItemList.Conveyor_Module_LV, 'D', ItemList.Tool_DataOrb}); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Automation_Threaded_SuperBuffer_MV.get(1L, new Object[0]), bitsd, new Object[]{ + "DMV", 'M', ItemList.Automation_SuperBuffer_MV, 'V', ItemList.Conveyor_Module_MV, 'D', ItemList.Tool_DataOrb}); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Automation_Threaded_SuperBuffer_HV.get(1L, new Object[0]), bitsd, new Object[]{ + "DMV", 'M', ItemList.Automation_SuperBuffer_HV, 'V', ItemList.Conveyor_Module_HV, 'D', ItemList.Tool_DataOrb}); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Automation_Threaded_SuperBuffer_EV.get(1L, new Object[0]), bitsd, new Object[]{ + "DMV", 'M', ItemList.Automation_SuperBuffer_EV, 'V', ItemList.Conveyor_Module_EV, 'D', ItemList.Tool_DataOrb}); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Automation_Threaded_SuperBuffer_IV.get(1L, new Object[0]), bitsd, new Object[]{ + "DMV", 'M', ItemList.Automation_SuperBuffer_IV, 'V', ItemList.Conveyor_Module_IV, 'D', ItemList.Tool_DataOrb}); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Automation_Threaded_SuperBuffer_LuV.get(1L, new Object[0]), bitsd, new Object[]{ + "DMV", 'M', ItemList.Automation_SuperBuffer_LuV, 'V', ItemList.Conveyor_Module_LuV, 'D', ItemList.Tool_DataOrb}); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Automation_Threaded_SuperBuffer_ZPM.get(1L, new Object[0]), bitsd, new Object[]{ + "DMV", 'M', ItemList.Automation_SuperBuffer_ZPM, 'V', ItemList.Conveyor_Module_ZPM, 'D', ItemList.Tool_DataOrb}); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Automation_Threaded_SuperBuffer_UV.get(1L, new Object[0]), bitsd, new Object[]{ + "DMV", 'M', ItemList.Automation_SuperBuffer_UV, 'V', ItemList.Conveyor_Module_UV, 'D', ItemList.Tool_DataOrb}); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Automation_Threaded_SuperBuffer_MAX.get(1L, new Object[0]), bitsd, new Object[]{ + "DMV", 'M', ItemList.Automation_SuperBuffer_MAX, 'V', GregtechItemList.Conveyor_Module_MAX, 'D', ItemList.Tool_DataOrb}); + } + +} diff --git a/src/resources/assets/miscutils/textures/blocks/iconsets/AUTOMATION_SUPERBUFFER.png b/src/resources/assets/miscutils/textures/blocks/iconsets/AUTOMATION_SUPERBUFFER.png Binary files differnew file mode 100644 index 0000000000..58ecf9f963 --- /dev/null +++ b/src/resources/assets/miscutils/textures/blocks/iconsets/AUTOMATION_SUPERBUFFER.png |