diff options
Diffstat (limited to 'src/main/java/gregtech/api/metatileentity/implementations')
17 files changed, 332 insertions, 140 deletions
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Cable.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Cable.java index a4c9c2b08d..46eaa4f065 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Cable.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Cable.java @@ -40,9 +40,11 @@ public class GT_MetaPipeEntity_Cable extends MetaPipeEntity implements IMetaTile public final Materials mMaterial; public final long mCableLossPerMeter, mAmperage, mVoltage; public final boolean mInsulated, mCanShock; - public long mTransferredAmperage = 0, mTransferredAmperageLast20 = 0, mTransferredVoltageLast20 = 0; + public int mTransferredAmperage = 0, mTransferredAmperageLast20 = 0,mTransferredAmperageLast20OK=0,mTransferredAmperageOK=0; + public long mTransferredVoltageLast20 = 0, mTransferredVoltage = 0,mTransferredVoltageLast20OK=0,mTransferredVoltageOK=0; public long mRestRF; public short mOverheat; + public static short mMaxOverheat=(short) (GT_Mod.gregtechproxy.mWireHeatingTicks * 100); public GT_MetaPipeEntity_Cable(int aID, String aName, String aNameRegional, float aThickNess, Materials aMaterial, long aCableLossPerMeter, long aAmperage, long aVoltage, boolean aInsulated, boolean aCanShock) { super(aID, aName, aNameRegional, 0); @@ -203,7 +205,8 @@ public class GT_MetaPipeEntity_Cable extends MetaPipeEntity implements IMetaTile } } else if (GregTech_API.mOutputRF && tTileEntity instanceof IEnergyReceiver) { ForgeDirection tDirection = ForgeDirection.getOrientation(i).getOpposite(); - int rfOut = (int) (aVoltage * GregTech_API.mEUtoRF / 100); + long rfOUT = aVoltage * GregTech_API.mEUtoRF / 100; + int rfOut = rfOUT>Integer.MAX_VALUE ? Integer.MAX_VALUE : (int)rfOUT; if (((IEnergyReceiver) tTileEntity).receiveEnergy(tDirection, rfOut, true) == rfOut) { ((IEnergyReceiver) tTileEntity).receiveEnergy(tDirection, rfOut, false); rUsedAmperes++; @@ -223,24 +226,33 @@ public class GT_MetaPipeEntity_Cable extends MetaPipeEntity implements IMetaTile } } } + mTransferredVoltage=(Math.max(mTransferredVoltage,aVoltage)); mTransferredAmperage += rUsedAmperes; - mTransferredVoltageLast20 = Math.max(mTransferredVoltageLast20, aVoltage); + mTransferredVoltageLast20 = (Math.max(mTransferredVoltageLast20, aVoltage)); mTransferredAmperageLast20 = Math.max(mTransferredAmperageLast20, mTransferredAmperage); if (aVoltage > mVoltage || mTransferredAmperage > mAmperage) { - if(mOverheat>GT_Mod.gregtechproxy.mWireHeatingTicks * 100){ - getBaseMetaTileEntity().setToFire();}else{mOverheat +=100;} + if(mOverheat>mMaxOverheat) + getBaseMetaTileEntity().setToFire(); + else + mOverheat +=100; return aAmperage; } return rUsedAmperes; + //Always return amount of used amperes, used all on overheat } @Override public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { if (aBaseMetaTileEntity.isServerSide()) { + mTransferredVoltageOK=mTransferredVoltage; + mTransferredVoltage=0; + mTransferredAmperageOK=mTransferredAmperage; mTransferredAmperage = 0; if(mOverheat>0)mOverheat--; if (aTick % 20 == 0) { + mTransferredVoltageLast20OK=mTransferredVoltageLast20; mTransferredVoltageLast20 = 0; + mTransferredAmperageLast20OK=mTransferredAmperageLast20; mTransferredAmperageLast20 = 0; mConnections = 0; for (byte i = 0, j = 0; i < 6; i++) { @@ -316,4 +328,28 @@ public class GT_MetaPipeEntity_Cable extends MetaPipeEntity implements IMetaTile public void loadNBTData(NBTTagCompound aNBT) { // } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public String[] getInfoData() { + return new String[]{ + //EnumChatFormatting.BLUE + mName + EnumChatFormatting.RESET, + "Heat: "+ + EnumChatFormatting.RED+ mOverheat +EnumChatFormatting.RESET+" / "+EnumChatFormatting.YELLOW+ mMaxOverheat + EnumChatFormatting.RESET, + "Max Load (1t):", + EnumChatFormatting.GREEN + Integer.toString(mTransferredAmperageOK) + EnumChatFormatting.RESET +" A / "+ + EnumChatFormatting.YELLOW + Long.toString(mAmperage) + EnumChatFormatting.RESET +" A", + "Max EU/p (1t):", + EnumChatFormatting.GREEN + Long.toString(mTransferredVoltageOK) + EnumChatFormatting.RESET +" EU / "+ + EnumChatFormatting.YELLOW + Long.toString(mVoltage) + EnumChatFormatting.RESET +" EU", + "Max Load (20t): "+ + EnumChatFormatting.GREEN + Integer.toString(mTransferredAmperageLast20OK) + EnumChatFormatting.RESET +" A", + "Max EU/p (20t): "+ + EnumChatFormatting.GREEN + Long.toString(mTransferredVoltageLast20OK) + EnumChatFormatting.RESET +" EU" + }; + } } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Fluid.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Fluid.java index ed6b8cd460..576e2c854e 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Fluid.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Fluid.java @@ -2,11 +2,7 @@ package gregtech.api.metatileentity.implementations; import gregtech.GT_Mod; import gregtech.api.GregTech_API; -import gregtech.api.enums.Dyes; -import gregtech.api.enums.ItemList; -import gregtech.api.enums.Materials; -import gregtech.api.enums.OrePrefixes; -import gregtech.api.enums.SubTag; +import gregtech.api.enums.*; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.ICoverable; @@ -416,4 +412,4 @@ public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity { if(GT_Mod.instance.isClientSide() && GT_Client.hideValue==1) return 0.0625F; return mThickNess; } -}
\ No newline at end of file +} diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicBatteryBuffer.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicBatteryBuffer.java index 5c24805503..c35690b868 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicBatteryBuffer.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicBatteryBuffer.java @@ -13,6 +13,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; import static gregtech.api.enums.GT_Values.V; @@ -54,7 +55,7 @@ public class GT_MetaTileEntity_BasicBatteryBuffer extends GT_MetaTileEntity_Tier ITexture[][][] rTextures = new ITexture[2][17][]; for (byte i = -1; i < 16; i++) { rTextures[0][i + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1]}; - rTextures[1][i + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], mInventory.length > 4 ? Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[mTier] : Textures.BlockIcons.OVERLAYS_ENERGY_OUT[mTier]}; + rTextures[1][i + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], mInventory.length==16 ? Textures.BlockIcons.OVERLAYS_ENERGY_OUT_POWER[mTier] : mInventory.length > 4 ? Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[mTier] : Textures.BlockIcons.OVERLAYS_ENERGY_OUT[mTier]}; } return rTextures; } @@ -116,12 +117,12 @@ public class GT_MetaTileEntity_BasicBatteryBuffer extends GT_MetaTileEntity_Tier @Override public long getMinimumStoredEU() { - return V[mTier] * 16 * mInventory.length; + return V[mTier] * 16L * mInventory.length; } @Override public long maxEUStore() { - return V[mTier] * 64 * mInventory.length; + return V[mTier] * 64L * mInventory.length; } @Override @@ -136,7 +137,7 @@ public class GT_MetaTileEntity_BasicBatteryBuffer extends GT_MetaTileEntity_Tier @Override public long maxAmperesIn() { - return mChargeableCount * 2; + return mChargeableCount * 2L; } @Override @@ -316,14 +317,15 @@ public class GT_MetaTileEntity_BasicBatteryBuffer extends GT_MetaTileEntity_Tier } return new String[]{ - getLocalName(), + EnumChatFormatting.BLUE+getLocalName()+EnumChatFormatting.RESET, "Stored Items:", - GT_Utility.formatNumbers(mStored) + " EU /", - GT_Utility.formatNumbers(mMax) + " EU"}; + EnumChatFormatting.GREEN+GT_Utility.formatNumbers(mStored) +EnumChatFormatting.RESET+ " EU / "+ + EnumChatFormatting.YELLOW+GT_Utility.formatNumbers(mMax) +EnumChatFormatting.RESET+ " EU" + }; } @Override public boolean isGivingInformation() { return true; } -}
\ No newline at end of file +} 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 73d3c19a6b..c20b8ad3a8 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 @@ -5,12 +5,11 @@ import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Recipe.GT_Recipe_Map; -import gregtech.common.GT_Pollution; import gregtech.api.util.GT_Utility; +import gregtech.common.GT_Pollution; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; -import net.minecraft.world.ChunkPosition; import net.minecraftforge.fluids.FluidStack; import java.util.Collection; @@ -144,17 +143,18 @@ public abstract class GT_MetaTileEntity_BasicGenerator extends GT_MetaTileEntity @Override public long maxEUOutput() { - return getBaseMetaTileEntity().isAllowedToWork() ? V[mTier] : 0; + return getBaseMetaTileEntity().isAllowedToWork() ? V[mTier] : 0L; } @Override public long maxEUStore() { - return Math.max(getEUVar(), V[mTier] * 40 + getMinimumStoredEU()); + return Math.max(getEUVar(), V[mTier] * 40L + getMinimumStoredEU()); } @Override public boolean doesFillContainers() { - return getBaseMetaTileEntity().isAllowedToWork(); + //return getBaseMetaTileEntity().isAllowedToWork(); + return false; } @Override @@ -188,6 +188,12 @@ public abstract class GT_MetaTileEntity_BasicGenerator extends GT_MetaTileEntity } @Override + public boolean isLiquidOutput(byte aSide) { + //return super.isLiquidOutput(aSide); + return false; + } + + @Override public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { if (aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.isAllowedToWork() && aTick % 10 == 0) { if (mFluid == null) { @@ -202,6 +208,7 @@ public abstract class GT_MetaTileEntity_BasicGenerator extends GT_MetaTileEntity int tFuelValue = getFuelValue(mFluid), tConsumed = consumedFluidPerOperation(mFluid); if (tFuelValue > 0 && tConsumed > 0 && mFluid.amount > tConsumed) { long tFluidAmountToUse = Math.min(mFluid.amount / tConsumed, (maxEUStore() - aBaseMetaTileEntity.getUniversalEnergyStored()) / tFuelValue); + //long tFluidAmountToUse = Math.min(mFluid.amount / tConsumed, (maxEUOutput() * 20 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()) / tFuelValue);//TODO CHECK if (tFluidAmountToUse > 0 && aBaseMetaTileEntity.increaseStoredEnergyUnits(tFluidAmountToUse * tFuelValue, true)) { GT_Pollution.addPollution(getBaseMetaTileEntity(),10 * getPollution()); mFluid.amount -= tFluidAmountToUse * tConsumed; @@ -224,7 +231,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.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java index 9114780b2f..9670a765ee 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java @@ -10,7 +10,6 @@ import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.objects.GT_ItemStack; import gregtech.api.objects.GT_RenderedTexture; -import gregtech.api.objects.XSTR; import gregtech.api.util.GT_OreDictUnificator; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Recipe.GT_Recipe_Map; @@ -20,6 +19,7 @@ import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.common.DimensionManager; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; @@ -208,12 +208,12 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B @Override public long getMinimumStoredEU() { - return V[mTier] * 16; + return V[mTier] * 16L; } @Override public long maxEUStore() { - return V[mTier] * 64; + return V[mTier] * 64L; } @Override @@ -228,7 +228,7 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B @Override public long maxAmperesIn() { - return (mEUt * 2) / V[mTier] + 1; + return ((long)mEUt * 2L) / V[mTier] + 1L; } @Override @@ -445,8 +445,8 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B endProcess(); } if (mProgresstime > 5) mStuttering = false; - XSTR aXSTR = new XSTR(); - if(GT_Mod.gregtechproxy.mAprilFool && aXSTR.nextInt(5000)==0)GT_Utility.sendSoundToPlayers(aBaseMetaTileEntity.getWorld(), GregTech_API.sSoundList.get(5), 10.0F, -1.0F, aBaseMetaTileEntity.getXCoord(), aBaseMetaTileEntity.getYCoord(),aBaseMetaTileEntity.getZCoord()); + //XSTR aXSTR = new XSTR(); + //if(GT_Mod.gregtechproxy.mAprilFool && aXSTR.nextInt(5000)==0)GT_Utility.sendSoundToPlayers(aBaseMetaTileEntity.getWorld(), GregTech_API.sSoundList.get(5), 10.0F, -1.0F, aBaseMetaTileEntity.getXCoord(), aBaseMetaTileEntity.getYCoord(),aBaseMetaTileEntity.getZCoord()); } else { if (!mStuttering) { stutterProcess(); @@ -486,7 +486,7 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B if (allowToCheckRecipe()) { if (mMaxProgresstime <= 0 && aBaseMetaTileEntity.isAllowedToWork() && (tRemovedOutputFluid || tSucceeded || aBaseMetaTileEntity.hasInventoryBeenModified() || aTick % 600 == 0 || aBaseMetaTileEntity.hasWorkJustBeenEnabled()) && hasEnoughEnergyToCheckRecipe()) { - if (checkRecipe() == 2) { + if (checkRecipe() == FOUND_AND_SUCCESSFULLY_USED_RECIPE) { if (mInventory[3] != null && mInventory[3].stackSize <= 0) mInventory[3] = null; for (int i = getInputSlot(), j = i + mInputSlotCount; i < j; i++) if (mInventory[i] != null && mInventory[i].stackSize <= 0) mInventory[i] = null; @@ -549,16 +549,46 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B calculateOverclockedNess(aRecipe.mEUt, aRecipe.mDuration); } + /** + * Calcualtes overclocked ness using long integers + * @param aEUt - recipe EUt + * @param aDuration - recipe Duration + */ protected void calculateOverclockedNess(int aEUt, int aDuration) { - if (aEUt <= 16) { - mEUt = aEUt * (1 << (mTier - 1)) * (1 << (mTier - 1)); - mMaxProgresstime = aDuration / (1 << (mTier - 1)); - } else { - mEUt = aEUt; + if(mTier==0){ + //Long time calculation + long xMaxProgresstime = ((long)aDuration)<<1; + if(xMaxProgresstime>Integer.MAX_VALUE-1){ + //make impossible if too long + mEUt=Integer.MAX_VALUE-1; + mMaxProgresstime=Integer.MAX_VALUE-1; + }else{ + mEUt=aEUt>>2; + mMaxProgresstime=(int)xMaxProgresstime; + } + }else{ + //Long EUt calculation + long xEUt=aEUt; + //Isnt too low EUt check? + long tempEUt = xEUt<V[1] ? V[1] : xEUt; + mMaxProgresstime = aDuration; - while (mEUt <= V[mTier - 1] * mAmperage) { - mEUt *= 4; - mMaxProgresstime /= 2; + + while (tempEUt <= V[mTier -1] * (long)mAmperage) { + tempEUt<<=2;//this actually controls overclocking + //xEUt *= 4;//this is effect of everclocking + mMaxProgresstime>>=1;//this is effect of overclocking + xEUt = mMaxProgresstime==0 ? xEUt>>1 : xEUt<<2;//U know, if the time is less than 1 tick make the machine use 2x less power + } + if(xEUt>Integer.MAX_VALUE-1){ + mEUt = Integer.MAX_VALUE-1; + mMaxProgresstime = Integer.MAX_VALUE-1; + }else{ + mEUt = (int)xEUt; + if(mEUt==0) + mEUt = 1; + if(mMaxProgresstime==0) + mMaxProgresstime = 1;//set time to 1 tick } } } @@ -694,12 +724,17 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B @Override public String[] getInfoData() { return new String[]{ - mNEIName, - "Progress:", (mProgresstime / 20) + " secs", - (mMaxProgresstime / 20) + " secs", + EnumChatFormatting.BLUE + mNEIName + EnumChatFormatting.RESET, + "Progress:", + EnumChatFormatting.GREEN + Integer.toString(mProgresstime/20) + EnumChatFormatting.RESET +" s / "+ + EnumChatFormatting.YELLOW + Integer.toString(mMaxProgresstime/20) + EnumChatFormatting.RESET +" s", "Stored Energy:", - getBaseMetaTileEntity().getStoredEU() + "EU", - getBaseMetaTileEntity().getEUCapacity() + "EU"}; + EnumChatFormatting.GREEN + Long.toString(getBaseMetaTileEntity().getStoredEU()) + EnumChatFormatting.RESET +" EU / "+ + EnumChatFormatting.YELLOW + Long.toString(getBaseMetaTileEntity().getEUCapacity()) + EnumChatFormatting.RESET +" EU", + "Probably uses: " + + EnumChatFormatting.RED + Integer.toString(mEUt) + EnumChatFormatting.RESET + " EU/t at " + + EnumChatFormatting.RED + Integer.toString(mEUt==0?0:mAmperage) + EnumChatFormatting.RESET +" A" + }; } @Override @@ -795,7 +830,12 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B if (mOutputItems[i] != null && getBaseMetaTileEntity().getRandomNumber(10000) > mCleanroom.mEfficiency) mOutputItems[i] = null; mOutputFluid = tRecipe.getFluidOutput(0); - calculateOverclockedNess(tRecipe); + if(!skipOC){ + calculateOverclockedNess(tRecipe); + //In case recipe is too OP for that machine + if (mMaxProgresstime == Integer.MAX_VALUE - 1 && mEUt == Integer.MAX_VALUE - 1) + return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; + } return FOUND_AND_SUCCESSFULLY_USED_RECIPE; } @@ -854,4 +894,4 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B public ITexture[] getSideFacingPipeInactive(byte aColor) { return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; } -}
\ No newline at end of file +} 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 06a115d3d4..d87e6d5ab8 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,7 +35,6 @@ 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; @@ -47,6 +46,8 @@ public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_ mGUIParameterA = (byte) aGUIParameterA; mGUIParameterB = (byte) aGUIParameterB; + + //TODO: CHECK if (aRecipe != null) { for (int i = 3; i < aRecipe.length; i++) { if (aRecipe[i] == X.CIRCUIT) { @@ -75,8 +76,15 @@ public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_ case 6: case 7: case 8: - aRecipe[i] = Ic2Items.reinforcedGlass; - break; + case 9: + case 10: + case 11: + case 12: + case 13: + case 14: + case 15: + aRecipe[i] = Ic2Items.reinforcedGlass; + break; default: aRecipe[i] = new ItemStack(Blocks.glass, 1, W); break; @@ -112,7 +120,7 @@ public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_ aRecipe[i] = OrePrefixes.plate.get(Materials.Neutronium); break; default: - aRecipe[i] = OrePrefixes.plate.get(Materials.TungstenSteel); + aRecipe[i] = OrePrefixes.plate.get(Materials.Neutronium); break; } continue; @@ -146,7 +154,7 @@ public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_ aRecipe[i] = OrePrefixes.pipeLarge.get(Materials.Ultimate); break; default: - aRecipe[i] = OrePrefixes.pipeMedium.get(Materials.TungstenSteel); + aRecipe[i] = OrePrefixes.pipeMedium.get(Materials.Ultimate); break; } continue; @@ -180,7 +188,7 @@ public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_ aRecipe[i] = OrePrefixes.wireGt02.get(Materials.NaquadahAlloy); break; default: - aRecipe[i] = OrePrefixes.wireGt08.get(Materials.Nichrome); + aRecipe[i] = OrePrefixes.wireGt08.get(Materials.NaquadahAlloy); break; } continue; @@ -214,7 +222,7 @@ public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_ aRecipe[i] = OrePrefixes.wireGt04.get(Materials.NaquadahAlloy); break; default: - aRecipe[i] = OrePrefixes.wireGt16.get(Materials.Nichrome); + aRecipe[i] = OrePrefixes.wireGt16.get(Materials.NaquadahAlloy); break; } continue; @@ -245,10 +253,10 @@ public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_ break; case 6: case 7: - aRecipe[i] = OrePrefixes.stickLong.get(Materials.NeodymiumMagnetic); + aRecipe[i] = OrePrefixes.stickLong.get(Materials.Samarium); break; default: - aRecipe[i] = OrePrefixes.block.get(Materials.NeodymiumMagnetic); + aRecipe[i] = OrePrefixes.block.get(Materials.Samarium); break; } continue; @@ -704,5 +712,5 @@ public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_ return !mSharedTank; } - public static enum X {PUMP, WIRE, WIRE4, HULL, PIPE, GLASS, PLATE, MOTOR, ROTOR, SENSOR, PISTON, CIRCUIT, EMITTER, CONVEYOR, ROBOT_ARM, COIL_HEATING, COIL_ELECTRIC, STICK_MAGNETIC, STICK_DISTILLATION, BETTER_CIRCUIT, FIELD_GENERATOR, COIL_HEATING_DOUBLE, STICK_ELECTROMAGNETIC;} + public static enum X {PUMP, WIRE, WIRE4, HULL, PIPE, GLASS, PLATE, MOTOR, ROTOR, SENSOR, PISTON, CIRCUIT, EMITTER, CONVEYOR, ROBOT_ARM, COIL_HEATING, COIL_ELECTRIC, STICK_MAGNETIC, STICK_DISTILLATION, BETTER_CIRCUIT, FIELD_GENERATOR, COIL_HEATING_DOUBLE, STICK_ELECTROMAGNETIC} } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java index dabb9f3f67..d2092f0b34 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java @@ -141,12 +141,12 @@ public abstract class GT_MetaTileEntity_Buffer extends GT_MetaTileEntity_TieredM @Override public long getMinimumStoredEU() { - return 512; + return 512L; } @Override public long maxEUStore() { - return 512 + V[mTier] * 50; + return 512L + V[mTier] * 50L; } @Override @@ -156,7 +156,7 @@ public abstract class GT_MetaTileEntity_Buffer extends GT_MetaTileEntity_TieredM @Override public long maxEUOutput() { - return bOutput ? V[mTier] : 0; + return bOutput ? V[mTier] : 0L; } @Override @@ -270,4 +270,4 @@ public abstract class GT_MetaTileEntity_Buffer extends GT_MetaTileEntity_TieredM public boolean allowGeneralRedstoneOutput(){ return true; } -}
\ No newline at end of file +} diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Dynamo.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Dynamo.java index e599aa0902..df28cd7e54 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Dynamo.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Dynamo.java @@ -74,7 +74,7 @@ public class GT_MetaTileEntity_Hatch_Dynamo extends GT_MetaTileEntity_Hatch { @Override public long maxEUStore() { - return 512 + V[mTier + 1] * 2; + return 512L + V[mTier + 1] * 2L; } @Override diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Energy.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Energy.java index 8d9f23f64e..bd362de26b 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Energy.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Energy.java @@ -74,7 +74,7 @@ public class GT_MetaTileEntity_Hatch_Energy extends GT_MetaTileEntity_Hatch { @Override public long maxEUStore() { - return 512 + V[mTier] * 8; + return 512L + V[mTier] * 8L; } @Override diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Input.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Input.java index 4c24a148ab..5a50e4f19d 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Input.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Input.java @@ -15,7 +15,7 @@ public class GT_MetaTileEntity_Hatch_Input extends GT_MetaTileEntity_Hatch { public GT_Recipe_Map mRecipeMap = null; public GT_MetaTileEntity_Hatch_Input(int aID, String aName, String aNameRegional, int aTier) { - super(aID, aName, aNameRegional, aTier, 3, "Fluid Input for Multiblocks (" + 8000 * (aTier + 1) + "L)"); + super(aID, aName, aNameRegional, aTier, 3, "Fluid Input for Multiblocks (" + (8000+8000*(aTier*(aTier+1)>>1)) + "L)"); } public GT_MetaTileEntity_Hatch_Input(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { @@ -65,7 +65,8 @@ public class GT_MetaTileEntity_Hatch_Input extends GT_MetaTileEntity_Hatch { @Override public boolean doesFillContainers() { - return true; + //return true; + return false; } @Override @@ -115,7 +116,7 @@ public class GT_MetaTileEntity_Hatch_Input extends GT_MetaTileEntity_Hatch { @Override public int getCapacity() { - return 8000 * (mTier + 1); + return 8000+8000*(mTier*(mTier+1)>>1); } @Override 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 608bec114e..0e0b024924 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 @@ -24,9 +24,6 @@ import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import java.util.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; @@ -69,11 +66,13 @@ public class GT_MetaTileEntity_Hatch_Maintenance extends GT_MetaTileEntity_Hatch @Override public ITexture[] getTexturesActive(ITexture aBaseTexture) { + if(mAuto)return new ITexture[]{aBaseTexture, new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_AUTOMAINTENANCE_IDLE)}; return new ITexture[]{aBaseTexture, new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_MAINTENANCE)}; } @Override public ITexture[] getTexturesInactive(ITexture aBaseTexture) { + if(mAuto)return new ITexture[]{aBaseTexture, new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_AUTOMAINTENANCE)}; return new ITexture[]{aBaseTexture, new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_MAINTENANCE), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_DUCTTAPE)}; } @@ -133,17 +132,28 @@ public class GT_MetaTileEntity_Hatch_Maintenance extends GT_MetaTileEntity_Hatch if (mInventory[i] != null && mInventory[i].stackSize <= 0) mInventory[i] = null; } - 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; + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + if(aBaseMetaTileEntity.isServerSide() && mAuto && aTick % 100L ==0L){ + aBaseMetaTileEntity.setActive(!isRecipeInputEqual(false)); + } + } + + public boolean isRecipeInputEqual(boolean aDecreaseStacksizeBySuccess) { + 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)}; + + int amt; + for (ItemStack tStack : mInputs) { if (tStack != null) { amt = tStack.stackSize; boolean temp = true; - for (ItemStack aStack : aInputs) { + for (ItemStack aStack : mInventory) { if ((GT_Utility.areUnificationsEqual(aStack, tStack, true) || GT_Utility.areUnificationsEqual(GT_OreDictUnificator.get(false, aStack), tStack, true))) { amt -= aStack.stackSize; if (amt < 1) { @@ -152,14 +162,15 @@ public class GT_MetaTileEntity_Hatch_Maintenance extends GT_MetaTileEntity_Hatch } } } - if (temp) tSuccess = false; + if (temp) return false; } } - if (tSuccess) { + + if (aDecreaseStacksizeBySuccess) { for (ItemStack tStack : mInputs) { if (tStack != null) { amt = tStack.stackSize; - for (ItemStack aStack : aInputs) { + for (ItemStack aStack : mInventory) { if ((GT_Utility.areUnificationsEqual(aStack, tStack, true) || GT_Utility.areUnificationsEqual(GT_OreDictUnificator.get(false, aStack), tStack, true))) { if (aStack.stackSize < amt) { amt -= aStack.stackSize; @@ -180,9 +191,8 @@ public class GT_MetaTileEntity_Hatch_Maintenance extends GT_MetaTileEntity_Hatch this.mSolderingTool = true; this.mWrench = true; updateSlots(); - return true; } - return false; + return true; } public void onToolClick(ItemStack aStack, EntityLivingBase aPlayer) { 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 1209b9c582..8a53a598cc 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 @@ -10,13 +10,12 @@ import gregtech.api.objects.XSTR; import gregtech.common.GT_Pollution; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; -import net.minecraft.world.ChunkPosition; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; public class GT_MetaTileEntity_Hatch_Muffler extends GT_MetaTileEntity_Hatch { public GT_MetaTileEntity_Hatch_Muffler(int aID, String aName, String aNameRegional, int aTier) { - super(aID, aName, aNameRegional, aTier, 0, "Outputs the Pollution (Might cause acidic rains and poisoning)"); + super(aID, aName, aNameRegional, aTier, 0, "Outputs the Pollution (Might cause ... things)"); } public GT_MetaTileEntity_Hatch_Muffler(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { @@ -78,9 +77,9 @@ public class GT_MetaTileEntity_Hatch_Muffler extends GT_MetaTileEntity_Hatch { } 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.85F, mTier - 1))); } @Override diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Output.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Output.java index 843cb319b6..b36e0fbdd4 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Output.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Output.java @@ -18,7 +18,7 @@ public class GT_MetaTileEntity_Hatch_Output extends GT_MetaTileEntity_Hatch { public byte mMode = 0; public GT_MetaTileEntity_Hatch_Output(int aID, String aName, String aNameRegional, int aTier) { - super(aID, aName, aNameRegional, aTier, 3, "Fluid Output for Multiblocks (" + 8000 * (aTier + 1) + "L) (Screwdriver for output type)"); + super(aID, aName, aNameRegional, aTier, 3, "Fluid Output for Multiblocks (" + (8000+8000*(aTier*(aTier+1)>>1)) + "L) (Screwdriver for output type)"); } public GT_MetaTileEntity_Hatch_Output(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { @@ -111,7 +111,7 @@ public class GT_MetaTileEntity_Hatch_Output extends GT_MetaTileEntity_Hatch { @Override public boolean doesEmptyContainers() { - return true; + return false; } @Override @@ -146,7 +146,7 @@ public class GT_MetaTileEntity_Hatch_Output extends GT_MetaTileEntity_Hatch { @Override public int getCapacity() { - return 8000 * (mTier + 1); + return 8000+8000*(mTier*(mTier+1)>>1); } @Override diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_OutputBus.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_OutputBus.java index 9b685743ca..f39694cc2d 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_OutputBus.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_OutputBus.java @@ -88,8 +88,6 @@ public class GT_MetaTileEntity_Hatch_OutputBus extends GT_MetaTileEntity_Hatch { return new GT_GUIContainer_2by2(aPlayerInventory, aBaseMetaTileEntity, "Output Bus"); case 2: return new GT_GUIContainer_3by3(aPlayerInventory, aBaseMetaTileEntity, "Output Bus"); - case 3: - return new GT_GUIContainer_4by4(aPlayerInventory, aBaseMetaTileEntity, "Output Bus"); default: return new GT_GUIContainer_4by4(aPlayerInventory, aBaseMetaTileEntity, "Output Bus"); } 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 86d74f3dac..5d6178e062 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 @@ -22,6 +22,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.fluids.FluidStack; import java.util.ArrayList; @@ -36,7 +37,7 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { public ItemStack[] mOutputItems = null; public FluidStack[] mOutputFluids = null; public String mNEI; - public int damageFactorLow = 5; + public int damageFactorLow = 5; public float damageFactorHigh = 0.6f; public ArrayList<GT_MetaTileEntity_Hatch_Input> mInputHatches = new ArrayList<GT_MetaTileEntity_Hatch_Input>(); @@ -222,30 +223,29 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { if (mMachine) { 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.mWrench) mWrench = true; - if (tHatch.mScrewdriver) mScrewdriver = true; - if (tHatch.mSoftHammer) mSoftHammer = true; - if (tHatch.mHardHammer) mHardHammer = true; - if (tHatch.mSolderingTool) mSolderingTool = true; - if (tHatch.mCrowbar) mCrowbar = true; - } else { + if (disableMaintenance){ mWrench = true; mScrewdriver = true; mSoftHammer = true; mHardHammer = true; mSolderingTool = true; mCrowbar = true; - } + } else { + if (tHatch.mAuto && !(mWrench&&mScrewdriver&&mSoftHammer&&mHardHammer&&mSolderingTool&&mCrowbar))tHatch.isRecipeInputEqual(true); + if (tHatch.mWrench) mWrench = true; + if (tHatch.mScrewdriver) mScrewdriver = true; + if (tHatch.mSoftHammer) mSoftHammer = true; + if (tHatch.mHardHammer) mHardHammer = true; + if (tHatch.mSolderingTool) mSolderingTool = true; + if (tHatch.mCrowbar) mCrowbar = true; - tHatch.mWrench = false; - tHatch.mScrewdriver = false; - tHatch.mSoftHammer = false; - tHatch.mHardHammer = false; - tHatch.mSolderingTool = false; - tHatch.mCrowbar = false; + tHatch.mWrench = false; + tHatch.mScrewdriver = false; + tHatch.mSoftHammer = false; + tHatch.mHardHammer = false; + tHatch.mSolderingTool = false; + tHatch.mCrowbar = false; + } } } if (getRepairStatus() > 0) { @@ -263,13 +263,15 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { } addOutput(tStack); } - if (mOutputFluids != null && mOutputFluids.length == 1) { - for (FluidStack tStack : mOutputFluids) - if (tStack != null) { - addOutput(tStack); - } - } else if (mOutputFluids != null && mOutputFluids.length > 1) { - addFluidOutputs(mOutputFluids); + if(mOutputFluids!=null) { + if (mOutputFluids.length == 1) { + for (FluidStack tStack : mOutputFluids) + if (tStack != null) { + addOutput(tStack); + } + } else if (mOutputFluids.length > 1) { + addFluidOutputs(mOutputFluids); + } } mEfficiency = Math.max(0, Math.min(mEfficiency + mEfficiencyIncrease, getMaxEfficiency(mInventory[1]) - ((getIdealStatus() - getRepairStatus()) * 1000))); mOutputItems = null; @@ -305,6 +307,9 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { } aBaseMetaTileEntity.setErrorDisplayID((aBaseMetaTileEntity.getErrorDisplayID() & ~127) | (mWrench ? 0 : 1) | (mScrewdriver ? 0 : 2) | (mSoftHammer ? 0 : 4) | (mHardHammer ? 0 : 8) | (mSolderingTool ? 0 : 16) | (mCrowbar ? 0 : 32) | (mMachine ? 0 : 64)); aBaseMetaTileEntity.setActive(mMaxProgresstime > 0); + boolean active=aBaseMetaTileEntity.isActive() && mPollution>0; + for(GT_MetaTileEntity_Hatch_Muffler aMuffler:mMufflerHatches) + aMuffler.getBaseMetaTileEntity().setActive(active); } } @@ -394,10 +399,11 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { return 6; } + public int getCurrentEfficiency(ItemStack itemStack) { - int maxEff = getMaxEfficiency(itemStack); - return maxEff - (getIdealStatus() - getRepairStatus()) * maxEff / 10; - } + int maxEff = getMaxEfficiency(itemStack); + return maxEff - (getIdealStatus() - getRepairStatus()) * maxEff / 10; + } public boolean doRandomMaintenanceDamage() { if (!isCorrectMachinePart(mInventory[1]) || getRepairStatus() == 0) { @@ -487,7 +493,7 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { } } - ((GT_MetaGenerated_Tool) mInventory[1].getItem()).doDamage(mInventory[1], (long) Math.min(mEUt / this.damageFactorLow, Math.pow(mEUt, this.damageFactorHigh))); + ((GT_MetaGenerated_Tool) mInventory[1].getItem()).doDamage(mInventory[1], (long)getDamageToComponent(mInventory[1]) * (long) Math.min(mEUt / this.damageFactorLow, Math.pow(mEUt, this.damageFactorHigh))); if (mInventory[1].stackSize == 0) mInventory[1] = null; } } @@ -528,6 +534,52 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { return rVoltage; } + /** + * Calcualtes overclocked ness using long integers + * @param aEUt - recipe EUt + * @param aDuration - recipe Duration + * @param mAmperage - should be 1 ? + */ + protected void calculateOverclockedNessMulti(int aEUt, int aDuration, int mAmperage, long maxInputVoltage) { + byte mTier=(byte)Math.max(0,GT_Utility.getTier(maxInputVoltage)); + if(mTier==0){ + //Long time calculation + long xMaxProgresstime = ((long)aDuration)<<1; + if(xMaxProgresstime>Integer.MAX_VALUE-1){ + //make impossible if too long + mEUt=Integer.MAX_VALUE-1; + mMaxProgresstime=Integer.MAX_VALUE-1; + }else{ + mEUt=aEUt>>2; + mMaxProgresstime=(int)xMaxProgresstime; + } + }else{ + //Long EUt calculation + long xEUt=aEUt; + //Isnt too low EUt check? + long tempEUt = xEUt<V[1] ? V[1] : xEUt; + + mMaxProgresstime = aDuration; + + while (tempEUt <= V[mTier -1] * mAmperage) { + tempEUt<<=2;//this actually controls overclocking + //xEUt *= 4;//this is effect of everclocking + mMaxProgresstime>>=1;//this is effect of overclocking + xEUt = mMaxProgresstime==0 ? xEUt>>1 : xEUt<<2;//U know, if the time is less than 1 tick make the machine use less power + } + if(xEUt>Integer.MAX_VALUE-1){ + mEUt = Integer.MAX_VALUE-1; + mMaxProgresstime = Integer.MAX_VALUE-1; + }else{ + mEUt = (int)xEUt; + if(mEUt==0) + mEUt = 1; + if(mMaxProgresstime==0) + mMaxProgresstime = 1;//set time to 1 tick + } + } + } + public boolean drainEnergyInput(long aEU) { if (aEU <= 0) return true; for (GT_MetaTileEntity_Hatch_Energy tHatch : mEnergyHatches) @@ -553,10 +605,11 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { return false; } - private void addFluidOutputs(FluidStack[] mOutputFluids2) { - for (int i = 0; i < mOutputFluids2.length; i++) { - if (mOutputHatches.size() > i && mOutputHatches.get(i) != null && mOutputFluids2[i] != null && isValidMetaTileEntity(mOutputHatches.get(i))) { - mOutputHatches.get(i).fill(mOutputFluids2[i], true); + protected void addFluidOutputs(FluidStack[] mOutputFluids) { + int min=mOutputFluids.length>mOutputHatches.size()?mOutputHatches.size():mOutputFluids.length; + for (int i = 0; i < min; ++i) { + if (this.mOutputHatches.get(i) != null && mOutputFluids[i] != null && isValidMetaTileEntity(this.mOutputHatches.get(i))) { + this.mOutputHatches.get(i).fill(mOutputFluids[i], true); } } @@ -810,7 +863,39 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { @Override public String[] getInfoData() { - return new String[]{"Progress:", (mProgresstime / 20) + "secs", (mMaxProgresstime / 20) + "secs", "Efficiency:", (mEfficiency / 100.0F) + "%", "Problems:", String.valueOf((getIdealStatus() - getRepairStatus()))}; + int mPollutionReduction=0; + for (GT_MetaTileEntity_Hatch_Muffler tHatch : mMufflerHatches) { + if (isValidMetaTileEntity(tHatch)) { + mPollutionReduction=Math.max(tHatch.calculatePollutionReduction(100),mPollutionReduction); + } + } + + long storedEnergy=0; + long maxEnergy=0; + for(GT_MetaTileEntity_Hatch_Energy tHatch : mEnergyHatches) { + if (isValidMetaTileEntity(tHatch)) { + storedEnergy+=tHatch.getBaseMetaTileEntity().getStoredEU(); + maxEnergy+=tHatch.getBaseMetaTileEntity().getEUCapacity(); + } + } + + return new String[]{ + "Progress:", + EnumChatFormatting.GREEN + Integer.toString(mProgresstime/20) + EnumChatFormatting.RESET +" s / "+ + EnumChatFormatting.YELLOW + Integer.toString(mMaxProgresstime/20) + EnumChatFormatting.RESET +" s", + "Stored Energy:", + EnumChatFormatting.GREEN + Long.toString(storedEnergy) + EnumChatFormatting.RESET +" EU / "+ + EnumChatFormatting.YELLOW + Long.toString(maxEnergy) + EnumChatFormatting.RESET +" EU", + "Probably uses: "+ + EnumChatFormatting.RED + Integer.toString(-mEUt) + EnumChatFormatting.RESET + " EU/t", + "Maximum total power (to all Energy Hatches, not single ones): ", + EnumChatFormatting.YELLOW+Long.toString(getMaxInputVoltage())+EnumChatFormatting.RESET+ " EU/t * 2A", + "Problems: "+ + EnumChatFormatting.RED+ (getIdealStatus() - getRepairStatus())+EnumChatFormatting.RESET+ + " Efficiency: "+ + EnumChatFormatting.YELLOW+Float.toString(mEfficiency / 100.0F)+EnumChatFormatting.RESET + " %", + "Pollution reduced to: "+ EnumChatFormatting.GREEN + mPollutionReduction+ EnumChatFormatting.RESET+" %" + }; } @Override 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 4187307c6b..c413fe3c07 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 @@ -8,6 +8,7 @@ import static gregtech.api.enums.GT_Values.GT; public abstract class GT_MetaTileEntity_TieredMachineBlock extends MetaTileEntity { /** * Value between [0 - 9] to describe the Tier of this Machine. + * PLZ [0-15] works - READ! GT_Values class. */ public final byte mTier; @@ -26,7 +27,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)); + mTier = (byte) Math.max(0, Math.min(aTier, 15)); mDescriptionArray = aDescription == null ? new String[0] : new String[]{aDescription}; mDescription = mDescriptionArray.length > 0 ? mDescriptionArray[0] : ""; // must always be the last call! @@ -36,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)); + mTier = (byte) Math.max(0, Math.min(aTier, 15)); mDescriptionArray = aDescription == null ? new String[0] : aDescription; mDescription = mDescriptionArray.length > 0 ? mDescriptionArray[0] : ""; @@ -88,4 +89,4 @@ public abstract class GT_MetaTileEntity_TieredMachineBlock extends MetaTileEntit * @param aTextures is the optional Array you can give to the Constructor. */ public abstract ITexture[][][] getTextureSet(ITexture[] aTextures); -}
\ No newline at end of file +} diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Transformer.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Transformer.java index 83497797ea..bcf98dbc3a 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Transformer.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Transformer.java @@ -117,27 +117,27 @@ public class GT_MetaTileEntity_Transformer extends GT_MetaTileEntity_TieredMachi @Override public long maxEUStore() { - return 512 + V[mTier + 1] * 2; + return 512L + V[mTier + 1] * 2L; } @Override public long maxEUInput() { - return V[getBaseMetaTileEntity().isAllowedToWork() ? mTier + 1 : mTier]; + return V[getBaseMetaTileEntity().isActive() ? mTier + 1 : mTier]; } @Override public long maxEUOutput() { - return V[getBaseMetaTileEntity().isAllowedToWork() ? mTier : mTier + 1]; + return V[getBaseMetaTileEntity().isActive() ? mTier : mTier + 1]; } @Override public long maxAmperesOut() { - return getBaseMetaTileEntity().isAllowedToWork() ? V[mTier + 1] / V[mTier] : 1; + return getBaseMetaTileEntity().isActive() ? (V[mTier + 1] / V[mTier] < 4 ? 4 : V[mTier + 1] / V[mTier]) : 1; } @Override public long maxAmperesIn() { - return getBaseMetaTileEntity().isAllowedToWork() ? 1 : V[mTier + 1] / V[mTier]; + return getBaseMetaTileEntity().isActive() ? 1 : (V[mTier + 1] / V[mTier] < 4 ? 4 : V[mTier + 1] / V[mTier]); } @Override @@ -155,22 +155,22 @@ public class GT_MetaTileEntity_Transformer extends GT_MetaTileEntity_TieredMachi ((IEnergySource) tTileEntity).drawEnergy(tEU); aBaseMetaTileEntity.injectEnergyUnits((byte) 6, tEU, 1); } else if (GregTech_API.mInputRF && tTileEntity instanceof IEnergyProvider && ((IEnergyProvider) tTileEntity).extractEnergy(ForgeDirection.getOrientation(GT_Utility.getOppositeSide(i)), 1, true) == 1) { - long tEU = (long) ((IEnergyProvider) tTileEntity).extractEnergy(ForgeDirection.getOrientation(GT_Utility.getOppositeSide(i)), (int) maxEUInput() * 100 / GregTech_API.mRFtoEU, false); + long tEU = (long) ((IEnergyProvider) tTileEntity).extractEnergy(ForgeDirection.getOrientation(GT_Utility.getOppositeSide(i)), GT_Utility.safeInt(maxEUInput() * 100L / GregTech_API.mRFtoEU), false); tEU = tEU * GregTech_API.mRFtoEU / 100; aBaseMetaTileEntity.injectEnergyUnits((byte) 6, Math.min(tEU, maxEUInput()), 1); } else if (GregTech_API.mInputRF && tTileEntity instanceof IEnergyStorage && ((IEnergyStorage) tTileEntity).extractEnergy(1, true) == 1) { - long tEU = (long) ((IEnergyStorage) tTileEntity).extractEnergy((int) maxEUInput() * 100 / GregTech_API.mRFtoEU, false); + long tEU = (long) ((IEnergyStorage) tTileEntity).extractEnergy(GT_Utility.safeInt(maxEUInput() * 100L / GregTech_API.mRFtoEU), false); tEU = tEU * GregTech_API.mRFtoEU / 100; aBaseMetaTileEntity.injectEnergyUnits((byte) 6, Math.min(tEU, maxEUInput()), 1); } else if (GregTech_API.mInputRF && GregTech_API.meIOLoaded && tTileEntity instanceof IPowerContainer && ((IPowerContainer) tTileEntity).getEnergyStored() > 0) { int storedRF = ((IPowerContainer) tTileEntity).getEnergyStored(); - int extractRF = (int) maxEUInput() * 100 / GregTech_API.mRFtoEU; + int extractRF = GT_Utility.safeInt(maxEUInput() * 100L / GregTech_API.mRFtoEU); long tEU = 0; if (tTileEntity instanceof TileCapBank) { ICapBankNetwork network = ((TileCapBank) tTileEntity).getNetwork(); if (network != null && network.getEnergyStoredL() > 0) { - tEU = Math.min((Math.min(Math.min(network.getEnergyStoredL(), storedRF - extractRF), network.getMaxOutput())) * GregTech_API.mRFtoEU / 100, maxEUInput()); - network.addEnergy((int) -(tEU * 100 / GregTech_API.mRFtoEU)); + tEU = Math.min((Math.min(Math.min(network.getEnergyStoredL(), storedRF - extractRF), network.getMaxOutput())) * (long)GregTech_API.mRFtoEU / 100L, maxEUInput()); + network.addEnergy(GT_Utility.safeInt(-(tEU * 100 / GregTech_API.mRFtoEU))); } } else { if (storedRF > extractRF) { @@ -178,7 +178,7 @@ public class GT_MetaTileEntity_Transformer extends GT_MetaTileEntity_TieredMachi tEU = maxEUInput(); } else { ((IPowerContainer) tTileEntity).setEnergyStored(0); - tEU = storedRF * GregTech_API.mRFtoEU / 100; + tEU = storedRF * (long)GregTech_API.mRFtoEU / 100L; } } aBaseMetaTileEntity.injectEnergyUnits((byte) 6, Math.min(tEU, maxEUInput()), 1); @@ -214,6 +214,15 @@ public class GT_MetaTileEntity_Transformer extends GT_MetaTileEntity_TieredMachi @Override public String getAlternativeModeText(){ - return (getBaseMetaTileEntity().isAllowedToWork() ? trans("145","Step Down, In: ") : trans("146","Step Up, In"))+maxEUInput()+trans("148","V@")+maxAmperesIn()+trans("147","Amp, Out: ")+maxEUOutput()+"V@"+maxAmperesOut()+trans("149","Amp"); + return + getBaseMetaTileEntity().isAllowedToWork() ? trans("145","Step Down, In: ") : trans("146","Step Up, In: ") + + maxEUInput() + + trans("148","V ") + + maxAmperesIn() + + trans("147","A, Out: ") + + maxEUOutput() + + trans("148","V ") + + maxAmperesOut() + + trans("149","A"); } }
\ No newline at end of file |