diff options
author | Alkalus <3060479+draknyte1@users.noreply.github.com> | 2022-01-09 17:49:52 +0000 |
---|---|---|
committer | Alkalus <3060479+draknyte1@users.noreply.github.com> | 2022-01-09 17:49:52 +0000 |
commit | 13b79706b6eddef6118453bf51782ad01b3e8328 (patch) | |
tree | 28afa10d207b77e5e127c21ad71dbe8b698c8a84 /src/main/java | |
parent | 77fb0cac1c9c2b57262f41da64926fe2778a3b65 (diff) | |
download | GT5-Unofficial-13b79706b6eddef6118453bf51782ad01b3e8328.tar.gz GT5-Unofficial-13b79706b6eddef6118453bf51782ad01b3e8328.tar.bz2 GT5-Unofficial-13b79706b6eddef6118453bf51782ad01b3e8328.zip |
Partially implemented Computer Cube.
Fix Multis wanting Mufflers when pollution = 0.
Fix getMethodName potentially crawling too far up the stack.
Diffstat (limited to 'src/main/java')
11 files changed, 1666 insertions, 23 deletions
diff --git a/src/main/java/gtPlusPlus/core/lib/CORE.java b/src/main/java/gtPlusPlus/core/lib/CORE.java index d805375e2d..bb0df9d5fb 100644 --- a/src/main/java/gtPlusPlus/core/lib/CORE.java +++ b/src/main/java/gtPlusPlus/core/lib/CORE.java @@ -333,28 +333,33 @@ public class CORE { } public static final void crash(String aReason) { - Logger.INFO("=========================================================="); - Logger.INFO("[GT++ CRASH]"); - Logger.INFO("=========================================================="); - Logger.INFO("Oooops..."); - Logger.INFO("This should only happy in a development environment or when something really bad happens."); - Logger.INFO("Reason: "+aReason); - Logger.INFO("=========================================================="); - Logger.INFO("Called from: "+ReflectionUtils.getMethodName(1)); - Logger.INFO(ReflectionUtils.getMethodName(2)); - Logger.INFO(ReflectionUtils.getMethodName(3)); - Logger.INFO(ReflectionUtils.getMethodName(4)); - Logger.INFO(ReflectionUtils.getMethodName(5)); - Logger.INFO(ReflectionUtils.getMethodName(6)); - Logger.INFO(ReflectionUtils.getMethodName(7)); - Logger.INFO(ReflectionUtils.getMethodName(8)); - Logger.INFO(ReflectionUtils.getMethodName(9)); - Logger.INFO(ReflectionUtils.getMethodName(10)); - Logger.INFO(ReflectionUtils.getMethodName(11)); - Logger.INFO(ReflectionUtils.getMethodName(12)); - Logger.INFO(ReflectionUtils.getMethodName(13)); - Logger.INFO(ReflectionUtils.getMethodName(14)); - Logger.INFO(ReflectionUtils.getMethodName(15)); + try { + Logger.INFO("=========================================================="); + Logger.INFO("[GT++ CRASH]"); + Logger.INFO("=========================================================="); + Logger.INFO("Oooops..."); + Logger.INFO("This should only happy in a development environment or when something really bad happens."); + Logger.INFO("Reason: "+aReason); + Logger.INFO("=========================================================="); + Logger.INFO("Called from: "+ReflectionUtils.getMethodName(1)); + Logger.INFO(ReflectionUtils.getMethodName(2)); + Logger.INFO(ReflectionUtils.getMethodName(3)); + Logger.INFO(ReflectionUtils.getMethodName(4)); + Logger.INFO(ReflectionUtils.getMethodName(5)); + Logger.INFO(ReflectionUtils.getMethodName(6)); + Logger.INFO(ReflectionUtils.getMethodName(7)); + Logger.INFO(ReflectionUtils.getMethodName(8)); + Logger.INFO(ReflectionUtils.getMethodName(9)); + Logger.INFO(ReflectionUtils.getMethodName(10)); + Logger.INFO(ReflectionUtils.getMethodName(11)); + Logger.INFO(ReflectionUtils.getMethodName(12)); + Logger.INFO(ReflectionUtils.getMethodName(13)); + Logger.INFO(ReflectionUtils.getMethodName(14)); + Logger.INFO(ReflectionUtils.getMethodName(15)); + } + catch (Throwable t) { + t.printStackTrace(); + } FMLCommonHandler.instance().exitJava(0, true); } diff --git a/src/main/java/gtPlusPlus/core/util/reflect/ReflectionUtils.java b/src/main/java/gtPlusPlus/core/util/reflect/ReflectionUtils.java index 1ef925f793..aaec2024e4 100644 --- a/src/main/java/gtPlusPlus/core/util/reflect/ReflectionUtils.java +++ b/src/main/java/gtPlusPlus/core/util/reflect/ReflectionUtils.java @@ -335,6 +335,9 @@ public class ReflectionUtils { public static String getMethodName(final int depth) { final StackTraceElement[] ste = new Throwable().getStackTrace(); //System. out.println(ste[ste.length-depth].getClassName()+"#"+ste[ste.length-depth].getMethodName()); + if (ste.length < depth) { + return "No valid stack."; + } return ste[depth+1].getMethodName(); } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java b/src/main/java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java index d42ea35a78..999d80199f 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java @@ -54,6 +54,7 @@ import gtPlusPlus.xmod.gregtech.api.world.GTPP_Worldgen; import gtPlusPlus.xmod.gregtech.common.Meta_GT_Proxy; import gtPlusPlus.xmod.gregtech.common.StaticFields59; import gtPlusPlus.xmod.gregtech.common.blocks.fluid.GregtechFluidHandler; +import gtPlusPlus.xmod.gregtech.common.computer.GT_ComputercubeDescription; import gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedGregtechTools; import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.GregtechMTE_ElementalDuplicator; import gtPlusPlus.xmod.gregtech.loaders.Gregtech_Blocks; @@ -176,6 +177,7 @@ public class HANDLER_GT { convertPyroToCokeOven(); generateElementalDuplicatorRecipes(); Meta_GT_Proxy.fixIC2FluidNames(); + GT_ComputercubeDescription.addStandardDescriptions(); RecipeLoader_AlgaeFarm.generateRecipes(); if (LoadedMods.AdvancedSolarPanel) { RecipeLoader_MolecularTransformer.run(); diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java index 7a7ae278c0..c61195a9e8 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java @@ -105,6 +105,7 @@ public enum GregtechItemList implements GregtechItemContainer { //Computer Cube Gregtech_Computer_Cube, + Gregtech_Computer_Cube_Machine, //Casings for batteries Battery_Casing_Gem_1, Battery_Casing_Gem_2, diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/computer/GT_Container_ComputerCube.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/computer/GT_Container_ComputerCube.java new file mode 100644 index 0000000000..5c5c7961d8 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/computer/GT_Container_ComputerCube.java @@ -0,0 +1,314 @@ +package gtPlusPlus.xmod.gregtech.api.gui.computer; + +import java.util.Iterator; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.GT_Mod; +import gregtech.api.GregTech_API; +import gregtech.api.gui.GT_ContainerMetaTile_Machine; +import gregtech.api.gui.GT_Slot_Holo; +import gregtech.api.gui.GT_Slot_Output; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.util.GT_ModHandler; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.xmod.gregtech.common.tileentities.automation.GT_MetaTileEntity_ElectricInventoryManager; +import gtPlusPlus.xmod.gregtech.common.tileentities.misc.GT_TileEntity_ComputerCube; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.Slot; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; + +public class GT_Container_ComputerCube extends GT_ContainerMetaTile_Machine { + + public int mEUOut; + + public int mHeat; + + public int mMaxHeat; + + public int mHEM; + + public int mExplosionStrength; + + public int mEU; + + public int mProgress; + + public int mID; + + public GT_Container_ComputerCube(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, int aID) { + super(aInventoryPlayer, aTileEntity); + mID = ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).mMode; + } + + public void addSlots(InventoryPlayer aInventoryPlayer) { + int y; + addSlotToContainer(new GT_Slot_Holo((IInventory)this.mTileEntity, 58, 156 + ((this.mID == 5) ? 50 : 0), 4, false, false, 1)); + switch (this.mID) { + case 1: + addSlotToContainer(new GT_Slot_Holo((IInventory)this.mTileEntity, 58, 156, 86, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo((IInventory)this.mTileEntity, 58, 156, 70, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo((IInventory)this.mTileEntity, 58, 156, 54, false, false, 1)); + for (y = 0; y < 6; y++) { + for (int x = 0; x < 9; x++) + addSlotToContainer(new GT_Slot_Holo((IInventory)this.mTileEntity, x + y * 9, 5 + x * 16, 5 + y * 16, false, false, 64)); + } + addSlotToContainer(new GT_Slot_Holo((IInventory)this.mTileEntity, 113, 153, 28, false, false, 64)); + break; + case 2: + addSlotToContainer(new Slot((IInventory)this.mTileEntity, 54, 8, 28)); + addSlotToContainer(new Slot((IInventory)this.mTileEntity, 55, 26, 28)); + addSlotToContainer(new GT_Slot_Output((IInventory)this.mTileEntity, 56, 134, 28)); + addSlotToContainer(new GT_Slot_Output((IInventory)this.mTileEntity, 57, 152, 28)); + break; + case 3: + addSlotToContainer(new GT_Slot_Holo((IInventory)this.mTileEntity, 58, 88, 65, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo((IInventory)this.mTileEntity, 58, 104, 65, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo((IInventory)this.mTileEntity, 59, 122, 35, false, false, 64)); + addSlotToContainer(new GT_Slot_Holo((IInventory)this.mTileEntity, 60, 92, 5, false, false, 64)); + addSlotToContainer(new GT_Slot_Holo((IInventory)this.mTileEntity, 61, 122, 5, false, false, 64)); + addSlotToContainer(new GT_Slot_Holo((IInventory)this.mTileEntity, 62, 152, 35, false, false, 64)); + addSlotToContainer(new GT_Slot_Holo((IInventory)this.mTileEntity, 63, 122, 65, false, false, 64)); + addSlotToContainer(new GT_Slot_Holo((IInventory)this.mTileEntity, 64, 92, 35, false, false, 64)); + break; + case 4: + addSlotToContainer(new GT_Slot_Holo((IInventory)this.mTileEntity, 58, 88, 65, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo((IInventory)this.mTileEntity, 58, 104, 65, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo((IInventory)this.mTileEntity, 59, 122, 5, false, false, 64)); + addSlotToContainer(new GT_Slot_Holo((IInventory)this.mTileEntity, 60, 122, 65, false, false, 64)); + addSlotToContainer(new GT_Slot_Holo((IInventory)this.mTileEntity, 61, 152, 35, false, false, 64)); + break; + case 5: + addSlotToContainer(new GT_Slot_Holo((IInventory)this.mTileEntity, 58, 190, 146, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo((IInventory)this.mTileEntity, 58, 206, 146, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo((IInventory)this.mTileEntity, 59, 206, 38, false, false, 64)); + addSlotToContainer(new GT_Slot_Holo((IInventory)this.mTileEntity, 60, 206, 56, false, false, 64)); + addSlotToContainer(new GT_Slot_Holo((IInventory)this.mTileEntity, 61, 206, 74, false, false, 64)); + addSlotToContainer(new GT_Slot_Holo((IInventory)this.mTileEntity, 62, 206, 92, false, false, 64)); + addSlotToContainer(new GT_Slot_Holo((IInventory)this.mTileEntity, 63, 206, 110, false, false, 64)); + addSlotToContainer(new GT_Slot_Holo((IInventory)this.mTileEntity, 64, 153, 7, false, false, 64)); + addSlotToContainer(new GT_Slot_Holo((IInventory)this.mTileEntity, 65, 169, 7, false, false, 64)); + addSlotToContainer(new GT_Slot_Holo((IInventory)this.mTileEntity, 66, 185, 7, false, false, 64)); + addSlotToContainer(new GT_Slot_Holo((IInventory)this.mTileEntity, 67, 153, 23, false, false, 64)); + addSlotToContainer(new GT_Slot_Holo((IInventory)this.mTileEntity, 68, 169, 23, false, false, 64)); + addSlotToContainer(new GT_Slot_Holo((IInventory)this.mTileEntity, 69, 185, 23, false, false, 64)); + addSlotToContainer(new GT_Slot_Holo((IInventory)this.mTileEntity, 70, 153, 39, false, false, 64)); + addSlotToContainer(new GT_Slot_Holo((IInventory)this.mTileEntity, 71, 169, 39, false, false, 64)); + addSlotToContainer(new GT_Slot_Holo((IInventory)this.mTileEntity, 72, 185, 39, false, false, 64)); + break; + case 6: + addSlotToContainer(new GT_Slot_Holo((IInventory)this.mTileEntity, 58, 88, 65, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo((IInventory)this.mTileEntity, 58, 104, 65, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo((IInventory)this.mTileEntity, 59, 122, 35, false, false, 64)); + addSlotToContainer(new GT_Slot_Holo((IInventory)this.mTileEntity, 60, 92, 5, false, false, 64)); + addSlotToContainer(new GT_Slot_Holo((IInventory)this.mTileEntity, 61, 122, 5, false, false, 64)); + addSlotToContainer(new GT_Slot_Holo((IInventory)this.mTileEntity, 62, 152, 35, false, false, 64)); + addSlotToContainer(new GT_Slot_Holo((IInventory)this.mTileEntity, 63, 122, 65, false, false, 64)); + addSlotToContainer(new GT_Slot_Holo((IInventory)this.mTileEntity, 64, 92, 35, false, false, 64)); + break; + } + } + + public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer) { + Logger.INFO("Clicked slot "+aSlotIndex); + if (aSlotIndex < 0) { + Logger.INFO(""); + return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); + } + if (this.mID != ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).mMode) { + Logger.INFO("This ID: "+mID+", Tile: "+((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).mMode); + return null; + } + Slot tSlot = (Slot) this.inventorySlots.get(aSlotIndex); + ItemStack tStack = tSlot.getStack(); + if (tSlot == null) { + Logger.INFO("Null Slot?"); + } + else { + Logger.INFO("Good Slot!"); + if (aSlotIndex == 0) { + Logger.INFO("Slot is 0"); + if (aMouseclick == 0) { + Logger.INFO("Forward"); + ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).switchModeForward(); + } else { + Logger.INFO("Backwards"); + ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).switchModeBackward(); + } + //aPlayer.openGui(CORE.MODID, GT_BlockMetaID_Machine.getComputerCubeGUIID((TileEntity)this.mTileEntity), this.mTileEntity.getWorld(), this.mTileEntity.getXCoord(), this.mTileEntity.getYCoord(), this.mTileEntity.getZCoord()); + } else if (aSlotIndex <= 2 && this.mID == 3) { + if (aSlotIndex == 1) { + ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).switchCentrifugePageBackward(); + onCraftMatrixChanged((IInventory)this.mTileEntity); + } else if (aSlotIndex == 2) { + ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).switchCentrifugePageForward(); + onCraftMatrixChanged((IInventory)this.mTileEntity); + } + } else if (aSlotIndex <= 2 && this.mID == 6) { + if (aSlotIndex == 1) { + ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).switchElectrolyzerPageBackward(); + onCraftMatrixChanged((IInventory)this.mTileEntity); + } else if (aSlotIndex == 2) { + ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).switchElectrolyzerPageForward(); + onCraftMatrixChanged((IInventory)this.mTileEntity); + } + } else if (aSlotIndex <= 2 && this.mID == 4) { + if (aSlotIndex == 1) { + ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).switchFusionPageBackward(); + onCraftMatrixChanged((IInventory)this.mTileEntity); + } else if (aSlotIndex == 2) { + ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).switchFusionPageForward(); + onCraftMatrixChanged((IInventory)this.mTileEntity); + } + } else if (aSlotIndex <= 2 && this.mID == 5) { + if (aSlotIndex == 1) { + ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).switchDescriptionPageBackward(); + onCraftMatrixChanged((IInventory)this.mTileEntity); + } else if (aSlotIndex == 2) { + ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).switchDescriptionPageForward(); + onCraftMatrixChanged((IInventory)this.mTileEntity); + } + } else if (aSlotIndex <= 58 && this.mID == 1) { + if (aSlotIndex == 1) { + ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).switchNuclearReactor(); + onCraftMatrixChanged((IInventory)this.mTileEntity); + } else if (aSlotIndex == 2) { + ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).loadNuclearReactor(); + onCraftMatrixChanged((IInventory)this.mTileEntity); + } else if (aSlotIndex == 3) { + ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).saveNuclearReactor(); + } else { + if (aShifthold == 1) { + tSlot.putStack(null); + return null; + } + if (aMouseclick == 0) { + if (tStack == null) { + if (getSlot(58).getStack() != null && aSlotIndex != 58) { + tSlot.putStack(getSlot(58).getStack().copy()); + } else { + tSlot.putStack(new ItemStack(GT_TileEntity_ComputerCube.sReactorList.get(0).mItem, 1)); + } + return null; + } + for (int i = 1; i < GT_TileEntity_ComputerCube.sReactorList.size(); i++) { + if (GT_TileEntity_ComputerCube.sReactorList.get(i - 1).mItem == tStack.getItem()) { + tSlot.putStack(new ItemStack(GT_TileEntity_ComputerCube.sReactorList.get(i).mItem, 1, 0)); + if (tSlot.getStack() != null && tSlot.getStack().getItem() == GT_ModHandler.getIC2Item("reactorIsotopeCell", 1).getItem()) + tSlot.getStack().setItemDamage(tSlot.getStack().getMaxDamage() - 1); + return null; + } + } + tSlot.putStack(null); + return null; + } + if (tStack == null) + return null; + if (tStack.stackSize < tStack.getMaxStackSize()) { + tStack.stackSize++; + return null; + } + tStack.stackSize = 1; + return null; + } + } else { + Logger.INFO("Super 2"); + return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); + } + } + Logger.INFO("???"); + return null; + } + + public boolean doesBindPlayerInventory() { + return (this.mID != 1 && this.mID != 5); + } + + public void detectAndSendChanges() { + super.detectAndSendChanges(); + if (mTileEntity.isClientSide() || mTileEntity.getMetaTileEntity() == null) { + return; + } + //this.mID = ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).mMode; + this.mEUOut = ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).mEUOut; + this.mHeat = ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).mHeat; + this.mMaxHeat = ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).mMaxHeat; + this.mHEM = (int)(((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).mHEM * 10000.0F); + this.mExplosionStrength = (int)(((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).mExplosionStrength * 100.0F); + this.mEU = ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).mEU; + this.mProgress = ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).mProgress; + Iterator<ICrafting> var2 = this.crafters.iterator(); + while (var2.hasNext()) { + ICrafting var1 = var2.next(); + var1.sendProgressBarUpdate((Container)this, 101, this.mEUOut); + var1.sendProgressBarUpdate((Container)this, 102, this.mHeat & 0xFFFF); + var1.sendProgressBarUpdate((Container)this, 103, this.mMaxHeat & 0xFFFF); + var1.sendProgressBarUpdate((Container)this, 104, this.mHEM); + var1.sendProgressBarUpdate((Container)this, 105, this.mExplosionStrength); + var1.sendProgressBarUpdate((Container)this, 106, this.mHeat >>> 16); + var1.sendProgressBarUpdate((Container)this, 107, this.mMaxHeat >>> 16); + var1.sendProgressBarUpdate((Container)this, 108, this.mEU & 0xFFFF); + var1.sendProgressBarUpdate((Container)this, 109, this.mEU >>> 16); + var1.sendProgressBarUpdate((Container)this, 110, this.mProgress); + //var1.sendProgressBarUpdate((Container)this, 111, this.mEUOut); + } + } + + @SideOnly(Side.CLIENT) + public void updateProgressBar(int par1, int par2) { + super.updateProgressBar(par1, par2); + switch (par1) { + case 101: + this.mEUOut = par2; + break; + case 102: + this.mHeat = this.mHeat & 0xFFFF0000 | par2; + break; + case 103: + this.mMaxHeat = this.mMaxHeat & 0xFFFF0000 | par2; + break; + case 104: + this.mHEM = par2; + break; + case 105: + this.mExplosionStrength = par2; + break; + case 106: + this.mHeat = this.mHeat & 0xFFFF | par2 << 16; + break; + case 107: + this.mMaxHeat = this.mMaxHeat & 0xFFFF | par2 << 16; + break; + case 108: + this.mEU = this.mEU & 0xFFFF0000 | par2; + case 109: + this.mEU = this.mEU & 0xFFFF | par2 << 16; + break; + case 110: + this.mProgress = par2; + break; + case 111: + //this.mID = par2; + break; + } + } + + public int getSlotStartIndex() { + return 1; + } + + public int getSlotCount() { + return (this.mID == 2) ? 4 : 0; + } + + public int getShiftClickSlotCount() { + return (this.mID == 2) ? 2 : 0; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/computer/GT_GUIContainer_ComputerCube.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/computer/GT_GUIContainer_ComputerCube.java new file mode 100644 index 0000000000..0006ce8823 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/computer/GT_GUIContainer_ComputerCube.java @@ -0,0 +1,133 @@ +package gtPlusPlus.xmod.gregtech.api.gui.computer; + +import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.xmod.gregtech.common.computer.GT_ComputercubeDescription; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; + +public class GT_GUIContainer_ComputerCube extends GT_GUIContainerMetaTile_Machine { + public GT_GUIContainer_ComputerCube(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aBaseMetaTileEntity, int aID) { + super(new GT_Container_ComputerCube(aInventoryPlayer, aBaseMetaTileEntity, aID), CORE.RES_PATH_GUI + "computer/"+aID+".png"); + if (aID == 5) + this.xSize += 50; + } + + protected void drawGuiContainerForegroundLayer(int par1, int par2) { + GT_Container_ComputerCube tContainer = (GT_Container_ComputerCube) this.mContainer; + //GT_TileEntity_ComputerCube tTileEntity = (GT_TileEntity_ComputerCube) tContainer.mTileEntity; + if (tContainer != null) + switch (tContainer.mID) { + case 0 : + this.fontRendererObj.drawString("G.L.A.D.-OS", 64, 61, 16448255); + this.fontRendererObj.drawString(StatCollector.translateToLocal("container.inventory"), 8, this.ySize - 96 + 2, 4210752); + break; + case 1 : + this.fontRendererObj.drawString("Reactorstats:", 7, 108, 16448255); + this.fontRendererObj.drawString(toNumber(tContainer.mEU) + "EU at " + tContainer.mEUOut + "EU/t", 7, 120, 16448255); + this.fontRendererObj.drawString("HEM: " + (tContainer.mHEM / 10000.0F), 7, 128, 16448255); + this.fontRendererObj.drawString(toNumber(tContainer.mHeat) + "/" + toNumber(tContainer.mMaxHeat) + "Heat", 7, 136, 16448255); + this.fontRendererObj.drawString("Explosionpower: " + (tContainer.mExplosionStrength / 100.0F), 7, 144, 16448255); + this.fontRendererObj.drawString("Runtime: " + ((tContainer.mEUOut > 0) ? ((tContainer.mEU / tContainer.mEUOut) / 20.0F) : 0.0F) + "secs", 7, 152, 16448255); + break; + case 2 : + this.fontRendererObj.drawString("Scanner", 51, 7, 16448255); + if (tContainer.mProgress == 0) { + this.fontRendererObj.drawString("Can be used to", 51, 24, 16448255); + this.fontRendererObj.drawString("scan Seedbags", 51, 32, 16448255); + } + else { + this.fontRendererObj.drawString("Progress:", 51, 24, 16448255); + this.fontRendererObj.drawString(tContainer.mProgress + "%", 51, 32, 16448255); + } + this.fontRendererObj.drawString(StatCollector.translateToLocal("container.inventory"), 8, this.ySize - 96 + 2, 4210752); + break; + case 3 : + this.fontRendererObj.drawString("Centrifuge", 7, 7, 16448255); + this.fontRendererObj.drawString("Recipe: " + (tContainer.mMaxHeat + 1) + "/" + GT_Recipe_Map.sCentrifugeRecipes.mRecipeList.size(), 7, 23, 16448255); + this.fontRendererObj.drawString("EU: " + toNumber(tContainer.mEU), 7, 31, 16448255); + break; + case 4 : + this.fontRendererObj.drawString("Fusionreactor", 7, 7, 16448255); + this.fontRendererObj.drawString("Recipe: " + (tContainer.mMaxHeat + 1) + "/" + GT_Recipe_Map.sFusionRecipes.mRecipeList.size(), 7, 23, 16448255); + this.fontRendererObj.drawString("Start: " + toNumber(tContainer.mEU) + "EU", 7, 31, 16448255); + this.fontRendererObj.drawString("EU/t: " + toNumber(tContainer.mEUOut), 7, 39, 16448255); + this.fontRendererObj.drawString(toNumber(tContainer.mHeat) + " Ticks", 7, 47, 16448255); + if (tContainer.mEUOut < 0) { + this.fontRendererObj.drawString("IN: " + toNumber(-tContainer.mEUOut * tContainer.mHeat) + "EU", 7, 55, 16448255); + break; + } + this.fontRendererObj.drawString("OUT: " + toNumber(tContainer.mEUOut * tContainer.mHeat) + "EU", 7, 55, 16448255); + break; + case 5 : + if (tContainer.mMaxHeat >= 0 && tContainer.mMaxHeat < GT_ComputercubeDescription.sDescriptions.size()) + for (int i = 0; i < ((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(tContainer.mMaxHeat)).mDescription.length; i++) { + if (i == 0) { + this.fontRendererObj.drawString(((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(tContainer.mMaxHeat)).mDescription[i], 7, 7, 16448255); + } + else { + this.fontRendererObj.drawString(((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(tContainer.mMaxHeat)).mDescription[i], 7, 7 + + 8 * i, 16448255); + } + } + break; + case 6 : + this.fontRendererObj.drawString("Electrolyzer", 7, 7, 16448255); + this.fontRendererObj.drawString("Recipe: " + (tContainer.mMaxHeat + 1) + "/" + GT_Recipe_Map.sElectrolyzerRecipes.mRecipeList.size(), 7, 23, 16448255); + this.fontRendererObj.drawString("EU: " + toNumber(tContainer.mEU), 7, 31, 16448255); + break; + } + } + + protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { + super.drawGuiContainerBackgroundLayer(par1, par2, par3); + int x = (width - xSize) / 2; + int y = (height - ySize) / 2; + drawTexturedModalRect(x, y, 0, 0, xSize, ySize); + + if (mContainer != null) { + GT_Container_ComputerCube tContainer = (GT_Container_ComputerCube) this.mContainer; + mGUIbackground = new ResourceLocation(mGUIbackgroundPath = CORE.RES_PATH_GUI + "computer/"+ ((GT_Container_ComputerCube) this.mContainer).mID + ".png"); + + switch (tContainer.mID) { + case 5 : + if (tContainer.mExplosionStrength != 0) + drawTexturedModalRect(x + 152, y + 6, 0, 166, 50, 50); + break; + } + } + + } + + public String toNumber(int aNumber) { + String tString = ""; + boolean temp = true, negative = false; + if (aNumber < 0) { + aNumber *= -1; + negative = true; + } + int i; + for (i = 1000000000; i > 0; i /= 10) { + int tDigit = aNumber / i % 10; + if (temp && tDigit != 0) + temp = false; + if (!temp) { + tString = tString + tDigit; + if (i != 1) { + int j; + for (j = i; j > 0;) { + if (j == 1) + tString = tString + ","; + j /= 1000; + } + } + } + } + if (tString.equals("")) + tString = "0"; + return negative ? ("-" + tString) : tString; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java index e2ca92d8b0..ec7115cb0f 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java @@ -1690,7 +1690,7 @@ public abstract class GregtechMeta_MultiBlockBase<T extends GT_MetaTileEntity_En } public boolean checkHatch() { - return mMaintenanceHatches.size() <= 1 && !mMufflerHatches.isEmpty(); + return mMaintenanceHatches.size() <= 1 && (this.getPollutionPerSecond(null) > 0 ? !mMufflerHatches.isEmpty() : true); } public <E> boolean addToMachineListInternal(ArrayList<E> aList, final IGregTechTileEntity aTileEntity, final int aBaseCasingIndex) { diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java index 84c0686d61..8f68b646f9 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java @@ -432,6 +432,7 @@ public class TexturesGtBlock { public static final CustomIcon Casing_Electric_Auto_Workbench_Side = new CustomIcon("TileEntities/gt4/OVERLAY_SIDE_CABINET"); + public static final CustomIcon Casing_Computer_Cube = new CustomIcon("TileEntities/gt4/computer"); public static final CustomIcon Casing_CropHarvester_Cutter = new CustomIcon("TileEntities/gt4/OVERLAY_CROP"); public static final CustomIcon Casing_CropHarvester_Boxes = new CustomIcon("TileEntities/gt4/OVERLAY_BOXES"); diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/computer/GT_ComputercubeDescription.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/computer/GT_ComputercubeDescription.java new file mode 100644 index 0000000000..ba48df1311 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/computer/GT_ComputercubeDescription.java @@ -0,0 +1,189 @@ +package gtPlusPlus.xmod.gregtech.common.computer; + +import java.util.ArrayList; + +import gregtech.api.enums.ItemList; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.util.minecraft.FluidUtils; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import net.minecraft.item.ItemStack; + +public class GT_ComputercubeDescription { + public static ArrayList<GT_ComputercubeDescription> sDescriptions = new ArrayList<GT_ComputercubeDescription>(); + + public String[] mDescription; + + public ItemStack[] mStacks; + + public GT_ComputercubeDescription(String[] aDescription, ItemStack[] aStacks) { + this.mDescription = aDescription; + this.mStacks = aStacks; + sDescriptions.add(this); + } + + public static void addStandardDescriptions() { + Logger.INFO("Adding Default Description Set of the Computer Cube"); + new GT_ComputercubeDescription(new String[] { + "Lightning Rod", "Also known as the Bane of", "Alblaka. The Lightning Rod", "enables you to gain Energy", "from Lightning! To set it up", "you just need the Block", "itself, 4 HV-Transformers", "and a crapton of Ironfences,", "which you then place on top", "of it. After that you have to", + "wait for a Thunderstorm and", "when you are lucky you get", "2.5 MFSU of Energy out of", "it. If a Rod is high enough", "then Rain is also enough to", "get stroke, but with less", "probability ofcourse." }, new ItemStack[] { + GT_ModHandler.getIC2Item("ironFence", 1), GT_ModHandler.getIC2Item("ironFence", 1), GT_ModHandler.getIC2Item("ironFence", 1), GT_ModHandler.getIC2Item("ironFence", 1), ItemList.Machine_IV_LightningRod.get(1), null, null, null, null, null, + null, null, null, null }); + new GT_ComputercubeDescription(new String[] { + "Quantum Chest", "You want to store tons of", "Materials into your Chests", "but you hate the Item limit", "of them? Not anymore! The", "Quantum Chest is able to", "store an INFINITE* amount", "of one single Item type per", "Chest.", "This Chest stores your Items", + "like Data and ever has a", "Stack of the Item ready for", "extraction. It is compatible", "with any Item that doesnt", "have a NBT-Tag. You ask what", "NBT is? I know it, thats enough.", "* = 2147483391" }, new ItemStack[] { + null, null, null, null, ItemList.Quantum_Chest_LV.get(1), null, null, null, null, null, + null, null, null, null }); + new GT_ComputercubeDescription(new String[] { + "Computer Cube", "The Device you are", "currently using. This Computer", "is running the G.L.A.D.-OS,", "which is containing many", "usefull Apps:", "- Reactor Planner", "- Seedbag Scanner", "- Recipelists for GT-Devices", "- ", + "- ", "- ", "- ", "- ", "And the Description List you", "are currently reading.", "~This Device has private Access~" }, new ItemStack[] { + null, null, null, null, GregtechItemList.Gregtech_Computer_Cube.get(1), null, null, null, null, null, + null, null, null, null }); + /* new GT_ComputercubeDescription(new String[] { + "UUM-Assembler", "It's like an automatic", "Crafting Table just for UUM", "It can store 20 UUM-Recipes", "and produces those on demand", "It costs 512EU per used piece", "of Universal-Usable-Matter(TM).", "The integrated Quantum Chest", "allows it to store all your", "UUM inside it.", + "Top and Bottom are for Input,", "while the Output is on the", "Sides. The Output is designed,", "to work with RP-Managers, so", "build it into your recursive", "Autocraftingsystem.", "" }, new ItemStack[] { + null, null, null, GT_ModHandler.getIC2Item("matter", 1), new ItemStack(GregTech_API.sBlockList[1], 1, 5), null, null, null, null, null, + null, null, null, null }); + new GT_ComputercubeDescription(new String[] { + "Sonictron", "You like Music? Then the", "Sonictron 9001 is your best", "choice! You can compose Alarms,", "Doorbell Sounds or boring", "Elevator Music, with the 64 Slots", "inside it. Just leftclick them", "to switch the Sound, rightclick", "them to switch the modulation", "and shiftclick to remove it.", + "Then apply Redstone to play", "With the mobile Version you can", "play sounds everywhere, after", "you copied them from a normal", "Sonictron via rightclicking", "Sneakrightclicking pastes", "Emits Redstone when finished." }, new ItemStack[] { + null, null, null, GregTech_API.getGregTechItem(32, 1, 0), new ItemStack(GregTech_API.sBlockList[1], 1, 6), null, null, null, null, null, + null, null, null, null }); + new GT_ComputercubeDescription(new String[] { + "L.E.S.U.", "The unlaggiest Multiblock ever!", "One Controllerblock, and as many", "'stupid' Storageblocks as you want.", "To use it, place one Controller", "and then place the LESU-Storages", "adjacent to it or other placed", "LESU-Storages. The Tier (max EU/t)", "of it depends on the amount of", "adjacent Storages. The", + "Storageblocks are NOT TileEntities,", "what means that they cause as much", "Lag as a random Dirtblock. And the", "Controller Block only checks ONCE", "for the Storages, so no", "Blockiterationlag, AT. ALL. Anyone,", "who says that they lag gets murdered!" }, new ItemStack[] { + null, null, null, new ItemStack(GregTech_API.sBlockList[0], 1, 6), new ItemStack(GregTech_API.sBlockList[1], 1, 7), null, null, null, null, null, + null, null, null, null }); + new GT_ComputercubeDescription(new String[] { + "I.D.S.U.", "The Interdimensional Storage Unit", "is a Device, which is like a", "wireless, crossdimensional and", "enderchestlike EU-Storage Block", "", "Every Player has one Network of", "these. The ID is determined by", "the Hashcode of the Name from the", "first Player, who opens it's GUI", + "", "It stores up to 1 Billion EU", "and emits EV. But you need at", "least two of them for Energy", "Transfer", "", "" }, new ItemStack[] { + null, null, null, null, new ItemStack(GregTech_API.sBlockList[1], 1, 8), null, null, null, null, null, + null, null, null, null }); + new GT_ComputercubeDescription(new String[] { + "A.E.S.U.", "The Adjustable Energy Storage Unit", "is like 10 MFSU and has an", "adjustable Output between 0 and", "2048EU/t. You could use it as a", "Transformer. It is Tier-IV, so", "it's basically needed to charge", "Energy Orbs and Lapotron Packs", "", "Not much else to say about it.", + "", "", "", "", "", "", "" }, new ItemStack[] { + null, null, null, null, new ItemStack(GregTech_API.sBlockList[1], 1, 9), null, null, null, null, null, + null, null, null, null }); + new GT_ComputercubeDescription(new String[] { + "Charge-O-Mat", "An automatable Charging Bench", "It puts (de-)charged Tools into", "the right Outputslots, which are", "accessible on the Sides of it.", "", "The Energy Orb inside stores enough", "to charge your QSuit almost instantly", "", "This is a Tier-V Charging Station", + "even when the Max-IN/OUT is only", "2048EU/t. It also charges your Armor", "when you are standing close to it.", "", "If you apply Redstone, then it", "decharges instead.", "" }, new ItemStack[] { + null, null, null, null, new ItemStack(GregTech_API.sBlockList[1], 1, 10), null, null, null, null, null, + null, null, null, null }); + new GT_ComputercubeDescription(new String[] { + "Centrifuge", "This is a Machine to seperate", "Isotopes.", "", "It has a maximum Consumption Rate", "of 5EU/t, and its Maxinput is", "32EU/t. The time it needs depends", "on the Recipe you use.", "", "It needs Tin Cells for some Recipes,", + "which you put in the Top Left Slot", "", "Top = Input", "Bottom = Tin Cells", "Side = Output", "", "You can pipe Lava into this Device" }, new ItemStack[] { + null, null, null, null, new ItemStack(GregTech_API.sBlockList[1], 1, 11), null, null, null, null, null, + null, null, null, null }); + new GT_ComputercubeDescription(new String[] { + "Electrolyzer", "This is a Machine to seperate", "Molecules and electrolyze", "Watercells.", "", "It has a maximum Consumption Rate", "of 128EU/t, and its Maxinput is", "128EU/t. The time it needs depends", "on the Recipe you use.", "", + "It needs Tin Cells for some Recipes,", "which you put in the Bottom Left Slot", "", "Top = Input", "Bottom = Tin Cells", "Side = Output", "" }, new ItemStack[] { + null, null, null, null, new ItemStack(GregTech_API.sBlockList[1], 1, 25), null, null, null, null, null, + null, null, null, null }); + new GT_ComputercubeDescription(new String[] { + "Grinder", "This Machines purpose is to", "macerate and grind Ores.", "It can ONLY grind Ores, don't", "try regular Macerator Recipes.", "It has a fixed Consumption Rate", "of 128EU/t, and its Maxinput is", "128EU/t. The time it needs is", "5 seconds per Ore Block", "It needs Water for most Recipes,", + "which you put in the Bottom Left Slot", "Top = Input", "Bottom = Water", "Side = Output", "Its a lagfree Multiblock Structure,", "so you need a special Machine Casing", "for this Device. (see GUI)" }, new ItemStack[] { + null, new ItemStack(Block.field_71943_B, 1), new ItemStack(GregTech_API.sBlockList[0], 1, 14), new ItemStack(GregTech_API.sBlockList[0], 1, 13), new ItemStack(GregTech_API.sBlockList[1], 1, 28), null, null, null, null, null, + null, null, null, null });*/ + new GT_ComputercubeDescription(new String[] { + "Electric Blast Furnace", "You may know the Blast Furnace", "of Railcraft. This one works", "similar, as it can also produce", "Steel out of Iron and Coal.", "", "Its heat Capacity depends on the", "used Machine Casings for building", "it. The better they are, the more", "Heat it can achieve.", + "", "Top = Input 1", "Bottom = Input 2", "Side = Output", "Its a lagfree Multiblock Structure,", "so you need a special Machine Casing", "for this Device. (see GUI)" }, new ItemStack[] { + null, null, null, null, ItemList.Machine_Multi_BlastFurnace.get(1), null, null, null, null, null, + null, null, null, null }); + /* new GT_ComputercubeDescription(new String[] { + "Sawmill", "This Device turns your Logs", "into more Planks, than a normal", "Steve can produce with his Hands.", "", "Its byproduct, Wood Pulp, can be", "compressed into special Planks,", "which are burning like Charcoal.", "", "It needs Water for most Recipes,", + "which you put in the Bottom Left Slot", "Top = Input", "Water Sides = Water", "Saw Side = Output", "Its a lagfree Multiblock Structure,", "so you need a special Machine Casing", "for this Device. (see GUI)" }, new ItemStack[] { + null, null, GT_MetaItem_Material.instance.getStack(15, 1), GT_MetaItem_Dust.instance.getStack(15, 1), new ItemStack(GregTech_API.sBlockList[1], 1, 32), null, null, null, null, null, + null, null, null, null });*/ + new GT_ComputercubeDescription(new String[] { + "Implosion Compressor", "You need to turn Dusts back", "into Gems? Or do you just want", "to make Iridium Plates?", "With a bit ITNT you can achieve", "that in this Device!", "", "We strongly recommend to use", "Flint Dust instead of Flints", "for making the ITNT.", + "", "Top = Input", "Explosion Sides = Output", "ITNT Side = ITNT Input", "Its a lagfree Multiblock Structure,", "so you need a special Machine Casing", "for this Device. (see GUI)" }, new ItemStack[] { + null, null, null, GT_ModHandler.getIC2Item("industrialTnt", 1, new ItemStack(net.minecraft.init.Blocks.tnt, 1)), ItemList.Machine_Multi_ImplosionCompressor.get(1), null, null, null, null, null, + null, null, null, null }); + /* new GT_ComputercubeDescription(new String[] { + "Superconductor", "Expensive, but superconducting", "nearly infinite EU/p and it has", "no Cableloss!", "Do not confuse this with the", "Superconductor Item!", "", "Supercondensator", "This is a special kind of Transformer", "It allows you to convert anything down", + "to 8192 EU/t, what is like a normal HVT.", "But if you apply Redstone to it then it", "outputs friggin 1000000EU/t!!!", "", "You also need it for the Fusion Reactor.", "Some Machines will require that high", "Voltage in a short period of time." }, new ItemStack[] { + null, null, GregTech_API.getGregTechItem(3, 1, 2), new ItemStack(GregTech_API.sBlockList[1], 1, 12), new ItemStack(GregTech_API.sBlockList[1], 1, 15), null, null, null, null, null, + null, null, null, null }); + new GT_ComputercubeDescription(new String[] { + "Player Detector", "This nice little Device is able", "to detect Players in a Range of", "16-Spherical Meters and a", "EU-Consumption of 2.5EU/t.", "", "It can be switched to 3 Diffrent", "Modes, to detect YOURSELF, OTHERS", "and ALL Players by Rightclicking it.", "", + "It doesnt detect regular Mobs.", "", "", "", "", "", "~This Device has private Access~" }, new ItemStack[] { + null, null, null, null, new ItemStack(GregTech_API.sBlockList[1], 1, 13), null, null, null, null, null, + null, null, null, null });*/ + new GT_ComputercubeDescription(new String[] { + "Matter Fabricator", "The Matter Fabricator is nothing", "else than a Mass Fabricator, which", "can ONLY run on Scrap and other", "Amplifiers.", "", "With the Default Config it is 100", "times more expensive than normal.", "Of course you can set the Config", "to 166666, to get your normal", + "Massfabricationrate back, or you", "could make Mass Fabrication even", "cheaper, if you really want to", "make Mass Fabrication that easy", "", "", "" }, new ItemStack[] { + null, null, null, GT_Utility.getFluidDisplayStack(FluidUtils.getUUA(1), false), ItemList.Machine_LV_Massfab.get(1), null, null, null, null, null, + null, null, null, null }); + new GT_ComputercubeDescription(new String[] { + "Electric Autocrafting Tables", "These are Crafting Tables for the", "common need of autocrafting in", "Factories. One Craft needs 5000EU to", "be performed, so you have actually to", "lay Wires to it. This Table is", "unique as its also able, to give you", "the used Capsulecellcontainers, made", "by Industrial Corp, back.", "You may use that behaviour to", + "craft anything releated to chemics,", "like the 2xKNO3-Recipe for Saltpeter.", "The 5 Modes are the following:", "1. Craft Recipe, 2. All 5 Modes", "3. Craft all as single Items", "4. 2x2-Grid and 5. a 3x3-Grid.", "It accepts only 32EU/p as Input." }, new ItemStack[] { + null, null, null, null, GregtechItemList.GT4_Electric_Auto_Workbench_LV.get(1), null, null, null, null, null, + null, null, null, null }); + /* new GT_ComputercubeDescription(new String[] { + "Automation with GregTech", "Translocators and Buffers are the", "newest Way to automate your Machines.", "Screw Buildcraft, these EU-wasting", "Devices are much more awesome.", "They output 32EU/t to their directed", "IN- and OUT-puts, making them usefull", "for things, like saving wires.", "Translocators are taking Stuff from", "the Block at their green Inputfacing", + "and putting it into the Block at the", "red Outputfacing. Buffers do the same,", "but the grab Items from their own", "Inventory, what makes them usefull", "as Pipe-replacement.", "Buffers also have Redstone Intelligence,", "which you can configure in their GUI." }, new ItemStack[] { + null, null, new ItemStack(GregTech_API.sBlockList[1], 1, 19), new ItemStack(GregTech_API.sBlockList[1], 1, 18), new ItemStack(GregTech_API.sBlockList[1], 1, 17), null, null, null, null, null, + null, null, null, null }); + new GT_ComputercubeDescription(new String[] { + "Silver Ore", "It's rarity is similar to Gold", "Silver can be used, to make", "Circuits cheaper, or you can use", "it for Redpowerstuff.", "", "", "", "", "", + "", "", "", "", "", "", "" }, new ItemStack[] { + null, null, GT_OreDictUnificator.get("dustSilver", 1), GregTech_API.getGregTechItem(0, 1, 17), new ItemStack(GregTech_API.sBlockList[2], 1, 1), null, null, null, null, null, + null, null, null, null }); + new GT_ComputercubeDescription(new String[] { + "Sapphires and Rubys", "These spawn exactly like Emeralds.", "But Rubies are found in Deserts,", "while Sapphires can be found in", "Oceans.", "", "They currently make only a cheaper", "Recipe for Energycrystals and", "Lapotroncrystals, but they are", "Redpower Compatible.", + "", "They also sometimes drop random", "other Gems, like Garnet for Ruby", "or green Sapphire for Sapphire", "in addition.", "", "" }, new ItemStack[] { + null, GregTech_API.getGregTechItem(0, 1, 32), new ItemStack(GregTech_API.sBlockList[2], 1, 3), GregTech_API.getGregTechItem(0, 1, 33), new ItemStack(GregTech_API.sBlockList[2], 1, 4), null, null, null, null, null, + null, null, null, null }); + new GT_ComputercubeDescription(new String[] { + "Bauxite Ore", "The Stuff out of which you can", "produce Aluminium and also", "Titanium.", "You find this Ore in Plains and", "Forests.", "", "If you think Aluminium is useless", "then note, that mobs NEVER spawn", "ontop of an Aluminium Block", + "(Same applies also for Silver-,", "Gem- and Iridium Blocks)", "Production Chain:", "macerating Bauxite Ore", "electrolyzing 24 Bauxite Dust", "smelting Aluminium Dust in a", "Blast Furnace" }, new ItemStack[] { + new ItemStack(GregTech_API.sBlockList[0], 1, 7), GregTech_API.getGregTechItem(0, 1, 18), GregTech_API.getGregTechItem(1, 1, 18), GregTech_API.getGregTechItem(1, 1, 17), new ItemStack(GregTech_API.sBlockList[2], 1, 5), null, null, null, null, null, + null, null, null, null }); + new GT_ComputercubeDescription(new String[] { + "Titanium", "Produced by centrifuging Bauxitedust", "as a byproduct, this Material can make", "anything much more resistant against", "damage, like Explosions.", "Blocks made of Titaniumingots have a", "large Blastresistance", "", "It can also be used to craft tons of", "mixed Metal Ingots", + "", "", "", "", "", "", "" }, new ItemStack[] { + new ItemStack(GregTech_API.sBlockList[0], 1, 8), GregTech_API.getGregTechItem(0, 1, 19), GregTech_API.getGregTechItem(1, 1, 19), GregTech_API.getGregTechItem(1, 1, 17), new ItemStack(GregTech_API.sBlockList[2], 1, 5), null, null, null, null, null, + null, null, null, null }); + new GT_ComputercubeDescription(new String[] { + "Iridium Ore", "You can find it only when you", "stripmine very large Areas with", "Quarries and such. There is only", "one in every 5th-10th Chunk.", "It's even more rare in Oceans!", "", "Some people disable the UUM-Recipe", "for Iridium, for making getting it", "an Achievement.", + "", "However Iridium Ore contains traces", "of Platinum, so it's best to use the", "Industrial Grinder for this Ore.", "", "", "" }, new ItemStack[] { + null, null, GT_OreDictUnificator.get("plateAlloyIridium", 1), GT_ModHandler.getIC2Item("iridiumOre", 1), new ItemStack(GregTech_API.sBlockList[2], 1, 2), null, null, null, null, null, + null, null, null, null }); + new GT_ComputercubeDescription(new String[] { + "Helium Coolant Cell", "These are just cheaper, than the", "Water based Coolant Cells, and can", "also hold six times more Heat.", "", "Helium Cells can also be used for", "making Luminators and Mininglasers", "", "", "", + "", "", "", "", "", "", "" }, new ItemStack[] { + GregTech_API.getGregTechItem(2, 1, 6), GregTech_API.getGregTechItem(2, 1, 3), GregTech_API.getGregTechItem(34, 1, 0), GregTech_API.getGregTechItem(35, 1, 0), GregTech_API.getGregTechItem(36, 1, 0), null, null, null, null, null, + null, null, null, null }); + new GT_ComputercubeDescription(new String[] { + "Destructopack", "Open its GUI via rightclick and", "dump all the useless Stuff from", "your Inventory into it, instead of", "littering Items into the World.", "", "", "", "", "", + "", "", "", "", "", "", "" }, new ItemStack[] { + null, null, null, null, GregTech_API.getGregTechItem(33, 1, 0), null, null, null, null, null, + null, null, null, null });*/ + new GT_ComputercubeDescription(new String[] { + "Data Orbs", "They store Data.", "", "Rightclick on a Computer Cube, to", "extract a Reactorplan", "", "Sneak-Rightclick on it, to insert", "a Reactorplan", "", "Works also with Sonictrons", + "", "", "", "", "", "", "" }, new ItemStack[] { + null, null, null, null, ItemList.Tool_DataOrb.get(1), null, null, null, null, null, + null, null, null, null }); + new GT_ComputercubeDescription(new String[] { + "Energy Orbs", "10Million EU in one Orb!", "", "This is a Tier-IV-Energystorage", "So a MFSU is not enough for it!", "", "Use it to create a Lapotron Pack,", "which is like an ultimate Lap Pack!", "", "", + "", "", "", "", "", "", "" }, new ItemStack[] { + null, null, null, ItemList.Energy_LapotronicOrb.get(1), null, null, null, null, null, null, + null, null, null, null }); + new GT_ComputercubeDescription(new String[] { + "Iridium Neutron Reflector", "It's used for Fusion Reactor Coils,", "and works like a normal one", "inside a Reactor, but it's also", "INDESTRUCTIBLE*.", "", "", "", "", "", + "", "", "", "", "", "", "* = for weardown" }, new ItemStack[] { + null, null, null, null, ItemList.Neutron_Reflector.get(1), null, null, null, null, null, + null, null, null, null }); + /*new GT_ComputercubeDescription(new String[] { + "Rock Cutter", "You want to get whole Blocks, but", "your Drill is not enchantable?", "The Rock Cutter has an awesome", "SilkTouch-III-Function!", "", "It works like a Drill, but you", "get the whole Block instead of", "'macerated' Ores!", "", + "Put those Blocks into a Macerator", "and double your Diamond Income!", "", "Or better. Use the Industrial", "Grinder to get even more", "Resources!", "" }, new ItemStack[] { + null, null, null, null, GregTech_API.getGregTechItem(46, 1, 0), null, null, null, null, null, + null, null, null, null }); + new GT_ComputercubeDescription(new String[] { + "Tesla Staff", "This completly untested PvP-Weapon", "destroys electric Armor in one hit", "", "The Energy Orb inside it must be", "fully charged to let this work.", "", "We are not responsible for any", "Electrocution Damage to yourself,", "while using it.", + "", "We also dont even know, if this", "Weapon has any effect AT ALL.", "", "", "", "" }, new ItemStack[] { + null, null, null, null, GregTech_API.getGregTechItem(47, 1, 0), null, null, null, null, null, + null, null, null, null });*/ + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/misc/GT_TileEntity_ComputerCube.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/misc/GT_TileEntity_ComputerCube.java new file mode 100644 index 0000000000..dd8c79a855 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/misc/GT_TileEntity_ComputerCube.java @@ -0,0 +1,986 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.misc; + +import java.util.ArrayList; +import java.util.Collections; + +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.ItemList; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicTank; +import gregtech.api.objects.GT_ItemStack; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.xmod.gregtech.api.gui.computer.GT_Container_ComputerCube; +import gtPlusPlus.xmod.gregtech.api.gui.computer.GT_GUIContainer_ComputerCube; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import gtPlusPlus.xmod.gregtech.common.computer.GT_ComputercubeDescription; +import ic2.api.reactor.IReactor; +import ic2.api.reactor.IReactorComponent; +import ic2.core.Ic2Items; +import ic2.core.init.MainConfig; +import ic2.core.util.ConfigUtil; +import net.minecraft.entity.Entity; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.ChunkCoordinates; +import net.minecraft.world.World; + +public class GT_TileEntity_ComputerCube extends GT_MetaTileEntity_BasicTank implements IReactor { + + public static boolean mSeedscanner = true; + + public static boolean mReactorplanner = true; + + public static ArrayList<GT_ItemStack> sReactorList; + + public boolean mStarted = false; + + public int mMode = 0; + + public int mHeat = 0; + + public int mEUOut = 0; + + public int mMaxHeat = 10000; + + public int mEU = 0; + + public int mProgress = 0; + + public int mEUTimer = 0; + + public int mEULast1 = 0; + + public int mEULast2 = 0; + + public int mEULast3 = 0; + + public int mEULast4 = 0; + + public float mHEM = 1.0F, mExplosionStrength = 0.0F; + + private boolean mNeedsUpdate; + + public GT_TileEntity_ComputerCube(final int aID, final String aDescription) { + super(aID, "computer.cube", "Computer Cube", 5, 114, aDescription); + } + + public GT_TileEntity_ComputerCube(final String aName, final String aDescription, final ITexture[][][] aTextures) { + super(aName, 5, 114, aDescription, aTextures); + } + + @Override + public Object getServerGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { + try { + return new GT_Container_ComputerCube(aPlayerInventory, aBaseMetaTileEntity, mMode); + } + catch (Throwable t) { + t.printStackTrace(); + return null; + } + } + + @Override + public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { + try { + return new GT_GUIContainer_ComputerCube(aPlayerInventory, aBaseMetaTileEntity, mMode); + } + catch (Throwable t) { + t.printStackTrace(); + return null; + } + } + + @Override + public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) { + return true; + } + Logger.INFO("Did rmb."); + boolean aDidOpen = aBaseMetaTileEntity.openGUI(aPlayer); + Logger.INFO("Did open? "+aDidOpen); + return true; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_TileEntity_ComputerCube(this.mName, this.mDescription, this.mTextures); + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + ItemStack tStack = aPlayer.getCurrentEquippedItem(); + if (tStack != null && ItemList.Tool_DataOrb.isStackEqual(tStack)) { + return false; + } + return true; + } + + @Override + public boolean isSimpleMachine() { + return true; + } + + @Override + public boolean isEnetInput() { + return true; + } + + @Override + public boolean isInputFacing(byte aDirection) { + return true; + } + + @Override + public long maxAmperesIn() { + return 4; + } + + @Override + public long maxEUInput() { + return GT_Values.V[2]; + } + + @Override + public long maxEUStore() { + return GT_Values.V[5] * 1024; + } + + @Override + public boolean ownerControl() { + return true; + } + + @Override + public int getSizeInventory() { + return 114; + } + + @Override + public boolean isValidSlot(int aIndex) { + return (aIndex > 53 && aIndex < 58); + } + + @Override + public boolean isFacingValid(byte aFacing) { + return true; + } + + public void saveNuclearReactor() { + for (int i = 0; i < 54; i++) { + if (this.mInventory[i] == null) { + this.mInventory[i + 59] = null; + } + else { + this.mInventory[i + 59] = this.mInventory[i].copy(); + } + } + } + + public void loadNuclearReactor() { + for (int i = 0; i < 54; i++) { + if (this.mInventory[i + 59] == null) { + this.mInventory[i] = null; + } + else { + this.mInventory[i] = this.mInventory[i + 59].copy(); + } + } + } + + public int getXCoord() { + return this.getBaseMetaTileEntity().getXCoord(); + } + + public int getYCoord() { + return this.getBaseMetaTileEntity().getYCoord(); + } + + public int getZCoord() { + return this.getBaseMetaTileEntity().getZCoord(); + } + + public void reset() { + this.mEU = 0; + this.mHeat = 0; + this.mEUOut = 0; + this.mMaxHeat = 10000; + this.mHEM = 1.0F; + this.mExplosionStrength = 0.0F; + this.mProgress = 0; + this.mInventory[113] = null; + int i; + for (i = 0; i < 54; i++) { + this.mInventory[i] = null; + this.mInventory[i + 59] = null; + } + for (i = 54; i < 58; i++) { + if (this.mInventory[i] != null) { + if (!this.getWorld().isRemote) + this.getWorld().spawnEntityInWorld((Entity) new EntityItem(this.getWorld(), this.getXCoord() + 0.5D, this.getYCoord() + 0.5D, this.getZCoord() + 0.5D, this.mInventory[i])); + this.mInventory[i] = null; + } + } + } + + public void switchModeForward() { + this.mMode = (this.mMode + 1) % 7; + switchMode(); + } + + public void switchModeBackward() { + this.mMode--; + if (this.mMode < 0) + this.mMode = 6; + switchMode(); + } + + private void switchMode() { + reset(); + if (this.mMode == 1 && !mReactorplanner) { + switchMode(); + return; + } + if (this.mMode == 2 && !mSeedscanner) { + switchMode(); + return; + } + if (this.mMode == 3) { + showCentrifugeRecipe(0); + } + if (this.mMode == 4) { + showFusionRecipe(0); + } + if (this.mMode == 5) { + showDescription(0); + } + if (this.mMode == 6) { + showElectrolyzerRecipe(0); + } + //this.getWorld().addBlockEvent(this.getXCoord(), this.getYCoord(), this.getZCoord(), (GregTech_API.sBlockList[1]), 10, this.mMode); + //this.getWorld().addBlockEvent(this.getXCoord(), this.getYCoord(), this.getZCoord(), (GregTech_API.sBlockList[1]), 11, this.mMaxHeat); + } + + public void showDescription(int aIndex) { + this.mExplosionStrength = 0.0F; + if (GT_ComputercubeDescription.sDescriptions.isEmpty()) { + return; + } + if (aIndex >= GT_ComputercubeDescription.sDescriptions.size() || aIndex < 0) + aIndex = 0; + if (((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(aIndex)).mStacks[0] == null) { + this.mInventory[59] = null; + } + else { + this.mInventory[59] = ((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(aIndex)).mStacks[0].copy(); + } + if (((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(aIndex)).mStacks[1] == null) { + this.mInventory[60] = null; + } + else { + this.mInventory[60] = ((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(aIndex)).mStacks[1].copy(); + } + if (((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(aIndex)).mStacks[2] == null) { + this.mInventory[61] = null; + } + else { + this.mInventory[61] = ((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(aIndex)).mStacks[2].copy(); + } + if (((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(aIndex)).mStacks[3] == null) { + this.mInventory[62] = null; + } + else { + this.mInventory[62] = ((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(aIndex)).mStacks[3].copy(); + } + if (((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(aIndex)).mStacks[4] == null) { + this.mInventory[63] = null; + } + else { + this.mInventory[63] = ((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(aIndex)).mStacks[4].copy(); + } + if (((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(aIndex)).mStacks[5] == null) { + this.mInventory[64] = null; + } + else { + this.mInventory[64] = ((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(aIndex)).mStacks[5].copy(); + this.mExplosionStrength = 100.0F; + } + if (((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(aIndex)).mStacks[6] == null) { + this.mInventory[65] = null; + } + else { + this.mInventory[65] = ((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(aIndex)).mStacks[6].copy(); + this.mExplosionStrength = 100.0F; + } + if (((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(aIndex)).mStacks[7] == null) { + this.mInventory[66] = null; + } + else { + this.mInventory[66] = ((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(aIndex)).mStacks[7].copy(); + this.mExplosionStrength = 100.0F; + } + if (((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(aIndex)).mStacks[8] == null) { + this.mInventory[67] = null; + } + else { + this.mInventory[67] = ((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(aIndex)).mStacks[8].copy(); + this.mExplosionStrength = 100.0F; + } + if (((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(aIndex)).mStacks[9] == null) { + this.mInventory[68] = null; + } + else { + this.mInventory[68] = ((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(aIndex)).mStacks[9].copy(); + this.mExplosionStrength = 100.0F; + } + if (((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(aIndex)).mStacks[10] == null) { + this.mInventory[69] = null; + } + else { + this.mInventory[69] = ((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(aIndex)).mStacks[10].copy(); + this.mExplosionStrength = 100.0F; + } + if (((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(aIndex)).mStacks[11] == null) { + this.mInventory[70] = null; + } + else { + this.mInventory[70] = ((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(aIndex)).mStacks[11].copy(); + this.mExplosionStrength = 100.0F; + } + if (((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(aIndex)).mStacks[12] == null) { + this.mInventory[71] = null; + } + else { + this.mInventory[71] = ((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(aIndex)).mStacks[12].copy(); + this.mExplosionStrength = 100.0F; + } + if (((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(aIndex)).mStacks[13] == null) { + this.mInventory[72] = null; + } + else { + this.mInventory[72] = ((GT_ComputercubeDescription) GT_ComputercubeDescription.sDescriptions.get(aIndex)).mStacks[13].copy(); + this.mExplosionStrength = 100.0F; + } + this.mMaxHeat = aIndex; + //this.getWorld().addBlockEvent(this.getXCoord(), this.getYCoord(), this.getZCoord(), GregTech_API.sBlockList[1], 11, this.mMaxHeat); + } + + public void switchDescriptionPageForward() { + if (++this.mMaxHeat >= GT_ComputercubeDescription.sDescriptions.size()) + this.mMaxHeat = 0; + showDescription(this.mMaxHeat); + } + + public void switchDescriptionPageBackward() { + if (--this.mMaxHeat < 0) + this.mMaxHeat = GT_ComputercubeDescription.sDescriptions.size() - 1; + showDescription(this.mMaxHeat); + } + + public void showCentrifugeRecipe(int aIndex) { + /* + if (aIndex >= GT_Recipe_Map.sCentrifugeRecipes.mRecipeList.size() || aIndex < 0) + aIndex = 0; + GT_Recipe tRecipe = GT_Recipe_Map.sCentrifugeRecipes.mRecipeList.get(aIndex); + if (tRecipe != null) { + if (tRecipe.mInput1 == null) { + this.mInventory[59] = null; + } + else { + this.mInventory[59] = tRecipe.mInput1.copy(); + } + if (tRecipe.mInput2 == null) { + this.mInventory[60] = null; + } + else { + this.mInventory[60] = tRecipe.mInput2.copy(); + } + if (tRecipe.mOutput1 == null) { + this.mInventory[61] = null; + } + else { + this.mInventory[61] = tRecipe.mOutput1.copy(); + } + if (tRecipe.mOutput2 == null) { + this.mInventory[62] = null; + } + else { + this.mInventory[62] = tRecipe.mOutput2.copy(); + } + if (tRecipe.mOutput3 == null) { + this.mInventory[63] = null; + } + else { + this.mInventory[63] = tRecipe.mOutput3.copy(); + } + if (tRecipe.mOutput4 == null) { + this.mInventory[64] = null; + } + else { + this.mInventory[64] = tRecipe.mOutput4.copy(); + } + this.mEU = tRecipe.mDuration * 5; + this.mMaxHeat = aIndex; + } + this.getWorld().addBlockEvent(this.xCoord, this.yCoord, this.zCoord, (GregTech_API.sBlockList[1]).field_71990_ca, 11, this.mMaxHeat); + */} + + public void switchCentrifugePageForward() { + if (++this.mMaxHeat >= GT_Recipe_Map.sCentrifugeRecipes.mRecipeList.size()) + this.mMaxHeat = 0; + // showCentrifugeRecipe(this.mMaxHeat); + } + + public void switchCentrifugePageBackward() { + if (--this.mMaxHeat < 0) + this.mMaxHeat = GT_Recipe_Map.sCentrifugeRecipes.mRecipeList.size() - 1; + // showCentrifugeRecipe(this.mMaxHeat); + } + + public void showElectrolyzerRecipe(int aIndex) { + /* + if (aIndex >= GT_Recipe_Map.sElectrolyzerRecipes.mRecipeList.size() || aIndex < 0) + aIndex = 0; + GT_Recipe tRecipe = GT_Recipe_Map.sElectrolyzerRecipes.get(aIndex); + if (tRecipe != null) { + if (tRecipe.mInput1 == null) { + this.mInventory[59] = null; + } + else { + this.mInventory[59] = tRecipe.mInput1.copy(); + } + if (tRecipe.mInput2 == null) { + this.mInventory[60] = null; + } + else { + this.mInventory[60] = tRecipe.mInput2.copy(); + } + if (tRecipe.mOutput1 == null) { + this.mInventory[61] = null; + } + else { + this.mInventory[61] = tRecipe.mOutput1.copy(); + } + if (tRecipe.mOutput2 == null) { + this.mInventory[62] = null; + } + else { + this.mInventory[62] = tRecipe.mOutput2.copy(); + } + if (tRecipe.mOutput3 == null) { + this.mInventory[63] = null; + } + else { + this.mInventory[63] = tRecipe.mOutput3.copy(); + } + if (tRecipe.mOutput4 == null) { + this.mInventory[64] = null; + } + else { + this.mInventory[64] = tRecipe.mOutput4.copy(); + } + this.mEU = tRecipe.mDuration * tRecipe.mEUt; + this.mMaxHeat = aIndex; + } + this.getWorld().addBlockEvent(this.xCoord, this.yCoord, this.zCoord, (GregTech_API.sBlockList[1]).field_71990_ca, 11, this.mMaxHeat); + */} + + public void switchElectrolyzerPageForward() { + if (++this.mMaxHeat >= GT_Recipe_Map.sElectrolyzerRecipes.mRecipeList.size()) + this.mMaxHeat = 0; + showElectrolyzerRecipe(this.mMaxHeat); + } + + public void switchElectrolyzerPageBackward() { + if (--this.mMaxHeat < 0) + this.mMaxHeat = GT_Recipe_Map.sElectrolyzerRecipes.mRecipeList.size() - 1; + showElectrolyzerRecipe(this.mMaxHeat); + } + + public static ArrayList<GT_Recipe> sFusionReactorRecipes = new ArrayList<GT_Recipe>(); + + public void showFusionRecipe(int aIndex) { + + if (sFusionReactorRecipes.isEmpty()) { + for (GT_Recipe aRecipe : GT_Recipe_Map.sFusionRecipes.mRecipeList) { + sFusionReactorRecipes.add(aRecipe); + } + Collections.sort(sFusionReactorRecipes); + } + + if (aIndex >= sFusionReactorRecipes.size() || aIndex < 0) { + aIndex = 0; + } + GT_Recipe tRecipe = sFusionReactorRecipes.get(aIndex); + if (tRecipe != null) { + if (tRecipe.mFluidInputs[0] == null) { + this.mInventory[59] = null; + } + else { + this.mInventory[59] = GT_Utility.getFluidDisplayStack(tRecipe.mFluidInputs[0], true); + } + if (tRecipe.mFluidInputs[1] == null) { + this.mInventory[60] = null; + } + else { + this.mInventory[60] = GT_Utility.getFluidDisplayStack(tRecipe.mFluidInputs[1], true); + } + if (tRecipe.mFluidOutputs[0] == null) { + this.mInventory[61] = null; + } + else { + this.mInventory[61] = GT_Utility.getFluidDisplayStack(tRecipe.mFluidOutputs[0], true); + } + this.mEU = tRecipe.mSpecialValue; + this.mEUOut = tRecipe.mEUt; + this.mHeat = tRecipe.mDuration; + this.mMaxHeat = aIndex; + } + //this.getWorld().addBlockEvent(this.getXCoord(), this.getYCoord(), this.getZCoord(), GregTech_API.sBlockList[1], 11, this.mMaxHeat); + } + + public void switchFusionPageForward() { + if (++this.mMaxHeat >= sFusionReactorRecipes.size()) + this.mMaxHeat = 0; + showFusionRecipe(this.mMaxHeat); + } + + public void switchFusionPageBackward() { + if (--this.mMaxHeat < 0) + this.mMaxHeat = sFusionReactorRecipes.size() - 1; + showFusionRecipe(this.mMaxHeat); + } + + public void switchNuclearReactor() { + if (this.mStarted) { + stopNuclearReactor(); + } + else { + startNuclearReactor(); + } + } + + public void startNuclearReactor() { + this.mStarted = true; + this.mHeat = 0; + this.mEU = 0; + } + + public void stopNuclearReactor() { + this.mStarted = false; + } + + public void storeAdditionalData(NBTTagCompound aNBT) { + aNBT.setInteger("mMode", this.mMode); + aNBT.setInteger("mProgress", this.mProgress); + aNBT.setBoolean("mStarted", this.mStarted); + aNBT.setInteger("mEU", this.mEU); + aNBT.setInteger("mHeat", this.mHeat); + aNBT.setInteger("mEUOut", this.mEUOut); + aNBT.setInteger("mMaxHeat", this.mMaxHeat); + aNBT.setFloat("mHEM", this.mHEM); + aNBT.setFloat("mExplosionStrength", this.mExplosionStrength); + } + + public void getAdditionalData(NBTTagCompound aNBT) { + this.mMode = aNBT.getInteger("mMode"); + this.mProgress = aNBT.getInteger("mProgress"); + this.mStarted = aNBT.getBoolean("mStarted"); + this.mEU = aNBT.getInteger("mEU"); + this.mHeat = aNBT.getInteger("mHeat"); + this.mEUOut = aNBT.getInteger("mEUOut"); + this.mMaxHeat = aNBT.getInteger("mMaxHeat"); + this.mHEM = aNBT.getFloat("mHEM"); + this.mExplosionStrength = aNBT.getFloat("mExplosionStrength"); + } + + public void onFirstTickUpdate() { + } + + @Override + public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) { + super.onFirstTick(aBaseMetaTileEntity); + if (sReactorList == null) { + sReactorList = new ArrayList<GT_ItemStack>(); + + String[] aIc2Items = new String[]{ + "reactorUraniumSimple", "reactorUraniumDual", "reactorUraniumQuad", /*"reactorIsotopeCell",*/ "reactorReflector", "reactorReflectorThick", "reactorCoolantSimple", + "reactorCoolantTriple", "reactorCoolantSix", "reactorCondensator", "reactorCondensatorLap", "reactorPlating", "reactorPlatingHeat", "reactorPlatingExplosive", "reactorVent", + "reactorVentCore", "reactorVentGold", "reactorVentSpread", "reactorVentDiamond", "reactorHeatSwitch", "reactorHeatSwitchCore", "reactorHeatSwitchSpread", + "reactorHeatSwitchDiamond", /*"reactorHeatpack",*/ + }; + + for (String aItem : aIc2Items) { + ItemStack aStack = GT_ModHandler.getIC2Item(aItem, 1); + if (!ItemUtils.checkForInvalidItems(aStack)) { + Logger.INFO("Unable to find IC2 Item: " + aItem); + CORE.crash("Unable to find IC2 Item: " + aItem); + } + else { + sReactorList.add(new GT_ItemStack(aStack.copy())); + } + } + + ItemList[] aGtItems = new ItemList[]{ + ItemList.Neutron_Reflector, ItemList.Moxcell_1, ItemList.Moxcell_2, ItemList.Moxcell_4, ItemList.Uraniumcell_1, ItemList.Uraniumcell_2, ItemList.Uraniumcell_4, + ItemList.NaquadahCell_1, ItemList.NaquadahCell_2, ItemList.NaquadahCell_4, ItemList.ThoriumCell_1, ItemList.ThoriumCell_2, ItemList.ThoriumCell_4, ItemList.Reactor_Coolant_He_1, + ItemList.Reactor_Coolant_He_3, ItemList.Reactor_Coolant_He_6, ItemList.Reactor_Coolant_NaK_1, ItemList.Reactor_Coolant_NaK_3, ItemList.Reactor_Coolant_NaK_6, + }; + + for (ItemList aItem : aGtItems) { + sReactorList.add(new GT_ItemStack(aItem.get(1))); + } + + } + + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + if(this.getBaseMetaTileEntity().isClientSide()) { + this.getWorld().markBlockForUpdate(this.getXCoord(), this.getYCoord(), this.getZCoord()); + this.mNeedsUpdate = false; + } + else { + this.mNeedsUpdate = false; + } + if (this.getBaseMetaTileEntity().isServerSide()) { + if (this.mMode == 2) { + if (this.mInventory[55] == null) { + this.mInventory[55] = this.mInventory[54]; + this.mInventory[54] = null; + } + if (this.mInventory[57] == null) { + this.mInventory[57] = this.mInventory[56]; + this.mInventory[56] = null; + } + + if (mSeedscanner && this.mInventory[55] != null && GT_Utility.areStacksEqual(this.mInventory[55], Ic2Items.cropSeed, true) && this.mInventory[55].getTagCompound() != null) { + if (this.mInventory[55].getTagCompound().getByte("scan") < 4) { + if (this.mProgress >= 100) { + this.mInventory[55].getTagCompound().setByte("scan", (byte) 4); + this.mProgress = 0; + } + else if (this.getBaseMetaTileEntity().decreaseStoredEnergyUnits(100, false)) { + this.mProgress++; + } + } + else { + this.mProgress = 0; + if (this.mInventory[56] == null) { + this.mInventory[56] = this.mInventory[55]; + this.mInventory[55] = null; + } + } + } + else { + this.mProgress = 0; + if (this.mInventory[56] == null) { + this.mInventory[56] = this.mInventory[55]; + this.mInventory[55] = null; + } + } + } + if (this.mMode == 1 && mReactorplanner && this.mStarted && this.getBaseMetaTileEntity().decreaseStoredEnergyUnits(32, false)) + for (int i = 0; i < 25 && this.mStarted; i++) { + this.mEUOut = 0; + this.mMaxHeat = 10000; + this.mHEM = 1.0F; + this.mExplosionStrength = 10.0F; + float tMultiplier = 1.0F; + for (int y = 0; y < 6; y++) { + for (int x = 0; x < 9; x++) { + ItemStack tStack = getStackInSlot(x + y * 9); + if (tStack != null) + if (tStack.getItem() instanceof IReactorComponent) { + IReactorComponent tComponent = (IReactorComponent) tStack.getItem(); + tComponent.processChamber(this, tStack, x, y, false); //TODO + float tInfluence = ((IReactorComponent) tStack.getItem()).influenceExplosion(this, tStack); + if (tInfluence > 0.0F && tInfluence < 1.0F) { + tMultiplier *= tInfluence; + } + else { + this.mExplosionStrength += tInfluence; + } + } + else if (tStack.isItemEqual(GT_ModHandler.getIC2Item("nearDepletedUraniumCell", 1)) || tStack.isItemEqual(GT_ModHandler.getIC2Item("reEnrichedUraniumCell", 1))) { + stopNuclearReactor(); + } + else { + setInventorySlotContents(x + y * 9, (ItemStack) null); + } + } + } + this.mEUOut *= getReactorEUOutput(); + if ((this.mEUOut == 0 && this.mEUTimer++ > 20) || this.mHeat >= this.mMaxHeat) + stopNuclearReactor(); + if (this.mEUOut != 0) + this.mEUTimer = 0; + this.mExplosionStrength *= this.mHEM * tMultiplier; + this.mEU += this.mEUOut * 20; + int tEU = this.mEULast1; + this.mEULast1 = this.mEULast2; + this.mEULast2 = this.mEULast3; + this.mEULast3 = this.mEULast4; + this.mEULast4 = this.mEUOut; + this.mEUOut = (this.mEUOut + this.mEULast1 + this.mEULast2 + this.mEULast3 + tEU) / 5; + } + if (aTick % 20L == 0L) { + //this.getWorld().addBlockEvent(this.xCoord, this.yCoord, this.zCoord, (GregTech_API.sBlockList[1]).field_71990_ca, 10, this.mMode); + //this.getWorld().addBlockEvent(this.xCoord, this.yCoord, this.zCoord, (GregTech_API.sBlockList[1]).field_71990_ca, 11, this.mMaxHeat); + } + } + } + + private int getReactorEUOutput() { + return MathUtils.roundToClosestInt(getReactorEnergyOutput() * 5.0F * ConfigUtil.getFloat(MainConfig.get(), "balance/energy/generator/nuclear")); + } + + @Override + public void receiveClientEvent(byte aEventID, byte aValue) { + super.receiveClientEvent(aEventID, aValue); + if (this.getWorld().isRemote) + switch (aEventID) { + case 10 : + this.mNeedsUpdate = true; + this.mMode = aValue; + break; + case 11 : + this.mMaxHeat = aValue; + break; + } + return; + } + + @Override + public void onValueUpdate(byte aValue) { + super.onValueUpdate(aValue); + this.mNeedsUpdate = true; + } + + @Override + public void onMachineBlockUpdate() { + super.onMachineBlockUpdate(); + this.mNeedsUpdate = true; + } + + public boolean canInsertItem(int i, ItemStack itemstack, int j) { + return (this.mMode == 2) ? ((i == 54 || i == 55)) : false; + } + + public boolean canExtractItem(int i, ItemStack itemstack, int j) { + return (this.mMode == 2) ? ((i == 56 || i == 57)) : false; + } + + public String getInvName() { + return "GregTech_Computercube"; + } + + public int getTexture(int aSide, int aMeta) { + switch (this.mMode) { + case 0 : + return 8; + case 1 : + return 46; + case 2 : + return 45; + } + return 48; + } + + @Override + public ChunkCoordinates getPosition() { + return new ChunkCoordinates(this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getYCoord(), this.getBaseMetaTileEntity().getZCoord()); + } + + @Override + public int getHeat() { + return this.mHeat; + } + + @Override + public void setHeat(int aHeat) { + this.mHeat = aHeat; + } + + @Override + public int addHeat(int aAmount) { + this.mHeat += aAmount; + return this.mHeat; + } + + @Override + public int getMaxHeat() { + return this.mMaxHeat; + } + + @Override + public void setMaxHeat(int aMaxHeat) { + this.mMaxHeat = aMaxHeat; + } + + @Override + public float getHeatEffectModifier() { + return this.mHEM; + } + + @Override + public void setHeatEffectModifier(float aHEM) { + this.mHEM = aHEM; + } + + + public int addOutput(int aEnergy) { + this.mEUOut += aEnergy; + return this.mEUOut; + } + + @Override + public ItemStack getItemAt(int x, int y) { + if (x < 0 || x > 8 || y < 0 || y > 5) + return null; + return getStackInSlot(x + y * 9); + } + + @Override + public void setItemAt(int x, int y, ItemStack aStack) { + setInventorySlotContents(x + y * 9, aStack); + } + + @Override + public void explode() { + stopNuclearReactor(); + } + + @Override + public int getTickRate() { + return 1; + } + + @Override + public boolean produceEnergy() { + return true; + } + + public int getProgress() { + return this.mProgress; + } + + public int getMaxProgress() { + return (this.mProgress > 0) ? 100 : 0; + } + + @Override + public float addOutput(float aEnergy) { + this.mEUOut = (int) (this.mEUOut + aEnergy); + return this.mEUOut; + } + + @Override + public World getWorld() { + return this.getBaseMetaTileEntity().getWorld(); + } + + @Override + public void addEmitHeat(int heat) { + + } + + @Override + public float getReactorEnergyOutput() { + return this.mEUOut; + } + + @Override + public double getReactorEUEnergyOutput() { + return 0; + } + + @Override + public void setRedstoneSignal(boolean redstone) { + + } + + @Override + public boolean isFluidCooled() { + return false; + } + + + + @Override + public boolean doesFillContainers() { + return false; + } + + @Override + public boolean doesEmptyContainers() { + return false; + } + + @Override + public boolean canTankBeFilled() { + return false; + } + + @Override + public boolean canTankBeEmptied() { + return false; + } + + @Override + public boolean displaysItemStack() { + return false; + } + + @Override + public boolean displaysStackSize() { + return false; + } + + @Override + public ITexture[][][] getTextureSet(final ITexture[] aTextures) { + final ITexture[][][] rTextures = new ITexture[10][17][]; + for (byte i = -1; i < 16; i++) { + rTextures[0][i + 1] = this.getFront(i); + rTextures[1][i + 1] = this.getSides(i); + rTextures[2][i + 1] = this.getSides(i); + rTextures[3][i + 1] = this.getSides(i); + rTextures[4][i + 1] = this.getSides(i); + rTextures[5][i + 1] = this.getFront(i); + rTextures[6][i + 1] = this.getSides(i); + rTextures[7][i + 1] = this.getSides(i); + rTextures[8][i + 1] = this.getSides(i); + rTextures[9][i + 1] = this.getSides(i); + } + return rTextures; + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, + final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + return this.mTextures[(aSide == aFacing ? 0 : aSide == GT_Utility.getOppositeSide(aFacing) ? 1 : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][aColorIndex + 1]; + } + + public ITexture[] getFront(final byte aColor) { + return new ITexture[] { new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Screen_3)}; + } + + public ITexture[] getSides(final byte aColor) { + return new ITexture[] { new GT_RenderedTexture(TexturesGtBlock.Casing_Computer_Cube)}; + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/Gregtech4Content.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/Gregtech4Content.java index 6741a3e433..5c34ce70fe 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/Gregtech4Content.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/Gregtech4Content.java @@ -5,6 +5,7 @@ import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.common.computer.GT_ComputercubeDescription; import gtPlusPlus.xmod.gregtech.common.tileentities.automation.GT_MetaTileEntity_ElectricAutoWorkbench; import gtPlusPlus.xmod.gregtech.common.tileentities.automation.GT_MetaTileEntity_ElectricInventoryManager; import gtPlusPlus.xmod.gregtech.common.tileentities.automation.GT_MetaTileEntity_TesseractGenerator; @@ -12,6 +13,7 @@ import gtPlusPlus.xmod.gregtech.common.tileentities.automation.GT_MetaTileEntity import gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic.GT_MetaTileEntity_CropHarvestor; import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.GT4Entity_AutoCrafter; import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.GT4Entity_ThermalBoiler; +import gtPlusPlus.xmod.gregtech.common.tileentities.misc.GT_TileEntity_ComputerCube; import gtPlusPlus.xmod.gregtech.common.tileentities.redstone.GT_MetaTileEntity_RedstoneButtonPanel; import gtPlusPlus.xmod.gregtech.common.tileentities.redstone.GT_MetaTileEntity_RedstoneLamp; import gtPlusPlus.xmod.gregtech.common.tileentities.redstone.GT_MetaTileEntity_RedstoneStrengthDisplay; @@ -40,9 +42,16 @@ public class Gregtech4Content { basic(); automation(); redstone(); + computer(); } } + + private static void computer() { + Logger.INFO("Gregtech 4 Content | Registering Computer Cube."); + GregtechItemList.Gregtech_Computer_Cube_Machine.set(new GT_TileEntity_ComputerCube(31130, "C-O-M-P-U-T-E-R").getStackForm(1L)); + } + private static void workbenches() { // Gregtech 4 Workbenches Logger.INFO("Gregtech 4 Content | Registering Workbenches."); |