From 6f6a22a69f307db13a94aef472e5aab6876791db Mon Sep 17 00:00:00 2001 From: Alkalus Date: Mon, 25 May 2020 13:28:22 +0100 Subject: + Added a Large Steam Macerator. % Made the Volumetric Flask Configurator tooltip better. --- .../base/GregtechMeta_SteamMultiBase.java | 294 +++++++++++++++++++++ 1 file changed, 294 insertions(+) create mode 100644 src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_SteamMultiBase.java (limited to 'src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations') diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_SteamMultiBase.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_SteamMultiBase.java new file mode 100644 index 0000000000..083af9f2f5 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_SteamMultiBase.java @@ -0,0 +1,294 @@ +package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base; + +import static gregtech.api.enums.GT_Values.V; +import static gtPlusPlus.core.util.data.ArrayUtils.removeNulls; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.commons.lang3.ArrayUtils; + +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.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.util.minecraft.FluidUtils; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.fluids.FluidStack; + +public abstract class GregtechMeta_SteamMultiBase extends GregtechMeta_MultiBlockBase { + + private int aMaxParallelForCurrentRecipe = 0; + + public GregtechMeta_SteamMultiBase(String aName) { + super(aName); + } + + public GregtechMeta_SteamMultiBase(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + if (aSide == aFacing) { + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[getCasingTextureIndex()], aActive ? getFrontOverlayActive() : getFrontOverlay()}; + } + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[getCasingTextureIndex()]}; + } + + protected abstract GT_RenderedTexture getFrontOverlay(); + + protected abstract GT_RenderedTexture getFrontOverlayActive(); + + private int getCasingTextureIndex() { + return 0; + } + + @Override + public boolean hasSlotInGUI() { + return false; + } + + @Override + public String getCustomGUIResourceName() { + return null; + } + + @Override + public int getEuDiscountForParallelism() { + return 0; + } + + @Override + public boolean checkRecipe(ItemStack arg0) { + + log("Running checkRecipeGeneric(0)"); + ArrayList tItems = getStoredInputs(); + ArrayList tFluids = getStoredFluids(); + GT_Recipe_Map tMap = this.getRecipeMap(); + if (tMap == null) { + return false; + } + ItemStack[] aItemInputs = tItems.toArray(new ItemStack[tItems.size()]); + FluidStack[] aFluidInputs = tFluids.toArray(new FluidStack[tFluids.size()]); + GT_Recipe tRecipe = tMap.findRecipe(getBaseMetaTileEntity(), mLastRecipe, false, V[1], null, null, aItemInputs); + if (tRecipe == null) { + return false; + } + + int aEUPercent = 100; + int aSpeedBonusPercent = 0; + int aOutputChanceRoll = 10000; + + // Reset outputs and progress stats + this.mEUt = 0; + this.mMaxProgresstime = 0; + this.mOutputItems = new ItemStack[]{}; + this.mOutputFluids = new FluidStack[]{}; + + + log("Running checkRecipeGeneric(1)"); + // Remember last recipe - an optimization for findRecipe() + this.mLastRecipe = tRecipe; + + + int aMaxParallelRecipes = this.canBufferOutputs(tRecipe, this.getMaxParallelRecipes()); + if (aMaxParallelRecipes == 0) { + log("BAD RETURN - 2"); + return false; + } + aMaxParallelForCurrentRecipe = aMaxParallelRecipes; + // EU discount + float tRecipeEUt = (tRecipe.mEUt * aEUPercent) / 100.0f; + float tTotalEUt = 0.0f; + + int parallelRecipes = 0; + + log("parallelRecipes: "+parallelRecipes); + log("aMaxParallelRecipes: "+aMaxParallelRecipes); + log("tTotalEUt: "+tTotalEUt); + log("tRecipeEUt: "+tRecipeEUt); + + + + // Count recipes to do in parallel, consuming input items and fluids and considering input voltage limits + for (; parallelRecipes < aMaxParallelRecipes && tTotalEUt < (32 - 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 * 2); + + this.mEUt = (int)Math.ceil(tTotalEUt * 3); + + //this.mEUt = (3 * tRecipe.mEUt); + + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + + 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()]); + + // Commit outputs + this.mOutputItems = tOutputItems; + this.mOutputFluids = tOutputFluids; + aMaxParallelForCurrentRecipe = 0; + updateSlots(); + + // Play sounds (GT++ addition - GT multiblocks play no sounds) + startProcess(); + + log("GOOD RETURN - 1"); + return true; + + } + + public ArrayList getAllSteamStacks(){ + ArrayList aFluids = new ArrayList(); + FluidStack aSteam = FluidUtils.getSteam(1); + for (FluidStack aFluid : this.getStoredFluids()) { + if (aFluid.isFluidEqual(aSteam)) { + aFluids.add(aFluid); + } + } + return aFluids; + } + + public int getTotalSteamStored() { + int aSteam = 0; + for (FluidStack aFluid : getAllSteamStacks()) { + aSteam += aFluid.amount; + } + return aSteam; + } + + public boolean tryConsumeSteam(int aAmount) { + if (getTotalSteamStored() <= 0) { + return false; + } + else { + return this.depleteInput(FluidUtils.getSteam(aAmount)); + } + } + + @Override + public int getMaxEfficiency(ItemStack arg0) { + return 0; + } + + + /** + * Called every tick the Machine runs + */ + public boolean onRunningTick(ItemStack aStack) { + if (mEUt < 0) { + long aSteamVal = (((long) -mEUt * 10000) / Math.max(1000, mEfficiency)); + Logger.INFO("Trying to drain "+aSteamVal+" steam per tick."); + //aMaxParallelForCurrentRecipe + if (!tryConsumeSteam((int) aSteamVal)) { + stopMachine(); + return false; + } + } + return true; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setInteger("aMaxParallelForCurrentRecipe", aMaxParallelForCurrentRecipe); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + aMaxParallelForCurrentRecipe = aNBT.getInteger("aMaxParallelForCurrentRecipe"); + } + + @Override + public void stopMachine() { + super.stopMachine(); + aMaxParallelForCurrentRecipe = 0; + } + +} -- cgit From d97f90bfc6c7f799d2986c0b40c9c4a89ba45ee1 Mon Sep 17 00:00:00 2001 From: Alkalus Date: Mon, 25 May 2020 15:56:44 +0100 Subject: + Added steam tier I/O buses & input hatch. + Added recipes for the custom steam hatch, buses and Macerator controller. % Changed Steam Grinder Meta ID. % Moved some logic internal to the SteamMultiBase class. (Handling of output buffering, bus/hatch handling and recipes) $ Fixed spelling of Maintenance in most multiblock tooltips. --- .../gtPlusPlus/core/recipe/RECIPES_Machines.java | 30 ++ .../xmod/gregtech/api/enums/GregtechItemList.java | 5 + .../GT_MetaTileEntity_Hatch_Steam_BusInput.java | 231 ++++++++ .../GT_MetaTileEntity_Hatch_Steam_BusOutput.java | 172 ++++++ .../base/GregtechMeta_MultiBlockBase.java | 35 +- .../base/GregtechMeta_SteamMultiBase.java | 578 +++++++++++++++++++-- .../GregtechMetaTileEntity_SteamMacerator.java | 44 +- .../gregtech/GregtechCustomHatches.java | 13 +- .../registration/gregtech/GregtechSteamMultis.java | 8 +- 9 files changed, 1050 insertions(+), 66 deletions(-) create mode 100644 src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Steam_BusInput.java create mode 100644 src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Steam_BusOutput.java (limited to 'src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations') diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java index 391073dcc2..cc51a9dcb2 100644 --- a/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java @@ -4,6 +4,7 @@ import static gtPlusPlus.core.lib.CORE.GTNH; import codechicken.nei.api.API; import cpw.mods.fml.common.Loader; +import gregtech.api.GregTech_API; import gregtech.api.enums.GT_Values; import gregtech.api.enums.ItemList; import gregtech.api.enums.Materials; @@ -629,6 +630,35 @@ public class RECIPES_Machines { RECIPE_SteamCondenser); } + ItemStack aBronzeBricks = ItemUtils.simpleMetaStack(GregTech_API.sBlockCasings1, 10, 1); + // Steam Macerator Multi + RecipeUtils.addShapedGregtechRecipe( + aBronzeBricks, ALLOY.POTIN.getGear(1), aBronzeBricks, + aBronzeBricks, ALLOY.POTIN.getFrameBox(1), aBronzeBricks, + aBronzeBricks, ALLOY.POTIN.getGear(1), aBronzeBricks, + GregtechItemList.Controller_SteamMaceratorMulti.get(1)); + + // Steam Hatch + RecipeUtils.addShapedGregtechRecipe( + "plateBronze", "pipeMediumBronze", "plateBronze", + "plateBronze", GregtechItemList.GT_FluidTank_ULV.get(1), "plateBronze", + "plateBronze", "pipeMediumBronze", "plateBronze", + GregtechItemList.Hatch_Input_Steam.get(1)); + + // Steam Input Bus + RecipeUtils.addShapedGregtechRecipe( + "plateBronze", ALLOY.POTIN.getPlate(1), "plateBronze", + "plateTin", ItemUtils.getSimpleStack(Blocks.chest), "plateTin", + "plateBronze", ALLOY.POTIN.getPlate(1), "plateBronze", + GregtechItemList.Hatch_Input_Bus_Steam.get(1)); + + // Steam Output Bus + RecipeUtils.addShapedGregtechRecipe( + "plateBronze", "plateTin", "plateBronze", + ALLOY.POTIN.getPlate(1), ItemUtils.getSimpleStack(Blocks.chest), ALLOY.POTIN.getPlate(1), + "plateBronze", "plateTin", "plateBronze", + GregtechItemList.Hatch_Output_Bus_Steam.get(1)); + //RF Convertor if (LoadedMods.CoFHCore && CORE.ConfigSwitches.enableMachine_RF_Convetor){ diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java index 99bd8e916c..087858ae97 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java @@ -429,6 +429,11 @@ public enum GregtechItemList implements GregtechItemContainer { Hatch_Input_Cryotheum, Hatch_Input_Pyrotheum, Hatch_Input_Naquadah, + Hatch_Input_Steam, + + //Steam Multi Buses + Hatch_Input_Bus_Steam, + Hatch_Output_Bus_Steam, //Battery hatches for PSS diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Steam_BusInput.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Steam_BusInput.java new file mode 100644 index 0000000000..f358d13930 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Steam_BusInput.java @@ -0,0 +1,231 @@ +package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations; + +import gregtech.api.enums.Textures; +import gregtech.api.gui.GT_Container_2by2; +import gregtech.api.gui.GT_GUIContainer_2by2; +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 gregtech.api.util.GT_Utility; +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_Steam_BusInput extends GT_MetaTileEntity_Hatch { + public GT_Recipe_Map mRecipeMap = null; + public boolean disableSort; + + public GT_MetaTileEntity_Hatch_Steam_BusInput(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier, getSlots(aTier), new String[]{ + "Item Input for Steam Multiblocks", + "Shift + right click with screwdriver to toggle automatic item shuffling", + "Capacity: 4 stacks"}); + } + + public GT_MetaTileEntity_Hatch_Steam_BusInput(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, 4, aDescription, aTextures); + } + + public GT_MetaTileEntity_Hatch_Steam_BusInput(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, 4, aDescription, aTextures); + } + + @Override + public ITexture[] getTexturesActive(ITexture aBaseTexture) { + return new ITexture[]{aBaseTexture, new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_IN)}; + } + + @Override + public ITexture[] getTexturesInactive(ITexture aBaseTexture) { + return new ITexture[]{aBaseTexture, new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_IN)}; + } + + @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_Steam_BusInput(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_2by2(aPlayerInventory, aBaseMetaTileEntity); + } + + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_2by2(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; + } else { + for (int i = 0; i < mInventory.length; i++) + for (int j = i + 1; j < mInventory.length; j++) + if (mInventory[j] != null && (mInventory[i] == null || GT_Utility.areStacksEqual(mInventory[i], mInventory[j]))) + GT_Utility.moveStackFromSlotAToSlotB(getBaseMetaTileEntity(), getBaseMetaTileEntity(), j, i, (byte) 64, (byte) 1, (byte) 64, (byte) 1); + } + } + + @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) { + if (aPlayer.isSneaking()) { + disableSort = !disableSort; + GT_Utility.sendChatToPlayer(aPlayer, trans("200", "Automatic Item Shuffling: " + (disableSort ? "Disabled" : "Enabled"))); + } + } + + 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 false; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return aSide == getBaseMetaTileEntity().getFrontFacing() && (mRecipeMap == null || mRecipeMap.containsInput(aStack)); + } + + + + @Override + public ITexture[][][] getTextureSet(ITexture[] aTextures) { + ITexture[][][] rTextures = new ITexture[14][17][]; + for (byte c = -1; c < 16; c++) { + if (rTextures[0][c + 1] == null) rTextures[0][c + 1] = getSideFacingActive(c); + if (rTextures[1][c + 1] == null) rTextures[1][c + 1] = getSideFacingInactive(c); + if (rTextures[2][c + 1] == null) rTextures[2][c + 1] = getFrontFacingActive(c); + if (rTextures[3][c + 1] == null) rTextures[3][c + 1] = getFrontFacingInactive(c); + if (rTextures[4][c + 1] == null) rTextures[4][c + 1] = getTopFacingActive(c); + if (rTextures[5][c + 1] == null) rTextures[5][c + 1] = getTopFacingInactive(c); + if (rTextures[6][c + 1] == null) rTextures[6][c + 1] = getBottomFacingActive(c); + if (rTextures[7][c + 1] == null) rTextures[7][c + 1] = getBottomFacingInactive(c); + if (rTextures[8][c + 1] == null) rTextures[8][c + 1] = getBottomFacingPipeActive(c); + if (rTextures[9][c + 1] == null) rTextures[9][c + 1] = getBottomFacingPipeInactive(c); + if (rTextures[10][c + 1] == null) rTextures[10][c + 1] = getTopFacingPipeActive(c); + if (rTextures[11][c + 1] == null) rTextures[11][c + 1] = getTopFacingPipeInactive(c); + if (rTextures[12][c + 1] == null) rTextures[12][c + 1] = getSideFacingPipeActive(c); + if (rTextures[13][c + 1] == null) rTextures[13][c + 1] = getSideFacingPipeInactive(c); + } + return rTextures; + } + + public ITexture[] getSideFacingActive(byte aColor) { + return new ITexture[]{new GT_RenderedTexture(mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_SIDE : Textures.BlockIcons.MACHINE_BRONZE_SIDE)}; + } + + public ITexture[] getSideFacingInactive(byte aColor) { + return new ITexture[]{new GT_RenderedTexture(mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_SIDE : Textures.BlockIcons.MACHINE_BRONZE_SIDE)}; + } + + public ITexture[] getFrontFacingActive(byte aColor) { + return new ITexture[]{new GT_RenderedTexture(mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_SIDE : Textures.BlockIcons.MACHINE_BRONZE_SIDE)}; + } + + public ITexture[] getFrontFacingInactive(byte aColor) { + return new ITexture[]{new GT_RenderedTexture(mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_SIDE : Textures.BlockIcons.MACHINE_BRONZE_SIDE)}; + } + + public ITexture[] getTopFacingActive(byte aColor) { + return new ITexture[]{new GT_RenderedTexture(mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_TOP : Textures.BlockIcons.MACHINE_BRONZE_TOP)}; + } + + public ITexture[] getTopFacingInactive(byte aColor) { + return new ITexture[]{new GT_RenderedTexture(mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_TOP : Textures.BlockIcons.MACHINE_BRONZE_TOP)}; + } + + public ITexture[] getBottomFacingActive(byte aColor) { + return new ITexture[]{new GT_RenderedTexture(mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_BOTTOM : Textures.BlockIcons.MACHINE_BRONZE_BOTTOM)}; + } + + public ITexture[] getBottomFacingInactive(byte aColor) { + return new ITexture[]{new GT_RenderedTexture(mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_BOTTOM : Textures.BlockIcons.MACHINE_BRONZE_BOTTOM)}; + } + + public ITexture[] getBottomFacingPipeActive(byte aColor) { + return new ITexture[]{new GT_RenderedTexture(mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_BOTTOM : Textures.BlockIcons.MACHINE_BRONZE_BOTTOM), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; + } + + public ITexture[] getBottomFacingPipeInactive(byte aColor) { + return new ITexture[]{new GT_RenderedTexture(mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_BOTTOM : Textures.BlockIcons.MACHINE_BRONZE_BOTTOM), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; + } + + public ITexture[] getTopFacingPipeActive(byte aColor) { + return new ITexture[]{new GT_RenderedTexture(mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_TOP : Textures.BlockIcons.MACHINE_BRONZE_TOP), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; + } + + public ITexture[] getTopFacingPipeInactive(byte aColor) { + return new ITexture[]{new GT_RenderedTexture(mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_TOP : Textures.BlockIcons.MACHINE_BRONZE_TOP), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; + } + + public ITexture[] getSideFacingPipeActive(byte aColor) { + return new ITexture[]{new GT_RenderedTexture(mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_SIDE : Textures.BlockIcons.MACHINE_BRONZE_SIDE), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; + } + + public ITexture[] getSideFacingPipeInactive(byte aColor) { + return new ITexture[]{new GT_RenderedTexture(mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_SIDE : Textures.BlockIcons.MACHINE_BRONZE_SIDE), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; + } + + +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Steam_BusOutput.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Steam_BusOutput.java new file mode 100644 index 0000000000..37dc016c1e --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Steam_BusOutput.java @@ -0,0 +1,172 @@ +package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations; + +import gregtech.api.enums.Textures; +import gregtech.api.gui.GT_Container_2by2; +import gregtech.api.gui.GT_GUIContainer_2by2; +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 net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; + +public class GT_MetaTileEntity_Hatch_Steam_BusOutput extends GT_MetaTileEntity_Hatch { + public GT_MetaTileEntity_Hatch_Steam_BusOutput(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier, 4, new String[]{"Item Output for Steam Multiblocks", + "Capacity: 4 stacks"}); + } + + public GT_MetaTileEntity_Hatch_Steam_BusOutput(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, 4, aDescription, aTextures); + } + + public GT_MetaTileEntity_Hatch_Steam_BusOutput(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, 4, aDescription, aTextures); + } + + @Override + public ITexture[] getTexturesActive(ITexture aBaseTexture) { + return new ITexture[]{aBaseTexture, new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; + } + + @Override + public ITexture[] getTexturesInactive(ITexture aBaseTexture) { + return new ITexture[]{aBaseTexture, new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; + } + + @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_Steam_BusOutput(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_2by2(aPlayerInventory, aBaseMetaTileEntity); + } + + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_2by2(aPlayerInventory, aBaseMetaTileEntity, "Steam Output Bus"); + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return aSide == aBaseMetaTileEntity.getFrontFacing(); + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return false; + } + + + + @Override + public ITexture[][][] getTextureSet(ITexture[] aTextures) { + ITexture[][][] rTextures = new ITexture[14][17][]; + for (byte c = -1; c < 16; c++) { + if (rTextures[0][c + 1] == null) rTextures[0][c + 1] = getSideFacingActive(c); + if (rTextures[1][c + 1] == null) rTextures[1][c + 1] = getSideFacingInactive(c); + if (rTextures[2][c + 1] == null) rTextures[2][c + 1] = getFrontFacingActive(c); + if (rTextures[3][c + 1] == null) rTextures[3][c + 1] = getFrontFacingInactive(c); + if (rTextures[4][c + 1] == null) rTextures[4][c + 1] = getTopFacingActive(c); + if (rTextures[5][c + 1] == null) rTextures[5][c + 1] = getTopFacingInactive(c); + if (rTextures[6][c + 1] == null) rTextures[6][c + 1] = getBottomFacingActive(c); + if (rTextures[7][c + 1] == null) rTextures[7][c + 1] = getBottomFacingInactive(c); + if (rTextures[8][c + 1] == null) rTextures[8][c + 1] = getBottomFacingPipeActive(c); + if (rTextures[9][c + 1] == null) rTextures[9][c + 1] = getBottomFacingPipeInactive(c); + if (rTextures[10][c + 1] == null) rTextures[10][c + 1] = getTopFacingPipeActive(c); + if (rTextures[11][c + 1] == null) rTextures[11][c + 1] = getTopFacingPipeInactive(c); + if (rTextures[12][c + 1] == null) rTextures[12][c + 1] = getSideFacingPipeActive(c); + if (rTextures[13][c + 1] == null) rTextures[13][c + 1] = getSideFacingPipeInactive(c); + } + return rTextures; + } + + + + public ITexture[] getSideFacingActive(byte aColor) { + return new ITexture[]{new GT_RenderedTexture(mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_SIDE : Textures.BlockIcons.MACHINE_BRONZE_SIDE)}; + } + + public ITexture[] getSideFacingInactive(byte aColor) { + return new ITexture[]{new GT_RenderedTexture(mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_SIDE : Textures.BlockIcons.MACHINE_BRONZE_SIDE)}; + } + + public ITexture[] getFrontFacingActive(byte aColor) { + return new ITexture[]{new GT_RenderedTexture(mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_SIDE : Textures.BlockIcons.MACHINE_BRONZE_SIDE)}; + } + + public ITexture[] getFrontFacingInactive(byte aColor) { + return new ITexture[]{new GT_RenderedTexture(mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_SIDE : Textures.BlockIcons.MACHINE_BRONZE_SIDE)}; + } + + public ITexture[] getTopFacingActive(byte aColor) { + return new ITexture[]{new GT_RenderedTexture(mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_TOP : Textures.BlockIcons.MACHINE_BRONZE_TOP)}; + } + + public ITexture[] getTopFacingInactive(byte aColor) { + return new ITexture[]{new GT_RenderedTexture(mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_TOP : Textures.BlockIcons.MACHINE_BRONZE_TOP)}; + } + + public ITexture[] getBottomFacingActive(byte aColor) { + return new ITexture[]{new GT_RenderedTexture(mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_BOTTOM : Textures.BlockIcons.MACHINE_BRONZE_BOTTOM)}; + } + + public ITexture[] getBottomFacingInactive(byte aColor) { + return new ITexture[]{new GT_RenderedTexture(mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_BOTTOM : Textures.BlockIcons.MACHINE_BRONZE_BOTTOM)}; + } + + public ITexture[] getBottomFacingPipeActive(byte aColor) { + return new ITexture[]{new GT_RenderedTexture(mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_BOTTOM : Textures.BlockIcons.MACHINE_BRONZE_BOTTOM), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; + } + + public ITexture[] getBottomFacingPipeInactive(byte aColor) { + return new ITexture[]{new GT_RenderedTexture(mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_BOTTOM : Textures.BlockIcons.MACHINE_BRONZE_BOTTOM), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; + } + + public ITexture[] getTopFacingPipeActive(byte aColor) { + return new ITexture[]{new GT_RenderedTexture(mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_TOP : Textures.BlockIcons.MACHINE_BRONZE_TOP), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; + } + + public ITexture[] getTopFacingPipeInactive(byte aColor) { + return new ITexture[]{new GT_RenderedTexture(mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_TOP : Textures.BlockIcons.MACHINE_BRONZE_TOP), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; + } + + public ITexture[] getSideFacingPipeActive(byte aColor) { + return new ITexture[]{new GT_RenderedTexture(mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_SIDE : Textures.BlockIcons.MACHINE_BRONZE_SIDE), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; + } + + public ITexture[] getSideFacingPipeInactive(byte aColor) { + return new ITexture[]{new GT_RenderedTexture(mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_SIDE : Textures.BlockIcons.MACHINE_BRONZE_SIDE), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; + } +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java index ea14320f93..17bf67317b 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java @@ -325,6 +325,7 @@ public abstract class GregtechMeta_MultiBlockBase extends GT_MetaTileEntity_Mult private final String aRequiresMaint = "1x Maintanence Hatch";*/ public final static String TAG_HIDE_HATCHES = "TAG_HIDE_HATCHES"; + public final static String TAG_HIDE_MAINT = "TAG_HIDE_MAINT"; public final static String TAG_HIDE_POLLUTION = "TAG_HIDE_POLLUTION"; public final static String TAG_HIDE_MACHINE_TYPE = "TAG_HIDE_MACHINE_TYPE"; @@ -348,13 +349,14 @@ public abstract class GregtechMeta_MultiBlockBase extends GT_MetaTileEntity_Mult String aRequiresMuffler = "1x Muffler Hatch"; //String aRequiresCoreModule = "1x Core Module"; - String aRequiresMaint = "1x Maintanence Hatch"; + String aRequiresMaint = "1x Maintenance Hatch"; String[] x = getTooltip(); //Filter List, toggle switches, rebuild map without flags boolean showHatches = true; boolean showMachineType = true; + boolean showMaint = true; boolean showPollution = getPollutionPerTick(null) > 0; AutoMap aTempMap = new AutoMap(); for (int ee = 0; ee < x.length; ee++) { @@ -368,6 +370,9 @@ public abstract class GregtechMeta_MultiBlockBase extends GT_MetaTileEntity_Mult else if (hh.equals(TAG_HIDE_MACHINE_TYPE)) { showMachineType = false; } + else if (hh.equals(TAG_HIDE_MAINT)) { + showMaint = false; + } else { aTempMap.put(x[ee]); } @@ -382,11 +387,13 @@ public abstract class GregtechMeta_MultiBlockBase extends GT_MetaTileEntity_Mult //Assemble ordered map for misc tooltips AutoMap aOrderedMap = new AutoMap(); if (showHatches) { - aOrderedMap.put(aRequiresMaint); //aOrderedMap.put(aRequiresCoreModule); if (showPollution) { aOrderedMap.put(aRequiresMuffler); } + if (showMaint) { + aOrderedMap.put(aRequiresMaint); + } } if (showMachineType) { @@ -478,7 +485,7 @@ public abstract class GregtechMeta_MultiBlockBase extends GT_MetaTileEntity_Mult public int canBufferOutputs(final GT_Recipe aRecipe, int aParallelRecipes, boolean aAllow16SlotWithoutCheck) { - Logger.INFO("Determining if we have space to buffer outputs. Parallel: "+aParallelRecipes); + log("Determining if we have space to buffer outputs. Parallel: "+aParallelRecipes); // Null recipe or a recipe with lots of outputs? // E.G. Gendustry custom comb with a billion centrifuge outputs? @@ -510,7 +517,7 @@ public abstract class GregtechMeta_MultiBlockBase extends GT_MetaTileEntity_Mult */ if (aDoesOutputItems) { - Logger.INFO("We have items to output."); + log("We have items to output."); // How many slots are free across all the output buses? int aInputBusSlotsFree = 0; @@ -628,9 +635,9 @@ public abstract class GregtechMeta_MultiBlockBase extends GT_MetaTileEntity_Mult if (aInputMap.size() > aInputBusSlotsFree) { aParallelRecipes = (int) Math.floor((double) aInputBusSlotsFree/aInputMap.size() * aParallelRecipes); // We do not have enough free slots in total to accommodate the remaining managed stacks. - Logger.INFO(" Free: "+aInputBusSlotsFree+", Required: "+aInputMap.size()); + log(" Free: "+aInputBusSlotsFree+", Required: "+aInputMap.size()); if(aParallelRecipes == 0) { - Logger.INFO("Failed to find enough space for all item outputs."); + log("Failed to find enough space for all item outputs."); return 0; } @@ -655,7 +662,7 @@ public abstract class GregtechMeta_MultiBlockBase extends GT_MetaTileEntity_Mult if (aDoesOutputFluids) { - Logger.INFO("We have Fluids to output."); + log("We have Fluids to output."); // How many slots are free across all the output buses? int aFluidHatches = 0; int aEmptyFluidHatches = 0; @@ -783,12 +790,12 @@ public abstract class GregtechMeta_MultiBlockBase extends GT_MetaTileEntity_Mult } // We have Fluid Stacks we did not merge. Do we have space? - Logger.INFO("fluids to output "+aOutputFluids.size()+" empty hatches "+aEmptyFluidHatches); + log("fluids to output "+aOutputFluids.size()+" empty hatches "+aEmptyFluidHatches); if (aOutputFluids.size() > 0) { // Not enough space to add fluids. if (aOutputFluids.size() > aEmptyFluidHatches) { aParallelRecipes = (int) Math.floor((double) aEmptyFluidHatches/aOutputFluids.size() * aParallelRecipes); - Logger.INFO("Failed to find enough space for all fluid outputs. Free: "+aEmptyFluidHatches+", Required: "+aOutputFluids.size()); + log("Failed to find enough space for all fluid outputs. Free: "+aEmptyFluidHatches+", Required: "+aOutputFluids.size()); return 0; } @@ -922,18 +929,18 @@ public abstract class GregtechMeta_MultiBlockBase extends GT_MetaTileEntity_Mult * log("parallelRecipes: "+parallelRecipes); * log("aMaxParallelRecipes: "+aMaxParallelRecipes); * log("tTotalEUt: "+tTotalEUt); log("tVoltage: "+tVoltage); - * log("tRecipeEUt: "+tRecipeEUt); Logger.INFO("EU1: "+tRecipeEUt); // Count + * log("tRecipeEUt: "+tRecipeEUt); log("EU1: "+tRecipeEUt); // Count * recipes to do in parallel, consuming input items and fluids and considering * input voltage limits for (; parallelRecipes < aMaxParallelRecipes && * tTotalEUt < (tVoltage - tRecipeEUt); parallelRecipes++) { if * (!tRecipe.isRecipeInputEqual(true, aFluidInputs, aItemInputs)) { * log("Broke at "+parallelRecipes+"."); break; } * log("Bumped EU from "+tTotalEUt+" to "+(tTotalEUt+tRecipeEUt)+"."); tTotalEUt - * += tRecipeEUt; Logger.INFO("EU2: "+tTotalEUt); } + * += tRecipeEUt; log("EU2: "+tTotalEUt); } * * if (parallelRecipes == 0) { log("BAD RETURN - 3"); return false; } * - * Logger.INFO("EU3: "+tTotalEUt); + * log("EU3: "+tTotalEUt); * * // -- Try not to fail after this point - inputs have already been consumed! * -- @@ -945,7 +952,7 @@ public abstract class GregtechMeta_MultiBlockBase extends GT_MetaTileEntity_Mult * aSpeedBonusPercent); this.mMaxProgresstime = (int)(tRecipe.mDuration * * tTimeFactor * 10000); * - * int aTempEu = (int) Math.floor(tTotalEUt); Logger.INFO("EU4: "+aTempEu); + * int aTempEu = (int) Math.floor(tTotalEUt); log("EU4: "+aTempEu); * this.mEUt = (int) aTempEu; * * @@ -1912,7 +1919,7 @@ public abstract class GregtechMeta_MultiBlockBase extends GT_MetaTileEntity_Mult //Handle Fluid Hatches using seperate logic else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) - aDidAdd = addFluidInputToMachineList(aMetaTileEntity, aBaseCasingIndex); + aDidAdd = addToMachineListInternal(mInputHatches, aMetaTileEntity, aBaseCasingIndex); else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) aDidAdd = addToMachineListInternal(mOutputHatches, aMetaTileEntity, aBaseCasingIndex); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_SteamMultiBase.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_SteamMultiBase.java index 083af9f2f5..a15388b27b 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_SteamMultiBase.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_SteamMultiBase.java @@ -12,19 +12,25 @@ 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.*; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Recipe.GT_Recipe_Map; -import gtPlusPlus.api.objects.Logger; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.api.objects.data.*; import gtPlusPlus.core.util.minecraft.FluidUtils; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Steam_BusInput; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Steam_BusOutput; +import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.fluids.FluidStack; public abstract class GregtechMeta_SteamMultiBase extends GregtechMeta_MultiBlockBase { - - private int aMaxParallelForCurrentRecipe = 0; + + public ArrayList mSteamInputs = new ArrayList(); + public ArrayList mSteamOutputs = new ArrayList(); + public ArrayList mSteamInputFluids = new ArrayList(); public GregtechMeta_SteamMultiBase(String aName) { super(aName); @@ -47,12 +53,12 @@ public abstract class GregtechMeta_SteamMultiBase extends GregtechMeta_MultiBloc protected abstract GT_RenderedTexture getFrontOverlayActive(); private int getCasingTextureIndex() { - return 0; + return 10; } @Override public boolean hasSlotInGUI() { - return false; + return true; } @Override @@ -68,6 +74,7 @@ public abstract class GregtechMeta_SteamMultiBase extends GregtechMeta_MultiBloc @Override public boolean checkRecipe(ItemStack arg0) { + log("Running checkRecipeGeneric(0)"); ArrayList tItems = getStoredInputs(); ArrayList tFluids = getStoredFluids(); @@ -79,6 +86,7 @@ public abstract class GregtechMeta_SteamMultiBase extends GregtechMeta_MultiBloc FluidStack[] aFluidInputs = tFluids.toArray(new FluidStack[tFluids.size()]); GT_Recipe tRecipe = tMap.findRecipe(getBaseMetaTileEntity(), mLastRecipe, false, V[1], null, null, aItemInputs); if (tRecipe == null) { + log("BAD RETURN - 1"); return false; } @@ -98,12 +106,12 @@ public abstract class GregtechMeta_SteamMultiBase extends GregtechMeta_MultiBloc this.mLastRecipe = tRecipe; - int aMaxParallelRecipes = this.canBufferOutputs(tRecipe, this.getMaxParallelRecipes()); + int aMaxParallelRecipes = canBufferOutputs(tRecipe.mOutputs, tRecipe.mFluidOutputs, this.getMaxParallelRecipes()); if (aMaxParallelRecipes == 0) { log("BAD RETURN - 2"); return false; } - aMaxParallelForCurrentRecipe = aMaxParallelRecipes; + // EU discount float tRecipeEUt = (tRecipe.mEUt * aEUPercent) / 100.0f; float tTotalEUt = 0.0f; @@ -140,9 +148,9 @@ public abstract class GregtechMeta_SteamMultiBase extends GregtechMeta_MultiBloc // 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 * 2); + this.mMaxProgresstime = (int)(tRecipe.mDuration * tTimeFactor * 1.5f); - this.mEUt = (int)Math.ceil(tTotalEUt * 3); + this.mEUt = (int)Math.ceil(tTotalEUt*1.33f); //this.mEUt = (3 * tRecipe.mEUt); @@ -156,22 +164,10 @@ public abstract class GregtechMeta_SteamMultiBase extends GregtechMeta_MultiBloc 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; - } - } + FluidStack[] tOutputFluids = getOutputFluids(tRecipe, 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; - } - } + ItemStack[] tOutputItems = getOutputItems(tRecipe); // Set output item stack sizes (taking output chance into account) for (int f = 0; f < tOutputItems.length; f++) { @@ -212,7 +208,6 @@ public abstract class GregtechMeta_SteamMultiBase extends GregtechMeta_MultiBloc // Commit outputs this.mOutputItems = tOutputItems; this.mOutputFluids = tOutputFluids; - aMaxParallelForCurrentRecipe = 0; updateSlots(); // Play sounds (GT++ addition - GT multiblocks play no sounds) @@ -256,15 +251,26 @@ public abstract class GregtechMeta_SteamMultiBase extends GregtechMeta_MultiBloc return 0; } + @Override + public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { + if (aBaseMetaTileEntity.isServerSide()) { + if (this.mUpdate == 1 || this.mStartUpCheck == 1) { + this.mSteamInputs.clear(); + this.mSteamOutputs.clear(); + this.mSteamInputFluids.clear(); + } + } + super.onPostTick(aBaseMetaTileEntity, aTick); + } /** * Called every tick the Machine runs */ public boolean onRunningTick(ItemStack aStack) { + fixAllMaintenanceIssue(); if (mEUt < 0) { long aSteamVal = (((long) -mEUt * 10000) / Math.max(1000, mEfficiency)); - Logger.INFO("Trying to drain "+aSteamVal+" steam per tick."); - //aMaxParallelForCurrentRecipe + //Logger.INFO("Trying to drain "+aSteamVal+" steam per tick."); if (!tryConsumeSteam((int) aSteamVal)) { stopMachine(); return false; @@ -272,23 +278,519 @@ public abstract class GregtechMeta_SteamMultiBase extends GregtechMeta_MultiBloc } return true; } - + @Override - public void saveNBTData(NBTTagCompound aNBT) { - super.saveNBTData(aNBT); - aNBT.setInteger("aMaxParallelForCurrentRecipe", aMaxParallelForCurrentRecipe); - } + public boolean addToMachineList(final IGregTechTileEntity aTileEntity, final int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } + final IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return false; + } - @Override - public void loadNBTData(NBTTagCompound aNBT) { - super.loadNBTData(aNBT); - aMaxParallelForCurrentRecipe = aNBT.getInteger("aMaxParallelForCurrentRecipe"); + //Use this to determine the correct value, then update the hatch texture after. + boolean aDidAdd = false; + + //Handle Custom Hustoms + + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_CustomFluidBase) + aDidAdd = addToMachineListInternal(mSteamInputFluids, aMetaTileEntity, aBaseCasingIndex); + + else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Steam_BusInput) + aDidAdd = addToMachineListInternal(mSteamInputs, aMetaTileEntity, aBaseCasingIndex); + + else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Steam_BusOutput) + aDidAdd = addToMachineListInternal(mSteamOutputs, aMetaTileEntity, aBaseCasingIndex); + + return aDidAdd; } + + + @Override public void stopMachine() { super.stopMachine(); - aMaxParallelForCurrentRecipe = 0; } + + public FluidStack[] getOutputFluids(GT_Recipe aRecipe, int parallelRecipes) { + // Collect fluid outputs + FluidStack[] tOutputFluids = new FluidStack[aRecipe.mFluidOutputs.length]; + for (int h = 0; h < aRecipe.mFluidOutputs.length; h++) { + if (aRecipe.getFluidOutput(h) != null) { + tOutputFluids[h] = aRecipe.getFluidOutput(h).copy(); + tOutputFluids[h].amount *= parallelRecipes; + } + } + return tOutputFluids; + } + + public ItemStack[] getOutputItems(GT_Recipe aRecipe) { + // Collect output item types + ItemStack[] tOutputItems = new ItemStack[aRecipe.mOutputs.length]; + for (int h = 0; h < aRecipe.mOutputs.length; h++) { + if (aRecipe.getOutput(h) != null) { + tOutputItems[h] = aRecipe.getOutput(h).copy(); + tOutputItems[h].stackSize = 0; + } + } + return tOutputItems; + } + + public int getOutputCount(ItemStack[] aOutputs) { + return aOutputs.length; + } + public int getOutputFluidCount(FluidStack[] aOutputs) { + return aOutputs.length; + } + + public int canBufferOutputs(final ItemStack[] aOutputs, FluidStack[] aFluidOutputs, int aParallelRecipes) { + + log("Determining if we have space to buffer outputs. Parallel: "+aParallelRecipes); + + // Null recipe or a recipe with lots of outputs? + // E.G. Gendustry custom comb with a billion centrifuge outputs? + // Do it anyway, provided the multi allows it. Default behaviour is aAllow16SlotWithoutCheck = true. + if (aOutputs == null && aFluidOutputs == null) { + return 0; + } + + // Do we even need to check for item outputs? + boolean aDoesOutputItems = aOutputs != null ? aOutputs.length > 0 : false; + // Do we even need to check for fluid outputs? + boolean aDoesOutputFluids = aFluidOutputs != null ? aFluidOutputs.length > 0 : false; + + if (!aDoesOutputItems && !aDoesOutputFluids) { + return 0; + } + + /* ======================================== + * Item Management + * ======================================== + */ + + if (aDoesOutputItems) { + log("We have items to output."); + + // How many slots are free across all the output buses? + int aInputBusSlotsFree = 0; + + /* + * Create Variables for Item Output + */ + + AutoMap> aItemMap = new AutoMap>(); + AutoMap aItemOutputs = new AutoMap(aOutputs); + + for (final GT_MetaTileEntity_Hatch_Steam_BusOutput tBus : this.mSteamOutputs) { + if (!isValidMetaTileEntity(tBus)) { + continue; + } + final IInventory tBusInv = tBus.getBaseMetaTileEntity(); + for (int i = 0; i < tBusInv.getSizeInventory(); i++) { + if (tBus.getStackInSlot(i) == null) { + aInputBusSlotsFree++; + } + else { + ItemStack aT = tBus.getStackInSlot(i); + int aSize = aT.stackSize; + aT = aT.copy(); + aT.stackSize = 0; + aItemMap.put(new FlexiblePair(aT, aSize)); + } + } + } + + // Count the slots we need, later we can check if any are able to merge with existing stacks + int aRecipeSlotsRequired = 0; + + // A map to hold the items we will be 'inputting' into the output buses. These itemstacks are actually the recipe outputs. + ConcurrentSet> aInputMap = new ConcurrentHashSet>(); + + // Iterate over the outputs, calculating require stack spacing they will require. + for (int i=0;i 64) { + int aSlotsNeedsForThisStack = (int) Math.ceil((double) ((float) aStackSize / 64f)); + // Should round up and add as many stacks as required nicely. + aRecipeSlotsRequired += aSlotsNeedsForThisStack; + for (int o=0;o 64 ? 64 : aStackSize; + aY = aY.copy(); + aY.stackSize = 0; + aInputMap.add(new FlexiblePair(aY, aStackToRemove)); + } + } + else { + // Only requires one slot + aRecipeSlotsRequired++; + aY = aY.copy(); + aY.stackSize = 0; + aInputMap.add(new FlexiblePair(aY, aStackSize)); + } + } + } + + // We have items to add to the output buses. See if any are not full stacks and see if we can make them full. + if (aInputMap.size() > 0) { + // Iterate over the current stored items in the Output busses, if any match and are not full, we can try account for merging. + busItems: for (FlexiblePair y : aItemMap) { + // Iterate over the 'inputs', we can safely remove these as we go. + outputItems: for (FlexiblePair u : aInputMap) { + // Create local vars for readability. + ItemStack aOutputBusStack = y.getKey(); + ItemStack aOutputStack = u.getKey(); + // Stacks match, including NBT. + if (GT_Utility.areStacksEqual(aOutputBusStack, aOutputStack, false)) { + // Stack Matches, but it's full, continue. + if (aOutputBusStack.stackSize >= 64) { + // This stack is full, no point checking it. + continue busItems; + } + else { + // We can merge these two stacks without any hassle. + if ((aOutputBusStack.stackSize + aOutputStack.stackSize) <= 64) { + // Update the stack size in the bus storage map. + y.setValue(aOutputBusStack.stackSize + aOutputStack.stackSize); + // Remove the 'input' stack from the recipe outputs, so we don't try count it again. + aInputMap.remove(u); + continue outputItems; + } + // Stack merging is too much, so we fill this stack, leave the remainder. + else { + int aRemainder = (aOutputBusStack.stackSize + aOutputStack.stackSize) - 64; + // Update the stack size in the bus storage map. + y.setValue(64); + // Create a new object to iterate over later, with the remainder data; + FlexiblePair t = new FlexiblePair(u.getKey(), aRemainder); + // Remove the 'input' stack from the recipe outputs, so we don't try count it again. + aInputMap.remove(u); + // Add the remainder stack. + aInputMap.add(t); + continue outputItems; + } + } + } + else { + continue outputItems; + } + } + } + } + + // We have stacks that did not merge, do we have space for them? + if (aInputMap.size() > 0) { + if (aInputMap.size() > aInputBusSlotsFree) { + aParallelRecipes = (int) Math.floor((double) aInputBusSlotsFree/aInputMap.size() * aParallelRecipes); + // We do not have enough free slots in total to accommodate the remaining managed stacks. + log(" Free: "+aInputBusSlotsFree+", Required: "+aInputMap.size()); + if(aParallelRecipes == 0) { + log("Failed to find enough space for all item outputs."); + return 0; + } + + } + } + + /* + * End Item Management + */ + + } + + + + + + /* ======================================== + * Fluid Management + * ======================================== + */ + + + + if (aDoesOutputFluids) { + log("We have Fluids to output."); + // How many slots are free across all the output buses? + int aFluidHatches = 0; + int aEmptyFluidHatches = 0; + int aFullFluidHatches = 0; + // Create Map for Fluid Output + ArrayList> aOutputHatches = new ArrayList>(); + for (final GT_MetaTileEntity_Hatch_Output tBus : this.mOutputHatches) { + if (!isValidMetaTileEntity(tBus)) { + continue; + } + aFluidHatches++; + // Map the Hatch with the space left for easy checking later. + if (tBus.getFluid() == null) { + aOutputHatches.add(new Triplet(tBus, null, tBus.getCapacity())); + } + else { + int aSpaceLeft = tBus.getCapacity() - tBus.getFluidAmount(); + aOutputHatches.add(new Triplet(tBus, tBus.getFluid(), aSpaceLeft)); + } + } + // Create a map of all the fluids we would like to output, we can iterate over this and see how many we can merge into existing hatch stacks. + ArrayList aOutputFluids = new ArrayList(); + // Ugly ass boxing + aOutputFluids.addAll(new AutoMap(aFluidOutputs)); + // Iterate the Hatches, updating their 'stored' data. + //for (Triplet aHatchData : aOutputHatches) { + for (int i = 0;i aNewHatchData = new Triplet(aHatch, aNewHatchStack, aNewHatchStack.amount); + //aOutputHatches.add(aNewHatchData); + break; + } + // We can fill this hatch perfectly (rare case), may as well add it directly to the full list. + else if (aSpaceLeftInHatch == aFluidToPutIntoHatch) { + // Copy Old Stack + FluidStack aNewHatchStack = aHatchStack.copy(); + // Add in amount from output stack + aNewHatchStack.amount += aFluidToPutIntoHatch; + // Remove fluid from output list, merge success + aOutputFluids.remove(aOutputFluids.get(j)); + j--; + // Remove hatch from hatch list, data is now invalid. + aOutputHatches.remove(aOutputHatches.get(i)); + i--; + // Re-add hatch to hatch list, with new data. + Triplet aNewHatchData = new Triplet(aHatch, aNewHatchStack, aNewHatchStack.amount); + aOutputHatches.add(aNewHatchData); + break; + } + // We have more space than we need to merge, so we remove the stack from the output list and update the hatch list. + else { + // Copy Old Stack + FluidStack aNewHatchStack = aHatchStack.copy(); + // Add in amount from output stack + aNewHatchStack.amount += aFluidToPutIntoHatch; + // Remove fluid from output list, merge success + aOutputFluids.remove(aOutputFluids.get(j)); + j--; + // Remove hatch from hatch list, data is now invalid. + aOutputHatches.remove(aOutputHatches.get(i)); + i--; + // Re-add hatch to hatch list, with new data. + Triplet aNewHatchData = new Triplet(aHatch, aNewHatchStack, aNewHatchStack.amount); + aOutputHatches.add(aNewHatchData); + // Check next fluid + continue; + } + + } + else { + continue; + } + } + } + } + + for (Triplet aFreeHatchCheck : aOutputHatches) { + // Free Hatch + if (aFreeHatchCheck.getValue_2() == null || aFreeHatchCheck.getValue_3() == 0 || aFreeHatchCheck.getValue_1().getFluid() == null) { + aEmptyFluidHatches++; + } + } + + // We have Fluid Stacks we did not merge. Do we have space? + log("fluids to output "+aOutputFluids.size()+" empty hatches "+aEmptyFluidHatches); + if (aOutputFluids.size() > 0) { + // Not enough space to add fluids. + if (aOutputFluids.size() > aEmptyFluidHatches) { + aParallelRecipes = (int) Math.floor((double) aEmptyFluidHatches/aOutputFluids.size() * aParallelRecipes); + log("Failed to find enough space for all fluid outputs. Free: "+aEmptyFluidHatches+", Required: "+aOutputFluids.size()); + return 0; + + } + } + + /* + * End Fluid Management + */ + } + + return aParallelRecipes; + } + + + /* + * Handle I/O with custom hatches + */ + + @Override + public boolean depleteInput(FluidStack aLiquid) { + if (aLiquid == null) return false; + for (GT_MetaTileEntity_Hatch_Input tHatch : mSteamInputFluids) { + tHatch.mRecipeMap = getRecipeMap(); + if (isValidMetaTileEntity(tHatch)) { + FluidStack tLiquid = tHatch.getFluid(); + if (tLiquid != null && tLiquid.isFluidEqual(aLiquid)) { + tLiquid = tHatch.drain(aLiquid.amount, false); + if (tLiquid != null && tLiquid.amount >= aLiquid.amount) { + tLiquid = tHatch.drain(aLiquid.amount, true); + return tLiquid != null && tLiquid.amount >= aLiquid.amount; + } + } + } + } + return false; + } + + @Override + public boolean depleteInput(ItemStack aStack) { + if (GT_Utility.isStackInvalid(aStack)) return false; + FluidStack aLiquid = GT_Utility.getFluidForFilledItem(aStack, true); + if (aLiquid != null) return depleteInput(aLiquid); + for (GT_MetaTileEntity_Hatch_Input tHatch : mSteamInputFluids) { + tHatch.mRecipeMap = getRecipeMap(); + if (isValidMetaTileEntity(tHatch)) { + if (GT_Utility.areStacksEqual(aStack, tHatch.getBaseMetaTileEntity().getStackInSlot(0))) { + if (tHatch.getBaseMetaTileEntity().getStackInSlot(0).stackSize >= aStack.stackSize) { + tHatch.getBaseMetaTileEntity().decrStackSize(0, aStack.stackSize); + return true; + } + } + } + } + for (GT_MetaTileEntity_Hatch_Steam_BusInput tHatch : mSteamInputs) { + tHatch.mRecipeMap = getRecipeMap(); + if (isValidMetaTileEntity(tHatch)) { + for (int i = tHatch.getBaseMetaTileEntity().getSizeInventory() - 1; i >= 0; i--) { + if (GT_Utility.areStacksEqual(aStack, tHatch.getBaseMetaTileEntity().getStackInSlot(i))) { + if (tHatch.getBaseMetaTileEntity().getStackInSlot(0).stackSize >= aStack.stackSize) { + tHatch.getBaseMetaTileEntity().decrStackSize(0, aStack.stackSize); + return true; + } + } + } + } + } + return false; + } + + @Override + public ArrayList getStoredFluids() { + ArrayList rList = new ArrayList(); + for (GT_MetaTileEntity_Hatch_Input tHatch : mSteamInputFluids) { + tHatch.mRecipeMap = getRecipeMap(); + if (isValidMetaTileEntity(tHatch) && tHatch.getFillableStack() != null) { + rList.add(tHatch.getFillableStack()); + } + } + return rList; + } + + @Override + public ArrayList getStoredInputs() { + ArrayList rList = new ArrayList(); + for (GT_MetaTileEntity_Hatch_Steam_BusInput tHatch : mSteamInputs) { + tHatch.mRecipeMap = getRecipeMap(); + if (isValidMetaTileEntity(tHatch)) { + for (int i = tHatch.getBaseMetaTileEntity().getSizeInventory() - 1; i >= 0; i--) { + if (tHatch.getBaseMetaTileEntity().getStackInSlot(i) != null) { + rList.add(tHatch.getBaseMetaTileEntity().getStackInSlot(i)); + } + } + } + } + return rList; + } + + @Override + public boolean addOutput(ItemStack aStack) { + if (GT_Utility.isStackInvalid(aStack)) return false; + aStack = GT_Utility.copy(aStack); + boolean outputSuccess = true; + while (outputSuccess && aStack.stackSize > 0) { + outputSuccess = false; + ItemStack single = aStack.splitStack(1); + for (GT_MetaTileEntity_Hatch_Steam_BusOutput tHatch : mSteamOutputs) { + if (!outputSuccess && isValidMetaTileEntity(tHatch)) { + for (int i = tHatch.getSizeInventory() - 1; i >= 0 && !outputSuccess; i--) { + if (tHatch.getBaseMetaTileEntity().addStackToSlot(i, single)) outputSuccess = true; + } + } + } + for (GT_MetaTileEntity_Hatch_Output tHatch : mOutputHatches) { + if (!outputSuccess && isValidMetaTileEntity(tHatch) && tHatch.outputsItems()) { + if (tHatch.getBaseMetaTileEntity().addStackToSlot(1, single)) outputSuccess = true; + } + } + } + return outputSuccess; + } + + @Override + public ArrayList getStoredOutputs() { + ArrayList rList = new ArrayList(); + for (GT_MetaTileEntity_Hatch_Steam_BusOutput tHatch : mSteamOutputs) { + if (isValidMetaTileEntity(tHatch)) { + for (int i = tHatch.getBaseMetaTileEntity().getSizeInventory() - 1; i >= 0; i--) { + rList.add(tHatch.getBaseMetaTileEntity().getStackInSlot(i)); + } + } + } + return rList; + } + + @Override + public void updateSlots() { + for (GT_MetaTileEntity_Hatch_Input tHatch : mSteamInputFluids) + if (isValidMetaTileEntity(tHatch)) tHatch.updateSlots(); + for (GT_MetaTileEntity_Hatch_Steam_BusInput tHatch : mSteamInputs) + if (isValidMetaTileEntity(tHatch)) tHatch.updateSlots(); + } + } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/steam/GregtechMetaTileEntity_SteamMacerator.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/steam/GregtechMetaTileEntity_SteamMacerator.java index 6e87e4c191..06d63867da 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/steam/GregtechMetaTileEntity_SteamMacerator.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/steam/GregtechMetaTileEntity_SteamMacerator.java @@ -1,6 +1,6 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing.steam; -import static gregtech.api.GregTech_API.sBlockCasings4; +import static gregtech.api.GregTech_API.sBlockCasings1; import gregtech.api.enums.ItemList; import gregtech.api.enums.Textures; @@ -16,7 +16,7 @@ import net.minecraftforge.common.util.ForgeDirection; public class GregtechMetaTileEntity_SteamMacerator extends GregtechMeta_SteamMultiBase { - private String mCasingName = "Robust Tungstensteel Machine Casing"; + private String mCasingName = "Bronze Plated Bricks"; public GregtechMetaTileEntity_SteamMacerator(String aName) { super(aName); @@ -37,12 +37,12 @@ public class GregtechMetaTileEntity_SteamMacerator extends GregtechMeta_SteamMul @Override protected GT_RenderedTexture getFrontOverlay() { - return new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_STEAM_MACERATOR); + return new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_TOP_STEAM_MACERATOR); } @Override protected GT_RenderedTexture getFrontOverlayActive() { - return new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_STEAM_MACERATOR_ACTIVE); + return new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_TOP_STEAM_MACERATOR_ACTIVE); } @Override @@ -53,16 +53,17 @@ public class GregtechMetaTileEntity_SteamMacerator extends GregtechMeta_SteamMul @Override public String[] getTooltip() { if (mCasingName.contains("gt.blockcasings")) { - mCasingName = ItemList.Casing_RobustTungstenSteel.get(1).getDisplayName(); + mCasingName = ItemList.Casing_BronzePlatedBricks.get(1).getDisplayName(); } return new String[]{ "Controller Block for the Steam Macerator", "Macerates "+getMaxParallelRecipes()+" ores at a time", "Size(WxHxD): 3x3x3 (Hollow), Controller (Front centered)", "1x Input Bus (Any casing)", - "1x Steam Hatch (Any casing)", "1x Output Bus (Any casing)", - mCasingName+"s for the rest (16 at least!)" + "1x Steam Hatch (Any casing)", + mCasingName+" for the rest (14 at least!)", + TAG_HIDE_MAINT }; } @@ -93,9 +94,9 @@ public class GregtechMetaTileEntity_SteamMacerator extends GregtechMeta_SteamMul Block aBlock = aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j); int aMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j); - if (!isValidBlockForStructure(tTileEntity, 48, true, aBlock, aMeta, - sBlockCasings4, 0)) { - Logger.INFO("Bad centrifuge casing"); + if (!isValidBlockForStructure(tTileEntity, 10, true, aBlock, aMeta, + sBlockCasings1, 10)) { + Logger.INFO("Bad macerator casing"); return false; } ++tAmount; @@ -104,9 +105,30 @@ public class GregtechMetaTileEntity_SteamMacerator extends GregtechMeta_SteamMul } } } - return tAmount >= 10; + if (tAmount >= 14) { + fixAllMaintenanceIssue(); + } + return tAmount >= 14; } } + + @Override + public ItemStack[] getOutputItems(GT_Recipe aRecipe) { + // Collect output item types + ItemStack[] tOutputItems = new ItemStack[1]; + for (int h = 0; h < 1; h++) { + if (aRecipe.getOutput(h) != null) { + tOutputItems[h] = aRecipe.getOutput(h).copy(); + tOutputItems[h].stackSize = 0; + } + } + return tOutputItems; + } + + @Override + public int getOutputCount(ItemStack[] aOutputs) { + return 1; + } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechCustomHatches.java b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechCustomHatches.java index 2c622b9d8e..677a47639c 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechCustomHatches.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechCustomHatches.java @@ -74,7 +74,18 @@ public class GregtechCustomHatches { // 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 + // to + // resitrct + // hatch + // to + 64000, // Capacity + 31040, // ID + "hatch.steam.input.tier.00", // unlocal name + "Steam Hatch" // Local name + ).getStackForm(1L)); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechSteamMultis.java b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechSteamMultis.java index cdb9eddea8..add0400d87 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechSteamMultis.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechSteamMultis.java @@ -2,6 +2,8 @@ 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_Steam_BusInput; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Steam_BusOutput; import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing.steam.GregtechMetaTileEntity_SteamMacerator; public class GregtechSteamMultis { @@ -10,8 +12,10 @@ public class GregtechSteamMultis { Logger.INFO("Gregtech5u Content | Registering Steam Multiblocks."); - GregtechItemList.Controller_SteamMaceratorMulti.set(new GregtechMetaTileEntity_SteamMacerator(31030, "gtpp.multimachine.steam.macerator", "Steam Grinder").getStackForm(1L)); - + GregtechItemList.Controller_SteamMaceratorMulti.set(new GregtechMetaTileEntity_SteamMacerator(31041, "gtpp.multimachine.steam.macerator", "Steam Grinder").getStackForm(1L)); + + GregtechItemList.Hatch_Input_Bus_Steam.set(new GT_MetaTileEntity_Hatch_Steam_BusInput(31046, "hatch.input_bus.tier.steam", "Input Bus (Steam)", 0).getStackForm(1L)); + GregtechItemList.Hatch_Output_Bus_Steam.set(new GT_MetaTileEntity_Hatch_Steam_BusOutput(31047, "hatch.output_bus.tier.steam", "Output Bus (Steam)", 0).getStackForm(1L)); } -- cgit From ce84ae027d07500fd91f5b5708d885e4447eceab Mon Sep 17 00:00:00 2001 From: Alkalus Date: Mon, 25 May 2020 16:25:51 +0100 Subject: % Changed Steam Multi recipes to use Tumbaga instead of Potin. % Changed some tooltips so that it's more obvious that steam things are ONLY for steam. $ Fixed handling of Fluid Name handling on Custom Fluid Hatches. --- .../gtPlusPlus/core/recipe/RECIPES_Machines.java | 14 ++--- .../GT_MetaTileEntity_Hatch_Steam_BusInput.java | 3 +- .../GT_MetaTileEntity_Hatch_Steam_BusOutput.java | 3 +- .../GT_MetaTileEntity_Hatch_CustomFluidBase.java | 68 ++++++++++++---------- 4 files changed, 48 insertions(+), 40 deletions(-) (limited to 'src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations') diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java index cc51a9dcb2..6c6eedfb54 100644 --- a/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java @@ -633,9 +633,9 @@ public class RECIPES_Machines { ItemStack aBronzeBricks = ItemUtils.simpleMetaStack(GregTech_API.sBlockCasings1, 10, 1); // Steam Macerator Multi RecipeUtils.addShapedGregtechRecipe( - aBronzeBricks, ALLOY.POTIN.getGear(1), aBronzeBricks, - aBronzeBricks, ALLOY.POTIN.getFrameBox(1), aBronzeBricks, - aBronzeBricks, ALLOY.POTIN.getGear(1), aBronzeBricks, + aBronzeBricks, ALLOY.TUMBAGA.getGear(1), aBronzeBricks, + aBronzeBricks, ALLOY.TUMBAGA.getFrameBox(1), aBronzeBricks, + aBronzeBricks, ALLOY.TUMBAGA.getGear(1), aBronzeBricks, GregtechItemList.Controller_SteamMaceratorMulti.get(1)); // Steam Hatch @@ -647,15 +647,15 @@ public class RECIPES_Machines { // Steam Input Bus RecipeUtils.addShapedGregtechRecipe( - "plateBronze", ALLOY.POTIN.getPlate(1), "plateBronze", - "plateTin", ItemUtils.getSimpleStack(Blocks.chest), "plateTin", - "plateBronze", ALLOY.POTIN.getPlate(1), "plateBronze", + "plateBronze", ALLOY.TUMBAGA.getPlate(1), "plateBronze", + "plateTin", ItemUtils.getSimpleStack(Blocks.hopper), "plateTin", + "plateBronze", ALLOY.TUMBAGA.getPlate(1), "plateBronze", GregtechItemList.Hatch_Input_Bus_Steam.get(1)); // Steam Output Bus RecipeUtils.addShapedGregtechRecipe( "plateBronze", "plateTin", "plateBronze", - ALLOY.POTIN.getPlate(1), ItemUtils.getSimpleStack(Blocks.chest), ALLOY.POTIN.getPlate(1), + ALLOY.TUMBAGA.getPlate(1), ItemUtils.getSimpleStack(Blocks.hopper), ALLOY.TUMBAGA.getPlate(1), "plateBronze", "plateTin", "plateBronze", GregtechItemList.Hatch_Output_Bus_Steam.get(1)); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Steam_BusInput.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Steam_BusInput.java index f358d13930..fb67b48e7f 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Steam_BusInput.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Steam_BusInput.java @@ -24,7 +24,8 @@ public class GT_MetaTileEntity_Hatch_Steam_BusInput extends GT_MetaTileEntity_Ha super(aID, aName, aNameRegional, aTier, getSlots(aTier), new String[]{ "Item Input for Steam Multiblocks", "Shift + right click with screwdriver to toggle automatic item shuffling", - "Capacity: 4 stacks"}); + "Capacity: 4 stacks", + "Does not work with non-steam multiblocks"}); } public GT_MetaTileEntity_Hatch_Steam_BusInput(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Steam_BusOutput.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Steam_BusOutput.java index 37dc016c1e..fb626cb817 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Steam_BusOutput.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Steam_BusOutput.java @@ -15,7 +15,8 @@ import net.minecraft.item.ItemStack; public class GT_MetaTileEntity_Hatch_Steam_BusOutput extends GT_MetaTileEntity_Hatch { public GT_MetaTileEntity_Hatch_Steam_BusOutput(int aID, String aName, String aNameRegional, int aTier) { super(aID, aName, aNameRegional, aTier, 4, new String[]{"Item Output for Steam Multiblocks", - "Capacity: 4 stacks"}); + "Capacity: 4 stacks", + "Does not work with non-steam multiblocks"}); } public GT_MetaTileEntity_Hatch_Steam_BusOutput(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GT_MetaTileEntity_Hatch_CustomFluidBase.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GT_MetaTileEntity_Hatch_CustomFluidBase.java index c9b98a6a64..127d4c8407 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GT_MetaTileEntity_Hatch_CustomFluidBase.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GT_MetaTileEntity_Hatch_CustomFluidBase.java @@ -1,6 +1,7 @@ package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base; import gregtech.api.util.GT_Utility; +import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.util.minecraft.FluidUtils; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; @@ -15,7 +16,7 @@ import gregtech.api.interfaces.IIconContainer; import gregtech.api.interfaces.ITexture; public class GT_MetaTileEntity_Hatch_CustomFluidBase extends GT_MetaTileEntity_Hatch_Input { - + public final Fluid mLockedFluid; public final int mFluidCapacity; @@ -64,46 +65,51 @@ public class GT_MetaTileEntity_Hatch_CustomFluidBase extends GT_MetaTileEntity_H protected FluidStack mLockedStack = null; protected Integer mLockedTemp = null; protected String mTempMod = null; - + @Override public String[] getDescription() { if (mLockedStack == null) { mLockedStack = FluidUtils.getFluidStack(mLockedFluid, 1); } - if (mLockedTemp == null) { - if (mLockedStack != null) { - mLockedTemp = mLockedStack.getFluid().getTemperature(); - } + int aFluidTemp = 0; + boolean isSteam = false; + if (mLockedFluid != null) { + aFluidTemp = mLockedFluid.getTemperature(); + mTempMod = mLockedFluid.getName(); } - if (mLockedTemp != null) { - if (mLockedTemp <= -3000) { - mTempMod = ""+EnumChatFormatting.DARK_PURPLE; - } - else if (mLockedTemp >= -2999 && mLockedTemp <= -500) { - mTempMod = ""+EnumChatFormatting.DARK_BLUE; - } - else if (mLockedTemp >= -499 && mLockedTemp <= -50) { - mTempMod = ""+EnumChatFormatting.BLUE; - } - else if (mLockedTemp >= 30 && mLockedTemp <= 300) { - mTempMod = ""+EnumChatFormatting.AQUA; - } - else if (mLockedTemp >= 301 && mLockedTemp <= 800) { - mTempMod = ""+EnumChatFormatting.YELLOW; - } - else if (mLockedTemp >= 801 && mLockedTemp <= 1500) { - mTempMod = ""+EnumChatFormatting.GOLD; - } - else if (mLockedTemp >= 1501) { - mTempMod = ""+EnumChatFormatting.RED; - } + if (mTempMod.toLowerCase().equals("steam")) { + isSteam = true; } + + EnumChatFormatting aColour = EnumChatFormatting.BLUE; + if (aFluidTemp <= -3000) { + aColour = EnumChatFormatting.DARK_PURPLE; + } + else if (aFluidTemp >= -2999 && aFluidTemp <= -500) { + aColour = EnumChatFormatting.DARK_BLUE; + } + else if (aFluidTemp >= -499 && aFluidTemp <= -50) { + aColour = EnumChatFormatting.BLUE; + } + else if (aFluidTemp >= 30 && aFluidTemp <= 300) { + aColour = EnumChatFormatting.AQUA; + } + else if (aFluidTemp >= 301 && aFluidTemp <= 800) { + aColour = EnumChatFormatting.YELLOW; + } + else if (aFluidTemp >= 801 && aFluidTemp <= 1500) { + aColour = EnumChatFormatting.GOLD; + } + else if (aFluidTemp >= 1501) { + aColour = EnumChatFormatting.RED; + } + String aFluidName = "Accepted Fluid: " + aColour + (mLockedStack != null ? mLockedStack.getLocalizedName() : "Empty") + EnumChatFormatting.RESET; String[] s2 = new String[]{ - "Fluid Input for Multiblocks", + "Fluid Input for "+(isSteam ? "Steam " : "")+"Multiblocks", "Capacity: " + getCapacity()+"L", - "Accepted Fluid: " + mTempMod + mLockedStack != null ? mLockedStack.getLocalizedName() : "Empty" - }; + aFluidName + }; return s2; } -- 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/api/metatileentity/implementations') 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 96a83ee47f994c922aba625b67645661bc8cb4fe Mon Sep 17 00:00:00 2001 From: Alkalus Date: Tue, 2 Jun 2020 13:46:43 +0100 Subject: - Removed placeholder map which was used to prevent BW crashes. % Made the Simple washer ignore certain impure dusts if GTNH is loaded. % Updated ChemPlant User manual to reflect requirement of Catalyst Bus. $ Fixed handling of recipe maps which don't use cells. $ Fixed Chem Plant not actually processing recipes. $ Made the Catalyst Hatch a lower tier. (Fixes Chem Plant requiring ZPM tier hulls) --- src/Java/gregtech/api/util/GTPP_Recipe.java | 2 +- src/Java/gtPlusPlus/GTplusplus.java | 251 ++++++++++++++------- src/Java/gtPlusPlus/core/handler/BookHandler.java | 3 +- .../gtPlusPlus/core/recipe/RECIPES_GREGTECH.java | 4 +- .../GT_MetaTileEntity_Hatch_Catalysts.java | 6 +- .../chemplant/GregtechMTE_ChemicalPlant.java | 233 ++++++++++++++++--- .../RecipeGen_MultisUsingFluidInsteadOfCells.java | 182 +++++++++++++++ .../gregtech/GregtechSimpleWasher.java | 9 +- 8 files changed, 565 insertions(+), 125 deletions(-) create mode 100644 src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_MultisUsingFluidInsteadOfCells.java (limited to 'src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations') diff --git a/src/Java/gregtech/api/util/GTPP_Recipe.java b/src/Java/gregtech/api/util/GTPP_Recipe.java index 04f593d797..b44b05985b 100644 --- a/src/Java/gregtech/api/util/GTPP_Recipe.java +++ b/src/Java/gregtech/api/util/GTPP_Recipe.java @@ -353,7 +353,7 @@ public class GTPP_Recipe extends GT_Recipe implements IComparableRecipe { //Basic Washer Map public static final GTPP_Recipe_Map_Internal sSimpleWasherRecipes = new GTPP_Recipe_Map_Internal(new HashSet(3), "gt.recipe.simplewasher", "Simple Dust Washer", null, RES_PATH_GUI + "basicmachines/PotionBrewer", 1, 1, 0, 0, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sSimpleWasherRecipes_FakeFuckBW = new GT_Recipe_Map(new HashSet(3), "gt.recipe.simplewasher", "Fuck you Bart", null, RES_PATH_GUI + "basicmachines/PotionBrewer", 1, 1, 0, 0, 1, E, 1, E, true, false); + //public static final GT_Recipe_Map sSimpleWasherRecipes_FakeFuckBW = new GT_Recipe_Map(new HashSet(3), "gt.recipe.simplewasher", "Fuck you Bart", null, RES_PATH_GUI + "basicmachines/PotionBrewer", 1, 1, 0, 0, 1, E, 1, E, true, false); public static final GTPP_Recipe_Map sChemicalPlantRecipes = new GTPP_Recipe_Map( new HashSet(100), diff --git a/src/Java/gtPlusPlus/GTplusplus.java b/src/Java/gtPlusPlus/GTplusplus.java index 0b34e77ed1..0df731c548 100644 --- a/src/Java/gtPlusPlus/GTplusplus.java +++ b/src/Java/gtPlusPlus/GTplusplus.java @@ -55,6 +55,7 @@ import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtTools; import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.chemplant.GregtechMTE_ChemicalPlant; import gtPlusPlus.xmod.gregtech.loaders.GT_Material_Loader; import gtPlusPlus.xmod.gregtech.loaders.RecipeGen_BlastSmelterGT_GTNH; +import gtPlusPlus.xmod.gregtech.loaders.RecipeGen_MultisUsingFluidInsteadOfCells; import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechMiniRaFusion; import gtPlusPlus.xmod.thaumcraft.commands.CommandDumpAspects; import net.minecraft.launchwrapper.Launch; @@ -65,12 +66,9 @@ import net.minecraft.util.IIcon; public class GTplusplus implements ActionListener { public static enum INIT_PHASE { - SUPER(null), - PRE_INIT(SUPER), - INIT(PRE_INIT), - POST_INIT(INIT), - SERVER_START(POST_INIT), - STARTED(SERVER_START); + SUPER(null), PRE_INIT(SUPER), INIT(PRE_INIT), POST_INIT( + INIT + ), SERVER_START(POST_INIT), STARTED(SERVER_START); protected boolean mIsPhaseActive = false; private final INIT_PHASE mPrev; @@ -78,7 +76,7 @@ public class GTplusplus implements ActionListener { mPrev = aPreviousPhase; } - public synchronized final boolean isPhaseActive() { + public synchronized final boolean isPhaseActive() { return mIsPhaseActive; } public synchronized final void setPhaseActive(boolean aIsPhaseActive) { @@ -94,17 +92,17 @@ public class GTplusplus implements ActionListener { public static INIT_PHASE CURRENT_LOAD_PHASE = INIT_PHASE.SUPER; - //Mod Instance + // Mod Instance @Mod.Instance(CORE.MODID) public static GTplusplus instance; - //Material Loader + // Material Loader public static GT_Material_Loader mGregMatLoader; - //GT_Proxy instance + // GT_Proxy instance protected static Meta_GT_Proxy mGregProxy; - //GT++ Proxy Instances + // GT++ Proxy Instances @SidedProxy(clientSide = "gtPlusPlus.core.proxy.ClientProxy", serverSide = "gtPlusPlus.core.proxy.ServerProxy") public static CommonProxy proxy; @@ -113,14 +111,32 @@ public class GTplusplus implements ActionListener { public static void loadTextures() { Logger.INFO("Loading some textures on the client."); // Tools - Logger.WARNING("Processing texture: " + TexturesGtTools.SKOOKUM_CHOOCHER.getTextureFile().getResourcePath()); - Logger.WARNING("Processing texture: " + TexturesGtTools.ANGLE_GRINDER.getTextureFile().getResourcePath()); - Logger.WARNING("Processing texture: " + TexturesGtTools.ELECTRIC_SNIPS.getTextureFile().getResourcePath()); - Logger.WARNING("Processing texture: " + TexturesGtTools.ELECTRIC_LIGHTER.getTextureFile().getResourcePath()); - Logger.WARNING("Processing texture: " + TexturesGtTools.ELECTRIC_BUTCHER_KNIFE.getTextureFile().getResourcePath()); + Logger.WARNING( + "Processing texture: " + + TexturesGtTools.SKOOKUM_CHOOCHER.getTextureFile().getResourcePath() + ); + Logger.WARNING( + "Processing texture: " + + TexturesGtTools.ANGLE_GRINDER.getTextureFile().getResourcePath() + ); + Logger.WARNING( + "Processing texture: " + + TexturesGtTools.ELECTRIC_SNIPS.getTextureFile().getResourcePath() + ); + Logger.WARNING( + "Processing texture: " + + TexturesGtTools.ELECTRIC_LIGHTER.getTextureFile().getResourcePath() + ); + Logger.WARNING( + "Processing texture: " + + TexturesGtTools.ELECTRIC_BUTCHER_KNIFE.getTextureFile().getResourcePath() + ); // Blocks - Logger.WARNING("Processing texture: " + TexturesGtBlock.Casing_Machine_Dimensional.getTextureFile().getResourcePath()); + Logger.WARNING( + "Processing texture: " + + TexturesGtBlock.Casing_Machine_Dimensional.getTextureFile().getResourcePath() + ); } public GTplusplus() { @@ -132,35 +148,45 @@ public class GTplusplus implements ActionListener { @Mod.EventHandler public void preInit(final FMLPreInitializationEvent event) { INIT_PHASE.PRE_INIT.setPhaseActive(true); - Logger.INFO("Loading " + CORE.name + " "+CORE.VERSION+" on Gregtech "+Utils.getGregtechVersionAsString()); - //Load all class objects within the plugin package. + Logger.INFO( + "Loading " + CORE.name + " " + CORE.VERSION + " on Gregtech " + + Utils.getGregtechVersionAsString() + ); + // Load all class objects within the plugin package. Core_Manager.veryEarlyInit(); PacketHandler.init(); - if(!Utils.isServer()){ + if (!Utils.isServer()) { enableCustomCapes = true; } - //Give this a go mate. - //initAnalytics(); + // Give this a go mate. + // initAnalytics(); setupMaterialBlacklist(); - //setupMaterialWhitelist(); + // setupMaterialWhitelist(); - //HTTP Requests + // HTTP Requests if (CORE.ConfigSwitches.enableUpdateChecker) { - CORE.MASTER_VERSION = NetworkUtils.getContentFromURL("https://raw.githubusercontent.com/draknyte1/GTplusplus/master/Recommended.txt").toLowerCase(); + CORE.MASTER_VERSION = NetworkUtils.getContentFromURL( + "https://raw.githubusercontent.com/draknyte1/GTplusplus/master/Recommended.txt" + ).toLowerCase(); CORE.USER_COUNTRY = GeoUtils.determineUsersCountry(); } // Handle GT++ Config - ConfigHandler.handleConfigFile(event); - - //Check for Dev - CORE.DEVENV = (Boolean) Launch.blackboard.get("fml.deobfuscatedEnvironment"); - if (enableUpdateChecker){ - Logger.INFO("Latest is " + CORE.MASTER_VERSION + ". Updated? " + Utils.isModUpToDate()); + ConfigHandler.handleConfigFile(event); + + // Check for Dev + CORE.DEVENV = (Boolean) Launch.blackboard.get( + "fml.deobfuscatedEnvironment" + ); + if (enableUpdateChecker) { + Logger.INFO( + "Latest is " + CORE.MASTER_VERSION + ". Updated? " + + Utils.isModUpToDate() + ); } - //Utils.LOG_INFO("User's Country: " + CORE.USER_COUNTRY); + // Utils.LOG_INFO("User's Country: " + CORE.USER_COUNTRY); Utils.registerEvent(new LoginEventHandler()); Utils.registerEvent(new MissingMappingsEvent()); @@ -182,7 +208,7 @@ public class GTplusplus implements ActionListener { Meta_GT_Proxy.init(); Core_Manager.init(); - //Used by foreign players to generate .lang files for translation. + // Used by foreign players to generate .lang files for translation. if (CORE.ConfigSwitches.dumpItemAndBlockData) { LocaleUtils.generateFakeLocaleFile(); } @@ -198,21 +224,32 @@ public class GTplusplus implements ActionListener { BookHandler.runLater(); Meta_GT_Proxy.postInit(); Core_Manager.postInit(); - //SprinklerHandler.registerModFerts(); + // SprinklerHandler.registerModFerts(); ItemGiantEgg.postInit(ModItems.itemBigEgg); BlockEventHandler.init(); - GTPP_Recipe.reInit(); - - Logger.INFO("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); - Logger.INFO("| Recipes succesfully Loaded: " + RegistrationHandler.recipesSuccess + " | Failed: " - + RegistrationHandler.recipesFailed + " |"); - Logger.INFO("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); - Logger.INFO("Finally, we are finished. Have some cripsy bacon as a reward."); + GTPP_Recipe.reInit(); + + Logger.INFO( + "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" + ); + Logger.INFO( + "| Recipes succesfully Loaded: " + + RegistrationHandler.recipesSuccess + " | Failed: " + + RegistrationHandler.recipesFailed + " |" + ); + Logger.INFO( + "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" + ); + Logger.INFO( + "Finally, we are finished. Have some cripsy bacon as a reward." + ); } @EventHandler - public synchronized void serverStarting(final FMLServerStartingEvent event) { + public synchronized void serverStarting( + final FMLServerStartingEvent event + ) { INIT_PHASE.SERVER_START.setPhaseActive(true); event.registerServerCommand(new CommandMath()); event.registerServerCommand(new CommandEnableDebugWhileRunning()); @@ -228,7 +265,9 @@ public class GTplusplus implements ActionListener { } @Mod.EventHandler - public synchronized void serverStopping(final FMLServerStoppingEvent event) { + public synchronized void serverStopping( + final FMLServerStoppingEvent event + ) { Core_Manager.serverStop(); if (GregtechBufferThread.mBufferThreadAllocation.size() > 0) { for (GregtechBufferThread i : GregtechBufferThread.mBufferThreadAllocation.values()) { @@ -244,11 +283,16 @@ public class GTplusplus implements ActionListener { } - /** - * This {@link EventHandler} is called after the {@link FMLPostInitializationEvent} stages of all loaded mods executes successfully. - * {@link #onLoadComplete(FMLLoadCompleteEvent)} exists to inject recipe generation after Gregtech and all other mods are entirely loaded and initialized. - * @param event - The {@link EventHandler} object passed through from FML to {@link #GTplusplus()}'s {@link #instance}. + * This {@link EventHandler} is called after the + * {@link FMLPostInitializationEvent} stages of all loaded mods executes + * successfully. {@link #onLoadComplete(FMLLoadCompleteEvent)} exists to + * inject recipe generation after Gregtech and all other mods are entirely + * loaded and initialized. + * + * @param event + * - The {@link EventHandler} object passed through from FML to + * {@link #GTplusplus()}'s {@link #instance}. */ @Mod.EventHandler public void onLoadComplete(FMLLoadCompleteEvent event) { @@ -259,17 +303,19 @@ public class GTplusplus implements ActionListener { Logger.INFO("Passed verification checks."); } - @Mod.EventHandler - public void onIDChangingEvent(FMLModIdMappingEvent aEvent) { - GTPP_Recipe.reInit(); - } + @Mod.EventHandler + public void onIDChangingEvent(FMLModIdMappingEvent aEvent) { + GTPP_Recipe.reInit(); + } public static void tryPatchTurbineTextures() { if (enableAnimatedTurbines) { BlockIcons h = Textures.BlockIcons.GAS_TURBINE_SIDE_ACTIVE; BlockIcons h2 = Textures.BlockIcons.STEAM_TURBINE_SIDE_ACTIVE; - try { - Logger.INFO("Trying to patch GT textures to make Turbines animated."); + try { + Logger.INFO( + "Trying to patch GT textures to make Turbines animated." + ); IIcon aIcon = TexturesGtBlock.Overlay_Machine_Turbine_Active.getIcon(); if (ReflectionUtils.setField(h, "mIcon", aIcon)) { Logger.INFO("Patched Gas Turbine Icon."); @@ -286,16 +332,33 @@ public class GTplusplus implements ActionListener { protected void generateGregtechRecipeMaps() { - int[] mValidCount = new int[] {0, 0, 0}; - int[] mInvalidCount = new int[] {0, 0, 0}; - int[] mOriginalCount = new int[] {0, 0, 0}; + int[] mValidCount = new int[]{ + 0, 0, 0 + }; + int[] mInvalidCount = new int[]{ + 0, 0, 0 + }; + int[] mOriginalCount = new int[]{ + 0, 0, 0 + }; RecipeGen_BlastSmelterGT_GTNH.generateGTNHBlastSmelterRecipesFromEBFList(); - FishPondFakeRecipe.generateFishPondRecipes(); + FishPondFakeRecipe.generateFishPondRecipes(); GregtechMiniRaFusion.generateSlowFusionrecipes(); SemiFluidFuelHandler.generateFuels(); GregtechMTE_ChemicalPlant.generateRecipes(); + mInvalidCount[0] = RecipeGen_MultisUsingFluidInsteadOfCells.generateRecipesNotUsingCells( + GT_Recipe.GT_Recipe_Map.sCentrifugeRecipes, GTPP_Recipe.GTPP_Recipe_Map.sMultiblockCentrifugeRecipes_GT + ); + mInvalidCount[1] = RecipeGen_MultisUsingFluidInsteadOfCells.generateRecipesNotUsingCells( + GT_Recipe.GT_Recipe_Map.sElectrolyzerRecipes, GTPP_Recipe.GTPP_Recipe_Map.sMultiblockElectrolyzerRecipes_GT + ); + mInvalidCount[2] = RecipeGen_MultisUsingFluidInsteadOfCells.generateRecipesNotUsingCells( + GT_Recipe.GT_Recipe_Map.sVacuumRecipes, GTPP_Recipe.GTPP_Recipe_Map.sAdvFreezerRecipes_GT + ); + /* + //Large Centrifuge generation mOriginalCount[0] = GT_Recipe.GT_Recipe_Map.sCentrifugeRecipes.mRecipeList.size(); for (GT_Recipe x : GT_Recipe.GT_Recipe_Map.sCentrifugeRecipes.mRecipeList) { @@ -320,13 +383,13 @@ public class GTplusplus implements ActionListener { mInvalidCount[0]++; } } - - /*if (GTPP_Recipe.GTPP_Recipe_Map.sMultiblockCentrifugeRecipes_GT.mRecipeList.size() < 1) { + + if (GTPP_Recipe.GTPP_Recipe_Map.sMultiblockCentrifugeRecipes_GT.mRecipeList.size() < 1) { for (GT_Recipe a : GTPP_Recipe.GTPP_Recipe_Map.sMultiblockCentrifugeRecipes_GT.mRecipeList) { GTPP_Recipe.GTPP_Recipe_Map.sMultiblockCentrifugeRecipes_GT.add(a); } - }*/ - + } + //Large Electrolyzer generation mOriginalCount[1] = GT_Recipe.GT_Recipe_Map.sElectrolyzerRecipes.mRecipeList.size(); for (GT_Recipe x : GT_Recipe.GT_Recipe_Map.sElectrolyzerRecipes.mRecipeList) { @@ -351,13 +414,13 @@ public class GTplusplus implements ActionListener { mInvalidCount[1]++; } } - - /*if (GTPP_Recipe.GTPP_Recipe_Map.sMultiblockElectrolyzerRecipes_GT.mRecipeList.size() < 1) { + + if (GTPP_Recipe.GTPP_Recipe_Map.sMultiblockElectrolyzerRecipes_GT.mRecipeList.size() < 1) { for (GT_Recipe a : GTPP_Recipe.GTPP_Recipe_Map.sMultiblockElectrolyzerRecipes_GT.mRecipeList) { GTPP_Recipe.GTPP_Recipe_Map.sMultiblockElectrolyzerRecipes_GT.add(a); } - }*/ - + } + //Advanced Vacuum Freezer generation mOriginalCount[2] = GT_Recipe.GT_Recipe_Map.sVacuumRecipes.mRecipeList.size(); for (GT_Recipe x : GT_Recipe.GT_Recipe_Map.sVacuumRecipes.mRecipeList) { @@ -375,15 +438,15 @@ public class GTplusplus implements ActionListener { mInvalidCount[2]++; } } - + //Redo plasma recipes in Adv. Vac. //Meta_GT_Proxy.generatePlasmaRecipesForAdvVacFreezer(); - - + + String[] machineName = new String[] {"Centrifuge", "Electrolyzer", "Vacuum Freezer"}; for (int i=0;i<3;i++) { Logger.INFO("[Recipe] Generated "+mValidCount[i]+" recipes for the Industrial "+machineName[i]+". The original machine can process "+mOriginalCount[i]+" recipes, meaning "+mInvalidCount[i]+" are invalid for this Multiblock's processing in some way."); - } + }*/ } protected void dumpGtRecipeMap(final GT_Recipe_Map r) { @@ -391,29 +454,43 @@ public class GTplusplus implements ActionListener { Logger.INFO("Dumping " + r.mUnlocalizedName + " Recipes for Debug."); for (final GT_Recipe newBo : x) { Logger.INFO("========================"); - Logger.INFO("Dumping Input: " + ItemUtils.getArrayStackNames(newBo.mInputs)); - Logger.INFO("Dumping Inputs " + ItemUtils.getFluidArrayStackNames(newBo.mFluidInputs)); + Logger.INFO( + "Dumping Input: " + + ItemUtils.getArrayStackNames(newBo.mInputs) + ); + Logger.INFO( + "Dumping Inputs " + ItemUtils.getFluidArrayStackNames( + newBo.mFluidInputs + ) + ); Logger.INFO("Dumping Duration: " + newBo.mDuration); Logger.INFO("Dumping EU/t: " + newBo.mEUt); - Logger.INFO("Dumping Output: " + ItemUtils.getArrayStackNames(newBo.mOutputs)); - Logger.INFO("Dumping Output: " + ItemUtils.getFluidArrayStackNames(newBo.mFluidOutputs)); + Logger.INFO( + "Dumping Output: " + + ItemUtils.getArrayStackNames(newBo.mOutputs) + ); + Logger.INFO( + "Dumping Output: " + ItemUtils.getFluidArrayStackNames( + newBo.mFluidOutputs + ) + ); Logger.INFO("========================"); } } - private static final boolean setupMaterialBlacklist(){ + private static final boolean setupMaterialBlacklist() { Material.invalidMaterials.put(Materials._NULL); Material.invalidMaterials.put(Materials.Clay); Material.invalidMaterials.put(Materials.Phosphorus); Material.invalidMaterials.put(Materials.Steel); Material.invalidMaterials.put(Materials.Bronze); Material.invalidMaterials.put(Materials.Hydrogen); - //Infused TC stuff - Material.invalidMaterials.put(Materials.InfusedAir); - Material.invalidMaterials.put(Materials.InfusedEarth); - Material.invalidMaterials.put(Materials.InfusedFire); + // Infused TC stuff + Material.invalidMaterials.put(Materials.InfusedAir); + Material.invalidMaterials.put(Materials.InfusedEarth); + Material.invalidMaterials.put(Materials.InfusedFire); Material.invalidMaterials.put(Materials.InfusedWater); - //EIO Materials + // EIO Materials Material.invalidMaterials.put(Materials.SoulSand); Material.invalidMaterials.put(Materials.EnderPearl); Material.invalidMaterials.put(Materials.EnderEye); @@ -422,7 +499,7 @@ public class GTplusplus implements ActionListener { Material.invalidMaterials.put(Materials.Soularium); Material.invalidMaterials.put(Materials.PhasedIron); - if (Material.invalidMaterials.size() > 0){ + if (Material.invalidMaterials.size() > 0) { return true; } return false; @@ -434,14 +511,14 @@ public class GTplusplus implements ActionListener { mGregMatLoader = new GT_Material_Loader(); - //Non GTNH Materials - if (!CORE.GTNH){ - //Mithril - Random Dungeon Loot - mGregMatLoader.enableMaterial(Materials.Mithril); - } + // Non GTNH Materials + if (!CORE.GTNH) { + // Mithril - Random Dungeon Loot + mGregMatLoader.enableMaterial(Materials.Mithril); + } - //Force - Alloying - mGregMatLoader.enableMaterial(Materials.Force); + // Force - Alloying + mGregMatLoader.enableMaterial(Materials.Force); } } diff --git a/src/Java/gtPlusPlus/core/handler/BookHandler.java b/src/Java/gtPlusPlus/core/handler/BookHandler.java index 13c57677a0..4bfd39e9a3 100644 --- a/src/Java/gtPlusPlus/core/handler/BookHandler.java +++ b/src/Java/gtPlusPlus/core/handler/BookHandler.java @@ -249,7 +249,8 @@ public class BookHandler { "27x Coils" + "\n" + "18x Pipe Casings" + "\n" + "57x Tiered Machine Casings" + "\n" + - "80+ Solid Casings", + "80+ Solid Casings" + "\n" + + "1x Catalyst Housing (Catalysts cannot go inside an Input Bus)", // Construction Guide "Construction Guide Pt1:" + "\n" + "\n" + diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java index d932f17d8f..633c710461 100644 --- a/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java @@ -344,7 +344,7 @@ public class RECIPES_GREGTECH { new ItemStack[] { CI.getNumberedAdvancedCircuit(12), CI.getTieredMachineCasing(aLaureniumTier-1), - CI.getPlate(aLaureniumTier-1, 8), + ALLOY.LAURENIUM.getPlate(8), CI.getGear(aLaureniumTier, 2) }, new FluidStack[] { @@ -368,7 +368,7 @@ public class RECIPES_GREGTECH { new ItemStack[] { CI.getNumberedAdvancedCircuit(12), CI.getTieredMachineCasing(aBotmiumTier-1), - CI.getPlate(aBotmiumTier-1, 8), + ALLOY.BOTMIUM.getPlate(8), CI.getGear(aBotmiumTier, 2) }, new FluidStack[] { diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/nbthandlers/GT_MetaTileEntity_Hatch_Catalysts.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/nbthandlers/GT_MetaTileEntity_Hatch_Catalysts.java index 23f7b2a6a0..ea74e650dd 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/nbthandlers/GT_MetaTileEntity_Hatch_Catalysts.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/nbthandlers/GT_MetaTileEntity_Hatch_Catalysts.java @@ -10,15 +10,15 @@ import net.minecraft.item.ItemStack; public class GT_MetaTileEntity_Hatch_Catalysts extends GT_MetaTileEntity_Hatch_NbtConsumable { public GT_MetaTileEntity_Hatch_Catalysts(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional, 7, 16, "Dedicated Catalyst Storage", false); + super(aID, aName, aNameRegional, 0, 16, "Dedicated Catalyst Storage", false); } public GT_MetaTileEntity_Hatch_Catalysts(String aName, String aDescription, ITexture[][][] aTextures) { - super(aName, 7, 16, aDescription, false, aTextures); + super(aName, 0, 16, aDescription, false, aTextures); } public GT_MetaTileEntity_Hatch_Catalysts(String aName, String[] aDescription, ITexture[][][] aTextures) { - super(aName, 7, 16, aDescription[0], false, aTextures); + super(aName, 0, 16, aDescription[0], false, aTextures); } @Override 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 4119a0df8c..66620e8109 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 @@ -48,9 +48,9 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase { private int mCoilTier = 0; 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); } @@ -58,7 +58,7 @@ 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; @@ -70,7 +70,7 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase { aSize = mTieredBlockRegistry.size(); return aSize > aSize2; } - + private static Block getBlockForTier(int aTier) { if (!mTieredBlockRegistry.containsKey(aTier)) { return Blocks.bedrock; @@ -142,6 +142,9 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase { @Override public GT_Recipe.GT_Recipe_Map getRecipeMap() { + if (GTPP_Recipe.GTPP_Recipe_Map.sChemicalPlant_GT.mRecipeList.size() == 0) { + generateRecipes(); + } return GTPP_Recipe.GTPP_Recipe_Map.sChemicalPlant_GT; } @@ -368,6 +371,10 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase { log("Not enough coils. Found "+aCoilCount+", require: 27."); return false; } + /*if (mCatalystBuses.size() != 1) { + log("A Catalyst Bus is Required."); + return false; + }*/ log("Structure Check Complete!"); @@ -761,34 +768,47 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase { long tEnergy = getMaxInputEnergy(); log("Running checkRecipeGeneric(0)"); + //GT_Recipe tRecipe = findRecipe(getBaseMetaTileEntity(), mLastRecipe, false, gregtech.api.enums.GT_Values.V[tTier], aFluidInputs, aItemInputs); + GT_Recipe tRecipe = findRecipe(mLastRecipe, gregtech.api.enums.GT_Values.V[tTier], getSolidCasingTier(), aItemInputs, aFluidInputs); + + + + + if (tRecipe == null) { + log("BAD RETURN - 1"); + return false; + } + // checks if it has a catalyst with enough durability ItemStack tCatalystRecipe = findCatalyst(aItemInputs); - if (tCatalystRecipe == null) { - log("does not have catalyst"); - return false; + boolean aDoesRecipeNeedCatalyst = false; + for (ItemStack aInputItem : tRecipe.mInputs) { + if (ItemUtils.isCatalyst(aInputItem)) { + aDoesRecipeNeedCatalyst = true; + break; + } + } + if (aDoesRecipeNeedCatalyst) { + if (tCatalystRecipe == null) { + log("does not have catalyst"); + return false; + } + if (mCatalystBuses.size() != 1) { + log("does not have correct number of catalyst hatchs. (Required 1, found "+mCatalystBuses.size()+")"); + 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"); @@ -929,7 +949,7 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase { log("damaging catalyst"); damageCatalyst(tCatalystRecipe, parallelRecipes); } - + // Commit outputs this.mOutputItems = tOutputItems; this.mOutputFluids = tOutputFluids; @@ -942,6 +962,159 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase { return true; } + private static final HashMap> mTieredRecipeMap = new HashMap>(); + private static final AutoMap aTier0Recipes = new AutoMap(); + private static final AutoMap aTier1Recipes = new AutoMap(); + private static final AutoMap aTier2Recipes = new AutoMap(); + private static final AutoMap aTier3Recipes = new AutoMap(); + private static final AutoMap aTier4Recipes = new AutoMap(); + private static final AutoMap aTier5Recipes = new AutoMap(); + private static final AutoMap aTier6Recipes = new AutoMap(); + private static final AutoMap aTier7Recipes = new AutoMap(); + private static boolean mInitRecipeCache = false; + + private static void initRecipeCaches() { + if (!mInitRecipeCache) { + mTieredRecipeMap.put((long) 0, aTier0Recipes); + mTieredRecipeMap.put((long) 1, aTier1Recipes); + mTieredRecipeMap.put((long) 2, aTier2Recipes); + mTieredRecipeMap.put((long) 3, aTier3Recipes); + mTieredRecipeMap.put((long) 4, aTier4Recipes); + mTieredRecipeMap.put((long) 5, aTier5Recipes); + mTieredRecipeMap.put((long) 6, aTier6Recipes); + mTieredRecipeMap.put((long) 7, aTier7Recipes); + for (GT_Recipe aRecipe : GTPP_Recipe.GTPP_Recipe_Map.sChemicalPlant_GT.mRecipeList) { + if (aRecipe != null) { + switch (aRecipe.mSpecialValue) { + case 0: + aTier0Recipes.add(aRecipe); + continue; + case 1: + aTier1Recipes.add(aRecipe); + continue; + case 2: + aTier2Recipes.add(aRecipe); + continue; + case 3: + aTier3Recipes.add(aRecipe); + continue; + case 4: + aTier4Recipes.add(aRecipe); + continue; + case 5: + aTier5Recipes.add(aRecipe); + continue; + case 6: + aTier6Recipes.add(aRecipe); + continue; + case 7: + aTier7Recipes.add(aRecipe); + continue; + } + } + } + mInitRecipeCache = true; + } + } + + private static boolean areInputsEqual(GT_Recipe aComparator, ItemStack[] aInputs, FluidStack[] aFluids) { + int aInputCount = aComparator.mInputs.length; + if (aInputCount > 0) { + //Logger.INFO("Looking for recipe with "+aInputCount+" Items"); + int aMatchingInputs = 0; + recipe : for (ItemStack a : aComparator.mInputs) { + for (ItemStack b : aInputs) { + if (a.getItem() == b.getItem()) { + if (a.getItemDamage() == b.getItemDamage()) { + //Logger.INFO("Found matching Item Input - "+b.getUnlocalizedName()); + aMatchingInputs++; + continue recipe; + } + } + } + } + if (aMatchingInputs != aInputCount) { + return false; + } + } + int aFluidInputCount = aComparator.mFluidInputs.length; + if (aFluidInputCount > 0) { + //Logger.INFO("Looking for recipe with "+aFluidInputCount+" Fluids"); + int aMatchingFluidInputs = 0; + recipe : for (FluidStack b : aComparator.mFluidInputs) { + //Logger.INFO("Checking for fluid "+b.getLocalizedName()); + for (FluidStack a : aFluids) { + if (GT_Utility.areFluidsEqual(a, b)) { + //Logger.INFO("Found matching Fluid Input - "+b.getLocalizedName()); + aMatchingFluidInputs++; + continue recipe; + } + else { + //Logger.INFO("Found fluid which did not match - "+a.getLocalizedName()); + } + } + } + if (aMatchingFluidInputs != aFluidInputCount) { + return false; + } + } + Logger.INFO("Recipes Match!"); + return true; + } + + public GT_Recipe findRecipe(final GT_Recipe aRecipe, final long aVoltage, final long aSpecialValue, ItemStack[] aInputs, final FluidStack[] aFluids) { + if (!mInitRecipeCache) { + initRecipeCaches(); + } + if (this.getRecipeMap().mRecipeList.isEmpty()) { + log("No Recipes in Map to search through."); + return null; + } + else { + log("Checking tier "+aSpecialValue+" recipes and below. Using Input Voltage of "+aVoltage+"V."); + log("We have "+aInputs.length+" Items and "+aFluids.length+" Fluids."); + // Try check the cached recipe first + if (aRecipe != null) { + if (areInputsEqual(aRecipe, aInputs, aFluids)) { + if (aRecipe.mEUt <= aVoltage) { + Logger.INFO("Using cached recipe."); + return aRecipe; + } + } + } + + // Get all recipes for the tier + AutoMap> aMasterMap = new AutoMap>(); + for (long i=0;i<=aSpecialValue;i++) { + aMasterMap.add(mTieredRecipeMap.get(i)); + } + GT_Recipe aFoundRecipe = null; + + // Iterate the tiers recipes until we find the one with all inputs matching + master : for (AutoMap aTieredMap : aMasterMap) { + for (GT_Recipe aRecipeToCheck : aTieredMap) { + if (areInputsEqual(aRecipeToCheck, aInputs, aFluids)) { + log("Found recipe with matching inputs!"); + if (aRecipeToCheck.mSpecialValue <= aSpecialValue) { + if (aRecipeToCheck.mEUt <= aVoltage) { + aFoundRecipe = aRecipeToCheck; + break master; + } + } + } + } + } + + // If we found a recipe, return it + if (aFoundRecipe != null) { + log("Found valid recipe."); + return aFoundRecipe; + } + } + log("Did not find valid recipe."); + return null; + } + private int getCatalysts(ItemStack[] aItemInputs, ItemStack aRecipeCatalyst, int aMaxParrallel, ArrayList aOutPut) { int allowedParrallel = 0; for (final ItemStack aInput : aItemInputs) { @@ -986,8 +1159,8 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase { log("not consuming catalyst"); } } - - + + } @@ -1041,18 +1214,18 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase { /* * Catalyst Handling */ - - + + @Override - public ArrayList getStoredInputs() { + public ArrayList getStoredInputs() { ArrayList tItems = super.getStoredInputs(); - for (GT_MetaTileEntity_Hatch_Catalysts tHatch : mCatalystBuses) { - tHatch.mRecipeMap = getRecipeMap(); - if (isValidMetaTileEntity(tHatch)) { - tItems.addAll(tHatch.getContentUsageSlots()); - } - } + for (GT_MetaTileEntity_Hatch_Catalysts tHatch : mCatalystBuses) { + tHatch.mRecipeMap = getRecipeMap(); + if (isValidMetaTileEntity(tHatch)) { + tItems.addAll(tHatch.getContentUsageSlots()); + } + } return tItems; } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_MultisUsingFluidInsteadOfCells.java b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_MultisUsingFluidInsteadOfCells.java new file mode 100644 index 0000000000..b94dbfa51f --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_MultisUsingFluidInsteadOfCells.java @@ -0,0 +1,182 @@ +package gtPlusPlus.xmod.gregtech.loaders; + +import gregtech.api.util.GTPP_Recipe; +import gregtech.api.util.GTPP_Recipe.GTPP_Recipe_Map_Internal; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.core.recipe.common.CI; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +public class RecipeGen_MultisUsingFluidInsteadOfCells { + + + private static ItemStack mEmptyCell; + private static AutoMap mItemsToIgnore = new AutoMap(); + private static boolean mInit = false; + + private static void init() { + if (!mInit) { + mInit = true; + mItemsToIgnore.add(ItemUtils.simpleMetaStack(CI.emptyCells(1).getItem(), 8, 1)); + + + } + } + + private static boolean doesItemMatchIgnoringStackSize(ItemStack a, ItemStack b) { + if (a == null || b == null) { + return false; + } + if (a.getItem() == b.getItem()) { + if (a.getItemDamage() == b.getItemDamage()) { + return true; + } + } + return false; + } + + private static boolean isEmptyCell(ItemStack aCell) { + if (aCell == null) { + return false; + } + if (mEmptyCell == null) { + mEmptyCell = CI.emptyCells(1); + } + if (mEmptyCell != null) { + ItemStack aTempStack = mEmptyCell.copy(); + aTempStack.stackSize = aCell.stackSize; + if (GT_Utility.areStacksEqual(aTempStack, aCell)) { + return true; + } + } + return false; + } + + private synchronized static FluidStack getFluidFromItemStack(final ItemStack ingot) { + if (ingot == null) { + return null; + } + FluidStack aFluid = GT_Utility.getFluidForFilledItem(ingot, true); + if (aFluid != null) { + return aFluid; + } + return null; + } + + public synchronized static int generateRecipesNotUsingCells(GT_Recipe_Map aInputs, GTPP_Recipe_Map_Internal aOutputs) { + init(); + int aRecipesHandled = 0; + int aInvalidRecipesToConvert = 0; + int aOriginalCount = aInputs.mRecipeList.size(); + + recipe : for (GT_Recipe x : aInputs.mRecipeList) { + if (x != null) { + + ItemStack[] aInputItems = x.mInputs.clone(); + ItemStack[] aOutputItems = x.mOutputs.clone(); + FluidStack[] aInputFluids = x.mFluidInputs.clone(); + FluidStack[] aOutputFluids = x.mFluidOutputs.clone(); + + AutoMap aInputItemsMap = new AutoMap(); + AutoMap aOutputItemsMap = new AutoMap(); + AutoMap aInputFluidsMap = new AutoMap(); + AutoMap aOutputFluidsMap = new AutoMap(); + + // Iterate Inputs, Convert valid items into fluids + inputs : for (ItemStack aInputStack : aInputItems) { + FluidStack aFoundFluid = getFluidFromItemStack(aInputStack); + if (aFoundFluid == null) { + for (ItemStack aBadStack : mItemsToIgnore) { + if (doesItemMatchIgnoringStackSize(aInputStack, aBadStack)) { + continue recipe; // Skip this recipe entirely if we find an item we don't like + } + } + if (!isEmptyCell(aInputStack)) { + aInputItemsMap.add(aInputStack); + } + } + else { + aFoundFluid.amount = aFoundFluid.amount * aInputStack.stackSize; + aInputFluidsMap.add(aFoundFluid); + } + } + // Iterate Outputs, Convert valid items into fluids + outputs: for (ItemStack aOutputStack : aOutputItems) { + FluidStack aFoundFluid = getFluidFromItemStack(aOutputStack); + if (aFoundFluid == null) { + for (ItemStack aBadStack : mItemsToIgnore) { + if (doesItemMatchIgnoringStackSize(aOutputStack, aBadStack)) { + continue recipe; // Skip this recipe entirely if we find an item we don't like + } + } + if (!isEmptyCell(aOutputStack)) { + aOutputItemsMap.add(aOutputStack); + } + } + else { + aFoundFluid.amount = aFoundFluid.amount * aOutputStack.stackSize; + aOutputFluidsMap.add(aFoundFluid); + } + } + // Add Input fluids second + for (FluidStack aInputFluid : aInputFluids) { + aInputFluidsMap.add(aInputFluid); + } + // Add Output fluids second + for (FluidStack aOutputFluid : aOutputFluids) { + aOutputFluidsMap.add(aOutputFluid); + } + + // Make some new Arrays + ItemStack[] aNewItemInputs = new ItemStack[aInputItemsMap.size()]; + ItemStack[] aNewItemOutputs = new ItemStack[aOutputItemsMap.size()]; + FluidStack[] aNewFluidInputs = new FluidStack[aInputFluidsMap.size()]; + FluidStack[] aNewFluidOutputs = new FluidStack[aOutputFluidsMap.size()]; + + // Add AutoMap contents to Arrays + for (int i = 0; i < aInputItemsMap.size(); i++) { + aNewItemInputs[i] = aInputItemsMap.get(i); + } + for (int i = 0; i < aOutputItemsMap.size(); i++) { + aNewItemOutputs[i] = aOutputItemsMap.get(i); + } + for (int i = 0; i < aInputFluidsMap.size(); i++) { + aNewFluidInputs[i] = aInputFluidsMap.get(i); + } + for (int i = 0; i < aOutputFluidsMap.size(); i++) { + aNewFluidOutputs[i] = aOutputFluidsMap.get(i); + } + + // Add Recipe to map + GT_Recipe aNewRecipe = new GTPP_Recipe( + false, + aNewItemInputs, + aNewItemOutputs, + x.mSpecialItems, + x.mChances, + aNewFluidInputs, + aNewFluidOutputs, + x.mDuration, + x.mEUt, + x.mSpecialValue); + aOutputs.add(aNewRecipe); + aRecipesHandled++; + } + else { + aInvalidRecipesToConvert++; + } + } + + Logger.INFO("Generated Recipes for "+aOutputs.mNEIName); + Logger.INFO("Original Map contains "+aOriginalCount+" recipes."); + Logger.INFO("Output Map contains "+aRecipesHandled+" recipes."); + Logger.INFO("There were "+aInvalidRecipesToConvert+" invalid recipes."); + return aRecipesHandled; + } + +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechSimpleWasher.java b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechSimpleWasher.java index d3c1368ad3..d2087b22f4 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechSimpleWasher.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechSimpleWasher.java @@ -41,11 +41,18 @@ public class GregtechSimpleWasher { } private static boolean generateDirtyDustRecipes(){ + boolean disablePlat = CORE.GTNH; int mRecipeCount = 0; // Generate Recipe Map for the Dust Washer. ItemStack dustClean; ItemStack dustDirty; - for (Materials v : Materials.values()) { + for (Materials v : Materials.values()) { + if (disablePlat) { + if (v == Materials.Platinum || v == Materials.Osmium || v == Materials.Iridium || v == Materials.Palladium) { + continue; + } + } + dustClean = GT_OreDictUnificator.get(OrePrefixes.dust, v, 1L); dustDirty = GT_OreDictUnificator.get(OrePrefixes.dustImpure, v, 1L); if (dustClean != null && dustDirty != null) { -- cgit From 8ee7350f7e52b898126331aea6e673c70942e42a Mon Sep 17 00:00:00 2001 From: Alkalus Date: Tue, 18 Aug 2020 18:35:49 +0100 Subject: + Added Spice of Life support. + Added new Food Crate. $ Fixed bug in Fish Catcher, where side by side traps didn't count properly as water. $ Fixed bug in Air Intake Hatch. --- .../core/handler/COMPAT_IntermodStaging.java | 4 ++ src/Java/gtPlusPlus/core/lib/LoadedMods.java | 6 ++ .../tileentities/general/TileEntityFishTrap.java | 3 +- .../general/TileEntityVolumetricFlaskSetter.java | 6 +- .../GT_MetaTileEntity_Hatch_AirIntake.java | 41 +++++++++++++- .../gtPlusPlus/xmod/sol/HANDLER_SpiceOfLife.java | 61 +++++++++++++++++++++ src/resources/assets/spiceoflife/lang/de_DE.lang | 2 + src/resources/assets/spiceoflife/lang/en_US.lang | 2 + src/resources/assets/spiceoflife/lang/es_ES.lang | 2 + src/resources/assets/spiceoflife/lang/fr_FR.lang | 2 + src/resources/assets/spiceoflife/lang/it_IT.lang | 2 + src/resources/assets/spiceoflife/lang/ko_KR.lang | 2 + src/resources/assets/spiceoflife/lang/ru_RU.lang | 2 + src/resources/assets/spiceoflife/lang/zh_CN.lang | 2 + .../spiceoflife/textures/items/foodcrate.png | Bin 0 -> 365 bytes .../textures/items/foodcrate_open_empty.png | Bin 0 -> 355 bytes .../textures/items/foodcrate_open_full.png | Bin 0 -> 509 bytes 17 files changed, 132 insertions(+), 5 deletions(-) create mode 100644 src/Java/gtPlusPlus/xmod/sol/HANDLER_SpiceOfLife.java create mode 100644 src/resources/assets/spiceoflife/lang/de_DE.lang create mode 100644 src/resources/assets/spiceoflife/lang/en_US.lang create mode 100644 src/resources/assets/spiceoflife/lang/es_ES.lang create mode 100644 src/resources/assets/spiceoflife/lang/fr_FR.lang create mode 100644 src/resources/assets/spiceoflife/lang/it_IT.lang create mode 100644 src/resources/assets/spiceoflife/lang/ko_KR.lang create mode 100644 src/resources/assets/spiceoflife/lang/ru_RU.lang create mode 100644 src/resources/assets/spiceoflife/lang/zh_CN.lang create mode 100644 src/resources/assets/spiceoflife/textures/items/foodcrate.png create mode 100644 src/resources/assets/spiceoflife/textures/items/foodcrate_open_empty.png create mode 100644 src/resources/assets/spiceoflife/textures/items/foodcrate_open_full.png (limited to 'src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations') diff --git a/src/Java/gtPlusPlus/core/handler/COMPAT_IntermodStaging.java b/src/Java/gtPlusPlus/core/handler/COMPAT_IntermodStaging.java index cd25fdb1c3..9a1b551d30 100644 --- a/src/Java/gtPlusPlus/core/handler/COMPAT_IntermodStaging.java +++ b/src/Java/gtPlusPlus/core/handler/COMPAT_IntermodStaging.java @@ -16,6 +16,7 @@ import gtPlusPlus.xmod.ob.HANDLER_OpenBlocks; import gtPlusPlus.xmod.railcraft.HANDLER_Railcraft; import gtPlusPlus.xmod.reliquary.HANDLER_Reliquary; import gtPlusPlus.xmod.sc2.HANDLER_SC2; +import gtPlusPlus.xmod.sol.HANDLER_SpiceOfLife; import gtPlusPlus.xmod.thaumcraft.HANDLER_Thaumcraft; import gtPlusPlus.xmod.thermalfoundation.HANDLER_TF; import gtPlusPlus.xmod.tinkers.HANDLER_Tinkers; @@ -39,6 +40,7 @@ public class COMPAT_IntermodStaging { HANDLER_Railcraft.preInit(); HANDLER_Reliquary.preInit(); HANDLER_OpenBlocks.preInit(); + HANDLER_SpiceOfLife.preInit(); } public static void init(FMLInitializationEvent init){ @@ -58,6 +60,7 @@ public class COMPAT_IntermodStaging { HANDLER_Railcraft.init(); HANDLER_Reliquary.init(); HANDLER_OpenBlocks.init(); + HANDLER_SpiceOfLife.init(); } public static void postInit(FMLPostInitializationEvent postinit){ @@ -77,6 +80,7 @@ public class COMPAT_IntermodStaging { HANDLER_Railcraft.postInit(); HANDLER_Reliquary.postInit(); HANDLER_OpenBlocks.postInit(); + HANDLER_SpiceOfLife.postInit(); } public static void onLoadComplete(FMLLoadCompleteEvent event) { diff --git a/src/Java/gtPlusPlus/core/lib/LoadedMods.java b/src/Java/gtPlusPlus/core/lib/LoadedMods.java index 329cf634b6..1eb8351d65 100644 --- a/src/Java/gtPlusPlus/core/lib/LoadedMods.java +++ b/src/Java/gtPlusPlus/core/lib/LoadedMods.java @@ -59,6 +59,7 @@ public class LoadedMods { public static boolean Waila = false; public static boolean CropsPlusPlus = false; //Barts Crop Mod public static boolean Reliquary = false; + public static boolean SpiceOfLife = false; @@ -211,6 +212,11 @@ public class LoadedMods { Logger.INFO("Components enabled for: WAILA"); totalMods++; } + if (isModLoaded("SpiceOfLife")){ + SpiceOfLife = true; + Logger.INFO("Components enabled for: Spice Of Life"); + totalMods++; + } if (isModLoaded("Mekanism")){ Mekanism = true; Logger.INFO("Components enabled for: Mekanism - This feature is not configurable and balances Mekanism to suit GT."); diff --git a/src/Java/gtPlusPlus/core/tileentities/general/TileEntityFishTrap.java b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityFishTrap.java index e7c37f7994..beff269428 100644 --- a/src/Java/gtPlusPlus/core/tileentities/general/TileEntityFishTrap.java +++ b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityFishTrap.java @@ -79,7 +79,8 @@ public class TileEntityFishTrap extends TileEntity implements ISidedInventory { } } if ((waterCount >= 2) && (trapCount <= 4)) { - this.waterSides = waterCount; + int aCheck = trapCount + waterCount; + this.waterSides = MathUtils.balance(aCheck, 0, 6); Logger.MACHINE_INFO("Valid Trap. "+waterCount+" | "+(this.tickCount/20)+"/"+(this.baseTickRate/20)); return true; } diff --git a/src/Java/gtPlusPlus/core/tileentities/general/TileEntityVolumetricFlaskSetter.java b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityVolumetricFlaskSetter.java index 316d271961..5b837397b1 100644 --- a/src/Java/gtPlusPlus/core/tileentities/general/TileEntityVolumetricFlaskSetter.java +++ b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityVolumetricFlaskSetter.java @@ -340,12 +340,12 @@ public class TileEntityVolumetricFlaskSetter extends TileEntity implements ISide @Override public boolean canInsertItem(final int aSlot, final ItemStack p_102007_2_, final int p_102007_3_) { - return aSlot >= 0 && aSlot <= 24; + return aSlot == aCurrentMode; } @Override - public boolean canExtractItem(final int p_102008_1_, final ItemStack p_102008_2_, final int p_102008_3_) { - return p_102008_1_ == 25; + public boolean canExtractItem(final int aSlot, final ItemStack p_102008_2_, final int p_102008_3_) { + return aSlot == Container_VolumetricFlaskSetter.SLOT_OUTPUT; } public String getCustomName() { diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_AirIntake.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_AirIntake.java index 4e6e2bc35b..3a0c101375 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_AirIntake.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_AirIntake.java @@ -1,6 +1,8 @@ package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations; import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; import net.minecraft.world.World; import net.minecraft.item.ItemStack; @@ -196,6 +198,20 @@ public class GT_MetaTileEntity_Hatch_AirIntake extends GT_MetaTileEntity_Hatch_I public boolean canTankBeEmptied() { return true; } + + private static Fluid AIR; + + public boolean isAirInHatch() { + if (this.mFluid != null) { + if (AIR == null) { + AIR = FluidUtils.getAir(1).getFluid(); + } + if (AIR == this.mFluid.getFluid()) { + return true; + } + } + return false; + } public boolean addAirToHatch(long aTick) { if (!this.getBaseMetaTileEntity().getAirAtSide(this.getBaseMetaTileEntity().getFrontFacing())) { @@ -209,6 +225,9 @@ public class GT_MetaTileEntity_Hatch_AirIntake extends GT_MetaTileEntity_Hatch_I return false; } else { + if (!isAirInHatch()) { + return false; + } if (this.mFluid != null && a1) { this.mFluid.amount += 1000; return true; @@ -244,6 +263,26 @@ public class GT_MetaTileEntity_Hatch_AirIntake extends GT_MetaTileEntity_Hatch_I @Override public boolean doesFillContainers() { - return true; + return false; + } + + @Override + public int fill(FluidStack aFluid, boolean doFill) { + return 0; + } + + @Override + public boolean canFill(ForgeDirection aSide, Fluid aFluid) { + return false; + } + + @Override + public int fill(ForgeDirection arg0, FluidStack arg1, boolean arg2) { + return 0; + } + + @Override + public int fill_default(ForgeDirection aSide, FluidStack aFluid, boolean doFill) { + return 0; } } \ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/sol/HANDLER_SpiceOfLife.java b/src/Java/gtPlusPlus/xmod/sol/HANDLER_SpiceOfLife.java new file mode 100644 index 0000000000..11cc5da89c --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/sol/HANDLER_SpiceOfLife.java @@ -0,0 +1,61 @@ +package gtPlusPlus.xmod.sol; + +import java.lang.reflect.Constructor; + +import cpw.mods.fml.common.registry.GameRegistry; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.LoadedMods; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import net.minecraft.item.Item; + +public class HANDLER_SpiceOfLife { + + public static final void preInit() { + if (LoadedMods.SpiceOfLife) { + //Add a new Lunch Box with a reasonable amount of slots + tryRegisterNewLunchBox("foodcrate", 12); + } + } + + public static final void init() { + if (LoadedMods.SpiceOfLife) { + + } + } + + public static final void postInit() { + if (LoadedMods.SpiceOfLife) { + + } + } + + private static boolean tryRegisterNewLunchBox(String aItemName, int aSlots) { + Item aNewBox = getNewLunchBox(aItemName, aSlots); + if (aNewBox != null) { + GameRegistry.registerItem(aNewBox, aItemName); + Logger.INFO("[Spice of Life] Registered "+aItemName+" as a new food container."); + return true; + } + return false; + } + + private static Item getNewLunchBox(String aItemName, int aSlots) { + Class aItemFoodContainer = ReflectionUtils.getClass("squeek.spiceoflife.items.ItemFoodContainer"); + if (aItemFoodContainer != null) { + Constructor aItemFoodContainerConstructor = ReflectionUtils.getConstructor(aItemFoodContainer, new Class[] {String.class, int.class}); + if (aItemFoodContainerConstructor != null) { + Object aNewObject = ReflectionUtils.createNewInstanceFromConstructor(aItemFoodContainerConstructor, new Object[] {aItemName, aSlots}); + if (aNewObject instanceof Item) { + Item aNewInstance = (Item) aNewObject; + return aNewInstance; + } + } + } + return null; + } + + + + + +} diff --git a/src/resources/assets/spiceoflife/lang/de_DE.lang b/src/resources/assets/spiceoflife/lang/de_DE.lang new file mode 100644 index 0000000000..63ad1e2a98 --- /dev/null +++ b/src/resources/assets/spiceoflife/lang/de_DE.lang @@ -0,0 +1,2 @@ +# Items +item.spiceoflife.foodcrate.name=Voedselkrat \ No newline at end of file diff --git a/src/resources/assets/spiceoflife/lang/en_US.lang b/src/resources/assets/spiceoflife/lang/en_US.lang new file mode 100644 index 0000000000..bf16f4dc93 --- /dev/null +++ b/src/resources/assets/spiceoflife/lang/en_US.lang @@ -0,0 +1,2 @@ +# Items +item.spiceoflife.foodcrate.name=Food Crate \ No newline at end of file diff --git a/src/resources/assets/spiceoflife/lang/es_ES.lang b/src/resources/assets/spiceoflife/lang/es_ES.lang new file mode 100644 index 0000000000..02fe4c8806 --- /dev/null +++ b/src/resources/assets/spiceoflife/lang/es_ES.lang @@ -0,0 +1,2 @@ +# Items +item.spiceoflife.foodcrate.name=Caja de comida \ No newline at end of file diff --git a/src/resources/assets/spiceoflife/lang/fr_FR.lang b/src/resources/assets/spiceoflife/lang/fr_FR.lang new file mode 100644 index 0000000000..418c2b7053 --- /dev/null +++ b/src/resources/assets/spiceoflife/lang/fr_FR.lang @@ -0,0 +1,2 @@ +# Items +item.spiceoflife.foodcrate.name=Caisse alimentaire \ No newline at end of file diff --git a/src/resources/assets/spiceoflife/lang/it_IT.lang b/src/resources/assets/spiceoflife/lang/it_IT.lang new file mode 100644 index 0000000000..841b97c63f --- /dev/null +++ b/src/resources/assets/spiceoflife/lang/it_IT.lang @@ -0,0 +1,2 @@ +# Items +item.spiceoflife.foodcrate.name=Cassa Alimentare \ No newline at end of file diff --git a/src/resources/assets/spiceoflife/lang/ko_KR.lang b/src/resources/assets/spiceoflife/lang/ko_KR.lang new file mode 100644 index 0000000000..7e9973e936 --- /dev/null +++ b/src/resources/assets/spiceoflife/lang/ko_KR.lang @@ -0,0 +1,2 @@ +# Items +item.spiceoflife.foodcrate.name=음식 상자 \ No newline at end of file diff --git a/src/resources/assets/spiceoflife/lang/ru_RU.lang b/src/resources/assets/spiceoflife/lang/ru_RU.lang new file mode 100644 index 0000000000..e167a0ae03 --- /dev/null +++ b/src/resources/assets/spiceoflife/lang/ru_RU.lang @@ -0,0 +1,2 @@ +# Items +item.spiceoflife.foodcrate.name=Продовольственный ящик \ No newline at end of file diff --git a/src/resources/assets/spiceoflife/lang/zh_CN.lang b/src/resources/assets/spiceoflife/lang/zh_CN.lang new file mode 100644 index 0000000000..bb211e7b57 --- /dev/null +++ b/src/resources/assets/spiceoflife/lang/zh_CN.lang @@ -0,0 +1,2 @@ +# Items +item.spiceoflife.foodcrate.name=食品箱 \ No newline at end of file diff --git a/src/resources/assets/spiceoflife/textures/items/foodcrate.png b/src/resources/assets/spiceoflife/textures/items/foodcrate.png new file mode 100644 index 0000000000..b717dd0318 Binary files /dev/null and b/src/resources/assets/spiceoflife/textures/items/foodcrate.png differ diff --git a/src/resources/assets/spiceoflife/textures/items/foodcrate_open_empty.png b/src/resources/assets/spiceoflife/textures/items/foodcrate_open_empty.png new file mode 100644 index 0000000000..4dbfd54ea7 Binary files /dev/null and b/src/resources/assets/spiceoflife/textures/items/foodcrate_open_empty.png differ diff --git a/src/resources/assets/spiceoflife/textures/items/foodcrate_open_full.png b/src/resources/assets/spiceoflife/textures/items/foodcrate_open_full.png new file mode 100644 index 0000000000..0284bd29ad Binary files /dev/null and b/src/resources/assets/spiceoflife/textures/items/foodcrate_open_full.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/api/metatileentity/implementations') 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