diff options
author | Alkalus <3060479+draknyte1@users.noreply.github.com> | 2019-08-24 16:34:38 +0100 |
---|---|---|
committer | Alkalus <3060479+draknyte1@users.noreply.github.com> | 2019-08-24 16:34:38 +0100 |
commit | 5f455188ce11c975ced96d8364624af540dd276b (patch) | |
tree | 498359404ed74a738f31bab4df3ca7b4ac22a6a9 /src | |
parent | 043b16e0c10674e606885d6586e3448803eb2f23 (diff) | |
download | GT5-Unofficial-5f455188ce11c975ced96d8364624af540dd276b.tar.gz GT5-Unofficial-5f455188ce11c975ced96d8364624af540dd276b.tar.bz2 GT5-Unofficial-5f455188ce11c975ced96d8364624af540dd276b.zip |
+ Added some more generic language strings.
- Removed maintenance requirement from Cyclotron.
% More work on new Multiblock GUIs.
$ Potentially fixed #507.
Diffstat (limited to 'src')
9 files changed, 713 insertions, 187 deletions
diff --git a/src/Java/gtPlusPlus/core/util/math/MathUtils.java b/src/Java/gtPlusPlus/core/util/math/MathUtils.java index bda722b47e..a9f7b901ef 100644 --- a/src/Java/gtPlusPlus/core/util/math/MathUtils.java +++ b/src/Java/gtPlusPlus/core/util/math/MathUtils.java @@ -692,6 +692,39 @@ public class MathUtils { public static int balance(int aInput, int aMin, int aMax) { return Math.max(Math.min(aInput, aMax), aMin); } + + /** + * Balances a number within a range. + * @param aInput - The number to balance + * @param aMin - The minimum bounds + * @param aMax - The maximum bounds + * @return - A Number which will be between the bounds, or a boundary value. + */ + public static Number balance(Number aInput, Number aMin, Number aMax) { + return max(min(aInput, aMax), aMin); + } + + /** + * Balances a number within a range. + * @param aInput - The number to balance + * @param aMin - The minimum bounds + * @param aMax - The maximum bounds + * @return - An Integer which will be between the bounds, or a boundary value. + */ + public static int balanceInt(Number aInput, Number aMin, Number aMax) { + return MathUtils.safeCast_LongToInt((long) balance(max(min(aInput, aMax), aMin), Integer.MIN_VALUE, Integer.MAX_VALUE)); + } + + /** + * Balances a number within a range. + * @param aInput - The number to balance + * @param aMin - The minimum bounds + * @param aMax - The maximum bounds + * @return - A Long which will be between the bounds, or a boundary value. + */ + public static long balanceLong(Number aInput, Number aMin, Number aMax) { + return (long) balance(max(min(aInput, aMax), aMin), Long.MIN_VALUE, Long.MAX_VALUE); + } public static int getValueWithinRange(int i, int aMin, int aMax) { int aAmount = Math.max(Math.min(i, aMax), aMin); @@ -703,5 +736,37 @@ public class MathUtils { int aRemainder = (int) (aLong - (aIntMaxInLong * Integer.MAX_VALUE)); return new Pair<Integer, Integer>(aIntMaxInLong, aRemainder); } + + + + + /** + * Returns the smaller of two {@code Number}s. That is, + * the result the argument closer to the value of + * {@link Long#MIN_VALUE}. If the arguments have the same + * value, the result is that same value. + * + * @param a an argument. + * @param b another argument. + * @return the smaller of {@code a} and {@code b}. + */ + public static Number min(Number a, Number b) { + return (a.longValue() <= b.longValue()) ? a : b; + } + + /** + * Returns the greater of two {@code Number}s. That is, the + * result is the argument closer to the value of + * {@link Long#MAX_VALUE}. If the arguments have the same value, + * the result is that same value. + * + * @param a an argument. + * @param b another argument. + * @return the larger of {@code a} and {@code b}. + */ + public static Number max(Number a, Number b) { + return (a.longValue() >= b.longValue()) ? a : b; + } + } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_MultiMachine.java b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_MultiMachine.java index 5fccb51e54..d3e22875ae 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_MultiMachine.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_MultiMachine.java @@ -1,12 +1,19 @@ package gtPlusPlus.xmod.gregtech.api.gui; import java.lang.reflect.Field; +import java.util.ArrayList; import java.util.List; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.gui.GT_ContainerMetaTile_Machine; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gtPlusPlus.api.objects.data.AutoMap; +import gregtech.api.util.GT_Recipe; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.reflect.ReflectionUtils; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.ICrafting; @@ -20,6 +27,9 @@ public class CONTAINER_MultiMachine extends GT_ContainerMetaTile_Machine { public String[] mTileDescription; private String[] oTileDescription; + + private GregtechMeta_MultiBlockBase mMCTEI; + private boolean mControllerSet = false; public CONTAINER_MultiMachine(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity) { @@ -29,56 +39,245 @@ public class CONTAINER_MultiMachine extends GT_ContainerMetaTile_Machine { public CONTAINER_MultiMachine(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity, final boolean bindInventory) { super(aInventoryPlayer, aTileEntity, bindInventory); } + + public static void setControllerInstance(CONTAINER_MultiMachine aContainer, IGregTechTileEntity aTile) { + if (aTile == null) { + return; + } + final IMetaTileEntity aMetaTileEntity = aTile.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return; + } + if (aMetaTileEntity instanceof GregtechMeta_MultiBlockBase) { + aContainer.mMCTEI = (GregtechMeta_MultiBlockBase) aMetaTileEntity; + } + } + + public int aTotalTickTime = 0; + public int aMaxParallel = 0; + public int aPollutionTick = 0; + public int aMaxInputVoltage = 0; + public int aInputTier = 0; + public int aOutputTier = 0; + public int aRecipeDuration = 0; + public int aRecipeEU = 0; + public int aRecipeSpecial = 0; + public int aPollutionReduction = 0; + public int aStoredEnergy = 0; + public int aMaxEnergy = 0; + public int aEfficiency = 0; + private int oTotalTickTime = 0; + private int oMaxParallel = 0; + private int oPollutionTick = 0; + private int oMaxInputVoltage = 0; + private int oInputTier = 0; + private int oOutputTier = 0; + private int oRecipeDuration = 0; + private int oRecipeEU = 0; + private int oRecipeSpecial = 0; + private int oPollutionReduction = 0; + private int oStoredEnergy = 0; + private int oMaxEnergy = 0; + private int oEfficiency = 0; + + private static Field timer; + //private static Field crafters; @Override - public void detectAndSendChanges() { + public final void detectAndSendChanges() { super.detectAndSendChanges(); if (this.mTileEntity.isClientSide() || this.mTileEntity.getMetaTileEntity() == null) { return; } - - try { - this.mTileDescription = this.mTileEntity.getInfoData(); - - Field bTimer = ReflectionUtils.getField(getClass(), "mTimer"); - Field bCrafters = ReflectionUtils.getField(getClass(), "crafters"); - int time = bTimer.getInt(this); - List crafters = (List) bCrafters.get(this); - AutoMap<ICrafting> aCrafting = new AutoMap<ICrafting>(); - if (crafters != null && !crafters.isEmpty()) { + if (!mControllerSet) { + setControllerInstance(this, this.mTileEntity); + } + mControllerSet = (mMCTEI != null); + if (timer == null) { + timer = ReflectionUtils.getField(getClass(), "mTimer"); + } + if (crafters == null) { + //crafters = ReflectionUtils.getField(getClass(), "crafters"); + } + if (timer != null && crafters != null && mControllerSet) { + Logger.INFO("Trying to update clientside GUI data"); + try { + Logger.INFO("0"); + int aTimer = (int) ReflectionUtils.getFieldValue(timer, this); + + //List crafters1List = (List) crafters1; + List<ICrafting> crafters2 = new ArrayList<ICrafting>(); + Logger.INFO("1"); for (Object o : crafters) { - aCrafting.put((ICrafting) o); + if (o instanceof ICrafting) { + crafters2.add((ICrafting) o); + } } - } + Logger.INFO("2"); + if (!crafters2.isEmpty()) { + Logger.INFO("3"); + handleInitialFieldSetting(); - for (final ICrafting var3 : aCrafting) { - if (time % 500 == 10 || this.oTileDescription != this.mTileDescription) { - var3.sendProgressBarUpdate((Container)this, 64, 0); + try { + Logger.INFO("4"); + for (final ICrafting var3 : crafters2) { + handleCraftingEvent(aTimer, var3); + } + Logger.INFO("5"); + handleInternalFieldSetting(); + Logger.INFO("6"); + } catch (Throwable t) { + + } } + } catch (Throwable t) { + t.printStackTrace(); } + } + else { + Logger.INFO("Failed."); + } + } + + public void handleInitialFieldSetting() { + this.aTotalTickTime = MathUtils.balance((int) mMCTEI.getTotalRuntimeInTicks(), Integer.MIN_VALUE, Integer.MAX_VALUE); + this.aMaxParallel = mMCTEI.getMaxParallelRecipes(); + this.aPollutionTick = mMCTEI.getPollutionPerTick(null); + this.aMaxInputVoltage = MathUtils.balance((int) mMCTEI.getMaxInputVoltage(), Integer.MIN_VALUE, Integer.MAX_VALUE); + this.aInputTier = MathUtils.balance((int) mMCTEI.getInputTier(), Integer.MIN_VALUE, Integer.MAX_VALUE); + this.aOutputTier = MathUtils.balance((int) mMCTEI.getOutputTier(), Integer.MIN_VALUE, Integer.MAX_VALUE); + if (mMCTEI.mLastRecipe != null) { + GT_Recipe aRecipe = mMCTEI.mLastRecipe; + this.aRecipeDuration = MathUtils.balance(aRecipe.mDuration, Integer.MIN_VALUE, Integer.MAX_VALUE); + this.aRecipeEU = MathUtils.balance(aRecipe.mEUt, Integer.MIN_VALUE, Integer.MAX_VALUE); + this.aRecipeSpecial = MathUtils.balance(aRecipe.mSpecialValue, Integer.MIN_VALUE, Integer.MAX_VALUE); + } + this.aPollutionReduction = mMCTEI.getPollutionReductionForAllMufflers(); + + this.aStoredEnergy = MathUtils.balance((int) mMCTEI.getStoredEnergyInAllEnergyHatches(), Integer.MIN_VALUE, Integer.MAX_VALUE); + this.aMaxEnergy = MathUtils.balance((int) mMCTEI.getMaxEnergyStorageOfAllEnergyHatches(), Integer.MIN_VALUE, Integer.MAX_VALUE); + this.aEfficiency = MathUtils.balance(mMCTEI.mEfficiency, Integer.MIN_VALUE, Integer.MAX_VALUE); + } - this.oTileDescription = this.mTileDescription; + public void handleCraftingEvent(int aTimer, ICrafting aCrafter) { + int aID = 750; + if (aTimer % 500 == 10 || this.oTotalTickTime != this.aTotalTickTime) { + aCrafter.sendProgressBarUpdate((Container) this, aID++, this.aTotalTickTime); + } + if (aTimer % 500 == 10 || this.oMaxParallel != this.aMaxParallel) { + aCrafter.sendProgressBarUpdate((Container) this, aID++, this.aMaxParallel); + } + if (aTimer % 500 == 10 || this.oPollutionTick != this.aPollutionTick) { + aCrafter.sendProgressBarUpdate((Container) this, aID++, this.aPollutionTick); + } + if (aTimer % 500 == 10 || this.oMaxInputVoltage != this.aMaxInputVoltage) { + aCrafter.sendProgressBarUpdate((Container) this, aID++, this.aMaxInputVoltage); + } + if (aTimer % 500 == 10 || this.oInputTier != this.aInputTier) { + aCrafter.sendProgressBarUpdate((Container) this, aID++, this.aInputTier); + } + if (aTimer % 500 == 10 || this.oOutputTier != this.aOutputTier) { + aCrafter.sendProgressBarUpdate((Container) this, aID++, this.aOutputTier); + } + if (aTimer % 500 == 10 || this.oRecipeDuration != this.aRecipeDuration) { + aCrafter.sendProgressBarUpdate((Container) this, aID++, this.aRecipeDuration); } - catch (Throwable t) { + if (aTimer % 500 == 10 || this.oRecipeEU != this.aRecipeEU) { + aCrafter.sendProgressBarUpdate((Container) this, aID++, this.aRecipeEU); + } + if (aTimer % 500 == 10 || this.oRecipeSpecial != this.aRecipeSpecial) { + aCrafter.sendProgressBarUpdate((Container) this, aID++, this.aRecipeSpecial); + } + if (aTimer % 500 == 10 || this.oPollutionReduction != this.aPollutionReduction) { + aCrafter.sendProgressBarUpdate((Container) this, aID++, this.aPollutionReduction); + } + if (aTimer % 500 == 10 || this.oStoredEnergy != this.aStoredEnergy) { + aCrafter.sendProgressBarUpdate((Container) this, aID++, this.aStoredEnergy); + } + if (aTimer % 500 == 10 || this.oMaxEnergy != this.aMaxEnergy) { + aCrafter.sendProgressBarUpdate((Container) this, aID++, this.aMaxEnergy); + } + if (aTimer % 500 == 10 || this.oEfficiency != this.aEfficiency) { + aCrafter.sendProgressBarUpdate((Container) this, aID++, this.aEfficiency); + } + } + + public void handleInternalFieldSetting() { + this.oTotalTickTime = this.aTotalTickTime; + this.oMaxParallel = this.aMaxParallel; + this.oPollutionTick = this.aPollutionTick; + this.oMaxInputVoltage = this.aMaxInputVoltage; + this.oInputTier = this.aInputTier; + this.oOutputTier = this.aOutputTier; + this.oRecipeDuration = this.aRecipeDuration; + this.oRecipeEU = this.aRecipeEU; + this.oRecipeSpecial = this.aRecipeSpecial; + this.oPollutionReduction = this.aPollutionReduction; + this.oStoredEnergy = this.aStoredEnergy; + this.oMaxEnergy = this.aMaxEnergy; + this.oEfficiency = this.aEfficiency; + } + @SideOnly(Side.CLIENT) + @Override + public void updateProgressBar(final int par1, final int par2) { + super.updateProgressBar(par1, par2); + int shiftedSwitch = par1 - 750; + switch (shiftedSwitch) { + case 0: { + this.aTotalTickTime = par2; + break; + } + case 1: { + this.aMaxParallel = par2; + break; + } + case 2: { + this.aPollutionTick = par2; + break; + } + case 3: { + this.aMaxInputVoltage = par2; + break; + } + case 4: { + this.aInputTier = par2; + break; + } + case 5: { + this.aOutputTier = par2; + break; + } + case 6: { + this.aRecipeDuration = par2; + break; + } + case 7: { + this.aRecipeEU = par2; + break; + } + case 8: { + this.aRecipeSpecial = par2; + break; + } + case 9: { + this.aPollutionReduction = par2; + break; + } + case 10: { + this.aStoredEnergy = par2; + break; + } + case 11: { + this.aMaxEnergy = par2; + break; + } + case 12: { + this.aEfficiency = par2; + break; + } } } } - -/*@Override - public void addSlots(InventoryPlayer aInventoryPlayer) { - addSlotToContainer(new Slot(mTileEntity, 1, 152, 5)); - } - - @Override - public int getSlotCount() { - return 1; - } - - @Override - public int getShiftClickSlotCount() { - return 0; - } -}*/ diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/GUI_MultiMachine.java b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/GUI_MultiMachine.java index 8293d5b9f3..c78e7789b8 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/GUI_MultiMachine.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/GUI_MultiMachine.java @@ -1,23 +1,26 @@ package gtPlusPlus.xmod.gregtech.api.gui; -import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.TimeUnit; +import gregtech.api.enums.GT_Values; import gregtech.api.enums.Materials; import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.util.GT_Utility; import gregtech.common.items.GT_MetaGenerated_Tool_01; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.reflect.ReflectionUtils; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.StatCollector; /** * NEVER INCLUDE THIS FILE IN YOUR MOD!!! @@ -28,128 +31,261 @@ import net.minecraft.util.ResourceLocation; */ public class GUI_MultiMachine extends GT_GUIContainerMetaTile_Machine { - String mName = ""; + private final static Materials GOOD; + private final static Materials BAD; + private final String mName; + + private final static ConcurrentHashMap<String, ItemStack> mToolStacks = new ConcurrentHashMap<String, ItemStack>(); + + //net.minecraft.client.gui.inventory.GuiContainer.drawItemStack(ItemStack, int, int, String) + private final static Method mDrawItemStack; + + static { + GOOD = Materials.Uranium; + BAD = Materials.Plutonium; + + //net.minecraft.client.gui.inventory.GuiContainer.drawItemStack(ItemStack, int, int, String) + mDrawItemStack = ReflectionUtils.getMethod(GuiContainer.class, "drawItemStack", new Class[] {ItemStack.class, int.class, int.class, String.class}); + } public GUI_MultiMachine(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity, final String aName, final String aTextureFile) { super(new CONTAINER_MultiMachine_NoPlayerInventory(aInventoryPlayer, aTileEntity), CORE.RES_PATH_GUI + (aTextureFile == null ? "MultiblockDisplay" : aTextureFile)); - this.mName = aName; + this.mName = aName != null ? aName : ""; } @Override - protected void drawGuiContainerForegroundLayer(final int par1, final int par2) { - fontRendererObj.drawString(this.mName+"!", 6, 7, 16448255); + protected void drawGuiContainerForegroundLayer(final int par1, final int par2) { if (this.mContainer != null) { + drawGuiInfoTextLayer(par1, par2); + drawGuiRepairStatusLayer(par1, par2); + } + } - boolean aWrench = (((CONTAINER_MultiMachine) this.mContainer).mDisplayErrorCode & 1) != 0; - boolean aScrewdriver = (((CONTAINER_MultiMachine) this.mContainer).mDisplayErrorCode & 2) != 0; - boolean aMallet = (((CONTAINER_MultiMachine) this.mContainer).mDisplayErrorCode & 4) != 0; - boolean aHammer = (((CONTAINER_MultiMachine) this.mContainer).mDisplayErrorCode & 8) != 0; - boolean aSoldering = (((CONTAINER_MultiMachine) this.mContainer).mDisplayErrorCode & 16) != 0; - boolean aCrowbar = (((CONTAINER_MultiMachine) this.mContainer).mDisplayErrorCode & 32) != 0; - - - - //net.minecraft.client.gui.inventory.GuiContainer.drawItemStack(ItemStack, int, int, String) - Method aDrawItemStack = ReflectionUtils.getMethod(GuiContainer.class, "drawItemStack", new Class[] {ItemStack.class, int.class, int.class, String.class}); - if (aDrawItemStack != null) { - - try { - - if ((((CONTAINER_MultiMachine) this.mContainer).mDisplayErrorCode & 64) != 0) { - this.fontRendererObj.drawString("Incomplete Structure.", 10, 16, 16448255); // Move down 8px - } - else { - Field aStringData = ReflectionUtils.getField(this.mContainer.getClass(), "oTileDescription"); - if (aStringData != null) { - String[] aData = (String[]) aStringData.get(this.mContainer); - int aIndex = 0; - this.fontRendererObj.drawString(""+aStringData.getType().getSimpleName(), 6, 16+(aIndex++*8), 16448255); // Move down 8px - if (aData != null && aData.length > 0) { - for (String s : aData) { - this.fontRendererObj.drawString(s, 6, 16+(aIndex++*8), 16448255); // Move down 8px - } - } - else { - this.fontRendererObj.drawString("Unable to get Info Data from Tile Entity | "+(aData != null), 6, 16+(aIndex++*8), 16448255); // Move down 8px - } - } - else { - this.fontRendererObj.drawString("Unable to get Info Data from Tile Entity | Bad", 6, 16, 16448255); // Move down 8px - - - } - - } - - - - - - - - //Migrate to static block - - Materials GOOD = Materials.Uranium; - Materials BAD = Materials.Plutonium; - - ItemStack aWrenchStack = GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats(GT_MetaGenerated_Tool_01.WRENCH, 1, (aWrench ? BAD : GOOD), Materials.Tungsten, null); - ItemStack aCrowbarStack = GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats(GT_MetaGenerated_Tool_01.CROWBAR, 1, (aCrowbar ? BAD : GOOD), Materials.Tungsten, null); - ItemStack aHammerStack = GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats(GT_MetaGenerated_Tool_01.HARDHAMMER, 1, (aHammer ? BAD : GOOD), Materials.Tungsten, null); - ItemStack aMalletStack = GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats(GT_MetaGenerated_Tool_01.SOFTHAMMER, 1, (aMallet ? BAD : GOOD), Materials.Tungsten, null); - ItemStack aScrewdriverStack = GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats(GT_MetaGenerated_Tool_01.SCREWDRIVER, 1, (aScrewdriver ? BAD : GOOD), Materials.Tungsten, null); - ItemStack aSolderingStack = GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats(GT_MetaGenerated_Tool_01.SOLDERING_IRON_LV, 1, (aSoldering ? BAD : GOOD), Materials.Tungsten, null); - - ItemStack[] aToolStacks2 = new ItemStack[] { - aWrenchStack, - aCrowbarStack, - aHammerStack, - aMalletStack, - aScrewdriverStack, - aSolderingStack - }; - - int aIndex = 0; - for (aIndex = 0; aIndex < 6; aIndex++) { - - int x = 156; - int y = 112 - (18*3) + (aIndex * 18); - aDrawItemStack.invoke(this, new Object[] { - aToolStacks2[aIndex] != null ? aToolStacks2[aIndex] : ItemUtils.getErrorStack(1, "Bad Times"), - x, - y, - ""+(aIndex == 2 ? "H" : aIndex == 3 ? "M" : "") // Stacksize Overlay - }); - this.fontRendererObj.drawString("", 10, 64, 16448255); - } - - } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { - e.printStackTrace(); - } + + protected void drawGuiInfoTextLayer(final float par1, final int par2) { + + if ((((CONTAINER_MultiMachine) this.mContainer).mDisplayErrorCode & 64) != 0) { + this.fontRendererObj.drawString(mName, 6, 7, 16448255); // Move down 8px + this.fontRendererObj.drawString("Incomplete Structure.", 6, 15, 16448255); // Move down 8px + } + else { + int aTotalTickTime = ((CONTAINER_MultiMachine) this.mContainer).aTotalTickTime; + int aMaxParallel = ((CONTAINER_MultiMachine) this.mContainer).aMaxParallel; + int aPollutionTick = ((CONTAINER_MultiMachine) this.mContainer).aPollutionTick; + int aMaxInputVoltage = ((CONTAINER_MultiMachine) this.mContainer).aMaxInputVoltage; + int aInputTier = ((CONTAINER_MultiMachine) this.mContainer).aInputTier; + int aOutputTier = ((CONTAINER_MultiMachine) this.mContainer).aOutputTier; + int aRecipeDuration = ((CONTAINER_MultiMachine) this.mContainer).aRecipeDuration; + int aRecipeEU = ((CONTAINER_MultiMachine) this.mContainer).aRecipeEU; + int aRecipeSpecial = ((CONTAINER_MultiMachine) this.mContainer).aRecipeSpecial; + int aEfficiency = ((CONTAINER_MultiMachine) this.mContainer).aEfficiency; + + int aPollutionReduction = ((CONTAINER_MultiMachine) this.mContainer).aPollutionReduction; + + + long aStoredEnergy = ((CONTAINER_MultiMachine) this.mContainer).aStoredEnergy; + long aMaxEnergy = ((CONTAINER_MultiMachine) this.mContainer).aMaxEnergy; + + /* + * Logic Block + */ + + long seconds = (aTotalTickTime/20); + int weeks = (int) (TimeUnit.SECONDS.toDays(seconds) / 7); + int days = (int) (TimeUnit.SECONDS.toDays(seconds) - 7 * weeks); + long hours = TimeUnit.SECONDS.toHours(seconds) - TimeUnit.DAYS.toHours(days) - TimeUnit.DAYS.toHours(7*weeks); + long minutes = TimeUnit.SECONDS.toMinutes(seconds) - (TimeUnit.SECONDS.toHours(seconds) * 60); + long second = TimeUnit.SECONDS.toSeconds(seconds) - (TimeUnit.SECONDS.toMinutes(seconds) *60); + + ArrayList<String> mInfo = new ArrayList<String>(); + + String EU = StatCollector.translateToLocal("GTPP.info.eu"); + + //GTPP.machines.tier + + mInfo.add(mName); + + if (aInputTier > 0) { + mInfo.add(StatCollector.translateToLocal("GTPP.machines.input")+" "+StatCollector.translateToLocal("GTPP.machines.tier")+": "+ EnumChatFormatting.GREEN +GT_Values.VOLTAGE_NAMES[aInputTier]); + } + if (aOutputTier > 0) { + mInfo.add(StatCollector.translateToLocal("GTPP.machines.output")+" "+StatCollector.translateToLocal("GTPP.machines.tier")+": "+ EnumChatFormatting.GREEN +GT_Values.VOLTAGE_NAMES[aOutputTier]); + } + + mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.progress")+": "+ + EnumChatFormatting.GREEN + Integer.toString(((CONTAINER_MultiMachine) this.mContainer).mProgressTime/20) + EnumChatFormatting.RESET +" s / "+ + EnumChatFormatting.YELLOW + Integer.toString(((CONTAINER_MultiMachine) this.mContainer).mMaxProgressTime/20) + EnumChatFormatting.RESET +" s"); + + + mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.energy")+": "+ + EnumChatFormatting.GREEN + Long.toString(aStoredEnergy) + EnumChatFormatting.RESET +" "+EU+" / "+ + EnumChatFormatting.YELLOW + Long.toString(aMaxEnergy) + EnumChatFormatting.RESET +" "+EU+""); + + if (aRecipeEU != 0 && aRecipeDuration > 0) { + mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.usage")+": "+ + EnumChatFormatting.RED + Integer.toString(-aRecipeEU) + EnumChatFormatting.RESET + " "+EU+"/t"); + mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.duration")+": "+ + EnumChatFormatting.RED + Integer.toString(aRecipeDuration) + EnumChatFormatting.RESET + " ticks"); + if (aRecipeSpecial > 0) { + mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.specialvalue")+": "+ + EnumChatFormatting.RED + Integer.toString(aRecipeEU) + EnumChatFormatting.RESET + ""); + } + } + + mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.mei")+": "+ + EnumChatFormatting.YELLOW+Long.toString(aMaxInputVoltage)+EnumChatFormatting.RESET+ " "+EU+"/t"+EnumChatFormatting.RESET); + + mInfo.add(StatCollector.translateToLocal(StatCollector.translateToLocal("GTPP.machines.tier")+": "+ + EnumChatFormatting.YELLOW+GT_Values.VN[GT_Utility.getTier(aMaxInputVoltage)]+ EnumChatFormatting.RESET)); + + mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.efficiency")+": "+ EnumChatFormatting.YELLOW+Float.toString(aEfficiency / 100.0F)+EnumChatFormatting.RESET + " %"); + + mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.pollution")+": "+ EnumChatFormatting.RED + (aPollutionTick*20)+ EnumChatFormatting.RESET+"/sec"); + mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.pollutionreduced")+": "+ EnumChatFormatting.GREEN + aPollutionReduction + EnumChatFormatting.RESET+" %"); + + mInfo.add(StatCollector.translateToLocal("GTPP.CC.parallel")+": "+EnumChatFormatting.GREEN+(aMaxParallel)+EnumChatFormatting.RESET); + + mInfo.add("Total Time Since Built: "); + mInfo.add("" + EnumChatFormatting.DARK_GREEN + Integer.toString(weeks)+EnumChatFormatting.RESET+" Weeks,"); + mInfo.add("" + EnumChatFormatting.DARK_GREEN+ Integer.toString(days) +EnumChatFormatting.RESET+ " Days,"); + mInfo.add("" + EnumChatFormatting.DARK_GREEN+ Long.toString(hours) +EnumChatFormatting.RESET+ " Hours,"); + mInfo.add("" + EnumChatFormatting.DARK_GREEN+ Long.toString(minutes) +EnumChatFormatting.RESET+ " Minutes,"); + mInfo.add("" + EnumChatFormatting.DARK_GREEN+ Long.toString(second) +EnumChatFormatting.RESET+ " Seconds"); + + + + // Machine Name + //fontRendererObj.drawString(this.mName, 6, 7, 16448255); + + for (int i=0;i<mInfo.size();i++) { + fontRendererObj.drawString(mInfo.get(i), 6, 7+(i*8), 16448255); } + } + + + + + } + protected void drawGuiRepairStatusLayer(final float par1, final int par2) { + boolean aWrench = (((CONTAINER_MultiMachine) this.mContainer).mDisplayErrorCode & 1) != 0; + boolean aScrewdriver = (((CONTAINER_MultiMachine) this.mContainer).mDisplayErrorCode & 2) != 0; + boolean aMallet = (((CONTAINER_MultiMachine) this.mContainer).mDisplayErrorCode & 4) != 0; + boolean aHammer = (((CONTAINER_MultiMachine) this.mContainer).mDisplayErrorCode & 8) != 0; + boolean aSoldering = (((CONTAINER_MultiMachine) this.mContainer).mDisplayErrorCode & 16) != 0; + boolean aCrowbar = (((CONTAINER_MultiMachine) this.mContainer).mDisplayErrorCode & 32) != 0; + if (mToolStacks.isEmpty()) { + // Map Stacks of Repair items + aWrench = false; + aScrewdriver = false; + aMallet = false; + aHammer = false; + aSoldering = false; + aCrowbar = false; + mToolStacks.put(aWrench+"WRENCH", GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats(GT_MetaGenerated_Tool_01.WRENCH, 1, (aWrench ? BAD : GOOD), Materials.Tungsten, null)); + mToolStacks.put(aCrowbar+"CROWBAR", GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats(GT_MetaGenerated_Tool_01.CROWBAR, 1, (aCrowbar ? BAD : GOOD), Materials.Tungsten, null)); + mToolStacks.put(aHammer+"HARDHAMMER", GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats(GT_MetaGenerated_Tool_01.HARDHAMMER, 1, (aHammer ? BAD : GOOD), Materials.Tungsten, null)); + mToolStacks.put(aMallet+"SOFTHAMMER", GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats(GT_MetaGenerated_Tool_01.SOFTHAMMER, 1, (aMallet ? BAD : GOOD), Materials.Tungsten, null)); + mToolStacks.put(aScrewdriver+"SCREWDRIVER", GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats(GT_MetaGenerated_Tool_01.SCREWDRIVER, 1, (aScrewdriver ? BAD : GOOD), Materials.Tungsten, null)); + mToolStacks.put(aSoldering+"SOLDERING_IRON_LV", GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats(GT_MetaGenerated_Tool_01.SOLDERING_IRON_LV, 1, (aSoldering ? BAD : GOOD), Materials.Tungsten, null)); + // Map Stacks of valid items + aWrench = true; + aScrewdriver = true; + aMallet = true; + aHammer = true; + aSoldering = true; + aCrowbar = true; + mToolStacks.put(aWrench+"WRENCH", GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats(GT_MetaGenerated_Tool_01.WRENCH, 1, (aWrench ? BAD : GOOD), Materials.Tungsten, null)); + mToolStacks.put(aCrowbar+"CROWBAR", GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats(GT_MetaGenerated_Tool_01.CROWBAR, 1, (aCrowbar ? BAD : GOOD), Materials.Tungsten, null)); + mToolStacks.put(aHammer+"HARDHAMMER", GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats(GT_MetaGenerated_Tool_01.HARDHAMMER, 1, (aHammer ? BAD : GOOD), Materials.Tungsten, null)); + mToolStacks.put(aMallet+"SOFTHAMMER", GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats(GT_MetaGenerated_Tool_01.SOFTHAMMER, 1, (aMallet ? BAD : GOOD), Materials.Tungsten, null)); + mToolStacks.put(aScrewdriver+"SCREWDRIVER", GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats(GT_MetaGenerated_Tool_01.SCREWDRIVER, 1, (aScrewdriver ? BAD : GOOD), Materials.Tungsten, null)); + mToolStacks.put(aSoldering+"SOLDERING_IRON_LV", GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats(GT_MetaGenerated_Tool_01.SOLDERING_IRON_LV, 1, (aSoldering ? BAD : GOOD), Materials.Tungsten, null)); + ItemStack aGlassPane1 = ItemUtils.getItemStackOfAmountFromOreDict("paneGlassRed", 1); + ItemStack aGlassPane2 = ItemUtils.getItemStackOfAmountFromOreDict("paneGlassLime", 1); + mToolStacks.put("falseGLASS", aGlassPane1); + mToolStacks.put("trueGLASS", aGlassPane2); - //ItemStack aWrenchStack = ItemUtils.getSimpleStack(GregTech_API.sWrenchList., i) + // Reset vars to real state + aWrench = (((CONTAINER_MultiMachine) this.mContainer).mDisplayErrorCode & 1) != 0; + aScrewdriver = (((CONTAINER_MultiMachine) this.mContainer).mDisplayErrorCode & 2) != 0; + aMallet = (((CONTAINER_MultiMachine) this.mContainer).mDisplayErrorCode & 4) != 0; + aHammer = (((CONTAINER_MultiMachine) this.mContainer).mDisplayErrorCode & 8) != 0; + aSoldering = (((CONTAINER_MultiMachine) this.mContainer).mDisplayErrorCode & 16) != 0; + aCrowbar = (((CONTAINER_MultiMachine) this.mContainer).mDisplayErrorCode & 32) != 0; + } + ItemStack aWrenchStack; + ItemStack aCrowbarStack; + ItemStack aHammerStack; + ItemStack aMalletStack; + ItemStack aScrewdriverStack; + ItemStack aSolderingStack; + if (!mToolStacks.isEmpty() && mDrawItemStack != null) { - if (((CONTAINER_MultiMachine) this.mContainer).mDisplayErrorCode == 0) { - if (((CONTAINER_MultiMachine) this.mContainer).mActive == 0) { - this.fontRendererObj.drawString("Hit with Soft Hammer", 10, 16, 16448255); - this.fontRendererObj.drawString("to (re-)start the Machine", 10, 24, 16448255); - this.fontRendererObj.drawString("if it doesn't start.", 10, 32, 16448255); - } else { - this.fontRendererObj.drawString("Running perfectly.", 10, 16, 16448255); + aWrenchStack = mToolStacks.get(aWrench + "WRENCH"); + aCrowbarStack = mToolStacks.get(aCrowbar + "CROWBAR"); + aHammerStack = mToolStacks.get(aHammer + "HARDHAMMER"); + aMalletStack = mToolStacks.get(aMallet + "SOFTHAMMER"); + aScrewdriverStack = mToolStacks.get(aScrewdriver + "SCREWDRIVER"); + aSolderingStack = mToolStacks.get(aSoldering + "SOLDERING_IRON_LV"); + + try { + + ItemStack[] aToolStacks2 = new ItemStack[] { + aWrenchStack, aCrowbarStack, + aHammerStack, aMalletStack, + aScrewdriverStack, aSolderingStack }; + + int aIndex = 0; + //Draw Repair status tools + for (aIndex = 0; aIndex < 6; aIndex++) { + int x = 156; + int y = 112 - (18 * 3) + (aIndex * 18); + mDrawItemStack.invoke(this, + new Object[] { + aToolStacks2[aIndex] != null ? aToolStacks2[aIndex] + : ItemUtils.getErrorStack(1, "Bad Times"), + x, y, "" + (aIndex == 2 ? "H" : aIndex == 3 ? "M" : "") // Stacksize Overlay + }); + //this.fontRendererObj.drawString("", 10, 64, 16448255); } + + //Draw Running status + boolean running = ((CONTAINER_MultiMachine) this.mContainer).mActive != 0; + ItemStack aGlassPane = mToolStacks.get(running+"GLASS"); + + if (aGlassPane == null) { + aGlassPane = ItemUtils.getItemStackOfAmountFromOreDict("paneGlass" + (running ? "Lime" : "Red"), 1); + mToolStacks.put(running+"GLASS", aGlassPane); + } + + mDrawItemStack.invoke(this, + new Object[] { + aGlassPane != null ? aGlassPane + : ItemUtils.getErrorStack(1, "Bad Times"), + 156, + 112 - (18 * 5), + running ? "On" : "Off"}); // Stacksize Overlay + + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + e.printStackTrace(); } } + + + + } + @Override protected void drawGuiContainerBackgroundLayer(final float par1, final int par2, final int par3) { super.drawGuiContainerBackgroundLayer(par1, par2, par3); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/GUI_MultiMachine_Default.java b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/GUI_MultiMachine_Default.java new file mode 100644 index 0000000000..0cfab4e71e --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/GUI_MultiMachine_Default.java @@ -0,0 +1,68 @@ +package gtPlusPlus.xmod.gregtech.api.gui; + +import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.util.GT_LanguageManager; +import gtPlusPlus.core.lib.CORE; +import net.minecraft.entity.player.InventoryPlayer; + +public class GUI_MultiMachine_Default extends GT_GUIContainerMetaTile_Machine +{ + String mName; + + public GUI_MultiMachine_Default(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity, final String aName, final String aTextureFile) { + super(new CONTAINER_MultiMachine(aInventoryPlayer, aTileEntity), CORE.RES_PATH_GUI + ((aTextureFile == null) ? "MultiblockDisplay" : aTextureFile)); + this.mName = ""; + this.mName = aName; + } + + @Override + protected void drawGuiContainerForegroundLayer(final int par1, final int par2) { + this.fontRendererObj.drawString(this.mName, 10, 8, 16448255); + if (this.mContainer != null) { + if ((((CONTAINER_MultiMachine)this.mContainer).mDisplayErrorCode & 0x1) != 0x0) { + this.fontRendererObj.drawString(this.trans("132", "Pipe is loose."), 10, 16, 16448255); + } + if ((((CONTAINER_MultiMachine)this.mContainer).mDisplayErrorCode & 0x2) != 0x0) { + this.fontRendererObj.drawString(this.trans("133", "Screws are missing."), 10, 24, 16448255); + } + if ((((CONTAINER_MultiMachine)this.mContainer).mDisplayErrorCode & 0x4) != 0x0) { + this.fontRendererObj.drawString(this.trans("134", "Something is stuck."), 10, 32, 16448255); + } + if ((((CONTAINER_MultiMachine)this.mContainer).mDisplayErrorCode & 0x8) != 0x0) { + this.fontRendererObj.drawString(this.trans("135", "Platings are dented."), 10, 40, 16448255); + } + if ((((CONTAINER_MultiMachine)this.mContainer).mDisplayErrorCode & 0x10) != 0x0) { + this.fontRendererObj.drawString(this.trans("136", "Circuitry burned out."), 10, 48, 16448255); + } + if ((((CONTAINER_MultiMachine)this.mContainer).mDisplayErrorCode & 0x20) != 0x0) { + this.fontRendererObj.drawString(this.trans("137", "That doesn't belong there."), 10, 56, 16448255); + } + if ((((CONTAINER_MultiMachine)this.mContainer).mDisplayErrorCode & 0x40) != 0x0) { + this.fontRendererObj.drawString(this.trans("138", "Incomplete Structure."), 10, 64, 16448255); + } + if (((CONTAINER_MultiMachine)this.mContainer).mDisplayErrorCode == 0) { + if (((CONTAINER_MultiMachine)this.mContainer).mActive == 0) { + this.fontRendererObj.drawString(this.trans("139", "Hit with Soft Hammer"), 10, 16, 16448255); + this.fontRendererObj.drawString(this.trans("140", "to (re-)start the Machine"), 10, 24, 16448255); + this.fontRendererObj.drawString(this.trans("141", "if it doesn't start."), 10, 32, 16448255); + } + else { + this.fontRendererObj.drawString(this.trans("142", "Running perfectly."), 10, 16, 16448255); + } + } + } + } + + public String trans(final String aKey, final String aEnglish) { + return GT_LanguageManager.addStringLocalization("Interaction_DESCRIPTION_Index_" + aKey, aEnglish, false); + } + + @Override + protected void drawGuiContainerBackgroundLayer(final float par1, final int par2, final int par3) { + super.drawGuiContainerBackgroundLayer(par1, par2, par3); + final int x = (this.width - this.xSize) / 2; + final int y = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); + } +} 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 0d30bfecf2..3df757d0c6 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 @@ -4,7 +4,6 @@ import static gtPlusPlus.core.util.data.ArrayUtils.removeNulls; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; -import java.lang.reflect.ParameterizedType; import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; @@ -53,6 +52,7 @@ import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.xmod.gregtech.api.gui.CONTAINER_MultiMachine; import gtPlusPlus.xmod.gregtech.api.gui.CONTAINER_MultiMachine_NoPlayerInventory; import gtPlusPlus.xmod.gregtech.api.gui.GUI_MultiMachine; +import gtPlusPlus.xmod.gregtech.api.gui.GUI_MultiMachine_Default; import gtPlusPlus.xmod.gregtech.api.gui.GUI_Multi_Basic_Slotted; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_AirIntake; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_ControlCore; @@ -68,6 +68,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; +import net.minecraft.world.World; import net.minecraftforge.fluids.FluidStack; public abstract class GregtechMeta_MultiBlockBase @@ -122,14 +123,24 @@ GT_MetaTileEntity_MultiBlockBase { } public abstract boolean hasSlotInGUI(); + + public long getTotalRuntimeInTicks() { + return this.mTotalRunTime; + } @Override public Object getServerGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { if (hasSlotInGUI()) { return new GT_Container_MultiMachine(aPlayerInventory, aBaseMetaTileEntity); } - else { - return new CONTAINER_MultiMachine_NoPlayerInventory(aPlayerInventory, aBaseMetaTileEntity); + else { + String aCustomGUI = getCustomGUIResourceName(); + if (aCustomGUI == null) { + return new CONTAINER_MultiMachine_NoPlayerInventory(aPlayerInventory, aBaseMetaTileEntity); + } + else { + return new CONTAINER_MultiMachine(aPlayerInventory, aBaseMetaTileEntity); + } } } @@ -142,7 +153,7 @@ GT_MetaTileEntity_MultiBlockBase { @Override public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { String aCustomGUI = getCustomGUIResourceName(); - aCustomGUI = aCustomGUI != null ? aCustomGUI : "MultiblockDisplay_Generic"; + aCustomGUI = aCustomGUI != null ? aCustomGUI : hasSlotInGUI() ? "MultiblockDisplay" : "MultiblockDisplay_Generic"; aCustomGUI = aCustomGUI + ".png"; if (hasSlotInGUI()) { if (!requiresVanillaGtGUI()) { @@ -153,7 +164,12 @@ GT_MetaTileEntity_MultiBlockBase { } } else { - return new GUI_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), aCustomGUI); + if (getCustomGUIResourceName() == null && !hasSlotInGUI()) { + return new GUI_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), aCustomGUI); + } + else { + return new GUI_MultiMachine_Default(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), aCustomGUI); + } } } @@ -192,31 +208,17 @@ GT_MetaTileEntity_MultiBlockBase { long minutes = TimeUnit.SECONDS.toMinutes(seconds) - (TimeUnit.SECONDS.toHours(seconds) * 60); long second = TimeUnit.SECONDS.toSeconds(seconds) - (TimeUnit.SECONDS.toMinutes(seconds) *60); - int mPollutionReduction=0; - for (GT_MetaTileEntity_Hatch_Muffler tHatch : mMufflerHatches) { - if (isValidMetaTileEntity(tHatch)) { - mPollutionReduction=Math.max(calculatePollutionReductionForHatch(tHatch, 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(); - } - } - + int mPollutionReduction = getPollutionReductionForAllMufflers(); + long storedEnergy = getStoredEnergyInAllEnergyHatches(); + long maxEnergy = getMaxEnergyStorageOfAllEnergyHatches(); int tTier = this.getControlCoreTier(); - mInfo.add(getMachineTooltip()); //Lets borrow the GTNH handling - mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.Progress")+": "+ + mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.progress")+": "+ EnumChatFormatting.GREEN + Integer.toString(mProgresstime/20) + EnumChatFormatting.RESET +" s / "+ EnumChatFormatting.YELLOW + Integer.toString(mMaxProgresstime/20) + EnumChatFormatting.RESET +" s"); @@ -262,6 +264,36 @@ GT_MetaTileEntity_MultiBlockBase { } + + public int getPollutionReductionForAllMufflers() { + int mPollutionReduction=0; + for (GT_MetaTileEntity_Hatch_Muffler tHatch : mMufflerHatches) { + if (isValidMetaTileEntity(tHatch)) { + mPollutionReduction=Math.max(calculatePollutionReductionForHatch(tHatch, 100),mPollutionReduction); + } + } + return mPollutionReduction; + } + + public long getStoredEnergyInAllEnergyHatches() { + long storedEnergy=0; + for(GT_MetaTileEntity_Hatch_Energy tHatch : mEnergyHatches) { + if (isValidMetaTileEntity(tHatch)) { + storedEnergy+=tHatch.getBaseMetaTileEntity().getStoredEU(); + } + } + return storedEnergy; + } + + public long getMaxEnergyStorageOfAllEnergyHatches() { + long maxEnergy=0; + for(GT_MetaTileEntity_Hatch_Energy tHatch : mEnergyHatches) { + if (isValidMetaTileEntity(tHatch)) { + maxEnergy+=tHatch.getBaseMetaTileEntity().getEUCapacity(); + } + } + return maxEnergy; + } @Override public boolean isGivingInformation() { @@ -2164,7 +2196,35 @@ GT_MetaTileEntity_MultiBlockBase { return false; } + @Override + public void onServerStart() { + super.onServerStart(); + tryTickWaitTimerDown(); + } + + @Override + public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) { + super.onFirstTick(aBaseMetaTileEntity); + tryTickWaitTimerDown(); + } + + @Override + public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPreTick(aBaseMetaTileEntity, aTick); + tryTickWaitTimerDown(); + } + @Override + public void onCreated(ItemStack aStack, World aWorld, EntityPlayer aPlayer) { + super.onCreated(aStack, aWorld, aPlayer); + tryTickWaitTimerDown(); + } + + private final void tryTickWaitTimerDown() { + if (mStartUpCheck > 10) { + mStartUpCheck = 10; + } + } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_EBF.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_EBF.java index d3f6fdb491..97ee87e4a2 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_EBF.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_EBF.java @@ -408,23 +408,25 @@ public class GregtechMetaTileEntity_Adv_EBF extends GregtechMeta_MultiBlockBase } - private volatile int mGraceTimer = 100; + private volatile int mGraceTimer = 2; - @SuppressWarnings("unused") @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - if (this.mMaxProgresstime > 0 && this.mProgresstime != 0 || this.getBaseMetaTileEntity().hasWorkJustBeenEnabled()) { - if (aTick % 10 == 0 || this.getBaseMetaTileEntity().hasWorkJustBeenEnabled()) { - if (!this.depleteInput(FluidUtils.getFluidStack("pyrotheum", 5))) { - this.causeMaintenanceIssue(); - this.stopMachine(); - } - if (false) { // To be replaced with a config option or something - this.explodeMultiblock(); - } - } + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + //Try dry Pyrotheum after all other logic + if (this.mStartUpCheck < 0) { + if (this.mMaxProgresstime > 0 && this.mProgresstime != 0 || this.getBaseMetaTileEntity().hasWorkJustBeenEnabled()) { + if (aTick % 10 == 0 || this.getBaseMetaTileEntity().hasWorkJustBeenEnabled()) { + if (!this.depleteInput(FluidUtils.getFluidStack("pyrotheum", 5))) { + if (mGraceTimer-- == 0) { + this.causeMaintenanceIssue(); + this.stopMachine(); + } + } + } + } } - super.onPostTick(aBaseMetaTileEntity, aTick); + } @Override diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_Cyclotron.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_Cyclotron.java index 91620eece5..ed6c913e6b 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_Cyclotron.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_Cyclotron.java @@ -6,7 +6,6 @@ import gregtech.GT_Mod; import gregtech.api.enums.Dyes; import gregtech.api.enums.TAE; import gregtech.api.enums.Textures; -import gregtech.api.gui.GT_Container_MultiMachine; import gregtech.api.interfaces.IIconContainer; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; @@ -22,14 +21,11 @@ import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; import gregtech.api.util.Recipe_GT; -import gregtech.common.gui.GT_GUIContainer_FusionReactor; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.item.chemistry.IonParticles; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.minecraft.gregtech.PollutionUtils; -import gtPlusPlus.xmod.gregtech.api.gui.CONTAINER_Cyclotron; -import gtPlusPlus.xmod.gregtech.api.gui.GUI_Cyclotron; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; import net.minecraft.block.Block; @@ -173,12 +169,7 @@ public class GregtechMetaTileEntity_Cyclotron extends GregtechMeta_MultiBlockBas return false; } } - mWrench = true; - mScrewdriver = true; - mSoftHammer = true; - mHardHammer = true; - mSolderingTool = true; - mCrowbar = true; + this.fixAllMaintenanceIssue(); log("Built Cyclotron."); turnCasingActive(true); return true; @@ -320,7 +311,7 @@ public class GregtechMetaTileEntity_Cyclotron extends GregtechMeta_MultiBlockBas /*if (CORE.DEVENV) { return this.checkRecipeGeneric(); }*/ - + this.fixAllMaintenanceIssue(); //log("Recipe Check."); ArrayList<ItemStack> tItemList = getStoredInputs(); @@ -411,6 +402,7 @@ public class GregtechMetaTileEntity_Cyclotron extends GregtechMeta_MultiBlockBas //Time Counter this.mTotalRunTime++; + this.fixAllMaintenanceIssue(); onRunningTick(null); @@ -502,7 +494,7 @@ public class GregtechMetaTileEntity_Cyclotron extends GregtechMeta_MultiBlockBas stopMachine(); } } - doRandomMaintenanceDamage(); + //doRandomMaintenanceDamage(); 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); diff --git a/src/resources/assets/gregtech/lang/en_US.lang b/src/resources/assets/gregtech/lang/en_US.lang index c388f9785e..9989bffcf0 100644 --- a/src/resources/assets/gregtech/lang/en_US.lang +++ b/src/resources/assets/gregtech/lang/en_US.lang @@ -4,15 +4,19 @@ GTPP.EBF.heat=Heat capacity GTPP.machines.tier=Tier +GTPP.machines.input=Input +GTPP.machines.output=Output GTPP.multiblock.pollutionreduced=Pollution reduced to GTPP.multiblock.pollution=Pollution GTPP.multiblock.energy=Stored Energy -GTPP.multiblock.Progress=Progress +GTPP.multiblock.progress=Progress GTPP.multiblock.efficiency=Efficiency GTPP.multiblock.problems=Problems GTPP.multiblock.mei=Max Energy Income GTPP.multiblock.usage=Probably uses +GTPP.multiblock.specialvalue=Special Value +GTPP.multiblock.duration=Duration diff --git a/src/resources/assets/gregtech/lang/zh_CN.lang b/src/resources/assets/gregtech/lang/zh_CN.lang index 750961610a..df43ca8590 100644 --- a/src/resources/assets/gregtech/lang/zh_CN.lang +++ b/src/resources/assets/gregtech/lang/zh_CN.lang @@ -8,7 +8,7 @@ GTPP.machines.tier=等级 GTPP.multiblock.pollutionreduced=减少污染至 GTPP.multiblock.pollution=污染 GTPP.multiblock.energy=能量存储 -GTPP.multiblock.Progress=进程 +GTPP.multiblock.progress=进程 GTPP.multiblock.efficiency=效率 GTPP.multiblock.problems=为每桶 GTPP.multiblock.mei=最大能量输入 |