diff options
Diffstat (limited to 'src/main/java/gregtech/api')
7 files changed, 191 insertions, 178 deletions
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicGenerator.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicGenerator.java index b540bdded5..76b2e9aaf5 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicGenerator.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicGenerator.java @@ -29,7 +29,7 @@ public abstract class GT_MetaTileEntity_BasicGenerator extends GT_MetaTileEntity public GT_MetaTileEntity_BasicGenerator(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { super(aName, aTier, 3, aDescription, aTextures); } - + public GT_MetaTileEntity_BasicGenerator(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { super(aName, aTier, 3, aDescription, aTextures); } @@ -59,9 +59,9 @@ public abstract class GT_MetaTileEntity_BasicGenerator extends GT_MetaTileEntity @Override public String[] getDescription() { - String[] desc = new String[mDescriptionArray.length + 1]; - System.arraycopy(mDescriptionArray, 0, desc, 0, mDescriptionArray.length); - desc[mDescriptionArray.length] = "Fuel Efficiency: " + getEfficiency() + "%"; + String[] desc = new String[mDescriptionArray.length + 1]; + System.arraycopy(mDescriptionArray, 0, desc, 0, mDescriptionArray.length); + desc[mDescriptionArray.length] = "Fuel Efficiency: " + getEfficiency() + "%"; return desc; } @@ -203,8 +203,8 @@ public abstract class GT_MetaTileEntity_BasicGenerator extends GT_MetaTileEntity if (tFuelValue > 0 && tConsumed > 0 && mFluid.amount > tConsumed) { long tFluidAmountToUse = Math.min(mFluid.amount / tConsumed, (maxEUStore() - aBaseMetaTileEntity.getUniversalEnergyStored()) / tFuelValue); if (tFluidAmountToUse > 0 && aBaseMetaTileEntity.increaseStoredEnergyUnits(tFluidAmountToUse * tFuelValue, true)) { - GT_Pollution.addPollution(this.getBaseMetaTileEntity().getWorld(), new ChunkPosition(this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getYCoord(), this.getBaseMetaTileEntity().getZCoord()), - 10 * getPollution()); + GT_Pollution.addPollution(this.getBaseMetaTileEntity().getWorld(), new ChunkPosition(this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getYCoord(), this.getBaseMetaTileEntity().getZCoord()), + 10 * getPollution()); mFluid.amount -= tFluidAmountToUse * tConsumed; } } @@ -216,8 +216,8 @@ public abstract class GT_MetaTileEntity_BasicGenerator extends GT_MetaTileEntity if (aBaseMetaTileEntity.addStackToSlot(getOutputSlot(), tEmptyContainer)) { aBaseMetaTileEntity.increaseStoredEnergyUnits(tFuelValue, true); aBaseMetaTileEntity.decrStackSize(getInputSlot(), 1); - GT_Pollution.addPollution(this.getBaseMetaTileEntity().getWorld(), new ChunkPosition(this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getYCoord(), this.getBaseMetaTileEntity().getZCoord()), - 10 * getPollution()); + GT_Pollution.addPollution(this.getBaseMetaTileEntity().getWorld(), new ChunkPosition(this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getYCoord(), this.getBaseMetaTileEntity().getZCoord()), + 10 * getPollution()); } } } @@ -226,7 +226,7 @@ public abstract class GT_MetaTileEntity_BasicGenerator extends GT_MetaTileEntity if (aBaseMetaTileEntity.isServerSide()) aBaseMetaTileEntity.setActive(aBaseMetaTileEntity.isAllowedToWork() && aBaseMetaTileEntity.getUniversalEnergyStored() >= maxEUOutput() + getMinimumStoredEU()); } - + public abstract int getPollution(); public abstract GT_Recipe_Map getRecipes(); diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_GT_Recipe.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_GT_Recipe.java index bb1ef1332f..06a115d3d4 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_GT_Recipe.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_GT_Recipe.java @@ -35,6 +35,7 @@ public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_ private final String mSound; private final boolean mSharedTank, mRequiresFluidForFiltering; private final byte mGUIParameterA, mGUIParameterB; + public GT_MetaTileEntity_BasicMachine_GT_Recipe(int aID, String aName, String aNameRegional, int aTier, String aDescription, GT_Recipe_Map aRecipes, int aInputSlots, int aOutputSlots, int aTankCapacity, int aGUIParameterA, int aGUIParameterB, String aGUIName, String aSound, boolean aSharedTank, boolean aRequiresFluidForFiltering, int aSpecialEffect, String aOverlays, Object[] aRecipe) { super(aID, aName, aNameRegional, aTier, aRecipes.mAmperage, aDescription, aInputSlots, aOutputSlots, aGUIName, aRecipes.mNEIName, new ITexture[]{new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/" + aOverlays.toLowerCase(Locale.ENGLISH) + "/OVERLAY_SIDE_ACTIVE")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/" + aOverlays.toLowerCase(Locale.ENGLISH) + "/OVERLAY_SIDE")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/" + aOverlays.toLowerCase(Locale.ENGLISH) + "/OVERLAY_FRONT_ACTIVE")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/" + aOverlays.toLowerCase(Locale.ENGLISH) + "/OVERLAY_FRONT")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/" + aOverlays.toLowerCase(Locale.ENGLISH) + "/OVERLAY_TOP_ACTIVE")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/" + aOverlays.toLowerCase(Locale.ENGLISH) + "/OVERLAY_TOP")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/" + aOverlays.toLowerCase(Locale.ENGLISH) + "/OVERLAY_BOTTOM_ACTIVE")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/" + aOverlays.toLowerCase(Locale.ENGLISH) + "/OVERLAY_BOTTOM"))}); mSharedTank = aSharedTank; @@ -74,8 +75,8 @@ public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_ case 6: case 7: case 8: - aRecipe[i] = Ic2Items.reinforcedGlass; - break; + aRecipe[i] = Ic2Items.reinforcedGlass; + break; default: aRecipe[i] = new ItemStack(Blocks.glass, 1, W); break; @@ -634,17 +635,21 @@ public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_ return new GT_GUIContainer_BasicMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), mGUIName, GT_Utility.isStringValid(mNEIName) ? mNEIName : getRecipeList() != null ? getRecipeList().mUnlocalizedName : "", mGUIParameterA, mGUIParameterB); } - @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - if (!super.allowPutStack(aBaseMetaTileEntity, aIndex, aSide, aStack)) return false; - if (mInventory[aIndex] != null) return true; - switch (mInputSlotCount) { - case 0: return false; - case 1: return getFillableStack() == null ? !mRequiresFluidForFiltering && getRecipeList().containsInput(aStack) : null!=getRecipeList().findRecipe(getBaseMetaTileEntity(), mLastRecipe, true, V[mTier], new FluidStack[] {getFillableStack()}, getSpecialSlot(), new ItemStack[] {aStack}); - case 2: return (!mRequiresFluidForFiltering || getFillableStack() != null) && (((getInputAt(0)!=null&&getInputAt(1)!=null) || (getInputAt(0)==null&&getInputAt(1)==null?getRecipeList().containsInput(aStack):(getRecipeList().containsInput(aStack)&&null!=getRecipeList().findRecipe(getBaseMetaTileEntity(), mLastRecipe, true, V[mTier], new FluidStack[] {getFillableStack()}, getSpecialSlot(), aIndex == getInputSlot() ? new ItemStack[] {aStack, getInputAt(1)} : new ItemStack[] {getInputAt(0), aStack}))))); - default: return getRecipeList().containsInput(aStack); - } - } + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + if (!super.allowPutStack(aBaseMetaTileEntity, aIndex, aSide, aStack)) return false; + if (mInventory[aIndex] != null) return true; + switch (mInputSlotCount) { + case 0: + return false; + case 1: + return getFillableStack() == null ? !mRequiresFluidForFiltering && getRecipeList().containsInput(aStack) : null != getRecipeList().findRecipe(getBaseMetaTileEntity(), mLastRecipe, true, V[mTier], new FluidStack[]{getFillableStack()}, getSpecialSlot(), new ItemStack[]{aStack}); + case 2: + return (!mRequiresFluidForFiltering || getFillableStack() != null) && (((getInputAt(0) != null && getInputAt(1) != null) || (getInputAt(0) == null && getInputAt(1) == null ? getRecipeList().containsInput(aStack) : (getRecipeList().containsInput(aStack) && null != getRecipeList().findRecipe(getBaseMetaTileEntity(), mLastRecipe, true, V[mTier], new FluidStack[]{getFillableStack()}, getSpecialSlot(), aIndex == getInputSlot() ? new ItemStack[]{aStack, getInputAt(1)} : new ItemStack[]{getInputAt(0), aStack}))))); + default: + return getRecipeList().containsInput(aStack); + } + } @Override public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Maintenance.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Maintenance.java index 339c3ae8db..3bcd29a6c9 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Maintenance.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Maintenance.java @@ -1,8 +1,5 @@ package gregtech.api.metatileentity.implementations; -import java.util.ArrayList; -import java.util.List; - import gregtech.GT_Mod; import gregtech.api.GregTech_API; import gregtech.api.enums.ItemList; @@ -28,6 +25,8 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import scala.actors.threadpool.Arrays; +import java.util.List; + public class GT_MetaTileEntity_Hatch_Maintenance extends GT_MetaTileEntity_Hatch { public boolean mWrench = false, mScrewdriver = false, mSoftHammer = false, mHardHammer = false, mSolderingTool = false, mCrowbar = false, mAuto; @@ -35,7 +34,7 @@ public class GT_MetaTileEntity_Hatch_Maintenance extends GT_MetaTileEntity_Hatch super(aID, aName, aNameRegional, aTier, 1, "For maintaining Multiblocks"); mAuto = false; } - + public GT_MetaTileEntity_Hatch_Maintenance(int aID, String aName, String aNameRegional, int aTier, boolean aAuto) { super(aID, aName, aNameRegional, aTier, 4, "For automatically maintaining Multiblocks"); mAuto = aAuto; @@ -53,19 +52,19 @@ public class GT_MetaTileEntity_Hatch_Maintenance extends GT_MetaTileEntity_Hatch @Override public String[] getDescription() { - if (mAuto) { - String[] desc = new String[mDescriptionArray.length + 3]; - System.arraycopy(mDescriptionArray, 0, desc, 0, mDescriptionArray.length); - desc[mDescriptionArray.length] = "4 Ducttape, 2 Lubricant Cells"; - desc[mDescriptionArray.length + 1] = "4 Steel Screws, 2 Adv Circuits"; - desc[mDescriptionArray.length + 2] = "For each autorepair"; - return desc; - } else { - String[] desc = new String[mDescriptionArray.length + 1]; - System.arraycopy(mDescriptionArray, 0, desc, 0, mDescriptionArray.length); - desc[mDescriptionArray.length] = "Cannot be shared between Multiblocks!"; - return desc; - } + if (mAuto) { + String[] desc = new String[mDescriptionArray.length + 3]; + System.arraycopy(mDescriptionArray, 0, desc, 0, mDescriptionArray.length); + desc[mDescriptionArray.length] = "4 Ducttape, 2 Lubricant Cells"; + desc[mDescriptionArray.length + 1] = "4 Steel Screws, 2 Adv Circuits"; + desc[mDescriptionArray.length + 2] = "For each autorepair"; + return desc; + } else { + String[] desc = new String[mDescriptionArray.length + 1]; + System.arraycopy(mDescriptionArray, 0, desc, 0, mDescriptionArray.length); + desc[mDescriptionArray.length] = "Cannot be shared between Multiblocks!"; + return desc; + } } @Override @@ -105,7 +104,8 @@ public class GT_MetaTileEntity_Hatch_Maintenance extends GT_MetaTileEntity_Hatch @Override public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - if(aTileEntity.getMetaTileID()==111) return new GT_MetaTileEntity_Hatch_Maintenance(mName, mTier, mDescriptionArray, mTextures, true); + if (aTileEntity.getMetaTileID() == 111) + return new GT_MetaTileEntity_Hatch_Maintenance(mName, mTier, mDescriptionArray, mTextures, true); return new GT_MetaTileEntity_Hatch_Maintenance(mName, mTier, mDescriptionArray, mTextures, false); } @@ -118,65 +118,65 @@ public class GT_MetaTileEntity_Hatch_Maintenance extends GT_MetaTileEntity_Hatch @Override public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - if(mAuto) return new GT_Container_2by2(aPlayerInventory, aBaseMetaTileEntity); + if (mAuto) return new GT_Container_2by2(aPlayerInventory, aBaseMetaTileEntity); return new GT_Container_MaintenanceHatch(aPlayerInventory, aBaseMetaTileEntity); } @Override public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - if(mAuto) return new GT_GUIContainer_2by2(aPlayerInventory, aBaseMetaTileEntity, getLocalName()); + if (mAuto) return new GT_GUIContainer_2by2(aPlayerInventory, aBaseMetaTileEntity, getLocalName()); return new GT_GUIContainer_MaintenanceHatch(aPlayerInventory, aBaseMetaTileEntity); } - + public boolean autoMaintainance() { - boolean tSuccess = true; - ItemStack[] mInputs = new ItemStack[]{ItemList.Duct_Tape.get(4, new Object[]{}),GT_OreDictUnificator.get(OrePrefixes.cell, Materials.Lubricant, 2),GT_OreDictUnificator.get(OrePrefixes.screw, Materials.Steel, 4),GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Advanced, 2)}; - List<ItemStack> aInputs = Arrays.asList(mInventory); - if (mInputs.length > 0 && aInputs == null) tSuccess = false; - int amt = 0; - for (ItemStack tStack : mInputs) { - if (tStack != null) { - amt = tStack.stackSize; - boolean temp = true; - for (ItemStack aStack : aInputs) { - if ((GT_Utility.areUnificationsEqual(aStack, tStack, true) || GT_Utility.areUnificationsEqual(GT_OreDictUnificator.get(false, aStack), tStack, true))) { - amt -= aStack.stackSize; - if (amt < 1) { - temp = false; - break; - } - } + boolean tSuccess = true; + ItemStack[] mInputs = new ItemStack[]{ItemList.Duct_Tape.get(4, new Object[]{}), GT_OreDictUnificator.get(OrePrefixes.cell, Materials.Lubricant, 2), GT_OreDictUnificator.get(OrePrefixes.screw, Materials.Steel, 4), GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Advanced, 2)}; + List<ItemStack> aInputs = Arrays.asList(mInventory); + if (mInputs.length > 0 && aInputs == null) tSuccess = false; + int amt = 0; + for (ItemStack tStack : mInputs) { + if (tStack != null) { + amt = tStack.stackSize; + boolean temp = true; + for (ItemStack aStack : aInputs) { + if ((GT_Utility.areUnificationsEqual(aStack, tStack, true) || GT_Utility.areUnificationsEqual(GT_OreDictUnificator.get(false, aStack), tStack, true))) { + amt -= aStack.stackSize; + if (amt < 1) { + temp = false; + break; } - if (temp) tSuccess = false; } } - if(tSuccess){ - for (ItemStack tStack : mInputs) { - if (tStack != null) { - amt = tStack.stackSize; - for (ItemStack aStack : aInputs) { - if ((GT_Utility.areUnificationsEqual(aStack, tStack, true) || GT_Utility.areUnificationsEqual(GT_OreDictUnificator.get(false, aStack), tStack, true))) { - if (aStack.stackSize < amt){ - amt -= aStack.stackSize; - aStack.stackSize = 0; - }else{ - aStack.stackSize -= amt; - amt = 0; - break; - } + if (temp) tSuccess = false; + } + } + if (tSuccess) { + for (ItemStack tStack : mInputs) { + if (tStack != null) { + amt = tStack.stackSize; + for (ItemStack aStack : aInputs) { + if ((GT_Utility.areUnificationsEqual(aStack, tStack, true) || GT_Utility.areUnificationsEqual(GT_OreDictUnificator.get(false, aStack), tStack, true))) { + if (aStack.stackSize < amt) { + amt -= aStack.stackSize; + aStack.stackSize = 0; + } else { + aStack.stackSize -= amt; + amt = 0; + break; } } } } - this.mCrowbar = true; - this.mHardHammer = true; - this.mScrewdriver = true; - this.mSoftHammer = true; - this.mSolderingTool = true; - this.mWrench = true; - return true; - } - return false; + } + this.mCrowbar = true; + this.mHardHammer = true; + this.mScrewdriver = true; + this.mSoftHammer = true; + this.mSolderingTool = true; + this.mWrench = true; + return true; + } + return false; } public void onToolClick(ItemStack aStack, EntityLivingBase aPlayer) { @@ -199,7 +199,10 @@ public class GT_MetaTileEntity_Hatch_Maintenance extends GT_MetaTileEntity_Hatch } if (mSolderingTool && aPlayer instanceof EntityPlayerMP) { EntityPlayerMP tPlayer = (EntityPlayerMP) aPlayer; - try{GT_Mod.instance.achievements.issueAchievement(tPlayer, "maintainance");}catch(Exception e){} + try { + GT_Mod.achievements.issueAchievement(tPlayer, "maintainance"); + } catch (Exception ignored) { + } } } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Muffler.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Muffler.java index 1445323fd5..dde8d7cf4f 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Muffler.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Muffler.java @@ -25,11 +25,11 @@ public class GT_MetaTileEntity_Hatch_Muffler extends GT_MetaTileEntity_Hatch { @Override public String[] getDescription() { - String[] desc = new String[mDescriptionArray.length + 2]; - System.arraycopy(mDescriptionArray, 0, desc, 0, mDescriptionArray.length); - desc[mDescriptionArray.length] = "DO NOT OBSTRUCT THE OUTPUT!"; - desc[mDescriptionArray.length + 1] = "Reduces Pollution to "+calculatePollutionReduction(100)+"%"; - return desc; + String[] desc = new String[mDescriptionArray.length + 2]; + System.arraycopy(mDescriptionArray, 0, desc, 0, mDescriptionArray.length); + desc[mDescriptionArray.length] = "DO NOT OBSTRUCT THE OUTPUT!"; + desc[mDescriptionArray.length + 1] = "Reduces Pollution to " + calculatePollutionReduction(100) + "%"; + return desc; } @Override @@ -68,15 +68,15 @@ public class GT_MetaTileEntity_Hatch_Muffler extends GT_MetaTileEntity_Hatch { } public boolean polluteEnvironment() { - if(getBaseMetaTileEntity().getAirAtSide(getBaseMetaTileEntity().getFrontFacing())){ - GT_Pollution.addPollution(this.getBaseMetaTileEntity().getWorld(), new ChunkPosition(this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getYCoord(), this.getBaseMetaTileEntity().getZCoord()), calculatePollutionReduction(10000)); - return true; - } + if (getBaseMetaTileEntity().getAirAtSide(getBaseMetaTileEntity().getFrontFacing())) { + GT_Pollution.addPollution(this.getBaseMetaTileEntity().getWorld(), new ChunkPosition(this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getYCoord(), this.getBaseMetaTileEntity().getZCoord()), calculatePollutionReduction(10000)); + return true; + } return false; } - - public int calculatePollutionReduction(int aPollution){ - return (int) (aPollution *(Math.pow(0.7, mTier-1))); + + public int calculatePollutionReduction(int aPollution) { + return (int) (aPollution * (Math.pow(0.7, mTier - 1))); } @Override diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java index 75fbf0fd2a..3dd59126b8 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java @@ -117,8 +117,8 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { aNBT.setInteger("mRuntime", mRuntime); if (mOutputItems != null) { - aNBT.setInteger("mOutputItemsLength", mOutputItems.length); - for (int i = 0; i < mOutputItems.length; i++) + aNBT.setInteger("mOutputItemsLength", mOutputItems.length); + for (int i = 0; i < mOutputItems.length; i++) if (mOutputItems[i] != null) { NBTTagCompound tNBT = new NBTTagCompound(); mOutputItems[i].writeToNBT(tNBT); @@ -126,8 +126,8 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { } } if (mOutputFluids != null) { - aNBT.setInteger("mOutputFluidsLength", mOutputFluids.length); - for (int i = 0; i < mOutputFluids.length; i++) + aNBT.setInteger("mOutputFluidsLength", mOutputFluids.length); + for (int i = 0; i < mOutputFluids.length; i++) if (mOutputFluids[i] != null) { NBTTagCompound tNBT = new NBTTagCompound(); mOutputFluids[i].writeToNBT(tNBT); @@ -152,12 +152,12 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { mEfficiency = aNBT.getInteger("mEfficiency"); mPollution = aNBT.getInteger("mPollution"); mRuntime = aNBT.getInteger("mRuntime"); - + int aOutputItemsLength = aNBT.getInteger("mOutputItemsLength"); if (aOutputItemsLength > 0) { mOutputItems = new ItemStack[aOutputItemsLength]; for (int i = 0; i < mOutputItems.length; i++) - mOutputItems[i] = GT_Utility.loadItem(aNBT, "mOutputItem" + i); + mOutputItems[i] = GT_Utility.loadItem(aNBT, "mOutputItem" + i); } int aOutputFluidsLength = aNBT.getInteger("mOutputFluidsLength"); @@ -166,7 +166,7 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { for (int i = 0; i < mOutputFluids.length; i++) mOutputFluids[i] = GT_Utility.loadFluid(aNBT, "mOutputFluids" + i); } - + mWrench = aNBT.getBoolean("mWrench"); mScrewdriver = aNBT.getBoolean("mScrewdriver"); mSoftHammer = aNBT.getBoolean("mSoftHammer"); @@ -222,7 +222,8 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { for (GT_MetaTileEntity_Hatch_Maintenance tHatch : mMaintenanceHatches) { if (isValidMetaTileEntity(tHatch)) { if (!GT_MetaTileEntity_MultiBlockBase.disableMaintenance) { - if(tHatch.mAuto && (!mWrench||!mScrewdriver||!mSoftHammer||!mHardHammer||!mSolderingTool||!mCrowbar))tHatch.autoMaintainance(); + if (tHatch.mAuto && (!mWrench || !mScrewdriver || !mSoftHammer || !mHardHammer || !mSolderingTool || !mCrowbar)) + tHatch.autoMaintainance(); if (tHatch.mWrench) mWrench = true; if (tHatch.mScrewdriver) mScrewdriver = true; if (tHatch.mSoftHammer) mSoftHammer = true; @@ -255,7 +256,10 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { if (mMaxProgresstime > 0 && ++mProgresstime >= mMaxProgresstime) { if (mOutputItems != null) for (ItemStack tStack : mOutputItems) if (tStack != null) { - try{GT_Mod.achievements.issueAchivementHatch(aBaseMetaTileEntity.getWorld().getPlayerEntityByName(aBaseMetaTileEntity.getOwnerName()), tStack);}catch(Exception e){} + try { + GT_Mod.achievements.issueAchivementHatch(aBaseMetaTileEntity.getWorld().getPlayerEntityByName(aBaseMetaTileEntity.getOwnerName()), tStack); + } catch (Exception ignored) { + } addOutput(tStack); } if (mOutputFluids != null && mOutputFluids.length == 1) { @@ -276,7 +280,7 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { if (mOutputFluids.length > 1) { try { GT_Mod.achievements.issueAchievement(aBaseMetaTileEntity.getWorld().getPlayerEntityByName(aBaseMetaTileEntity.getOwnerName()), "oilplant"); - } catch (Exception e) { + } catch (Exception ignored) { } } } @@ -724,7 +728,7 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); if (aMetaTileEntity == null) return false; if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance) { - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; return mMaintenanceHatches.add((GT_MetaTileEntity_Hatch_Maintenance) aMetaTileEntity); } return false; diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_TieredMachineBlock.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_TieredMachineBlock.java index 7a77861494..4187307c6b 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_TieredMachineBlock.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_TieredMachineBlock.java @@ -13,7 +13,7 @@ public abstract class GT_MetaTileEntity_TieredMachineBlock extends MetaTileEntit @Deprecated public final String mDescription; - + /** * A simple Description. */ @@ -37,7 +37,7 @@ public abstract class GT_MetaTileEntity_TieredMachineBlock extends MetaTileEntit public GT_MetaTileEntity_TieredMachineBlock(int aID, String aName, String aNameRegional, int aTier, int aInvSlotCount, String[] aDescription, ITexture... aTextures) { super(aID, aName, aNameRegional, aInvSlotCount); mTier = (byte) Math.max(0, Math.min(aTier, 9)); - mDescriptionArray = aDescription == null ? new String[0] : aDescription; + mDescriptionArray = aDescription == null ? new String[0] : aDescription; mDescription = mDescriptionArray.length > 0 ? mDescriptionArray[0] : ""; // must always be the last call! diff --git a/src/main/java/gregtech/api/util/GT_Recipe.java b/src/main/java/gregtech/api/util/GT_Recipe.java index aed39defb2..2c3134816d 100644 --- a/src/main/java/gregtech/api/util/GT_Recipe.java +++ b/src/main/java/gregtech/api/util/GT_Recipe.java @@ -76,7 +76,7 @@ public class GT_Recipe implements Comparable<GT_Recipe> { * Used for describing recipes that do not fit the default recipe pattern (for example Large Boiler Fuels) */ private String[] neiDesc = null; - + private GT_Recipe(GT_Recipe aRecipe) { mInputs = GT_Utility.copyStackArray((Object[]) aRecipe.mInputs); mOutputs = GT_Utility.copyStackArray((Object[]) aRecipe.mOutputs); @@ -93,6 +93,7 @@ public class GT_Recipe implements Comparable<GT_Recipe> { mEnabled = aRecipe.mEnabled; mHidden = aRecipe.mHidden; } + protected GT_Recipe(boolean aOptimize, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecialItems, int[] aChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) { if (aInputs == null) aInputs = new ItemStack[0]; if (aOutputs == null) aOutputs = new ItemStack[0]; @@ -330,13 +331,13 @@ public class GT_Recipe implements Comparable<GT_Recipe> { boolean temp = true; amt = tFluid.amount; for (FluidStack aFluid : aFluidInputs) - if (aFluid != null && aFluid.isFluidEqual(tFluid)){ - if (aDontCheckStackSizes ){ + if (aFluid != null && aFluid.isFluidEqual(tFluid)) { + if (aDontCheckStackSizes) { temp = false; break; } amt -= aFluid.amount; - if (amt<1){ + if (amt < 1) { temp = false; break; } @@ -397,14 +398,14 @@ public class GT_Recipe implements Comparable<GT_Recipe> { amt = tStack.stackSize; for (ItemStack aStack : aInputs) { if ((GT_Utility.areUnificationsEqual(aStack, tStack, true) || GT_Utility.areUnificationsEqual(GT_OreDictUnificator.get(false, aStack), tStack, true))) { - if (aDontCheckStackSizes){ + if (aDontCheckStackSizes) { aStack.stackSize -= amt; break; } - if (aStack.stackSize < amt){ + if (aStack.stackSize < amt) { amt -= aStack.stackSize; aStack.stackSize = 0; - }else{ + } else { aStack.stackSize -= amt; amt = 0; break; @@ -441,15 +442,16 @@ public class GT_Recipe implements Comparable<GT_Recipe> { } public String[] getNeiDesc() { - return neiDesc; - } - protected void setNeiDesc(String... neiDesc) { - this.neiDesc = neiDesc; - } + return neiDesc; + } - public static class GT_Recipe_AssemblyLine{ + protected void setNeiDesc(String... neiDesc) { + this.neiDesc = neiDesc; + } + + public static class GT_Recipe_AssemblyLine { public static final ArrayList<GT_Recipe_AssemblyLine> sAssemblylineRecipes = new ArrayList<GT_Recipe_AssemblyLine>(); - + public ItemStack mResearchItem; public int mResearchTime; public ItemStack[] mInputs; @@ -457,17 +459,17 @@ public class GT_Recipe implements Comparable<GT_Recipe> { public ItemStack mOutput; public int mDuration; public int mEUt; - + public GT_Recipe_AssemblyLine(ItemStack aResearchItem, int aResearchTime, ItemStack[] aInputs, FluidStack[] aFluidInputs, ItemStack aOutput, int aDuration, int aEUt) { - mResearchItem = aResearchItem; - mResearchTime = aResearchTime; - mInputs = aInputs; - mFluidInputs = aFluidInputs; - mOutput = aOutput; - mDuration = aDuration; - mEUt = aEUt; - } - + mResearchItem = aResearchItem; + mResearchTime = aResearchTime; + mInputs = aInputs; + mFluidInputs = aFluidInputs; + mOutput = aOutput; + mDuration = aDuration; + mEUt = aEUt; + } + } public static class GT_Recipe_Map { @@ -489,7 +491,7 @@ public class GT_Recipe implements Comparable<GT_Recipe> { public static final GT_Recipe_Map sByProductList = new GT_Recipe_Map(new HashSet<GT_Recipe>(1000), "gt.recipe.byproductlist", "Ore Byproduct List", null, RES_PATH_GUI + "basicmachines/Default", 1, 6, 1, 0, 1, E, 1, E, true, true); public static final GT_Recipe_Map sReplicatorFakeRecipes = new GT_Recipe_Map(new HashSet<GT_Recipe>(100), "gt.recipe.replicator", "Replicator", null, RES_PATH_GUI + "basicmachines/Replicator", 0, 1, 0, 1, 1, E, 1, E, true, true); public static final GT_Recipe_Map sAssemblylineFakeRecipes = new GT_Recipe_Map(new HashSet<GT_Recipe>(30), "gt.recipe.scanner", "Scanner", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 1, 0, 1, E, 1, E, true, true); - + public static final GT_Recipe_Map sPlasmaArcFurnaceRecipes = new GT_Recipe_Map(new HashSet<GT_Recipe>(10000), "gt.recipe.plasmaarcfurnace", "Plasma Arc Furnace", null, RES_PATH_GUI + "basicmachines/PlasmaArcFurnace", 1, 4, 1, 1, 1, E, 1, E, true, true); public static final GT_Recipe_Map sArcFurnaceRecipes = new GT_Recipe_Map(new HashSet<GT_Recipe>(10000), "gt.recipe.arcfurnace", "Arc Furnace", null, RES_PATH_GUI + "basicmachines/ArcFurnace", 1, 4, 1, 1, 3, E, 1, E, true, true); public static final GT_Recipe_Map sPrinterRecipes = new GT_Recipe_Map_Printer(new HashSet<GT_Recipe>(100), "gt.recipe.printer", "Printer", null, RES_PATH_GUI + "basicmachines/Printer", 1, 1, 1, 1, 1, E, 1, E, true, true); @@ -545,7 +547,7 @@ public class GT_Recipe implements Comparable<GT_Recipe> { public static final GT_Recipe_Map_Fuel sLargeNaquadahReactorFuels = new GT_Recipe_Map_Fuel(new HashSet<GT_Recipe>(10), "gt.recipe.largenaquadahreactor", "Large Naquadah Reactor", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); public static final GT_Recipe_Map_Fuel sFluidNaquadahReactorFuels = new GT_Recipe_Map_Fuel(new HashSet<GT_Recipe>(10), "gt.recipe.fluidnaquadahreactor", "Fluid Naquadah Reactor", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); public static final GT_Recipe_Map_Large_Boiler_Fake_Fuels sLargeBoilerFakeFuels = new GT_Recipe_Map_Large_Boiler_Fake_Fuels(); - + /** * HashMap of Recipes based on their Items */ @@ -1378,47 +1380,46 @@ public class GT_Recipe implements Comparable<GT_Recipe> { } public static class GT_Recipe_Map_Large_Boiler_Fake_Fuels extends GT_Recipe_Map { - - public GT_Recipe_Map_Large_Boiler_Fake_Fuels(){ - super(new HashSet<GT_Recipe>(30), "gt.recipe.largeboilerfakefuels", "Large Boiler", null, RES_PATH_GUI + "basicmachines/Default", 1, 0, 1, 0, 1, E, 1, E, true , true); - GT_Recipe explanatoryRecipe = new GT_Recipe(true, new ItemStack[]{}, new ItemStack[]{}, null, null, null, null, 1, 1, 1); - explanatoryRecipe.setNeiDesc("Not all solid fuels are listed.", "Any item that burns in a", "vanilla furnace will burn in", "a Large Boiler."); - addRecipe(explanatoryRecipe); - } - - public GT_Recipe addDenseLiquidRecipe(GT_Recipe recipe) { - return addRecipe(recipe, ((double)recipe.mSpecialValue) / 10); - } - - public GT_Recipe addDieselRecipe(GT_Recipe recipe) { - return addRecipe(recipe,((double)recipe.mSpecialValue) / 40); - } - - public void addSolidRecipes(ItemStack ... itemStacks) { - for(ItemStack itemStack : itemStacks){ - addSolidRecipe(itemStack); - } - } - - public GT_Recipe addSolidRecipe(ItemStack fuelItemStack){ - return addRecipe(new GT_Recipe(true, new ItemStack[]{fuelItemStack}, new ItemStack[]{}, null, null, null, null, 1, 0, GT_ModHandler.getFuelValue(fuelItemStack) / 1600), ((double)GT_ModHandler.getFuelValue(fuelItemStack)) / 1600); - } - - private GT_Recipe addRecipe(GT_Recipe recipe, double baseBurnTime){ - recipe = new GT_Recipe(recipe); - - double bronzeBurnTime = baseBurnTime * 2; - double steelBurnTime = baseBurnTime * 1.5; - double titaniumBurnTime = baseBurnTime * 1.3; - double tungstensteelBurnTime = baseBurnTime * 1.2; - - recipe.setNeiDesc("Burn time in seconds:", - String.format("Bronze Boiler: %.4f", bronzeBurnTime), - String.format("Steel Boiler: %.4f", steelBurnTime), - String.format("Titanium Boiler: %.4f", titaniumBurnTime), - String.format("Tungstensteel Boiler: %.4f", tungstensteelBurnTime)); - return super.addRecipe(recipe); - } - + + public GT_Recipe_Map_Large_Boiler_Fake_Fuels() { + super(new HashSet<GT_Recipe>(30), "gt.recipe.largeboilerfakefuels", "Large Boiler", null, RES_PATH_GUI + "basicmachines/Default", 1, 0, 1, 0, 1, E, 1, E, true, true); + GT_Recipe explanatoryRecipe = new GT_Recipe(true, new ItemStack[]{}, new ItemStack[]{}, null, null, null, null, 1, 1, 1); + explanatoryRecipe.setNeiDesc("Not all solid fuels are listed.", "Any item that burns in a", "vanilla furnace will burn in", "a Large Boiler."); + addRecipe(explanatoryRecipe); + } + + public GT_Recipe addDenseLiquidRecipe(GT_Recipe recipe) { + return addRecipe(recipe, ((double) recipe.mSpecialValue) / 10); + } + + public GT_Recipe addDieselRecipe(GT_Recipe recipe) { + return addRecipe(recipe, ((double) recipe.mSpecialValue) / 40); + } + + public void addSolidRecipes(ItemStack... itemStacks) { + for (ItemStack itemStack : itemStacks) { + addSolidRecipe(itemStack); + } + } + + public GT_Recipe addSolidRecipe(ItemStack fuelItemStack) { + return addRecipe(new GT_Recipe(true, new ItemStack[]{fuelItemStack}, new ItemStack[]{}, null, null, null, null, 1, 0, GT_ModHandler.getFuelValue(fuelItemStack) / 1600), ((double) GT_ModHandler.getFuelValue(fuelItemStack)) / 1600); + } + + private GT_Recipe addRecipe(GT_Recipe recipe, double baseBurnTime) { + recipe = new GT_Recipe(recipe); + + double bronzeBurnTime = baseBurnTime * 2; + double steelBurnTime = baseBurnTime * 1.5; + double titaniumBurnTime = baseBurnTime * 1.3; + double tungstensteelBurnTime = baseBurnTime * 1.2; + + recipe.setNeiDesc("Burn time in seconds:", + String.format("Bronze Boiler: %.4f", bronzeBurnTime), + String.format("Steel Boiler: %.4f", steelBurnTime), + String.format("Titanium Boiler: %.4f", titaniumBurnTime), + String.format("Tungstensteel Boiler: %.4f", tungstensteelBurnTime)); + return super.addRecipe(recipe); + } } } |