From 7e38e60d2205d0ca89610ade667099398cc6cb57 Mon Sep 17 00:00:00 2001 From: Alkalus Date: Tue, 26 May 2020 15:31:51 +0100 Subject: + Added two new Alloys. (Botmium and Laurenium) + Added four new Maching Casing blocks. --- .../blocks/GregtechMetaSpecialMachineCasings.java | 77 ++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaSpecialMachineCasings.java (limited to 'src/Java/gtPlusPlus/xmod/gregtech/common/blocks') diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaSpecialMachineCasings.java b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaSpecialMachineCasings.java new file mode 100644 index 0000000000..e91c865bd6 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaSpecialMachineCasings.java @@ -0,0 +1,77 @@ +package gtPlusPlus.xmod.gregtech.common.blocks; + +import java.util.List; + +import gregtech.api.enums.Textures; +import gregtech.api.util.GT_LanguageManager; +import gregtech.common.blocks.GT_Material_Casings; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; + + +public class GregtechMetaSpecialMachineCasings extends GregtechMetaCasingBlocksAbstract { + + + public static class SpecialCasingItemBlock extends GregtechMetaCasingItems { + + public SpecialCasingItemBlock(Block par1) { + super(par1); + } + + @Override + public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) { + int aMeta = aStack.getItemDamage(); + if (aMeta < 10) { + //aList.add("Tier: "+GT_Values.VN[aMeta]); + } + super.addInformation(aStack, aPlayer, aList, aF3_H); + } + } + + public GregtechMetaSpecialMachineCasings() { + super(SpecialCasingItemBlock.class, "gtplusplus.blockspecialcasings.2", GT_Material_Casings.INSTANCE); + for (byte i = 0; i < 16; i = (byte) (i + 1)) { + //TAE.registerTextures(new GT_CopiedBlockTexture(this, 6, i)); + // Don't register these Textures, They already exist within vanilla GT. (May not exist in 5.08) + } + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".0.name", "Strong Bronze Machine Casing"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".1.name", "Sturdy Aluminium Machine Casing"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".2.name", "Vigorous Laurenium Machine Casing"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".3.name", "Rugged Botmium Machine Casing"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".4.name", ""); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".5.name", ""); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".6.name", ""); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".7.name", ""); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".8.name", ""); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".9.name", ""); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".10.name", ""); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".11.name", ""); // Unused + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".12.name", ""); // Unused + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".13.name", ""); // Unused + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".14.name", ""); // Unused + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".15.name", ""); // Unused + + GregtechItemList.Casing_Machine_Custom_1.set(new ItemStack(this, 1, 0)); + GregtechItemList.Casing_Machine_Custom_2.set(new ItemStack(this, 1, 1)); + GregtechItemList.Casing_Machine_Custom_3.set(new ItemStack(this, 1, 2)); + GregtechItemList.Casing_Machine_Custom_4.set(new ItemStack(this, 1, 3)); + } + + public IIcon getIcon(int aSide, int aMeta) { + switch (aMeta) { + case 0: + return Textures.BlockIcons.MACHINE_BRONZEPLATEDBRICKS.getIcon(); + case 1: + return Textures.BlockIcons.MACHINE_CASING_FROST_PROOF.getIcon(); + case 2: + return Textures.BlockIcons.MACHINE_CASING_CLEAN_STAINLESSSTEEL.getIcon(); + case 3: + return Textures.BlockIcons.MACHINE_CASING_STABLE_TITANIUM.getIcon(); + } + return Textures.BlockIcons.RENDERING_ERROR.getIcon(); + } + +} -- cgit From 92b8261907b3800d4468c1dc546eccc4e158c224 Mon Sep 17 00:00:00 2001 From: Alkalus Date: Tue, 26 May 2020 17:34:28 +0100 Subject: + Added new Machine casings to the Chemical Plant code. % Changed colours of the two new alloys. --- src/Java/gregtech/api/enums/TAE.java | 2 +- src/Java/gtPlusPlus/core/material/ALLOY.java | 4 +- .../blocks/GregtechMetaSpecialMachineCasings.java | 8 +- .../common/blocks/textures/TexturesGtBlock.java | 4 +- .../chemplant/GregtechMTE_ChemicalPlant.java | 172 +++++++++------------ .../gregtech/GregtechAlgaeContent.java | 25 +++ .../TileEntities/MACHINE_CASING_LAURENIUM.png | Bin 0 -> 416 bytes 7 files changed, 112 insertions(+), 103 deletions(-) create mode 100644 src/resources/assets/miscutils/textures/blocks/TileEntities/MACHINE_CASING_LAURENIUM.png (limited to 'src/Java/gtPlusPlus/xmod/gregtech/common/blocks') diff --git a/src/Java/gregtech/api/enums/TAE.java b/src/Java/gregtech/api/enums/TAE.java index d7e16feb09..82ae7a3f52 100644 --- a/src/Java/gregtech/api/enums/TAE.java +++ b/src/Java/gregtech/api/enums/TAE.java @@ -42,7 +42,7 @@ public class TAE { return registerTexture(64 + aRealID, gt_CopiedBlockTexture); } - private static boolean registerTexture(int aID, GT_CopiedBlockTexture gt_CopiedBlockTexture) { + public static boolean registerTexture(int aID, GT_CopiedBlockTexture gt_CopiedBlockTexture) { if (mFreeSlots.contains(aID)) { mFreeSlots.remove(aID); mTAE.put(aID, gt_CopiedBlockTexture); diff --git a/src/Java/gtPlusPlus/core/material/ALLOY.java b/src/Java/gtPlusPlus/core/material/ALLOY.java index 4428dffbeb..22ffc34205 100644 --- a/src/Java/gtPlusPlus/core/material/ALLOY.java +++ b/src/Java/gtPlusPlus/core/material/ALLOY.java @@ -818,7 +818,7 @@ public final class ALLOY { public static final Material LAURENIUM = new Material( "Laurenium", //Material Name MaterialState.SOLID, //State - null, //Material Colour + new short[] {244, 168, 255, 0}, //Material Colour 6825, //Melting Point in C 11355, //Boiling Point in C -1, @@ -838,7 +838,7 @@ public final class ALLOY { public static final Material BOTMIUM = new Material( "Botmium", //Material Name MaterialState.SOLID, //State - null, //Material Colour + new short[] {80, 160, 80, 0}, //Material Colour 8220, //Melting Point in C 10540, //Boiling Point in C -1, diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaSpecialMachineCasings.java b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaSpecialMachineCasings.java index e91c865bd6..8f5dff592a 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaSpecialMachineCasings.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaSpecialMachineCasings.java @@ -2,10 +2,13 @@ package gtPlusPlus.xmod.gregtech.common.blocks; import java.util.List; +import gregtech.api.enums.TAE; import gregtech.api.enums.Textures; +import gregtech.api.objects.GT_CopiedBlockTexture; import gregtech.api.util.GT_LanguageManager; import gregtech.common.blocks.GT_Material_Casings; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -40,6 +43,7 @@ public class GregtechMetaSpecialMachineCasings extends GregtechMetaCasingBlocksA GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".0.name", "Strong Bronze Machine Casing"); GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".1.name", "Sturdy Aluminium Machine Casing"); GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".2.name", "Vigorous Laurenium Machine Casing"); + TAE.registerTexture(84, new GT_CopiedBlockTexture(this, 6, 2)); GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".3.name", "Rugged Botmium Machine Casing"); GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".4.name", ""); GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".5.name", ""); @@ -67,9 +71,9 @@ public class GregtechMetaSpecialMachineCasings extends GregtechMetaCasingBlocksA case 1: return Textures.BlockIcons.MACHINE_CASING_FROST_PROOF.getIcon(); case 2: - return Textures.BlockIcons.MACHINE_CASING_CLEAN_STAINLESSSTEEL.getIcon(); + return TexturesGtBlock.Casing_Material_Laurenium.getIcon(); case 3: - return Textures.BlockIcons.MACHINE_CASING_STABLE_TITANIUM.getIcon(); + return Textures.BlockIcons.MACHINE_HEATPROOFCASING.getIcon(); } return Textures.BlockIcons.RENDERING_ERROR.getIcon(); } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java index 93322d2ef1..ba6f3511a5 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java @@ -214,7 +214,9 @@ public class TexturesGtBlock { public static final CustomIcon Casing_Material_HastelloyN = Internal_Casing_HastelloyN; private static final CustomIcon Internal_Casing_Fluid_IncoloyDS = new CustomIcon("TileEntities/MACHINE_CASING_FLUID_INCOLOY_DS"); public static final CustomIcon Casing_Material_Fluid_IncoloyDS = Internal_Casing_Fluid_IncoloyDS; - + + private static final CustomIcon Internal_Casing_Laurenium = new CustomIcon("TileEntities/MACHINE_CASING_LAURENIUM"); + public static final CustomIcon Casing_Material_Laurenium = Internal_Casing_Laurenium; //Trinium Alloys public static final CustomIcon Casing_Trinium_Titanium = new CustomIcon("TileEntities/MACHINE_CASING_STABLE_TRINIUM_TITANIUM"); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/chemplant/GregtechMTE_ChemicalPlant.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/chemplant/GregtechMTE_ChemicalPlant.java index 8699393ca2..7fd89c481a 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/chemplant/GregtechMTE_ChemicalPlant.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/chemplant/GregtechMTE_ChemicalPlant.java @@ -3,6 +3,7 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.c import static gtPlusPlus.core.util.data.ArrayUtils.removeNulls; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import org.apache.commons.lang3.ArrayUtils; @@ -16,11 +17,12 @@ import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_TieredMachineBlock; import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GTPP_Recipe; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; -import gregtech.api.util.GTPP_Recipe; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.api.objects.data.Triplet; import gtPlusPlus.core.item.chemistry.general.ItemGenericChemBase; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.recipe.common.CI; @@ -32,6 +34,7 @@ import gtPlusPlus.xmod.gregtech.common.Meta_GT_Proxy; import gtPlusPlus.xmod.gregtech.common.StaticFields59; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; import net.minecraft.block.Block; +import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.util.ForgeDirection; @@ -46,6 +49,8 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase { private ArrayList mCatalystBuses = new ArrayList(); + private static final HashMap> mTieredBlockRegistry = new HashMap>(); + public GregtechMTE_ChemicalPlant(final int aID, final String aName, final String aNameRegional) { super(aID, aName, aNameRegional); } @@ -53,6 +58,40 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase { public GregtechMTE_ChemicalPlant(final String aName) { super(aName); } + + public static boolean registerMachineCasingForTier(int aTier, Block aBlock, int aMeta, int aCasingTextureID) { + int aSize = mTieredBlockRegistry.size(); + int aSize2 = aSize; + Triplet aCasingData = new Triplet(aBlock, aMeta, aCasingTextureID); + if (mTieredBlockRegistry.containsKey(aTier)) { + CORE.crash("Tried to register a Machine casing for tier "+aTier+" to the Chemical Plant, however this tier already contains one."); + } + mTieredBlockRegistry.put(aTier, aCasingData); + aSize = mTieredBlockRegistry.size(); + return aSize > aSize2; + } + + private static Block getBlockForTier(int aTier) { + if (!mTieredBlockRegistry.containsKey(aTier)) { + return Blocks.bedrock; + } + return mTieredBlockRegistry.get(aTier).getValue_1(); + } + private static int getMetaForTier(int aTier) { + if (!mTieredBlockRegistry.containsKey(aTier)) { + return 32; + } + return mTieredBlockRegistry.get(aTier).getValue_2(); + } + private static int getCasingTextureIdForTier(int aTier) { + if (!mTieredBlockRegistry.containsKey(aTier)) { + Logger.INFO("Couldn't find casing texture ID for tier "+aTier); + return 10; + } + int aCasingID = mTieredBlockRegistry.get(aTier).getValue_3(); + //Logger.INFO("Found casing texture ID "+aCasingID+" for tier "+aTier); + return aCasingID; + } @Override public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { @@ -108,24 +147,8 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase { if (aBaseMetaTileEntity.getWorld() != null) { } - // Check the Tier Client Side - int aTier = mSolidCasingTier; - - if (aTier == 1) { - aOriginalTexture = Textures.BlockIcons.CASING_BLOCKS[16]; - } - else if (aTier == 2) { - aOriginalTexture = Textures.BlockIcons.CASING_BLOCKS[49]; - } - else if (aTier == 3) { - aOriginalTexture = Textures.BlockIcons.CASING_BLOCKS[50]; - } - else if (aTier == 4) { - aOriginalTexture = Textures.BlockIcons.CASING_BLOCKS[48]; - } - else { - aOriginalTexture = Textures.BlockIcons.CASING_BLOCKS[11]; - } + int aCasingID = getCasingTextureID(); + aOriginalTexture = Textures.BlockIcons.CASING_BLOCKS[aCasingID]; if (aSide == aFacing) { return new ITexture[]{aOriginalTexture, new GT_RenderedTexture(aActive ? TexturesGtBlock.Overlay_Machine_Controller_Advanced_Active : TexturesGtBlock.Overlay_Machine_Controller_Advanced)}; @@ -135,7 +158,7 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase { @Override public boolean hasSlotInGUI() { - return false; + return true; } @Override @@ -165,7 +188,7 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase { } private int getSolidCasingTier() { - return mSolidCasingTier; + return this.mSolidCasingTier; } private int getMachineCasingTier() { @@ -180,23 +203,9 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase { private int getCasingTextureID() { // Check the Tier Client Side - int aTier = mSolidCasingTier; - - if (aTier == 1) { - return 16; - } - else if (aTier == 2) { - return 49; - } - else if (aTier == 3) { - return 50; - } - else if (aTier == 4) { - return 48; - } - else { - return 11; - } + int aTier = mSolidCasingTier; + int aCasingID = getCasingTextureIdForTier(aTier); + return aCasingID; } public boolean addToMachineList(IGregTechTileEntity aTileEntity) { @@ -237,21 +246,15 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase { mCoilTier = aNBT.getInteger("mCoilTier"); } - private static boolean isBlockSolidCasing(Block aBlock, int aMeta) { - if (aBlock == null) { + private static boolean isBlockSolidCasing(int aCurrentTier, Block aBlock, int aMeta) { + if (aBlock == null || (aMeta < 0 || aMeta > 16)) { return false; } - if (aBlock == GregTech_API.sBlockCasings2 && aMeta == 0) { + Block aTieredCasing = getBlockForTier(aCurrentTier); + int aTieredMeta = getMetaForTier(aCurrentTier); + if (aBlock == aTieredCasing && aMeta == aTieredMeta) { return true; } - if (aBlock == GregTech_API.sBlockCasings4) { - int aMetaStainlessCasing = 1; - int aMetaTitaniumCasing = 2; - int aMetaTungstenCasing = 0; - if (aMeta == aMetaStainlessCasing || aMeta == aMetaTitaniumCasing || aMeta == aMetaTungstenCasing) { - return true; - } - } return false; } private static boolean isBlockMachineCasing(Block aBlock, int aMeta) { @@ -272,8 +275,8 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase { Block aCasingBlock2 = GregTech_API.sBlockCasings2; if (aBlock == aCasingBlock2) { int aMetaBronzePipeCasing = 12; - int aMetaSteelPipeCasing = 13; - int aMetaTitaniumPipeCasing = 14; + //int aMetaSteelPipeCasing = 13; + //int aMetaTitaniumPipeCasing = 14; int aMetaTungstenPipeCasing = 15; if (aMeta > aMetaTungstenPipeCasing || aMeta < aMetaBronzePipeCasing) { return false; @@ -328,7 +331,6 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase { int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX * 3; int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ * 3; - int tAmount = 0; Logger.INFO("Checking ChemPlant Structure"); // Require Air above controller @@ -522,7 +524,7 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase { } } else { - if (isBlockSolidCasing(aBlock, aMeta)) { + if (isBlockSolidCasing(mSolidCasingTier, aBlock, aMeta)) { tAmount++; } else { @@ -558,7 +560,7 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase { } Block aBlock = aBaseMetaTileEntity.getBlockOffset(aOffsetX + i, r, aOffsetZ + j); int aMeta = aBaseMetaTileEntity.getMetaIDOffset(aOffsetX + i, r, aOffsetZ + j); - if (isBlockSolidCasing(aBlock, aMeta)) { + if (isBlockSolidCasing(mSolidCasingTier, aBlock, aMeta)) { tAmount++; } else { @@ -574,7 +576,7 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase { for (int j = -3; j < 4; j++) { Block aBlock = aBaseMetaTileEntity.getBlockOffset(aOffsetX + i, 6, aOffsetZ + j); int aMeta = aBaseMetaTileEntity.getMetaIDOffset(aOffsetX + i, 6, aOffsetZ + j); - if (isBlockSolidCasing(aBlock, aMeta)) { + if (isBlockSolidCasing(mSolidCasingTier, aBlock, aMeta)) { tAmount++; } else { @@ -644,26 +646,12 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase { else { aInitStructureCheck = aBaseMetaTileEntity.getBlockOffset(0, 1, xDir); aInitStructureCheckMeta = aBaseMetaTileEntity.getMetaIDOffset(0, 1, xDir); - } - if (aInitStructureCheck == GregTech_API.sBlockCasings2) { - int aMetaSteelCasing = 0; - if (aInitStructureCheckMeta == aMetaSteelCasing) { - return 1; - } - } - else if (aInitStructureCheck == GregTech_API.sBlockCasings4) { - int aMetaStainlessCasing = 1; - int aMetaTitaniumCasing = 2; - int aMetaTungstenCasing = 0; - if (aInitStructureCheckMeta == aMetaStainlessCasing) { - return 2; - } - else if (aInitStructureCheckMeta == aMetaTitaniumCasing) { - return 3; - } - else if (aInitStructureCheckMeta == aMetaTungstenCasing) { - return 4; - } + } + for (int aTier : mTieredBlockRegistry.keySet()) { + Triplet aData = mTieredBlockRegistry.get(aTier); + if (aData.getValue_1() == aInitStructureCheck && aData.getValue_2() == aInitStructureCheckMeta) { + return aTier; + } } return 0; } @@ -694,7 +682,6 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase { aInitStructureCheck = aBaseMetaTileEntity.getBlockOffset(0, 0, -1); aInitStructureCheckMeta = aBaseMetaTileEntity.getMetaIDOffset(0, 0, -1); } - } else { if (xDir > 0) { @@ -706,7 +693,6 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase { aInitStructureCheckMeta = aBaseMetaTileEntity.getMetaIDOffset(-1, 0, 0); } } - if (isBlockMachineCasing(aInitStructureCheck, aInitStructureCheckMeta)) { Logger.INFO("Using Meta "+aInitStructureCheckMeta); return aInitStructureCheckMeta; @@ -758,8 +744,12 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase { } // Silly Client Syncing if (aBaseMetaTileEntity.isClientSide()) { - this.mSolidCasingTier = getCasingTierOnClientSide(); + if (this != null && this.getBaseMetaTileEntity() != null && this.getBaseMetaTileEntity().getWorld() != null) { + this.mSolidCasingTier = getCasingTierOnClientSide(); + markDirty(); + } } + Logger.INFO("SolidCasingTier: "+mSolidCasingTier); super.onPostTick(aBaseMetaTileEntity, aTick); } @@ -1053,26 +1043,14 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase { aInitStructureCheck = aBaseMetaTileEntity.getBlockOffset(0, 1, xDir); aInitStructureCheckMeta = aBaseMetaTileEntity.getMetaIDOffset(0, 1, xDir); } - if (aInitStructureCheck == GregTech_API.sBlockCasings2) { - int aMetaSteelCasing = 0; - if (aInitStructureCheckMeta == aMetaSteelCasing) { - return 1; - } - } - else if (aInitStructureCheck == GregTech_API.sBlockCasings4) { - int aMetaStainlessCasing = 1; - int aMetaTitaniumCasing = 2; - int aMetaTungstenCasing = 0; - if (aInitStructureCheckMeta == aMetaStainlessCasing) { - return 2; - } - else if (aInitStructureCheckMeta == aMetaTitaniumCasing) { - return 3; - } - else if (aInitStructureCheckMeta == aMetaTungstenCasing) { - return 4; - } + for (int aTier : mTieredBlockRegistry.keySet()) { + Triplet aData = mTieredBlockRegistry.get(aTier); + if (aData.getValue_1() == aInitStructureCheck && aData.getValue_2() == aInitStructureCheckMeta) { + Logger.INFO("Found Tier information for "+aTier); + return aTier; + } } + Logger.INFO("Could not find tier info for "+aInitStructureCheck.getLocalizedName()+"|"+aInitStructureCheckMeta); return 0; } catch (Throwable t) { diff --git a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechAlgaeContent.java b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechAlgaeContent.java index 08901a1a3b..6ddc971f85 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechAlgaeContent.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechAlgaeContent.java @@ -1,6 +1,9 @@ package gtPlusPlus.xmod.gregtech.registration.gregtech; +import gregtech.api.GregTech_API; +import gregtech.api.enums.Textures; import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.nbthandlers.GT_MetaTileEntity_Hatch_Catalysts; @@ -25,6 +28,28 @@ public class GregtechAlgaeContent { GregtechItemList.ChemicalPlant_Controller.set(new GregtechMTE_ChemicalPlant(998, "chemicalplant.controller.tier.single", "ExxonMobil Chemical Plant").getStackForm(1L)); GregtechItemList.Bus_Catalysts.set((new GT_MetaTileEntity_Hatch_Catalysts(31030, "hatch.catalysts", "Catalyst Housing")).getStackForm(1L)); + + + int aTier = 0; + // Bronze + GregtechMTE_ChemicalPlant.registerMachineCasingForTier(aTier++, ModBlocks.blockCustomMachineCasings, 0, 10); + // Steel + GregtechMTE_ChemicalPlant.registerMachineCasingForTier(aTier++, GregTech_API.sBlockCasings2, 0, 16); + // Aluminium + GregtechMTE_ChemicalPlant.registerMachineCasingForTier(aTier++, ModBlocks.blockCustomMachineCasings, 1, 17); + // Stainless + GregtechMTE_ChemicalPlant.registerMachineCasingForTier(aTier++, GregTech_API.sBlockCasings4, 1, 49); + // Titanium + GregtechMTE_ChemicalPlant.registerMachineCasingForTier(aTier++, GregTech_API.sBlockCasings4, 2, 50); + // Tungsten + GregtechMTE_ChemicalPlant.registerMachineCasingForTier(aTier++, GregTech_API.sBlockCasings4, 0, 48); + // Laurenium + GregtechMTE_ChemicalPlant.registerMachineCasingForTier(aTier++, ModBlocks.blockCustomMachineCasings, 2, 84); + // Botmium + GregtechMTE_ChemicalPlant.registerMachineCasingForTier(aTier++, ModBlocks.blockCustomMachineCasings, 3, 11); + + + } } diff --git a/src/resources/assets/miscutils/textures/blocks/TileEntities/MACHINE_CASING_LAURENIUM.png b/src/resources/assets/miscutils/textures/blocks/TileEntities/MACHINE_CASING_LAURENIUM.png new file mode 100644 index 0000000000..02bd653538 Binary files /dev/null and b/src/resources/assets/miscutils/textures/blocks/TileEntities/MACHINE_CASING_LAURENIUM.png differ -- cgit From 664c388b944e87125a9305fbbdda6a374854e0b5 Mon Sep 17 00:00:00 2001 From: Alkalus Date: Sat, 30 May 2020 14:20:48 +0100 Subject: + Added framework for Elemental Duplicator. + Added custom Data Orb bus for Elemental Duplicator. - Removed weird dependency on CofhCore. --- .../gtPlusPlus/core/block/base/BlockBaseFluid.java | 3 +- .../renderer/particle/EntityDropParticleFX.java | 96 ++ .../gtPlusPlus/core/handler/COMPAT_HANDLER.java | 1 + .../xmod/gregtech/api/enums/GregtechItemList.java | 11 +- ...etaTileEntity_Hatch_ElementalDataOrbHolder.java | 141 +++ .../common/blocks/GregtechMetaCasingBlocks5.java | 10 +- .../common/blocks/textures/TexturesGtBlock.java | 1 + .../GregtechMTE_ElementalDuplicator.java | 989 +++++++++++++++++++++ .../chemplant/GregtechMTE_ChemicalPlant.java | 47 +- .../GregtechIndustrialElementDuplicator.java | 20 + .../textures/blocks/metro/TEXTURE_TECH_PANEL_D.png | Bin 0 -> 360 bytes 11 files changed, 1287 insertions(+), 32 deletions(-) create mode 100644 src/Java/gtPlusPlus/core/client/renderer/particle/EntityDropParticleFX.java create mode 100644 src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_ElementalDataOrbHolder.java create mode 100644 src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_ElementalDuplicator.java create mode 100644 src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialElementDuplicator.java create mode 100644 src/resources/assets/miscutils/textures/blocks/metro/TEXTURE_TECH_PANEL_D.png (limited to 'src/Java/gtPlusPlus/xmod/gregtech/common/blocks') diff --git a/src/Java/gtPlusPlus/core/block/base/BlockBaseFluid.java b/src/Java/gtPlusPlus/core/block/base/BlockBaseFluid.java index 49bb5aaf0c..db37e18a32 100644 --- a/src/Java/gtPlusPlus/core/block/base/BlockBaseFluid.java +++ b/src/Java/gtPlusPlus/core/block/base/BlockBaseFluid.java @@ -14,8 +14,7 @@ import net.minecraft.entity.EnumCreatureType; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; - -import cofh.lib.render.particle.EntityDropParticleFX; +import gtPlusPlus.core.client.renderer.particle.EntityDropParticleFX; import gtPlusPlus.core.creative.AddToCreativeTab; import gtPlusPlus.core.item.base.itemblock.ItemBlockMeta; import gtPlusPlus.core.lib.CORE; diff --git a/src/Java/gtPlusPlus/core/client/renderer/particle/EntityDropParticleFX.java b/src/Java/gtPlusPlus/core/client/renderer/particle/EntityDropParticleFX.java new file mode 100644 index 0000000000..ed2fdff272 --- /dev/null +++ b/src/Java/gtPlusPlus/core/client/renderer/particle/EntityDropParticleFX.java @@ -0,0 +1,96 @@ +package gtPlusPlus.core.client.renderer.particle; + +import cofh.lib.util.helpers.MathHelper; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import net.minecraft.block.BlockLiquid; +import net.minecraft.block.material.Material; +import net.minecraft.client.particle.EntityFX; +import net.minecraft.world.World; + +@SideOnly(Side.CLIENT) +public class EntityDropParticleFX extends EntityFX { + + private int bobTimer; + + public EntityDropParticleFX(World world, double x, double y, double z, float particleRed, float particleGreen, float particleBlue) { + + this(world, x, y, z, particleRed, particleGreen, particleBlue, -1); + } + + public EntityDropParticleFX(World world, double x, double y, double z, float particleRed, float particleGreen, float particleBlue, int gravityMod) { + + super(world, x, y, z, 0.0D, 0.0D, 0.0D); + this.motionX = this.motionY = this.motionZ = 0.0D; + + this.particleRed = particleRed; + this.particleGreen = particleGreen; + this.particleBlue = particleBlue; + + this.setParticleTextureIndex(113); + this.setSize(0.01F, 0.01F); + this.particleGravity = -0.06F * gravityMod; + this.bobTimer = 40; + this.particleMaxAge = (int) (48.0D / (Math.random() * 0.8D + 0.2D)); + this.motionX = this.motionY = this.motionZ = 0.0D; + } + + @Override + public void onUpdate() { + + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; + + this.motionY -= this.particleGravity; + + if (this.bobTimer-- > 0) { + this.motionX *= 0.02D; + this.motionY *= 0.02D; + this.motionZ *= 0.02D; + this.setParticleTextureIndex(113); + } else { + this.setParticleTextureIndex(112); + } + this.moveEntity(this.motionX, this.motionY, this.motionZ); + this.motionX *= 0.9800000190734863D; + this.motionY *= 0.9800000190734863D; + this.motionZ *= 0.9800000190734863D; + + if (this.particleMaxAge-- <= 0) { + this.setDead(); + } + if (this.onGround) { + this.setParticleTextureIndex(114); + this.motionX *= 0.699999988079071D; + this.motionZ *= 0.699999988079071D; + } + if (this.particleGravity > 0) { + Material material = this.worldObj.getBlock(MathHelper.floor(this.posX), MathHelper.floor(this.posY), MathHelper.floor(this.posZ)).getMaterial(); + + if (material.isLiquid() || material.isSolid()) { + double d0 = MathHelper.floor(this.posY) + + 1 + - BlockLiquid.getLiquidHeightPercent(this.worldObj.getBlockMetadata(MathHelper.floor(this.posX), MathHelper.floor(this.posY), + MathHelper.floor(this.posZ))); + if (this.posY < d0) { + this.setDead(); + } + } + } else { + Material material = this.worldObj.getBlock(MathHelper.ceil(this.posX), MathHelper.ceil(this.posY), MathHelper.ceil(this.posZ)).getMaterial(); + + if (material.isLiquid() || material.isSolid()) { + double d0 = MathHelper.ceil(this.posY) + + 1 + - BlockLiquid.getLiquidHeightPercent(this.worldObj.getBlockMetadata(MathHelper.ceil(this.posX), MathHelper.ceil(this.posY), + MathHelper.ceil(this.posZ))); + if (this.posY > d0) { + this.setDead(); + } + } + } + } + +} diff --git a/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java b/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java index fab74183aa..bbc0e44d7e 100644 --- a/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java +++ b/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java @@ -157,6 +157,7 @@ public class COMPAT_HANDLER { GregtechIndustrialAlloySmelter.run(); GregtechIsaMill.run(); GregtechSteamMultis.run(); + GregtechIndustrialElementDuplicator.run(); //New Horizons Content NewHorizonsAccelerator.run(); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java index 7d76082aee..161ba24378 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java @@ -397,6 +397,10 @@ public enum GregtechItemList implements GregtechItemContainer { // Flotation Cell Controller_Flotation_Cell, + // Elemental Duplicator + Controller_ElementalDuplicator, + Casing_ElementalDuplicator, + // Big Steam Macerator Controller_SteamMaceratorMulti, @@ -445,7 +449,10 @@ public enum GregtechItemList implements GregtechItemContainer { //Steam Multi Buses Hatch_Input_Bus_Steam, - Hatch_Output_Bus_Steam, + Hatch_Output_Bus_Steam, + + //Elemental Duplicator Data Orb Bus + Hatch_Input_Elemental_Duplicator, //Battery hatches for PSS @@ -703,7 +710,7 @@ public enum GregtechItemList implements GregtechItemContainer { FakeMachineCasingPlate_MV, FakeMachineCasingPlate_HV, FakeMachineCasingPlate_EV, FakeMachineCasingPlate_IV, FakeMachineCasingPlate_LuV, FakeMachineCasingPlate_ZPM, - FakeMachineCasingPlate_UV, FakeMachineCasingPlate_MAX, + FakeMachineCasingPlate_UV, FakeMachineCasingPlate_MAX, diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_ElementalDataOrbHolder.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_ElementalDataOrbHolder.java new file mode 100644 index 0000000000..a98c57eb30 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_ElementalDataOrbHolder.java @@ -0,0 +1,141 @@ +package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations; + +import gregtech.api.gui.GT_Container_4by4; +import gregtech.api.gui.GT_GUIContainer_4by4; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_LanguageManager; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +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_Hatch_ElementalDataOrbHolder extends GT_MetaTileEntity_Hatch { + public GT_Recipe_Map mRecipeMap = null; + public boolean disableSort; + + public GT_MetaTileEntity_Hatch_ElementalDataOrbHolder(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier, 16, new String[]{ + "Holds Data Orbs for the Elemental Duplicator", + }); + disableSort = true; + } + + public GT_MetaTileEntity_Hatch_ElementalDataOrbHolder(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, 16, aDescription, aTextures); + } + + public GT_MetaTileEntity_Hatch_ElementalDataOrbHolder(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, 16, aDescription, aTextures); + } + + @Override + public ITexture[] getTexturesActive(ITexture aBaseTexture) { + return new ITexture[]{aBaseTexture, new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Cyber_Interface)}; + } + + @Override + public ITexture[] getTexturesInactive(ITexture aBaseTexture) { + return new ITexture[]{aBaseTexture, new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Cyber_Interface)}; + } + + @Override + public boolean isSimpleMachine() { + return true; + } + + @Override + public boolean isFacingValid(byte aFacing) { + return true; + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public boolean isValidSlot(int aIndex) { + return true; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_Hatch_ElementalDataOrbHolder(mName, mTier, mDescriptionArray, mTextures); + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) return true; + aBaseMetaTileEntity.openGUI(aPlayer); + return true; + } + + @Override + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_Container_4by4(aPlayerInventory, aBaseMetaTileEntity); + } + + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_4by4(aPlayerInventory, aBaseMetaTileEntity, "Steam Input Bus"); + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { + if (aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.hasInventoryBeenModified()) { + fillStacksIntoFirstSlots(); + } + } + + public void updateSlots() { + for (int i = 0; i < mInventory.length; i++) + if (mInventory[i] != null && mInventory[i].stackSize <= 0) mInventory[i] = null; + fillStacksIntoFirstSlots(); + } + + protected void fillStacksIntoFirstSlots() { + if (disableSort) { + for (int i = 0; i < mInventory.length; i++) + if (mInventory[i] != null && mInventory[i].stackSize <= 0) + mInventory[i] = null; + } + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setBoolean("disableSort", disableSort); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + disableSort = aNBT.getBoolean("disableSort"); + } + + @Override + public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + + } + + public String trans(String aKey, String aEnglish) { + return GT_LanguageManager.addStringLocalization("Interaction_DESCRIPTION_Index_" + aKey, aEnglish, false); + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return true; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return aSide == getBaseMetaTileEntity().getFrontFacing() && (mRecipeMap == null || mRecipeMap.containsInput(aStack)); + } + +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks5.java b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks5.java index f3ad1de188..832ee2b56e 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks5.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks5.java @@ -26,10 +26,9 @@ extends GregtechMetaCasingBlocksAbstract { GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".0.name", "IsaMill Exterior Casing"); // IsaMill Casing TAE.registerTexture(0, 2, new GT_CopiedBlockTexture(this, 6, 0)); GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".1.name", "IsaMill Piping"); // IsaMill Pipe - TAE.registerTexture(0, 3, new GT_CopiedBlockTexture(this, 6, 0)); GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".2.name", "IsaMill Gearbox"); // IsaMill Gearbox - TAE.registerTexture(0, 4, new GT_CopiedBlockTexture(this, 6, 0)); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".3.name", ""); // Unused + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".3.name", "Elemental Confinement Shell"); // Duplicator Casing + TAE.registerTexture(0, 3, new GT_CopiedBlockTexture(this, 6, 3)); GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".4.name", ""); // Unused GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".5.name", ""); // Unused GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".6.name", ""); // Unused @@ -42,9 +41,11 @@ extends GregtechMetaCasingBlocksAbstract { GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".13.name", ""); // Unused GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".14.name", ""); // Unused GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".15.name", ""); // Unused + GregtechItemList.Casing_IsaMill_Casing.set(new ItemStack(this, 1, 0)); GregtechItemList.Casing_IsaMill_Pipe.set(new ItemStack(this, 1, 1)); GregtechItemList.Casing_IsaMill_Gearbox.set(new ItemStack(this, 1, 2)); + GregtechItemList.Casing_ElementalDuplicator.set(new ItemStack(this, 1, 2)); } @Override @@ -62,7 +63,8 @@ extends GregtechMetaCasingBlocksAbstract { return TexturesGtBlock.TEXTURE_PIPE_GRINDING_MILL.getIcon(); case 2: return TexturesGtBlock.TEXTURE_GEARBOX_GRINDING_MILL.getIcon(); - + case 3: + return TexturesGtBlock.TEXTURE_TECH_PANEL_D.getIcon(); } } return Textures.BlockIcons.RENDERING_ERROR.getIcon(); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java index ba6f3511a5..07fd2fe82b 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java @@ -469,6 +469,7 @@ public class TexturesGtBlock { public static final CustomIcon TEXTURE_TECH_PANEL_A = new CustomIcon("metro/TEXTURE_TECH_PANEL_A"); public static final CustomIcon TEXTURE_TECH_PANEL_B = new CustomIcon("metro/TEXTURE_TECH_PANEL_B"); public static final CustomIcon TEXTURE_TECH_PANEL_C = new CustomIcon("metro/TEXTURE_TECH_PANEL_C"); + public static final CustomIcon TEXTURE_TECH_PANEL_D = new CustomIcon("metro/TEXTURE_TECH_PANEL_D"); public static final CustomIcon TEXTURE_TECH_PANEL_RADIOACTIVE = new CustomIcon("TileEntities/DecayablesChest_bottom"); public static final CustomIcon TEXTURE_TECH_PANEL_RADIOACTIVE_ALT = new CustomIcon("TileEntities/DecayablesChest_top"); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_ElementalDuplicator.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_ElementalDuplicator.java new file mode 100644 index 0000000000..05b6b19d5c --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_ElementalDuplicator.java @@ -0,0 +1,989 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; + +import static gtPlusPlus.core.util.data.ArrayUtils.removeNulls; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +import org.apache.commons.lang3.ArrayUtils; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.GregTech_API; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_TieredMachineBlock; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GTPP_Recipe; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.api.objects.data.Triplet; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.item.chemistry.general.ItemGenericChemBase; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.recipe.common.CI; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_ElementalDataOrbHolder; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.nbthandlers.GT_MetaTileEntity_Hatch_Catalysts; +import gtPlusPlus.xmod.gregtech.common.Meta_GT_Proxy; +import gtPlusPlus.xmod.gregtech.common.StaticFields59; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; + +public class GregtechMTE_ElementalDuplicator extends GregtechMeta_MultiBlockBase { + + private int mSolidCasingTier = 0; + private int mMachineCasingTier = 0; + private int mPipeCasingTier = 0; + private int mCoilTier = 0; + + private ArrayList mDataHolders = new ArrayList(); + + private static final HashMap> mTieredBlockRegistry = new HashMap>(); + + public GregtechMTE_ElementalDuplicator(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMTE_ElementalDuplicator(final String aName) { + super(aName); + } + + public static boolean registerMachineCasingForTier(int aTier, Block aBlock, int aMeta, int aCasingTextureID) { + int aSize = mTieredBlockRegistry.size(); + int aSize2 = aSize; + Triplet aCasingData = new Triplet(aBlock, aMeta, aCasingTextureID); + if (mTieredBlockRegistry.containsKey(aTier)) { + CORE.crash("Tried to register a Machine casing for tier "+aTier+" to the Chemical Plant, however this tier already contains one."); + } + mTieredBlockRegistry.put(aTier, aCasingData); + aSize = mTieredBlockRegistry.size(); + return aSize > aSize2; + } + + private static Block getBlockForTier(int aTier) { + if (!mTieredBlockRegistry.containsKey(aTier)) { + return Blocks.bedrock; + } + return mTieredBlockRegistry.get(aTier).getValue_1(); + } + private static int getMetaForTier(int aTier) { + if (!mTieredBlockRegistry.containsKey(aTier)) { + return 32; + } + return mTieredBlockRegistry.get(aTier).getValue_2(); + } + private static int getCasingTextureIdForTier(int aTier) { + return 67; + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMTE_ElementalDuplicator(this.mName); + } + + @Override + public String getMachineType() { + return "Chemical Plant"; + } + + @Override + public String[] getTooltip() { + return new String[] { + "Controller Block for the Industrial Replication Machine", + "Now replication is less painful", + "Please read to user manual for more information on construction & usage", + TAG_HIDE_MAINT + }; + } + + @Override + public String getSound() { + return GregTech_API.sSoundList.get(Integer.valueOf(207)); + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + + ITexture aOriginalTexture; + + // Check things exist client side (The worst code ever) + if (aBaseMetaTileEntity.getWorld() != null) { + + } + int aCasingID = getCasingTextureID(); + aOriginalTexture = Textures.BlockIcons.CASING_BLOCKS[aCasingID]; + + if (aSide == aFacing) { + return new ITexture[]{aOriginalTexture, new GT_RenderedTexture(aActive ? TexturesGtBlock.Overlay_Machine_Controller_Advanced_Active : TexturesGtBlock.Overlay_Machine_Controller_Advanced)}; + } + return new ITexture[]{aOriginalTexture}; + } + + @Override + public boolean hasSlotInGUI() { + return true; + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return GTPP_Recipe.GTPP_Recipe_Map.sChemicalPlant_GT; + } + + public static void generateRecipes() { + for (GTPP_Recipe i : GTPP_Recipe.GTPP_Recipe_Map.sChemicalPlantRecipes.mRecipeList) { + GTPP_Recipe.GTPP_Recipe_Map.sChemicalPlant_GT.add(i); + } + } + + @Override + public boolean isFacingValid(final byte aFacing) { + return aFacing > 1; + } + + @Override + public int getMaxParallelRecipes() { + return 2 * getPipeCasingTier(); + } + + @Override + public int getEuDiscountForParallelism() { + return 100; + } + + private int getSolidCasingTier() { + return this.mSolidCasingTier; + } + + private int getMachineCasingTier() { + return mMachineCasingTier; + } + private int getPipeCasingTier() { + return mPipeCasingTier; + } + private int getCoilTier() { + return mCoilTier; + } + + private int getCasingTextureID() { + // Check the Tier Client Side + int aTier = mSolidCasingTier; + int aCasingID = getCasingTextureIdForTier(aTier); + return aCasingID; + } + + public boolean addToMachineList(IGregTechTileEntity aTileEntity) { + int aMaxTier = getMachineCasingTier(); + final IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity instanceof GT_MetaTileEntity_TieredMachineBlock) { + GT_MetaTileEntity_TieredMachineBlock aMachineBlock = (GT_MetaTileEntity_TieredMachineBlock) aMetaTileEntity; + int aTileTier = aMachineBlock.mTier; + if (aTileTier > aMaxTier) { + Logger.INFO("Hatch tier too high."); + return false; + } + else { + return addToMachineList(aTileEntity, getCasingTextureID()); + } + } + else { + Logger.INFO("Bad Tile Entity being added to hatch map."); // Shouldn't ever happen, but.. ya know.. + return false; + } + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setInteger("mSolidCasingTier", this.mSolidCasingTier); + aNBT.setInteger("mMachineCasingTier", this.mMachineCasingTier); + aNBT.setInteger("mPipeCasingTier", this.mPipeCasingTier); + aNBT.setInteger("mCoilTier", this.mCoilTier); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + mSolidCasingTier = aNBT.getInteger("mSolidCasingTier"); + mMachineCasingTier = aNBT.getInteger("mMachineCasingTier"); + mPipeCasingTier = aNBT.getInteger("mPipeCasingTier"); + mCoilTier = aNBT.getInteger("mCoilTier"); + } + + private static boolean isBlockSolidCasing(int aCurrentTier, Block aBlock, int aMeta) { + if (aBlock == null || (aMeta < 0 || aMeta > 16)) { + return false; + } + Block aTieredCasing = ModBlocks.blockCasings5Misc; + int aTieredMeta = 3; + if (aBlock == aTieredCasing && aMeta == aTieredMeta) { + return true; + } + return false; + } + private static boolean isBlockMachineCasing(Block aBlock, int aMeta) { + Block aCasingBlock1 = GregTech_API.sBlockCasings1; + if (aBlock == aCasingBlock1) { + if (aMeta > 9 || aMeta < 0) { + return false; + } + else { + return true; + } + } + else { + return false; + } + } + private static boolean isBlockPipeCasing(Block aBlock, int aMeta) { + Block aCasingBlock2 = GregTech_API.sBlockCasings2; + if (aBlock == aCasingBlock2) { + int aMetaBronzePipeCasing = 12; + //int aMetaSteelPipeCasing = 13; + //int aMetaTitaniumPipeCasing = 14; + int aMetaTungstenPipeCasing = 15; + if (aMeta > aMetaTungstenPipeCasing || aMeta < aMetaBronzePipeCasing) { + return false; + } + else { + return true; + } + } + else { + return false; + } + } + + private static AutoMap mValidCoilMetaCache; + + private static boolean isBlockCoil(Block aBlock, int aMeta) { + Block aCasingBlock; + if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { + aCasingBlock = StaticFields59.getBlockCasings5(); + } + else { + aCasingBlock = GregTech_API.sBlockCasings1; + } + // Cache the meta values for later + if (mValidCoilMetaCache == null || mValidCoilMetaCache.isEmpty()) { + AutoMap aValidCoilMeta = new AutoMap(); + // Only use the right meta values available. + if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { + aValidCoilMeta = Meta_GT_Proxy.GT_ValidHeatingCoilMetas; + } + else { + aValidCoilMeta.put(12); + aValidCoilMeta.put(13); + aValidCoilMeta.put(14); + } + mValidCoilMetaCache = aValidCoilMeta; + } + if (aBlock == aCasingBlock) { + for (int i: mValidCoilMetaCache.values()) { + if (i == aMeta) { + return true; + } + } + } + return false; + } + + + @Override + public boolean checkMultiblock(final IGregTechTileEntity aBaseMetaTileEntity, final ItemStack aStack) { + + int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX * 3; + int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ * 3; + + Logger.INFO("Checking ChemPlant Structure"); + + // Require Air above controller + boolean aAirCheck = aBaseMetaTileEntity.getAirOffset(0, 1, 0); + + if (!aAirCheck) { + Logger.INFO("No Air Above Controller"); + return false; + } else { + + //String aName = aInitStructureCheck != null ? ItemUtils.getLocalizedNameOfBlock(aInitStructureCheck, aInitStructureCheckMeta) : "Air"; + + mSolidCasingTier = getSolidCasingTierCheck(aBaseMetaTileEntity, xDir, zDir); + mMachineCasingTier = getMachineCasingTierCheck(aBaseMetaTileEntity, xDir, zDir); + + Logger.INFO("Initial Casing Check Complete, Solid Casing Tier: "+mSolidCasingTier+", Machine Casing Tier: "+mMachineCasingTier); + + int aSolidCasingCount = 0; + int aMachineCasingCount = 0; + int aPipeCount = 0; + int aCoilCount = 0; + + aSolidCasingCount = checkSolidCasings(aBaseMetaTileEntity, aStack, xDir, zDir); + aMachineCasingCount = checkMachineCasings(aBaseMetaTileEntity, aStack, xDir, zDir); + aPipeCount = checkPipes(aBaseMetaTileEntity, aStack, xDir, zDir); + aCoilCount = checkCoils(aBaseMetaTileEntity, aStack, xDir, zDir); + + Logger.INFO("Casing Counts: "); + Logger.INFO("Solid: "+aSolidCasingCount+", Machine: "+aMachineCasingCount); + Logger.INFO("Pipe: "+aPipeCount+", Coil: "+aCoilCount); + + + Logger.INFO("Casing Tiers: "); + Logger.INFO("Solid: "+getSolidCasingTier()+", Machine: "+getMachineCasingTier()); + Logger.INFO("Pipe: "+getPipeCasingTier()+", Coil: "+getCoilTier()); + + // Attempt to sync fields here, so that it updates client side values. + aBaseMetaTileEntity.getWorld().markBlockForUpdate(aBaseMetaTileEntity.getXCoord(), aBaseMetaTileEntity.getYCoord(), aBaseMetaTileEntity.getZCoord()); + + + + // Minimum 80/93 Solid Casings + if (aSolidCasingCount < 80) { + Logger.INFO("Not enough solid casings. Found "+aSolidCasingCount+", require: 80."); + return false; + } + if (aMachineCasingCount != 57) { + Logger.INFO("Not enough machine casings. Found "+aMachineCasingCount+", require: 57."); + return false; + } + if (aPipeCount != 18) { + Logger.INFO("Not enough pipe casings. Found "+aPipeCount+", require: 18."); + return false; + } + if (aCoilCount != 27) { + Logger.INFO("Not enough coils. Found "+aCoilCount+", require: 27."); + return false; + } + + Logger.INFO("Structure Check Complete!"); + + return true; + } + } + + + public int checkCoils(final IGregTechTileEntity aBaseMetaTileEntity, final ItemStack aStack, int aOffsetX, int aOffsetZ) { + int tAmount = 0; + int aCurrentCoilMeta = -1; + for (int i = -1; i < 2; i++) { + for (int j = -1; j < 2; j++) { + for (int h = 0; h < 8; h++) { + if (h == 1 || h == 3 || h == 5) { + Block aBlock = aBaseMetaTileEntity.getBlockOffset(aOffsetX + i, h, aOffsetZ + j); + int aMeta = aBaseMetaTileEntity.getMetaIDOffset(aOffsetX + i, h, aOffsetZ + j); + if (isBlockCoil(aBlock, aMeta)) { + if (aCurrentCoilMeta < 0) { + aCurrentCoilMeta = aMeta; + } + if (aCurrentCoilMeta != aMeta) { + return tAmount; + } + else { + tAmount++; + } + } + } + } + } + } + + if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { + this.mCoilTier = (aCurrentCoilMeta+1); + } + else { + if (aCurrentCoilMeta == 12) { + this.mCoilTier = 1; + } + else if (aCurrentCoilMeta == 13) { + this.mCoilTier = 2; + } + else if (aCurrentCoilMeta == 14) { + this.mCoilTier = 3; + } + else { + this.mCoilTier = 0; + } + } + + return tAmount; + } + + + public int checkPipes(final IGregTechTileEntity aBaseMetaTileEntity, final ItemStack aStack, int aOffsetX, int aOffsetZ) { + int tAmount = 0; + int aCurrentPipeMeta = -1; + for (int i = -1; i < 2; i++) { + for (int j = -1; j < 2; j++) { + for (int h = 0; h < 8; h++) { + if (h == 2 || h == 4) { + Block aBlock = aBaseMetaTileEntity.getBlockOffset(aOffsetX + i, h, aOffsetZ + j); + int aMeta = aBaseMetaTileEntity.getMetaIDOffset(aOffsetX + i, h, aOffsetZ + j); + if (isBlockPipeCasing(aBlock, aMeta)) { + if (aCurrentPipeMeta < 0) { + aCurrentPipeMeta = aMeta; + } + if (aCurrentPipeMeta != aMeta) { + return tAmount; + } + else { + tAmount++; + } + } + } + } + } + } + + if (aCurrentPipeMeta == 12) { + this.mPipeCasingTier = 1; + } + else if (aCurrentPipeMeta == 13) { + this.mPipeCasingTier = 2; + } + else if (aCurrentPipeMeta == 14) { + this.mPipeCasingTier = 3; + } + else if (aCurrentPipeMeta == 15) { + this.mPipeCasingTier = 4; + } + else { + this.mPipeCasingTier = 0; + } + + return tAmount; + } + + + public int checkSolidCasings(final IGregTechTileEntity aBaseMetaTileEntity, final ItemStack aStack, int aOffsetX, int aOffsetZ) { + + int tAmount = 0; + + // Only check a 7x7 + for (int i = -3; i < 4; i++) { + for (int j = -3; j < 4; j++) { + // If we are on the 7x7 ring, proceed + IGregTechTileEntity aTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(aOffsetX + i, 0, aOffsetZ + j); + Block aBlock = aBaseMetaTileEntity.getBlockOffset(aOffsetX + i, 0, aOffsetZ + j); + int aMeta = aBaseMetaTileEntity.getMetaIDOffset(aOffsetX + i, 0, aOffsetZ + j); + + if (aTileEntity != null) { + + if (this.addToMachineList(aTileEntity)) { + tAmount++; + } + else { + if (aTileEntity != null) { + Logger.INFO("Adding "+aTileEntity.getInventoryName()); + } + final IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + Logger.INFO("Error counting Bottom Layer Casing Ring. Bad Tile Entity. Found "+aTileEntity.getInventoryName()); + return tAmount; + } + //Handle controller + if (aMetaTileEntity instanceof GregtechMTE_ElementalDuplicator) { + continue; + } + else { + Logger.INFO("Error counting Bottom Layer Casing Ring. Bad Tile Entity. Found "+aMetaTileEntity.getInventoryName()); + return tAmount; + } + } + } + else { + if (isBlockSolidCasing(mSolidCasingTier, aBlock, aMeta)) { + tAmount++; + } + else { + Logger.INFO("Error counting Bottom Layer Casing Ring. Found "+aBlock.getLocalizedName()+":"+aMeta); + return tAmount; + } + } + + } + } + + return tAmount; + } + + + public int checkMachineCasings(final IGregTechTileEntity aBaseMetaTileEntity, final ItemStack aStack, int aOffsetX, int aOffsetZ) { + int tAmount = 0; + int aHeight = 0; + // Iterate once for each layer + for (int aIteration=0;aIteration<3;aIteration++) { + // Dynamically set height + aHeight = (aIteration == 0 ? 0 : aIteration == 1 ? 1 : 5); + // Only check a 5x5 area + for (int i = -2; i < 3; i++) { + for (int j = -2; j < 3; j++) { + // If we are on the 5x5 ring, proceed + if (i == -2 || i == 2 || j == -2 || j == 2) { + // If the second axis is on the outer ring, continue + if (i < -2 || i > 2 || j < -2 || j > 2) { + continue; + } + Block aBlock = aBaseMetaTileEntity.getBlockOffset(aOffsetX + i, aHeight, aOffsetZ + j); + int aMeta = aBaseMetaTileEntity.getMetaIDOffset(aOffsetX + i, aHeight, aOffsetZ + j); + if (isBlockMachineCasing(aBlock, aMeta)) { + tAmount++; + } + else { + return tAmount; + } + } + } + } + } + + // Check bottom layer inner 3x3 + for (int i = -1; i < 2; i++) { + for (int j = -1; j < 2; j++) { + Block aBlock = aBaseMetaTileEntity.getBlockOffset(aOffsetX + i, 0, aOffsetZ + j); + int aMeta = aBaseMetaTileEntity.getMetaIDOffset(aOffsetX + i, 0, aOffsetZ + j); + if (isBlockMachineCasing(aBlock, aMeta)) { + tAmount++; + } + else { + return tAmount; + } + } + } + + return tAmount; + } + + public int getSolidCasingTierCheck(IGregTechTileEntity aBaseMetaTileEntity, int xDir, int zDir) { + Block aInitStructureCheck; + int aInitStructureCheckMeta; + if (xDir == 0) { + aInitStructureCheck = aBaseMetaTileEntity.getBlockOffset(zDir, 1, 0); + aInitStructureCheckMeta = aBaseMetaTileEntity.getMetaIDOffset(zDir, 1, 0); + } + else { + aInitStructureCheck = aBaseMetaTileEntity.getBlockOffset(0, 1, xDir); + aInitStructureCheckMeta = aBaseMetaTileEntity.getMetaIDOffset(0, 1, xDir); + } + for (int aTier : mTieredBlockRegistry.keySet()) { + Triplet aData = mTieredBlockRegistry.get(aTier); + if (aData.getValue_1() == aInitStructureCheck && aData.getValue_2() == aInitStructureCheckMeta) { + return aTier; + } + } + return 0; + } + + @Override + public boolean addToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + final IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return false; + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_ElementalDataOrbHolder) { + log("Found GT_MetaTileEntity_Hatch_ElementalDataOrbHolder"); + return addToMachineListInternal(mDataHolders, aMetaTileEntity, aBaseCasingIndex); + } + return super.addToMachineList(aTileEntity, aBaseCasingIndex); + } + + public int getMachineCasingTierCheck(IGregTechTileEntity aBaseMetaTileEntity, int xDir, int zDir) { + return 10; + } + + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerTick(final ItemStack aStack) { + return 0; + } + + @Override + public int getAmountOfOutputs() { + return 1; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } + + @Override + public String getCustomGUIResourceName() { + return null; + } + + // Same speed bonus as pyro oven + public int getSpeedBonus() { + return 50 * (this.mCoilTier - 2); + } + + public int getMaxCatalystDurability() { + return 50; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aBaseMetaTileEntity.isServerSide()) { + if (this.mUpdate == 1 || this.mStartUpCheck == 1) { + this.mDataHolders.clear(); + } + } + // Silly Client Syncing + if (aBaseMetaTileEntity.isClientSide()) { + if (this != null && this.getBaseMetaTileEntity() != null && this.getBaseMetaTileEntity().getWorld() != null) { + this.mSolidCasingTier = getCasingTierOnClientSide(); + markDirty(); + } + } + super.onPostTick(aBaseMetaTileEntity, aTick); + } + + @Override + public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPreTick(aBaseMetaTileEntity, aTick); + } + + @Override + public boolean checkRecipe(final ItemStack aStack) { + return checkRecipeGeneric(getMaxParallelRecipes(), getEuDiscountForParallelism(), getSpeedBonus()); + } + + + @Override + public boolean checkRecipeGeneric( + ItemStack[] aItemInputs, FluidStack[] aFluidInputs, + int aMaxParallelRecipes, int aEUPercent, + int aSpeedBonusPercent, int aOutputChanceRoll, GT_Recipe aRecipe) { + + // Based on the Processing Array. A bit overkill, but very flexible. + + // Reset outputs and progress stats + this.mEUt = 0; + this.mMaxProgresstime = 0; + this.mOutputItems = new ItemStack[]{}; + this.mOutputFluids = new FluidStack[]{}; + + long tVoltage = getMaxInputVoltage(); + byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + long tEnergy = getMaxInputEnergy(); + log("Running checkRecipeGeneric(0)"); + + // checks if it has a catalyst with enough durability + ItemStack tCatalystRecipe = findCatalyst(aItemInputs); + if (tCatalystRecipe == null) { + log("does not have catalyst"); + return false; + } + + GT_Recipe tRecipe = findRecipe( + getBaseMetaTileEntity(), mLastRecipe, false, + gregtech.api.enums.GT_Values.V[tTier], aFluidInputs, aItemInputs); + + + log("Running checkRecipeGeneric(1)"); + // Remember last recipe - an optimization for findRecipe() + this.mLastRecipe = tRecipe; + + + if (tRecipe == null) { + log("BAD RETURN - 1"); + return false; + } + + if (tRecipe.mSpecialValue > this.mSolidCasingTier) { + log("solid tier is too low"); + return false; + } + + + aMaxParallelRecipes = this.canBufferOutputs(tRecipe, aMaxParallelRecipes); + if (aMaxParallelRecipes == 0) { + log("BAD RETURN - 2"); + return false; + } + + // checks if it has enough catalyst durabilety + ArrayListtCatalysts = null; + int tMaxParrallelCatalyst = aMaxParallelRecipes; + if (tCatalystRecipe != null) { + tCatalysts = new ArrayList(); + tMaxParrallelCatalyst = getCatalysts(aItemInputs, tCatalystRecipe, aMaxParallelRecipes, tCatalysts); + log("Can process "+tMaxParrallelCatalyst+" recipes. If less than "+aMaxParallelRecipes+", catalyst does not have enough durability."); + } + + if (tMaxParrallelCatalyst == 0) { + log("found not enough catalysts"); + return false; + } + + // EU discount + float tRecipeEUt = (tRecipe.mEUt * aEUPercent) / 100.0f; + float tTotalEUt = 0.0f; + log("aEUPercent "+aEUPercent); + log("mEUt "+tRecipe.mEUt); + + int parallelRecipes = 0; + + log("parallelRecipes: "+parallelRecipes); + log("aMaxParallelRecipes: "+tMaxParrallelCatalyst); + log("tTotalEUt: "+tTotalEUt); + log("tVoltage: "+tVoltage); + log("tEnergy: "+tEnergy); + log("tRecipeEUt: "+tRecipeEUt); + // Count recipes to do in parallel, consuming input items and fluids and considering input voltage limits + for (; parallelRecipes < tMaxParrallelCatalyst && tTotalEUt < (tEnergy - tRecipeEUt); parallelRecipes++) { + if (!tRecipe.isRecipeInputEqual(true, aFluidInputs, aItemInputs)) { + log("Broke at "+parallelRecipes+"."); + break; + } + log("Bumped EU from "+tTotalEUt+" to "+(tTotalEUt+tRecipeEUt)+"."); + tTotalEUt += tRecipeEUt; + } + + if (parallelRecipes == 0) { + log("BAD RETURN - 3"); + return false; + } + + // -- Try not to fail after this point - inputs have already been consumed! -- + + + // Convert speed bonus to duration multiplier + // e.g. 100% speed bonus = 200% speed = 100%/200% = 50% recipe duration. + aSpeedBonusPercent = Math.max(-99, aSpeedBonusPercent); + float tTimeFactor = 100.0f / (100.0f + aSpeedBonusPercent); + this.mMaxProgresstime = (int)(tRecipe.mDuration * tTimeFactor); + + this.mEUt = (int)Math.ceil(tTotalEUt); + + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + + // Overclock + if (this.mEUt <= 16) { + this.mEUt = (this.mEUt * (1 << tTier - 1) * (1 << tTier - 1)); + this.mMaxProgresstime = (this.mMaxProgresstime / (1 << tTier - 1)); + } else { + while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { + this.mEUt *= 4; + this.mMaxProgresstime /= 2; + } + } + + if (this.mEUt > 0) { + this.mEUt = (-this.mEUt); + } + + + this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); + + // Collect fluid outputs + FluidStack[] tOutputFluids = new FluidStack[tRecipe.mFluidOutputs.length]; + for (int h = 0; h < tRecipe.mFluidOutputs.length; h++) { + if (tRecipe.getFluidOutput(h) != null) { + tOutputFluids[h] = tRecipe.getFluidOutput(h).copy(); + tOutputFluids[h].amount *= parallelRecipes; + } + } + + // Collect output item types + ItemStack[] tOutputItems = new ItemStack[tRecipe.mOutputs.length]; + for (int h = 0; h < tRecipe.mOutputs.length; h++) { + if (tRecipe.getOutput(h) != null) { + tOutputItems[h] = tRecipe.getOutput(h).copy(); + tOutputItems[h].stackSize = 0; + } + } + + // Set output item stack sizes (taking output chance into account) + for (int f = 0; f < tOutputItems.length; f++) { + if (tRecipe.mOutputs[f] != null && tOutputItems[f] != null) { + for (int g = 0; g < parallelRecipes; g++) { + if (getBaseMetaTileEntity().getRandomNumber(aOutputChanceRoll) < tRecipe.getOutputChance(f)) + tOutputItems[f].stackSize += tRecipe.mOutputs[f].stackSize; + } + } + } + + tOutputItems = removeNulls(tOutputItems); + + // Sanitize item stack size, splitting any stacks greater than max stack size + List splitStacks = new ArrayList(); + for (ItemStack tItem : tOutputItems) { + while (tItem.getMaxStackSize() < tItem.stackSize) { + ItemStack tmp = tItem.copy(); + tmp.stackSize = tmp.getMaxStackSize(); + tItem.stackSize = tItem.stackSize - tItem.getMaxStackSize(); + splitStacks.add(tmp); + } + } + + if (splitStacks.size() > 0) { + ItemStack[] tmp = new ItemStack[splitStacks.size()]; + tmp = splitStacks.toArray(tmp); + tOutputItems = ArrayUtils.addAll(tOutputItems, tmp); + } + + // Strip empty stacks + List tSList = new ArrayList(); + for (ItemStack tS : tOutputItems) { + if (tS.stackSize > 0) tSList.add(tS); + } + tOutputItems = tSList.toArray(new ItemStack[tSList.size()]); + + // Damage catalyst once all is said and done. + if (tCatalystRecipe != null) { + log("damaging catalyst"); + damageCatalyst(tCatalystRecipe, parallelRecipes); + } + + // Commit outputs + this.mOutputItems = tOutputItems; + this.mOutputFluids = tOutputFluids; + updateSlots(); + + // Play sounds (GT++ addition - GT multiblocks play no sounds) + startProcess(); + + log("GOOD RETURN - 1"); + return true; + } + + private int getCatalysts(ItemStack[] aItemInputs, ItemStack aRecipeCatalyst, int aMaxParrallel, ArrayList aOutPut) { + int allowedParrallel = 0; + for (final ItemStack aInput : aItemInputs) { + if (aRecipeCatalyst.isItemEqual(aInput)) { + int aDurabilityRemaining = getMaxCatalystDurability() - getDamage(aInput); + return Math.min(aMaxParrallel, aDurabilityRemaining); + } + } + return allowedParrallel; + } + + private ItemStack findCatalyst(ItemStack[] aItemInputs) { + if (aItemInputs != null) { + for (final ItemStack aInput : aItemInputs) { + if (aInput != null) { + if (ItemUtils.isCatalyst(aInput)) { + return aInput; + } + } + } + } + return null; + } + + + private void damageCatalyst(ItemStack aStack, int parallelRecipes) { + for (int i=0; i= getMaxCatalystDurability()) { + log("consume catalyst"); + addOutput(CI.getEmptyCatalyst(1)); + aStack = null; + } + else { + log("damaging catalyst"); + setDamage(aStack, damage); + } + } + else { + log("not consuming catalyst"); + } + } + + + + } + + private int getDamage(ItemStack aStack) { + return ItemGenericChemBase.getCatalystDamage(aStack); + } + + private void setDamage(ItemStack aStack,int aAmount) { + ItemGenericChemBase.setCatalystDamage(aStack, aAmount); + } + + + + @SideOnly(Side.CLIENT) + private final int getCasingTierOnClientSide() { + + if (this == null || this.getBaseMetaTileEntity().getWorld() == null) { + return 0; + } + try { + Block aInitStructureCheck; + int aInitStructureCheckMeta; + IGregTechTileEntity aBaseMetaTileEntity = this.getBaseMetaTileEntity(); + int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX * 3; + int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ * 3; + if (xDir == 0) { + aInitStructureCheck = aBaseMetaTileEntity.getBlockOffset(zDir, 1, 0); + aInitStructureCheckMeta = aBaseMetaTileEntity.getMetaIDOffset(zDir, 1, 0); + } + else { + aInitStructureCheck = aBaseMetaTileEntity.getBlockOffset(0, 1, xDir); + aInitStructureCheckMeta = aBaseMetaTileEntity.getMetaIDOffset(0, 1, xDir); + } + for (int aTier : mTieredBlockRegistry.keySet()) { + Triplet aData = mTieredBlockRegistry.get(aTier); + if (aData.getValue_1() == aInitStructureCheck && aData.getValue_2() == aInitStructureCheckMeta) { + return aTier; + } + } + return 0; + } + catch (Throwable t) { + t.printStackTrace(); + return 0; + } + + } + + + + /* + * Catalyst Handling + */ + + + + @Override + public ArrayList getStoredInputs() { + ArrayList tItems = super.getStoredInputs(); + for (GT_MetaTileEntity_Hatch_ElementalDataOrbHolder tHatch : mDataHolders) { + tHatch.mRecipeMap = getRecipeMap(); + if (isValidMetaTileEntity(tHatch)) { + ArrayList aTempList = new ArrayList(); + for (ItemStack s : tHatch.mInventory) { + aTempList.add(s); + } + tItems.addAll(aTempList); + } + } + return tItems; + } + + + + + +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/chemplant/GregtechMTE_ChemicalPlant.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/chemplant/GregtechMTE_ChemicalPlant.java index 4b1acf6494..4119a0df8c 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/chemplant/GregtechMTE_ChemicalPlant.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/chemplant/GregtechMTE_ChemicalPlant.java @@ -85,7 +85,6 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase { } private static int getCasingTextureIdForTier(int aTier) { if (!mTieredBlockRegistry.containsKey(aTier)) { - Logger.INFO("Couldn't find casing texture ID for tier "+aTier); return 10; } int aCasingID = mTieredBlockRegistry.get(aTier).getValue_3(); @@ -195,7 +194,7 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase { GT_MetaTileEntity_TieredMachineBlock aMachineBlock = (GT_MetaTileEntity_TieredMachineBlock) aMetaTileEntity; int aTileTier = aMachineBlock.mTier; if (aTileTier > aMaxTier) { - Logger.INFO("Hatch tier too high."); + log("Hatch tier too high."); return false; } else { @@ -203,7 +202,7 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase { } } else { - Logger.INFO("Bad Tile Entity being added to hatch map."); // Shouldn't ever happen, but.. ya know.. + log("Bad Tile Entity being added to hatch map."); // Shouldn't ever happen, but.. ya know.. return false; } } @@ -311,13 +310,13 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase { int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX * 3; int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ * 3; - Logger.INFO("Checking ChemPlant Structure"); + log("Checking ChemPlant Structure"); // Require Air above controller boolean aAirCheck = aBaseMetaTileEntity.getAirOffset(0, 1, 0); if (!aAirCheck) { - Logger.INFO("No Air Above Controller"); + log("No Air Above Controller"); return false; } else { @@ -326,7 +325,7 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase { mSolidCasingTier = getSolidCasingTierCheck(aBaseMetaTileEntity, xDir, zDir); mMachineCasingTier = getMachineCasingTierCheck(aBaseMetaTileEntity, xDir, zDir); - Logger.INFO("Initial Casing Check Complete, Solid Casing Tier: "+mSolidCasingTier+", Machine Casing Tier: "+mMachineCasingTier); + log("Initial Casing Check Complete, Solid Casing Tier: "+mSolidCasingTier+", Machine Casing Tier: "+mMachineCasingTier); int aSolidCasingCount = 0; int aMachineCasingCount = 0; @@ -338,14 +337,14 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase { aPipeCount = checkPipes(aBaseMetaTileEntity, aStack, xDir, zDir); aCoilCount = checkCoils(aBaseMetaTileEntity, aStack, xDir, zDir); - Logger.INFO("Casing Counts: "); - Logger.INFO("Solid: "+aSolidCasingCount+", Machine: "+aMachineCasingCount); - Logger.INFO("Pipe: "+aPipeCount+", Coil: "+aCoilCount); + log("Casing Counts: "); + log("Solid: "+aSolidCasingCount+", Machine: "+aMachineCasingCount); + log("Pipe: "+aPipeCount+", Coil: "+aCoilCount); - Logger.INFO("Casing Tiers: "); - Logger.INFO("Solid: "+getSolidCasingTier()+", Machine: "+getMachineCasingTier()); - Logger.INFO("Pipe: "+getPipeCasingTier()+", Coil: "+getCoilTier()); + log("Casing Tiers: "); + log("Solid: "+getSolidCasingTier()+", Machine: "+getMachineCasingTier()); + log("Pipe: "+getPipeCasingTier()+", Coil: "+getCoilTier()); // Attempt to sync fields here, so that it updates client side values. aBaseMetaTileEntity.getWorld().markBlockForUpdate(aBaseMetaTileEntity.getXCoord(), aBaseMetaTileEntity.getYCoord(), aBaseMetaTileEntity.getZCoord()); @@ -354,23 +353,23 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase { // Minimum 80/93 Solid Casings if (aSolidCasingCount < 80) { - Logger.INFO("Not enough solid casings. Found "+aSolidCasingCount+", require: 80."); + log("Not enough solid casings. Found "+aSolidCasingCount+", require: 80."); return false; } if (aMachineCasingCount != 57) { - Logger.INFO("Not enough machine casings. Found "+aMachineCasingCount+", require: 57."); + log("Not enough machine casings. Found "+aMachineCasingCount+", require: 57."); return false; } if (aPipeCount != 18) { - Logger.INFO("Not enough pipe casings. Found "+aPipeCount+", require: 18."); + log("Not enough pipe casings. Found "+aPipeCount+", require: 18."); return false; } if (aCoilCount != 27) { - Logger.INFO("Not enough coils. Found "+aCoilCount+", require: 27."); + log("Not enough coils. Found "+aCoilCount+", require: 27."); return false; } - Logger.INFO("Structure Check Complete!"); + log("Structure Check Complete!"); return true; } @@ -490,7 +489,7 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase { else { final IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); if (aMetaTileEntity == null) { - Logger.INFO("Error counting Bottom Layer Casing Ring. Bad Tile Entity. Found "+aTileEntity.getInventoryName()); + log("Error counting Bottom Layer Casing Ring. Bad Tile Entity. Found "+aTileEntity.getInventoryName()); return tAmount; } //Handle controller @@ -498,7 +497,7 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase { continue; } else { - Logger.INFO("Error counting Bottom Layer Casing Ring. Bad Tile Entity. Found "+aMetaTileEntity.getInventoryName()); + log("Error counting Bottom Layer Casing Ring. Bad Tile Entity. Found "+aMetaTileEntity.getInventoryName()); return tAmount; } } @@ -508,7 +507,7 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase { tAmount++; } else { - Logger.INFO("Error counting Bottom Layer Casing Ring. Found "+aBlock.getLocalizedName()+":"+aMeta); + log("Error counting Bottom Layer Casing Ring. Found "+aBlock.getLocalizedName()+":"+aMeta); return tAmount; } } @@ -544,7 +543,7 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase { tAmount++; } else { - Logger.INFO("Error counting Pillars. Found "+ItemUtils.getLocalizedNameOfBlock(aBlock, aMeta)); + log("Error counting Pillars. Found "+ItemUtils.getLocalizedNameOfBlock(aBlock, aMeta)); return tAmount; } } @@ -560,7 +559,7 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase { tAmount++; } else { - Logger.INFO("Error counting Top Layer casings. Found "+ItemUtils.getLocalizedNameOfBlock(aBlock, aMeta)); + log("Error counting Top Layer casings. Found "+ItemUtils.getLocalizedNameOfBlock(aBlock, aMeta)); return tAmount; } } @@ -652,7 +651,7 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase { public int getMachineCasingTierCheck(IGregTechTileEntity aBaseMetaTileEntity, int xDir, int zDir) { Block aInitStructureCheck; int aInitStructureCheckMeta; - Logger.INFO(""+xDir+", "+zDir); + log(""+xDir+", "+zDir); if (xDir == 0) { if (zDir > 0) { aInitStructureCheck = aBaseMetaTileEntity.getBlockOffset(0, 0, 1); @@ -674,7 +673,7 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase { } } if (isBlockMachineCasing(aInitStructureCheck, aInitStructureCheckMeta)) { - Logger.INFO("Using Meta "+aInitStructureCheckMeta); + log("Using Meta "+aInitStructureCheckMeta); return aInitStructureCheckMeta; } return 0; diff --git a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialElementDuplicator.java b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialElementDuplicator.java new file mode 100644 index 0000000000..5fa9ebdace --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialElementDuplicator.java @@ -0,0 +1,20 @@ +package gtPlusPlus.xmod.gregtech.registration.gregtech; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_ElementalDataOrbHolder; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Steam_BusInput; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.GregtechMTE_ElementalDuplicator; + +public class GregtechIndustrialElementDuplicator { + + public static void run(){ + + Logger.INFO("Gregtech5u Content | Registering Elemental Duplicator Multiblock."); + + GregtechItemList.Controller_ElementalDuplicator.set(new GregtechMTE_ElementalDuplicator(31050, "gtpp.multimachine.replicator", "Elemental Duplicator").getStackForm(1L)); + GregtechItemList.Hatch_Input_Elemental_Duplicator.set(new GT_MetaTileEntity_Hatch_ElementalDataOrbHolder(31051, "hatch.input_bus.elementalorbholder", "Elemental Data Orb Storage", 7).getStackForm(1L)); + + } + +} diff --git a/src/resources/assets/miscutils/textures/blocks/metro/TEXTURE_TECH_PANEL_D.png b/src/resources/assets/miscutils/textures/blocks/metro/TEXTURE_TECH_PANEL_D.png new file mode 100644 index 0000000000..0cf3f40762 Binary files /dev/null and b/src/resources/assets/miscutils/textures/blocks/metro/TEXTURE_TECH_PANEL_D.png differ -- cgit From 0aa283261421d95ae2370d25ba8a2ac318368afc Mon Sep 17 00:00:00 2001 From: Alkalus Date: Thu, 5 Nov 2020 02:11:29 +0000 Subject: + Added RTG power Hatch. + Added better handler for packager recipes. % Moved RTG fuel pellet recipe handling to it's own function. $ Fixed minor oversight in ItemStackData. $ Fixed TC Alchemical Furnace being a laggy PoS. $ Maybe fixed TC Aspect scanner on items with invalid unlocal names. --- build.properties | 2 +- .../api/helpers/GregtechPlusPlus_API.java | 10 + .../api/objects/minecraft/ItemStackData.java | 4 +- .../api/objects/minecraft/ThaumcraftDataStack.java | 71 +++ .../objects/minecraft/ThaumcraftItemStackData.java | 57 +++ .../objects/minecraft/ThaumcraftSmeltingCache.java | 39 ++ .../gtPlusPlus/core/recipe/RECIPES_GREGTECH.java | 6 + .../core/util/minecraft/InventoryUtils.java | 26 ++ .../gtPlusPlus/core/util/minecraft/ItemUtils.java | 15 +- .../preloader/asm/ClassesToTransform.java | 4 +- .../preloader/asm/helpers/MethodHelper_TC.java | 272 ++++++++--- .../ClassTransformer_GT_EnergyHatchPatch.java | 317 +++++++++++++ .../ClassTransformer_TC_AlchemicalFurnace.java | 513 +++++++++++++++++++++ ...ssTransformer_TC_ThaumcraftCraftingManager.java | 60 ++- .../Preloader_Transformer_Handler.java | 9 + .../xmod/gregtech/api/enums/GregtechItemList.java | 6 +- .../interfaces/internal/IGregtech_RecipeAdder.java | 5 +- .../GT_MetaTileEntity_Hatch_Energy_RTG.java | 282 +++++++++++ .../common/blocks/textures/TexturesGtBlock.java | 10 +- .../common/items/MetaGeneratedGregtechItems.java | 47 +- .../machines/multi/misc/GMTE_AmazonPackager.java | 7 +- .../xmod/gregtech/recipes/GregtechRecipeAdder.java | 64 ++- .../gregtech/GregtechCustomHatches.java | 127 ++--- .../thaumcraft/objects/ThreadAspectScanner.java | 2 +- .../blocks/iconsets/OVERLAY_ENERGY_RTG_OFF.png | Bin 0 -> 353 bytes .../blocks/iconsets/OVERLAY_ENERGY_RTG_ON.png | Bin 0 -> 377 bytes 26 files changed, 1754 insertions(+), 201 deletions(-) create mode 100644 src/Java/gtPlusPlus/api/objects/minecraft/ThaumcraftDataStack.java create mode 100644 src/Java/gtPlusPlus/api/objects/minecraft/ThaumcraftItemStackData.java create mode 100644 src/Java/gtPlusPlus/api/objects/minecraft/ThaumcraftSmeltingCache.java create mode 100644 src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_EnergyHatchPatch.java create mode 100644 src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_TC_AlchemicalFurnace.java create mode 100644 src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Energy_RTG.java create mode 100644 src/resources/assets/miscutils/textures/blocks/iconsets/OVERLAY_ENERGY_RTG_OFF.png create mode 100644 src/resources/assets/miscutils/textures/blocks/iconsets/OVERLAY_ENERGY_RTG_ON.png (limited to 'src/Java/gtPlusPlus/xmod/gregtech/common/blocks') diff --git a/build.properties b/build.properties index 1ecc02e148..d1371791b8 100644 --- a/build.properties +++ b/build.properties @@ -1,6 +1,6 @@ minecraft.version=1.7.10 forge.version=10.13.4.1614-1.7.10 -ic2.version=2.2.790-experimental +ic2.version=2.2.817-experimental gt.version=5.09.31 gtpp.version=1.7.05 diff --git a/src/Java/gtPlusPlus/api/helpers/GregtechPlusPlus_API.java b/src/Java/gtPlusPlus/api/helpers/GregtechPlusPlus_API.java index fb1258f6d2..6fe4209efe 100644 --- a/src/Java/gtPlusPlus/api/helpers/GregtechPlusPlus_API.java +++ b/src/Java/gtPlusPlus/api/helpers/GregtechPlusPlus_API.java @@ -6,6 +6,7 @@ import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.WeightedCollection; import gtPlusPlus.api.objects.minecraft.multi.SpecialMultiBehaviour; import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy_RTG; import gtPlusPlus.xmod.gregtech.api.util.SpecialBehaviourTooltipHandler; import net.minecraft.block.Block; import net.minecraft.item.ItemStack; @@ -36,6 +37,15 @@ public class GregtechPlusPlus_API { return mSpecialBehaviourItemMap; } + /** + * Allows RTG Fuel pellets from other mods to be used in the RTG hatch. + * @param aStack - The Pellet Stack, sanitsed after passing through. + * @param aFuelValue - The Fuel Value of the Pellet to be added to the energy storage. + * @return - Did register? + */ + public static boolean registerPelletForRtgHatch(ItemStack aStack, long aFuelValue) { + return GT_MetaTileEntity_Hatch_Energy_RTG.registerPelletForHatch(aStack, aFuelValue); + } } diff --git a/src/Java/gtPlusPlus/api/objects/minecraft/ItemStackData.java b/src/Java/gtPlusPlus/api/objects/minecraft/ItemStackData.java index 4fb6b9d8a7..476926826b 100644 --- a/src/Java/gtPlusPlus/api/objects/minecraft/ItemStackData.java +++ b/src/Java/gtPlusPlus/api/objects/minecraft/ItemStackData.java @@ -27,7 +27,9 @@ public class ItemStackData { } public ItemStack getStack() { - return ItemUtils.simpleMetaStack(mItem, mDamage, mStackSize); + ItemStack aTemp = ItemUtils.simpleMetaStack(mItem, mDamage, mStackSize); + aTemp.setTagCompound(mNBT); + return aTemp; } } diff --git a/src/Java/gtPlusPlus/api/objects/minecraft/ThaumcraftDataStack.java b/src/Java/gtPlusPlus/api/objects/minecraft/ThaumcraftDataStack.java new file mode 100644 index 0000000000..947b0a97b4 --- /dev/null +++ b/src/Java/gtPlusPlus/api/objects/minecraft/ThaumcraftDataStack.java @@ -0,0 +1,71 @@ +package gtPlusPlus.api.objects.minecraft; + +import java.util.Iterator; +import java.util.Stack; + +import net.minecraft.item.ItemStack; +import thaumcraft.api.aspects.AspectList; + +public class ThaumcraftDataStack extends Stack { + + private final int mStackSize; + + public ThaumcraftDataStack() { + this(Integer.MAX_VALUE); + } + + public ThaumcraftDataStack(int aMaxSize) { + mStackSize = aMaxSize; + } + + public boolean containsItemStack(ItemStack aStack, boolean aAddItemStackIfMissingFromStack) { + return getItemStackIndex(aStack) != -1; + } + + private int getItemStackIndex(ItemStack aStack) { + if (this.empty() || aStack == null) { + return -1; + } + Iterator iterator = this.iterator(); + int aIndex = 0; + while(iterator.hasNext()){ + ThaumcraftItemStackData value = iterator.next(); + if (value.doesItemStackDataMatch(aStack)) { + //int index = this.search(value); + return aIndex; + } + aIndex++; + } + return -1; + } + + public AspectList getAspectsForStack(ItemStack aStack) { + if (aStack != null) { + int aIndex = getItemStackIndex(aStack); + if (!this.empty()) { + if (aIndex != -1) { + ThaumcraftItemStackData aValue = this.elementAt(aIndex); + if (aValue != null) { + return aValue.getAspectList(); + } + } + } + if (this.empty() || aIndex == -1) { + ThaumcraftItemStackData aTemp = new ThaumcraftItemStackData(aStack); + this.push(aTemp); + return aTemp.getAspectList(); + } + } + return new AspectList(); + } + + @Override + public ThaumcraftItemStackData push(ThaumcraftItemStackData item) { + if (this.size() >= this.mStackSize) { + this.pop(); + } + return super.push(item); + } + + +} diff --git a/src/Java/gtPlusPlus/api/objects/minecraft/ThaumcraftItemStackData.java b/src/Java/gtPlusPlus/api/objects/minecraft/ThaumcraftItemStackData.java new file mode 100644 index 0000000000..1e9ea49dbf --- /dev/null +++ b/src/Java/gtPlusPlus/api/objects/minecraft/ThaumcraftItemStackData.java @@ -0,0 +1,57 @@ +package gtPlusPlus.api.objects.minecraft; + +import gtPlusPlus.core.util.minecraft.ItemUtils; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import thaumcraft.api.aspects.AspectList; +import thaumcraft.common.lib.crafting.ThaumcraftCraftingManager; + +public class ThaumcraftItemStackData { + + protected final Item mItem; + protected final int mDamage; + protected final int mStackSize; + protected final NBTTagCompound mNBT; + protected final String mUniqueDataTag; + private final AspectList mAspectList; + + public ThaumcraftItemStackData (ItemStack aStack) { + mItem = aStack.getItem(); + mDamage = aStack.getItemDamage(); + mStackSize = aStack.stackSize; + mNBT = (aStack.getTagCompound() != null ? aStack.getTagCompound() : new NBTTagCompound()); + mUniqueDataTag = ""+Item.getIdFromItem(mItem)+""+mDamage+""+mNBT.getId(); + mAspectList = ThaumcraftCraftingManager.getObjectTags(aStack); + } + + public String getUniqueDataIdentifier() { + return this.mUniqueDataTag; + } + + public ItemStack getStack() { + ItemStack aTemp = ItemUtils.simpleMetaStack(mItem, mDamage, mStackSize); + aTemp.setTagCompound(mNBT); + return aTemp; + } + + public AspectList getAspectList() { + return mAspectList; + } + + public boolean doesItemStackDataMatch(ItemStack aStack) { + if (aStack == null) { + return false; + } + Item aItem = aStack.getItem(); + int aMeta = aStack.getItemDamage(); + if (aItem != null) { + if (aItem == mItem && aMeta == mDamage) { + return true; + } + } + return false; + } + + +} diff --git a/src/Java/gtPlusPlus/api/objects/minecraft/ThaumcraftSmeltingCache.java b/src/Java/gtPlusPlus/api/objects/minecraft/ThaumcraftSmeltingCache.java new file mode 100644 index 0000000000..1e16527065 --- /dev/null +++ b/src/Java/gtPlusPlus/api/objects/minecraft/ThaumcraftSmeltingCache.java @@ -0,0 +1,39 @@ +package gtPlusPlus.api.objects.minecraft; + +import java.util.HashMap; + +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +public class ThaumcraftSmeltingCache { + + HashMap mInternalCache = new HashMap(); + + public void addItemToCache(ItemStack aStack, Boolean aSmelting) { + String aKey = getUniqueKey(aStack); + mInternalCache.put(aKey, aSmelting); + } + + public int canSmelt(ItemStack aStack) { + String aKey = getUniqueKey(aStack); + Boolean aCanSmeltValue = mInternalCache.get(aKey); + if (aCanSmeltValue != null) { + if (aCanSmeltValue) { + return 1; + } + else { + return 0; + } + } + return -1; + } + + public static final String getUniqueKey(ItemStack aStack) { + Item aItem = aStack.getItem(); + int aDamage = aStack.getItemDamage(); + NBTTagCompound aNBT = (aStack.getTagCompound() != null ? aStack.getTagCompound() : new NBTTagCompound()); + return ""+Item.getIdFromItem(aItem)+""+aDamage+""+aNBT.getId(); + } + +} diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java index 633c710461..34142d0390 100644 --- a/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java @@ -93,6 +93,7 @@ public class RECIPES_GREGTECH { vacuumFreezerRecipes(); fluidheaterRecipes(); chemplantRecipes(); + packagerRecipes(); /** @@ -111,6 +112,11 @@ public class RECIPES_GREGTECH { + private static void packagerRecipes() { + + + } + private static void chemplantRecipes() { //This is subsequently absorbed in water to form nitric acid and nitric oxide. diff --git a/src/Java/gtPlusPlus/core/util/minecraft/InventoryUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/InventoryUtils.java index aaa81a0057..fe67c88d69 100644 --- a/src/Java/gtPlusPlus/core/util/minecraft/InventoryUtils.java +++ b/src/Java/gtPlusPlus/core/util/minecraft/InventoryUtils.java @@ -2,6 +2,11 @@ package gtPlusPlus.core.util.minecraft; import java.util.Random; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy_RTG; import net.minecraft.block.Block; import net.minecraft.entity.item.EntityItem; import net.minecraft.inventory.IInventory; @@ -58,5 +63,26 @@ public class InventoryUtils { } } + + public static void sortInventoryItems(MetaTileEntity aTile) { + sortInventoryItems(aTile.getBaseMetaTileEntity()); + } + + public static void sortInventoryItems(IGregTechTileEntity aBaseMetaTileEntity) { + IInventory mInv = aBaseMetaTileEntity.getIInventory(aBaseMetaTileEntity.getXCoord(), aBaseMetaTileEntity.getYCoord(), aBaseMetaTileEntity.getZCoord()); + AutoMap aInvContents = new AutoMap(); + int aSize = mInv.getSizeInventory(); + for (int slot=0; slot history) { - int tmeta = meta; - if (item == null) { - return null; - } - //Preloader_Logger.INFO("Generating aspect tags for "+item.getUnlocalizedName()+":"+meta); - try { - tmeta = ((new ItemStack(item, 1, meta).getItem().isDamageable() || !new ItemStack(item, 1, meta).getItem().getHasSubtypes()) ? 32767 : meta); - } - catch (Exception ex) {} - //Preloader_Logger.INFO("Set Meta to "+tmeta); - if (ThaumcraftApi.exists(item, tmeta)) { - return ThaumcraftCraftingManager.getObjectTags(new ItemStack(item, 1, tmeta)); - } - if (history.contains(Arrays.asList(item, tmeta))) { - return null; - } - history.add(Arrays.asList(item, tmeta)); - if (history.size() < 100) { - AspectList ret = generateTagsFromRecipes(item, (tmeta == 32767) ? 0 : meta, history); - ret = capAspects(ret, 64); - ThaumcraftApi.registerObjectTag(new ItemStack(item, 1, tmeta), ret); - return ret; - } - return null; - } - - private static AspectList capAspects(final AspectList sourcetags, final int amount) { - if (sourcetags == null) { - return sourcetags; - } - final AspectList out = new AspectList(); - for (final Aspect aspect : sourcetags.getAspects()) { - out.merge(aspect, Math.min(amount, sourcetags.getAmount(aspect))); - } - return out; - } - - private static AspectList generateTagsFromRecipes(final Item item, final int meta, final ArrayList history) { - AspectList ret = null; - ret = generateTagsFromCrucibleRecipes(item, meta, history); - if (ret != null) { - return ret; - } - ret = generateTagsFromArcaneRecipes(item, meta, history); - if (ret != null) { - return ret; - } - ret = generateTagsFromInfusionRecipes(item, meta, history); - if (ret != null) { - return ret; - } - ret = generateTagsFromCraftingRecipes(item, meta, history); - return ret; - } - - private static boolean isClassSet() { - if (mThaumcraftCraftingManager == null) { - mThaumcraftCraftingManager = ReflectionUtils.getClass("thaumcraft.common.lib.crafting.ThaumcraftCraftingManager"); - } - return true; - } - - private static Method mGetTagsFromCraftingRecipes; - private static Method mGetTagsFromInfusionRecipes; - private static Method mGetTagsFromArcaneRecipes; - private static Method mGetTagsFromCrucibleRecipes; - + public static AspectList generateTags(Item item, int meta) { + AspectList temp = generateTags(item, meta, new ArrayList()); + return temp; + } + + public static AspectList generateTags(final Item item, final int meta, final ArrayList history) { + int tmeta = meta; + if (item == null) { + return null; + } + //Preloader_Logger.INFO("Generating aspect tags for "+item.getUnlocalizedName()+":"+meta); + try { + tmeta = ((new ItemStack(item, 1, meta).getItem().isDamageable() || !new ItemStack(item, 1, meta).getItem().getHasSubtypes()) ? 32767 : meta); + } + catch (Exception ex) {} + //Preloader_Logger.INFO("Set Meta to "+tmeta); + if (ThaumcraftApi.exists(item, tmeta)) { + return ThaumcraftCraftingManager.getObjectTags(new ItemStack(item, 1, tmeta)); + } + if (history.contains(Arrays.asList(item, tmeta))) { + return null; + } + history.add(Arrays.asList(item, tmeta)); + if (history.size() < 100) { + AspectList ret = generateTagsFromRecipes(item, (tmeta == 32767) ? 0 : meta, history); + ret = capAspects(ret, 64); + ThaumcraftApi.registerObjectTag(new ItemStack(item, 1, tmeta), ret); + return ret; + } + return null; + } + + private static AspectList capAspects(final AspectList sourcetags, final int amount) { + if (sourcetags == null) { + return sourcetags; + } + final AspectList out = new AspectList(); + for (final Aspect aspect : sourcetags.getAspects()) { + out.merge(aspect, Math.min(amount, sourcetags.getAmount(aspect))); + } + return out; + } + + private static AspectList generateTagsFromRecipes(final Item item, final int meta, final ArrayList history) { + AspectList ret = null; + ret = generateTagsFromCrucibleRecipes(item, meta, history); + if (ret != null) { + return ret; + } + ret = generateTagsFromArcaneRecipes(item, meta, history); + if (ret != null) { + return ret; + } + ret = generateTagsFromInfusionRecipes(item, meta, history); + if (ret != null) { + return ret; + } + ret = generateTagsFromCraftingRecipes(item, meta, history); + return ret; + } + + private static boolean isClassSet() { + if (mThaumcraftCraftingManager == null) { + mThaumcraftCraftingManager = ReflectionUtils.getClass("thaumcraft.common.lib.crafting.ThaumcraftCraftingManager"); + } + return true; + } + + private static Method mGetTagsFromCraftingRecipes; + private static Method mGetTagsFromInfusionRecipes; + private static Method mGetTagsFromArcaneRecipes; + private static Method mGetTagsFromCrucibleRecipes; + private static AspectList generateTagsFromCraftingRecipes(Item item, int meta, ArrayList history) { isClassSet(); if (mGetTagsFromCraftingRecipes == null) { @@ -116,5 +126,127 @@ public class MethodHelper_TC { } return (AspectList) ReflectionUtils.invokeNonBool(null, mGetTagsFromCrucibleRecipes, new Object[] {item, meta, history}); } - + + + + /* + * Let's improve the TC lookup for aspects, cause the default implementation is shit. + */ + + + public static AspectList getObjectTags(ItemStack itemstack) { + Item item; + int meta; + try { + item = itemstack.getItem(); + meta = itemstack.getItemDamage(); + } catch (Exception var8) { + return null; + } + + AspectList tmp = (AspectList)ThaumcraftApi.objectTags.get(Arrays.asList(new Object[]{item, Integer.valueOf(meta)})); + if(tmp == null) { + for(List l : ThaumcraftApi.objectTags.keySet()) { + if((Item)l.get(0) == item && l.get(1) instanceof int[]) { + int[] range = (int[])((int[])l.get(1)); + Arrays.sort(range); + if(Arrays.binarySearch(range, meta) >= 0) { + tmp = (AspectList)ThaumcraftApi.objectTags.get(Arrays.asList(new Object[]{item, range})); + return tmp; + } + } + } + + tmp = (AspectList)ThaumcraftApi.objectTags.get(Arrays.asList(new Object[]{item, Integer.valueOf(32767)})); + if(tmp == null && tmp == null) { + if(meta == 32767 && tmp == null) { + int index = 0; + + while(true) { + tmp = (AspectList)ThaumcraftApi.objectTags.get(Arrays.asList(new Object[]{item, Integer.valueOf(index)})); + ++index; + if(index >= 16 || tmp != null) { + break; + } + } + } + + if(tmp == null) { + tmp = generateTags(item, meta); + } + } + } + + if(itemstack.getItem() instanceof ItemWandCasting) { + ItemWandCasting wand = (ItemWandCasting)itemstack.getItem(); + if(tmp == null) { + tmp = new AspectList(); + } + + tmp.merge(Aspect.MAGIC, (wand.getRod(itemstack).getCraftCost() + wand.getCap(itemstack).getCraftCost()) / 2); + tmp.merge(Aspect.TOOL, (wand.getRod(itemstack).getCraftCost() + wand.getCap(itemstack).getCraftCost()) / 3); + } + + if(item != null && item == Items.potionitem) { + if(tmp == null) { + tmp = new AspectList(); + } + + tmp.merge(Aspect.WATER, 1); + ItemPotion ip = (ItemPotion)item; + List effects = ip.getEffects(itemstack.getItemDamage()); + if(effects != null) { + if(ItemPotion.isSplash(itemstack.getItemDamage())) { + tmp.merge(Aspect.ENTROPY, 2); + } + + for(PotionEffect var6 : effects) { + tmp.merge(Aspect.MAGIC, (var6.getAmplifier() + 1) * 2); + if(var6.getPotionID() == Potion.blindness.id) { + tmp.merge(Aspect.DARKNESS, (var6.getAmplifier() + 1) * 3); + } else if(var6.getPotionID() == Potion.confusion.id) { + tmp.merge(Aspect.ELDRITCH, (var6.getAmplifier() + 1) * 3); + } else if(var6.getPotionID() == Potion.damageBoost.id) { + tmp.merge(Aspect.WEAPON, (var6.getAmplifier() + 1) * 3); + } else if(var6.getPotionID() == Potion.digSlowdown.id) { + tmp.merge(Aspect.TRAP, (var6.getAmplifier() + 1) * 3); + } else if(var6.getPotionID() == Potion.digSpeed.id) { + tmp.merge(Aspect.TOOL, (var6.getAmplifier() + 1) * 3); + } else if(var6.getPotionID() == Potion.fireResistance.id) { + tmp.merge(Aspect.ARMOR, var6.getAmplifier() + 1); + tmp.merge(Aspect.FIRE, (var6.getAmplifier() + 1) * 2); + } else if(var6.getPotionID() == Potion.harm.id) { + tmp.merge(Aspect.DEATH, (var6.getAmplifier() + 1) * 3); + } else if(var6.getPotionID() == Potion.heal.id) { + tmp.merge(Aspect.HEAL, (var6.getAmplifier() + 1) * 3); + } else if(var6.getPotionID() == Potion.hunger.id) { + tmp.merge(Aspect.DEATH, (var6.getAmplifier() + 1) * 3); + } else if(var6.getPotionID() == Potion.invisibility.id) { + tmp.merge(Aspect.SENSES, (var6.getAmplifier() + 1) * 3); + } else if(var6.getPotionID() == Potion.jump.id) { + tmp.merge(Aspect.FLIGHT, (var6.getAmplifier() + 1) * 3); + } else if(var6.getPotionID() == Potion.moveSlowdown.id) { + tmp.merge(Aspect.TRAP, (var6.getAmplifier() + 1) * 3); + } else if(var6.getPotionID() == Potion.moveSpeed.id) { + tmp.merge(Aspect.MOTION, (var6.getAmplifier() + 1) * 3); + } else if(var6.getPotionID() == Potion.nightVision.id) { + tmp.merge(Aspect.SENSES, (var6.getAmplifier() + 1) * 3); + } else if(var6.getPotionID() == Potion.poison.id) { + tmp.merge(Aspect.POISON, (var6.getAmplifier() + 1) * 3); + } else if(var6.getPotionID() == Potion.regeneration.id) { + tmp.merge(Aspect.HEAL, (var6.getAmplifier() + 1) * 3); + } else if(var6.getPotionID() == Potion.resistance.id) { + tmp.merge(Aspect.ARMOR, (var6.getAmplifier() + 1) * 3); + } else if(var6.getPotionID() == Potion.waterBreathing.id) { + tmp.merge(Aspect.AIR, (var6.getAmplifier() + 1) * 3); + } else if(var6.getPotionID() == Potion.weakness.id) { + tmp.merge(Aspect.DEATH, (var6.getAmplifier() + 1) * 3); + } + } + } + } + + return capAspects(tmp, 64); + } + } diff --git a/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_EnergyHatchPatch.java b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_EnergyHatchPatch.java new file mode 100644 index 0000000000..83560eb6c3 --- /dev/null +++ b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_EnergyHatchPatch.java @@ -0,0 +1,317 @@ +package gtPlusPlus.preloader.asm.transformers; + +import static org.objectweb.asm.Opcodes.*; + +import org.apache.logging.log4j.Level; +import org.objectweb.asm.*; + +import cpw.mods.fml.relauncher.FMLRelaunchLog; +import gtPlusPlus.preloader.asm.ClassesToTransform; + +public class ClassTransformer_GT_EnergyHatchPatch { + + private static final String aRtgInputFormatted = ClassesToTransform.GTPP_MTE_HATCH_RTG.replace(".", "/"); + private static final String aEnergyFormatted = ClassesToTransform.GT_MTE_HATCH_ENERGY.replace(".", "/"); + + private final boolean isValid; + private final ClassReader reader; + private final ClassWriter writer; + + + public ClassTransformer_GT_EnergyHatchPatch(byte[] basicClass, String aClassName) { + ClassReader aTempReader = null; + ClassWriter aTempWriter = null; + + FMLRelaunchLog.log("[GT++ ASM] Gregtech Energy Hatch Patch", Level.INFO, "Attempting to add slots capabilities to GT Energy Hatches."); + FMLRelaunchLog.log("[GT++ ASM] Gregtech Energy Hatch Patch", Level.INFO, "Patching "+aClassName+"."); + + aTempReader = new ClassReader(basicClass); + aTempWriter = new ClassWriter(aTempReader, ClassWriter.COMPUTE_FRAMES); + aTempReader.accept(new localClassVisitor(aTempWriter, aClassName), 0); + + if (aTempReader != null && aTempWriter != null) { + isValid = true; + } + else { + isValid = false; + } + FMLRelaunchLog.log("[GT++ ASM] Gregtech Energy Hatch Patch", Level.INFO, "Valid patch? "+isValid+"."); + reader = aTempReader; + writer = aTempWriter; + + + if (reader != null && writer != null) { + FMLRelaunchLog.log("[GT++ ASM] Gregtech Energy Hatch Patch", Level.INFO, "Attempting Method Injection."); + injectMethod(aClassName); + } + + } + + public boolean isValidTransformer() { + return isValid; + } + + public ClassReader getReader() { + return reader; + } + + public ClassWriter getWriter() { + return writer; + } + + + public boolean injectMethod(String aClassName) { + + boolean didInject = false; + MethodVisitor mv; + ClassWriter cw = getWriter(); + int aConID = 1; + + //GT_MetaTileEntity_Hatch_Energy + //Constructor + if (aClassName.equals(ClassesToTransform.GT_MTE_HATCH_ENERGY)){ + + + //Constructor 1 + { + mv = cw.visitMethod(ACC_PUBLIC, "", "(ILjava/lang/String;Ljava/lang/String;II[Ljava/lang/String;)V", null, null); + mv.visitCode(); + Label l0 = new Label(); + mv.visitLabel(l0); + mv.visitLineNumber(26, l0); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ILOAD, 1); + mv.visitVarInsn(ALOAD, 2); + mv.visitVarInsn(ALOAD, 3); + mv.visitVarInsn(ILOAD, 4); + mv.visitVarInsn(ILOAD, 5); + mv.visitVarInsn(ALOAD, 6); + mv.visitInsn(ICONST_0); + mv.visitTypeInsn(ANEWARRAY, "gregtech/api/interfaces/ITexture"); + mv.visitMethodInsn(INVOKESPECIAL, "gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch", "", "(ILjava/lang/String;Ljava/lang/String;II[Ljava/lang/String;[Lgregtech/api/interfaces/ITexture;)V", false); + Label l1 = new Label(); + mv.visitLabel(l1); + mv.visitLineNumber(27, l1); + mv.visitInsn(RETURN); + Label l2 = new Label(); + mv.visitLabel(l2); + mv.visitLocalVariable("this", "Lgregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Energy;", null, l0, l2, 0); + mv.visitLocalVariable("aID", "I", null, l0, l2, 1); + mv.visitLocalVariable("aName", "Ljava/lang/String;", null, l0, l2, 2); + mv.visitLocalVariable("aNameRegional", "Ljava/lang/String;", null, l0, l2, 3); + mv.visitLocalVariable("aTier", "I", null, l0, l2, 4); + mv.visitLocalVariable("aSlots", "I", null, l0, l2, 5); + mv.visitLocalVariable("aDesc", "[Ljava/lang/String;", null, l0, l2, 6); + mv.visitMaxs(8, 7); + mv.visitEnd(); + FMLRelaunchLog.log("[GT++ ASM] Gregtech Energy Hatch Patch", Level.INFO, "Injection new constructor "+(aConID++)); + } + + //Constructor 2 + { + mv = cw.visitMethod(ACC_PUBLIC, "", "(Ljava/lang/String;IILjava/lang/String;[[[Lgregtech/api/interfaces/ITexture;)V", null, null); + mv.visitCode(); + Label l0 = new Label(); + mv.visitLabel(l0); + mv.visitLineNumber(30, l0); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 1); + mv.visitVarInsn(ILOAD, 2); + mv.visitVarInsn(ILOAD, 3); + mv.visitVarInsn(ALOAD, 4); + mv.visitVarInsn(ALOAD, 5); + mv.visitMethodInsn(INVOKESPECIAL, "gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch", "", "(Ljava/lang/String;IILjava/lang/String;[[[Lgregtech/api/interfaces/ITexture;)V", false); + Label l1 = new Label(); + mv.visitLabel(l1); + mv.visitLineNumber(31, l1); + mv.visitInsn(RETURN); + Label l2 = new Label(); + mv.visitLabel(l2); + mv.visitLocalVariable("this", "Lgregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Energy;", null, l0, l2, 0); + mv.visitLocalVariable("aName", "Ljava/lang/String;", null, l0, l2, 1); + mv.visitLocalVariable("aTier", "I", null, l0, l2, 2); + mv.visitLocalVariable("aSlots", "I", null, l0, l2, 3); + mv.visitLocalVariable("aDescription", "Ljava/lang/String;", null, l0, l2, 4); + mv.visitLocalVariable("aTextures", "[[[Lgregtech/api/interfaces/ITexture;", null, l0, l2, 5); + mv.visitMaxs(6, 6); + mv.visitEnd(); + FMLRelaunchLog.log("[GT++ ASM] Gregtech Energy Hatch Patch", Level.INFO, "Injection new constructor "+(aConID++)); + } + + //Third constructor with String[] for GT 5.09 + { + mv = cw.visitMethod(ACC_PUBLIC, "", "(Ljava/lang/String;II[Ljava/lang/String;[[[Lgregtech/api/interfaces/ITexture;)V", null, null); + mv.visitCode(); + Label l0 = new Label(); + mv.visitLabel(l0); + mv.visitLineNumber(34, l0); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 1); + mv.visitVarInsn(ILOAD, 2); + mv.visitVarInsn(ILOAD, 3); + mv.visitVarInsn(ALOAD, 4); + mv.visitVarInsn(ALOAD, 5); + mv.visitMethodInsn(INVOKESPECIAL, "gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch", "", "(Ljava/lang/String;II[Ljava/lang/String;[[[Lgregtech/api/interfaces/ITexture;)V", false); + Label l1 = new Label(); + mv.visitLabel(l1); + mv.visitLineNumber(35, l1); + mv.visitInsn(RETURN); + Label l2 = new Label(); + mv.visitLabel(l2); + mv.visitLocalVariable("this", "Lgregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Energy;", null, l0, l2, 0); + mv.visitLocalVariable("aName", "Ljava/lang/String;", null, l0, l2, 1); + mv.visitLocalVariable("aTier", "I", null, l0, l2, 2); + mv.visitLocalVariable("aSlots", "I", null, l0, l2, 3); + mv.visitLocalVariable("aDescription", "[Ljava/lang/String;", null, l0, l2, 4); + mv.visitLocalVariable("aTextures", "[[[Lgregtech/api/interfaces/ITexture;", null, l0, l2, 5); + mv.visitMaxs(6, 6); + mv.visitEnd(); + FMLRelaunchLog.log("[GT++ ASM] Gregtech Energy Hatch Patch", Level.INFO, "Injection new constructor "+(aConID++)); + } + didInject = true; + } + + //GT_MetaTileEntity_Hatch_Energy_RTG + //Constructor + if (aClassName.equals(ClassesToTransform.GTPP_MTE_HATCH_RTG)){ + + { + mv = cw.visitMethod(ACC_PUBLIC, "", "(ILjava/lang/String;Ljava/lang/String;II)V", null, null); + mv.visitCode(); + Label l0 = new Label(); + mv.visitLabel(l0); + mv.visitLineNumber(38, l0); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ILOAD, 1); + mv.visitVarInsn(ALOAD, 2); + mv.visitVarInsn(ALOAD, 3); + mv.visitVarInsn(ILOAD, 4); + mv.visitVarInsn(ILOAD, 5); + mv.visitInsn(ICONST_2); + mv.visitTypeInsn(ANEWARRAY, "java/lang/String"); + mv.visitInsn(DUP); + mv.visitInsn(ICONST_0); + mv.visitLdcInsn("Energy Injector for Multiblocks"); + mv.visitInsn(AASTORE); + mv.visitInsn(DUP); + mv.visitInsn(ICONST_1); + mv.visitLdcInsn("Accepts RTG pellets for Fuel"); + mv.visitInsn(AASTORE); + mv.visitMethodInsn(INVOKESPECIAL, "gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Energy", "", "(ILjava/lang/String;Ljava/lang/String;II[Ljava/lang/String;)V", false); + Label l1 = new Label(); + mv.visitLabel(l1); + mv.visitLineNumber(39, l1); + mv.visitInsn(RETURN); + Label l2 = new Label(); + mv.visitLabel(l2); + mv.visitLocalVariable("this", "LgtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Energy_RTG;", null, l0, l2, 0); + mv.visitLocalVariable("aID", "I", null, l0, l2, 1); + mv.visitLocalVariable("aName", "Ljava/lang/String;", null, l0, l2, 2); + mv.visitLocalVariable("aNameRegional", "Ljava/lang/String;", null, l0, l2, 3); + mv.visitLocalVariable("aTier", "I", null, l0, l2, 4); + mv.visitLocalVariable("aSlots", "I", null, l0, l2, 5); + mv.visitMaxs(10, 6); + mv.visitEnd(); + FMLRelaunchLog.log("[GT++ ASM] Gregtech Energy Hatch Patch", Level.INFO, "Injection new constructor "+(aConID++)); + } + { + mv = cw.visitMethod(ACC_PUBLIC, "", "(Ljava/lang/String;IILjava/lang/String;[[[Lgregtech/api/interfaces/ITexture;)V", null, null); + mv.visitCode(); + Label l0 = new Label(); + mv.visitLabel(l0); + mv.visitLineNumber(42, l0); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 1); + mv.visitVarInsn(ILOAD, 2); + mv.visitVarInsn(ILOAD, 3); + mv.visitVarInsn(ALOAD, 4); + mv.visitVarInsn(ALOAD, 5); + mv.visitMethodInsn(INVOKESPECIAL, "gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Energy", "", "(Ljava/lang/String;IILjava/lang/String;[[[Lgregtech/api/interfaces/ITexture;)V", false); + Label l1 = new Label(); + mv.visitLabel(l1); + mv.visitLineNumber(43, l1); + mv.visitInsn(RETURN); + Label l2 = new Label(); + mv.visitLabel(l2); + mv.visitLocalVariable("this", "LgtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Energy_RTG;", null, l0, l2, 0); + mv.visitLocalVariable("aName", "Ljava/lang/String;", null, l0, l2, 1); + mv.visitLocalVariable("aTier", "I", null, l0, l2, 2); + mv.visitLocalVariable("aSlots", "I", null, l0, l2, 3); + mv.visitLocalVariable("aDescription", "Ljava/lang/String;", null, l0, l2, 4); + mv.visitLocalVariable("aTextures", "[[[Lgregtech/api/interfaces/ITexture;", null, l0, l2, 5); + mv.visitMaxs(6, 6); + mv.visitEnd(); + FMLRelaunchLog.log("[GT++ ASM] Gregtech Energy Hatch Patch", Level.INFO, "Injection new constructor "+(aConID++)); + } + { + mv = cw.visitMethod(ACC_PUBLIC, "", "(Ljava/lang/String;II[Ljava/lang/String;[[[Lgregtech/api/interfaces/ITexture;)V", null, null); + mv.visitCode(); + Label l0 = new Label(); + mv.visitLabel(l0); + mv.visitLineNumber(46, l0); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 1); + mv.visitVarInsn(ILOAD, 2); + mv.visitVarInsn(ILOAD, 3); + mv.visitVarInsn(ALOAD, 4); + mv.visitVarInsn(ALOAD, 5); + mv.visitMethodInsn(INVOKESPECIAL, "gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Energy", "", "(Ljava/lang/String;II[Ljava/lang/String;[[[Lgregtech/api/interfaces/ITexture;)V", false); + Label l1 = new Label(); + mv.visitLabel(l1); + mv.visitLineNumber(47, l1); + mv.visitInsn(RETURN); + Label l2 = new Label(); + mv.visitLabel(l2); + mv.visitLocalVariable("this", "LgtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Energy_RTG;", null, l0, l2, 0); + mv.visitLocalVariable("aName", "Ljava/lang/String;", null, l0, l2, 1); + mv.visitLocalVariable("aTier", "I", null, l0, l2, 2); + mv.visitLocalVariable("aSlots", "I", null, l0, l2, 3); + mv.visitLocalVariable("aDescription", "[Ljava/lang/String;", null, l0, l2, 4); + mv.visitLocalVariable("aTextures", "[[[Lgregtech/api/interfaces/ITexture;", null, l0, l2, 5); + mv.visitMaxs(6, 6); + mv.visitEnd(); + FMLRelaunchLog.log("[GT++ ASM] Gregtech Energy Hatch Patch", Level.INFO, "Injection new constructor "+(aConID++)); + } + + + didInject = true; + } + + FMLRelaunchLog.log("[GT++ ASM] Gregtech Energy Hatch Patch", Level.INFO, "Method injection complete. Successful? "+didInject); + return didInject; + + } + + public final class localClassVisitor extends ClassVisitor { + + private final String mClassName; + + public localClassVisitor(ClassVisitor cv, String aClassName) { + super(ASM5, cv); + mClassName = aClassName; + } + + @Override + public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { + MethodVisitor methodVisitor = null; + if ((mClassName.equals(ClassesToTransform.GTPP_MTE_HATCH_RTG)) && access == ACC_PUBLIC && name.equals("") && (desc.equals("(Ljava/lang/String;ILjava/lang/String;[[[Lgregtech/api/interfaces/ITexture;)V") || desc.equals("(Ljava/lang/String;I[Ljava/lang/String;[[[Lgregtech/api/interfaces/ITexture;)V"))) { + FMLRelaunchLog.log("[GT++ ASM] Gregtech Energy Hatch Patch", Level.INFO, "Found Constructor, "+"'"+access+"', "+"'"+name+"', "+"'"+desc+"', "+"'"+signature+"'"); + methodVisitor = null; + } + else { + methodVisitor = super.visitMethod(access, name, desc, signature, exceptions); + } + if (methodVisitor == null) { + if (mClassName.equals(ClassesToTransform.GT_MTE_HATCH_ENERGY)){ + FMLRelaunchLog.log("[GT++ ASM] Gregtech Energy Hatch Patch", Level.INFO, "Removed method from "+mClassName); + } + else { + FMLRelaunchLog.log("[GT++ ASM] Gregtech Energy Hatch Patch", Level.INFO, "Removed Constructor with descriptor '"+desc+"' from "+mClassName); + } + } + return methodVisitor; + } + } + + +} diff --git a/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_TC_AlchemicalFurnace.java b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_TC_AlchemicalFurnace.java new file mode 100644 index 0000000000..abdfb7d25a --- /dev/null +++ b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_TC_AlchemicalFurnace.java @@ -0,0 +1,513 @@ +package gtPlusPlus.preloader.asm.transformers; + +import static org.objectweb.asm.Opcodes.*; + +import org.apache.logging.log4j.Level; +import org.objectweb.asm.*; + +import cpw.mods.fml.relauncher.FMLRelaunchLog; +import gtPlusPlus.preloader.Preloader_Logger; + +public class ClassTransformer_TC_AlchemicalFurnace { + + private final boolean isValid; + private final ClassReader reader; + private final ClassWriter writer; + + public ClassTransformer_TC_AlchemicalFurnace(byte[] basicClass) { + + ClassReader aTempReader = null; + ClassWriter aTempWriter = null; + + aTempReader = new ClassReader(basicClass); + aTempWriter = new ClassWriter(aTempReader, ClassWriter.COMPUTE_FRAMES); + localClassVisitor aTempMethodRemover = new localClassVisitor(aTempWriter); + aTempReader.accept(aTempMethodRemover, 0); + boolean wasMethodObfuscated = aTempMethodRemover.getObfuscatedRemoval(); + + if (aTempReader != null && aTempWriter != null) { + isValid = true; + } else { + isValid = false; + } + + if (isValid) { + Preloader_Logger.LOG("TC Alchemy Furnace Patch", Level.INFO, "Attempting Field Injection."); + boolean fields = addField(aTempWriter); + Preloader_Logger.LOG("TC Alchemy Furnace Patch", Level.INFO, "Success? "+fields); + Preloader_Logger.LOG("TC Alchemy Furnace Patch", Level.INFO, "Attempting Method Injection."); + boolean methods = injectMethod(wasMethodObfuscated, aTempWriter); + Preloader_Logger.LOG("TC Alchemy Furnace Patch", Level.INFO, "Success? "+methods); + } + + Preloader_Logger.LOG("TC Alchemy Furnace Patch", Level.INFO, "Valid patch? " + isValid + "."); + reader = aTempReader; + writer = aTempWriter; + } + + public boolean isValidTransformer() { + return isValid; + } + + public ClassReader getReader() { + return reader; + } + + public ClassWriter getWriter() { + return writer; + } + + // Add a field to hold the smelting cache + public boolean addField(ClassWriter cv) { + Preloader_Logger.LOG("TC Alchemy Furnace Patch", Level.INFO, "Field injection complete."); + FieldVisitor fv = cv.visitField(ACC_PRIVATE, "smeltingCache", "LgtPlusPlus/api/objects/minecraft/ThaumcraftDataStack;", null, null); + if (fv != null) { + fv.visitEnd(); + return true; + } + return false; + } + + public boolean injectMethod(boolean wasMethodObfuscated, ClassWriter cw) { + MethodVisitor mv; + boolean didInject = false; + + // Get the right string to use for the environment we are in. + String aItemStack = "net/minecraft/item/ItemStack"; + String aItemStack_Obf = "add"; + String aCorrectString = wasMethodObfuscated ? aItemStack_Obf : aItemStack; + + // thaumcraft/common/tiles/TileAlchemyFurnace + // Replace the original canSmelt with one that uses the optimized cache + { + mv = cw.visitMethod(ACC_PRIVATE, "canSmelt", "()Z", null, null); + mv.visitCode(); + Label l0 = new Label(); + mv.visitLabel(l0); + mv.visitLineNumber(306, l0); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "thaumcraft/common/tiles/TileAlchemyFurnace", "furnaceItemStacks", "[L"+aCorrectString+";"); + mv.visitInsn(ICONST_0); + mv.visitInsn(AALOAD); + Label l1 = new Label(); + mv.visitJumpInsn(IFNONNULL, l1); + Label l2 = new Label(); + mv.visitLabel(l2); + mv.visitLineNumber(307, l2); + mv.visitInsn(ICONST_0); + mv.visitInsn(IRETURN); + mv.visitLabel(l1); + mv.visitLineNumber(309, l1); + mv.visitFrame(Opcodes.F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 0); + mv.visitMethodInsn(INVOKESPECIAL, "thaumcraft/common/tiles/TileAlchemyFurnace", "getAspectsFromInventoryItem", "()Lthaumcraft/api/aspects/AspectList;", false); + mv.visitVarInsn(ASTORE, 1); + Label l3 = new Label(); + mv.visitLabel(l3); + mv.visitLineNumber(310, l3); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "thaumcraft/common/tiles/TileAlchemyFurnace", "furnaceItemStacks", "[L"+aCorrectString+";"); + mv.visitInsn(ICONST_0); + mv.visitInsn(AALOAD); + mv.visitVarInsn(ALOAD, 1); + mv.visitMethodInsn(INVOKESTATIC, "thaumcraft/common/lib/crafting/ThaumcraftCraftingManager", "getBonusTags", "(L"+aCorrectString+";Lthaumcraft/api/aspects/AspectList;)Lthaumcraft/api/aspects/AspectList;", false); + mv.visitVarInsn(ASTORE, 1); + Label l4 = new Label(); + mv.visitLabel(l4); + mv.visitLineNumber(311, l4); + mv.visitVarInsn(ALOAD, 1); + Label l5 = new Label(); + mv.visitJumpInsn(IFNULL, l5); + mv.visitVarInsn(ALOAD, 1); + mv.visitMethodInsn(INVOKEVIRTUAL, "thaumcraft/api/aspects/AspectList", "size", "()I", false); + mv.visitJumpInsn(IFEQ, l5); + Label l6 = new Label(); + mv.visitLabel(l6); + mv.visitLineNumber(312, l6); + mv.visitVarInsn(ALOAD, 1); + mv.visitMethodInsn(INVOKEVIRTUAL, "thaumcraft/api/aspects/AspectList", "visSize", "()I", false); + mv.visitVarInsn(ISTORE, 2); + Label l7 = new Label(); + mv.visitLabel(l7); + mv.visitLineNumber(313, l7); + mv.visitVarInsn(ILOAD, 2); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "thaumcraft/common/tiles/TileAlchemyFurnace", "maxVis", "I"); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "thaumcraft/common/tiles/TileAlchemyFurnace", "vis", "I"); + mv.visitInsn(ISUB); + Label l8 = new Label(); + mv.visitJumpInsn(IF_ICMPLE, l8); + Label l9 = new Label(); + mv.visitLabel(l9); + mv.visitLineNumber(314, l9); + mv.visitInsn(ICONST_0); + mv.visitInsn(IRETURN); + mv.visitLabel(l8); + mv.visitLineNumber(316, l8); + mv.visitFrame(Opcodes.F_APPEND,2, new Object[] {"thaumcraft/api/aspects/AspectList", Opcodes.INTEGER}, 0, null); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ILOAD, 2); + mv.visitIntInsn(BIPUSH, 10); + mv.visitInsn(IMUL); + mv.visitInsn(I2F); + mv.visitInsn(FCONST_1); + mv.visitLdcInsn(new Float("0.125")); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "thaumcraft/common/tiles/TileAlchemyFurnace", "bellows", "I"); + mv.visitInsn(I2F); + mv.visitInsn(FMUL); + mv.visitInsn(FSUB); + mv.visitInsn(FMUL); + mv.visitInsn(F2I); + mv.visitFieldInsn(PUTFIELD, "thaumcraft/common/tiles/TileAlchemyFurnace", "smeltTime", "I"); + Label l10 = new Label(); + mv.visitLabel(l10); + mv.visitLineNumber(317, l10); + mv.visitInsn(ICONST_1); + mv.visitInsn(IRETURN); + mv.visitLabel(l5); + mv.visitLineNumber(320, l5); + mv.visitFrame(Opcodes.F_CHOP,1, null, 0, null); + mv.visitInsn(ICONST_0); + mv.visitInsn(IRETURN); + Label l11 = new Label(); + mv.visitLabel(l11); + mv.visitLocalVariable("this", "Lthaumcraft/common/tiles/TileAlchemyFurnace;", null, l0, l11, 0); + mv.visitLocalVariable("al", "Lthaumcraft/api/aspects/AspectList;", null, l3, l11, 1); + mv.visitLocalVariable("vs", "I", null, l7, l5, 2); + mv.visitMaxs(5, 3); + mv.visitEnd(); + } + + { + mv = cw.visitMethod(ACC_PUBLIC, "smeltItem", "()V", null, null); + mv.visitCode(); + Label l0 = new Label(); + mv.visitLabel(l0); + mv.visitLineNumber(330, l0); + mv.visitVarInsn(ALOAD, 0); + mv.visitMethodInsn(INVOKESPECIAL, "thaumcraft/common/tiles/TileAlchemyFurnace", "canSmelt", "()Z", false); + Label l1 = new Label(); + mv.visitJumpInsn(IFEQ, l1); + Label l2 = new Label(); + mv.visitLabel(l2); + mv.visitLineNumber(331, l2); + mv.visitVarInsn(ALOAD, 0); + mv.visitMethodInsn(INVOKESPECIAL, "thaumcraft/common/tiles/TileAlchemyFurnace", "getAspectsFromInventoryItem", "()Lthaumcraft/api/aspects/AspectList;", false); + mv.visitVarInsn(ASTORE, 1); + Label l3 = new Label(); + mv.visitLabel(l3); + mv.visitLineNumber(332, l3); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "thaumcraft/common/tiles/TileAlchemyFurnace", "furnaceItemStacks", "[L"+aCorrectString+";"); + mv.visitInsn(ICONST_0); + mv.visitInsn(AALOAD); + mv.visitVarInsn(ALOAD, 1); + mv.visitMethodInsn(INVOKESTATIC, "thaumcraft/common/lib/crafting/ThaumcraftCraftingManager", "getBonusTags", "(L"+aCorrectString+";Lthaumcraft/api/aspects/AspectList;)Lthaumcraft/api/aspects/AspectList;", false); + mv.visitVarInsn(ASTORE, 1); + Label l4 = new Label(); + mv.visitLabel(l4); + mv.visitLineNumber(334, l4); + mv.visitVarInsn(ALOAD, 1); + mv.visitMethodInsn(INVOKEVIRTUAL, "thaumcraft/api/aspects/AspectList", "getAspects", "()[Lthaumcraft/api/aspects/Aspect;", false); + mv.visitInsn(DUP); + mv.visitVarInsn(ASTORE, 5); + mv.visitInsn(ARRAYLENGTH); + mv.visitVarInsn(ISTORE, 4); + mv.visitInsn(ICONST_0); + mv.visitVarInsn(ISTORE, 3); + Label l5 = new Label(); + mv.visitJumpInsn(GOTO, l5); + Label l6 = new Label(); + mv.visitLabel(l6); + mv.visitFrame(Opcodes.F_FULL, 6, new Object[] {"thaumcraft/common/tiles/TileAlchemyFurnace", "thaumcraft/api/aspects/AspectList", Opcodes.TOP, Opcodes.INTEGER, Opcodes.INTEGER, "[Lthaumcraft/api/aspects/Aspect;"}, 0, new Object[] {}); + mv.visitVarInsn(ALOAD, 5); + mv.visitVarInsn(ILOAD, 3); + mv.visitInsn(AALOAD); + mv.visitVarInsn(ASTORE, 2); + Label l7 = new Label(); + mv.visitLabel(l7); + mv.visitLineNumber(335, l7); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "thaumcraft/common/tiles/TileAlchemyFurnace", "aspects", "Lthaumcraft/api/aspects/AspectList;"); + mv.visitVarInsn(ALOAD, 2); + mv.visitVarInsn(ALOAD, 1); + mv.visitVarInsn(ALOAD, 2); + mv.visitMethodInsn(INVOKEVIRTUAL, "thaumcraft/api/aspects/AspectList", "getAmount", "(Lthaumcraft/api/aspects/Aspect;)I", false); + mv.visitMethodInsn(INVOKEVIRTUAL, "thaumcraft/api/aspects/AspectList", "add", "(Lthaumcraft/api/aspects/Aspect;I)Lthaumcraft/api/aspects/AspectList;", false); + mv.visitInsn(POP); + Label l8 = new Label(); + mv.visitLabel(l8); + mv.visitLineNumber(334, l8); + mv.visitIincInsn(3, 1); + mv.visitLabel(l5); + mv.visitFrame(Opcodes.F_SAME, 0, null, 0, null); + mv.visitVarInsn(ILOAD, 3); + mv.visitVarInsn(ILOAD, 4); + mv.visitJumpInsn(IF_ICMPLT, l6); + Label l9 = new Label(); + mv.visitLabel(l9); + mv.visitLineNumber(338, l9); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "thaumcraft/common/tiles/TileAlchemyFurnace", "aspects", "Lthaumcraft/api/aspects/AspectList;"); + mv.visitMethodInsn(INVOKEVIRTUAL, "thaumcraft/api/aspects/AspectList", "visSize", "()I", false); + mv.visitFieldInsn(PUTFIELD, "thaumcraft/common/tiles/TileAlchemyFurnace", "vis", "I"); + Label l10 = new Label(); + mv.visitLabel(l10); + mv.visitLineNumber(339, l10); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "thaumcraft/common/tiles/TileAlchemyFurnace", "furnaceItemStacks", "[L"+aCorrectString+";"); + mv.visitInsn(ICONST_0); + mv.visitInsn(AALOAD); + mv.visitInsn(DUP); + mv.visitFieldInsn(GETFIELD, ""+aCorrectString+"", "stackSize", "I"); + mv.visitInsn(ICONST_1); + mv.visitInsn(ISUB); + mv.visitFieldInsn(PUTFIELD, ""+aCorrectString+"", "stackSize", "I"); + Label l11 = new Label(); + mv.visitLabel(l11); + mv.visitLineNumber(340, l11); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "thaumcraft/common/tiles/TileAlchemyFurnace", "furnaceItemStacks", "[L"+aCorrectString+";"); + mv.visitInsn(ICONST_0); + mv.visitInsn(AALOAD); + mv.visitFieldInsn(GETFIELD, ""+aCorrectString+"", "stackSize", "I"); + mv.visitJumpInsn(IFGT, l1); + Label l12 = new Label(); + mv.visitLabel(l12); + mv.visitLineNumber(341, l12); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "thaumcraft/common/tiles/TileAlchemyFurnace", "furnaceItemStacks", "[L"+aCorrectString+";"); + mv.visitInsn(ICONST_0); + mv.visitInsn(ACONST_NULL); + mv.visitInsn(AASTORE); + mv.visitLabel(l1); + mv.visitLineNumber(345, l1); + mv.visitFrame(Opcodes.F_FULL, 1, new Object[] {"thaumcraft/common/tiles/TileAlchemyFurnace"}, 0, new Object[] {}); + mv.visitInsn(RETURN); + Label l13 = new Label(); + mv.visitLabel(l13); + mv.visitLocalVariable("this", "Lthaumcraft/common/tiles/TileAlchemyFurnace;", null, l0, l13, 0); + mv.visitLocalVariable("al", "Lthaumcraft/api/aspects/AspectList;", null, l3, l1, 1); + mv.visitLocalVariable("a", "Lthaumcraft/api/aspects/Aspect;", null, l7, l8, 2); + mv.visitMaxs(4, 6); + mv.visitEnd(); + } + + { + mv = cw.visitMethod(ACC_PUBLIC, "isItemValidForSlot", "(IL"+aCorrectString+";)Z", null, null); + mv.visitCode(); + Label l0 = new Label(); + mv.visitLabel(l0); + mv.visitLineNumber(362, l0); + mv.visitVarInsn(ILOAD, 1); + Label l1 = new Label(); + mv.visitJumpInsn(IFNE, l1); + Label l2 = new Label(); + mv.visitLabel(l2); + mv.visitLineNumber(363, l2); + mv.visitVarInsn(ALOAD, 0); + mv.visitMethodInsn(INVOKESPECIAL, "thaumcraft/common/tiles/TileAlchemyFurnace", "getAspectsFromInventoryItem", "()Lthaumcraft/api/aspects/AspectList;", false); + mv.visitVarInsn(ASTORE, 3); + Label l3 = new Label(); + mv.visitLabel(l3); + mv.visitLineNumber(364, l3); + mv.visitVarInsn(ALOAD, 2); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKESTATIC, "thaumcraft/common/lib/crafting/ThaumcraftCraftingManager", "getBonusTags", "(L"+aCorrectString+";Lthaumcraft/api/aspects/AspectList;)Lthaumcraft/api/aspects/AspectList;", false); + mv.visitVarInsn(ASTORE, 3); + Label l4 = new Label(); + mv.visitLabel(l4); + mv.visitLineNumber(365, l4); + mv.visitVarInsn(ALOAD, 3); + mv.visitJumpInsn(IFNULL, l1); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "thaumcraft/api/aspects/AspectList", "size", "()I", false); + mv.visitJumpInsn(IFLE, l1); + Label l5 = new Label(); + mv.visitLabel(l5); + mv.visitLineNumber(366, l5); + mv.visitInsn(ICONST_1); + mv.visitInsn(IRETURN); + mv.visitLabel(l1); + mv.visitLineNumber(370, l1); + mv.visitFrame(Opcodes.F_SAME, 0, null, 0, null); + mv.visitVarInsn(ILOAD, 1); + mv.visitInsn(ICONST_1); + Label l6 = new Label(); + mv.visitJumpInsn(IF_ICMPNE, l6); + mv.visitVarInsn(ALOAD, 2); + mv.visitMethodInsn(INVOKESTATIC, "thaumcraft/common/tiles/TileAlchemyFurnace", "isItemFuel", "(L"+aCorrectString+";)Z", false); + Label l7 = new Label(); + mv.visitJumpInsn(GOTO, l7); + mv.visitLabel(l6); + mv.visitFrame(Opcodes.F_SAME, 0, null, 0, null); + mv.visitInsn(ICONST_0); + mv.visitLabel(l7); + mv.visitFrame(Opcodes.F_SAME1, 0, null, 1, new Object[] {Opcodes.INTEGER}); + mv.visitInsn(IRETURN); + Label l8 = new Label(); + mv.visitLabel(l8); + mv.visitLocalVariable("this", "Lthaumcraft/common/tiles/TileAlchemyFurnace;", null, l0, l8, 0); + mv.visitLocalVariable("par1", "I", null, l0, l8, 1); + mv.visitLocalVariable("par2ItemStack", "L"+aCorrectString+";", null, l0, l8, 2); + mv.visitLocalVariable("al", "Lthaumcraft/api/aspects/AspectList;", null, l3, l1, 3); + mv.visitMaxs(2, 4); + mv.visitEnd(); + } + + { + mv = cw.visitMethod(ACC_PRIVATE, "getAspectsFromInventoryItem", "()Lthaumcraft/api/aspects/AspectList;", null, null); + mv.visitCode(); + Label l0 = new Label(); + mv.visitLabel(l0); + mv.visitLineNumber(416, l0); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "thaumcraft/common/tiles/TileAlchemyFurnace", "smeltingCache", "LgtPlusPlus/api/objects/minecraft/ThaumcraftDataStack;"); + Label l1 = new Label(); + mv.visitJumpInsn(IFNONNULL, l1); + Label l2 = new Label(); + mv.visitLabel(l2); + mv.visitLineNumber(417, l2); + mv.visitVarInsn(ALOAD, 0); + mv.visitTypeInsn(NEW, "gtPlusPlus/api/objects/minecraft/ThaumcraftDataStack"); + mv.visitInsn(DUP); + mv.visitIntInsn(BIPUSH, 20); + mv.visitMethodInsn(INVOKESPECIAL, "gtPlusPlus/api/objects/minecraft/ThaumcraftDataStack", "", "(I)V", false); + mv.visitFieldInsn(PUTFIELD, "thaumcraft/common/tiles/TileAlchemyFurnace", "smeltingCache", "LgtPlusPlus/api/objects/minecraft/ThaumcraftDataStack;"); + mv.visitLabel(l1); + mv.visitLineNumber(419, l1); + mv.visitFrame(Opcodes.F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "thaumcraft/common/tiles/TileAlchemyFurnace", "smeltingCache", "LgtPlusPlus/api/objects/minecraft/ThaumcraftDataStack;"); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "thaumcraft/common/tiles/TileAlchemyFurnace", "furnaceItemStacks", "[L"+aCorrectString+";"); + mv.visitInsn(ICONST_0); + mv.visitInsn(AALOAD); + mv.visitMethodInsn(INVOKEVIRTUAL, "gtPlusPlus/api/objects/minecraft/ThaumcraftDataStack", "getAspectsForStack", "(L"+aCorrectString+";)Lthaumcraft/api/aspects/AspectList;", false); + mv.visitVarInsn(ASTORE, 1); + Label l3 = new Label(); + mv.visitLabel(l3); + mv.visitLineNumber(420, l3); + mv.visitVarInsn(ALOAD, 1); + mv.visitInsn(ARETURN); + Label l4 = new Label(); + mv.visitLabel(l4); + mv.visitLocalVariable("this", "Lthaumcraft/common/tiles/TileAlchemyFurnace;", null, l0, l4, 0); + mv.visitLocalVariable("al", "Lthaumcraft/api/aspects/AspectList;", null, l3, l4, 1); + mv.visitMaxs(4, 2); + mv.visitEnd(); + } + + didInject = true; + + Preloader_Logger.LOG("TC Alchemy Furnace Patch", Level.INFO, "Method injection complete."); + return didInject; + } + + public final class localClassVisitor extends ClassVisitor { + + boolean obfuscated = false; + + public localClassVisitor(ClassVisitor cv) { + super(ASM5, cv); + } + + public boolean getObfuscatedRemoval() { + return obfuscated; + } + + @Override + public FieldVisitor visitField(int access, String name, String desc, String signature, Object value) { + //Preloader_Logger.LOG("TC Alchemy Furnace Patch", Level.INFO, "Found Field "+name+" | "+desc); + return cv.visitField(access, name, desc, signature, value); + } + + @Override + public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { + MethodVisitor methodVisitor; + String aDesc1_1 = "()Z"; + String aDesc1_2 = "()V"; + String aDesc1_3 = "(ILnet/minecraft/item/ItemStack;)Z"; + String aDesc2_3 = "(ILadd;)Z"; + if (name.equals("canSmelt")) { + if (desc.equals(aDesc1_1)) { + Preloader_Logger.LOG("TC Alchemy Furnace Patch", Level.INFO, "Found canSmelt to remove: "+desc+" | "+signature); + Preloader_Logger.LOG("TC Alchemy Furnace Patch", Level.INFO, "Is not obfuscated."); + obfuscated = false; + methodVisitor = null; + } + else { + Preloader_Logger.INFO("Found canSmelt: "+desc+" | "+signature); + if (desc.toLowerCase().contains("item")) { + obfuscated = false; + Preloader_Logger.LOG("TC Alchemy Furnace Patch", Level.INFO, "Is not obfuscated."); + } + else { + obfuscated = true; + Preloader_Logger.LOG("TC Alchemy Furnace Patch", Level.INFO, "Is obfuscated."); + } + methodVisitor = null; + } + } + else if (name.equals("smeltItem")) { + if (desc.equals(aDesc1_2)) { + Preloader_Logger.LOG("TC Alchemy Furnace Patch", Level.INFO, "Found smeltItem to remove: "+desc+" | "+signature); + Preloader_Logger.LOG("TC Alchemy Furnace Patch", Level.INFO, "Is not obfuscated."); + obfuscated = false; + methodVisitor = null; + } + else { + Preloader_Logger.INFO("Found smeltItem: "+desc+" | "+signature); + if (desc.toLowerCase().contains("item")) { + obfuscated = false; + Preloader_Logger.LOG("TC Alchemy Furnace Patch", Level.INFO, "Is not obfuscated."); + } + else { + obfuscated = true; + Preloader_Logger.LOG("TC Alchemy Furnace Patch", Level.INFO, "Is obfuscated."); + } + methodVisitor = null; + } + } + else if (name.equals("isItemValidForSlot")) { + if (desc.equals(aDesc1_3)) { + Preloader_Logger.LOG("TC Alchemy Furnace Patch", Level.INFO, "Found isItemValidForSlot to remove: "+desc+" | "+signature); + Preloader_Logger.LOG("TC Alchemy Furnace Patch", Level.INFO, "Is not obfuscated."); + obfuscated = false; + methodVisitor = null; + } + else if (desc.equals(aDesc2_3)) { + Preloader_Logger.LOG("TC Alchemy Furnace Patch", Level.INFO, "Found isItemValidForSlot to remove: "+desc+" | "+signature); + Preloader_Logger.LOG("TC Alchemy Furnace Patch", Level.INFO, "Is obfuscated."); + obfuscated = true; + methodVisitor = null; + } + else { + Preloader_Logger.INFO("Found isItemValidForSlot: "+desc+" | "+signature); + if (desc.toLowerCase().contains("item")) { + obfuscated = false; + Preloader_Logger.LOG("TC Alchemy Furnace Patch", Level.INFO, "Is not obfuscated."); + } + else { + obfuscated = true; + Preloader_Logger.LOG("TC Alchemy Furnace Patch", Level.INFO, "Is obfuscated."); + } + methodVisitor = null; + } + } + else { + methodVisitor = super.visitMethod(access, name, desc, signature, exceptions); + } + + if (methodVisitor == null) { + Preloader_Logger.LOG("TC Alchemy Furnace Patch", Level.INFO, "Found method " + name + ", removing."); + Preloader_Logger.LOG("TC Alchemy Furnace Patch", Level.INFO, "Descriptor: "+desc+" | "+signature); + } + return methodVisitor; + } + } + +} diff --git a/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_TC_ThaumcraftCraftingManager.java b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_TC_ThaumcraftCraftingManager.java index da472717b7..424b316c02 100644 --- a/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_TC_ThaumcraftCraftingManager.java +++ b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_TC_ThaumcraftCraftingManager.java @@ -14,7 +14,7 @@ public class ClassTransformer_TC_ThaumcraftCraftingManager { private final ClassWriter writer; public ClassTransformer_TC_ThaumcraftCraftingManager(byte[] basicClass) { - + ClassReader aTempReader = null; ClassWriter aTempWriter = null; @@ -29,7 +29,7 @@ public class ClassTransformer_TC_ThaumcraftCraftingManager { } else { isValid = false; } - + Preloader_Logger.LOG("TC CraftingManager Patch", Level.INFO, "Valid patch? " + isValid + "."); reader = aTempReader; writer = aTempWriter; @@ -37,6 +37,7 @@ public class ClassTransformer_TC_ThaumcraftCraftingManager { if (reader != null && writer != null) { Preloader_Logger.LOG("TC CraftingManager Patch", Level.INFO, "Attempting Method Injection."); injectMethod("generateTags", wasMethodObfuscated); + injectMethod("getObjectTags", wasMethodObfuscated); } } @@ -58,7 +59,9 @@ public class ClassTransformer_TC_ThaumcraftCraftingManager { boolean didInject = false; ClassWriter cw = getWriter(); String aitemClassName = wasMethodObfuscated ? "adb" : "net/minecraft/item/Item"; - String aClassName = "thaumcraft.common.lib.crafting.ThaumcraftCraftingManager"; + String aitemStackClassName = wasMethodObfuscated ? "add" : "net/minecraft/item/ItemStack"; + String aClassName = "thaumcraft.common.lib.crafting.ThaumcraftCraftingManager"; + if (aMethodName.equals("generateTags")) { Preloader_Logger.LOG("TC CraftingManager Patch", Level.INFO, "Injecting " + aMethodName + ", static replacement call to "+aClassName+"."); mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, "generateTags", "(L"+aitemClassName+";ILjava/util/ArrayList;)Lthaumcraft/api/aspects/AspectList;", "(L"+aitemClassName+";ILjava/util/ArrayList;)Lthaumcraft/api/aspects/AspectList;", null); @@ -80,7 +83,24 @@ public class ClassTransformer_TC_ThaumcraftCraftingManager { mv.visitEnd(); didInject = true; } - + + if (aMethodName.equals("getObjectTags")) { + mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, "getObjectTags", "(L"+aitemStackClassName+";)Lthaumcraft/api/aspects/AspectList;", null, null); + mv.visitCode(); + Label l0 = new Label(); + mv.visitLabel(l0); + mv.visitLineNumber(222, l0); + mv.visitVarInsn(ALOAD, 0); + mv.visitMethodInsn(INVOKESTATIC, "gtPlusPlus/preloader/asm/helpers/MethodHelper_TC", "getObjectTags", "(L"+aitemStackClassName+";)Lthaumcraft/api/aspects/AspectList;", false); + mv.visitInsn(ARETURN); + Label l1 = new Label(); + mv.visitLabel(l1); + mv.visitLocalVariable("itemstack", "L"+aitemStackClassName+";", null, l0, l1, 0); + mv.visitMaxs(1, 1); + mv.visitEnd(); + didInject = true; + } + Preloader_Logger.LOG("TC CraftingManager Patch", Level.INFO, "Method injection complete."); return didInject; } @@ -88,7 +108,7 @@ public class ClassTransformer_TC_ThaumcraftCraftingManager { public final class localClassVisitor extends ClassVisitor { boolean obfuscated = false; - + public localClassVisitor(ClassVisitor cv) { super(ASM5, cv); } @@ -102,9 +122,9 @@ public class ClassTransformer_TC_ThaumcraftCraftingManager { MethodVisitor methodVisitor; String aDeObfName = "net/minecraft/item/Item"; String aObfName = "adb"; - String aDesc1 = "(L+aDeObfName+;ILjava/util/ArrayList;)Lthaumcraft/api/aspects/AspectList;"; + String aDesc1 = "(L"+aDeObfName+";ILjava/util/ArrayList;)Lthaumcraft/api/aspects/AspectList;"; String aDesc2 = "(L"+aObfName+";ILjava/util/ArrayList;)Lthaumcraft/api/aspects/AspectList;"; - + if (name.equals("generateTags") && signature != null) { if (desc.equals(aDesc1)) { Preloader_Logger.LOG("TC CraftingManager Patch", Level.INFO, "Found generateTags to remove: "+desc+" | "+signature); @@ -131,6 +151,32 @@ public class ClassTransformer_TC_ThaumcraftCraftingManager { methodVisitor = null; } } + else if (name.equals("getObjectTags")) { + if (desc.equals(aDesc1)) { + Preloader_Logger.LOG("TC CraftingManager Patch", Level.INFO, "Found getObjectTags to remove: "+desc+" | "+signature); + Preloader_Logger.LOG("TC CraftingManager Patch", Level.INFO, "Is not obfuscated."); + obfuscated = false; + methodVisitor = null; + } + else if (desc.equals(aDesc2)) { + Preloader_Logger.LOG("TC CraftingManager Patch", Level.INFO, "Found getObjectTags to remove: "+desc+" | "+signature); + Preloader_Logger.LOG("TC CraftingManager Patch", Level.INFO, "Is obfuscated."); + obfuscated = true; + methodVisitor = null; + } + else { + Preloader_Logger.INFO("Found getObjectTags: "+desc+" | "+signature); + if (desc.toLowerCase().contains("item")) { + obfuscated = false; + Preloader_Logger.LOG("TC CraftingManager Patch", Level.INFO, "Is not obfuscated."); + } + else { + obfuscated = true; + Preloader_Logger.LOG("TC CraftingManager Patch", Level.INFO, "Is obfuscated."); + } + methodVisitor = null; + } + } else { methodVisitor = super.visitMethod(access, name, desc, signature, exceptions); } 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 998ee03555..6e0f94a54b 100644 --- a/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_Transformer_Handler.java +++ b/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_Transformer_Handler.java @@ -190,6 +190,11 @@ public class Preloader_Transformer_Handler implements IClassTransformer { Preloader_Logger.INFO("Gregtech Bus Patch", "Transforming "+transformedName); return new ClassTransformer_GT_BusPatch(basicClass, transformedName).getWriter().toByteArray(); } + //Inject Custom constructors for RTG Hatches + if (transformedName.equals(GT_MTE_HATCH_ENERGY) || transformedName.equals(GTPP_MTE_HATCH_RTG)) { + Preloader_Logger.INFO("Gregtech RTG Patch", "Transforming "+transformedName); + return new ClassTransformer_GT_EnergyHatchPatch(basicClass, transformedName).getWriter().toByteArray(); + } //Try patch achievements if (transformedName.equals(GT_ACHIEVEMENTS)) { Preloader_Logger.INFO("Gregtech Achievements Patch", "Transforming "+transformedName); @@ -281,6 +286,10 @@ public class Preloader_Transformer_Handler implements IClassTransformer { Preloader_Logger.INFO("Thaumcraft CraftingManager Patch", "Transforming "+transformedName); return new ClassTransformer_TC_ThaumcraftCraftingManager(basicClass).getWriter().toByteArray(); } + if (transformedName.equals(THAUMCRAFT_TILE_ALCHEMY_FURNACE)) { + Preloader_Logger.INFO("Thaumcraft Alchemy Furnace Patch", "Transforming "+transformedName); + return new ClassTransformer_TC_AlchemicalFurnace(basicClass).getWriter().toByteArray(); + } //Fix Thaumic Tinkerer Shit if (transformedName.equals(THAUMICTINKERER_TILE_REPAIRER) && AsmConfig.enableThaumicTinkererRepairFix) { //Preloader_Logger.INFO("Thaumic Tinkerer RepairItem Patch", "Transforming "+transformedName); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java index 53bb8d8410..9e62d05df2 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java @@ -453,7 +453,11 @@ public enum GregtechItemList implements GregtechItemContainer { //Elemental Duplicator Data Orb Bus Hatch_Input_Elemental_Duplicator, - + + //RTG Hatch + Hatch_RTG_LV, + Hatch_RTG_MV, + Hatch_RTG_HV, //Battery hatches for PSS Hatch_Input_Battery_MV, diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/IGregtech_RecipeAdder.java b/src/Java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/IGregtech_RecipeAdder.java index bf36b56015..229bc234e9 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/IGregtech_RecipeAdder.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/IGregtech_RecipeAdder.java @@ -293,6 +293,9 @@ public interface IGregtech_RecipeAdder { public boolean addFlotationRecipe(Materials aMat, ItemStack aXanthate, FluidStack[] aInputFluids, FluidStack[] aOutputFluids, int aTime, int aEU); public boolean addFlotationRecipe(Material aMat, ItemStack aXanthate, FluidStack[] aInputFluids, FluidStack[] aOutputFluids, int aTime, int aEU); - + public boolean addpackagerRecipe(ItemStack aRecipeType, ItemStack aInput1, ItemStack aInput2, ItemStack aOutputStack1); + + public boolean addFuelForRTG(ItemStack aFuelPellet, int aFuelDays, int aVoltage); + } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Energy_RTG.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Energy_RTG.java new file mode 100644 index 0000000000..7b52b9449f --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Energy_RTG.java @@ -0,0 +1,282 @@ +package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations; + +import static gregtech.api.enums.GT_Values.V; + +import java.lang.reflect.Constructor; +import java.util.HashMap; + +import gregtech.api.gui.GT_Container_3by3; +import gregtech.api.gui.GT_GUIContainer_3by3; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.util.minecraft.InventoryUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +public class GT_MetaTileEntity_Hatch_Energy_RTG extends GT_MetaTileEntity_Hatch_Energy { + + public GT_MetaTileEntity_Hatch_Energy_RTG(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier); + } + + public GT_MetaTileEntity_Hatch_Energy_RTG(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } + + public GT_MetaTileEntity_Hatch_Energy_RTG(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } + + @Override + public String[] getDescription() { + return super.getDescription(); + } + + @Override + public ITexture[] getTexturesActive(ITexture aBaseTexture) { + return new ITexture[]{aBaseTexture, TexturesGtBlock.getTextureFromIcon(TexturesGtBlock.Overlay_Hatch_RTG_On, new short[] {220, 220, 220, 0})}; + } + + @Override + public ITexture[] getTexturesInactive(ITexture aBaseTexture) { + return new ITexture[]{aBaseTexture, TexturesGtBlock.getTextureFromIcon(TexturesGtBlock.Overlay_Hatch_RTG_Off, new short[] {220, 220, 220, 0})}; + } + + @Override + public boolean isSimpleMachine() { + return true; + } + + @Override + public boolean isFacingValid(byte aFacing) { + return true; + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public boolean isEnetInput() { + return false; + } + + @Override + public boolean isInputFacing(byte aSide) { + return aSide == getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public boolean isValidSlot(int aIndex) { + return true; + } + + @Override + public long getMinimumStoredEU() { + return 0; + } + + @Override + public long maxEUInput() { + return V[mTier]; + } + + @Override + public long maxEUStore() { + return Long.MAX_VALUE / (Short.MAX_VALUE * Byte.MAX_VALUE) ; + } + + @Override + public long maxAmperesIn() { + return 0; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + Constructor aCon = ReflectionUtils.getConstructor(this.getClass(), new Class[] {String.class, int.class, int.class, String[].class, ITexture[][][].class}); + Object aInst = ReflectionUtils.createNewInstanceFromConstructor(aCon, new Object[] {mName, mTier, 9, mDescriptionArray, mTextures}); + if (GT_MetaTileEntity_Hatch_Energy_RTG.class.isInstance(aInst)) { + return (MetaTileEntity) aInst; + } + Logger.INFO("Created bad sized RTG hatch."); + return new GT_MetaTileEntity_Hatch_Energy_RTG(mName, mTier, mDescriptionArray, mTextures); + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return true; + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) return true; + aBaseMetaTileEntity.openGUI(aPlayer); + return true; + } + + @Override + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_Container_3by3(aPlayerInventory, aBaseMetaTileEntity); + } + + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_3by3(aPlayerInventory, aBaseMetaTileEntity, "RTG Power Unit"); + } + + private static class Dat { + + protected final String mUniqueDataTag; + private final ItemStack mStack; + private final NBTTagCompound mNBT; + + public Dat(ItemStack aStack) { + mStack = aStack; + mNBT = (aStack.getTagCompound() != null ? aStack.getTagCompound() : new NBTTagCompound()); + mUniqueDataTag = ""+Item.getIdFromItem(aStack.getItem())+""+aStack.getItemDamage()+""+1+""+mNBT.getId(); + } + + public int getKey() { + return Item.getIdFromItem(mStack.getItem())+mStack.getItemDamage(); + } + + } + + private static final HashMap mFuelInstanceMap = new HashMap(); + private static final HashMap mFuelValueMap = new HashMap(); + private static final HashMap mFuelTypeMap = new HashMap(); + private static final HashMap mFuelTypeMapReverse = new HashMap(); + + public static boolean registerPelletForHatch(ItemStack aStack, long aFuelValue) { + if (!ItemUtils.checkForInvalidItems(aStack)) { + return false; + } + ItemStack aTemp = aStack.copy(); + aTemp.stackSize = 1; + Dat aDat = new Dat(aTemp); + String aKey = aDat.mUniqueDataTag; + mFuelInstanceMap.put(aKey, aTemp); + mFuelValueMap.put(aKey, aFuelValue); + mFuelTypeMap.put(aKey, aDat.getKey()); + mFuelTypeMapReverse.put(aDat.getKey(), aKey); + Logger.INFO("RTG Hatch: Registered Fuel Pellet: "+ItemUtils.getItemName(aTemp)+", Fuel Value: "+aFuelValue+", Key: "+aKey+", Key2: "+aDat.getKey()); + return true; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { + if (aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.hasInventoryBeenModified()) { + InventoryUtils.sortInventoryItems(this); + } + if (aTimer % 100 == 0 && aBaseMetaTileEntity.isServerSide()) { + if (hasPellet(this)) { + Logger.INFO("Has Pellet"); + tryConsumePellet(this); + } + } + } + + private static void tryConsumePellet(GT_MetaTileEntity_Hatch_Energy_RTG aTile) { + ItemStack aPellet = getPelletToConsume(aTile); + if (aPellet != null) { + Logger.INFO("Found Pellet"); + long aFuel = getFuelValueOfPellet(aPellet); + if (aFuel > 0) { + Logger.INFO("Has Fuel Value: "+aFuel); + if (hasSpaceForEnergy(aTile, aFuel)) { + Logger.INFO("Can buffer"); + aPellet.stackSize = 0; + Logger.INFO("Stack set to 0"); + aPellet = null; + Logger.INFO("null stack"); + addEnergyToInternalStorage(aTile, aFuel); + Logger.INFO("Consumed"); + } + } + } + aTile.updateSlots(); + Logger.INFO("updating slots"); + } + + private static void addEnergyToInternalStorage(GT_MetaTileEntity_Hatch_Energy_RTG aTile, long aFuel) { + aTile.getBaseMetaTileEntity().increaseStoredEnergyUnits(aFuel, true); + } + + public static boolean hasSpaceForEnergy(GT_MetaTileEntity_Hatch_Energy_RTG aTile, long aAmount) { + long aMax = aTile.maxEUStore(); + long aCurrent = aTile.getEUVar(); + if ((aMax - aCurrent) >= aAmount) { + return true; + } + return false; + } + + public void updateSlots() { + for (int i = 0; i < mInventory.length; i++) { + if (mInventory[i] != null && mInventory[i].stackSize <= 0) { + mInventory[i] = null; + } + } + InventoryUtils.sortInventoryItems(this); + } + + public static boolean hasPellet(GT_MetaTileEntity_Hatch_Energy_RTG aTile) { + for (ItemStack o : aTile.mInventory) { + if (o != null ) { + for (ItemStack i : mFuelInstanceMap.values()) { + if (ItemUtils.areItemsEqual(o, i)) { + return true; + } + } + } + } + return false; + } + + public static String getPelletType(ItemStack o) { + if (o == null) { + return "error"; + } + Dat aDat = new Dat(o); + return mFuelTypeMapReverse.get(aDat.getKey()); + } + + public static long getFuelValueOfPellet(ItemStack aPellet) { + String aType = getPelletType(aPellet); + if (mFuelValueMap.containsKey(aType)) { + return mFuelValueMap.get(aType); + } + return 0; + } + + public static ItemStack getPelletToConsume(GT_MetaTileEntity_Hatch_Energy_RTG aTile) { + for (ItemStack o : aTile.mInventory) { + if (o != null ) { + for (ItemStack i : mFuelInstanceMap.values()) { + if (ItemUtils.areItemsEqual(o, i)) { + return o; + } + } + } + } + return null; + } + + + +} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java index 07fd2fe82b..8b181a05f4 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java @@ -99,6 +99,10 @@ public class TexturesGtBlock { } } + public static GT_RenderedTexture getTextureFromIcon(CustomIcon aIcon, short[] aRGB) { + return new GT_RenderedTexture(aIcon, aRGB); + } + /* * Add Some Custom Textures below. * I am not sure whether or not I need to declare them as such, but better to be safe than sorry. @@ -397,7 +401,11 @@ public class TexturesGtBlock { // Catalyst Bus private static final CustomIcon Internal_Overlay_Bus_Catalyst = new CustomIcon("iconsets/OVERLAY_CATALYSTS"); public static final CustomIcon Overlay_Bus_Catalyst = Internal_Overlay_Bus_Catalyst; - + // RTG Hatch + private static final CustomIcon Internal_Overlay_Hatch_RTG_Off = new CustomIcon("iconsets/OVERLAY_ENERGY_RTG_OFF"); + public static final CustomIcon Overlay_Hatch_RTG_Off = Internal_Overlay_Hatch_RTG_Off; + private static final CustomIcon Internal_Overlay_Hatch_RTG_On = new CustomIcon("iconsets/OVERLAY_ENERGY_RTG_ON"); + public static final CustomIcon Overlay_Hatch_RTG_On = Internal_Overlay_Hatch_RTG_On; //Dimensional private static final CustomIcon Internal_Overlay_Machine_Dimensional_Blue = new CustomIcon("TileEntities/adv_machine_dimensional_cover_blue"); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechItems.java b/src/Java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechItems.java index de16a247b0..ce8b6eaf62 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechItems.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechItems.java @@ -201,46 +201,13 @@ public class MetaGeneratedGregtechItems extends Gregtech_MetaItem_X32 { GregtechItemList.Pellet_RTG_SR90.set(this.addItem(42, StringUtils.superscript("90")+"Sr Pellet", "", new Object[]{getTcAspectStack(TC_Aspects.RADIO, 4L), getTcAspectStack(TC_Aspects.POTENTIA, 2L), getTcAspectStack(TC_Aspects.METALLUM, 2L)})); GregtechItemList.Pellet_RTG_PO210.set(this.addItem(43, StringUtils.superscript("210")+"Po Pellet", "", new Object[]{getTcAspectStack(TC_Aspects.RADIO, 4L), getTcAspectStack(TC_Aspects.POTENTIA, 2L), getTcAspectStack(TC_Aspects.METALLUM, 2L)})); GregtechItemList.Pellet_RTG_AM241.set(this.addItem(44, StringUtils.superscript("241")+"Am Pellet", "", new Object[]{getTcAspectStack(TC_Aspects.RADIO, 4L), getTcAspectStack(TC_Aspects.POTENTIA, 2L), getTcAspectStack(TC_Aspects.METALLUM, 2L)})); - GTPP_Recipe.GTPP_Recipe_Map.sRTGFuels.addRecipe( - true, - new ItemStack[]{GregtechItemList.Pellet_RTG_PU238.get(1)}, - new ItemStack[]{}, - null, - null, - null, - 0, - 64, - MathUtils.roundToClosestInt(87.7f)); - GTPP_Recipe.GTPP_Recipe_Map.sRTGFuels.addRecipe( - true, - new ItemStack[]{GregtechItemList.Pellet_RTG_SR90.get(1)}, - new ItemStack[]{}, - null, - null, - null, - 0, - 32, - MathUtils.roundToClosestInt(28.8f)); - GTPP_Recipe.GTPP_Recipe_Map.sRTGFuels.addRecipe( - true, - new ItemStack[]{GregtechItemList.Pellet_RTG_PO210.get(1)}, - new ItemStack[]{}, - null, - null, - null, - 0, - 512, - MathUtils.roundToClosestInt(1f)); - GTPP_Recipe.GTPP_Recipe_Map.sRTGFuels.addRecipe( - true, - new ItemStack[]{GregtechItemList.Pellet_RTG_AM241.get(1)}, - new ItemStack[]{}, - null, - null, - null, - 0, - 16, - MathUtils.roundToClosestInt(432/2)); + + CORE.RA.addFuelForRTG(GregtechItemList.Pellet_RTG_PU238.get(1), MathUtils.roundToClosestInt(87.7f), 64); + CORE.RA.addFuelForRTG(GregtechItemList.Pellet_RTG_SR90.get(1), MathUtils.roundToClosestInt(28.8f), 32); + CORE.RA.addFuelForRTG(GregtechItemList.Pellet_RTG_PO210.get(1), 1, 512); + CORE.RA.addFuelForRTG(GregtechItemList.Pellet_RTG_AM241.get(1), MathUtils.roundToClosestInt(432/2), 16); + CORE.RA.addFuelForRTG(GT_ModHandler.getIC2Item("RTGPellets", 1), MathUtils.roundToClosestInt(2.6f), 8); + //Computer Cube GregtechItemList.Gregtech_Computer_Cube.set(this.addItem(tLastID = 55, "Gregtech Computer Cube", "Reusable", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 8L), getTcAspectStack(TC_Aspects.METALLUM, 8L), getTcAspectStack(TC_Aspects.POTENTIA, 8L)})); this.setElectricStats(32000 + tLastID, GT_Values.V[6]* 10 * 60 * 20, GT_Values.V[5], 5L, -3L, true); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/misc/GMTE_AmazonPackager.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/misc/GMTE_AmazonPackager.java index eca02d290e..10286411a7 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/misc/GMTE_AmazonPackager.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/misc/GMTE_AmazonPackager.java @@ -2,9 +2,6 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.misc; import java.util.ArrayList; -import net.minecraft.block.Block; -import net.minecraft.item.ItemStack; - import gregtech.api.enums.*; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; @@ -15,13 +12,13 @@ import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; - import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.api.objects.minecraft.ItemStackData; import gtPlusPlus.core.block.ModBlocks; -import gtPlusPlus.core.lib.CORE; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; diff --git a/src/Java/gtPlusPlus/xmod/gregtech/recipes/GregtechRecipeAdder.java b/src/Java/gtPlusPlus/xmod/gregtech/recipes/GregtechRecipeAdder.java index f372baff30..1f41bf84e3 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/recipes/GregtechRecipeAdder.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/recipes/GregtechRecipeAdder.java @@ -26,8 +26,10 @@ import gtPlusPlus.core.util.minecraft.MaterialUtils; import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; import gtPlusPlus.xmod.gregtech.api.interfaces.internal.IGregtech_RecipeAdder; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy_RTG; import gtPlusPlus.xmod.gregtech.common.StaticFields59; import gtPlusPlus.xmod.gregtech.common.helpers.FlotationRecipeHandler; +import gtPlusPlus.xmod.gregtech.common.tileentities.generators.GregtechMetaTileEntity_RTG; import gtPlusPlus.xmod.gregtech.recipes.machines.RECIPEHANDLER_MatterFabricator; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; @@ -96,7 +98,7 @@ public class GregtechRecipeAdder implements IGregtech_RecipeAdder { e.getStackTrace(); } try { - + GTPP_Recipe aSpecialRecipe = new GTPP_Recipe( true, new ItemStack[] { aInput1, aInput2 }, @@ -113,8 +115,8 @@ public class GregtechRecipeAdder implements IGregtech_RecipeAdder { int aSize2 = aSize; GTPP_Recipe.GTPP_Recipe_Map.sCokeOvenRecipes.add(aSpecialRecipe); aSize = GTPP_Recipe.GTPP_Recipe_Map.sCokeOvenRecipes.mRecipeList.size(); - - + + // RECIPEHANDLER_CokeOven.debug4(aInput1, aInput2, aFluidInput, // aFluidOutput, aOutput, aDuration, aEUt); /*if (aFluidInput == null && aInput2 != null) { @@ -398,7 +400,7 @@ public class GregtechRecipeAdder implements IGregtech_RecipeAdder { if (aFluidOutput != null) { Logger.WARNING("Recipe will output: " + aFluidOutput.getFluid().getName()); } - + GTPP_Recipe aSpecialRecipe = new GTPP_Recipe( true, aInput, @@ -421,7 +423,7 @@ public class GregtechRecipeAdder implements IGregtech_RecipeAdder { GTPP_Recipe.GTPP_Recipe_Map.sChemicalDehydratorRecipes.addRecipe(true, aInput, aOutputItems, null, aChances, new FluidStack[] { aFluidInput }, new FluidStack[] { aFluidOutput }, aDuration, aEUt, 0); - + } else { Logger.WARNING("Dehydrator recipe has two input items."); @@ -513,7 +515,7 @@ public class GregtechRecipeAdder implements IGregtech_RecipeAdder { /*GTPP_Recipe.GTPP_Recipe_Map.sAlloyBlastSmelterRecipes.addRecipe(true, aInput, aOutputStack, null, aChance, new FluidStack[] { aInputFluid }, new FluidStack[] { aOutput }, aDuration, aEUt, aSpecialValue);*/ - + return aSize > aSize2; } @@ -569,7 +571,7 @@ public class GregtechRecipeAdder implements IGregtech_RecipeAdder { int aSize2 = aSize; GTPP_Recipe.GTPP_Recipe_Map.sFissionFuelProcessing.add(aSpecialRecipe); aSize = GTPP_Recipe.GTPP_Recipe_Map.sFissionFuelProcessing.mRecipeList.size(); - + if (aSize > aSize2) { Logger.INFO("Added Nuclear Fuel Recipe."); return true; @@ -607,7 +609,7 @@ public class GregtechRecipeAdder implements IGregtech_RecipeAdder { int aSize2 = aSize; GTPP_Recipe.GTPP_Recipe_Map.sCyclotronRecipes.add(aSpecialRecipe); aSize = GTPP_Recipe.GTPP_Recipe_Map.sCyclotronRecipes.mRecipeList.size(); - + if (aSize > aSize2) { Logger.INFO("Added Cyclotron Recipe."); return true; @@ -648,12 +650,12 @@ public class GregtechRecipeAdder implements IGregtech_RecipeAdder { int aSize2 = aSize; GTPP_Recipe.GTPP_Recipe_Map.sAdvancedMixerRecipes.add(aSpecialRecipe); aSize = GTPP_Recipe.GTPP_Recipe_Map.sAdvancedMixerRecipes.mRecipeList.size(); - + /*GTPP_Recipe.GTPP_Recipe_Map.sAdvancedMixerRecipes.addRecipe(true, new ItemStack[] { aInput1, aInput2, aInput3, aInput4 }, new ItemStack[] { aOutput1, aOutput2, aOutput3, aOutput4 }, null, null, new FluidStack[] { aFluidInput }, new FluidStack[] { aFluidOutput }, aDuration, aEUt, 0);*/ - + return aSize > aSize2; } @@ -715,7 +717,7 @@ public class GregtechRecipeAdder implements IGregtech_RecipeAdder { aEUtick, aSpecial); GTPP_Recipe.GTPP_Recipe_Map.sMultiblockCentrifugeRecipes_GT.addRecipe(aRecipe); - + //GTPP_Recipe.GTPP_Recipe_Map.sMultiblockCentrifugeRecipes.addRecipe(true, aInputs, aOutputs, null, aChances, aFluidInputs, aFluidOutputs, aDuration, aEUtick, aSpecial); return true; } @@ -1660,6 +1662,46 @@ public class GregtechRecipeAdder implements IGregtech_RecipeAdder { return aSize > aSize2; } + @Override + public boolean addpackagerRecipe(ItemStack aRecipeType, ItemStack aSmallDust, ItemStack aTinyDust, ItemStack aOutputStack1) { + AutoMap aResults = new AutoMap(); + //Dust 1 + aResults.put(GT_Values.RA.addBoxingRecipe(GT_Utility.copyAmount(4L, new Object[]{aSmallDust}), aRecipeType, aOutputStack1, 100, 4)); + //Dust 2 + aResults.put(GT_Values.RA.addBoxingRecipe(GT_Utility.copyAmount(9L, new Object[]{aTinyDust}), aRecipeType, aOutputStack1, 100, 4)); + for (boolean b : aResults) { + if (!b) { + return false; + } + } + return true; + } + + @Override + public boolean addFuelForRTG(ItemStack aFuelPellet, int aFuelDays, int aVoltage) { + int aSize1 = GTPP_Recipe.GTPP_Recipe_Map.sRTGFuels.mRecipeList.size(); + GTPP_Recipe.GTPP_Recipe_Map.sRTGFuels.addRecipe( + true, + new ItemStack[]{aFuelPellet}, + new ItemStack[]{}, + null, + null, + null, + 0, + aVoltage, + aFuelDays); + int aSize2 = GTPP_Recipe.GTPP_Recipe_Map.sRTGFuels.mRecipeList.size(); + + if (aSize2 > aSize1) { + long eu = GregtechMetaTileEntity_RTG.getTotalEUGenerated(GregtechMetaTileEntity_RTG.convertDaysToTicks(aFuelDays), aVoltage); + GT_MetaTileEntity_Hatch_Energy_RTG.registerPelletForHatch(aFuelPellet, eu); + return true; + } + else { + return false; + } + } + diff --git a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechCustomHatches.java b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechCustomHatches.java index 677a47639c..c748da5d3c 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechCustomHatches.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechCustomHatches.java @@ -7,14 +7,9 @@ import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.util.minecraft.FluidUtils; import gtPlusPlus.core.util.minecraft.gregtech.PollutionUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_AirIntake; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_ControlCore; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Muffler_Adv; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Naquadah; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_TurbineProvider; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_SuperBus_Input; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_SuperBus_Output; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.*; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GT_MetaTileEntity_Hatch_CustomFluidBase; public class GregtechCustomHatches { @@ -27,6 +22,7 @@ public class GregtechCustomHatches { run2(); } run3(); + run4(); } } @@ -70,10 +66,10 @@ public class GregtechCustomHatches { // Multiblock Control Core Bus GregtechItemList.Hatch_Control_Core.set((new GT_MetaTileEntity_Hatch_ControlCore(30020, "hatch.control.adv", "Control Core Module", 1)).getStackForm(1L)); - + // Multiblock Air Intake Hatch GregtechItemList.Hatch_Air_Intake.set(new GT_MetaTileEntity_Hatch_AirIntake(861, "hatch.air.intake.tier.00", "Air Intake Hatch", 5).getStackForm(1L)); - + // Steam Hatch GregtechItemList.Hatch_Input_Steam .set(new GT_MetaTileEntity_Hatch_CustomFluidBase(FluidUtils.getSteam(1).getFluid(), // Fluid @@ -86,10 +82,10 @@ public class GregtechCustomHatches { "hatch.steam.input.tier.00", // unlocal name "Steam Hatch" // Local name ).getStackForm(1L)); - - - - + + + + } @@ -125,86 +121,86 @@ public class GregtechCustomHatches { private static void run3() { - - + + /* * Super Input Busses */ - + int aStartID = 30021; Class aGT_MetaTileEntity_SuperBus_Input = GT_MetaTileEntity_SuperBus_Input.class; Class aGT_MetaTileEntity_SuperBus_Output = GT_MetaTileEntity_SuperBus_Output.class; - + GregtechItemList.Hatch_SuperBus_Input_ULV - .set(((IMetaTileEntity) generateBus(aGT_MetaTileEntity_SuperBus_Input, aStartID++, "hatch.superbus.input.tier.00", "Super Bus (I) (ULV)", 0)) - .getStackForm(1L)); + .set(((IMetaTileEntity) generateBus(aGT_MetaTileEntity_SuperBus_Input, aStartID++, "hatch.superbus.input.tier.00", "Super Bus (I) (ULV)", 0)) + .getStackForm(1L)); GregtechItemList.Hatch_SuperBus_Input_LV - .set(((IMetaTileEntity) generateBus(aGT_MetaTileEntity_SuperBus_Input, aStartID++, "hatch.superbus.input.tier.01", "Super Bus (I) (LV)", 1)) - .getStackForm(1L)); + .set(((IMetaTileEntity) generateBus(aGT_MetaTileEntity_SuperBus_Input, aStartID++, "hatch.superbus.input.tier.01", "Super Bus (I) (LV)", 1)) + .getStackForm(1L)); GregtechItemList.Hatch_SuperBus_Input_MV - .set(((IMetaTileEntity) generateBus(aGT_MetaTileEntity_SuperBus_Input, aStartID++, "hatch.superbus.input.tier.02", "Super Bus (I) (MV)", 2)) - .getStackForm(1L)); + .set(((IMetaTileEntity) generateBus(aGT_MetaTileEntity_SuperBus_Input, aStartID++, "hatch.superbus.input.tier.02", "Super Bus (I) (MV)", 2)) + .getStackForm(1L)); GregtechItemList.Hatch_SuperBus_Input_HV - .set(((IMetaTileEntity) generateBus(aGT_MetaTileEntity_SuperBus_Input, aStartID++, "hatch.superbus.input.tier.03", "Super Bus (I) (HV)", 3)) - .getStackForm(1L)); + .set(((IMetaTileEntity) generateBus(aGT_MetaTileEntity_SuperBus_Input, aStartID++, "hatch.superbus.input.tier.03", "Super Bus (I) (HV)", 3)) + .getStackForm(1L)); GregtechItemList.Hatch_SuperBus_Input_EV - .set(((IMetaTileEntity) generateBus(aGT_MetaTileEntity_SuperBus_Input, aStartID++, "hatch.superbus.input.tier.04", "Super Bus (I) (EV)", 4)) - .getStackForm(1L)); + .set(((IMetaTileEntity) generateBus(aGT_MetaTileEntity_SuperBus_Input, aStartID++, "hatch.superbus.input.tier.04", "Super Bus (I) (EV)", 4)) + .getStackForm(1L)); GregtechItemList.Hatch_SuperBus_Input_IV - .set(((IMetaTileEntity) generateBus(aGT_MetaTileEntity_SuperBus_Input, aStartID++, "hatch.superbus.input.tier.05", "Super Bus (I) (IV)", 5)) - .getStackForm(1L)); + .set(((IMetaTileEntity) generateBus(aGT_MetaTileEntity_SuperBus_Input, aStartID++, "hatch.superbus.input.tier.05", "Super Bus (I) (IV)", 5)) + .getStackForm(1L)); GregtechItemList.Hatch_SuperBus_Input_LuV - .set(((IMetaTileEntity) generateBus(aGT_MetaTileEntity_SuperBus_Input, aStartID++, "hatch.superbus.input.tier.06", "Super Bus (I) (LuV)", 6)) - .getStackForm(1L)); + .set(((IMetaTileEntity) generateBus(aGT_MetaTileEntity_SuperBus_Input, aStartID++, "hatch.superbus.input.tier.06", "Super Bus (I) (LuV)", 6)) + .getStackForm(1L)); GregtechItemList.Hatch_SuperBus_Input_ZPM - .set(((IMetaTileEntity) generateBus(aGT_MetaTileEntity_SuperBus_Input, aStartID++, "hatch.superbus.input.tier.07", "Super Bus (I) (ZPM)", 7)) - .getStackForm(1L)); + .set(((IMetaTileEntity) generateBus(aGT_MetaTileEntity_SuperBus_Input, aStartID++, "hatch.superbus.input.tier.07", "Super Bus (I) (ZPM)", 7)) + .getStackForm(1L)); GregtechItemList.Hatch_SuperBus_Input_UV - .set(((IMetaTileEntity) generateBus(aGT_MetaTileEntity_SuperBus_Input, aStartID++, "hatch.superbus.input.tier.08", "Super Bus (I) (UV)", 8)) - .getStackForm(1L)); + .set(((IMetaTileEntity) generateBus(aGT_MetaTileEntity_SuperBus_Input, aStartID++, "hatch.superbus.input.tier.08", "Super Bus (I) (UV)", 8)) + .getStackForm(1L)); GregtechItemList.Hatch_SuperBus_Input_MAX - .set(((IMetaTileEntity) generateBus(aGT_MetaTileEntity_SuperBus_Input, aStartID++, "hatch.superbus.input.tier.09", "Super Bus (I) (MAX)", 9)) - .getStackForm(1L)); + .set(((IMetaTileEntity) generateBus(aGT_MetaTileEntity_SuperBus_Input, aStartID++, "hatch.superbus.input.tier.09", "Super Bus (I) (MAX)", 9)) + .getStackForm(1L)); /* * Super Output Busses */ GregtechItemList.Hatch_SuperBus_Output_ULV - .set(((IMetaTileEntity) generateBus(aGT_MetaTileEntity_SuperBus_Output, aStartID++, "hatch.superbus.output.tier.00", "Super Bus (O) (ULV)", 0)) - .getStackForm(1L)); + .set(((IMetaTileEntity) generateBus(aGT_MetaTileEntity_SuperBus_Output, aStartID++, "hatch.superbus.output.tier.00", "Super Bus (O) (ULV)", 0)) + .getStackForm(1L)); GregtechItemList.Hatch_SuperBus_Output_LV - .set(((IMetaTileEntity) generateBus(aGT_MetaTileEntity_SuperBus_Output, aStartID++, "hatch.superbus.output.tier.01", "Super Bus (O) (LV)", 1)) - .getStackForm(1L)); + .set(((IMetaTileEntity) generateBus(aGT_MetaTileEntity_SuperBus_Output, aStartID++, "hatch.superbus.output.tier.01", "Super Bus (O) (LV)", 1)) + .getStackForm(1L)); GregtechItemList.Hatch_SuperBus_Output_MV - .set(((IMetaTileEntity) generateBus(aGT_MetaTileEntity_SuperBus_Output, aStartID++, "hatch.superbus.output.tier.02", "Super Bus (O) (MV)", 2)) - .getStackForm(1L)); + .set(((IMetaTileEntity) generateBus(aGT_MetaTileEntity_SuperBus_Output, aStartID++, "hatch.superbus.output.tier.02", "Super Bus (O) (MV)", 2)) + .getStackForm(1L)); GregtechItemList.Hatch_SuperBus_Output_HV - .set(((IMetaTileEntity) generateBus(aGT_MetaTileEntity_SuperBus_Output, aStartID++, "hatch.superbus.output.tier.03", "Super Bus (O) (HV)", 3)) - .getStackForm(1L)); + .set(((IMetaTileEntity) generateBus(aGT_MetaTileEntity_SuperBus_Output, aStartID++, "hatch.superbus.output.tier.03", "Super Bus (O) (HV)", 3)) + .getStackForm(1L)); GregtechItemList.Hatch_SuperBus_Output_EV - .set(((IMetaTileEntity) generateBus(aGT_MetaTileEntity_SuperBus_Output, aStartID++, "hatch.superbus.output.tier.04", "Super Bus (O) (EV)", 4)) - .getStackForm(1L)); + .set(((IMetaTileEntity) generateBus(aGT_MetaTileEntity_SuperBus_Output, aStartID++, "hatch.superbus.output.tier.04", "Super Bus (O) (EV)", 4)) + .getStackForm(1L)); GregtechItemList.Hatch_SuperBus_Output_IV - .set(((IMetaTileEntity) generateBus(aGT_MetaTileEntity_SuperBus_Output, aStartID++, "hatch.superbus.output.tier.05", "Super Bus (O) (IV)", 5)) - .getStackForm(1L)); + .set(((IMetaTileEntity) generateBus(aGT_MetaTileEntity_SuperBus_Output, aStartID++, "hatch.superbus.output.tier.05", "Super Bus (O) (IV)", 5)) + .getStackForm(1L)); GregtechItemList.Hatch_SuperBus_Output_LuV - .set(((IMetaTileEntity) generateBus(aGT_MetaTileEntity_SuperBus_Output, aStartID++, "hatch.superbus.output.tier.06", "Super Bus (O) (LuV)", 6)) - .getStackForm(1L)); + .set(((IMetaTileEntity) generateBus(aGT_MetaTileEntity_SuperBus_Output, aStartID++, "hatch.superbus.output.tier.06", "Super Bus (O) (LuV)", 6)) + .getStackForm(1L)); GregtechItemList.Hatch_SuperBus_Output_ZPM - .set(((IMetaTileEntity) generateBus(aGT_MetaTileEntity_SuperBus_Output, aStartID++, "hatch.superbus.output.tier.07", "Super Bus (O) (ZPM)", 7)) - .getStackForm(1L)); + .set(((IMetaTileEntity) generateBus(aGT_MetaTileEntity_SuperBus_Output, aStartID++, "hatch.superbus.output.tier.07", "Super Bus (O) (ZPM)", 7)) + .getStackForm(1L)); GregtechItemList.Hatch_SuperBus_Output_UV - .set(((IMetaTileEntity) generateBus(aGT_MetaTileEntity_SuperBus_Output, aStartID++, "hatch.superbus.output.tier.08", "Super Bus (O) (UV)", 8)) - .getStackForm(1L)); + .set(((IMetaTileEntity) generateBus(aGT_MetaTileEntity_SuperBus_Output, aStartID++, "hatch.superbus.output.tier.08", "Super Bus (O) (UV)", 8)) + .getStackForm(1L)); GregtechItemList.Hatch_SuperBus_Output_MAX - .set(((IMetaTileEntity) generateBus(aGT_MetaTileEntity_SuperBus_Output, aStartID++, "hatch.superbus.output.tier.09", "Super Bus (O) (MAX)", 9)) - .getStackForm(1L)); + .set(((IMetaTileEntity) generateBus(aGT_MetaTileEntity_SuperBus_Output, aStartID++, "hatch.superbus.output.tier.09", "Super Bus (O) (MAX)", 9)) + .getStackForm(1L)); } - + private static Object generateBus(Class aClass, int aID, String aUnlocalName, String aLocalName, int aTier) { Class aBusEntity = aClass; Constructor constructor; @@ -238,4 +234,19 @@ public class GregtechCustomHatches { return null; } + + private static void run4() { + int aID = 31060; + //41, "hatch.energy.tier.01", "LV Energy Hatch", 1 + Constructor aRTG = ReflectionUtils.getConstructor(GT_MetaTileEntity_Hatch_Energy_RTG.class, new Class[] {int.class, String.class, String.class, int.class, int.class}); + Object aHatch1 = ReflectionUtils.createNewInstanceFromConstructor(aRTG, new Object[] {aID++, "hatch.energy.rtg.tier.01", "RTG Power Unit [LV]", 1, 9}); + Object aHatch2 = ReflectionUtils.createNewInstanceFromConstructor(aRTG, new Object[] {aID++, "hatch.energy.rtg.tier.02", "RTG Power Unit [MV]", 2, 9}); + Object aHatch3 = ReflectionUtils.createNewInstanceFromConstructor(aRTG, new Object[] {aID++, "hatch.energy.rtg.tier.03", "RTG Power Unit [HV]", 3, 9}); + + GregtechItemList.Hatch_RTG_LV.set(((IMetaTileEntity) aHatch1).getStackForm(1L)); + GregtechItemList.Hatch_RTG_MV.set(((IMetaTileEntity) aHatch2).getStackForm(1L)); + GregtechItemList.Hatch_RTG_HV.set(((IMetaTileEntity) aHatch3).getStackForm(1L)); + + } + } diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/objects/ThreadAspectScanner.java b/src/Java/gtPlusPlus/xmod/thaumcraft/objects/ThreadAspectScanner.java index 491633b381..fdcf7b8498 100644 --- a/src/Java/gtPlusPlus/xmod/thaumcraft/objects/ThreadAspectScanner.java +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/objects/ThreadAspectScanner.java @@ -36,7 +36,7 @@ public class ThreadAspectScanner extends Thread { } String nameKey; try { - nameKey = aStack.getUnlocalizedName(); + nameKey = ItemUtils.getUnlocalizedItemName(aStack); } catch (NullPointerException n) { try { nameKey = Utils.sanitizeString(aStack.getDisplayName().toLowerCase()); diff --git a/src/resources/assets/miscutils/textures/blocks/iconsets/OVERLAY_ENERGY_RTG_OFF.png b/src/resources/assets/miscutils/textures/blocks/iconsets/OVERLAY_ENERGY_RTG_OFF.png new file mode 100644 index 0000000000..8b5f405322 Binary files /dev/null and b/src/resources/assets/miscutils/textures/blocks/iconsets/OVERLAY_ENERGY_RTG_OFF.png differ diff --git a/src/resources/assets/miscutils/textures/blocks/iconsets/OVERLAY_ENERGY_RTG_ON.png b/src/resources/assets/miscutils/textures/blocks/iconsets/OVERLAY_ENERGY_RTG_ON.png new file mode 100644 index 0000000000..2424eef68f Binary files /dev/null and b/src/resources/assets/miscutils/textures/blocks/iconsets/OVERLAY_ENERGY_RTG_ON.png differ -- cgit