aboutsummaryrefslogtreecommitdiff
path: root/src/Java
diff options
context:
space:
mode:
authorJordan Byrne <draknyte1@hotmail.com>2018-02-04 00:54:48 +1000
committerJordan Byrne <draknyte1@hotmail.com>2018-02-04 00:54:48 +1000
commitc736d1091698a2ef1a4a4c953392683d12abdc93 (patch)
tree6ef4beedf5fc653995c98c3d1d645b113557797b /src/Java
parent4e3816e70a7cd9a36f609e421911275444ddbb75 (diff)
downloadGT5-Unofficial-c736d1091698a2ef1a4a4c953392683d12abdc93.tar.gz
GT5-Unofficial-c736d1091698a2ef1a4a4c953392683d12abdc93.tar.bz2
GT5-Unofficial-c736d1091698a2ef1a4a4c953392683d12abdc93.zip
+ Added Super Chests.
$ More work on Gregtech ASM. > NBTTagCompound is now created in MetaTileEntity. getDrops() & breakBlock() are also both overwritten.
Diffstat (limited to 'src/Java')
-rw-r--r--src/Java/gtPlusPlus/api/objects/Logger.java2
-rw-r--r--src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java1
-rw-r--r--src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_ClassTransformer2.java263
-rw-r--r--src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_Transformer_Handler.java9
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java5
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_SuperChest.java69
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/api/gui/GUI_SuperChest.java37
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GT_MetaTileEntity_TieredChest.java192
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechSuperTanks.java52
9 files changed, 553 insertions, 77 deletions
diff --git a/src/Java/gtPlusPlus/api/objects/Logger.java b/src/Java/gtPlusPlus/api/objects/Logger.java
index 6e2e9f6107..1ecdaa9e86 100644
--- a/src/Java/gtPlusPlus/api/objects/Logger.java
+++ b/src/Java/gtPlusPlus/api/objects/Logger.java
@@ -75,7 +75,7 @@ public class Logger {
// ASM Comments
public static void LOG_ASM(final String s) {
- FMLRelaunchLog.info("", s);
+ FMLRelaunchLog.info("[Special ASM Logging] ", s);
}
diff --git a/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java b/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java
index c6aff47c5b..059e9ad5dc 100644
--- a/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java
+++ b/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java
@@ -102,6 +102,7 @@ public class COMPAT_HANDLER {
GregtechMiniRaFusion.run();
GregtechComponentAssembler.run();
GregtechTeslaTower.run();
+ GregtechSuperTanks.run();
//New Horizons Content
NewHorizonsAccelerator.run();
diff --git a/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_ClassTransformer2.java b/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_ClassTransformer2.java
index 6da476309f..99f82e6462 100644
--- a/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_ClassTransformer2.java
+++ b/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_ClassTransformer2.java
@@ -4,30 +4,180 @@ import static org.objectweb.asm.Opcodes.*;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Random;
import org.apache.logging.log4j.Level;
import org.objectweb.asm.*;
-import org.objectweb.asm.commons.GeneratorAdapter;
import cpw.mods.fml.relauncher.FMLRelaunchLog;
import gregtech.api.GregTech_API;
import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
+import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.metatileentity.BaseMetaTileEntity;
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicTank;
+import gregtech.common.blocks.GT_Block_Machines;
import gtPlusPlus.api.objects.Logger;
+import gtPlusPlus.api.objects.XSTR;
import gtPlusPlus.core.util.item.ItemUtils;
import gtPlusPlus.core.util.reflect.ReflectionUtils;
+import net.minecraft.block.Block;
+import net.minecraft.block.BlockContainer;
+import net.minecraft.entity.Entity;
+import net.minecraft.entity.item.EntityItem;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.world.World;
import net.minecraftforge.fluids.FluidStack;
public class Preloader_ClassTransformer2 {
- private final static Class<BaseMetaTileEntity> customTransformer2 = BaseMetaTileEntity.class;
-
+ /**
+ *
+ * So what I'd try is something like patch a new field into BaseMetaTileEntity to hold the ItemNBT,
+ * then patch GT_Block_Machines.breakBlock to store the ItemNBT into that field by calling setItemNBT,
+ * and then patch BaseMetaTileEntity.getDrops to retrieve that field instead of calling setItemNBT
+ * But there's probably a simpler solution if all you want to do is fix this
+ * for your super tanks rather than for all GT machines
+ * (which would only include saving the output count for chest buffers and item distributors...)
+ *
+ */
+
+
+
+
NBTTagCompound mItemStorageNBT = new NBTTagCompound();
+ private final static Class<BaseMetaTileEntity> customTransformer2 = BaseMetaTileEntity.class;
+ public static final class GT_MetaTile_Visitor extends ClassVisitor {
+ private boolean isGt_Block_Machines = false;
+ private boolean mHasSetField = false;
+ public GT_MetaTile_Visitor(ClassVisitor cv, boolean isGt_Block_Machines) {
+ super(ASM5, cv);
+ this.isGt_Block_Machines = isGt_Block_Machines;
+ }
+
+ @Override
+ public FieldVisitor visitField(int access, String name, String desc, String signature, Object value) {
+ FieldVisitor j = super.visitField(access, name, desc, signature, value);
+ if (!mHasSetField) {
+ mHasSetField = true;
+ FMLRelaunchLog.log("[GT++ ASM] NBTFixer", Level.INFO, "Injecting field 'mItemStorageNBT' into BaseMetaTileEntity.java. Access OpCode: "+access);
+ j = cv.visitField(0, "mItemStorageNBT", "Lnet/minecraft/nbt/NBTTagCompound;", null, null);
+ j.visitEnd();
+ }
+ return j;
+ }
+
+ @Override
+ public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
+ MethodVisitor methodVisitor = super.visitMethod(access, name, desc, signature, exceptions);
+
+ if (isGt_Block_Machines) { //Lnet/minecraft/world/World;IIILnet/minecraft/block/Block;I)V
+ if(name.equals("breakBlock") && desc.equals("(Lnet/minecraft/world/World;IIILnet/minecraft/block/Block;I)V")) {
+ FMLRelaunchLog.log("[GT++ ASM] NBTFixer", Level.INFO, "Found target method 'breakBlock' [Unobfuscated]. Access OpCode: "+access);
+ return new swapBreakBlock(methodVisitor);
+ }
+ else if (name.equals("breakBlock") && !desc.equals("(Lnet/minecraft/world/World;IIILnet/minecraft/block/Block;I)V")) {
+ FMLRelaunchLog.log("[GT++ ASM] NBTFixer", Level.INFO, "Found target method 'breakBlock' [Obfuscated]. Access OpCode: "+access);
+ return new swapBreakBlock(methodVisitor);
+ }
+ }
+ else {
+ if(name.equals("getDrops") && desc.equals("()Ljava/util/ArrayList;")) {
+ FMLRelaunchLog.log("[GT++ ASM] NBTFixer", Level.INFO, "Found target method 'getDrops'. Access OpCode: "+access);
+ return new swapGetDrops(methodVisitor);
+ }
+ }
+ return methodVisitor;
+ }
+
+ }
+
+
+
+
+ private static final class swapGetDrops extends MethodVisitor {
+
+ public swapGetDrops(MethodVisitor mv) {
+ super(ASM5, mv);
+ }
+
+ @Override
+ public void visitCode() {
+ FMLRelaunchLog.log("[GT++ ASM] NBTFixer", Level.INFO, "Fixing Greg & Blood's poor attempt at setItemNBT().");
+ super.visitCode();
+ //ALOAD 0
+ //INVOKESTATIC gtPlusPlus/preloader/asm/transformers/Preloader_ClassTransformer2 getDrops (Lgregtech/api/metatileentity/BaseMetaTileEntity;)Ljava/util/ArrayList;
+ //ARETURN
+
+ super.visitVarInsn(ALOAD, 0);
+ super.visitMethodInsn(INVOKESTATIC,
+ "gtPlusPlus/preloader/asm/transformers/Preloader_ClassTransformer2",
+ "getDrops",
+ "(Lgregtech/api/metatileentity/BaseMetaTileEntity;)Ljava/util/ArrayList;",
+ false);
+ FMLRelaunchLog.log("[GT++ ASM] NBTFixer", Level.INFO, "Method should now be replaced.");
+ //super.visitVarInsn(ARETURN, 0);
+ super.visitInsn(ARETURN);
+ }
+
+ }
+
+ private static final class swapBreakBlock extends MethodVisitor {
+
+ public swapBreakBlock(MethodVisitor mv) {
+ super(ASM5, mv);
+ }
+
+ @Override
+ public void visitCode() {
+ FMLRelaunchLog.log("[GT++ ASM] NBTFixer", Level.INFO, "Fixing breakBlock() in GT_Block_Machines.class");
+ super.visitCode();
+ //super.visitVarInsn(ALOAD, 0);
+
+ super.visitVarInsn(ALOAD, 1);
+ super.visitVarInsn(ILOAD, 2);
+ super.visitVarInsn(ILOAD, 3);
+ super.visitVarInsn(ILOAD, 4);
+ super.visitVarInsn(ALOAD, 5);
+ super.visitVarInsn(ILOAD, 6);
+
+ super.visitMethodInsn(INVOKESTATIC,
+ "gtPlusPlus/preloader/asm/transformers/Preloader_ClassTransformer2",
+ "breakBlock",
+ "(Lnet/minecraft/world/World;IIILnet/minecraft/block/Block;I)V",
+ false);
+ FMLRelaunchLog.log("[GT++ ASM] NBTFixer", Level.INFO, "Method should now be replaced.");
+ super.visitInsn(RETURN);
+ }
+
+ }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
public static ArrayList<ItemStack> getDrops(BaseMetaTileEntity o) {
Logger.INFO("DROP!");
try {
@@ -44,7 +194,7 @@ public class Preloader_ClassTransformer2 {
FluidStack tFluid = null;
if (GT_MetaTileEntity_BasicTank.class.isInstance(o)) {
try {
- tFluid = (FluidStack) ReflectionUtils.getField(GT_MetaTileEntity_BasicTank.class, "mFluid").get(o);
+ tFluid = (FluidStack) ReflectionUtils.getField(GT_MetaTileEntity_BasicTank.class, "mFluid").get(o);
}
catch (Throwable t) {
Logger.REFLECTION("mFluid was not set.");
@@ -65,7 +215,7 @@ public class Preloader_ClassTransformer2 {
Logger.REFLECTION("tCoverSides: "+(tCoverSides != null));
Logger.REFLECTION("tCoverData: "+(tCoverData != null));
Logger.REFLECTION("tMetaTileEntity: "+(tMetaTileEntity != null));
-
+
ItemStack rStack = new ItemStack(GregTech_API.sBlockMachines, 1, tID);
NBTTagCompound tNBT = new NBTTagCompound();
@@ -98,7 +248,7 @@ public class Preloader_ClassTransformer2 {
catch (Throwable t){
Logger.REFLECTION("getDropsHack1");
t.printStackTrace();
- }
+ }
}
//Set stack NBT
@@ -114,80 +264,45 @@ public class Preloader_ClassTransformer2 {
}
- public static final class GT_MetaTile_Visitor extends ClassVisitor {
-
- public GT_MetaTile_Visitor(ClassVisitor cv) {
- super(ASM5, cv);
- }
-
- @Override
- public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
- MethodVisitor methodVisitor = super.visitMethod(access, name, desc, signature, exceptions);
- if(name.equals("getDrops") && desc.equals("()Ljava/util/ArrayList;")) {
- FMLRelaunchLog.log("[GT++ ASM] NBTFixer", Level.INFO, "Found target method. Access OpCode: "+access);
- //return new TrySwapMethod(methodVisitor, access, name, desc);
- return new SwapTwo(methodVisitor);
+ public static void breakBlock(final World aWorld, final int aX, final int aY, final int aZ, final Block block,
+ final int meta) {
+ Logger.INFO("BREAK!");
+ GregTech_API.causeMachineUpdate(aWorld, aX, aY, aZ);
+ final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ);
+ if (tTileEntity instanceof IGregTechTileEntity) {
+ final IGregTechTileEntity tGregTechTileEntity = (IGregTechTileEntity) tTileEntity;
+ final Random tRandom = new XSTR();
+ GT_Block_Machines.mTemporaryTileEntity.set(tGregTechTileEntity);
+ for (int i = 0; i < tGregTechTileEntity.getSizeInventory(); ++i) {
+ final ItemStack tItem = tGregTechTileEntity.getStackInSlot(i);
+ if (tItem != null && tItem.stackSize > 0 && tGregTechTileEntity.isValidSlot(i)) {
+ final EntityItem tItemEntity = new EntityItem(aWorld,
+ (double) (aX + tRandom.nextFloat() * 0.8f + 0.1f),
+ (double) (aY + tRandom.nextFloat() * 0.8f + 0.1f),
+ (double) (aZ + tRandom.nextFloat() * 0.8f + 0.1f),
+ new ItemStack(tItem.getItem(), tItem.stackSize, tItem.getItemDamage()));
+ if (tItem.hasTagCompound()) {
+ tItemEntity.getEntityItem().setTagCompound((NBTTagCompound) tItem.getTagCompound().copy());
+ }
+ tItemEntity.motionX = tRandom.nextGaussian() * 0.0500000007450581;
+ tItemEntity.motionY = tRandom.nextGaussian() * 0.0500000007450581 + 0.2000000029802322;
+ tItemEntity.motionZ = tRandom.nextGaussian() * 0.0500000007450581;
+ aWorld.spawnEntityInWorld((Entity) tItemEntity);
+ tItem.stackSize = 0;
+ tGregTechTileEntity.setInventorySlotContents(i, (ItemStack) null);
+ }
}
- return methodVisitor;
}
+ //gtPlusPlus.preloader.asm.transformers.Preloader_ClassTransformer2.breakBlockWorld(aWorld, aX, aY, aZ, block, meta);
+ aWorld.removeTileEntity(aX, aY, aZ);
}
- /*private static final class TrySwapMethod extends GeneratorAdapter {
-
- public TrySwapMethod(MethodVisitor mv, int access, String name, String desc) {
- super(Opcodes.ASM5, mv, access, name, desc);
- FMLRelaunchLog.log("[GT++ ASM] NBTFixer", Level.INFO, "Created method swapper for '"+name+"' in 'gregtech/api/metatileentity/BaseMetaTileEntity'. Desc: "+desc);
- }
-
- @Override
- public void visitMethodInsn(int opcode, String owner, String name, String desc, boolean itf) {
- //gtPlusPlus.preloader.asm.transformers.Preloader_ClassTransformer2
- if(opcode==INVOKESPECIAL && owner.equals("net/minecraft/item/ItemStack")
- && name.equals("<init>") && desc.equals("(Lnet/minecraft/block/Block;II)V")) {
- FMLRelaunchLog.log("[GT++ ASM] NBTFixer", Level.INFO, "Trying to proccess '"+name+"' | Opcode: "+opcode+" | Desc: "+desc+" | Owner: "+owner);
- FMLRelaunchLog.log("[GT++ ASM] NBTFixer", Level.INFO, "Fixing Greg & Blood's poor attempt at setItemNBT().");
- // not relaying the original instruction to super effectively removes the original
- // instruction, instead we're producing a different instruction:
- super.visitVarInsn(ALOAD, 0);
- super.visitMethodInsn(INVOKESTATIC, "gtPlusPlus/preloader/asm/transformers/Preloader_ClassTransformer2",
- "getDrops", "()Ljava/util/ArrayList;", false);
- FMLRelaunchLog.log("[GT++ ASM] NBTFixer", Level.INFO, "Method should now be replaced.");
- }
- else { // relaying to super will reproduce the same instruction
- //FMLRelaunchLog.log("[GT++ ASM] NBTFixer", Level.INFO, "Original method call.");
- super.visitMethodInsn(opcode, owner, name, desc, itf);
- }
+ public static void breakBlockWorld(World world, int aX, int aY, int aZ, Block block, int meta){
+ if (block.hasTileEntity(meta) && !(block instanceof BlockContainer))
+ {
+ world.removeTileEntity(aX, aY, aZ);
}
-
- // all other, not overridden visit methods reproduce the original instructions
- }*/
-
- private static final class SwapTwo extends MethodVisitor {
-
- public SwapTwo(MethodVisitor mv) {
- super(ASM5, mv);
- }
-
- @Override
- public void visitCode() {
- FMLRelaunchLog.log("[GT++ ASM] NBTFixer", Level.INFO, "Fixing Greg & Blood's poor attempt at setItemNBT().");
- super.visitCode();
- //ALOAD 0
- //INVOKESTATIC gtPlusPlus/preloader/asm/transformers/Preloader_ClassTransformer2 getDrops (Lgregtech/api/metatileentity/BaseMetaTileEntity;)Ljava/util/ArrayList;
- //ARETURN
-
- super.visitVarInsn(ALOAD, 0);
- super.visitMethodInsn(INVOKESTATIC,
- "gtPlusPlus/preloader/asm/transformers/Preloader_ClassTransformer2",
- "getDrops",
- "(Lgregtech/api/metatileentity/BaseMetaTileEntity;)Ljava/util/ArrayList;",
- false);
- FMLRelaunchLog.log("[GT++ ASM] NBTFixer", Level.INFO, "Method should now be replaced.");
- //super.visitVarInsn(ARETURN, 0);
- super.visitInsn(ARETURN);
- }
-
}
}
diff --git a/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_Transformer_Handler.java b/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_Transformer_Handler.java
index 723061f998..6e30f0f94c 100644
--- a/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_Transformer_Handler.java
+++ b/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_Transformer_Handler.java
@@ -22,7 +22,14 @@ public class Preloader_Transformer_Handler implements IClassTransformer {
FMLRelaunchLog.log("[GT++ ASM] NBTFixer", Level.INFO, "Transforming %s", transformedName);
ClassWriter classWriter = new ClassWriter(ClassWriter.COMPUTE_FRAMES);
ClassReader x = new ClassReader(basicClass);
- x.accept(new GT_MetaTile_Visitor(classWriter), ClassReader.EXPAND_FRAMES);
+ x.accept(new GT_MetaTile_Visitor(classWriter, false), ClassReader.EXPAND_FRAMES);
+ return classWriter.toByteArray();
+ }
+ if(transformedName.equals("gregtech.common.blocks.GT_Block_Machines")) {
+ FMLRelaunchLog.log("[GT++ ASM] NBTFixer", Level.INFO, "Transforming %s", transformedName);
+ ClassWriter classWriter = new ClassWriter(ClassWriter.COMPUTE_FRAMES);
+ ClassReader x = new ClassReader(basicClass);
+ x.accept(new GT_MetaTile_Visitor(classWriter, true), ClassReader.EXPAND_FRAMES);
return classWriter.toByteArray();
}
return basicClass;
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java
index 898565352b..ff46212aa4 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java
@@ -278,7 +278,10 @@ public enum GregtechItemList implements GregtechItemContainer {
//Tesla Tower
TelsaTower,
- Battery_Gem_1, Battery_Gem_2, Battery_Gem_3,
+ Battery_Gem_1, Battery_Gem_2, Battery_Gem_3,
+
+ //Super Tier Chests
+ Super_Chest_LV, Super_Chest_MV, Super_Chest_HV, Super_Chest_EV, Super_Chest_IV,
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_SuperChest.java b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_SuperChest.java
new file mode 100644
index 0000000000..0c33baeda4
--- /dev/null
+++ b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_SuperChest.java
@@ -0,0 +1,69 @@
+package gtPlusPlus.xmod.gregtech.api.gui;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import gregtech.api.gui.GT_ContainerMetaTile_Machine;
+import gregtech.api.gui.GT_Slot_Output;
+import gregtech.api.gui.GT_Slot_Render;
+import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
+import gtPlusPlus.xmod.gregtech.common.tileentities.storage.GT_MetaTileEntity_TieredChest;
+
+import java.util.Iterator;
+import net.minecraft.entity.player.InventoryPlayer;
+import net.minecraft.inventory.ICrafting;
+import net.minecraft.inventory.Slot;
+
+public class CONTAINER_SuperChest extends GT_ContainerMetaTile_Machine {
+ public int mContent = 0;
+
+ public CONTAINER_SuperChest(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) {
+ super(aInventoryPlayer, aTileEntity);
+ }
+
+ public void addSlots(InventoryPlayer aInventoryPlayer) {
+ this.addSlotToContainer(new Slot(this.mTileEntity, 0, 80, 17));
+ this.addSlotToContainer(new GT_Slot_Output(this.mTileEntity, 1, 80, 53));
+ this.addSlotToContainer(new GT_Slot_Render(this.mTileEntity, 2, 59, 42));
+ }
+
+ public void detectAndSendChanges() {
+ super.detectAndSendChanges();
+ if (!this.mTileEntity.isClientSide() && this.mTileEntity.getMetaTileEntity() != null) {
+ if (this.mTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_TieredChest) {
+ this.mContent = ((GT_MetaTileEntity_TieredChest) this.mTileEntity.getMetaTileEntity()).mItemCount;
+ } else {
+ this.mContent = 0;
+ }
+
+ Iterator var2 = this.crafters.iterator();
+
+ while (var2.hasNext()) {
+ ICrafting var1 = (ICrafting) var2.next();
+ var1.sendProgressBarUpdate(this, 100, this.mContent & '￿');
+ var1.sendProgressBarUpdate(this, 101, this.mContent >>> 16);
+ }
+
+ }
+ }
+
+ @SideOnly(Side.CLIENT)
+ public void updateProgressBar(int par1, int par2) {
+ super.updateProgressBar(par1, par2);
+ switch (par1) {
+ case 100 :
+ this.mContent = this.mContent & -65536 | par2;
+ break;
+ case 101 :
+ this.mContent = this.mContent & '￿' | par2 << 16;
+ }
+
+ }
+
+ public int getSlotCount() {
+ return 2;
+ }
+
+ public int getShiftClickSlotCount() {
+ return 1;
+ }
+} \ No newline at end of file
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/GUI_SuperChest.java b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/GUI_SuperChest.java
new file mode 100644
index 0000000000..259f589950
--- /dev/null
+++ b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/GUI_SuperChest.java
@@ -0,0 +1,37 @@
+package gtPlusPlus.xmod.gregtech.api.gui;
+
+import gregtech.api.gui.GT_GUIContainerMetaTile_Machine;
+import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
+import gregtech.api.util.GT_Utility;
+import net.minecraft.entity.player.InventoryPlayer;
+import net.minecraft.util.StatCollector;
+
+public class GUI_SuperChest extends GT_GUIContainerMetaTile_Machine {
+ private final String mName;
+
+ public GUI_SuperChest(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity,
+ String aName) {
+ super(new CONTAINER_SuperChest(aInventoryPlayer, aTileEntity), "gregtech:textures/gui/BasicTank.png");
+ this.mName = aName;
+ }
+
+ protected void drawGuiContainerForegroundLayer(int par1, int par2) {
+ this.fontRendererObj.drawString(StatCollector.translateToLocal("container.inventory"), 8, this.ySize - 96 + 2,
+ 4210752);
+ this.fontRendererObj.drawString(this.mName, 8, 6, 4210752);
+ if (this.mContainer != null) {
+ this.fontRendererObj.drawString("Item Amount", 10, 20, 16448255);
+ this.fontRendererObj.drawString(
+ GT_Utility.parseNumberToString(((CONTAINER_SuperChest) this.mContainer).mContent), 10, 30,
+ 16448255);
+ }
+
+ }
+
+ protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) {
+ super.drawGuiContainerBackgroundLayer(par1, par2, par3);
+ int x = (this.width - this.xSize) / 2;
+ 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/common/tileentities/storage/GT_MetaTileEntity_TieredChest.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GT_MetaTileEntity_TieredChest.java
new file mode 100644
index 0000000000..e3c7cbded5
--- /dev/null
+++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GT_MetaTileEntity_TieredChest.java
@@ -0,0 +1,192 @@
+package gtPlusPlus.xmod.gregtech.common.tileentities.storage;
+
+import gregtech.api.enums.Textures.BlockIcons;
+import gregtech.api.interfaces.ITexture;
+import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
+import gregtech.api.metatileentity.MetaTileEntity;
+import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_TieredMachineBlock;
+import gregtech.api.objects.GT_RenderedTexture;
+import gregtech.api.util.GT_Utility;
+import gregtech.common.gui.GT_Container_QuantumChest;
+import gregtech.common.gui.GT_GUIContainer_QuantumChest;
+import gtPlusPlus.xmod.gregtech.api.gui.CONTAINER_SuperChest;
+import gtPlusPlus.xmod.gregtech.api.gui.GUI_SuperChest;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.entity.player.InventoryPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+
+public class GT_MetaTileEntity_TieredChest extends GT_MetaTileEntity_TieredMachineBlock {
+ public int mItemCount = 0;
+ public ItemStack mItemStack = null;
+ private final static double mStorageFactor = (270000.0D/8);
+
+ public GT_MetaTileEntity_TieredChest(int aID, String aName, String aNameRegional, int aTier) {
+ super(aID, aName, aNameRegional, aTier, 3,
+ "This Chest stores " + (int) (Math.pow(6.0D, (double) aTier) * mStorageFactor) + " Items", new ITexture[0]);
+ }
+
+ public GT_MetaTileEntity_TieredChest(String aName, int aTier, String aDescription, ITexture[][][] aTextures) {
+ super(aName, aTier, 3, aDescription, aTextures);
+ }
+
+ public GT_MetaTileEntity_TieredChest(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) {
+ super(aName, aTier, 3, aDescription, aTextures);
+ }
+
+ public boolean isSimpleMachine() {
+ return true;
+ }
+
+ public boolean isFacingValid(byte aFacing) {
+ return true;
+ }
+
+ public boolean isAccessAllowed(EntityPlayer aPlayer) {
+ return true;
+ }
+
+ public boolean isValidSlot(int aIndex) {
+ return true;
+ }
+
+ public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) {
+ return new GT_MetaTileEntity_TieredChest(this.mName, this.mTier, this.mDescriptionArray, this.mTextures);
+ }
+
+ public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) {
+ if (aBaseMetaTileEntity.isClientSide()) {
+ return true;
+ } else {
+ aBaseMetaTileEntity.openGUI(aPlayer);
+ return true;
+ }
+ }
+
+ public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
+ return new CONTAINER_SuperChest(aPlayerInventory, aBaseMetaTileEntity);
+ }
+
+ public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
+ return new GUI_SuperChest(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName());
+ }
+
+ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) {
+ if (this.getBaseMetaTileEntity().isServerSide() && this.getBaseMetaTileEntity().isAllowedToWork()) {
+ if (this.getItemCount() <= 0) {
+ this.mItemStack = null;
+ this.mItemCount = 0;
+ }
+
+ if (this.mItemStack == null && this.mInventory[0] != null) {
+ this.mItemStack = this.mInventory[0].copy();
+ }
+
+ if (this.mInventory[0] != null && this.mItemCount < this.getMaxItemCount()
+ && GT_Utility.areStacksEqual(this.mInventory[0], this.mItemStack)) {
+ this.mItemCount += this.mInventory[0].stackSize;
+ if (this.mItemCount > this.getMaxItemCount()) {
+ this.mInventory[0].stackSize = this.mItemCount - this.getMaxItemCount();
+ this.mItemCount = this.getMaxItemCount();
+ } else {
+ this.mInventory[0] = null;
+ }
+ }
+
+ if (this.mInventory[1] == null && this.mItemStack != null) {
+ this.mInventory[1] = this.mItemStack.copy();
+ this.mInventory[1].stackSize = Math.min(this.mItemStack.getMaxStackSize(), this.mItemCount);
+ this.mItemCount -= this.mInventory[1].stackSize;
+ } else if (this.mItemCount > 0 && GT_Utility.areStacksEqual(this.mInventory[1], this.mItemStack)
+ && this.mInventory[1].getMaxStackSize() > this.mInventory[1].stackSize) {
+ int tmp = Math.min(this.mItemCount,
+ this.mInventory[1].getMaxStackSize() - this.mInventory[1].stackSize);
+ this.mInventory[1].stackSize += tmp;
+ this.mItemCount -= tmp;
+ }
+
+ if (this.mItemStack != null) {
+ this.mInventory[2] = this.mItemStack.copy();
+ this.mInventory[2].stackSize = Math.min(this.mItemStack.getMaxStackSize(), this.mItemCount);
+ } else {
+ this.mInventory[2] = null;
+ }
+ }
+
+ }
+
+ private int getItemCount() {
+ return this.mItemCount;
+ }
+
+ public void setItemCount(int aCount) {
+ this.mItemCount = aCount;
+ }
+
+ public int getProgresstime() {
+ return this.mItemCount + (this.mInventory[0] == null ? 0 : this.mInventory[0].stackSize)
+ + (this.mInventory[1] == null ? 0 : this.mInventory[1].stackSize);
+ }
+
+ public int maxProgresstime() {
+ return this.getMaxItemCount();
+ }
+
+ public int getMaxItemCount() {
+ return (int) (Math.pow(6.0D, (double) this.mTier) * mStorageFactor - 128.0D);
+ }
+
+ public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) {
+ return aIndex == 1;
+ }
+
+ public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) {
+ return aIndex == 0 && (this.mInventory[0] == null || GT_Utility.areStacksEqual(this.mInventory[0], aStack));
+ }
+
+ public String[] getInfoData() {
+ return this.mItemStack == null
+ ? new String[]{"Super Storage Chest", "Stored Items:", "No Items", Integer.toString(0),
+ Integer.toString(this.getMaxItemCount())}
+ : new String[]{"Super Storage Chest", "Stored Items:", this.mItemStack.getDisplayName(),
+ Integer.toString(this.mItemCount), Integer.toString(this.getMaxItemCount())};
+ }
+
+ public boolean isGivingInformation() {
+ return true;
+ }
+
+ public void saveNBTData(NBTTagCompound aNBT) {
+ aNBT.setInteger("mItemCount", this.mItemCount);
+ if (this.mItemStack != null) {
+ aNBT.setTag("mItemStack", this.mItemStack.writeToNBT(new NBTTagCompound()));
+ }
+
+ }
+
+ public void loadNBTData(NBTTagCompound aNBT) {
+ if (aNBT.hasKey("mItemCount")) {
+ this.mItemCount = aNBT.getInteger("mItemCount");
+ }
+
+ if (aNBT.hasKey("mItemStack")) {
+ this.mItemStack = ItemStack.loadItemStackFromNBT((NBTTagCompound) aNBT.getTag("mItemStack"));
+ }
+
+ }
+
+ public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex,
+ boolean aActive, boolean aRedstone) {
+ return aBaseMetaTileEntity.getFrontFacing() == 0 && aSide == 4
+ ? new ITexture[]{BlockIcons.MACHINE_CASINGS[this.mTier][aColorIndex + 1],
+ new GT_RenderedTexture(BlockIcons.OVERLAY_QCHEST)}
+ : (aSide == aBaseMetaTileEntity.getFrontFacing()
+ ? new ITexture[]{BlockIcons.MACHINE_CASINGS[this.mTier][aColorIndex + 1],
+ new GT_RenderedTexture(BlockIcons.OVERLAY_QCHEST)}
+ : new ITexture[]{BlockIcons.MACHINE_CASINGS[this.mTier][aColorIndex + 1]});
+ }
+
+ public ITexture[][][] getTextureSet(ITexture[] aTextures) {
+ return new ITexture[0][0][0];
+ }
+} \ No newline at end of file
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechSuperTanks.java b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechSuperTanks.java
new file mode 100644
index 0000000000..3a5199197c
--- /dev/null
+++ b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechSuperTanks.java
@@ -0,0 +1,52 @@
+package gtPlusPlus.xmod.gregtech.registration.gregtech;
+
+import static gtPlusPlus.core.recipe.common.CI.bitsd;
+
+import gregtech.api.enums.ItemList;
+import gregtech.api.enums.Materials;
+import gregtech.api.enums.OrePrefixes;
+import gregtech.api.util.GT_ModHandler;
+import gtPlusPlus.core.recipe.common.CI;
+import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList;
+import gtPlusPlus.xmod.gregtech.common.tileentities.storage.GT_MetaTileEntity_TieredChest;
+
+public class GregtechSuperTanks {
+
+ public static void run() {
+ int mId = 890;
+ GregtechItemList.Super_Chest_LV.set((new GT_MetaTileEntity_TieredChest(mId++, "super.chest.tier.01", "Super Chest I", 1)).getStackForm(1L));
+ GregtechItemList.Super_Chest_MV.set((new GT_MetaTileEntity_TieredChest(mId++, "super.chest.tier.02", "Super Chest II", 2)).getStackForm(1L));
+ GregtechItemList.Super_Chest_HV.set((new GT_MetaTileEntity_TieredChest(mId++, "super.chest.tier.03", "Super Chest III", 3)).getStackForm(1L));
+ GregtechItemList.Super_Chest_EV.set((new GT_MetaTileEntity_TieredChest(mId++, "super.chest.tier.04", "Super Chest IV", 4)).getStackForm(1L));
+ GregtechItemList.Super_Chest_IV.set((new GT_MetaTileEntity_TieredChest(mId++, "super.chest.tier.05", "Super Chest V", 5)).getStackForm(1L));
+
+
+ GT_ModHandler.addCraftingRecipe(GregtechItemList.Super_Chest_LV.get(1L, new Object[0]), bitsd,
+ new Object[]{"DPD", "PMP", "DGD", Character.valueOf('M'), ItemList.Hull_LV, Character.valueOf('G'),
+ ItemList.Automation_ChestBuffer_LV, Character.valueOf('D'),
+ OrePrefixes.circuit.get(Materials.Basic), Character.valueOf('P'),
+ OrePrefixes.plate.get(Materials.Invar)});
+
+ GT_ModHandler.addCraftingRecipe(GregtechItemList.Super_Chest_MV.get(1L, new Object[0]), bitsd,
+ new Object[]{"DPD", "PMP", "DGD", Character.valueOf('M'), ItemList.Hull_MV, Character.valueOf('G'),
+ ItemList.Automation_ChestBuffer_MV, Character.valueOf('D'), OrePrefixes.circuit.get(Materials.Good),
+ Character.valueOf('P'), OrePrefixes.plate.get(Materials.Aluminium)});
+
+ GT_ModHandler.addCraftingRecipe(GregtechItemList.Super_Chest_HV.get(1L, new Object[0]), bitsd,
+ new Object[]{"DPD", "PMP", "DGD", Character.valueOf('M'), ItemList.Hull_HV, Character.valueOf('G'),
+ ItemList.Automation_ChestBuffer_HV, Character.valueOf('D'), OrePrefixes.circuit.get(Materials.Advanced),
+ Character.valueOf('P'), OrePrefixes.plate.get(Materials.StainlessSteel)});
+
+ GT_ModHandler.addCraftingRecipe(GregtechItemList.Super_Chest_EV.get(1L, new Object[0]), bitsd,
+ new Object[]{"DPD", "PMP", "DGD", Character.valueOf('M'), ItemList.Hull_EV, Character.valueOf('G'),
+ ItemList.Automation_ChestBuffer_EV, Character.valueOf('D'), OrePrefixes.circuit.get(Materials.Data),
+ Character.valueOf('P'), OrePrefixes.plate.get(Materials.Titanium)});
+
+ GT_ModHandler.addCraftingRecipe(GregtechItemList.Super_Chest_IV.get(1L, new Object[0]), bitsd,
+ new Object[]{"DPD", "PMP", "DGD", Character.valueOf('M'), ItemList.Hull_IV, Character.valueOf('G'),
+ ItemList.Automation_ChestBuffer_IV, Character.valueOf('D'),
+ OrePrefixes.circuit.get(Materials.Elite), Character.valueOf('P'),
+ OrePrefixes.plate.get(Materials.Tungsten)});
+ }
+
+}