From 2ac85af0eca2352d5fc9d8d21c1b8ce03823bfed Mon Sep 17 00:00:00 2001 From: bartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com> Date: Wed, 27 May 2020 12:14:06 +0200 Subject: Unified Large Chem reactor OC related #294 Signed-off-by: bartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com> --- .../GT_MetaTileEntity_MultiBlockBase.java | 82 +++++++++++----------- 1 file changed, 42 insertions(+), 40 deletions(-) (limited to 'src/main/java/gregtech/api') 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 3efbe0d57b..c6828c707e 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 @@ -1,10 +1,5 @@ package gregtech.api.metatileentity.implementations; -import static gregtech.api.enums.GT_Values.V; -import static gregtech.api.enums.GT_Values.VN; - -import java.util.ArrayList; - import gregtech.GT_Mod; import gregtech.api.GregTech_API; import gregtech.api.enums.ConfigCategories; @@ -29,6 +24,11 @@ import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; import net.minecraftforge.fluids.FluidStack; +import java.util.ArrayList; + +import static gregtech.api.enums.GT_Values.V; +import static gregtech.api.enums.GT_Values.VN; + public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { public static boolean disableMaintenance; @@ -538,13 +538,6 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { aFirstVoltageFound = aVoltage; } else { - /** - * Calcualtes overclocked ness using long integers - * @param aEUt - recipe EUt - * @param aDuration - recipe Duration - * @param mAmperage - should be 1 ? - */ - //Long time calculation if (aFirstVoltageFound != aVoltage) { aFoundMixedDynamos = true; } @@ -559,13 +552,10 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { } long leftToInject; - //Long EUt calculation long aVoltage; - //Isnt too low EUt check? int aAmpsToInject; int aRemainder; int ampsOnCurrentHatch; - //xEUt *= 4;//this is effect of everclocking for (GT_MetaTileEntity_Hatch_Dynamo aDynamo : mDynamoHatches) { if (isValidMetaTileEntity(aDynamo)) { leftToInject = aEU - injected; @@ -594,51 +584,63 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { } /** - * Calcualtes overclocked ness using long integers - * @param aEUt - recipe EUt - * @param aDuration - recipe Duration - * @param mAmperage - should be 1 ? + * Calcualtes the overclockedness using long integers + * @param aEUt - recipe EUt + * @param aDuration - recipe Duration + * @param mAmperage - should be 1 ? + * @param maxInputVoltage - Multiblock Max input voltage + * @param perfectOC - If the Multiblock OCs perfectly, i.e. the large Chemical Reactor */ - protected void calculateOverclockedNessMulti(int aEUt, int aDuration, int mAmperage, long maxInputVoltage) { - byte mTier=(byte)Math.max(0,GT_Utility.getTier(maxInputVoltage)); - if(mTier==0){ + protected void calculateOverclockedNessMultiInternal(int aEUt, int aDuration, int mAmperage, long maxInputVoltage, boolean perfectOC) { + 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){ + if(xMaxProgresstime > Integer.MAX_VALUE - 1){ //make impossible if too long - mEUt=Integer.MAX_VALUE-1; - mMaxProgresstime=Integer.MAX_VALUE-1; + mEUt = Integer.MAX_VALUE - 1; + mMaxProgresstime = Integer.MAX_VALUE - 1; }else{ - mEUt=aEUt>>2; - mMaxProgresstime=(int)xMaxProgresstime; + mEUt = aEUt >> 2; + mMaxProgresstime= (int) xMaxProgresstime; } }else{ //Long EUt calculation - long xEUt=aEUt; + long xEUt = aEUt; //Isnt too low EUt check? - long tempEUt = xEUt>=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 + mMaxProgresstime >>= ocTimeShift;//this is effect of overclocking + xEUt = mMaxProgresstime==0 ? xEUt >> ocTimeShift : 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) + 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) + if(mMaxProgresstime == 0) mMaxProgresstime = 1;//set time to 1 tick } } } + protected void calculateOverclockedNessMulti(int aEUt, int aDuration, int mAmperage, long maxInputVoltage) { + calculateOverclockedNessMultiInternal(aEUt,aDuration,mAmperage,maxInputVoltage,false); + } + + protected void calculatePerfectOverclockedNessMulti(int aEUt, int aDuration, int mAmperage, long maxInputVoltage) { + calculateOverclockedNessMultiInternal(aEUt,aDuration,mAmperage,maxInputVoltage,true); + } + public boolean drainEnergyInput(long aEU) { if (aEU <= 0) return true; for (GT_MetaTileEntity_Hatch_Energy tHatch : mEnergyHatches) -- cgit From 8d2ae1ef739dcad3e8c2b22ee52d0ff6e3ee1b91 Mon Sep 17 00:00:00 2001 From: Jason Mitchell Date: Sun, 31 May 2020 10:53:54 -0700 Subject: Only modify aStack when doDrain == true --- src/main/java/gregtech/api/items/GT_MetaBase_Item.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/main/java/gregtech/api') diff --git a/src/main/java/gregtech/api/items/GT_MetaBase_Item.java b/src/main/java/gregtech/api/items/GT_MetaBase_Item.java index 264c510701..511ad096d0 100644 --- a/src/main/java/gregtech/api/items/GT_MetaBase_Item.java +++ b/src/main/java/gregtech/api/items/GT_MetaBase_Item.java @@ -514,11 +514,14 @@ public abstract class GT_MetaBase_Item extends GT_Generic_Item implements ISpeci if (tFluid != null && maxDrain >= tFluid.amount) { ItemStack tStack = GT_Utility.getContainerItem(aStack, false); if (tStack == null) { - aStack.stackSize = 0; + if(doDrain) aStack.stackSize = 0; return tFluid; } - aStack.setItemDamage(tStack.getItemDamage()); - aStack.func_150996_a(tStack.getItem()); + if(doDrain) { + GT_Log.out.println("FUCKTHECELLS - Draining " + aStack.getDisplayName() + " and setting to " + tStack.getDisplayName()); + aStack.setItemDamage(tStack.getItemDamage()); + aStack.func_150996_a(tStack.getItem()); + } return tFluid; } -- cgit From 5a34664d0790c2c6155c77f4abc409ef6e12e766 Mon Sep 17 00:00:00 2001 From: Jason Mitchell Date: Sun, 31 May 2020 11:01:13 -0700 Subject: Remove Logging --- src/main/java/gregtech/api/items/GT_MetaBase_Item.java | 1 - 1 file changed, 1 deletion(-) (limited to 'src/main/java/gregtech/api') diff --git a/src/main/java/gregtech/api/items/GT_MetaBase_Item.java b/src/main/java/gregtech/api/items/GT_MetaBase_Item.java index 511ad096d0..edc60b45fc 100644 --- a/src/main/java/gregtech/api/items/GT_MetaBase_Item.java +++ b/src/main/java/gregtech/api/items/GT_MetaBase_Item.java @@ -518,7 +518,6 @@ public abstract class GT_MetaBase_Item extends GT_Generic_Item implements ISpeci return tFluid; } if(doDrain) { - GT_Log.out.println("FUCKTHECELLS - Draining " + aStack.getDisplayName() + " and setting to " + tStack.getDisplayName()); aStack.setItemDamage(tStack.getItemDamage()); aStack.func_150996_a(tStack.getItem()); } -- cgit From e4bd293915ea20359dc228a623c08f7a1055d843 Mon Sep 17 00:00:00 2001 From: moller21 <42100910+moller21@users.noreply.github.com> Date: Mon, 1 Jun 2020 17:02:56 +0200 Subject: Added gui's for the rest of em covers. --- src/main/java/gregtech/api/gui/GT_GUICover.java | 11 +- .../java/gregtech/api/gui/widgets/GT_GuiIcon.java | 1 + .../gregtech/api/gui/widgets/GT_GuiIconButton.java | 12 +- .../api/gui/widgets/GT_GuiIconCheckButton.java | 31 ++ .../api/gui/widgets/GT_GuiIntegerTextBox.java | 12 + src/main/java/gregtech/api/util/GT_Utility.java | 58 ++++ .../java/gregtech/common/covers/GT_Cover_Arm.java | 360 ++++++++++++++++++++- .../common/covers/GT_Cover_ControlsWork.java | 80 +++++ .../gregtech/common/covers/GT_Cover_Conveyor.java | 126 ++++++++ .../gregtech/common/covers/GT_Cover_DoesWork.java | 123 ++++++- .../gregtech/common/covers/GT_Cover_EUMeter.java | 111 +++++++ .../common/covers/GT_Cover_Fluidfilter.java | 4 +- .../gregtech/common/covers/GT_Cover_ItemMeter.java | 245 +++++++++++++- .../common/covers/GT_Cover_LiquidMeter.java | 88 ++++- .../common/covers/GT_Cover_NeedMaintainance.java | 120 +++++++ .../common/covers/GT_Cover_PlayerDetector.java | 80 +++++ .../java/gregtech/common/covers/GT_Cover_Pump.java | 2 +- .../covers/GT_Cover_RedstoneWirelessBase.java | 119 +++++++ .../gregtech/common/covers/GT_Cover_Shutter.java | 82 +++++ .../assets/gregtech/textures/gui/GuiButtons.png | Bin 9499 -> 9910 bytes 20 files changed, 1625 insertions(+), 40 deletions(-) create mode 100644 src/main/java/gregtech/api/gui/widgets/GT_GuiIconCheckButton.java (limited to 'src/main/java/gregtech/api') diff --git a/src/main/java/gregtech/api/gui/GT_GUICover.java b/src/main/java/gregtech/api/gui/GT_GUICover.java index 94346186a8..f1232c9432 100644 --- a/src/main/java/gregtech/api/gui/GT_GUICover.java +++ b/src/main/java/gregtech/api/gui/GT_GUICover.java @@ -157,8 +157,10 @@ public abstract class GT_GUICover extends GuiScreen implements GT_IToolTipRender public void mouseClicked(int x, int y, int button) { for (GT_GuiIntegerTextBox tBox : textBoxes) { boolean hadFocus = tBox.isFocused(); - tBox.mouseClicked(x,y,button); - if (tBox.isFocused() && button == 1) //rightclick -> lcear it + if (tBox.isEnabled() || hadFocus) + tBox.mouseClicked(x,y,button); + + if (tBox.isFocused() && button == 1 && tBox.isEnabled()) //rightclick -> lcear it tBox.setText("0"); else if (hadFocus && !tBox.isFocused()) applyTextBox(tBox); @@ -193,6 +195,9 @@ public abstract class GT_GUICover extends GuiScreen implements GT_IToolTipRender return; } } + if (textBoxes.size() > 0 ) + setFocusedTextBox(textBoxes.get(0)); + return; } if (focusedTextBox != null && focusedTextBox.textboxKeyTyped(c, key)){ @@ -239,7 +244,7 @@ public abstract class GT_GUICover extends GuiScreen implements GT_IToolTipRender */ private void setFocusedTextBox(GT_GuiIntegerTextBox boxToFocus) { for (GT_GuiIntegerTextBox textBox : textBoxes) { - textBox.setFocused(textBox.equals(boxToFocus)); + textBox.setFocused(textBox.equals(boxToFocus) && textBox.isEnabled()); } } public void applyTextBox(GT_GuiIntegerTextBox box) { diff --git a/src/main/java/gregtech/api/gui/widgets/GT_GuiIcon.java b/src/main/java/gregtech/api/gui/widgets/GT_GuiIcon.java index 1c31462e62..41e851054d 100644 --- a/src/main/java/gregtech/api/gui/widgets/GT_GuiIcon.java +++ b/src/main/java/gregtech/api/gui/widgets/GT_GuiIcon.java @@ -18,6 +18,7 @@ public enum GT_GuiIcon { CROSS (0, 32*4, 32), WHITELIST (0, 32*5, 32), BLACKLIST (0, 32*6, 32), + PROGRESS (0, 32*7, 32), EXPORT (0, 0, 32*2), IMPORT (0, 32, 32*2), diff --git a/src/main/java/gregtech/api/gui/widgets/GT_GuiIconButton.java b/src/main/java/gregtech/api/gui/widgets/GT_GuiIconButton.java index f68962f58f..e081c4227d 100644 --- a/src/main/java/gregtech/api/gui/widgets/GT_GuiIconButton.java +++ b/src/main/java/gregtech/api/gui/widgets/GT_GuiIconButton.java @@ -12,7 +12,7 @@ public class GT_GuiIconButton extends GuiButton implements IGuiScreen.IGuiElemen protected GT_GuiIcon icon; private int x0, y0; - private IGuiScreen gui; + protected IGuiScreen gui; private String[] tooltipText; private GT_GuiTooltip tooltip; @@ -56,7 +56,7 @@ public class GT_GuiIconButton extends GuiButton implements IGuiScreen.IGuiElemen int x = xPosition; int y = yPosition; if(!this.field_146123_n) { - GL11.glColor4f(200F/255F, 210F/255F, 1, 1); + // GL11.glColor4f(200F/255F, 210F/255F, 1, 1); } else GL11.glColor4f(1, 1, 1, 1); @@ -84,13 +84,17 @@ public class GT_GuiIconButton extends GuiButton implements IGuiScreen.IGuiElemen return GT_GuiIcon.BUTTON_DISABLED; if (this.equals(this.gui.getSelectedButton())) return mouseOver ? GT_GuiIcon.BUTTON_HIGHLIGHT_DOWN : GT_GuiIcon.BUTTON_DOWN; - else - return mouseOver ? GT_GuiIcon.BUTTON_HIGHLIGHT : GT_GuiIcon.BUTTON_NORMAL; + + return mouseOver ? GT_GuiIcon.BUTTON_HIGHLIGHT : GT_GuiIcon.BUTTON_NORMAL; } public GT_GuiIcon getIcon() { return icon; } + public GT_GuiIconButton setIcon(GT_GuiIcon icon) { + this.icon = icon; + return this; + } public GT_GuiTooltip getTooltip() { return tooltip; diff --git a/src/main/java/gregtech/api/gui/widgets/GT_GuiIconCheckButton.java b/src/main/java/gregtech/api/gui/widgets/GT_GuiIconCheckButton.java new file mode 100644 index 0000000000..4e6fd86f55 --- /dev/null +++ b/src/main/java/gregtech/api/gui/widgets/GT_GuiIconCheckButton.java @@ -0,0 +1,31 @@ +package gregtech.api.gui.widgets; + +import gregtech.api.interfaces.IGuiScreen; + +public class GT_GuiIconCheckButton extends GT_GuiIconButton { + private GT_GuiIcon checkedIcon, normalIcon; + private boolean checked = false; + + public GT_GuiIconCheckButton(IGuiScreen gui, int id, int x, int y, GT_GuiIcon checkedIcon, GT_GuiIcon normalIcon) { + super(gui, id, x, y, normalIcon); + this.checkedIcon = checkedIcon; + this.normalIcon = normalIcon; + } + + public GT_GuiIcon getButtonTexture(boolean mouseOver) { + if (!enabled) + return GT_GuiIcon.BUTTON_DISABLED; + if (this.equals(super.gui.getSelectedButton())) + return mouseOver ? GT_GuiIcon.BUTTON_HIGHLIGHT_DOWN : GT_GuiIcon.BUTTON_DOWN; + return mouseOver ? GT_GuiIcon.BUTTON_HIGHLIGHT : GT_GuiIcon.BUTTON_NORMAL; + } + + public boolean isChecked() { + return checked; + } + + public void setChecked(boolean checked) { + super.setIcon(checked ? checkedIcon : normalIcon); + this.checked = checked; + } +} diff --git a/src/main/java/gregtech/api/gui/widgets/GT_GuiIntegerTextBox.java b/src/main/java/gregtech/api/gui/widgets/GT_GuiIntegerTextBox.java index 3f6fe64e73..e2ba53e4c9 100644 --- a/src/main/java/gregtech/api/gui/widgets/GT_GuiIntegerTextBox.java +++ b/src/main/java/gregtech/api/gui/widgets/GT_GuiIntegerTextBox.java @@ -10,6 +10,7 @@ public class GT_GuiIntegerTextBox extends GuiTextField implements IGuiScreen.IGu private final int x0, y0; private final IGuiScreen gui; public final int id; + private boolean enabled; public GT_GuiIntegerTextBox(IGuiScreen gui, int id, int x, int y, int width, int height) { super(Minecraft.getMinecraft().fontRenderer, x, y, width, height); @@ -18,6 +19,7 @@ public class GT_GuiIntegerTextBox extends GuiTextField implements IGuiScreen.IGu x0 = x; y0 = y; this.gui = gui; + enabled = true; gui.addElement(this); } @@ -47,4 +49,14 @@ public class GT_GuiIntegerTextBox extends GuiTextField implements IGuiScreen.IGu } return false; } + + @Override + public void setEnabled(boolean p_146184_1_) { + super.setEnabled(p_146184_1_); + enabled = p_146184_1_; + } + + public boolean isEnabled() { + return enabled; + } } diff --git a/src/main/java/gregtech/api/util/GT_Utility.java b/src/main/java/gregtech/api/util/GT_Utility.java index 8584e849bb..f5dfb42a2c 100644 --- a/src/main/java/gregtech/api/util/GT_Utility.java +++ b/src/main/java/gregtech/api/util/GT_Utility.java @@ -665,6 +665,64 @@ public class GT_Utility { return 0; } + /** + * Moves Stack from Inv-Side to Inv-Slot. + * + * @return the Amount of moved Items + */ + public static byte moveFromSlotToSide(IInventory fromTile, Object toTile, int aGrabFrom, byte aPutTo, List aFilter, boolean aInvertFilter, byte aMaxTargetStackSize, byte aMinTargetStackSize, byte aMaxMoveAtOnce, byte aMinMoveAtOnce, boolean aDoCheckChests) { + if (fromTile == null || aGrabFrom < 0 || aMinTargetStackSize <= 0 || aMaxMoveAtOnce <= 0 || aMinTargetStackSize > aMaxTargetStackSize || aMinMoveAtOnce > aMaxMoveAtOnce) + return 0; + + if (!listContainsItem(aFilter, fromTile.getStackInSlot(aGrabFrom), true, aInvertFilter) || + !isAllowedToTakeFromSlot(fromTile, aGrabFrom, (byte) 6, fromTile.getStackInSlot(aGrabFrom))) + return 0; + + if (toTile instanceof IInventory) { + int[] tPutSlots = null; + if (toTile instanceof ISidedInventory) + tPutSlots = ((ISidedInventory) toTile).getAccessibleSlotsFromSide(aPutTo); + + if (tPutSlots == null) { + tPutSlots = new int[((IInventory) toTile).getSizeInventory()]; + for (int i = 0; i < tPutSlots.length; i++) tPutSlots[i] = i; + } + + byte tMovedItemCount = 0; + for (int tPutSlot : tPutSlots) { + if (isAllowedToPutIntoSlot((IInventory) toTile, tPutSlot, aPutTo, fromTile.getStackInSlot(aGrabFrom), aMaxTargetStackSize)) { + tMovedItemCount += moveStackFromSlotAToSlotB(fromTile, (IInventory) toTile, aGrabFrom, tPutSlot, aMaxTargetStackSize, aMinTargetStackSize, (byte) (aMaxMoveAtOnce - tMovedItemCount), aMinMoveAtOnce); + if (tMovedItemCount >= aMaxMoveAtOnce) { + return tMovedItemCount; + + } + } + } + if (tMovedItemCount > 0) return tMovedItemCount; + + if (aDoCheckChests && toTile instanceof TileEntityChest) { + TileEntityChest tTileEntity2 = (TileEntityChest) toTile; + if (tTileEntity2.adjacentChestChecked) { + if (tTileEntity2.adjacentChestXNeg != null) { + tMovedItemCount = moveFromSlotToSide(fromTile, tTileEntity2.adjacentChestXNeg, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce, false); + } else if (tTileEntity2.adjacentChestZNeg != null) { + tMovedItemCount = moveFromSlotToSide(fromTile, tTileEntity2.adjacentChestZNeg, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce, false); + } else if (tTileEntity2.adjacentChestXPos != null) { + tMovedItemCount = moveFromSlotToSide(fromTile, tTileEntity2.adjacentChestXPos, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce, false); + } else if (tTileEntity2.adjacentChestZPos != null) { + tMovedItemCount = moveFromSlotToSide(fromTile, tTileEntity2.adjacentChestZPos, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce, false); + } + if (tMovedItemCount > 0) return tMovedItemCount; + } + } + } + return moveStackIntoPipe(fromTile, toTile, new int[]{aGrabFrom}, (byte) 6, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce, aDoCheckChests); + } + + public static byte moveFromSlotToSide(IInventory fromTile, Object toTile, int aGrabFrom, byte aPutTo, List aFilter, boolean aInvertFilter, byte aMaxTargetStackSize, byte aMinTargetStackSize, byte aMaxMoveAtOnce, byte aMinMoveAtOnce) { + return moveFromSlotToSide(fromTile, toTile, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce, true); + } + public static boolean listContainsItem(Collection aList, ItemStack aStack, boolean aTIfListEmpty, boolean aInvertFilter) { if (aStack == null || aStack.stackSize < 1) return false; if (aList == null) return aTIfListEmpty; diff --git a/src/main/java/gregtech/common/covers/GT_Cover_Arm.java b/src/main/java/gregtech/common/covers/GT_Cover_Arm.java index 70d0340d1f..c86f80e530 100644 --- a/src/main/java/gregtech/common/covers/GT_Cover_Arm.java +++ b/src/main/java/gregtech/common/covers/GT_Cover_Arm.java @@ -1,10 +1,19 @@ package gregtech.common.covers; +import gregtech.api.enums.GT_Values; +import gregtech.api.gui.GT_GUICover; +import gregtech.api.gui.widgets.GT_GuiFakeItemButton; +import gregtech.api.gui.widgets.GT_GuiIcon; +import gregtech.api.gui.widgets.GT_GuiIconButton; +import gregtech.api.gui.widgets.GT_GuiIntegerTextBox; import gregtech.api.interfaces.tileentity.ICoverable; import gregtech.api.interfaces.tileentity.IMachineProgress; +import gregtech.api.net.GT_Packet_TileEntityCover; import gregtech.api.util.GT_CoverBehavior; import gregtech.api.util.GT_Utility; +import net.minecraft.client.gui.GuiButton; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.fluids.Fluid; @@ -12,47 +21,135 @@ public class GT_Cover_Arm extends GT_CoverBehavior { public final int mTickRate; + //msb unused, 2nd : direction (1=export) + //right 15 bits: internalSlot, next 15 bits adjSlot, 0 = all, slot = -1 + protected final static int EXPORT_MASK = 0x40000000; + protected final static int SLOT_ID_MASK = 0x7FFF; + protected final static int SLOT_ID_MIN = 0; + public GT_Cover_Arm(int aTickRate) { this.mTickRate = aTickRate; } public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) { - if ((aCoverVariable == 0) || (((aTileEntity instanceof IMachineProgress)) && (!((IMachineProgress) aTileEntity).isAllowedToWork()))) { + if ((((aTileEntity instanceof IMachineProgress)) && (!((IMachineProgress) aTileEntity).isAllowedToWork()))) { return aCoverVariable; } - TileEntity tTileEntity = aTileEntity.getTileEntityAtSide(aSide); - //aTileEntity.decreaseStoredEnergyUnits(1L, true); + + boolean usePower = false; if (aTileEntity.getUniversalEnergyCapacity() >= 128L) { if (aTileEntity.isUniversalEnergyStored(256L)) { - aTileEntity.decreaseStoredEnergyUnits(4 * GT_Utility.moveOneItemStackIntoSlot(aCoverVariable > 0 ? aTileEntity : tTileEntity, aCoverVariable > 0 ? tTileEntity : aTileEntity, aCoverVariable > 0 ? aSide : GT_Utility.getOppositeSide(aSide), Math.abs(aCoverVariable) - 1, null, false, (byte) 64, (byte) 1, (byte) 64, (byte) 1), true); + usePower = true; + } else { + return aCoverVariable; } + } + + TileEntity toTile, fromTile; + int toSlot, fromSlot; + + if ((aCoverVariable & EXPORT_MASK) > 0) { + fromTile = (TileEntity) aTileEntity; + toTile = aTileEntity.getTileEntityAtSide(aSide); + fromSlot = aCoverVariable & SLOT_ID_MASK; + toSlot = (aCoverVariable>>15) & SLOT_ID_MASK; } else { - GT_Utility.moveOneItemStackIntoSlot(aCoverVariable > 0 ? aTileEntity : tTileEntity, aCoverVariable > 0 ? tTileEntity : aTileEntity, aCoverVariable > 0 ? aSide : GT_Utility.getOppositeSide(aSide), Math.abs(aCoverVariable) - 1, null, false, (byte) 64, (byte) 1, (byte) 64, (byte) 1); + fromTile = aTileEntity.getTileEntityAtSide(aSide); + toTile = (TileEntity) aTileEntity; + fromSlot = (aCoverVariable>>15) & SLOT_ID_MASK; + toSlot = aCoverVariable & SLOT_ID_MASK; } + + byte movedItems = 0; + if(fromSlot > 0 && toSlot > 0) { + if (fromTile instanceof IInventory && toTile instanceof IInventory) + movedItems = GT_Utility.moveFromSlotToSlot((IInventory) fromTile, (IInventory) toTile, fromSlot-1, toSlot-1, null, false, (byte)64, (byte)1, (byte)64, (byte)1); + } else if (toSlot > 0) { + byte side; + if ((aCoverVariable & EXPORT_MASK) > 0) + side = aSide; + else + side = GT_Utility.getOppositeSide(aSide); + movedItems = GT_Utility.moveOneItemStackIntoSlot(fromTile, toTile, side, toSlot-1, null, false, (byte)64, (byte)1, (byte)64, (byte)1); + } else if (fromSlot > 0) { + byte toSide; + if ((aCoverVariable & EXPORT_MASK) > 0) + toSide = aSide; + else + toSide = GT_Utility.getOppositeSide(aSide); + if (fromTile instanceof IInventory) + movedItems = GT_Utility.moveFromSlotToSide((IInventory) fromTile, toTile, fromSlot-1, toSide, null, false, (byte)64, (byte)1, (byte)64, (byte)1); + } else { + byte fromSide, toSide; + if ((aCoverVariable & EXPORT_MASK) > 0) { + fromSide = aSide; + toSide = GT_Utility.getOppositeSide(aSide); + } else { + fromSide = GT_Utility.getOppositeSide(aSide); + toSide = aSide; + } + movedItems = GT_Utility.moveOneItemStack(fromTile, toTile, fromSide, toSide, null, false, (byte)64, (byte)1, (byte)64, (byte)1); + } + + if (usePower) + aTileEntity.decreaseStoredEnergyUnits(4*movedItems, true); + return aCoverVariable; } public int onCoverScrewdriverclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) { + int step = 0; if (GT_Utility.getClickedFacingCoords(aSide, aX, aY, aZ)[0] >= 0.5F) { - aCoverVariable += aPlayer.isSneaking() ? 256 : 16; + step += aPlayer.isSneaking() ? 256 : 16; } else { - aCoverVariable += aPlayer.isSneaking() ? 256 : 16; + step -= aPlayer.isSneaking() ? 256 : 16; } - GT_Utility.sendChatToPlayer(aPlayer, (aCoverVariable > 0 ? trans("001","Puts out into adjacent Slot #") : trans("002","Grabs in for own Slot #")) + (Math.abs(aCoverVariable) - 1)); + aCoverVariable = getNewVar(aCoverVariable, step); + sendMessageToPlayer(aPlayer, aCoverVariable); return aCoverVariable; } public boolean onCoverRightclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) { - if (GT_Utility.getClickedFacingCoords(aSide, aX, aY, aZ)[0] >= 0.5F) { - aCoverVariable++; - } else { - aCoverVariable--; - } - GT_Utility.sendChatToPlayer(aPlayer, (aCoverVariable > 0 ? trans("001","Puts out into adjacent Slot #") : trans("002","Grabs in for own Slot #")) + (Math.abs(aCoverVariable) - 1)); + int step = (GT_Utility.getClickedFacingCoords(aSide, aX, aY, aZ)[0] >= 0.5F) ? 1 : -1; + aCoverVariable = getNewVar(aCoverVariable, step); + sendMessageToPlayer(aPlayer, aCoverVariable); aTileEntity.setCoverDataAtSide(aSide, aCoverVariable); return true; } + private void sendMessageToPlayer(EntityPlayer aPlayer, int var) { + if ((var & EXPORT_MASK) != 0) + GT_Utility.sendChatToPlayer(aPlayer, trans("001","Puts out into adjacent Slot #") + (((var >> 15) & SLOT_ID_MASK) - 1)); + else + GT_Utility.sendChatToPlayer(aPlayer, trans("002","Grabs in for own Slot #") + ((var & SLOT_ID_MASK) - 1)); + } + + private int getNewVar(int var, int step) { + int intSlot = (var & SLOT_ID_MASK); + int adjSlot = (var >> 15) & SLOT_ID_MASK; + if ((var & EXPORT_MASK) == 0) { + int x = (intSlot + step); + if (x > SLOT_ID_MASK ) + return createVar(0, SLOT_ID_MASK, 0); + else if (x < 1) + return createVar(- step - intSlot + 1, 0, 1); + else + return createVar(0, x, 0); + } else { + int x = (adjSlot - step); + if (x > SLOT_ID_MASK ) + return createVar(SLOT_ID_MASK, 0, 1); + else if (x < 1) + return createVar(0, + step - adjSlot + 1, 0); + else + return createVar(x, 0, 1); + } + } + + private int createVar(int adjSlot, int intSlot, int export){ + return ((export & 0x1) << 30) | ((adjSlot & SLOT_ID_MASK) << 15) | (intSlot & SLOT_ID_MASK); + } + public boolean letsRedstoneGoIn(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return true; } @@ -92,4 +189,239 @@ public class GT_Cover_Arm public int getTickRate(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return this.mTickRate; } + + /** + * GUI Stuff + */ + + @Override + public boolean hasCoverGUI() { + return true; + } + + @Override + public Object getClientGUI(byte aSide, int aCoverID, int coverData, ICoverable aTileEntity) { + return new GT_Cover_Arm.GUI(aSide, aCoverID, coverData, aTileEntity); + } + + private class GUI extends GT_GUICover { + private final byte side; + private final int coverID; + private GT_GuiIntegerTextBox intSlot, adjSlot; + private GT_GuiFakeItemButton intSlotIcon, adjSlotIcon; + private int coverVariable; + + private final static int startX = 10; + private final static int startY = 25; + private final static int spaceX = 18; + private final static int spaceY = 18; + + private final String ANY_TEXT = trans("ANY", "Any"); + + private boolean export; + private int internalSlotID, adjacentSlotID; + + private final int maxIntSlot, maxAdjSlot; + + public GUI(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + super(aTileEntity, 176, 107, GT_Utility.intToStack(aCoverID)); + this.side = aSide; + this.coverID = aCoverID; + this.coverVariable = aCoverVariable; + + export = (coverVariable & EXPORT_MASK) > 0; + internalSlotID = (coverVariable & SLOT_ID_MASK); + adjacentSlotID = (coverVariable >> 15) & SLOT_ID_MASK; + + new GT_GuiIconButton(this, 0, startX + spaceX * 0, startY + spaceY * 0, GT_GuiIcon.EXPORT).setTooltipText(trans("006", "Export")); + new GT_GuiIconButton(this, 1, startX + spaceX * 1, startY + spaceY * 0, GT_GuiIcon.IMPORT).setTooltipText(trans("007", "Import")); + + intSlot = new GT_GuiIntegerTextBox(this, 2, startX + spaceX * 0, startY + spaceY * 1 + 2, spaceX * 2+5, 12); + setBoxText(intSlot, internalSlotID-1); + intSlot.setMaxStringLength(6); + + adjSlot = new GT_GuiIntegerTextBox(this, 3, startX + spaceX * 0, startY + spaceY * 2 + 2, spaceX * 2+5, 12); + setBoxText(adjSlot, adjacentSlotID-1); + adjSlot.setMaxStringLength(6); + + //intSlotIcon = new GT_GuiFakeItemButton(this, startX + spaceX * 8-4, startY + spaceY * 1, GT_GuiIcon.SLOT_GRAY); + //adjSlotIcon = new GT_GuiFakeItemButton(this, startX + spaceX * 8-4, startY + spaceY * 2, GT_GuiIcon.SLOT_GRAY); + + if (super.tile instanceof TileEntity && !super.tile.isDead()) { + maxIntSlot = tile.getSizeInventory()-1; + + TileEntity adj = super.tile.getTileEntityAtSide(side); + if (adj instanceof IInventory) + maxAdjSlot = ((IInventory) adj).getSizeInventory()-1; + else + maxAdjSlot = -1; + } else { + maxIntSlot = -1; + maxAdjSlot = -1; + } + } + + @Override + public void drawExtras(int mouseX, int mouseY, float parTicks) { + super.drawExtras(mouseX, mouseY, parTicks); + if (export) + this.getFontRenderer().drawString(trans("006", "Export"), startX + spaceX*3, 4+startY+spaceY*0, 0xFF555555); + else + this.getFontRenderer().drawString(trans("007", "Import"), startX + spaceX*3, 4+startY+spaceY*0, 0xFF555555); + + this.getFontRenderer().drawString(trans("254", "Internal slot#"), startX + spaceX*3, 4+startY+spaceY*1, 0xFF555555); + this.getFontRenderer().drawString(trans("255", "Adjacent slot#"), startX + spaceX*3, 4+startY+spaceY*2, 0xFF555555); + } + + @Override + protected void onInitGui(int guiLeft, int guiTop, int gui_width, int gui_height) { + intSlot.setFocused(true); + updateButtons(); + + //updateInventorySlots(); + } + + @Override + public void buttonClicked(GuiButton btn) { + if (buttonClickable(btn.id)) { + export = btn.id == 0; + coverVariable = getNewCoverVariable(); + GT_Values.NW.sendToServer(new GT_Packet_TileEntityCover(side, coverID, coverVariable, tile)); + } + updateButtons(); + } + + private void updateButtons() { + GuiButton b; + for (Object o : buttonList) { + b = (GuiButton) o; + b.enabled = buttonClickable(b.id); + } + } + + @Override + public void onMouseWheel(int x, int y, int delta) { + for (GT_GuiIntegerTextBox box : textBoxes) { + if (box.isFocused()) { + int step = Math.max(1, Math.abs(delta / 120)); + step = (isShiftKeyDown() ? 50 : isCtrlKeyDown() ? 5 : 1) * (delta > 0 ? step : -step); + int maxSlot = box.id == 3 ? maxAdjSlot : maxIntSlot; + int val = parseTextBox(box, maxSlot); + if (val < 0) + val = -1; + val = val + step; + + if (maxSlot < val) + if (maxSlot < 0) + val = -1; + else + val = maxSlot; + else if (val < SLOT_ID_MIN) + val = -1; + + setBoxText(box, val); + return; + } + } + } + + @Override + public void applyTextBox(GT_GuiIntegerTextBox box) { + int val = -1; + + if (box.id == 2) { + val = parseTextBox(box, maxIntSlot); + internalSlotID = val+1; + } + else if (box.id == 3) { + val = parseTextBox(box, maxAdjSlot); + adjacentSlotID = val+1; + } + + setBoxText(box, val); + coverVariable = getNewCoverVariable(); + GT_Values.NW.sendToServer(new GT_Packet_TileEntityCover(side, coverID, coverVariable, tile)); + //updateInventorySlots(); + } + + @Override + public void resetTextBox(GT_GuiIntegerTextBox box) { + int val = 0; + if (box.id == 2) + val = internalSlotID-1; + else if (box.id == 3) + val = adjacentSlotID-1; + setBoxText(box, val); + } + + private void setBoxText(GT_GuiIntegerTextBox box, int val) { + box.setText( val < 0 ? ANY_TEXT : String.valueOf(val)); + } + + private int parseTextBox(GT_GuiIntegerTextBox box, int maxSlot) { + String text = box.getText(); + if (text == null) + return -1; + text = text.trim(); + if (text.startsWith(ANY_TEXT)) + text = text.substring(ANY_TEXT.length()); + + if (text.isEmpty()) + return -1; + + int val; + try { + val = Integer.parseInt(text); + } catch (NumberFormatException e) { + return -1; + } + + if (maxSlot < val) + if (maxSlot < 0) + return -1; + else + return maxSlot; + else if (val < SLOT_ID_MIN) + return SLOT_ID_MIN; + return val; + } + + private int getNewCoverVariable() { + return (export ? EXPORT_MASK : 0) | ((adjacentSlotID & SLOT_ID_MASK) << 15) | (internalSlotID & SLOT_ID_MASK); + } + + private boolean buttonClickable(int id) { + if (id == 0) + return !export; + return export; + } + +// getStackInSlot wasn't available client side.. +// private void updateInventorySlots() { +// updateInventorySlot(intSlotIcon, internalSlotID, true); +// updateInventorySlot(adjSlotIcon, adjacentSlotID, false); +// } +// +// private void updateInventorySlot(GT_GuiFakeItemButton button, int slotID, boolean internal) { +// if (slotID == SLOT_ID_ANY) { +// button.setItem(null); +// return; +// } +// +// if (super.tile instanceof TileEntity && !super.tile.isDead()) { +// TileEntity tile; +// if (internal) +// tile = (TileEntity) super.tile; +// else +// tile = super.tile.getTileEntityAtSide(side); +// +// if (tile instanceof IInventory && ((IInventory) tile).getSizeInventory() >= slotID) { +// ItemStack item = ((IInventory) tile).getStackInSlot(slotID); +// button.setItem(item); +// return; +// } +// } +// button.setItem(null); +// } + } } diff --git a/src/main/java/gregtech/common/covers/GT_Cover_ControlsWork.java b/src/main/java/gregtech/common/covers/GT_Cover_ControlsWork.java index 96a2d4a2b8..9624b68464 100644 --- a/src/main/java/gregtech/common/covers/GT_Cover_ControlsWork.java +++ b/src/main/java/gregtech/common/covers/GT_Cover_ControlsWork.java @@ -1,9 +1,15 @@ package gregtech.common.covers; +import gregtech.api.enums.GT_Values; +import gregtech.api.gui.GT_GUICover; +import gregtech.api.gui.widgets.GT_GuiIcon; +import gregtech.api.gui.widgets.GT_GuiIconButton; import gregtech.api.interfaces.tileentity.ICoverable; import gregtech.api.interfaces.tileentity.IMachineProgress; +import gregtech.api.net.GT_Packet_TileEntityCover; import gregtech.api.util.GT_CoverBehavior; import gregtech.api.util.GT_Utility; +import net.minecraft.client.gui.GuiButton; import net.minecraft.entity.player.EntityPlayer; import net.minecraftforge.fluids.Fluid; @@ -70,4 +76,78 @@ public class GT_Cover_ControlsWork public int getTickRate(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return 1; } + + /** + * GUI Stuff + */ + + @Override + public boolean hasCoverGUI() { + return true; + } + + @Override + public Object getClientGUI(byte aSide, int aCoverID, int coverData, ICoverable aTileEntity) { + return new GT_Cover_ControlsWork.GUI(aSide, aCoverID, coverData, aTileEntity); + } + + private class GUI extends GT_GUICover { + private final byte side; + private final int coverID; + private int coverVariable; + + private final static int startX = 10; + private final static int startY = 25; + private final static int spaceX = 18; + private final static int spaceY = 18; + + public GUI(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + super(aTileEntity, 176, 107, GT_Utility.intToStack(aCoverID)); + this.side = aSide; + this.coverID = aCoverID; + this.coverVariable = aCoverVariable; + + GuiButton b; + b = new GT_GuiIconButton(this, 0, startX + spaceX * 0, startY + spaceY * 0, GT_GuiIcon.REDSTONE_ON); + b = new GT_GuiIconButton(this, 1, startX + spaceX * 0, startY + spaceY * 1, GT_GuiIcon.REDSTONE_OFF); + b = new GT_GuiIconButton(this, 2, startX + spaceX * 0, startY + spaceY * 2, GT_GuiIcon.CROSS); + } + + @Override + public void drawExtras(int mouseX, int mouseY, float parTicks) { + super.drawExtras(mouseX, mouseY, parTicks); + this.fontRendererObj.drawString(trans("243", "Enable with Redstone"), 3+startX + spaceX*1, 4+startY+spaceY*0, 0xFF555555); + this.fontRendererObj.drawString(trans("244", "Disable with Redstone"),3+startX + spaceX*1, 4+startY+spaceY*1, 0xFF555555); + this.fontRendererObj.drawString(trans("245", "Disable machine"), 3+startX + spaceX*1, 4+startY+spaceY*2, 0xFF555555); + } + + @Override + protected void onInitGui(int guiLeft, int guiTop, int gui_width, int gui_height) { + updateButtons(); + } + + public void buttonClicked(GuiButton btn) { + if (getClickable(btn.id)) { + coverVariable = getNewCoverVariable(btn.id); + GT_Values.NW.sendToServer(new GT_Packet_TileEntityCover(side, coverID, coverVariable, tile)); + } + updateButtons(); + } + + private void updateButtons() { + GuiButton b; + for (Object o : buttonList) { + b = (GuiButton) o; + b.enabled = getClickable(b.id); + } + } + + private int getNewCoverVariable(int id) { + return id; + } + + private boolean getClickable(int id) { + return id != coverVariable; + } + } } diff --git a/src/main/java/gregtech/common/covers/GT_Cover_Conveyor.java b/src/main/java/gregtech/common/covers/GT_Cover_Conveyor.java index d781f10915..303f358a34 100644 --- a/src/main/java/gregtech/common/covers/GT_Cover_Conveyor.java +++ b/src/main/java/gregtech/common/covers/GT_Cover_Conveyor.java @@ -1,9 +1,15 @@ package gregtech.common.covers; +import gregtech.api.enums.GT_Values; +import gregtech.api.gui.GT_GUICover; +import gregtech.api.gui.widgets.GT_GuiIcon; +import gregtech.api.gui.widgets.GT_GuiIconButton; import gregtech.api.interfaces.tileentity.ICoverable; import gregtech.api.interfaces.tileentity.IMachineProgress; +import gregtech.api.net.GT_Packet_TileEntityCover; import gregtech.api.util.GT_CoverBehavior; import gregtech.api.util.GT_Utility; +import net.minecraft.client.gui.GuiButton; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.fluids.Fluid; @@ -112,4 +118,124 @@ public class GT_Cover_Conveyor extends GT_CoverBehavior { public int getTickRate(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return this.mTickRate; } + + /** + * GUI Stuff + */ + + @Override + public boolean hasCoverGUI() { + return true; + } + + @Override + public Object getClientGUI(byte aSide, int aCoverID, int coverData, ICoverable aTileEntity) { + return new GT_Cover_Conveyor.GUI(aSide, aCoverID, coverData, aTileEntity); + } + + private class GUI extends GT_GUICover { + private final byte side; + private final int coverID; + private int coverVariable; + + private final static int startX = 10; + private final static int startY = 25; + private final static int spaceX = 18; + private final static int spaceY = 18; + + public GUI(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + super(aTileEntity, 176, 107, GT_Utility.intToStack(aCoverID)); + this.side = aSide; + this.coverID = aCoverID; + this.coverVariable = aCoverVariable; + + GT_GuiIconButton b; + b = new GT_GuiIconButton(this, 0, startX + spaceX*0, startY+spaceY*0, GT_GuiIcon.EXPORT).setTooltipText(trans("006","Export")); + b = new GT_GuiIconButton(this, 1, startX + spaceX*1, startY+spaceY*0, GT_GuiIcon.IMPORT).setTooltipText(trans("007","Import")); + b = new GT_GuiIconButton(this, 2, startX + spaceX*0, startY+spaceY*1, GT_GuiIcon.CHECKMARK).setTooltipText(trans("224","Ignore")); + b = new GT_GuiIconButton(this, 3, startX + spaceX*1, startY+spaceY*1, GT_GuiIcon.REDSTONE_ON).setTooltipText(trans("225","Conditional")); + b = new GT_GuiIconButton(this, 4, startX + spaceX*2, startY+spaceY*1, GT_GuiIcon.REDSTONE_OFF).setTooltipText(trans("226","Invert Condition")); + b = new GT_GuiIconButton(this, 5, startX + spaceX*0, startY+spaceY*2, GT_GuiIcon.ALLOW_INPUT).setTooltipText(trans("227","Allow Input")); + b = new GT_GuiIconButton(this, 6, startX + spaceX*1, startY+spaceY*2, GT_GuiIcon.BLOCK_INPUT).setTooltipText(trans("228","Block Input")); + } + + @Override + public void drawExtras(int mouseX, int mouseY, float parTicks) { + super.drawExtras(mouseX, mouseY, parTicks); + this.fontRendererObj.drawString(trans("229","Import/Export" ), startX + spaceX*3, 3+startY+spaceY*0, 0xFF555555); + this.fontRendererObj.drawString(trans("230","Conditional"), startX + spaceX*3, 3+startY+spaceY*1, 0xFF555555); + this.fontRendererObj.drawString(trans("231", "Enable Input"), startX + spaceX*3, 3+startY+spaceY*2, 0xFF555555); + } + + @Override + protected void onInitGui(int guiLeft, int guiTop, int gui_width, int gui_height) { + updateButtons(); + } + + public void buttonClicked(GuiButton btn){ + if (getClickable(btn.id)){ + coverVariable = getNewCoverVariable(btn.id); + GT_Values.NW.sendToServer(new GT_Packet_TileEntityCover(side, coverID, coverVariable, tile)); + } + updateButtons(); + } + + private void updateButtons(){ + GuiButton b; + for (Object o : buttonList) { + b = (GuiButton) o; + b.enabled = getClickable(b.id); + } + } + + private int getNewCoverVariable(int id) { + switch (id) { + case 0: + return coverVariable & ~0x1; + case 1: + return coverVariable | 0x1; + case 2: + if (coverVariable > 5) + return 0x6 | (coverVariable & ~0xE); + return (coverVariable & ~0xE); + case 3: + if (coverVariable > 5) + return 0x8 | (coverVariable & ~0xE); + return 0x2 | (coverVariable & ~0xE); + case 4: + if (coverVariable > 5) + return 0xA | (coverVariable & ~0xE); + return (0x4 | (coverVariable & ~0xE)); + case 5: + if (coverVariable <= 5) + return coverVariable + 6; + break; + case 6: + if (coverVariable > 5) + return coverVariable - 6; + } + return coverVariable; + } + + private boolean getClickable(int id) { + if (coverVariable < 0 | 11 < coverVariable) + return false; + + switch (id) { + case 0: case 1: + return (0x1 & coverVariable) != id; + case 2: + return (coverVariable % 6) >= 2; + case 3: + return (coverVariable % 6) < 2 | 4 <= (coverVariable % 6); + case 4: + return (coverVariable % 6) < 4; + case 5: + return coverVariable < 6; + case 6: + return coverVariable >= 6; + } + return false; + } + } } diff --git a/src/main/java/gregtech/common/covers/GT_Cover_DoesWork.java b/src/main/java/gregtech/common/covers/GT_Cover_DoesWork.java index 963b519f34..f2a37dd3cc 100644 --- a/src/main/java/gregtech/common/covers/GT_Cover_DoesWork.java +++ b/src/main/java/gregtech/common/covers/GT_Cover_DoesWork.java @@ -1,9 +1,16 @@ package gregtech.common.covers; +import gregtech.api.enums.GT_Values; +import gregtech.api.gui.GT_GUICover; +import gregtech.api.gui.widgets.GT_GuiIcon; +import gregtech.api.gui.widgets.GT_GuiIconButton; +import gregtech.api.gui.widgets.GT_GuiIconCheckButton; import gregtech.api.interfaces.tileentity.ICoverable; import gregtech.api.interfaces.tileentity.IMachineProgress; +import gregtech.api.net.GT_Packet_TileEntityCover; import gregtech.api.util.GT_CoverBehavior; import gregtech.api.util.GT_Utility; +import net.minecraft.client.gui.GuiButton; import net.minecraft.entity.player.EntityPlayer; import net.minecraftforge.fluids.Fluid; @@ -31,10 +38,10 @@ public class GT_Cover_DoesWork aCoverVariable = (aCoverVariable + (aPlayer.isSneaking()? -1 : 1)) % 4; if(aCoverVariable <0){aCoverVariable = 3;} switch(aCoverVariable) { - case 0: GT_Utility.sendChatToPlayer(aPlayer, trans("018", "Normal")); break; - case 1: GT_Utility.sendChatToPlayer(aPlayer, trans("019", "Inverted")); break; - case 2: GT_Utility.sendChatToPlayer(aPlayer, trans("020", "Ready to work")); break; - case 3: GT_Utility.sendChatToPlayer(aPlayer, trans("021", "Not ready to work")); break; + case 0: GT_Utility.sendChatToPlayer(aPlayer, trans("018", "Normal")); break; // Progress scaled + case 1: GT_Utility.sendChatToPlayer(aPlayer, trans("019", "Inverted")); break; // ^ inverted + case 2: GT_Utility.sendChatToPlayer(aPlayer, trans("020", "Ready to work")); break; // Not Running + case 3: GT_Utility.sendChatToPlayer(aPlayer, trans("021", "Not ready to work")); break; // Running } return aCoverVariable; } @@ -70,4 +77,112 @@ public class GT_Cover_DoesWork public int getTickRate(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return 5; } + + /** + * GUI Stuff + */ + + @Override + public boolean hasCoverGUI() { + return true; + } + + @Override + public Object getClientGUI(byte aSide, int aCoverID, int coverData, ICoverable aTileEntity) { + return new GT_Cover_DoesWork.GUI(aSide, aCoverID, coverData, aTileEntity); + } + + private class GUI extends GT_GUICover { + private final byte side; + private final int coverID; + private int coverVariable; + + private final static int startX = 10; + private final static int startY = 25; + private final static int spaceX = 18; + private final static int spaceY = 18; + + public GUI(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + super(aTileEntity, 176, 107, GT_Utility.intToStack(aCoverID)); + this.side = aSide; + this.coverID = aCoverID; + this.coverVariable = aCoverVariable; + + GuiButton b; + b = new GT_GuiIconButton(this, 0, startX + spaceX*0, startY+spaceY*0, GT_GuiIcon.PROGRESS); + b = new GT_GuiIconButton(this, 1, startX + spaceX*1, startY+spaceY*0, GT_GuiIcon.CHECKMARK); + b = new GT_GuiIconCheckButton(this, 2, startX + spaceX*0, startY+spaceY*1, GT_GuiIcon.REDSTONE_ON, GT_GuiIcon.REDSTONE_OFF); + } + + @Override + public void drawExtras(int mouseX, int mouseY, float parTicks) { + super.drawExtras(mouseX, mouseY, parTicks); + String s1, s2; + if ((coverVariable & 0x2) > 0) + s1 = trans("242", "Machine idle"); + else + s1 = trans("241", "Recipe progress"); + if ((coverVariable & 0x1) > 0) + s2 = trans("INVERTED","Inverted"); + else + s2 = trans("NORMAL","Normal"); + this.fontRendererObj.drawString(s1, startX + spaceX*3, 4+startY+spaceY*0, 0xFF555555); + this.fontRendererObj.drawString(s2, startX + spaceX*3, 4+startY+spaceY*1, 0xFF555555); + } + + @Override + protected void onInitGui(int guiLeft, int guiTop, int gui_width, int gui_height) { + updateButtons(); + } + + public void buttonClicked(GuiButton btn){ + if (getClickable(btn.id)){ + boolean state = false; + if (btn.id == 2) + state = ((GT_GuiIconCheckButton) btn).isChecked(); + + coverVariable = getNewCoverVariable(btn.id, state); + GT_Values.NW.sendToServer(new GT_Packet_TileEntityCover(side, coverID, coverVariable, tile)); + } + updateButtons(); + } + + private void updateButtons(){ + GuiButton b; + for (Object o : buttonList) { + b = (GuiButton) o; + if(b.id == 2){ + ((GT_GuiIconCheckButton) b).setChecked((coverVariable & 0x1) > 0); + } else { + b.enabled = getClickable(b.id); + } + } + } + + private int getNewCoverVariable(int id, boolean buttonState) { + switch (id) { + case 0: + return coverVariable & ~0x2; + case 1: + return coverVariable | 0x2; + case 2: + if (buttonState) + return coverVariable & ~0x1; + return coverVariable | 0x1; + } + return coverVariable; + } + + private boolean getClickable(int id) { + switch (id) { + case 0: + return (coverVariable & 0x2) > 0; + case 1: + return (coverVariable & 0x2) == 0; + case 2: + return true; + } + return false; + } + } } diff --git a/src/main/java/gregtech/common/covers/GT_Cover_EUMeter.java b/src/main/java/gregtech/common/covers/GT_Cover_EUMeter.java index 13aafe90df..35dcd9f6b4 100644 --- a/src/main/java/gregtech/common/covers/GT_Cover_EUMeter.java +++ b/src/main/java/gregtech/common/covers/GT_Cover_EUMeter.java @@ -1,14 +1,20 @@ package gregtech.common.covers; +import gregtech.api.enums.GT_Values; +import gregtech.api.gui.GT_GUICover; +import gregtech.api.gui.widgets.GT_GuiIcon; +import gregtech.api.gui.widgets.GT_GuiIconCheckButton; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.ICoverable; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.items.GT_MetaBase_Item; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicBatteryBuffer; +import gregtech.api.net.GT_Packet_TileEntityCover; import gregtech.api.util.GT_CoverBehavior; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_Utility; import ic2.api.item.IElectricItem; +import net.minecraft.client.gui.GuiButton; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.Fluid; @@ -141,4 +147,109 @@ public class GT_Cover_EUMeter public int getTickRate(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return 20; } + + /** + * GUI Stuff + */ + + @Override + public boolean hasCoverGUI() { + return true; + } + + @Override + public Object getClientGUI(byte aSide, int aCoverID, int coverData, ICoverable aTileEntity) { + return new GUI(aSide, aCoverID, coverData, aTileEntity); + } + + private class GUI extends GT_GUICover { + private final byte side; + private final int coverID; + private int coverVariable; + + private final static int startX = 10; + private final static int startY = 25; + private final static int spaceX = 18; + private final static int spaceY = 18; + + public GUI(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + super(aTileEntity, 176, 107, GT_Utility.intToStack(aCoverID)); + this.side = aSide; + this.coverID = aCoverID; + this.coverVariable = aCoverVariable; + + GuiButton b; + b = new GT_GuiIconCheckButton(this, 0, startX + spaceX*0, startY+spaceY*1, GT_GuiIcon.CHECKMARK, null) + .setTooltipText(trans("031", "Normal Universal Storage")); + b = new GT_GuiIconCheckButton(this, 1, startX + spaceX*0, startY+spaceY*0, GT_GuiIcon.CHECKMARK, null) + .setTooltipText(trans("033", "Normal Electricity Storage")); + b = new GT_GuiIconCheckButton(this, 2, startX + spaceX*0, startY+spaceY*2, GT_GuiIcon.CHECKMARK, null) + .setTooltipText(trans("035", "Normal Steam Storage")); + b = new GT_GuiIconCheckButton(this, 3, startX + spaceX*4, startY+spaceY*1, GT_GuiIcon.CHECKMARK, null) + .setTooltipText(trans("037", "Normal Average Electric Input")); + b = new GT_GuiIconCheckButton(this, 4, startX + spaceX*4, startY+spaceY*2, GT_GuiIcon.CHECKMARK, null) + .setTooltipText(trans("039", "Normal Average Electric Output")); + b = new GT_GuiIconCheckButton(this, 5, startX + spaceX*4, startY+spaceY*0, GT_GuiIcon.CHECKMARK, null) + .setTooltipText(trans("041", "Normal Electricity Storage(Including Batteries)")); + b = new GT_GuiIconCheckButton(this, 6, startX + spaceX*0, startY+spaceY*3+4, GT_GuiIcon.REDSTONE_ON, GT_GuiIcon.REDSTONE_OFF); + } + + @Override + public void drawExtras(int mouseX, int mouseY, float parTicks) { + super.drawExtras(mouseX, mouseY, parTicks); + String s2; + if ((coverVariable & 0x1) > 0) + s2 = trans("INVERTED","Inverted"); + else + s2 = trans("NORMAL","Normal"); + this.fontRendererObj.drawString(s2, startX + spaceX*1, 8+startY+spaceY*3, 0xFF555555); + + this.fontRendererObj.drawString("Universal", + startX + spaceX*1, 4+startY+spaceY*1, 0xFF555555); + this.fontRendererObj.drawString("Int. EU", + startX + spaceX*1, 4+startY+spaceY*0, 0xFF555555); + this.fontRendererObj.drawString("Steam", + startX + spaceX*1, 4+startY+spaceY*2, 0xFF555555); + this.fontRendererObj.drawString("Avg. Input", + startX + spaceX*5, 4+startY+spaceY*1, 0xFF555555); + this.fontRendererObj.drawString("Avg. Output", + startX + spaceX*5, 4+startY+spaceY*2, 0xFF555555); + this.fontRendererObj.drawString("EU stored", + startX + spaceX*5, 4+startY+spaceY*0, 0xFF555555); + } + + @Override + protected void onInitGui(int guiLeft, int guiTop, int gui_width, int gui_height) { + updateButtons(); + } + + public void buttonClicked(GuiButton btn){ + if (btn.id == 6 || !isEnabled(btn.id)){ + coverVariable = getNewCoverVariable(btn.id, ((GT_GuiIconCheckButton) btn).isChecked()); + GT_Values.NW.sendToServer(new GT_Packet_TileEntityCover(side, coverID, coverVariable, tile)); + } + updateButtons(); + } + + private void updateButtons(){ + for (Object o : buttonList) + ((GT_GuiIconCheckButton) o).setChecked(isEnabled(((GT_GuiIconCheckButton) o).id)); + } + + private int getNewCoverVariable(int id, boolean checked) { + if (id == 6) { + if (checked) + return coverVariable & ~0x1; + else + return coverVariable | 0x1; + } + return (coverVariable & 0x1) | (id << 1) ; + } + + private boolean isEnabled(int id) { + if (id == 6) + return (coverVariable & 0x1) > 0; + return (coverVariable >> 1) == id; + } + } } diff --git a/src/main/java/gregtech/common/covers/GT_Cover_Fluidfilter.java b/src/main/java/gregtech/common/covers/GT_Cover_Fluidfilter.java index 0a213bb844..bc966d3f54 100644 --- a/src/main/java/gregtech/common/covers/GT_Cover_Fluidfilter.java +++ b/src/main/java/gregtech/common/covers/GT_Cover_Fluidfilter.java @@ -184,8 +184,8 @@ public class GT_Cover_Fluidfilter extends GT_CoverBehavior { this.coverVariable = aCoverVariable; GT_GuiIconButton b; - b = new GT_GuiIconButton(this, 0, startX + spaceX*0, startY+spaceY*0, GT_GuiIcon.EXPORT).setTooltipText(trans("232","Filter Input")); - b = new GT_GuiIconButton(this, 1, startX + spaceX*1, startY+spaceY*0, GT_GuiIcon.IMPORT).setTooltipText(trans("233","Filter Output")); + b = new GT_GuiIconButton(this, 0, startX + spaceX*0, startY+spaceY*0, GT_GuiIcon.IMPORT).setTooltipText(trans("232","Filter Input")); + b = new GT_GuiIconButton(this, 1, startX + spaceX*1, startY+spaceY*0, GT_GuiIcon.EXPORT).setTooltipText(trans("233","Filter Output")); b = new GT_GuiIconButton(this, 2, startX + spaceX*0, startY+spaceY*2, GT_GuiIcon.BLOCK_INPUT).setTooltipText(trans("234", "Block Output")); b = new GT_GuiIconButton(this, 3, startX + spaceX*1, startY+spaceY*2, GT_GuiIcon.ALLOW_INPUT).setTooltipText(trans("235", "Allow Output")); b = new GT_GuiIconButton(this, 4, startX + spaceX*0, startY+spaceY*1, GT_GuiIcon.WHITELIST).setTooltipText(trans("236","Whitelist Fluid")); diff --git a/src/main/java/gregtech/common/covers/GT_Cover_ItemMeter.java b/src/main/java/gregtech/common/covers/GT_Cover_ItemMeter.java index 40706721c9..063788d50f 100644 --- a/src/main/java/gregtech/common/covers/GT_Cover_ItemMeter.java +++ b/src/main/java/gregtech/common/covers/GT_Cover_ItemMeter.java @@ -1,20 +1,33 @@ package gregtech.common.covers; +import gregtech.api.enums.GT_Values; +import gregtech.api.gui.GT_GUICover; +import gregtech.api.gui.widgets.GT_GuiFakeItemButton; +import gregtech.api.gui.widgets.GT_GuiIcon; +import gregtech.api.gui.widgets.GT_GuiIconCheckButton; +import gregtech.api.gui.widgets.GT_GuiIntegerTextBox; import gregtech.api.interfaces.tileentity.ICoverable; +import gregtech.api.net.GT_Packet_TileEntityCover; import gregtech.api.util.GT_CoverBehavior; import gregtech.api.util.GT_Utility; +import net.minecraft.client.gui.GuiButton; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; import net.minecraftforge.fluids.Fluid; public class GT_Cover_ItemMeter extends GT_CoverBehavior { + + // left bit (normal/invert) + // >> 1: 0=all items, else slot-1 + public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) { int[] tSlots; - if (aCoverVariable < 2) { + if ((aCoverVariable & 0x2) > 0) { tSlots = aTileEntity.getAccessibleSlotsFromSide(aSide); } else { - tSlots = new int[]{aCoverVariable - 2}; + tSlots = new int[]{(aCoverVariable >> 1) - 1}; } int tMax = 0; int tUsed = 0; @@ -26,22 +39,52 @@ public class GT_Cover_ItemMeter tUsed += (tStack.stackSize<<6)/tStack.getMaxStackSize(); } } + + boolean inverted = (aCoverVariable & 0x1)>0; if(tUsed==0)//nothing - aTileEntity.setOutputRedstoneSignal(aSide, (byte)(aCoverVariable == 1 ? 15 : 0)); + aTileEntity.setOutputRedstoneSignal(aSide, (byte)(inverted ? 15 : 0)); else if(tUsed >= tMax)//full - aTileEntity.setOutputRedstoneSignal(aSide, (byte)(aCoverVariable == 1 ? 0 : 15)); + aTileEntity.setOutputRedstoneSignal(aSide, (byte)(inverted ? 0 : 15)); else//1-14 range - aTileEntity.setOutputRedstoneSignal(aSide, (byte)(aCoverVariable == 1 ? 14-((14*tUsed)/tMax) : 1+((14*tUsed)/tMax)) ); + aTileEntity.setOutputRedstoneSignal(aSide, (byte)(inverted ? 14-((14*tUsed)/tMax) : 1+((14*tUsed)/tMax)) ); return aCoverVariable; } public int onCoverScrewdriverclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) { - aCoverVariable = (aCoverVariable + (aPlayer.isSneaking()? -1 : 1)) % (2 + aTileEntity.getSizeInventory()); - switch(aCoverVariable) { - case 0: GT_Utility.sendChatToPlayer(aPlayer, trans("051", "Normal")); break; - case 1: GT_Utility.sendChatToPlayer(aPlayer, trans("052", "Inverted")); break; - default: GT_Utility.sendChatToPlayer(aPlayer, trans("053", "Slot: ") + (aCoverVariable - 2)); break; + if (aPlayer.isSneaking()) { + if ((0x1 & aCoverVariable)>0) { + aCoverVariable = aCoverVariable & ~0x1; + GT_Utility.sendChatToPlayer(aPlayer, trans("NORMAL","Normal")); + } + else { + aCoverVariable = aCoverVariable | 0x1; + GT_Utility.sendChatToPlayer(aPlayer, trans("INVERTED","Inverted")); + } + return aCoverVariable; } + + int val = aCoverVariable >> 1; + int lsb = aCoverVariable & 0x1; + + if (val < 0) + aCoverVariable = lsb; + else + aCoverVariable = ((val + 1) << 1) | lsb; + + if ((aCoverVariable >> 1) > aTileEntity.getSizeInventory()) + aCoverVariable = lsb; + + if ((aCoverVariable >> 1) == 0) + GT_Utility.sendChatToPlayer(aPlayer, trans("053", "Slot: ") + trans("ALL", "All")); + else + GT_Utility.sendChatToPlayer(aPlayer, trans("053", "Slot: ") + ((aCoverVariable >> 1) - 1)); + + //aCoverVariable = (aCoverVariable + (aPlayer.isSneaking()? -1 : 1)) % (aTileEntity.getSizeInventory() + 2); + //switch(aCoverVariable) { + // case 0: GT_Utility.sendChatToPlayer(aPlayer, trans("051", "Normal")); break; + // case 1: GT_Utility.sendChatToPlayer(aPlayer, trans("052", "Inverted")); break; + // default: GT_Utility.sendChatToPlayer(aPlayer, trans("053", "Slot: ") + (aCoverVariable >> 1)); break; + //} return aCoverVariable; } @@ -76,4 +119,186 @@ public class GT_Cover_ItemMeter public int getTickRate(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return 5; } + + /** + * GUI Stuff + */ + + @Override + public boolean hasCoverGUI() { + return true; + } + + @Override + public Object getClientGUI(byte aSide, int aCoverID, int coverData, ICoverable aTileEntity) { + return new GUI(aSide, aCoverID, coverData, aTileEntity); + } + + private class GUI extends GT_GUICover { + private final byte side; + private final int coverID; + private final GT_GuiIconCheckButton button; + private final GT_GuiIntegerTextBox intSlot; + private final GT_GuiFakeItemButton intSlotIcon; + private int coverVariable; + + private final static int startX = 10; + private final static int startY = 25; + private final static int spaceX = 18; + private final static int spaceY = 18; + + private final int maxSlot; + + private final String ALL = trans("ALL", "All"); + private final String INVERTED = trans("INVERTED","Inverted"); + private final String NORMAL = trans("NORMAL","Normal"); + + public GUI(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + super(aTileEntity, 176, 107, GT_Utility.intToStack(aCoverID)); + this.side = aSide; + this.coverID = aCoverID; + this.coverVariable = aCoverVariable; + + button = new GT_GuiIconCheckButton(this, 0, startX + spaceX*0, startY+spaceY*0, GT_GuiIcon.REDSTONE_ON, GT_GuiIcon.REDSTONE_OFF); + + intSlot = new GT_GuiIntegerTextBox(this, 1, startX + spaceX * 0, startY + spaceY * 1 + 2, spaceX * 2+5, 12); + intSlot.setMaxStringLength(6); + + //only shows if opened gui of block sadly, should've used container. + intSlotIcon = new GT_GuiFakeItemButton(this, startX + spaceX * 8-4, startY + spaceY * 1, GT_GuiIcon.SLOT_GRAY); + + if (tile instanceof TileEntity && !super.tile.isDead()) + maxSlot = tile.getSizeInventory() - 1; + else + maxSlot = -1; + + if (maxSlot == -1) + intSlot.setEnabled(false); + } + + @Override + public void drawExtras(int mouseX, int mouseY, float parTicks) { + super.drawExtras(mouseX, mouseY, parTicks); + if ((coverVariable & 0x1) > 0) + this.getFontRenderer().drawString(INVERTED, startX + spaceX*3, 4+startY+spaceY*0, 0xFF555555); + else + this.getFontRenderer().drawString(NORMAL, startX + spaceX*3, 4+startY+spaceY*0, 0xFF555555); + + this.getFontRenderer().drawString(trans("254", "Internal slot#"), startX + spaceX*3, 4+startY+spaceY*1, 0xFF555555); + } + + @Override + protected void onInitGui(int guiLeft, int guiTop, int gui_width, int gui_height) { + update(); + if (intSlot.isEnabled()) + intSlot.setFocused(true); + } + + @Override + public void buttonClicked(GuiButton btn) { + if (isInverted()) + coverVariable = (coverVariable & ~0x1); + else + coverVariable = (coverVariable | 0x1); + + GT_Values.NW.sendToServer(new GT_Packet_TileEntityCover(side, coverID, coverVariable, tile)); + update(); + } + + private void update() { + resetTextBox(intSlot); + button.setChecked(isInverted()); + + int slot = getSlot(); + if (slot < 0) { + intSlotIcon.setItem(null); + return; + } + if (tile instanceof TileEntity && !super.tile.isDead()) { + if (tile.getSizeInventory() >= slot) { + ItemStack item = tile.getStackInSlot(slot); + intSlotIcon.setItem(item); + return; + } + } + intSlotIcon.setItem(null); + } + + @Override + public void onMouseWheel(int x, int y, int delta) { + for (GT_GuiIntegerTextBox box : textBoxes) { + if (box.isFocused()) { + int step = Math.max(1, Math.abs(delta / 120)); + step = (isShiftKeyDown() ? 50 : isCtrlKeyDown() ? 5 : 1) * (delta > 0 ? step : -step); + int val = parseTextBox(box); + + if (val < 0) + val = -1; + + val = val + step; + + if (val < 0) + val = -1; + else if (val > maxSlot ) + val = maxSlot; + + box.setText(val < 0 ? ALL : String.valueOf(val)); + return; + } + } + } + + @Override + public void applyTextBox(GT_GuiIntegerTextBox box) { + int val = parseTextBox(box); + + if (val < 0) + coverVariable = coverVariable & 0x1; + else + coverVariable = ((val+1) << 1) | (coverVariable & 0x1); + + GT_Values.NW.sendToServer(new GT_Packet_TileEntityCover(side, coverID, coverVariable, tile)); + update(); + } + + @Override + public void resetTextBox(GT_GuiIntegerTextBox box) { + box.setText(getSlot() < 0 ? ALL : String.valueOf(getSlot())); + } + + private int parseTextBox(GT_GuiIntegerTextBox box) { + String text = box.getText(); + if (text == null) + return -1; + text = text.trim(); + if (text.startsWith(ALL)) + text = text.substring(ALL.length()); + + if (text.isEmpty()) + return -1; + + int val; + try { + val = Integer.parseInt(text); + } catch (NumberFormatException e) { + return -1; + } + + if (val < 0) + return -1; + else if (maxSlot < val) + return maxSlot; + return val; + } + + private boolean isInverted() { + return ((coverVariable & 0x1) > 0); + } + + private int getSlot() { + if ((coverVariable & ~0x1) == 0) + return -1; + return (coverVariable >> 1) - 1; + } + } } diff --git a/src/main/java/gregtech/common/covers/GT_Cover_LiquidMeter.java b/src/main/java/gregtech/common/covers/GT_Cover_LiquidMeter.java index 5a0bb2e7d2..9ca2f77d62 100644 --- a/src/main/java/gregtech/common/covers/GT_Cover_LiquidMeter.java +++ b/src/main/java/gregtech/common/covers/GT_Cover_LiquidMeter.java @@ -1,8 +1,14 @@ package gregtech.common.covers; +import gregtech.api.enums.GT_Values; +import gregtech.api.gui.GT_GUICover; +import gregtech.api.gui.widgets.GT_GuiIcon; +import gregtech.api.gui.widgets.GT_GuiIconCheckButton; import gregtech.api.interfaces.tileentity.ICoverable; +import gregtech.api.net.GT_Packet_TileEntityCover; import gregtech.api.util.GT_CoverBehavior; import gregtech.api.util.GT_Utility; +import net.minecraft.client.gui.GuiButton; import net.minecraft.entity.player.EntityPlayer; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.Fluid; @@ -42,9 +48,9 @@ public class GT_Cover_LiquidMeter public int onCoverScrewdriverclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) { if (aCoverVariable == 0) { - GT_Utility.sendChatToPlayer(aPlayer, trans("054", "Inverted")); - } else { GT_Utility.sendChatToPlayer(aPlayer, trans("055", "Normal")); + } else { + GT_Utility.sendChatToPlayer(aPlayer, trans("054", "Inverted")); } return aCoverVariable == 0 ? 1 : 0; } @@ -80,4 +86,82 @@ public class GT_Cover_LiquidMeter public int getTickRate(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return 5; } + /** + * GUI Stuff + */ + + @Override + public boolean hasCoverGUI() { + return true; + } + + @Override + public Object getClientGUI(byte aSide, int aCoverID, int coverData, ICoverable aTileEntity) { + return new GUI(aSide, aCoverID, coverData, aTileEntity); + } + + private class GUI extends GT_GUICover { + private final byte side; + private final int coverID; + private int coverVariable; + + private final static int startX = 10; + private final static int startY = 25; + private final static int spaceX = 18; + private final static int spaceY = 18; + + public GUI(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + super(aTileEntity, 176, 107, GT_Utility.intToStack(aCoverID)); + this.side = aSide; + this.coverID = aCoverID; + this.coverVariable = aCoverVariable; + new GT_GuiIconCheckButton(this, 0, startX + spaceX*0, startY+spaceY*0, GT_GuiIcon.REDSTONE_ON, GT_GuiIcon.REDSTONE_OFF); + } + + @Override + public void drawExtras(int mouseX, int mouseY, float parTicks) { + super.drawExtras(mouseX, mouseY, parTicks); + String s2; + if (coverVariable == 0) + s2 = trans("INVERTED","Inverted"); + else + s2 = trans("NORMAL","Normal"); + + this.fontRendererObj.drawString(s2, startX + spaceX*1, 4+startY+spaceY*0, 0xFF555555); + } + + @Override + protected void onInitGui(int guiLeft, int guiTop, int gui_width, int gui_height) { + updateButtons(); + } + + public void buttonClicked(GuiButton btn){ + boolean state = false; + if (btn.id == 0) + state = ((GT_GuiIconCheckButton) btn).isChecked(); + + coverVariable = getNewCoverVariable(btn.id, state); + GT_Values.NW.sendToServer(new GT_Packet_TileEntityCover(side, coverID, coverVariable, tile)); + updateButtons(); + } + + private void updateButtons(){ + GuiButton b; + for (Object o : buttonList) { + b = (GuiButton) o; + if(b.id == 0) + ((GT_GuiIconCheckButton) b).setChecked(coverVariable == 0); + } + } + + private int getNewCoverVariable(int id, boolean buttonState) { + if (id == 0) { + if (buttonState) + return coverVariable | 0x1; + else + return coverVariable & ~0x1; + } + return coverVariable; + } + } } \ No newline at end of file diff --git a/src/main/java/gregtech/common/covers/GT_Cover_NeedMaintainance.java b/src/main/java/gregtech/common/covers/GT_Cover_NeedMaintainance.java index 3316b204dc..43160aa908 100644 --- a/src/main/java/gregtech/common/covers/GT_Cover_NeedMaintainance.java +++ b/src/main/java/gregtech/common/covers/GT_Cover_NeedMaintainance.java @@ -1,12 +1,18 @@ package gregtech.common.covers; +import gregtech.api.enums.GT_Values; +import gregtech.api.gui.GT_GUICover; +import gregtech.api.gui.widgets.GT_GuiIcon; +import gregtech.api.gui.widgets.GT_GuiIconCheckButton; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.ICoverable; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.items.GT_MetaGenerated_Tool; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; +import gregtech.api.net.GT_Packet_TileEntityCover; import gregtech.api.util.GT_CoverBehavior; import gregtech.api.util.GT_Utility; +import net.minecraft.client.gui.GuiButton; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.Fluid; @@ -139,5 +145,119 @@ public class GT_Cover_NeedMaintainance extends GT_CoverBehavior { public int getTickRate(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return 60; } + /** + * GUI Stuff + */ + @Override + public boolean hasCoverGUI() { + return true; + } + + @Override + public Object getClientGUI(byte aSide, int aCoverID, int coverData, ICoverable aTileEntity) { + return new GUI(aSide, aCoverID, coverData, aTileEntity); + } + + private class GUI extends GT_GUICover { + private final byte side; + private final int coverID; + private int coverVariable; + + private final String[] tooltiptext = { + trans("056", "Emit if 1 Maintenance Needed"), + trans("058", "Emit if 2 Maintenance Needed"), + trans("060", "Emit if 3 Maintenance Needed"), + trans("062", "Emit if 4 Maintenance Needed"), + trans("064", "Emit if 5 Maintenance Needed"), + trans("066", "Emit if rotor needs maintenance low accuracy mod"), + trans("068", "Emit if rotor needs maintenance high accuracy mod"), + }; + + private final String[] buttontext = { + trans("247", "1 Issue"), + trans("248", "2 Issues"), + trans("249", "3 Issues"), + trans("250", "4 Issues"), + trans("251", "5 Issues"), + trans("252", "Rotor < 80%"), + trans("253", "Rotor < 100%"), + + trans("INVERTED","Inverted"), + trans("NORMAL","Normal"), + }; + + private final static int startX = 10; + private final static int startY = 25; + private final static int spaceX = 18; + private final static int spaceY = 18; + + public GUI(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + super(aTileEntity, 176, 107, GT_Utility.intToStack(aCoverID)); + this.side = aSide; + this.coverID = aCoverID; + this.coverVariable = aCoverVariable; + + GuiButton b; + b = new GT_GuiIconCheckButton(this, 0, startX + spaceX*0, startY+spaceY*0, GT_GuiIcon.CHECKMARK, null).setTooltipText(tooltiptext[0]); + b = new GT_GuiIconCheckButton(this, 1, startX + spaceX*0, startY+spaceY*1, GT_GuiIcon.CHECKMARK, null).setTooltipText(tooltiptext[1]); + b = new GT_GuiIconCheckButton(this, 2, startX + spaceX*0, startY+spaceY*2, GT_GuiIcon.CHECKMARK, null).setTooltipText(tooltiptext[2]); + b = new GT_GuiIconCheckButton(this, 3, startX + spaceX*0, startY+spaceY*3, GT_GuiIcon.CHECKMARK, null).setTooltipText(tooltiptext[3]); + b = new GT_GuiIconCheckButton(this, 4, startX + spaceX*4 + 4, startY+spaceY*0, GT_GuiIcon.CHECKMARK, null).setTooltipText(tooltiptext[4]); + b = new GT_GuiIconCheckButton(this, 5, startX + spaceX*4 + 4, startY+spaceY*1, GT_GuiIcon.CHECKMARK, null).setTooltipText(tooltiptext[5]); + b = new GT_GuiIconCheckButton(this, 6, startX + spaceX*4 + 4, startY+spaceY*2, GT_GuiIcon.CHECKMARK, null).setTooltipText(tooltiptext[6]); + b = new GT_GuiIconCheckButton(this, 7, startX + spaceX*4 + 4, startY+spaceY*3, GT_GuiIcon.REDSTONE_ON, GT_GuiIcon.REDSTONE_OFF); + } + + + @Override + public void drawExtras(int mouseX, int mouseY, float parTicks) { + super.drawExtras(mouseX, mouseY, parTicks); + + this.fontRendererObj.drawString(buttontext[0],startX + spaceX*1, 4+startY+spaceY*0, 0xFF555555); + this.fontRendererObj.drawString(buttontext[1],startX + spaceX*1, 4+startY+spaceY*1, 0xFF555555); + this.fontRendererObj.drawString(buttontext[2],startX + spaceX*1, 4+startY+spaceY*2, 0xFF555555); + this.fontRendererObj.drawString(buttontext[3],startX + spaceX*1, 4+startY+spaceY*3, 0xFF555555); + this.fontRendererObj.drawString(buttontext[4],startX + spaceX*5 + 4, 4+startY+spaceY*0, 0xFF555555); + this.fontRendererObj.drawString(buttontext[5],startX + spaceX*5 + 4, 4+startY+spaceY*1, 0xFF555555); + this.fontRendererObj.drawString(buttontext[6],startX + spaceX*5 + 4, 4+startY+spaceY*2, 0xFF555555); + // inverted normal + String s2 = ((coverVariable & 0x1) > 0) ? buttontext[7] : buttontext[8]; + this.fontRendererObj.drawString(s2, startX + spaceX*5 + 4, 4+startY+spaceY*3, 0xFF555555); + } + + @Override + protected void onInitGui(int guiLeft, int guiTop, int gui_width, int gui_height) { + updateButtons(); + } + + public void buttonClicked(GuiButton btn){ + if (btn.id == 7 || !isEnabled(btn.id)){ + coverVariable = getNewCoverVariable(btn.id, ((GT_GuiIconCheckButton) btn).isChecked()); + GT_Values.NW.sendToServer(new GT_Packet_TileEntityCover(side, coverID, coverVariable, tile)); + } + updateButtons(); + } + + private void updateButtons(){ + for (Object o : buttonList) + ((GT_GuiIconCheckButton) o).setChecked(isEnabled(((GT_GuiIconCheckButton) o).id)); + } + + private int getNewCoverVariable(int id, boolean checked) { + if (id == 7) { + if (checked) + return coverVariable & ~0x1; + else + return coverVariable | 0x1; + } + return (coverVariable & 0x1) | (id << 1) ; + } + + private boolean isEnabled(int id) { + if (id == 7) + return (coverVariable & 0x1) > 0; + return (coverVariable >>> 1) == id; + } + } } diff --git a/src/main/java/gregtech/common/covers/GT_Cover_PlayerDetector.java b/src/main/java/gregtech/common/covers/GT_Cover_PlayerDetector.java index 9e6c764170..57f52ab42d 100644 --- a/src/main/java/gregtech/common/covers/GT_Cover_PlayerDetector.java +++ b/src/main/java/gregtech/common/covers/GT_Cover_PlayerDetector.java @@ -1,9 +1,15 @@ package gregtech.common.covers; +import gregtech.api.enums.GT_Values; +import gregtech.api.gui.GT_GUICover; +import gregtech.api.gui.widgets.GT_GuiIcon; +import gregtech.api.gui.widgets.GT_GuiIconCheckButton; import gregtech.api.interfaces.tileentity.ICoverable; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.net.GT_Packet_TileEntityCover; import gregtech.api.util.GT_CoverBehavior; import gregtech.api.util.GT_Utility; +import net.minecraft.client.gui.GuiButton; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraftforge.fluids.Fluid; @@ -94,5 +100,79 @@ public class GT_Cover_PlayerDetector extends GT_CoverBehavior { public int getTickRate(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return 20; } + /** + * GUI Stuff + */ + @Override + public boolean hasCoverGUI() { + return true; + } + + @Override + public Object getClientGUI(byte aSide, int aCoverID, int coverData, ICoverable aTileEntity) { + return new GUI(aSide, aCoverID, coverData, aTileEntity); + } + + private class GUI extends GT_GUICover { + private final byte side; + private final int coverID; + private int coverVariable; + + private final static int startX = 10; + private final static int startY = 25; + private final static int spaceX = 18; + private final static int spaceY = 18; + + public GUI(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + super(aTileEntity, 176, 107, GT_Utility.intToStack(aCoverID)); + this.side = aSide; + this.coverID = aCoverID; + this.coverVariable = aCoverVariable; + + new GT_GuiIconCheckButton(this, 0, startX + spaceX*0, startY+spaceY*0, GT_GuiIcon.CHECKMARK, null) + .setTooltipText(trans("068", "Emit if any Player is close")); + new GT_GuiIconCheckButton(this, 1, startX + spaceX*0, startY+spaceY*1, GT_GuiIcon.CHECKMARK, null) + .setTooltipText(trans("069", "Emit if other Player is close")); + new GT_GuiIconCheckButton(this, 2, startX + spaceX*0, startY+spaceY*2, GT_GuiIcon.CHECKMARK, null) + .setTooltipText(trans("070", "Emit if you are close")); + } + + @Override + public void drawExtras(int mouseX, int mouseY, float parTicks) { + super.drawExtras(mouseX, mouseY, parTicks); + this.fontRendererObj.drawString("Any player", + startX + spaceX*1, 4+startY+spaceY*0, 0xFF555555); + this.fontRendererObj.drawString("Other players", + startX + spaceX*1, 4+startY+spaceY*1, 0xFF555555); + this.fontRendererObj.drawString("Only owner", + startX + spaceX*1, 4+startY+spaceY*2, 0xFF555555); + } + + @Override + protected void onInitGui(int guiLeft, int guiTop, int gui_width, int gui_height) { + updateButtons(); + } + + public void buttonClicked(GuiButton btn){ + if (!isEnabled(btn.id)){ + coverVariable = getNewCoverVariable(btn.id, ((GT_GuiIconCheckButton) btn).isChecked()); + GT_Values.NW.sendToServer(new GT_Packet_TileEntityCover(side, coverID, coverVariable, tile)); + } + updateButtons(); + } + + private void updateButtons(){ + for (Object o : buttonList) + ((GT_GuiIconCheckButton) o).setChecked(isEnabled(((GT_GuiIconCheckButton) o).id)); + } + + private int getNewCoverVariable(int id, boolean checked) { + return id; + } + + private boolean isEnabled(int id) { + return coverVariable == id; + } + } } diff --git a/src/main/java/gregtech/common/covers/GT_Cover_Pump.java b/src/main/java/gregtech/common/covers/GT_Cover_Pump.java index 364229f6f8..a6f7d653b9 100644 --- a/src/main/java/gregtech/common/covers/GT_Cover_Pump.java +++ b/src/main/java/gregtech/common/covers/GT_Cover_Pump.java @@ -2,13 +2,13 @@ package gregtech.common.covers; import gregtech.api.enums.GT_Values; import gregtech.api.gui.GT_GUICover; +import gregtech.api.gui.widgets.GT_GuiIcon; import gregtech.api.gui.widgets.GT_GuiIconButton; import gregtech.api.interfaces.tileentity.ICoverable; import gregtech.api.interfaces.tileentity.IMachineProgress; import gregtech.api.net.GT_Packet_TileEntityCover; import gregtech.api.util.GT_CoverBehavior; import gregtech.api.util.GT_Utility; -import gregtech.api.gui.widgets.GT_GuiIcon; import net.minecraft.client.gui.GuiButton; import net.minecraft.entity.player.EntityPlayer; import net.minecraftforge.common.util.ForgeDirection; diff --git a/src/main/java/gregtech/common/covers/GT_Cover_RedstoneWirelessBase.java b/src/main/java/gregtech/common/covers/GT_Cover_RedstoneWirelessBase.java index a359d20aa9..1407311b88 100644 --- a/src/main/java/gregtech/common/covers/GT_Cover_RedstoneWirelessBase.java +++ b/src/main/java/gregtech/common/covers/GT_Cover_RedstoneWirelessBase.java @@ -1,7 +1,12 @@ package gregtech.common.covers; import gregtech.api.GregTech_API; +import gregtech.api.enums.GT_Values; +import gregtech.api.gui.GT_GUICover; +import gregtech.api.gui.widgets.GT_GuiIntegerTextBox; +import gregtech.api.interfaces.IGuiScreen; import gregtech.api.interfaces.tileentity.ICoverable; +import gregtech.api.net.GT_Packet_TileEntityCover; import gregtech.api.util.GT_CoverBehavior; import gregtech.api.util.GT_Utility; import net.minecraft.entity.player.EntityPlayer; @@ -78,4 +83,118 @@ public abstract class GT_Cover_RedstoneWirelessBase public int getTickRate(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return 1; } + /** + * GUI Stuff + */ + + @Override + public boolean hasCoverGUI() { + return true; + } + + @Override + public Object getClientGUI(byte aSide, int aCoverID, int coverData, ICoverable aTileEntity) { + return new GUI(aSide, aCoverID, coverData, aTileEntity); + } + + private class GUI extends GT_GUICover { + private final byte side; + private final int coverID; + private GT_GuiIntegerTextBox fBox; + private int coverVariable; + + private final static int startX = 10; + private final static int startY = 25; + private final static int spaceX = 18; + private final static int spaceY = 18; + + + public GUI(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + super(aTileEntity, 176, 107, GT_Utility.intToStack(aCoverID)); + this.side = aSide; + this.coverID = aCoverID; + this.coverVariable = aCoverVariable; + + fBox = new GT_GuiIntegerTextBoxWithMinus(this, 2,startX + spaceX*0,startY+spaceY*0 + 2, spaceX*4-3,12); + fBox.setText(String.valueOf(coverVariable)); + fBox.setMaxStringLength(12); + + } + + @Override + public void drawExtras(int mouseX, int mouseY, float parTicks) { + super.drawExtras(mouseX, mouseY, parTicks); + this.getFontRenderer().drawString(trans("246","Frequency" ), startX + spaceX*4, 4+startY+spaceY*0, 0xFF555555); + } + + @Override + protected void onInitGui(int guiLeft, int guiTop, int gui_width, int gui_height) { + fBox.setFocused(true); + } + + @Override + public void onMouseWheel(int x, int y, int delta) { + for (GT_GuiIntegerTextBox box : textBoxes){ + if (box.isFocused()) { + int step = Math.max(1, Math.abs(delta / 120)); + step = (isShiftKeyDown() ? 1000 : isCtrlKeyDown() ? 50 : 1) * (delta > 0 ? step : -step); + long i; + try { + i = Long.parseLong(box.getText()); + } catch (NumberFormatException e) { + return; + } + i = i + step; + if (i > Integer.MAX_VALUE) + i = Integer.MAX_VALUE; + else if (i < Integer.MIN_VALUE) + i = Integer.MIN_VALUE; + + box.setText(String.valueOf(i)); + return; + } + } + } + + @Override + public void applyTextBox(GT_GuiIntegerTextBox box) { + long i; + String s = box.getText().trim(); + try { + i = Long.parseLong(s); + } catch (NumberFormatException e) { + resetTextBox(box); + return; + } + + if (i > Integer.MAX_VALUE) + i = Integer.MAX_VALUE; + else if (i < Integer.MIN_VALUE) + i = Integer.MIN_VALUE; + + + coverVariable = (int) i; + fBox.setText(String.valueOf(coverVariable)); + GT_Values.NW.sendToServer(new GT_Packet_TileEntityCover(side, coverID, coverVariable, tile)); + } + + @Override + public void resetTextBox(GT_GuiIntegerTextBox box) { + box.setText(String.valueOf(coverVariable)); + } + + private class GT_GuiIntegerTextBoxWithMinus extends GT_GuiIntegerTextBox { + + public GT_GuiIntegerTextBoxWithMinus(IGuiScreen gui, int id, int x, int y, int width, int height) { + super(gui, id, x, y, width, height); + } + + @Override + public boolean validChar(char c, int key) { + if (getCursorPosition() == 0 && key == 12) // minus first allowed. + return true; + return super.validChar(c, key); + } + } + } } diff --git a/src/main/java/gregtech/common/covers/GT_Cover_Shutter.java b/src/main/java/gregtech/common/covers/GT_Cover_Shutter.java index b43cbe0122..b1c0c5c3af 100644 --- a/src/main/java/gregtech/common/covers/GT_Cover_Shutter.java +++ b/src/main/java/gregtech/common/covers/GT_Cover_Shutter.java @@ -1,9 +1,15 @@ package gregtech.common.covers; +import gregtech.api.enums.GT_Values; +import gregtech.api.gui.GT_GUICover; +import gregtech.api.gui.widgets.GT_GuiIcon; +import gregtech.api.gui.widgets.GT_GuiIconCheckButton; import gregtech.api.interfaces.tileentity.ICoverable; import gregtech.api.interfaces.tileentity.IMachineProgress; +import gregtech.api.net.GT_Packet_TileEntityCover; import gregtech.api.util.GT_CoverBehavior; import gregtech.api.util.GT_Utility; +import net.minecraft.client.gui.GuiButton; import net.minecraft.entity.player.EntityPlayer; import net.minecraftforge.fluids.Fluid; @@ -64,4 +70,80 @@ public class GT_Cover_Shutter public int getTickRate(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return 0; } + + /** + * GUI Stuff + */ + + @Override + public boolean hasCoverGUI() { + return true; + } + + @Override + public Object getClientGUI(byte aSide, int aCoverID, int coverData, ICoverable aTileEntity) { + return new GUI(aSide, aCoverID, coverData, aTileEntity); + } + + private class GUI extends GT_GUICover { + private final byte side; + private final int coverID; + private int coverVariable; + + private final static int startX = 10; + private final static int startY = 25; + private final static int spaceX = 18; + private final static int spaceY = 18; + + public GUI(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + super(aTileEntity, 176, 107, GT_Utility.intToStack(aCoverID)); + this.side = aSide; + this.coverID = aCoverID; + this.coverVariable = aCoverVariable; + + new GT_GuiIconCheckButton(this, 0, startX + spaceX*0, startY+spaceY*0, GT_GuiIcon.CHECKMARK, null); + new GT_GuiIconCheckButton(this, 1, startX + spaceX*0, startY+spaceY*1, GT_GuiIcon.CHECKMARK, null); + new GT_GuiIconCheckButton(this, 2, startX + spaceX*0, startY+spaceY*2, GT_GuiIcon.CHECKMARK, null); + new GT_GuiIconCheckButton(this, 3, startX + spaceX*0, startY+spaceY*3, GT_GuiIcon.CHECKMARK, null); + } + + @Override + public void drawExtras(int mouseX, int mouseY, float parTicks) { + super.drawExtras(mouseX, mouseY, parTicks); + this.fontRendererObj.drawString(trans("082", "Open if work enabled"), + 3+startX + spaceX*1, 4+startY+spaceY*0, 0xFF555555); + this.fontRendererObj.drawString(trans("083", "Open if work disabled"), + 3+startX + spaceX*1, 4+startY+spaceY*1, 0xFF555555); + this.fontRendererObj.drawString(trans("084", "Only Output allowed"), + 3+startX + spaceX*1, 4+startY+spaceY*2, 0xFF555555); + this.fontRendererObj.drawString(trans("085", "Only Input allowed"), + 3+startX + spaceX*1, 4+startY+spaceY*3, 0xFF555555); + } + + @Override + protected void onInitGui(int guiLeft, int guiTop, int gui_width, int gui_height) { + updateButtons(); + } + + public void buttonClicked(GuiButton btn){ + if (!isEnabled(btn.id)){ + coverVariable = getNewCoverVariable(btn.id, ((GT_GuiIconCheckButton) btn).isChecked()); + GT_Values.NW.sendToServer(new GT_Packet_TileEntityCover(side, coverID, coverVariable, tile)); + } + updateButtons(); + } + + private void updateButtons(){ + for (Object o : buttonList) + ((GT_GuiIconCheckButton) o).setChecked(isEnabled(((GT_GuiIconCheckButton) o).id)); + } + + private int getNewCoverVariable(int id, boolean checked) { + return id; + } + + private boolean isEnabled(int id) { + return coverVariable == id; + } + } } diff --git a/src/main/resources/assets/gregtech/textures/gui/GuiButtons.png b/src/main/resources/assets/gregtech/textures/gui/GuiButtons.png index f9b1d69325..54f5230e7a 100644 Binary files a/src/main/resources/assets/gregtech/textures/gui/GuiButtons.png and b/src/main/resources/assets/gregtech/textures/gui/GuiButtons.png differ -- cgit From 8b93a2909d7285f6506a56889929039c41882845 Mon Sep 17 00:00:00 2001 From: bartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com> Date: Tue, 9 Jun 2020 17:55:25 +0200 Subject: MachineBlock runnable toggle Signed-off-by: bartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com> --- build.properties | 2 +- .../api/threads/GT_Runnable_MachineBlockUpdate.java | 21 ++++++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) (limited to 'src/main/java/gregtech/api') diff --git a/build.properties b/build.properties index 3d0a5a60b2..eb5559e8fc 100644 --- a/build.properties +++ b/build.properties @@ -1,6 +1,6 @@ minecraft.version=1.7.10 forge.version=10.13.4.1614-1.7.10 -gt.version=5.09.33.51 +gt.version=5.09.33.52 ae2.version=rv3-beta-22 applecore.version=1.7.10-1.2.1+107.59407 diff --git a/src/main/java/gregtech/api/threads/GT_Runnable_MachineBlockUpdate.java b/src/main/java/gregtech/api/threads/GT_Runnable_MachineBlockUpdate.java index 3d28a94de9..284b37ad09 100644 --- a/src/main/java/gregtech/api/threads/GT_Runnable_MachineBlockUpdate.java +++ b/src/main/java/gregtech/api/threads/GT_Runnable_MachineBlockUpdate.java @@ -36,8 +36,27 @@ public class GT_Runnable_MachineBlockUpdate implements Runnable { this.z = aZ; } + public static boolean isEnabled() { + return isEnabled; + } + + public static void setEnabled() { + GT_Runnable_MachineBlockUpdate.isEnabled = true; + } + + public static void setDisabled() { + GT_Runnable_MachineBlockUpdate.isEnabled = false; + } + + public static void setEnabled(boolean isEnabled) { + GT_Runnable_MachineBlockUpdate.isEnabled = isEnabled; + } + + private static boolean isEnabled = false; + public static void setMachineUpdateValues(World aWorld, int aX, int aY, int aZ) { - EXECUTOR_SERVICE.submit(new GT_Runnable_MachineBlockUpdate(aWorld, aX, aY, aZ)); + if (isEnabled) + EXECUTOR_SERVICE.submit(new GT_Runnable_MachineBlockUpdate(aWorld, aX, aY, aZ)); } public static void initExecutorService() { -- cgit From 3a59a69ff4e4161b1040859420eea414d48b78e4 Mon Sep 17 00:00:00 2001 From: bartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com> Date: Tue, 9 Jun 2020 21:20:32 +0200 Subject: Fixed NEI time value for Replicators Signed-off-by: bartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com> --- src/main/java/gregtech/api/util/GT_Recipe.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/main/java/gregtech/api') diff --git a/src/main/java/gregtech/api/util/GT_Recipe.java b/src/main/java/gregtech/api/util/GT_Recipe.java index db8ecf73b6..2ae67a572a 100644 --- a/src/main/java/gregtech/api/util/GT_Recipe.java +++ b/src/main/java/gregtech/api/util/GT_Recipe.java @@ -23,6 +23,7 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.IFluidContainerItem; import java.util.*; +import java.util.concurrent.atomic.AtomicInteger; import static gregtech.api.enums.GT_Values.*; @@ -1838,15 +1839,19 @@ public class GT_Recipe implements Comparable { } public GT_Recipe addFakeRecipe(boolean aCheckForCollisions, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecial, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) { + AtomicInteger ai = new AtomicInteger(); Optional.ofNullable(GT_OreDictUnificator.getAssociation(aOutputs[0])) .map(itemData -> itemData.mMaterial) .map(materialsStack -> materialsStack.mMaterial) .map(materials -> materials.mElement) .map(Element::getMass) .ifPresent(e -> - aFluidInputs[0].amount = (int) GT_MetaTileEntity_Replicator.cubicFluidMultiplier(e) + { + aFluidInputs[0].amount = (int) GT_MetaTileEntity_Replicator.cubicFluidMultiplier(e); + ai.set(GT_Utility.safeInt(aFluidInputs[0].amount * 512L, 1)); + } ); - return addFakeRecipe(aCheckForCollisions, new GT_Recipe(false, aInputs, aOutputs, aSpecial, null, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue)); + return addFakeRecipe(aCheckForCollisions, new GT_Recipe(false, aInputs, aOutputs, aSpecial, null, aFluidInputs, aFluidOutputs, ai.get(), aEUt, aSpecialValue)); } } -- cgit From 4f728a69836210a6c70993f376a9a66a253c92bb Mon Sep 17 00:00:00 2001 From: DreamMasterXXL Date: Thu, 11 Jun 2020 13:06:20 +0200 Subject: Phtalic Acid name wrong #6232 https://github.com/GTNewHorizons/GT-New-Horizons-Modpack/issues/6232 --- src/main/java/gregtech/api/enums/Materials.java | 2 +- src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/main/java/gregtech/api') diff --git a/src/main/java/gregtech/api/enums/Materials.java b/src/main/java/gregtech/api/enums/Materials.java index 671679b835..636cc55967 100644 --- a/src/main/java/gregtech/api/enums/Materials.java +++ b/src/main/java/gregtech/api/enums/Materials.java @@ -734,7 +734,7 @@ public class Materials implements IColorModulationContainer, ISubTagContainer { public static Materials Nitrochlorobenzene = new MaterialBuilder(592, TextureSet.SET_FLUID , "2-Nitrochlorobenzene").addCell().addFluid().setRGB(143, 181, 26).setColor(Dyes.dyeLime).setMaterialList(new MaterialStack(Carbon, 6), new MaterialStack(Hydrogen, 4), new MaterialStack(Chlorine, 1), new MaterialStack(Nitrogen, 1), new MaterialStack(Oxygen, 2)).constructMaterial(); public static Materials Dimethylbenzene = new MaterialBuilder(593, TextureSet.SET_FLUID , "Dimethylbenzene").addCell().addFluid().setRGB(102, 156, 64).setColor(Dyes.dyeLime).setMaterialList(new MaterialStack(Carbon, 8), new MaterialStack(Hydrogen, 10)).constructMaterial(); public static Materials Potassiumdichromate = new MaterialBuilder(594, TextureSet.SET_DULL , "Potassium Dichromate").setName("PotassiumDichromate").addDustItems().setRGB(255, 8, 127).setColor(Dyes.dyePink).setMaterialList(new MaterialStack(Potassium, 2), new MaterialStack(Chrome, 2), new MaterialStack(Oxygen, 7)).addElectrolyzerRecipe().constructMaterial(); - public static Materials PhthalicAcid = new MaterialBuilder(595, TextureSet.SET_FLUID , "Phtalic Acid").addCell().addFluid().setRGB(54, 133, 71).setColor(Dyes.dyeOrange).setMaterialList(new MaterialStack(Carbon, 8), new MaterialStack(Hydrogen, 6), new MaterialStack(Oxygen, 4)).constructMaterial(); + public static Materials PhthalicAcid = new MaterialBuilder(595, TextureSet.SET_FLUID , "Phthalic Acid").addCell().addFluid().setRGB(54, 133, 71).setColor(Dyes.dyeOrange).setMaterialList(new MaterialStack(Carbon, 8), new MaterialStack(Hydrogen, 6), new MaterialStack(Oxygen, 4)).constructMaterial(); public static Materials Dichlorobenzidine = new MaterialBuilder(596, TextureSet.SET_FLUID , "3,3-Dichlorobenzidine").addCell().addFluid().setRGB(161, 222, 166).setColor(Dyes.dyeOrange).setMaterialList(new MaterialStack(Carbon, 12),new MaterialStack(Hydrogen, 10), new MaterialStack(Nitrogen, 2), new MaterialStack(Chlorine, 2)).constructMaterial(); public static Materials Diaminobenzidin = new MaterialBuilder(597, TextureSet.SET_FLUID , "3,3-Diaminobenzidine").addCell().addFluid().setRGB(51, 125, 89).setColor(Dyes.dyeOrange).setMaterialList(new MaterialStack(Carbon, 12),new MaterialStack(Hydrogen, 14),new MaterialStack(Nitrogen, 4)).constructMaterial(); public static Materials Diphenylisophthalate = new MaterialBuilder(598, TextureSet.SET_FLUID , "Diphenyl Isophtalate").addCell().addFluid().setRGB(36, 110, 87).setColor(Dyes.dyeOrange).setMaterialList(new MaterialStack(Carbon, 20),new MaterialStack(Hydrogen, 20),new MaterialStack(Oxygen, 4)).constructMaterial(); diff --git a/src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java b/src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java index 8a13916fc6..cdbe444248 100644 --- a/src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java +++ b/src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java @@ -3787,7 +3787,7 @@ public class GT_MachineRecipeLoader implements Runnable { GT_Values.RA.addChemicalRecipe(Materials.Methane.getCells(1), GT_Utility.getIntegratedCircuit(11), Materials.Benzene.getFluid(1000), GT_Values.NF,Materials.Dimethylbenzene.getCells(1), 4000, 120); GT_Values.RA.addChemicalRecipe(Materials.Benzene.getCells(1), GT_Utility.getIntegratedCircuit(12), Materials.Methane.getGas(1000), GT_Values.NF, Materials.Dimethylbenzene.getCells(1), 4000, 120); - //Phtalic Acid + //Phthalic Acid GT_Values.RA.addChemicalRecipe(Materials.Dimethylbenzene.getCells(1), Materials.Potassiumdichromate.getDustTiny(1), Materials.Oxygen.getGas(2000), Materials.Water.getFluid(2000),Materials.PhthalicAcid.getCells(1), 100, 1920); GT_Values.RA.addChemicalRecipe(Materials.Dimethylbenzene.getCells(1), Materials.Potassiumdichromate.getDustTiny(1),Materials.Oxygen.getGas(2000), Materials.PhthalicAcid.getFluid(1000),Materials.Water.getCells(2), 100, 1920); GT_Values.RA.addChemicalRecipe(Materials.Oxygen.getCells(2), Materials.Potassiumdichromate.getDustTiny(1),Materials.Dimethylbenzene.getFluid(1000), Materials.Water.getFluid(2000),Materials.PhthalicAcid.getCells(1), ItemList.Cell_Empty.get(1L),100, 1920); -- cgit From 37586579c85d8aec1e0072f107aa43afeac2524a Mon Sep 17 00:00:00 2001 From: DreamMasterXXL Date: Thu, 11 Jun 2020 15:40:07 +0200 Subject: Do shit --- src/main/java/gregtech/api/enums/Materials.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/main/java/gregtech/api') diff --git a/src/main/java/gregtech/api/enums/Materials.java b/src/main/java/gregtech/api/enums/Materials.java index 636cc55967..632de9def3 100644 --- a/src/main/java/gregtech/api/enums/Materials.java +++ b/src/main/java/gregtech/api/enums/Materials.java @@ -734,7 +734,7 @@ public class Materials implements IColorModulationContainer, ISubTagContainer { public static Materials Nitrochlorobenzene = new MaterialBuilder(592, TextureSet.SET_FLUID , "2-Nitrochlorobenzene").addCell().addFluid().setRGB(143, 181, 26).setColor(Dyes.dyeLime).setMaterialList(new MaterialStack(Carbon, 6), new MaterialStack(Hydrogen, 4), new MaterialStack(Chlorine, 1), new MaterialStack(Nitrogen, 1), new MaterialStack(Oxygen, 2)).constructMaterial(); public static Materials Dimethylbenzene = new MaterialBuilder(593, TextureSet.SET_FLUID , "Dimethylbenzene").addCell().addFluid().setRGB(102, 156, 64).setColor(Dyes.dyeLime).setMaterialList(new MaterialStack(Carbon, 8), new MaterialStack(Hydrogen, 10)).constructMaterial(); public static Materials Potassiumdichromate = new MaterialBuilder(594, TextureSet.SET_DULL , "Potassium Dichromate").setName("PotassiumDichromate").addDustItems().setRGB(255, 8, 127).setColor(Dyes.dyePink).setMaterialList(new MaterialStack(Potassium, 2), new MaterialStack(Chrome, 2), new MaterialStack(Oxygen, 7)).addElectrolyzerRecipe().constructMaterial(); - public static Materials PhthalicAcid = new MaterialBuilder(595, TextureSet.SET_FLUID , "Phthalic Acid").addCell().addFluid().setRGB(54, 133, 71).setColor(Dyes.dyeOrange).setMaterialList(new MaterialStack(Carbon, 8), new MaterialStack(Hydrogen, 6), new MaterialStack(Oxygen, 4)).constructMaterial(); + public static Materials PhthalicAcid = new MaterialBuilder(595, TextureSet.SET_FLUID , "Phthalic Acid").setName("PhthalicAcidGT5U").addCell().addFluid().setRGB(54, 133, 71).setColor(Dyes.dyeOrange).setMaterialList(new MaterialStack(Carbon, 8), new MaterialStack(Hydrogen, 6), new MaterialStack(Oxygen, 4)).constructMaterial(); public static Materials Dichlorobenzidine = new MaterialBuilder(596, TextureSet.SET_FLUID , "3,3-Dichlorobenzidine").addCell().addFluid().setRGB(161, 222, 166).setColor(Dyes.dyeOrange).setMaterialList(new MaterialStack(Carbon, 12),new MaterialStack(Hydrogen, 10), new MaterialStack(Nitrogen, 2), new MaterialStack(Chlorine, 2)).constructMaterial(); public static Materials Diaminobenzidin = new MaterialBuilder(597, TextureSet.SET_FLUID , "3,3-Diaminobenzidine").addCell().addFluid().setRGB(51, 125, 89).setColor(Dyes.dyeOrange).setMaterialList(new MaterialStack(Carbon, 12),new MaterialStack(Hydrogen, 14),new MaterialStack(Nitrogen, 4)).constructMaterial(); public static Materials Diphenylisophthalate = new MaterialBuilder(598, TextureSet.SET_FLUID , "Diphenyl Isophtalate").addCell().addFluid().setRGB(36, 110, 87).setColor(Dyes.dyeOrange).setMaterialList(new MaterialStack(Carbon, 20),new MaterialStack(Hydrogen, 20),new MaterialStack(Oxygen, 4)).constructMaterial(); -- cgit From 598339a91c62e04719eda0886d60c12397743653 Mon Sep 17 00:00:00 2001 From: DreamMasterXXL Date: Thu, 11 Jun 2020 19:23:10 +0200 Subject: Phthalic Acid change breaks things #6242 https://github.com/GTNewHorizons/GT-New-Horizons-Modpack/issues/6242 --- src/main/java/gregtech/api/enums/Materials.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/main/java/gregtech/api') diff --git a/src/main/java/gregtech/api/enums/Materials.java b/src/main/java/gregtech/api/enums/Materials.java index 632de9def3..c7df2b219d 100644 --- a/src/main/java/gregtech/api/enums/Materials.java +++ b/src/main/java/gregtech/api/enums/Materials.java @@ -734,7 +734,7 @@ public class Materials implements IColorModulationContainer, ISubTagContainer { public static Materials Nitrochlorobenzene = new MaterialBuilder(592, TextureSet.SET_FLUID , "2-Nitrochlorobenzene").addCell().addFluid().setRGB(143, 181, 26).setColor(Dyes.dyeLime).setMaterialList(new MaterialStack(Carbon, 6), new MaterialStack(Hydrogen, 4), new MaterialStack(Chlorine, 1), new MaterialStack(Nitrogen, 1), new MaterialStack(Oxygen, 2)).constructMaterial(); public static Materials Dimethylbenzene = new MaterialBuilder(593, TextureSet.SET_FLUID , "Dimethylbenzene").addCell().addFluid().setRGB(102, 156, 64).setColor(Dyes.dyeLime).setMaterialList(new MaterialStack(Carbon, 8), new MaterialStack(Hydrogen, 10)).constructMaterial(); public static Materials Potassiumdichromate = new MaterialBuilder(594, TextureSet.SET_DULL , "Potassium Dichromate").setName("PotassiumDichromate").addDustItems().setRGB(255, 8, 127).setColor(Dyes.dyePink).setMaterialList(new MaterialStack(Potassium, 2), new MaterialStack(Chrome, 2), new MaterialStack(Oxygen, 7)).addElectrolyzerRecipe().constructMaterial(); - public static Materials PhthalicAcid = new MaterialBuilder(595, TextureSet.SET_FLUID , "Phthalic Acid").setName("PhthalicAcidGT5U").addCell().addFluid().setRGB(54, 133, 71).setColor(Dyes.dyeOrange).setMaterialList(new MaterialStack(Carbon, 8), new MaterialStack(Hydrogen, 6), new MaterialStack(Oxygen, 4)).constructMaterial(); + public static Materials PhthalicAcid = new MaterialBuilder(595, TextureSet.SET_FLUID , "Phthalic Acid").setName("phtalicacid").addCell().addFluid().setRGB(54, 133, 71).setColor(Dyes.dyeOrange).setMaterialList(new MaterialStack(Carbon, 8), new MaterialStack(Hydrogen, 6), new MaterialStack(Oxygen, 4)).constructMaterial(); public static Materials Dichlorobenzidine = new MaterialBuilder(596, TextureSet.SET_FLUID , "3,3-Dichlorobenzidine").addCell().addFluid().setRGB(161, 222, 166).setColor(Dyes.dyeOrange).setMaterialList(new MaterialStack(Carbon, 12),new MaterialStack(Hydrogen, 10), new MaterialStack(Nitrogen, 2), new MaterialStack(Chlorine, 2)).constructMaterial(); public static Materials Diaminobenzidin = new MaterialBuilder(597, TextureSet.SET_FLUID , "3,3-Diaminobenzidine").addCell().addFluid().setRGB(51, 125, 89).setColor(Dyes.dyeOrange).setMaterialList(new MaterialStack(Carbon, 12),new MaterialStack(Hydrogen, 14),new MaterialStack(Nitrogen, 4)).constructMaterial(); public static Materials Diphenylisophthalate = new MaterialBuilder(598, TextureSet.SET_FLUID , "Diphenyl Isophtalate").addCell().addFluid().setRGB(36, 110, 87).setColor(Dyes.dyeOrange).setMaterialList(new MaterialStack(Carbon, 20),new MaterialStack(Hydrogen, 20),new MaterialStack(Oxygen, 4)).constructMaterial(); -- cgit From c40ad6aecab563410ad68fde6e39bcc0e3121469 Mon Sep 17 00:00:00 2001 From: DreamMasterXXL Date: Thu, 11 Jun 2020 21:09:51 +0200 Subject: Revert "MachineBlock runnable toggle" This reverts commit 8b93a2909d7285f6506a56889929039c41882845. --- build.properties | 2 +- .../api/threads/GT_Runnable_MachineBlockUpdate.java | 21 +-------------------- 2 files changed, 2 insertions(+), 21 deletions(-) (limited to 'src/main/java/gregtech/api') diff --git a/build.properties b/build.properties index eb5559e8fc..3d0a5a60b2 100644 --- a/build.properties +++ b/build.properties @@ -1,6 +1,6 @@ minecraft.version=1.7.10 forge.version=10.13.4.1614-1.7.10 -gt.version=5.09.33.52 +gt.version=5.09.33.51 ae2.version=rv3-beta-22 applecore.version=1.7.10-1.2.1+107.59407 diff --git a/src/main/java/gregtech/api/threads/GT_Runnable_MachineBlockUpdate.java b/src/main/java/gregtech/api/threads/GT_Runnable_MachineBlockUpdate.java index 284b37ad09..3d28a94de9 100644 --- a/src/main/java/gregtech/api/threads/GT_Runnable_MachineBlockUpdate.java +++ b/src/main/java/gregtech/api/threads/GT_Runnable_MachineBlockUpdate.java @@ -36,27 +36,8 @@ public class GT_Runnable_MachineBlockUpdate implements Runnable { this.z = aZ; } - public static boolean isEnabled() { - return isEnabled; - } - - public static void setEnabled() { - GT_Runnable_MachineBlockUpdate.isEnabled = true; - } - - public static void setDisabled() { - GT_Runnable_MachineBlockUpdate.isEnabled = false; - } - - public static void setEnabled(boolean isEnabled) { - GT_Runnable_MachineBlockUpdate.isEnabled = isEnabled; - } - - private static boolean isEnabled = false; - public static void setMachineUpdateValues(World aWorld, int aX, int aY, int aZ) { - if (isEnabled) - EXECUTOR_SERVICE.submit(new GT_Runnable_MachineBlockUpdate(aWorld, aX, aY, aZ)); + EXECUTOR_SERVICE.submit(new GT_Runnable_MachineBlockUpdate(aWorld, aX, aY, aZ)); } public static void initExecutorService() { -- cgit From 780d5dca0ef4614ba724aa275b23e9db28490a3f Mon Sep 17 00:00:00 2001 From: DreamMasterXXL Date: Fri, 12 Jun 2020 10:53:15 +0200 Subject: Revert "Revert "MachineBlock runnable toggle"" This reverts commit c40ad6aecab563410ad68fde6e39bcc0e3121469. --- .../api/threads/GT_Runnable_MachineBlockUpdate.java | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'src/main/java/gregtech/api') diff --git a/src/main/java/gregtech/api/threads/GT_Runnable_MachineBlockUpdate.java b/src/main/java/gregtech/api/threads/GT_Runnable_MachineBlockUpdate.java index 3d28a94de9..284b37ad09 100644 --- a/src/main/java/gregtech/api/threads/GT_Runnable_MachineBlockUpdate.java +++ b/src/main/java/gregtech/api/threads/GT_Runnable_MachineBlockUpdate.java @@ -36,8 +36,27 @@ public class GT_Runnable_MachineBlockUpdate implements Runnable { this.z = aZ; } + public static boolean isEnabled() { + return isEnabled; + } + + public static void setEnabled() { + GT_Runnable_MachineBlockUpdate.isEnabled = true; + } + + public static void setDisabled() { + GT_Runnable_MachineBlockUpdate.isEnabled = false; + } + + public static void setEnabled(boolean isEnabled) { + GT_Runnable_MachineBlockUpdate.isEnabled = isEnabled; + } + + private static boolean isEnabled = false; + public static void setMachineUpdateValues(World aWorld, int aX, int aY, int aZ) { - EXECUTOR_SERVICE.submit(new GT_Runnable_MachineBlockUpdate(aWorld, aX, aY, aZ)); + if (isEnabled) + EXECUTOR_SERVICE.submit(new GT_Runnable_MachineBlockUpdate(aWorld, aX, aY, aZ)); } public static void initExecutorService() { -- cgit From 9bea4eeb1b59740ba417902ed595c7b4ebb62c34 Mon Sep 17 00:00:00 2001 From: DreamMasterXXL Date: Fri, 12 Jun 2020 10:54:15 +0200 Subject: fix --- .../java/gregtech/api/threads/GT_Runnable_MachineBlockUpdate.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/main/java/gregtech/api') diff --git a/src/main/java/gregtech/api/threads/GT_Runnable_MachineBlockUpdate.java b/src/main/java/gregtech/api/threads/GT_Runnable_MachineBlockUpdate.java index 284b37ad09..129c6a7a57 100644 --- a/src/main/java/gregtech/api/threads/GT_Runnable_MachineBlockUpdate.java +++ b/src/main/java/gregtech/api/threads/GT_Runnable_MachineBlockUpdate.java @@ -45,14 +45,14 @@ public class GT_Runnable_MachineBlockUpdate implements Runnable { } public static void setDisabled() { - GT_Runnable_MachineBlockUpdate.isEnabled = false; + GT_Runnable_MachineBlockUpdate.isEnabled = true; } public static void setEnabled(boolean isEnabled) { GT_Runnable_MachineBlockUpdate.isEnabled = isEnabled; } - private static boolean isEnabled = false; + private static boolean isEnabled = true; public static void setMachineUpdateValues(World aWorld, int aX, int aY, int aZ) { if (isEnabled) -- cgit From d0a8a3d73f7ddfaf3c6bfde7d6ceca7dc91f0b93 Mon Sep 17 00:00:00 2001 From: Martin Robertz Date: Fri, 12 Jun 2020 19:46:33 +0200 Subject: fix derp --- src/main/java/gregtech/api/threads/GT_Runnable_MachineBlockUpdate.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/main/java/gregtech/api') diff --git a/src/main/java/gregtech/api/threads/GT_Runnable_MachineBlockUpdate.java b/src/main/java/gregtech/api/threads/GT_Runnable_MachineBlockUpdate.java index 129c6a7a57..ee56a0b0c0 100644 --- a/src/main/java/gregtech/api/threads/GT_Runnable_MachineBlockUpdate.java +++ b/src/main/java/gregtech/api/threads/GT_Runnable_MachineBlockUpdate.java @@ -45,7 +45,7 @@ public class GT_Runnable_MachineBlockUpdate implements Runnable { } public static void setDisabled() { - GT_Runnable_MachineBlockUpdate.isEnabled = true; + GT_Runnable_MachineBlockUpdate.isEnabled = false; } public static void setEnabled(boolean isEnabled) { -- cgit From 3e925efcda289784b291cb4da2d5dc537897d722 Mon Sep 17 00:00:00 2001 From: repo_alt Date: Fri, 17 Jul 2020 03:37:33 +0300 Subject: Transformer not change visually when mode changes to step up https://github.com/GTNewHorizons/GT-New-Horizons-Modpack/issues/5420 --- src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java | 5 +++-- .../implementations/GT_MetaTileEntity_Transformer.java | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'src/main/java/gregtech/api') diff --git a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java index 63c88cfd0a..61e8382777 100644 --- a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java @@ -545,7 +545,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE NW.sendPacketToAllPlayersInRange(worldObj, new GT_Packet_TileEntity(xCoord, (short) yCoord, zCoord, mID, mCoverSides[0], mCoverSides[1], mCoverSides[2], mCoverSides[3], mCoverSides[4], mCoverSides[5], - oTextureData = (byte) ((mFacing & 7) | (mActive ? 8 : 0) | (mRedstone ? 16 : 0) | (mLockUpgrade ? 32 : 0)), + oTextureData = (byte) ((mFacing & 7) | (mActive ? 8 : 0) | (mRedstone ? 16 : 0) | (mLockUpgrade ? 32 : 0) | (mWorks ? 64 : 0) ), oTexturePage = (hasValidMetaTileEntity() && mMetaTileEntity instanceof GT_MetaTileEntity_Hatch) ? ((GT_MetaTileEntity_Hatch) mMetaTileEntity).getTexturePage() : 0, oUpdateData = hasValidMetaTileEntity() ? mMetaTileEntity.getUpdateData() : 0, oRedstoneData = (byte) (((mSidedRedstone[0] > 0) ? 1 : 0) | ((mSidedRedstone[1] > 0) ? 2 : 0) | ((mSidedRedstone[2] > 0) ? 4 : 0) | ((mSidedRedstone[3] > 0) ? 8 : 0) | ((mSidedRedstone[4] > 0) ? 16 : 0) | ((mSidedRedstone[5] > 0) ? 32 : 0)), @@ -556,7 +556,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE } if (mTickTimer > 10) { - byte tData = (byte) ((mFacing & 7) | (mActive ? 8 : 0) | (mRedstone ? 16 : 0) | (mLockUpgrade ? 32 : 0)); + byte tData = (byte) ((mFacing & 7) | (mActive ? 8 : 0) | (mRedstone ? 16 : 0) | (mLockUpgrade ? 32 : 0)| (mWorks ? 64 : 0)); if (tData != oTextureData) sendBlockEvent((byte) 0, oTextureData = tData); tData = mMetaTileEntity.getUpdateData(); @@ -681,6 +681,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE mActive = ((aValue & 8) != 0); mRedstone = ((aValue & 16) != 0); //mLockUpgrade = ((aValue&32) != 0); + mWorks = ((aValue & 64) != 0); break; case 1: if (hasValidMetaTileEntity()) { 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 f33b8aa3d9..711670db08 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 @@ -60,7 +60,7 @@ public class GT_MetaTileEntity_Transformer extends GT_MetaTileEntity_TieredMachi @Override public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { - return mTextures[Math.min(2, aSide) + (aSide == aFacing ? 3 : 0) + (aActive ? 0 : 6)][aColorIndex + 1]; + return mTextures[Math.min(2, aSide) + (aSide == aFacing ? 3 : 0) + (aBaseMetaTileEntity.isAllowedToWork() ? 0 : 6)][aColorIndex + 1]; } @Override -- cgit From df83dc4261da35a7b71bb334d120e7530a556fe2 Mon Sep 17 00:00:00 2001 From: repo_alt Date: Fri, 17 Jul 2020 16:27:12 +0300 Subject: Fixed average EU input/output display https://github.com/GTNewHorizons/GT-New-Horizons-Modpack/issues/5472 --- .../java/gregtech/api/metatileentity/BaseMetaTileEntity.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/main/java/gregtech/api') diff --git a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java index 61e8382777..1b8a7da979 100644 --- a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java @@ -1725,15 +1725,19 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE @Override public long getAverageElectricInput() { long rEU = 0; - for (long tEU : mAverageEUInput) rEU += tEU; - return rEU / mAverageEUInput.length; + for (int i = 0; i < mAverageEUInput.length; ++i) + if (i != mAverageEUInputIndex) + rEU += mAverageEUInput[i]; + return rEU / (mAverageEUInput.length - 1); } @Override public long getAverageElectricOutput() { long rEU = 0; - for (long tEU : mAverageEUOutput) rEU += tEU; - return rEU / mAverageEUOutput.length; + for (int i = 0; i < mAverageEUOutput.length; ++i) + if (i != mAverageEUOutputIndex) + rEU += mAverageEUOutput[i]; + return rEU / (mAverageEUOutput.length - 1); } @Override -- cgit From 8ce4ae8d22f31587c600bf8190cfb88e1a4f2ea2 Mon Sep 17 00:00:00 2001 From: moller21 <42100910+moller21@users.noreply.github.com> Date: Sun, 19 Jul 2020 19:08:59 +0200 Subject: Rework clientside pollution (#302) * Rework clientside pollution * Pollution rework * removed debug --- .../java/gregtech/api/net/GT_Packet_Pollution.java | 31 ++- src/main/java/gregtech/common/GT_Client.java | 49 +---- src/main/java/gregtech/common/GT_Pollution.java | 71 +++++-- src/main/java/gregtech/common/GT_Proxy.java | 5 - .../common/entities/GT_EntityFXPollution.java | 65 ++++++ .../common/misc/GT_ClientPollutionMap.java | 156 ++++++++++++++ src/main/java/gregtech/common/misc/GT_Command.java | 50 +++-- .../common/render/GT_PollutionRenderer.java | 235 +++++++++++++++++++++ 8 files changed, 577 insertions(+), 85 deletions(-) create mode 100644 src/main/java/gregtech/common/entities/GT_EntityFXPollution.java create mode 100644 src/main/java/gregtech/common/misc/GT_ClientPollutionMap.java create mode 100644 src/main/java/gregtech/common/render/GT_PollutionRenderer.java (limited to 'src/main/java/gregtech/api') diff --git a/src/main/java/gregtech/api/net/GT_Packet_Pollution.java b/src/main/java/gregtech/api/net/GT_Packet_Pollution.java index 2c67d74150..7f717c1a47 100644 --- a/src/main/java/gregtech/api/net/GT_Packet_Pollution.java +++ b/src/main/java/gregtech/api/net/GT_Packet_Pollution.java @@ -1,38 +1,47 @@ package gregtech.api.net; import com.google.common.io.ByteArrayDataInput; -import com.google.common.io.ByteArrayDataOutput; -import com.google.common.io.ByteStreams; -import gregtech.common.GT_Pollution; +import gregtech.common.GT_Client; +import net.minecraft.world.ChunkCoordIntPair; import net.minecraft.world.IBlockAccess; +import java.nio.ByteBuffer; + public class GT_Packet_Pollution extends GT_Packet { - private int mPollution; + private ChunkCoordIntPair chunk; + private int pollution; public GT_Packet_Pollution() { super(true); } - public GT_Packet_Pollution(int aPollution) { + public GT_Packet_Pollution(ChunkCoordIntPair chunk, int pollution) { super(false); - mPollution = aPollution; + this.chunk = chunk; + this.pollution = pollution; } @Override public byte[] encode() { - ByteArrayDataOutput tOut = ByteStreams.newDataOutput(4); - tOut.writeInt(mPollution); - return tOut.toByteArray(); + return ByteBuffer + .allocate(12) + .putInt(chunk.chunkXPos) + .putInt(chunk.chunkZPos) + .putInt(pollution) + .array(); } @Override public GT_Packet decode(ByteArrayDataInput aData) { - return new GT_Packet_Pollution(aData.readInt()); + return new GT_Packet_Pollution( + new ChunkCoordIntPair(aData.readInt(), aData.readInt()), + aData.readInt() + ); } @Override public void process(IBlockAccess aWorld) { - GT_Pollution.mPlayerPollution = mPollution; + GT_Client.recieveChunkPollutionPacket(chunk, pollution); } @Override diff --git a/src/main/java/gregtech/common/GT_Client.java b/src/main/java/gregtech/common/GT_Client.java index 51f5e30c28..e528323da4 100644 --- a/src/main/java/gregtech/common/GT_Client.java +++ b/src/main/java/gregtech/common/GT_Client.java @@ -33,6 +33,7 @@ import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.stats.StatFileWriter; import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.ChunkCoordIntPair; import net.minecraft.world.World; import net.minecraftforge.client.event.DrawBlockHighlightEvent; import net.minecraftforge.oredict.OreDictionary; @@ -56,7 +57,8 @@ public class GT_Client extends GT_Proxy }); } - private final HashSet mCapeList = new HashSet(); + private final HashSet mCapeList = new HashSet<>(); + public final static GT_PollutionRenderer mPollutionRenderer = new GT_PollutionRenderer(); private final GT_CapeRenderer mCapeRenderer; private final List mPosR; private final List mPosG; @@ -247,45 +249,6 @@ public class GT_Client extends GT_Proxy drawGrid(aEvent, false); } - //TODO less bad - //@SubscribeEvent - //public void manipulateDensity(EntityViewRenderEvent.FogDensity event) { - // if(GT_Pollution.mPlayerPollution > (GT_Mod.gregtechproxy.mPollutionSmogLimit)){ - // event.density = (0.15f*(Math.min(GT_Pollution.mPlayerPollution/((float)GT_Mod.gregtechproxy.mPollutionSourRainLimit),1.0f)))+0.1f; - // event.setCanceled(true); - // } - //} - - //@SubscribeEvent - //public void manipulateColor(EntityViewRenderEvent.FogColors event) { - // if(GT_Pollution.mPlayerPollution > GT_Mod.gregtechproxy.mPollutionSmogLimit){ - // event.red = 140f/255f; - // event.green = 80f/255f; - // event.blue = 40f/255f; - // } - //} - - //@SubscribeEvent - //public void manipulateGrassColor(BiomeEvent.GetGrassColor event) { - // if(GT_Pollution.mPlayerPollution > GT_Mod.gregtechproxy.mPollutionSmogLimit){ - // event.newColor = 0xD2691E; - // } - //} - - //@SubscribeEvent - //public void manipulateWaterColor(BiomeEvent.GetWaterColor event) { - // if(GT_Pollution.mPlayerPollution > GT_Mod.gregtechproxy.mPollutionSmogLimit){ - // event.newColor = 0x556B2F; - // } - //} - - //@SubscribeEvent - //public void manipulateFoliageColor(BiomeEvent.GetFoliageColor event) { - // if(GT_Pollution.mPlayerPollution > GT_Mod.gregtechproxy.mPollutionSmogLimit){ - // event.newColor = 0xCD853F; - // } - //} - public boolean isServerSide() { return true; } @@ -329,6 +292,8 @@ public class GT_Client extends GT_Proxy mCapeList.add(tName.toLowerCase()); } (new Thread(this)).start(); + + mPollutionRenderer.preLoad(); } public void onLoad() { @@ -730,4 +695,8 @@ public class GT_Client extends GT_Proxy return 0; } } + + public static void recieveChunkPollutionPacket(ChunkCoordIntPair chunk, int pollution) { + mPollutionRenderer.processPacket(chunk, pollution); + } } diff --git a/src/main/java/gregtech/common/GT_Pollution.java b/src/main/java/gregtech/common/GT_Pollution.java index f25c21f86a..be49e57e4a 100644 --- a/src/main/java/gregtech/common/GT_Pollution.java +++ b/src/main/java/gregtech/common/GT_Pollution.java @@ -1,12 +1,18 @@ package gregtech.common; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.TickEvent; +import cpw.mods.fml.common.network.NetworkRegistry; import gregtech.GT_Mod; +import gregtech.api.enums.GT_Values; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.net.GT_Packet_Pollution; import gregtech.api.util.GT_Utility; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.init.Blocks; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; @@ -15,6 +21,8 @@ import net.minecraft.world.ChunkCoordIntPair; import net.minecraft.world.ChunkPosition; import net.minecraft.world.World; import net.minecraft.world.chunk.Chunk; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.world.ChunkWatchEvent; import java.util.ArrayList; import java.util.HashMap; @@ -64,6 +72,10 @@ public class GT_Pollution { private final World aWorld; public static int mPlayerPollution; + private static int POLLUTIONPACKET_MINVALUE = 1000; + + private static GT_PollutionEventHandler EVENT_HANDLER; + public GT_Pollution(World world){ aWorld=world; chunkData=dimensionWiseChunkData.get(aWorld.provider.dimensionId); @@ -72,6 +84,11 @@ public class GT_Pollution { dimensionWiseChunkData.put(world.provider.dimensionId,chunkData); } dimensionWisePollution.put(aWorld.provider.dimensionId,this); + + if (EVENT_HANDLER == null) { + EVENT_HANDLER = new GT_PollutionEventHandler(); + MinecraftForge.EVENT_BUS.register(EVENT_HANDLER); + } } public static void onWorldTick(TickEvent.WorldTickEvent aEvent){//called from proxy @@ -130,7 +147,9 @@ public class GT_Pollution { AxisAlignedBB chunk = AxisAlignedBB.getBoundingBox(actualPos.chunkXPos << 4, 0, actualPos.chunkZPos << 4, (actualPos.chunkXPos << 4) + 16, 256, (actualPos.chunkZPos << 4) + 16); List tEntitys = aWorld.getEntitiesWithinAABB(EntityLivingBase.class, chunk); for (EntityLivingBase tEnt : tEntitys) { - if (!GT_Utility.isWearingFullGasHazmat(tEnt)) { + if (tEnt instanceof EntityPlayerMP && ((EntityPlayerMP) tEnt).capabilities.isCreativeMode) + continue; + if (!(GT_Utility.isWearingFullGasHazmat(tEnt))) { switch (XSTR_INSTANCE.nextInt(3)) { default: tEnt.addPotionEffect(new PotionEffect(Potion.digSlowdown.id, Math.min(tPollution / 1000, 1000), tPollution / 400000)); @@ -148,6 +167,8 @@ public class GT_Pollution { //AxisAlignedBB chunk = AxisAlignedBB.getBoundingBox(tPos.chunkPosX*16, 0, tPos.chunkPosZ*16, tPos.chunkPosX*16+16, 256, tPos.chunkPosZ*16+16); //List tEntitys = aWorld.getEntitiesWithinAABB(EntityLiving.class, chunk); for (EntityLivingBase tEnt : tEntitys) { + if (tEnt instanceof EntityPlayerMP && ((EntityPlayerMP) tEnt).capabilities.isCreativeMode) + continue; if (!GT_Utility.isWearingFullGasHazmat(tEnt)) { switch (XSTR_INSTANCE.nextInt(4)) { default: @@ -178,15 +199,21 @@ public class GT_Pollution { } //Write new pollution to Hashmap !!! chunkData.get(actualPos)[GTPOLLUTION] = tPollution; + + //Send new value to players nearby + if (tPollution > POLLUTIONPACKET_MINVALUE) { + NetworkRegistry.TargetPoint point = new NetworkRegistry.TargetPoint(aWorld.provider.dimensionId, (actualPos.chunkXPos << 4), 64, (actualPos.chunkZPos << 4), 256); + GT_Values.NW.sendToAllAround(new GT_Packet_Pollution(actualPos, tPollution), point); + } } } - + private static void damageBlock(World world, int x, int y, int z, boolean sourRain){ if (world.isRemote) return; Block tBlock = world.getBlock(x, y, z); int tMeta = world.getBlockMetadata(x, y, z); if (tBlock == Blocks.air || tBlock == Blocks.stone || tBlock == Blocks.sand|| tBlock == Blocks.deadbush)return; - + if (tBlock == Blocks.leaves || tBlock == Blocks.leaves2 || tBlock.getMaterial() == Material.leaves) world.setBlockToAir(x, y, z); if (tBlock == Blocks.reeds) { @@ -199,12 +226,12 @@ public class GT_Pollution { tBlock.dropBlockAsItem(world, x, y, z, tMeta, 0); world.setBlockToAir(x, y, z); } - if (tBlock == Blocks.waterlily || tBlock == Blocks.wheat || tBlock == Blocks.cactus || + if (tBlock == Blocks.waterlily || tBlock == Blocks.wheat || tBlock == Blocks.cactus || tBlock.getMaterial() == Material.cactus || tBlock == Blocks.melon_block || tBlock == Blocks.melon_stem) { tBlock.dropBlockAsItem(world, x, y, z, tMeta, 0); world.setBlockToAir(x, y, z); } - if (tBlock == Blocks.red_flower || tBlock == Blocks.yellow_flower || tBlock == Blocks.carrots || + if (tBlock == Blocks.red_flower || tBlock == Blocks.yellow_flower || tBlock == Blocks.carrots || tBlock == Blocks.potatoes || tBlock == Blocks.pumpkin || tBlock == Blocks.pumpkin_stem) { tBlock.dropBlockAsItem(world, x, y, z, tMeta, 0); world.setBlockToAir(x, y, z); @@ -218,12 +245,12 @@ public class GT_Pollution { if (tBlock == Blocks.mossy_cobblestone) world.setBlock(x, y, z, Blocks.cobblestone); if (tBlock == Blocks.grass || tBlock.getMaterial() == Material.grass ) - world.setBlock(x, y, z, Blocks.dirt); + world.setBlock(x, y, z, Blocks.dirt); if(tBlock == Blocks.farmland || tBlock == Blocks.dirt){ - world.setBlock(x, y, z, Blocks.sand); + world.setBlock(x, y, z, Blocks.sand); } - - if(sourRain && world.isRaining() && (tBlock == Blocks.stone || tBlock == Blocks.gravel || tBlock == Blocks.cobblestone) && + + if(sourRain && world.isRaining() && (tBlock == Blocks.stone || tBlock == Blocks.gravel || tBlock == Blocks.cobblestone) && world.getBlock(x, y+1, z) == Blocks.air && world.canBlockSeeTheSky(x, y, z)){ if(tBlock == Blocks.stone){world.setBlock(x, y, z, Blocks.cobblestone); } else if(tBlock == Blocks.cobblestone){world.setBlock(x, y, z, Blocks.gravel); } @@ -256,19 +283,22 @@ public class GT_Pollution { } public static int getPollution(Chunk ch){ - if(!GT_Mod.gregtechproxy.mPollution)return 0; + if(!GT_Mod.gregtechproxy.mPollution) + return 0; HashMap dataMap=dimensionWiseChunkData.get(ch.worldObj.provider.dimensionId); if(dataMap==null || dataMap.get(ch.getChunkCoordIntPair())==null) return 0; return dataMap.get(ch.getChunkCoordIntPair())[GTPOLLUTION]; } - public static int getPollution(ChunkCoordIntPair aCh, int aDim){ - if(!GT_Mod.gregtechproxy.mPollution)return 0; - HashMap dataMap=dimensionWiseChunkData.get(aDim); - if(dataMap==null || dataMap.get(aCh)==null) return 0; + public static int getPollution(ChunkCoordIntPair aCh, int aDim) { + if (!GT_Mod.gregtechproxy.mPollution) + return 0; + HashMap dataMap = dimensionWiseChunkData.get(aDim); + if (dataMap == null || dataMap.get(aCh) == null) + return 0; return dataMap.get(aCh)[GTPOLLUTION]; } - + //Add compatibility with old code @Deprecated /*Don't use it... too weird way of passing position*/ public static void addPollution(World aWorld, ChunkPosition aPos, int aPollution){ @@ -276,4 +306,15 @@ public class GT_Pollution { //is just bad especially when that is both used to store ChunkPos and BlockPos depending on context addPollution(aWorld.getChunkFromBlockCoords(aPos.chunkPosX,aPos.chunkPosZ),aPollution); } + + public class GT_PollutionEventHandler { + @SubscribeEvent + public void chunkWatch(ChunkWatchEvent.Watch event) { + if (chunkData.containsKey(event.chunk)) { + int pollution = chunkData.get(event.chunk)[GTPOLLUTION]; + if (pollution > POLLUTIONPACKET_MINVALUE) + GT_Values.NW.sendToPlayer(new GT_Packet_Pollution(event.chunk, pollution), event.player); + } + } + } } diff --git a/src/main/java/gregtech/common/GT_Proxy.java b/src/main/java/gregtech/common/GT_Proxy.java index 26b971a093..5b762d6d58 100644 --- a/src/main/java/gregtech/common/GT_Proxy.java +++ b/src/main/java/gregtech/common/GT_Proxy.java @@ -1490,11 +1490,6 @@ public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler { aEvent.player.addExhaustion(Math.max(1.0F, tCount / 666.6F)); } } - if (aEvent.player.ticksExisted % 10 == 0) { - int tPollution = 0; - tPollution = GT_Pollution.getPollution(new ChunkCoordIntPair(aEvent.player.chunkCoordX,aEvent.player.chunkCoordZ), aEvent.player.dimension); - if(aEvent.player instanceof EntityPlayerMP)GT_Values.NW.sendToPlayer(new GT_Packet_Pollution(tPollution), (EntityPlayerMP) aEvent.player); - } } } diff --git a/src/main/java/gregtech/common/entities/GT_EntityFXPollution.java b/src/main/java/gregtech/common/entities/GT_EntityFXPollution.java new file mode 100644 index 0000000000..2123313190 --- /dev/null +++ b/src/main/java/gregtech/common/entities/GT_EntityFXPollution.java @@ -0,0 +1,65 @@ +package gregtech.common.entities; + +import cofh.lib.util.helpers.MathHelper; +import net.minecraft.client.particle.EntityFX; +import net.minecraft.world.World; + +import java.util.Random; + +public class GT_EntityFXPollution extends EntityFX { + + public GT_EntityFXPollution(World world, double x, double y, double z) { + super(world, x, y, z,0 ,0 ,0); + + this.particleRed = 0.25F; + this.particleGreen = 0.2F; + this.particleBlue = 0.25F; + + this.motionX *= 0.1D; + this.motionY *= -0.1D; + this.motionZ *= 0.1F; + + Random random = world.rand; + this.motionX += random.nextFloat() * -1.9D * random.nextFloat() * 0.1D; + this.motionY += random.nextFloat() * -0.5D * random.nextFloat() * 0.1D * 5.0D; + this.motionZ += random.nextFloat() * -1.9D * random.nextFloat() * 0.1D; + + this.particleTextureIndexX = 0; + this.particleTextureIndexY = 0; + + this.particleMaxAge = (int)((double)20 / ((double)random.nextFloat() * 0.8D + 0.2D)); + + this.particleScale *= 0.75F; + this.noClip = true; + } + + @Override + public void onUpdate() { + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; + + if (this.particleAge++ >= this.particleMaxAge) { + this.setDead(); + } else { + this.motionY += -5.0E-4D; + this.moveEntity(this.motionX, this.motionY, this.motionZ); + if (this.posY == this.prevPosY) { + this.motionX *= 1.1D; + this.motionZ *= 1.1D; + } + this.motionX *= 0.96D; + this.motionY *= 0.96D; + this.motionZ *= 0.96D; + if (this.onGround) { + this.motionX *= 0.7D; + this.motionZ *= 0.7D; + } + } + } + + + public float getSize(float tickDelta) { + return this.particleScale * MathHelper.clamp(((float)this.particleAge + tickDelta) / (float)this.particleMaxAge * 32.0F, 0.0F, 1.0F); + } +} diff --git a/src/main/java/gregtech/common/misc/GT_ClientPollutionMap.java b/src/main/java/gregtech/common/misc/GT_ClientPollutionMap.java new file mode 100644 index 0000000000..7ba470e412 --- /dev/null +++ b/src/main/java/gregtech/common/misc/GT_ClientPollutionMap.java @@ -0,0 +1,156 @@ +package gregtech.common.misc; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.entity.EntityClientPlayerMP; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.MathHelper; +import org.lwjgl.opengl.GL11; + +public class GT_ClientPollutionMap { + private static final byte RADIUS = 24; + private static final byte DISTANCE_RELOAD_MAP = 5; //When player moved x chunks, shift the map to new center. + private static final byte SIZE = RADIUS*2+1; //Area to keep stored. + + private int x0, z0; + private int dim; + + private boolean initialized = false; + + private static short[][] chunkMatrix; //short because reasons. + + + public GT_ClientPollutionMap(){ } + + public void reset() { + initialized = false; + } + + private void initialize(int playerChunkX, int playerChunkZ, int dimension) { + initialized = true; + chunkMatrix = new short[SIZE][SIZE]; + x0 = playerChunkX; + z0 = playerChunkZ; + dim = dimension; + } + + public void addChunkPollution(int chunkX, int chunkZ, int pollution) { + EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer; + if (player == null || player.worldObj == null) + return; + + int playerXChunk = MathHelper.floor_double(player.posX) >> 4; + int playerZChunk = MathHelper.floor_double(player.posZ) >> 4; //posX/Z seems to be always loaded, + + if (!initialized) { + initialize(playerXChunk, playerZChunk, player.dimension); + } + + if (dim != player.dimension) { + initialize(playerXChunk, playerZChunk, player.dimension); + } + + if (Math.abs(x0 - playerXChunk) > DISTANCE_RELOAD_MAP || Math.abs(z0 - playerZChunk) > DISTANCE_RELOAD_MAP) + shiftCenter(playerXChunk, playerZChunk); + + int relX = chunkX - x0 + RADIUS; + if (relX >= SIZE || relX < 0) //out of bounds + return; + int relZ = chunkZ - z0 + RADIUS; + if (relZ >= SIZE || relZ < 0) //out of bounds + return; + + pollution = pollution/225; + if (pollution > Short.MAX_VALUE) //Sanity + chunkMatrix[relX][relZ] = Short.MAX_VALUE; //Max pollution = 7,3mill + else if (pollution < 0) + chunkMatrix[relX][relZ] = 0; + else + chunkMatrix[relX][relZ] = (short) (pollution); + } + + //xy interpolation, between 4 chunks as corners, unknown treated as 0. + public int getPollution(double fx, double fz) { + if (!initialized) + return 0; + int x = MathHelper.floor_double(fx); + int z = MathHelper.floor_double(fz); + int xDiff = ((x-8) >> 4) - x0; + int zDiff = ((z-8) >> 4) - z0; + + if (xDiff < -RADIUS || zDiff < -RADIUS || xDiff >= RADIUS || zDiff >= RADIUS ) + return 0; + + //coordinates in shifted chunk. + x = (x-8) % 16; + z = (z-8) % 16; + if (x < 0) + x = 16+x; + if (z < 0) + z = 16+z; + + int xi = 15 - x; + int zi = 15 - z; + + //read pollution in 4 corner chunks + int offsetX = RADIUS+xDiff; + int offsetZ = RADIUS+zDiff; + + int c00 = chunkMatrix[offsetX][offsetZ]; + int c10 = chunkMatrix[offsetX+1][offsetZ]; + int c01 = chunkMatrix[offsetX][offsetZ+1]; + int c11 = chunkMatrix[offsetX+1][offsetZ+1]; + + //Is divided by 15*15 but is handled when storing chunk data. + return c00*xi*zi + c10*x*zi + c01*xi*z + c11*x*z; + } + + //shift the matrix to fit new center + private void shiftCenter(int chunkX, int chunkZ) { + int xDiff = chunkX - x0; + int zDiff = chunkZ - z0; + boolean[] allEmpty = new boolean[SIZE]; //skip check z row if its empty. + if (xDiff > 0) + for (byte x = 0; x < SIZE; x++) { + int xOff = x + xDiff; + if (xOff < SIZE) { + chunkMatrix[x] = chunkMatrix[xOff].clone(); + } else { + chunkMatrix[x] = new short[SIZE]; + allEmpty[x] = true; + } + } + else if (xDiff < 0) + for (byte x = SIZE-1; x >= 0; x--) { + int xOff = x + xDiff; + if (xOff > 0) { + chunkMatrix[x] = chunkMatrix[xOff].clone(); + } else { + chunkMatrix[x] = new short[SIZE]; + allEmpty[x] = true; + } + } + + if (zDiff > 0) + for (byte x = 0; x < SIZE; x++) { + if (allEmpty[x]) + continue; + for (int z = 0; z < SIZE ; z++) { + int zOff = z + zDiff; + chunkMatrix[x][z] = (zOff < SIZE) ? chunkMatrix[x][zOff] : 0; + } + } + else if (zDiff < 0) + for (byte x = 0; x < SIZE; x++) { + if (allEmpty[x]) + continue; + for (int z = SIZE-1; z >= 0 ; z--) { + int zOff = z+zDiff; + chunkMatrix[x][z] = (zOff > 0) ? chunkMatrix[x][zOff] : 0; + } + } + + x0 = chunkX; + z0 = chunkZ; + } +} diff --git a/src/main/java/gregtech/common/misc/GT_Command.java b/src/main/java/gregtech/common/misc/GT_Command.java index 66ae7058bc..f3272ee341 100644 --- a/src/main/java/gregtech/common/misc/GT_Command.java +++ b/src/main/java/gregtech/common/misc/GT_Command.java @@ -1,11 +1,15 @@ package gregtech.common.misc; +import gregtech.GT_Mod; import gregtech.api.enums.GT_Values; import gregtech.api.objects.GT_ChunkManager; +import gregtech.common.GT_Pollution; import net.minecraft.command.CommandBase; import net.minecraft.command.ICommandSender; import net.minecraft.command.WrongUsageException; import net.minecraft.util.ChatComponentText; +import net.minecraft.util.ChunkCoordinates; + import java.lang.reflect.Field; import java.util.ArrayList; import java.util.Arrays; @@ -21,10 +25,10 @@ public final class GT_Command extends CommandBase { @Override public String getCommandUsage(ICommandSender sender) { - return "Usage: gt . Valid subcommands are: toggle, chunks."; + return "Usage: gt . Valid subcommands are: toggle, chunks, pollution."; } private void printHelp(ICommandSender sender) { - sender.addChatMessage(new ChatComponentText("Usage: gt ")); + sender.addChatMessage(new ChatComponentText("Usage: gt ")); sender.addChatMessage(new ChatComponentText("\"toggle D1\" - toggles general.Debug (D1)")); sender.addChatMessage(new ChatComponentText("\"toggle D2\" - toggles general.Debug2 (D2)")); sender.addChatMessage(new ChatComponentText("\"toggle debugCleanroom\" - toggles cleanroom debug log")); @@ -38,6 +42,10 @@ public final class GT_Command extends CommandBase { sender.addChatMessage(new ChatComponentText("\"toggle debugStones\" - toggles worldgen stones debug")); sender.addChatMessage(new ChatComponentText("\"toggle debugChunkloaders\" - toggles chunkloaders debug")); sender.addChatMessage(new ChatComponentText("\"chunks\" - print a list of the force loaded chunks")); + sender.addChatMessage(new ChatComponentText( + "\"pollution \" - adds the of the pollution to the current chunk, " + + "\n if isnt specified, will add" + GT_Mod.gregtechproxy.mPollutionSmogLimit + "gibbl." + )); } @Override @@ -45,25 +53,24 @@ public final class GT_Command extends CommandBase { List l = new ArrayList<>(); Stream keywords = Arrays.stream(new String[]{"toggle", "chunks"}); String test = ss.length == 0 ? "" : ss[0].trim(); - if (ss.length == 0 || ss.length == 1 && (test.isEmpty() || keywords.anyMatch(s -> s.startsWith(test)))) { - keywords.forEach(s -> { - if (test.isEmpty() || s.startsWith(test)) - l.add(s); - }); + if (ss.length == 0 || ss.length == 1 && (test.isEmpty() || Stream.of("toggle", "chunks", "pollution").anyMatch(s -> s.startsWith(test)))) { + Stream.of("toggle", "chunks", "pollution") + .filter(s -> test.isEmpty() || s.startsWith(test)) + .forEach(l::add); } else if (test.equals("toggle")) { - String test1 = ss.length == 1 ? "" : ss[1].trim(); - Arrays.stream(new String[]{"D1", "D2", "debugCleanroom", "debugDriller", "debugBlockPump", "debugBlockMiner", "debugWorldGen", "debugEntityCramming", - "debugOrevein", "debugSmallOres", "debugStones", "debugChunkloaders"}).forEach(s -> { - if (test1.isEmpty() || s.startsWith(test1)) - l.add(s); - }); + String test1 = ss[1].trim(); + Stream.of("D1", "D2", "debugCleanroom", "debugDriller", "debugBlockPump", "debugBlockMiner", "debugWorldGen", "debugEntityCramming", + "debugOrevein", "debugSmallOres", "debugStones", "debugChunkloaders") + .filter(s -> test1.isEmpty() || s.startsWith(test1)) + .forEach(l::add); + } return l; } @Override public void processCommand(ICommandSender sender, String[] strings) { - if (strings.length < 1 || (!strings[0].equals("toggle") && !strings[0].equals("chunks"))) { + if (strings.length < 1) { printHelp(sender); return; } @@ -90,6 +97,21 @@ public final class GT_Command extends CommandBase { GT_ChunkManager.printTickets(); sender.addChatMessage(new ChatComponentText("Forced chunks logged to GregTech.log")); break; + case "pollution": { + ChunkCoordinates coordinates = sender.getPlayerCoordinates(); + int amount = (strings.length < 2) ? GT_Mod.gregtechproxy.mPollutionSmogLimit : Integer.parseInt(strings[1]); + GT_Pollution.addPollution(sender + .getEntityWorld() + .getChunkFromBlockCoords( + coordinates.posX, + coordinates.posZ + ), + amount + ); + break; + } + default: + printHelp(sender); } } } diff --git a/src/main/java/gregtech/common/render/GT_PollutionRenderer.java b/src/main/java/gregtech/common/render/GT_PollutionRenderer.java new file mode 100644 index 0000000000..832e93ecf9 --- /dev/null +++ b/src/main/java/gregtech/common/render/GT_PollutionRenderer.java @@ -0,0 +1,235 @@ +package gregtech.common.render; + +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.eventhandler.EventPriority; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.gameevent.TickEvent; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.common.misc.GT_ClientPollutionMap; +import net.minecraft.client.Minecraft; +import net.minecraft.client.entity.EntityClientPlayerMP; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.world.ChunkCoordIntPair; +import net.minecraftforge.client.event.EntityViewRenderEvent; +import net.minecraftforge.event.world.WorldEvent; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class GT_PollutionRenderer { + private static GT_ClientPollutionMap pollutionMap; + private static int playerPollution = 0; + + private static boolean DEBUG = false; + + // PARTICLES_POLLUTION_START + PARTICLES_POLLUTION_END -> Max Particles + private static final int PARTICLES_MAX_NUM = 100; + private static final int PARTICLES_POLLUTION_START = 400000; + private static final int PARTICLES_POLLUTION_END = 3500000; + + private static final int FOG_START_AT_POLLUTION = 400000; + private static final int FOG_MAX_AT_POLLUTION = 7000000; + //jump from linear to exponential fog. x*FOG_MAX_AT_POLLUTION+FOG_START_AT_POLLUTION + private static final double FOG_START_EXP_RATIO = 0.02D; + + private static final float[] fogColor = {0.3f, 0.25f, 0.1f}; + private static final short[] grassColor = {230, 180, 40}; + private static final short[] leavesColor = {160, 80, 15}; + private static final short[] liquidColor = {160, 200, 10}; + private static final short[] foliageColor = {160, 80, 15}; + + //TODO need to soft update some blocks, grass and leaves does more often than liquid it looks like. + + public GT_PollutionRenderer() { + pollutionMap = new GT_ClientPollutionMap(); + } + + public void preLoad() { + net.minecraftforge.common.MinecraftForge.EVENT_BUS.register(this); + FMLCommonHandler.instance().bus().register(this); + } + + public void processPacket(ChunkCoordIntPair chunk, int pollution) { + pollutionMap.addChunkPollution(chunk.chunkXPos, chunk.chunkZPos, pollution); + } + + @SubscribeEvent(priority = EventPriority.HIGH) + public void enteredWorld(WorldEvent.Load event) { + EntityClientPlayerMP p = Minecraft.getMinecraft().thePlayer; + if (!event.world.isRemote || p == null) + return; + pollutionMap.reset(); + } + + private static int color(int color, int pollution, int low, float high, short[] colors) { + if ( pollution < low) + return color; + + int r = (color >> 16) & 0xFF; + int g = (color >> 8) & 0xFF; + int b = color & 0xFF; + float p = (pollution - low) / high; + if (p > 1) p = 1; + float pi = 1 - p; + + r = ((int) (r * pi + p * colors[0])) & 0xFF; + g = ((int) (g * pi + p * colors[1])) & 0xFF; + b = ((int) (b * pi + p * colors[2])) & 0xFF; + + return (r & 0xFF) << 16 | (g & 0xFF) << 8 | b & 0xFF; + } + + // Methods for hodgepodge to color grass / foliage blocks etc. + public static int colorGrass(int oColor, int x, int z) { + return color(oColor, pollutionMap.getPollution(x, z)/1000, 350, 600, grassColor); + } + public static int colorLeaves(int oColor, int x, int z) { + return color(oColor, pollutionMap.getPollution(x, z)/1000, 300, 500, leavesColor); + } + public static int colorLiquid(int oColor, int x, int z) { + return color(oColor, pollutionMap.getPollution(x, z)/1000, 300, 500, liquidColor); + } + public static int colorFoliage(int oColor, int x, int z) { + return color(oColor, pollutionMap.getPollution(x, z)/1000, 300, 500, foliageColor); + } + + @SubscribeEvent(priority = EventPriority.LOW) + public void manipulateColor(EntityViewRenderEvent.FogColors event) { + if (!DEBUG && Minecraft.getMinecraft().thePlayer.capabilities.isCreativeMode) + return; + + if (event.block.getMaterial() == Material.water || + event.block.getMaterial() == Material.lava) + return; + + float x = fogIntensityLastTick > 1 ? 1F : (float) fogIntensityLastTick; + float xi = 1 - x; + + event.red = xi*event.red + x*fogColor[0]; + event.green = xi*event.green + x*fogColor[1]; + event.blue = xi*event.blue + x*fogColor[2]; + } + + private static final int END_MAX_DISTANCE = 192 - 1; + private static double fogIntensityLastTick = 0; + + @SubscribeEvent(priority = EventPriority.LOWEST) + public void renderGTPollutionFog(EntityViewRenderEvent.RenderFogEvent event) { + if ((!DEBUG && Minecraft.getMinecraft().thePlayer.capabilities.isCreativeMode) || + (fogIntensityLastTick <= 0 && fogIntensityLastTick >= FOG_START_EXP_RATIO)) + return; + + if (event.fogMode == 0) { + double v = 1 - fogIntensityLastTick/FOG_START_EXP_RATIO; + //trying to smooth out jump from linear to exponential + GL11.glFogi(GL11.GL_FOG_MODE, GL11.GL_LINEAR); + GL11.glFogf(GL11.GL_FOG_START, (float) ((END_MAX_DISTANCE-20) * 0.75F * v + 20)); + GL11.glFogf(GL11.GL_FOG_END, (float) (END_MAX_DISTANCE * (0.75F + v * 0.25F))); + } + //else if ( event.fogMode < 0) { } + } + + @SubscribeEvent(priority = EventPriority.LOWEST) + public void renderGTPollutionFog(EntityViewRenderEvent.FogDensity event) { + if (!DEBUG && Minecraft.getMinecraft().thePlayer.capabilities.isCreativeMode) + return; + + if (event.entity.isPotionActive(Potion.blindness) || + (fogIntensityLastTick < FOG_START_EXP_RATIO) || + event.block.getMaterial() == Material.water || + event.block.getMaterial() == Material.lava + ) + return; + + GL11.glFogi(GL11.GL_FOG_MODE, GL11.GL_EXP2); + event.density = (float) Math.pow(fogIntensityLastTick - FOG_START_EXP_RATIO, .75F)/5 + 0.01F; + event.setCanceled(true); + } + + private double lastUpdate = 0; + @SubscribeEvent(priority = EventPriority.HIGHEST) + public void onRenderTick(TickEvent.RenderTickEvent event) { + Minecraft mc = Minecraft.getMinecraft(); + if (mc == null) + return; + EntityClientPlayerMP player = mc.thePlayer; + if (player == null) + return; + + if (event.phase == TickEvent.Phase.START) { + if (event.renderTickTime < lastUpdate) + lastUpdate = lastUpdate - 1; + float step = (float) ((event.renderTickTime - lastUpdate) / 50); + lastUpdate = event.renderTickTime; + + float fogIntensity = (playerPollution-FOG_START_AT_POLLUTION)/ (float) FOG_MAX_AT_POLLUTION; + if (fogIntensity > 1) fogIntensity = 1; + else if (fogIntensity < 0) fogIntensity = 0; + + double e = fogIntensity-fogIntensityLastTick; + if (e != 0) { + if (e > 0.2) e = 0.2D; + else if (e < -0.5) e = - 0.5D; + + if (e > 0.001D || e < -0.001D) + fogIntensityLastTick += step *e; + else + fogIntensityLastTick = fogIntensity; + } + } + else if (DEBUG) { + drawPollution("Intensity: " + (fogIntensityLastTick * 10000), 0); + drawPollution("Pollution: " + pollutionMap.getPollution(Minecraft.getMinecraft().thePlayer.lastTickPosX, Minecraft.getMinecraft().thePlayer.lastTickPosZ), 20); + drawPollution("Density: " + ((float)(Math.pow(fogIntensityLastTick - FOG_START_EXP_RATIO, .75F)/5 + 0.01F)* 10000), 40); + } + } + + // Adding dirt particles in the air + @SubscribeEvent(priority = EventPriority.HIGHEST) + public void onClientTick(TickEvent.ClientTickEvent event) { + Minecraft mc = Minecraft.getMinecraft(); + if (mc == null) + return; + EntityClientPlayerMP player = mc.thePlayer; + if (player == null || (player.capabilities.isCreativeMode && !DEBUG)) + return; + + World w = player.worldObj; + playerPollution = pollutionMap.getPollution(player.lastTickPosX, player.lastTickPosZ); + + float intensity = ((float) playerPollution - PARTICLES_POLLUTION_START) / PARTICLES_POLLUTION_END; + if (intensity < 0) + return; + else if (intensity > 1) + intensity = 1; + else + intensity *= intensity; + + int x = MathHelper.floor_double(player.posX); + int y = MathHelper.floor_double(player.posY); + int z = MathHelper.floor_double(player.posZ); + + int numParticles = Math.round(intensity * PARTICLES_MAX_NUM); + + for (int l = 0; l < numParticles; ++l) { + int i1 = x + w.rand.nextInt(16) - w.rand.nextInt(16); + int j1 = y + w.rand.nextInt(16) - w.rand.nextInt(16); + int k1 = z + w.rand.nextInt(16) - w.rand.nextInt(16); + Block block = w.getBlock(i1, j1, k1); + + if (block.getMaterial() == Material.air) { + EntityFX fx = new GT_EntityFXPollution(w, (float) i1 + w.rand.nextFloat(), (float) j1 + w.rand.nextFloat(), (float) k1 + w.rand.nextFloat()); + mc.effectRenderer.addEffect(fx); + } + } + } + + private void drawPollution(String text, int off){ + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + Minecraft.getMinecraft().fontRenderer.drawStringWithShadow(text, 0, off, 0xFFFFFFFF); + GL11.glDisable(GL11.GL_BLEND); + GL11.glPopMatrix(); + } +} -- cgit From b3b3ef4f0961fda0eb7e56bf1cf43cabc0e4f8d6 Mon Sep 17 00:00:00 2001 From: DreamMasterXXL Date: Thu, 23 Jul 2020 19:09:07 +0200 Subject: feat(Gregtech) add Raw DD Portal Block Add Raw Poatal Block for DD Infusion recipe --- src/main/java/gregtech/api/enums/ItemList.java | 1 + src/main/java/gregtech/api/enums/Textures.java | 1 + .../gregtech/common/blocks/GT_Block_Reinforced.java | 4 ++++ .../loaders/postload/GT_MachineRecipeLoader.java | 19 +++++++++++++++++++ .../textures/blocks/iconsets/BLOCK_DEEP_DARK_RAW.png | Bin 0 -> 3218 bytes 5 files changed, 25 insertions(+) create mode 100644 src/main/resources/assets/gregtech/textures/blocks/iconsets/BLOCK_DEEP_DARK_RAW.png (limited to 'src/main/java/gregtech/api') diff --git a/src/main/java/gregtech/api/enums/ItemList.java b/src/main/java/gregtech/api/enums/ItemList.java index cb6e94f5ba..6f7a0567a1 100644 --- a/src/main/java/gregtech/api/enums/ItemList.java +++ b/src/main/java/gregtech/api/enums/ItemList.java @@ -1474,6 +1474,7 @@ public enum ItemList implements IItemContainer { Block_TungstenSteelReinforced, Block_NaquadahPlate, Block_NeutroniumPlate, + Block_BedrockiumCompressed, Honeycomb, Charcoal_Pile, diff --git a/src/main/java/gregtech/api/enums/Textures.java b/src/main/java/gregtech/api/enums/Textures.java index a813eacd57..7b229550ff 100644 --- a/src/main/java/gregtech/api/enums/Textures.java +++ b/src/main/java/gregtech/api/enums/Textures.java @@ -351,6 +351,7 @@ public class Textures { BLOCK_TITANIUMPREIN, BLOCK_NAQUADAHPREIN, BLOCK_NEUTRONIUMPREIN, + BLOCK_DEEP_DARK_RAW, BLOCK_IRREIN, BLOCK_PLASCRETE, BLOCK_TSREIN, diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Reinforced.java b/src/main/java/gregtech/common/blocks/GT_Block_Reinforced.java index 32ce6e78f9..ec31cb212c 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Reinforced.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Reinforced.java @@ -55,6 +55,7 @@ public class GT_Block_Reinforced extends GT_Generic_Block { GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".9.name", "Titanium Reinforced Block"); GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".10.name", "Naquadah Reinforced Block"); GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".11.name", "Neutronium Reinforced Block"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".12.name", "Raw Deep Dark Portal Block"); ItemList.Block_BronzePlate.set(new ItemStack(this.setHardness(60.0f).setResistance(150.0f), 1, 0)); ItemList.Block_IridiumTungstensteel.set(new ItemStack(this.setHardness(400.0f).setResistance(600.0f), 1, 1)); ItemList.Block_Plascrete.set(new ItemStack(this.setHardness(40.0f).setResistance(100.0f), 1, 2)); @@ -67,6 +68,7 @@ public class GT_Block_Reinforced extends GT_Generic_Block { ItemList.Block_TitaniumPlate.set(new ItemStack(this.setHardness(200.0f).setResistance(300.0f), 1, 9)); ItemList.Block_NaquadahPlate.set(new ItemStack(this.setHardness(500.0f).setResistance(1000.0f), 1, 10)); ItemList.Block_NeutroniumPlate.set(new ItemStack(this.setHardness(750.0f).setResistance(2500.0f), 1, 11)); + ItemList.Block_BedrockiumCompressed.set(new ItemStack(this.setHardness(1500.0f).setResistance(5000.0f), 1, 12)); //GT_ModHandler.addCraftingRecipe(ItemList.Block_BronzePlate.get(1L, new Object[0]),GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"hP ", "PBP", " P ", 'P', OrePrefixes.plate.get(Materials.Bronze), 'B', OrePrefixes.stone.get(Materials.GraniteBlack)}); //GT_ModHandler.addCraftingRecipe(ItemList.Block_BronzePlate.get(1L, new Object[0]),GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"hP ", "PBP", " P ", 'P', OrePrefixes.plate.get(Materials.Bronze), 'B', OrePrefixes.stone.get(Materials.GraniteRed)}); //GT_ModHandler.addCraftingRecipe(ItemList.Block_IridiumTungstensteel.get(1L, new Object[0]),GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"hBP", 'P', OrePrefixes.plate.get(Materials.Iridium), 'B', ItemList.Block_TungstenSteelReinforced.get(1L, new Object[0])}); @@ -116,6 +118,8 @@ public class GT_Block_Reinforced extends GT_Generic_Block { return Textures.BlockIcons.BLOCK_NAQUADAHPREIN.getIcon(); case 11: return Textures.BlockIcons.BLOCK_NEUTRONIUMPREIN.getIcon(); + case 12: + return Textures.BlockIcons.BLOCK_DEEP_DARK_RAW.getIcon(); } } return Textures.BlockIcons.MACHINE_CASING_SOLID_STEEL.getIcon(); diff --git a/src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java b/src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java index cdbe444248..a705c3895d 100644 --- a/src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java +++ b/src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java @@ -2752,6 +2752,25 @@ public class GT_MachineRecipeLoader implements Runnable { Materials.ElectrumFlux.getMolten(1152L), }, ItemList.FusionComputer_UV.get(1), 1000, 90000); + GT_Values.RA.addAssemblylineRecipe(GT_ModHandler.getModItem("dreamcraft", "item.HeavyDutyPlateTier8", 1, 0), 576000, new Object[]{ + GT_ModHandler.getModItem("ExtraUtilities", "cobblestone_compressed", 1, 7), + GT_ModHandler.getModItem("IC2", "blockMachine2", 1, 0), + GT_OreDictUnificator.get(OrePrefixes.block, Materials.Infinity, 4L), + new Object[]{OrePrefixes.circuit.get(Materials.Piko), 1}, + new Object[]{OrePrefixes.circuit.get(Materials.Piko), 1}, + new Object[]{OrePrefixes.circuit.get(Materials.Piko), 1}, + new Object[]{OrePrefixes.circuit.get(Materials.Piko), 1}, + GT_ModHandler.getModItem("dreamcraft", "PicoWafer", 32, 0), + ItemList.Robot_Arm_UEV.get(1), + ItemList.Emitter_UEV.get(1), + ItemList.Sensor_UEV.get(1), + ItemList.Field_Generator_UEV.get(1), + }, new FluidStack[]{ + new FluidStack(FluidRegistry.getFluid("oganesson"), 2880), + Materials.Infinity.getMolten(2880L), + Materials.Cheese.getMolten(2880L), + }, ItemList.Block_BedrockiumCompressed.get(1), 10000, 5000000); + if (GregTech_API.sThaumcraftCompat != null) { String tKey = "GT_WOOD_TO_CHARCOAL"; GT_LanguageManager.addStringLocalization(GT_MachineRecipeLoader.aTextTCGTPage + tKey, "You have discovered a way of making charcoal magically instead of using regular ovens for this purpose.

To create charcoal from wood you first need an air-free environment, some vacuus essentia is needed for that, then you need to incinerate the wood using ignis essentia and wait until all the water inside the wood is burned away.

This method however doesn't create creosote oil as byproduct."); diff --git a/src/main/resources/assets/gregtech/textures/blocks/iconsets/BLOCK_DEEP_DARK_RAW.png b/src/main/resources/assets/gregtech/textures/blocks/iconsets/BLOCK_DEEP_DARK_RAW.png new file mode 100644 index 0000000000..ef3500ab97 Binary files /dev/null and b/src/main/resources/assets/gregtech/textures/blocks/iconsets/BLOCK_DEEP_DARK_RAW.png differ -- cgit From 2fc039b454f70ac4422b5683ba005171ae5de97a Mon Sep 17 00:00:00 2001 From: Kalle Date: Wed, 29 Jul 2020 23:10:54 +0300 Subject: Simple optimization to GT_Utility.moveOneItemStack --- src/main/java/gregtech/api/util/GT_Utility.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/main/java/gregtech/api') diff --git a/src/main/java/gregtech/api/util/GT_Utility.java b/src/main/java/gregtech/api/util/GT_Utility.java index f5dfb42a2c..6798b5434d 100644 --- a/src/main/java/gregtech/api/util/GT_Utility.java +++ b/src/main/java/gregtech/api/util/GT_Utility.java @@ -559,10 +559,12 @@ public class GT_Utility { for (int i = 0; i < tGrabSlots.length; i++) { byte tMovedItemCount = 0; - for (int j = 0; j < tPutSlots.length; j++) { - if (listContainsItem(aFilter, aTileEntity1.getStackInSlot(tGrabSlots[i]), true, aInvertFilter)) { - if (isAllowedToTakeFromSlot(aTileEntity1, tGrabSlots[i], aGrabFrom, aTileEntity1.getStackInSlot(tGrabSlots[i]))) { - if (isAllowedToPutIntoSlot((IInventory) aTileEntity2, tPutSlots[j], aPutTo, aTileEntity1.getStackInSlot(tGrabSlots[i]), aMaxTargetStackSize)) { + + if (listContainsItem(aFilter, aTileEntity1.getStackInSlot(tGrabSlots[i]), true, aInvertFilter)) { + ItemStack tGrabStack = aTileEntity1.getStackInSlot(tGrabSlots[i]); + for (int j = 0; j < tPutSlots.length; j++) { + if (isAllowedToTakeFromSlot(aTileEntity1, tGrabSlots[i], aGrabFrom, tGrabStack)) { + if (isAllowedToPutIntoSlot((IInventory) aTileEntity2, tPutSlots[j], aPutTo, tGrabStack, aMaxTargetStackSize)) { tMovedItemCount += moveStackFromSlotAToSlotB(aTileEntity1, (IInventory) aTileEntity2, tGrabSlots[i], tPutSlots[j], aMaxTargetStackSize, aMinTargetStackSize, (byte) (aMaxMoveAtOnce - tMovedItemCount), aMinMoveAtOnce); if (tMovedItemCount >= aMaxMoveAtOnce) { return tMovedItemCount; -- cgit From e703df6cde3a293222702e7c7cc3109c1e5a6289 Mon Sep 17 00:00:00 2001 From: Kalle Date: Fri, 31 Jul 2020 19:05:52 +0300 Subject: Better optimization for moving items between inventories. --- src/main/java/gregtech/api/util/GT_Utility.java | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'src/main/java/gregtech/api') diff --git a/src/main/java/gregtech/api/util/GT_Utility.java b/src/main/java/gregtech/api/util/GT_Utility.java index 6798b5434d..6df77f16bf 100644 --- a/src/main/java/gregtech/api/util/GT_Utility.java +++ b/src/main/java/gregtech/api/util/GT_Utility.java @@ -559,16 +559,14 @@ public class GT_Utility { for (int i = 0; i < tGrabSlots.length; i++) { byte tMovedItemCount = 0; - - if (listContainsItem(aFilter, aTileEntity1.getStackInSlot(tGrabSlots[i]), true, aInvertFilter)) { - ItemStack tGrabStack = aTileEntity1.getStackInSlot(tGrabSlots[i]); - for (int j = 0; j < tPutSlots.length; j++) { - if (isAllowedToTakeFromSlot(aTileEntity1, tGrabSlots[i], aGrabFrom, tGrabStack)) { + ItemStack tGrabStack = aTileEntity1.getStackInSlot(tGrabSlots[i]); + if (listContainsItem(aFilter, tGrabStack, true, aInvertFilter)) { + if (isAllowedToTakeFromSlot(aTileEntity1, tGrabSlots[i], aGrabFrom, tGrabStack)) { + for (int j = 0; j < tPutSlots.length; j++) { if (isAllowedToPutIntoSlot((IInventory) aTileEntity2, tPutSlots[j], aPutTo, tGrabStack, aMaxTargetStackSize)) { - tMovedItemCount += moveStackFromSlotAToSlotB(aTileEntity1, (IInventory) aTileEntity2, tGrabSlots[i], tPutSlots[j], aMaxTargetStackSize, aMinTargetStackSize, (byte) (aMaxMoveAtOnce - tMovedItemCount), aMinMoveAtOnce); + tMovedItemCount += moveStackFromSlotAToSlotB(aTileEntity1, (IInventory) aTileEntity2, tGrabSlots[i], tPutSlots[j], aMaxTargetStackSize, aMinTargetStackSize, (byte) (aMaxMoveAtOnce - tMovedItemCount), aMinMoveAtOnce); if (tMovedItemCount >= aMaxMoveAtOnce) { return tMovedItemCount; - } } } -- cgit From 79b56cc68c9ed7140e9c3804405053c750cf0b42 Mon Sep 17 00:00:00 2001 From: moller21 <42100910+moller21@users.noreply.github.com> Date: Sat, 1 Aug 2020 00:21:49 +0200 Subject: Fix batteries in machines chugging cpu to look up recipes. --- .../gregtech/api/metatileentity/BaseMetaTileEntity.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src/main/java/gregtech/api') diff --git a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java index 1b8a7da979..9e37141bc6 100644 --- a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java @@ -496,15 +496,17 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE for (int i = mMetaTileEntity.dechargerSlotStartIndex(), k = mMetaTileEntity.dechargerSlotCount() + i; i < k; i++) { if (mMetaTileEntity.mInventory[i] != null && getStoredEU() < getEUCapacity()) { dischargeItem(mMetaTileEntity.mInventory[i]); - if(ic2.api.info.Info.itemEnergy.getEnergyValue(mMetaTileEntity.mInventory[i])>0){ + if(ic2.api.info.Info.itemEnergy.getEnergyValue(mMetaTileEntity.mInventory[i])>0){ if((getStoredEU() + ic2.api.info.Info.itemEnergy.getEnergyValue(mMetaTileEntity.mInventory[i])) 0 && mMetaTileEntity.mInventory[i] != null) { chargeItem(mMetaTileEntity.mInventory[i]); - if (mMetaTileEntity.mInventory[i].stackSize <= 0) + if (mMetaTileEntity.mInventory[i].stackSize <= 0) { mMetaTileEntity.mInventory[i] = null; - mInventoryChanged = true; + mInventoryChanged = true; + } } } } -- cgit From 09a56b53995f98535d337aa40c2c75a92a70144c Mon Sep 17 00:00:00 2001 From: moller21 <42100910+moller21@users.noreply.github.com> Date: Sun, 2 Aug 2020 19:21:20 +0200 Subject: Fix full size pipes restrictor textures. --- .../metatileentity/implementations/GT_MetaPipeEntity_Fluid.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/main/java/gregtech/api') 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 0767bd0081..23afaa84f7 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 @@ -104,7 +104,13 @@ public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity { {1, 0, 2, 3}, {1, 0, 2, 3} }; - if (aSide >= 0 && aSide < 6) for (byte i = 0; i < 4; i++) if (isInputDisabledAtSide(sRestrictionArray[aSide][i])) tMask |= 1 << i; + if (aSide >= 0 && aSide < 6) { + for (byte i = 0; i < 4; i++) if (isInputDisabledAtSide(sRestrictionArray[aSide][i])) tMask |= 1 << i; + //Full block size renderer flips side 5 and 2 textures, flip restrictor textures to compensate + if (tThickNess >= 0.99F && (aSide == 5 || aSide == 2)) + if (tMask > 3 && tMask < 12) + tMask = (byte) (tMask ^ 12); + } return new ITexture[]{aConnected ? getBaseTexture(tThickNess, mPipeAmount, mMaterial, aColorIndex) : new GT_RenderedTexture(mMaterial.mIconSet.mTextures[OrePrefixes.pipe.mTextureIndex], Dyes.getModulation(aColorIndex, mMaterial.mRGBa)), getRestrictorTexture(tMask)}; } -- cgit From 3a07aac9a56e9f340954e9092aecf85ba648c405 Mon Sep 17 00:00:00 2001 From: moller21 <42100910+moller21@users.noreply.github.com> Date: Sun, 23 Aug 2020 15:33:20 +0200 Subject: Attempt at improving chest buffers, also slowing down lower tier ones. --- .../implementations/GT_MetaTileEntity_Buffer.java | 23 +++--- .../java/gregtech/api/util/GT_LanguageManager.java | 2 +- src/main/java/gregtech/api/util/GT_Utility.java | 7 +- .../common/gui/GT_Container_ChestBuffer.java | 2 +- .../common/gui/GT_Container_SuperBuffer.java | 2 +- .../automation/GT_MetaTileEntity_ChestBuffer.java | 86 ++++++++++++---------- .../automation/GT_MetaTileEntity_SuperBuffer.java | 3 +- .../automation/GT_MetaTileEntity_TypeFilter.java | 6 +- 8 files changed, 68 insertions(+), 63 deletions(-) (limited to 'src/main/java/gregtech/api') 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 73ab28822a..a57f2440a7 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 @@ -12,7 +12,7 @@ import net.minecraft.nbt.NBTTagCompound; import static gregtech.api.enums.GT_Values.V; public abstract class GT_MetaTileEntity_Buffer extends GT_MetaTileEntity_TieredMachineBlock { - public boolean bOutput = false, bRedstoneIfFull = false, bInvert = false, bStockingMode = true; + public boolean bOutput = false, bRedstoneIfFull = false, bInvert = false, bStockingMode = false; public int mSuccess = 0, mTargetStackSize = 0; public GT_MetaTileEntity_Buffer(int aID, String aName, String aNameRegional, int aTier, int aInvSlotCount, String aDescription) { @@ -257,18 +257,15 @@ public abstract class GT_MetaTileEntity_Buffer extends GT_MetaTileEntity_TieredM } protected void moveItems(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { - if( bStockingMode ) { - int tCost = GT_Utility.moveOneItemStack(aBaseMetaTileEntity, aBaseMetaTileEntity.getTileEntityAtSide(aBaseMetaTileEntity.getBackFacing()), aBaseMetaTileEntity.getBackFacing(), aBaseMetaTileEntity.getFrontFacing(), null, false, mTargetStackSize == 0 ? 64 : (byte) mTargetStackSize, mTargetStackSize == 0 ? 1 : (byte) mTargetStackSize, (byte) 64, (byte) 1); - if (tCost > 0 || aBaseMetaTileEntity.hasInventoryBeenModified()) { - mSuccess = 50; - aBaseMetaTileEntity.decreaseStoredEnergyUnits(Math.abs(tCost), true); - } - } else { - int tCost = GT_Utility.moveOneItemStack(aBaseMetaTileEntity, aBaseMetaTileEntity.getTileEntityAtSide(aBaseMetaTileEntity.getBackFacing()), aBaseMetaTileEntity.getBackFacing(), aBaseMetaTileEntity.getFrontFacing(), null, false, (byte) 64, (byte) 1, mTargetStackSize == 0 ? 64 : (byte) mTargetStackSize, mTargetStackSize == 0 ? 1 : (byte) mTargetStackSize); - if (tCost > 0 || aBaseMetaTileEntity.hasInventoryBeenModified()) { - mSuccess = 50; - aBaseMetaTileEntity.decreaseStoredEnergyUnits(Math.abs(tCost), true); - } + int tCost; + if( bStockingMode ) + tCost = GT_Utility.moveOneItemStack(aBaseMetaTileEntity, aBaseMetaTileEntity.getTileEntityAtSide(aBaseMetaTileEntity.getBackFacing()), aBaseMetaTileEntity.getBackFacing(), aBaseMetaTileEntity.getFrontFacing(), null, false, mTargetStackSize == 0 ? 64 : (byte) mTargetStackSize, (byte) 1, (byte) 64, (byte) 1); + else + tCost = GT_Utility.moveOneItemStack(aBaseMetaTileEntity, aBaseMetaTileEntity.getTileEntityAtSide(aBaseMetaTileEntity.getBackFacing()), aBaseMetaTileEntity.getBackFacing(), aBaseMetaTileEntity.getFrontFacing(), null, false, (byte) 64, (byte) 1, mTargetStackSize == 0 ? 64 : (byte) mTargetStackSize, mTargetStackSize == 0 ? 1 : (byte) mTargetStackSize); + + if (tCost > 0 || aBaseMetaTileEntity.hasInventoryBeenModified()) { + mSuccess = 50; + aBaseMetaTileEntity.decreaseStoredEnergyUnits(Math.abs(tCost), true); } } diff --git a/src/main/java/gregtech/api/util/GT_LanguageManager.java b/src/main/java/gregtech/api/util/GT_LanguageManager.java index b44b6ffa40..c87e0f7417 100644 --- a/src/main/java/gregtech/api/util/GT_LanguageManager.java +++ b/src/main/java/gregtech/api/util/GT_LanguageManager.java @@ -323,7 +323,7 @@ public class GT_LanguageManager { addStringLocalization("Interaction_DESCRIPTION_Index_214", "Connected"); addStringLocalization("Interaction_DESCRIPTION_Index_215", "Disconnected"); addStringLocalization("Interaction_DESCRIPTION_Index_216", "Deprecated Recipe"); - addStringLocalization("Interaction_DESCRIPTION_Index_217", "Stocking mode. Keeps this many items in destination input slots."); + addStringLocalization("Interaction_DESCRIPTION_Index_217", "Stocking mode. Keeps this many items in destination input slots. This mode can be server unfriendly."); addStringLocalization("Interaction_DESCRIPTION_Index_218", "Transfer size mode. Add exactly this many items in destination input slots as long as there is room."); addStringLocalization("Interaction_DESCRIPTION_Index_500", "Fitting: Loose - More Flow"); addStringLocalization("Interaction_DESCRIPTION_Index_501", "Fitting: Tight - More Efficiency"); diff --git a/src/main/java/gregtech/api/util/GT_Utility.java b/src/main/java/gregtech/api/util/GT_Utility.java index 6df77f16bf..a65ed00aed 100644 --- a/src/main/java/gregtech/api/util/GT_Utility.java +++ b/src/main/java/gregtech/api/util/GT_Utility.java @@ -547,7 +547,7 @@ public class GT_Utility { for (int i = 0; i < tGrabSlots.length; i++) tGrabSlots[i] = i; } - if (aTileEntity2 != null && aTileEntity2 instanceof IInventory) { + if (aTileEntity2 instanceof IInventory) { int[] tPutSlots = null; if (aTileEntity2 instanceof ISidedInventory) tPutSlots = ((ISidedInventory) aTileEntity2).getAccessibleSlotsFromSide(aPutTo); @@ -561,13 +561,12 @@ public class GT_Utility { byte tMovedItemCount = 0; ItemStack tGrabStack = aTileEntity1.getStackInSlot(tGrabSlots[i]); if (listContainsItem(aFilter, tGrabStack, true, aInvertFilter)) { - if (isAllowedToTakeFromSlot(aTileEntity1, tGrabSlots[i], aGrabFrom, tGrabStack)) { + if (tGrabStack.stackSize >= aMinMoveAtOnce && isAllowedToTakeFromSlot(aTileEntity1, tGrabSlots[i], aGrabFrom, tGrabStack)) { for (int j = 0; j < tPutSlots.length; j++) { if (isAllowedToPutIntoSlot((IInventory) aTileEntity2, tPutSlots[j], aPutTo, tGrabStack, aMaxTargetStackSize)) { tMovedItemCount += moveStackFromSlotAToSlotB(aTileEntity1, (IInventory) aTileEntity2, tGrabSlots[i], tPutSlots[j], aMaxTargetStackSize, aMinTargetStackSize, (byte) (aMaxMoveAtOnce - tMovedItemCount), aMinMoveAtOnce); - if (tMovedItemCount >= aMaxMoveAtOnce) { + if (tMovedItemCount >= aMaxMoveAtOnce ||(tMovedItemCount > 0 && aMaxTargetStackSize < 64)) return tMovedItemCount; - } } } } diff --git a/src/main/java/gregtech/common/gui/GT_Container_ChestBuffer.java b/src/main/java/gregtech/common/gui/GT_Container_ChestBuffer.java index 016d0889f7..d465134d5e 100644 --- a/src/main/java/gregtech/common/gui/GT_Container_ChestBuffer.java +++ b/src/main/java/gregtech/common/gui/GT_Container_ChestBuffer.java @@ -67,7 +67,7 @@ public class GT_Container_ChestBuffer if (aSlotIndex == 30) { ((GT_MetaTileEntity_ChestBuffer) this.mTileEntity.getMetaTileEntity()).bStockingMode = (!((GT_MetaTileEntity_ChestBuffer) this.mTileEntity.getMetaTileEntity()).bStockingMode); if (((GT_MetaTileEntity_ChestBuffer) this.mTileEntity.getMetaTileEntity()).bStockingMode) { - GT_Utility.sendChatToPlayer(aPlayer, trans("217","Stocking mode. Keeps this many items in destination input slots.")); + GT_Utility.sendChatToPlayer(aPlayer, trans("217","Stocking mode. Keeps this many items in destination input slots. This mode can be server unfriendly.")); } else { GT_Utility.sendChatToPlayer(aPlayer, trans("218", "Transfer size mode. Add exactly this many items in destination input slots as long as there is room.")); } diff --git a/src/main/java/gregtech/common/gui/GT_Container_SuperBuffer.java b/src/main/java/gregtech/common/gui/GT_Container_SuperBuffer.java index 5a59cb5aa9..530e64aa68 100644 --- a/src/main/java/gregtech/common/gui/GT_Container_SuperBuffer.java +++ b/src/main/java/gregtech/common/gui/GT_Container_SuperBuffer.java @@ -62,7 +62,7 @@ public class GT_Container_SuperBuffer if (aSlotIndex == 3) { ((GT_MetaTileEntity_ChestBuffer) this.mTileEntity.getMetaTileEntity()).bStockingMode = (!((GT_MetaTileEntity_ChestBuffer) this.mTileEntity.getMetaTileEntity()).bStockingMode); if (((GT_MetaTileEntity_ChestBuffer) this.mTileEntity.getMetaTileEntity()).bStockingMode) { - GT_Utility.sendChatToPlayer(aPlayer, trans("217","Stocking mode. Keeps this many items in destination input slots.")); + GT_Utility.sendChatToPlayer(aPlayer, trans("217","Stocking mode. Keeps this many items in destination input slots. This mode can be server unfriendly.")); } else { GT_Utility.sendChatToPlayer(aPlayer, trans("218", "Transfer size mode. Add exactly this many items in destination input slots as long as there is room.")); } diff --git a/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_ChestBuffer.java b/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_ChestBuffer.java index d11b1f2f81..6605d4fc35 100644 --- a/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_ChestBuffer.java +++ b/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_ChestBuffer.java @@ -19,11 +19,15 @@ import java.util.Comparator; public class GT_MetaTileEntity_ChestBuffer extends GT_MetaTileEntity_Buffer { + private static final int[] tickRate = {400, 200, 100, 20, 4, 1, 1, 1,1,1}; + + public GT_MetaTileEntity_ChestBuffer(int aID, String aName, String aNameRegional, int aTier) { super(aID, aName, aNameRegional, aTier, 28, new String[]{ "Buffers up to 27 Item Stacks", "Use Screwdriver to regulate output stack size", - "Consumes 3EU per moved Item"}); + "Consumes 3EU per moved Item", + getTickRateDesc(aTier)}); } public GT_MetaTileEntity_ChestBuffer(int aID, String aName, String aNameRegional, int aTier, int aInvSlotCount, String aDescription) { @@ -55,6 +59,8 @@ public class GT_MetaTileEntity_ChestBuffer } protected void moveItems(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { + if (aTimer % tickRate[mTier] > 0) return; + if(aBaseMetaTileEntity.hasInventoryBeenModified()) { fillStacksIntoFirstSlots(); } @@ -64,9 +70,9 @@ public class GT_MetaTileEntity_ChestBuffer super.moveItems(aBaseMetaTileEntity, aTimer); } // mSuccesss is set to 50 on a successful move - if(mSuccess == 50) { - fillStacksIntoFirstSlots(); - } + //if(mSuccess == 50) { + // fillStacksIntoFirstSlots(); + //} if(mSuccess < 0) { mSuccess = 0; } @@ -85,47 +91,32 @@ public class GT_MetaTileEntity_ChestBuffer return 1; Item item1 = o1.getItem(); Item item2 = o2.getItem(); - - // If item1 is a block and item2 isn't, sort item1 before item2 - if (((item1 instanceof ItemBlock)) && (!(item2 instanceof ItemBlock))) { + + if(item1 instanceof ItemBlock) { + if (!(item2 instanceof ItemBlock)) + return -1; // If item1 is a block and item2 isn't, sort item1 before item2 + } else if (item2 instanceof ItemBlock) + return 1; // If item2 is a block and item1 isn't, sort item1 after item2 + + int id1 = Item.getIdFromItem( item1 ); + int id2 = Item.getIdFromItem( item2 ); + if ( id1 < id2 ) { return -1; } - - // If item2 is a block and item1 isn't, sort item1 after item2 - if (((item2 instanceof ItemBlock)) && (!(item1 instanceof ItemBlock))) { + if ( id1 > id2 ) { return 1; } - // If the items are blocks, use the string comparison - if ((item1 instanceof ItemBlock)) { // only need to check one since we did the check above - String displayName1 = o1.getDisplayName(); - String displayName2 = o2.getDisplayName(); - int result = displayName1.compareToIgnoreCase(displayName2); - //GT_FML_LOGGER.info("sorter: " + displayName1 + " " + displayName2 + " " + result); - return result; - } else - { - // Not a block. Use the ID and damage to compare them. - int id1 = Item.getIdFromItem( item1 ); - int id2 = Item.getIdFromItem( item2 ); - if ( id1 < id2 ) { - return -1; - } - if ( id1 > id2 ) { - return 1; - } - // id1 must equal id2, get their damage and compare - id1 = o1.getItemDamage(); - id2 = o2.getItemDamage(); - - if ( id1 < id2 ) { - return -1; - } - if ( id1 > id2 ) { - return 1; - } - return 0; + id1 = o1.getItemDamage(); + id2 = o2.getItemDamage(); + + if ( id1 < id2 ) { + return -1; + } + if ( id1 > id2 ) { + return 1; } + return 0; } }); } @@ -155,4 +146,21 @@ public class GT_MetaTileEntity_ChestBuffer public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { return new GT_GUIContainer_ChestBuffer(aPlayerInventory, aBaseMetaTileEntity); } + + protected static String getTickRateDesc(int tier){ + int tickRate = getTickRate(tier); + String s = ""; + if (tickRate < 20) + s = "1/" + 20/tickRate + " "; + else if (tickRate > 20) { + s = (tickRate / 20) + "th "; + } + return "Moves items every " + s + "second"; + } + + protected static int getTickRate(int tier) { + if (tier > 9) + return 1; + return tickRate[tier]; + } } diff --git a/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_SuperBuffer.java b/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_SuperBuffer.java index 10fcb47d12..da35f17518 100644 --- a/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_SuperBuffer.java +++ b/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_SuperBuffer.java @@ -15,7 +15,8 @@ public class GT_MetaTileEntity_SuperBuffer super(aID, aName, aNameRegional, aTier, 257, new String[]{ "Buffers up to 256 Item Stacks", "Use Screwdriver to regulate output stack size", - "Consumes 1EU per moved Item"}); + "Consumes 1EU per moved Item", + getTickRateDesc(aTier)}); } public GT_MetaTileEntity_SuperBuffer(String aName, int aTier, int aInvSlotCount, String aDescription, ITexture[][][] aTextures) { diff --git a/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_TypeFilter.java b/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_TypeFilter.java index 9b9f782601..6292a769a2 100644 --- a/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_TypeFilter.java +++ b/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_TypeFilter.java @@ -83,17 +83,17 @@ public class GT_MetaTileEntity_TypeFilter } } } - this.mRotationIndex = 0; + this.mRotationIndex = -1; } } public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { super.onPreTick(aBaseMetaTileEntity, aTick); - if ((getBaseMetaTileEntity().isServerSide()) && (aTick % 8L == 0L)) { + if ((getBaseMetaTileEntity().isServerSide()) && ((aTick % 8L == 0L) || mRotationIndex == -1)) { if (this.mPrefix.mPrefixedItems.isEmpty()) { this.mInventory[9] = null; } else { - this.mInventory[9] = GT_Utility.copyAmount(1L, new Object[]{this.mPrefix.mPrefixedItems.get(this.mRotationIndex = (this.mRotationIndex + 1) % this.mPrefix.mPrefixedItems.size())}); + this.mInventory[9] = GT_Utility.copyAmount(1L, this.mPrefix.mPrefixedItems.get(this.mRotationIndex = (this.mRotationIndex + 1) % this.mPrefix.mPrefixedItems.size())); if (this.mInventory[9].getItemDamage() == 32767) { this.mInventory[9].setItemDamage(0); } -- cgit From b403f91a2f38ca5f8ea94732cab4e776e46c4e7a Mon Sep 17 00:00:00 2001 From: moller21 <42100910+moller21@users.noreply.github.com> Date: Sun, 23 Aug 2020 15:47:03 +0200 Subject: Revert stocking mode change. --- .../api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/main/java/gregtech/api') 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 a57f2440a7..645836a801 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 @@ -259,7 +259,7 @@ public abstract class GT_MetaTileEntity_Buffer extends GT_MetaTileEntity_TieredM protected void moveItems(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { int tCost; if( bStockingMode ) - tCost = GT_Utility.moveOneItemStack(aBaseMetaTileEntity, aBaseMetaTileEntity.getTileEntityAtSide(aBaseMetaTileEntity.getBackFacing()), aBaseMetaTileEntity.getBackFacing(), aBaseMetaTileEntity.getFrontFacing(), null, false, mTargetStackSize == 0 ? 64 : (byte) mTargetStackSize, (byte) 1, (byte) 64, (byte) 1); + tCost = GT_Utility.moveOneItemStack(aBaseMetaTileEntity, aBaseMetaTileEntity.getTileEntityAtSide(aBaseMetaTileEntity.getBackFacing()), aBaseMetaTileEntity.getBackFacing(), aBaseMetaTileEntity.getFrontFacing(), null, false, mTargetStackSize == 0 ? 64 : (byte) mTargetStackSize, mTargetStackSize == 0 ? 1 : (byte) mTargetStackSize, (byte) 64, (byte) 1); else tCost = GT_Utility.moveOneItemStack(aBaseMetaTileEntity, aBaseMetaTileEntity.getTileEntityAtSide(aBaseMetaTileEntity.getBackFacing()), aBaseMetaTileEntity.getBackFacing(), aBaseMetaTileEntity.getFrontFacing(), null, false, (byte) 64, (byte) 1, mTargetStackSize == 0 ? 64 : (byte) mTargetStackSize, mTargetStackSize == 0 ? 1 : (byte) mTargetStackSize); -- cgit From 7f78a91208b9c0a61b63ab1bb18c2719fcb54512 Mon Sep 17 00:00:00 2001 From: moller21 <42100910+moller21@users.noreply.github.com> Date: Tue, 25 Aug 2020 22:34:26 +0200 Subject: Redstone, power, strong, signal, cover --- .../api/metatileentity/BaseMetaPipeEntity.java | 31 ++++++++++++++++++---- .../api/metatileentity/BaseMetaTileEntity.java | 25 +++++++++++++++-- 2 files changed, 49 insertions(+), 7 deletions(-) (limited to 'src/main/java/gregtech/api') diff --git a/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java b/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java index b9c8641a86..a14e164b48 100644 --- a/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java +++ b/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java @@ -54,7 +54,7 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE private int[] mCoverSides = new int[]{0, 0, 0, 0, 0, 0}, mCoverData = new int[]{0, 0, 0, 0, 0, 0}, mTimeStatistics = new int[GregTech_API.TICKS_FOR_LAG_AVERAGING]; private boolean mInventoryChanged = false, mWorkUpdate = false, mWorks = true, mNeedsUpdate = true, mNeedsBlockUpdate = true, mSendClientData = false; private boolean mCheckConnections = false; - private byte mColor = 0, oColor = 0, mStrongRedstone = 0, oRedstoneData = 63, oTextureData = 0, oUpdateData = 0, mLagWarningCount = 0; + private byte mColor = 0, oColor = 0, mStrongRedstone = 0, oStrongRedstone = 0, oRedstoneData = 63, oTextureData = 0, oUpdateData = 0, mLagWarningCount = 0; private int oX = 0, oY = 0, oZ = 0, mTimeStatisticsIndex = 0; private short mID = 0; private long mTickTimer = 0; @@ -308,11 +308,31 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE if (tData != oRedstoneData) sendBlockEvent((byte) 3, oRedstoneData = tData); } - if (mNeedsBlockUpdate) { - worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, getBlockOffset(0, 0, 0)); - mNeedsBlockUpdate = false; + if (mNeedsBlockUpdate) { + Block thisBlock = getBlockOffset(0, 0, 0); + for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { + int x1 = xCoord + dir.offsetX, y1 = yCoord + dir.offsetY, z1 = zCoord + dir.offsetZ; + + if (worldObj.blockExists(x1, y1, z1)) { + worldObj.notifyBlockOfNeighborChange(x1, y1, z1, thisBlock); + + //update if it was / is strong powered. + if (((((mStrongRedstone | oStrongRedstone) >>> dir.ordinal()) & 1) != 0 ) && getBlock(x1, y1, z1).isNormalCube()) { + int skipUpdateSide = dir.getOpposite().ordinal(); //Don't update this block. + + for (ForgeDirection dir2 : ForgeDirection.VALID_DIRECTIONS) { + int x2 = x1 + dir2.offsetX, y2 = y1 + dir2.offsetY, z2 = z1 + dir2.offsetZ; + if (dir2.ordinal() != skipUpdateSide && worldObj.blockExists(x2, y2, z2)) + worldObj.notifyBlockOfNeighborChange(x2, y2, z2, thisBlock); + + } + } + } + } + oStrongRedstone = mStrongRedstone; + mNeedsBlockUpdate = false; + } } - } default: tCode = -1; break; @@ -907,6 +927,7 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE mStrongRedstone ^= (1 << tSide); GT_Utility.sendChatToPlayer(aPlayer, trans("091","Redstone Output at Side ") + tSide + trans("092"," set to: ") + ((mStrongRedstone & (1 << tSide)) != 0 ? trans("093","Strong") : trans("094","Weak"))); GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(103), 3.0F, -1, xCoord, yCoord, zCoord); + issueBlockUpdate(); } doEnetUpdate(); return true; diff --git a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java index 9e37141bc6..8ef7ff0f04 100644 --- a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java @@ -62,7 +62,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE private byte[] mSidedRedstone = new byte[]{15, 15, 15, 15, 15, 15}; private int[] mCoverSides = new int[]{0, 0, 0, 0, 0, 0}, mCoverData = new int[]{0, 0, 0, 0, 0, 0}, mTimeStatistics = new int[GregTech_API.TICKS_FOR_LAG_AVERAGING]; private boolean mHasEnoughEnergy = true, mRunningThroughTick = false, mInputDisabled = false, mOutputDisabled = false, mMuffler = false, mLockUpgrade = false, mActive = false, mRedstone = false, mWorkUpdate = false, mSteamConverter = false, mInventoryChanged = false, mWorks = true, mNeedsUpdate = true, mNeedsBlockUpdate = true, mSendClientData = false, oRedstone = false; - private byte mColor = 0, oColor = 0, mStrongRedstone = 0, oRedstoneData = 63, oTextureData = 0, oUpdateData = 0, oTexturePage=0, oLightValueClient = -1, oLightValue = -1, mLightValue = 0, mOtherUpgrades = 0, mFacing = 0, oFacing = 0, mWorkData = 0; + private byte mColor = 0, oColor = 0, oStrongRedstone = 0, mStrongRedstone = 0, oRedstoneData = 63, oTextureData = 0, oUpdateData = 0, oTexturePage=0, oLightValueClient = -1, oLightValue = -1, mLightValue = 0, mOtherUpgrades = 0, mFacing = 0, oFacing = 0, mWorkData = 0; private int mDisplayErrorCode = 0, oX = 0, oY = 0, oZ = 0, mTimeStatisticsIndex = 0, mLagWarningCount = 0; private short mID = 0; public long mTickTimer = 0; @@ -586,7 +586,27 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE } if (mNeedsBlockUpdate) { - worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, getBlockOffset(0, 0, 0)); + Block thisBlock = getBlockOffset(0, 0, 0); + for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { + int x1 = xCoord + dir.offsetX, y1 = yCoord + dir.offsetY, z1 = zCoord + dir.offsetZ; + + if (worldObj.blockExists(x1, y1, z1)) { + worldObj.notifyBlockOfNeighborChange(x1, y1, z1, thisBlock); + + //update if it was / is strong powered. + if (((((mStrongRedstone | oStrongRedstone) >>> dir.ordinal()) & 1) != 0 ) && getBlock(x1, y1, z1).isNormalCube()) { + int skipUpdateSide = dir.getOpposite().ordinal(); //Don't update this block. + + for (ForgeDirection dir2 : ForgeDirection.VALID_DIRECTIONS) { + int x2 = x1 + dir2.offsetX, y2 = y1 + dir2.offsetY, z2 = z1 + dir2.offsetZ; + if (dir2.ordinal() != skipUpdateSide && worldObj.blockExists(x2, y2, z2)) + worldObj.notifyBlockOfNeighborChange(x2, y2, z2, thisBlock); + + } + } + } + } + oStrongRedstone = mStrongRedstone; mNeedsBlockUpdate = false; } } @@ -1399,6 +1419,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE mStrongRedstone ^= (1 << tSide); GT_Utility.sendChatToPlayer(aPlayer, trans("091","Redstone Output at Side ") + tSide + trans("092"," set to: ") + ((mStrongRedstone & (1 << tSide)) != 0 ? trans("093","Strong") : trans("094","Weak"))); GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(103), 3.0F, -1, xCoord, yCoord, zCoord); + issueBlockUpdate(); } doEnetUpdate(); return true; -- cgit From 3a8cc3c906b1c5c6ea0ce8595d07712d22912f88 Mon Sep 17 00:00:00 2001 From: moller21 <42100910+moller21@users.noreply.github.com> Date: Sat, 29 Aug 2020 13:48:36 +0200 Subject: Move neighbour update to BaseTileEntity --- .../api/metatileentity/BaseMetaPipeEntity.java | 21 +-------------------- .../api/metatileentity/BaseMetaTileEntity.java | 21 +-------------------- .../api/metatileentity/BaseTileEntity.java | 22 ++++++++++++++++++++++ 3 files changed, 24 insertions(+), 40 deletions(-) (limited to 'src/main/java/gregtech/api') diff --git a/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java b/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java index a14e164b48..6025e7eb13 100644 --- a/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java +++ b/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java @@ -309,26 +309,7 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE } if (mNeedsBlockUpdate) { - Block thisBlock = getBlockOffset(0, 0, 0); - for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { - int x1 = xCoord + dir.offsetX, y1 = yCoord + dir.offsetY, z1 = zCoord + dir.offsetZ; - - if (worldObj.blockExists(x1, y1, z1)) { - worldObj.notifyBlockOfNeighborChange(x1, y1, z1, thisBlock); - - //update if it was / is strong powered. - if (((((mStrongRedstone | oStrongRedstone) >>> dir.ordinal()) & 1) != 0 ) && getBlock(x1, y1, z1).isNormalCube()) { - int skipUpdateSide = dir.getOpposite().ordinal(); //Don't update this block. - - for (ForgeDirection dir2 : ForgeDirection.VALID_DIRECTIONS) { - int x2 = x1 + dir2.offsetX, y2 = y1 + dir2.offsetY, z2 = z1 + dir2.offsetZ; - if (dir2.ordinal() != skipUpdateSide && worldObj.blockExists(x2, y2, z2)) - worldObj.notifyBlockOfNeighborChange(x2, y2, z2, thisBlock); - - } - } - } - } + updateNeighbours(mStrongRedstone, oStrongRedstone); oStrongRedstone = mStrongRedstone; mNeedsBlockUpdate = false; } diff --git a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java index 8ef7ff0f04..2a275a5354 100644 --- a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java @@ -586,26 +586,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE } if (mNeedsBlockUpdate) { - Block thisBlock = getBlockOffset(0, 0, 0); - for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { - int x1 = xCoord + dir.offsetX, y1 = yCoord + dir.offsetY, z1 = zCoord + dir.offsetZ; - - if (worldObj.blockExists(x1, y1, z1)) { - worldObj.notifyBlockOfNeighborChange(x1, y1, z1, thisBlock); - - //update if it was / is strong powered. - if (((((mStrongRedstone | oStrongRedstone) >>> dir.ordinal()) & 1) != 0 ) && getBlock(x1, y1, z1).isNormalCube()) { - int skipUpdateSide = dir.getOpposite().ordinal(); //Don't update this block. - - for (ForgeDirection dir2 : ForgeDirection.VALID_DIRECTIONS) { - int x2 = x1 + dir2.offsetX, y2 = y1 + dir2.offsetY, z2 = z1 + dir2.offsetZ; - if (dir2.ordinal() != skipUpdateSide && worldObj.blockExists(x2, y2, z2)) - worldObj.notifyBlockOfNeighborChange(x2, y2, z2, thisBlock); - - } - } - } - } + updateNeighbours(mStrongRedstone, oStrongRedstone); oStrongRedstone = mStrongRedstone; mNeedsBlockUpdate = false; } diff --git a/src/main/java/gregtech/api/metatileentity/BaseTileEntity.java b/src/main/java/gregtech/api/metatileentity/BaseTileEntity.java index f5ba784162..dcaa98f120 100644 --- a/src/main/java/gregtech/api/metatileentity/BaseTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/BaseTileEntity.java @@ -427,6 +427,28 @@ public abstract class BaseTileEntity extends TileEntity implements IHasWorldObje clearNullMarkersFromTileEntityBuffer(); } + public void updateNeighbours(int mStrongRedstone, int oStrongRedstone) { + Block thisBlock = getBlockOffset(0, 0, 0); + for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { + int x1 = xCoord + dir.offsetX, y1 = yCoord + dir.offsetY, z1 = zCoord + dir.offsetZ; + + if (worldObj.blockExists(x1, y1, z1)) { + worldObj.notifyBlockOfNeighborChange(x1, y1, z1, thisBlock); + + //update if it was / is strong powered. + if (((((mStrongRedstone | oStrongRedstone) >>> dir.ordinal()) & 1) != 0 ) && getBlock(x1, y1, z1).isNormalCube()) { + int skipUpdateSide = dir.getOpposite().ordinal(); //Don't update this block. Still updates diagonal blocks twice if conditions meet. + + for (ForgeDirection dir2 : ForgeDirection.VALID_DIRECTIONS) { + int x2 = x1 + dir2.offsetX, y2 = y1 + dir2.offsetY, z2 = z1 + dir2.offsetZ; + if (dir2.ordinal() != skipUpdateSide && worldObj.blockExists(x2, y2, z2)) + worldObj.notifyBlockOfNeighborChange(x2, y2, z2, thisBlock); + } + } + } + } + } + @Override public final void sendBlockEvent(byte aID, byte aValue) { NW.sendPacketToAllPlayersInRange(worldObj, new GT_Packet_Block_Event(xCoord, (short) yCoord, zCoord, aID, aValue), xCoord, zCoord); -- cgit From 3cff40ad257cc5ea5bef66920bbcef08996c0ac9 Mon Sep 17 00:00:00 2001 From: repo_alt Date: Wed, 2 Sep 2020 14:10:41 +0300 Subject: GT p2p tunnel was added to AE itself --- build.gradle | 2 +- build.properties | 2 +- src/main/java/gregtech/GT_Mod.java | 3 +-- .../implementations/GT_MetaPipeEntity_Cable.java | 3 --- .../loaders/oreprocessing/ProcessingWire.java | 18 +++++++++++---- .../loaders/postload/GT_AE2EnergyTunnelLoader.java | 27 ---------------------- 6 files changed, 17 insertions(+), 38 deletions(-) delete mode 100644 src/main/java/gregtech/loaders/postload/GT_AE2EnergyTunnelLoader.java (limited to 'src/main/java/gregtech/api') diff --git a/build.gradle b/build.gradle index 2f28009a4c..3ab328be4b 100644 --- a/build.gradle +++ b/build.gradle @@ -112,7 +112,7 @@ dependencies { provided name: "Galacticraft-API", version: config.gc.version, ext: 'jar' provided name: "GalacticraftCore-Dev", version: config.gc.version, ext: 'jar' provided name: 'CoFHLib', version: config.cofhlib.version, ext: 'jar' - provided name: 'CoFHCore', version: config.cofhcore.version, ext: 'jar' +// provided name: 'CoFHCore', version: config.cofhcore.version, ext: 'jar' provided name: 'Railcraft', version: config.railcraft.version, ext: 'jar' provided name: 'IC2NuclearControl', version: config.nc.version, ext: 'jar' diff --git a/build.properties b/build.properties index eb5559e8fc..212a1b999c 100644 --- a/build.properties +++ b/build.properties @@ -1,6 +1,6 @@ minecraft.version=1.7.10 forge.version=10.13.4.1614-1.7.10 -gt.version=5.09.33.52 +gt.version=5.09.33.53 ae2.version=rv3-beta-22 applecore.version=1.7.10-1.2.1+107.59407 diff --git a/src/main/java/gregtech/GT_Mod.java b/src/main/java/gregtech/GT_Mod.java index e4fedf1fa1..27932b98c2 100644 --- a/src/main/java/gregtech/GT_Mod.java +++ b/src/main/java/gregtech/GT_Mod.java @@ -767,8 +767,7 @@ public class GT_Mod implements IGT_Mod { new GT_CropLoader().run(); new GT_Worldgenloader().run(); new GT_CoverLoader().run(); - new GT_AE2EnergyTunnelLoader().run(); - + LoadArmorComponents.init(); GT_RecipeRegistrator.registerUsagesForMaterials(null, false, new ItemStack(Blocks.planks, 1), new ItemStack(Blocks.cobblestone, 1), new ItemStack(Blocks.stone, 1), new ItemStack(Items.leather, 1)); 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 3373b142c4..02d6752bdd 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 @@ -24,7 +24,6 @@ import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_Utility; import gregtech.common.GT_Client; import gregtech.common.covers.GT_Cover_SolarPanel; -import gregtech.loaders.postload.PartP2PGTPower; import ic2.api.energy.EnergyNet; import ic2.api.energy.tile.IEnergyEmitter; import ic2.api.energy.tile.IEnergySink; @@ -423,8 +422,6 @@ public class GT_MetaPipeEntity_Cable extends MetaPipeEntity implements IMetaTile // AE2-p2p Compat if (GT_Mod.gregtechproxy.mAE2Integration) { - if (tTileEntity instanceof IEnergySource && tTileEntity instanceof IPartHost && ((IPartHost)tTileEntity).getPart(tDir) instanceof PartP2PGTPower && ((IEnergySource) tTileEntity).emitsEnergyTo((TileEntity) baseMetaTile, tDir)) - return true; if (tTileEntity instanceof appeng.tile.powersink.IC2 && ((appeng.tile.powersink.IC2)tTileEntity).acceptsEnergyFrom((TileEntity)baseMetaTile, tDir)) return true; } diff --git a/src/main/java/gregtech/loaders/oreprocessing/ProcessingWire.java b/src/main/java/gregtech/loaders/oreprocessing/ProcessingWire.java index 7e54fdb279..63f4abcf65 100644 --- a/src/main/java/gregtech/loaders/oreprocessing/ProcessingWire.java +++ b/src/main/java/gregtech/loaders/oreprocessing/ProcessingWire.java @@ -18,7 +18,7 @@ public class ProcessingWire implements gregtech.api.interfaces.IOreRecipeRegistr private Materials[] dielectrics = {Materials.PolyvinylChloride, Materials.Polydimethylsiloxane}; private Materials[] rubbers = {Materials.Rubber, Materials.StyreneButadieneRubber, Materials.Silicone}; private Materials[] syntheticRubbers = {Materials.StyreneButadieneRubber, Materials.Silicone}; - + static private TunnelType tt = TunnelType.ME; public ProcessingWire() { OrePrefixes.wireGt01.add(this); OrePrefixes.wireGt02.add(this); @@ -29,6 +29,16 @@ public class ProcessingWire implements gregtech.api.interfaces.IOreRecipeRegistr } public void registerOre(OrePrefixes aPrefix, Materials aMaterial, String aOreDictName, String aModName, ItemStack aStack) { + if (GT_Mod.gregtechproxy.mAE2Integration) { + if (tt == TunnelType.ME) { + try { + tt = TunnelType.valueOf("GT_POWER"); + } catch (IllegalArgumentException ignored) { + tt = TunnelType.IC2_POWER; + } + } + } + int cableWidth; OrePrefixes correspondingCable; switch (aPrefix) { @@ -83,7 +93,7 @@ public class ProcessingWire implements gregtech.api.interfaces.IOreRecipeRegistr GT_ModHandler.addShapelessCraftingRecipe(GT_Utility.copyAmount(1L, new Object[]{aStack}), new Object[]{OrePrefixes.wireGt12.get(aMaterial), OrePrefixes.wireGt04.get(aMaterial)}); if (GT_Mod.gregtechproxy.mAE2Integration) { - Api.INSTANCE.registries().p2pTunnel().addNewAttunement(aStack, TunnelType.IC2_POWER); + Api.INSTANCE.registries().p2pTunnel().addNewAttunement(aStack, tt); } break; default: @@ -173,8 +183,8 @@ public class ProcessingWire implements gregtech.api.interfaces.IOreRecipeRegistr } GT_Values.RA.addUnboxingRecipe(GT_OreDictUnificator.get(correspondingCable, aMaterial, 1L), GT_Utility.copyAmount(1L, new Object[]{aStack}), null, 100, 8); if (GT_Mod.gregtechproxy.mAE2Integration) { - Api.INSTANCE.registries().p2pTunnel().addNewAttunement(aStack, TunnelType.IC2_POWER); - Api.INSTANCE.registries().p2pTunnel().addNewAttunement(GT_OreDictUnificator.get(correspondingCable, aMaterial, 1L), TunnelType.IC2_POWER); + Api.INSTANCE.registries().p2pTunnel().addNewAttunement(aStack, tt); + Api.INSTANCE.registries().p2pTunnel().addNewAttunement(GT_OreDictUnificator.get(correspondingCable, aMaterial, 1L), tt); } } } diff --git a/src/main/java/gregtech/loaders/postload/GT_AE2EnergyTunnelLoader.java b/src/main/java/gregtech/loaders/postload/GT_AE2EnergyTunnelLoader.java deleted file mode 100644 index a558696045..0000000000 --- a/src/main/java/gregtech/loaders/postload/GT_AE2EnergyTunnelLoader.java +++ /dev/null @@ -1,27 +0,0 @@ -package gregtech.loaders.postload; - -import appeng.items.parts.PartType; -import gregtech.GT_Mod; -import gregtech.api.util.GT_Log; - -import java.lang.reflect.Field; - -public class GT_AE2EnergyTunnelLoader implements Runnable { - @Override - public void run() { - if (GT_Mod.gregtechproxy.mAE2Integration) { - try { - load(); - } catch (Throwable e) { - GT_Log.out.println("Failed to load P2P tunnel for GT electricity"); - e.printStackTrace(GT_Log.out); - } - } - } - - public void load() throws Throwable { - Field f = PartType.class.getDeclaredField("myPart"); - f.setAccessible(true); - f.set(PartType.P2PTunnelEU, PartP2PGTPower.class); - } -} -- cgit From 9f4b4a2358b11a33d8d323a2c92a551a11e2ab51 Mon Sep 17 00:00:00 2001 From: repo_alt Date: Tue, 8 Sep 2020 00:37:20 +0300 Subject: A simple cache for the furnace recipes, to avoid linear iteration (Should help with https://github.com/GTNewHorizons/GT-New-Horizons-Modpack/issues/6416) --- build.properties | 2 +- src/main/java/gregtech/api/util/GT_ModHandler.java | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) (limited to 'src/main/java/gregtech/api') diff --git a/build.properties b/build.properties index 212a1b999c..633a84e787 100644 --- a/build.properties +++ b/build.properties @@ -1,6 +1,6 @@ minecraft.version=1.7.10 forge.version=10.13.4.1614-1.7.10 -gt.version=5.09.33.53 +gt.version=5.09.33.54 ae2.version=rv3-beta-22 applecore.version=1.7.10-1.2.1+107.59407 diff --git a/src/main/java/gregtech/api/util/GT_ModHandler.java b/src/main/java/gregtech/api/util/GT_ModHandler.java index e195bf9b02..4f318bb752 100644 --- a/src/main/java/gregtech/api/util/GT_ModHandler.java +++ b/src/main/java/gregtech/api/util/GT_ModHandler.java @@ -122,6 +122,7 @@ public class GT_ModHandler { public static List sSingleNonBlockDamagableRecipeList_warntOutput = new ArrayList(50); public static List sVanillaRecipeList_warntOutput = new ArrayList(50); public static final List sSingleNonBlockDamagableRecipeList_verified = new ArrayList(1000); + private static HashMap smeltingRecipeCache = new LinkedHashMap<>(); static { sNativeRecipeClasses.add(ShapedRecipes.class.getName()); @@ -1566,7 +1567,13 @@ public class GT_ModHandler { */ public static ItemStack getSmeltingOutput(ItemStack aInput, boolean aRemoveInput, ItemStack aOutputSlot) { if (aInput == null || aInput.stackSize < 1) return null; - ItemStack rStack = GT_OreDictUnificator.get(FurnaceRecipes.smelting().getSmeltingResult(aInput)); + GT_ItemStack gtInput = new GT_ItemStack(aInput); + ItemStack rStack = smeltingRecipeCache.get(gtInput); + if (rStack == null) { + rStack = GT_OreDictUnificator.get(FurnaceRecipes.smelting().getSmeltingResult(aInput)); + if (rStack != null) + smeltingRecipeCache.put(gtInput, rStack); + } if (rStack != null && (aOutputSlot == null || (GT_Utility.areStacksEqual(rStack, aOutputSlot) && rStack.stackSize + aOutputSlot.stackSize <= aOutputSlot.getMaxStackSize()))) { if (aRemoveInput) aInput.stackSize--; return rStack; -- cgit From 726e3d0fe46e3ba793f3c3e9b7acc3fd00a752ef Mon Sep 17 00:00:00 2001 From: repo_alt Date: Wed, 9 Sep 2020 08:24:03 +0300 Subject: replace HashMap with a (bounded) Guava Cache --- src/main/java/gregtech/api/util/GT_ModHandler.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'src/main/java/gregtech/api') diff --git a/src/main/java/gregtech/api/util/GT_ModHandler.java b/src/main/java/gregtech/api/util/GT_ModHandler.java index 4f318bb752..4d264bec9b 100644 --- a/src/main/java/gregtech/api/util/GT_ModHandler.java +++ b/src/main/java/gregtech/api/util/GT_ModHandler.java @@ -1,5 +1,7 @@ package gregtech.api.util; +import com.google.common.cache.Cache; +import com.google.common.cache.CacheBuilder; import cpw.mods.fml.common.event.FMLInterModComms; import cpw.mods.fml.common.registry.GameRegistry; import gregtech.GT_Mod; @@ -122,7 +124,7 @@ public class GT_ModHandler { public static List sSingleNonBlockDamagableRecipeList_warntOutput = new ArrayList(50); public static List sVanillaRecipeList_warntOutput = new ArrayList(50); public static final List sSingleNonBlockDamagableRecipeList_verified = new ArrayList(1000); - private static HashMap smeltingRecipeCache = new LinkedHashMap<>(); + private static Cache sSmeltingRecipeCache = CacheBuilder.newBuilder().maximumSize(1000).build(); static { sNativeRecipeClasses.add(ShapedRecipes.class.getName()); @@ -1566,14 +1568,14 @@ public class GT_ModHandler { * Used in my own Furnace. */ public static ItemStack getSmeltingOutput(ItemStack aInput, boolean aRemoveInput, ItemStack aOutputSlot) { - if (aInput == null || aInput.stackSize < 1) return null; - GT_ItemStack gtInput = new GT_ItemStack(aInput); - ItemStack rStack = smeltingRecipeCache.get(gtInput); - if (rStack == null) { - rStack = GT_OreDictUnificator.get(FurnaceRecipes.smelting().getSmeltingResult(aInput)); - if (rStack != null) - smeltingRecipeCache.put(gtInput, rStack); + if (aInput == null || aInput.stackSize < 1) + return null; + ItemStack rStack = null; + try { + rStack = sSmeltingRecipeCache.get(new GT_ItemStack(aInput), () -> GT_OreDictUnificator.get(FurnaceRecipes.smelting().getSmeltingResult(aInput))); + } catch (Exception ignored){ } + if (rStack != null && (aOutputSlot == null || (GT_Utility.areStacksEqual(rStack, aOutputSlot) && rStack.stackSize + aOutputSlot.stackSize <= aOutputSlot.getMaxStackSize()))) { if (aRemoveInput) aInput.stackSize--; return rStack; -- cgit From efbaa3fcb94da0aea4a4d51519b58df4641e68d9 Mon Sep 17 00:00:00 2001 From: botn365 <42187820+botn365@users.noreply.github.com> Date: Fri, 18 Sep 2020 22:31:23 +0200 Subject: fix energy consumption on OC past tick limit fix the energy consumption of the large chemical reactor where it would reduce the energy consumption if the it OCd past the tick limit --- .../implementations/GT_MetaTileEntity_MultiBlockBase.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/main/java/gregtech/api') 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 c6828c707e..c41d2ca316 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 @@ -617,8 +617,17 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { while (tempEUt <= V[mTier - 1] * mAmperage) { tempEUt <<= 2;//this actually controls overclocking //xEUt *= 4;//this is effect of everclocking + int oldTime = mMaxProgresstime; mMaxProgresstime >>= ocTimeShift;//this is effect of overclocking - xEUt = mMaxProgresstime==0 ? xEUt >> ocTimeShift : xEUt << 2;//U know, if the time is less than 1 tick make the machine use less power + if (mMaxProgresstime <1) + { + xEUt *= oldTime * (perfectOC ? 1:2); + break; + } + else + { + xEUt <<= ocTimeShift; + } } if(xEUt > Integer.MAX_VALUE - 1) { mEUt = Integer.MAX_VALUE - 1; -- cgit From ce56bfde0fd9d9e032fbbd5b431923dbf0d679a4 Mon Sep 17 00:00:00 2001 From: DreamMasterXXL Date: Sat, 19 Sep 2020 19:40:57 +0200 Subject: Revert "fix energy consumption on OC past tick limit" This reverts commit efbaa3fcb94da0aea4a4d51519b58df4641e68d9. --- .../implementations/GT_MetaTileEntity_MultiBlockBase.java | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) (limited to 'src/main/java/gregtech/api') 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 c41d2ca316..c6828c707e 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 @@ -617,17 +617,8 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { while (tempEUt <= V[mTier - 1] * mAmperage) { tempEUt <<= 2;//this actually controls overclocking //xEUt *= 4;//this is effect of everclocking - int oldTime = mMaxProgresstime; mMaxProgresstime >>= ocTimeShift;//this is effect of overclocking - if (mMaxProgresstime <1) - { - xEUt *= oldTime * (perfectOC ? 1:2); - break; - } - else - { - xEUt <<= ocTimeShift; - } + xEUt = mMaxProgresstime==0 ? xEUt >> ocTimeShift : 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; -- cgit From 40a6b42cd5e2ad4f6a97fffebf991d56c3ac50fc Mon Sep 17 00:00:00 2001 From: korneel vandamme Date: Sat, 19 Sep 2020 19:55:01 +0200 Subject: fix to much power on non perfect OC --- .../implementations/GT_MetaTileEntity_MultiBlockBase.java | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/main/java/gregtech/api') 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 c41d2ca316..6d2110baee 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 @@ -621,6 +621,8 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { mMaxProgresstime >>= ocTimeShift;//this is effect of overclocking if (mMaxProgresstime <1) { + if(oldTime == 1) + break; xEUt *= oldTime * (perfectOC ? 1:2); break; } -- cgit From 305d6832b7e2a501b45eb41bf2cdb8e4edb65cfb Mon Sep 17 00:00:00 2001 From: korneel vandamme Date: Sat, 19 Sep 2020 20:30:48 +0200 Subject: put back oldTime --- .../metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java | 1 + 1 file changed, 1 insertion(+) (limited to 'src/main/java/gregtech/api') 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 a64073d67e..6d2110baee 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 @@ -617,6 +617,7 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { while (tempEUt <= V[mTier - 1] * mAmperage) { tempEUt <<= 2;//this actually controls overclocking //xEUt *= 4;//this is effect of everclocking + int oldTime = mMaxProgresstime; mMaxProgresstime >>= ocTimeShift;//this is effect of overclocking if (mMaxProgresstime <1) { -- cgit From 6d0cb6ec9146fd98d9b0671a7be92f9fe647d4e1 Mon Sep 17 00:00:00 2001 From: kaziu687 Date: Thu, 1 Oct 2020 21:06:14 +0200 Subject: Update BaseMetaTileEntity.java Fixes problem that may cause explosion on Thermos servers with load-chunks-on-request: false When machine stays at the edge of loaded chunk (where siblings is not loaded) worldObj.getPrecipitationHeight will return -1 (cuz chunk wont be loaded on request). Machine will explode even if there is a roof. --- src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/main/java/gregtech/api') diff --git a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java index 2a275a5354..7e711aaccd 100644 --- a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java @@ -448,10 +448,10 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE if (getRandomNumber(1000) == 0) { if ((getCoverIDAtSide((byte) 1) == 0 && worldObj.getPrecipitationHeight(xCoord, zCoord) - 2 < yCoord) - || (getCoverIDAtSide((byte) 2) == 0 && worldObj.getPrecipitationHeight(xCoord, zCoord - 1) - 1 < yCoord) - || (getCoverIDAtSide((byte) 3) == 0 && worldObj.getPrecipitationHeight(xCoord, zCoord + 1) - 1 < yCoord) - || (getCoverIDAtSide((byte) 4) == 0 && worldObj.getPrecipitationHeight(xCoord - 1, zCoord) - 1 < yCoord) - || (getCoverIDAtSide((byte) 5) == 0 && worldObj.getPrecipitationHeight(xCoord + 1, zCoord) - 1 < yCoord)) { + || (getCoverIDAtSide((byte) 2) == 0 && worldObj.getPrecipitationHeight(xCoord, zCoord - 1) - 1 < yCoord && worldObj.getPrecipitationHeight(xCoord, zCoord - 1) > -1) + || (getCoverIDAtSide((byte) 3) == 0 && worldObj.getPrecipitationHeight(xCoord, zCoord + 1) - 1 < yCoord && worldObj.getPrecipitationHeight(xCoord, zCoord + 1) > -1) + || (getCoverIDAtSide((byte) 4) == 0 && worldObj.getPrecipitationHeight(xCoord - 1, zCoord) - 1 < yCoord && worldObj.getPrecipitationHeight(xCoord - 1, zCoord) > -1) + || (getCoverIDAtSide((byte) 5) == 0 && worldObj.getPrecipitationHeight(xCoord + 1, zCoord) - 1 < yCoord) && worldObj.getPrecipitationHeight(xCoord + 1, zCoord) > -1) { if (GregTech_API.sMachineRainExplosions && worldObj.isRaining() && getBiome().rainfall > 0) { if (getRandomNumber(10) == 0) { try{ -- cgit From b9170d551d95e9fe61234397dbd5ae67df2b6149 Mon Sep 17 00:00:00 2001 From: kaziu687 Date: Thu, 1 Oct 2020 22:41:24 +0200 Subject: worldObj.getPrecipitationHeight moved to variable --- .../gregtech/api/metatileentity/BaseMetaTileEntity.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src/main/java/gregtech/api') diff --git a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java index 7e711aaccd..cfb34eb34e 100644 --- a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java @@ -447,11 +447,16 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE } if (getRandomNumber(1000) == 0) { + int precipitationHeightAtSide2 = worldObj.getPrecipitationHeight(xCoord, zCoord - 1); + int precipitationHeightAtSide3 = worldObj.getPrecipitationHeight(xCoord, zCoord + 1); + int precipitationHeightAtSide4 = worldObj.getPrecipitationHeight(xCoord - 1, zCoord); + int precipitationHeightAtSide5 = worldObj.getPrecipitationHeight(xCoord + 1, zCoord); + if ((getCoverIDAtSide((byte) 1) == 0 && worldObj.getPrecipitationHeight(xCoord, zCoord) - 2 < yCoord) - || (getCoverIDAtSide((byte) 2) == 0 && worldObj.getPrecipitationHeight(xCoord, zCoord - 1) - 1 < yCoord && worldObj.getPrecipitationHeight(xCoord, zCoord - 1) > -1) - || (getCoverIDAtSide((byte) 3) == 0 && worldObj.getPrecipitationHeight(xCoord, zCoord + 1) - 1 < yCoord && worldObj.getPrecipitationHeight(xCoord, zCoord + 1) > -1) - || (getCoverIDAtSide((byte) 4) == 0 && worldObj.getPrecipitationHeight(xCoord - 1, zCoord) - 1 < yCoord && worldObj.getPrecipitationHeight(xCoord - 1, zCoord) > -1) - || (getCoverIDAtSide((byte) 5) == 0 && worldObj.getPrecipitationHeight(xCoord + 1, zCoord) - 1 < yCoord) && worldObj.getPrecipitationHeight(xCoord + 1, zCoord) > -1) { + || (getCoverIDAtSide((byte) 2) == 0 && precipitationHeightAtSide2 - 1 < yCoord && precipitationHeightAtSide2 > -1) + || (getCoverIDAtSide((byte) 3) == 0 && precipitationHeightAtSide3 - 1 < yCoord && precipitationHeightAtSide3 > -1) + || (getCoverIDAtSide((byte) 4) == 0 && precipitationHeightAtSide4 - 1 < yCoord && precipitationHeightAtSide4 > -1) + || (getCoverIDAtSide((byte) 5) == 0 && precipitationHeightAtSide5 - 1 < yCoord && precipitationHeightAtSide5 > -1)) { if (GregTech_API.sMachineRainExplosions && worldObj.isRaining() && getBiome().rainfall > 0) { if (getRandomNumber(10) == 0) { try{ -- cgit From 749e36968f3a2b392f497e59934ad521f4c78742 Mon Sep 17 00:00:00 2001 From: bartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com> Date: Sun, 4 Oct 2020 23:36:56 +0200 Subject: Invalid Muffler Hatch Facing Added the ability to change the invalid facing orientation on the Muffler Hatch Signed-off-by: bartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com> --- .../GT_MetaTileEntity_Hatch_Muffler.java | 97 +++++++++++++--------- 1 file changed, 56 insertions(+), 41 deletions(-) (limited to 'src/main/java/gregtech/api') 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 9cadeaddc2..b3998b62e7 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 @@ -12,6 +12,8 @@ import net.minecraft.item.ItemStack; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; +import java.util.Arrays; + import static gregtech.api.objects.XSTR.XSTR_INSTANCE; public class GT_MetaTileEntity_Hatch_Muffler extends GT_MetaTileEntity_Hatch { @@ -53,10 +55,23 @@ public class GT_MetaTileEntity_Hatch_Muffler extends GT_MetaTileEntity_Hatch { return true; } + private int[] mFacings; + + /*private void init()*/ { + setInValidFacings(ForgeDirection.DOWN); + } + + public void setInValidFacings(ForgeDirection... aFacings) { + mFacings = Arrays.stream(aFacings).mapToInt(Enum::ordinal).toArray(); + } + @Override public boolean isFacingValid(byte aFacing) { - return aFacing != 0; - } + for (int x : mFacings) + if (x == aFacing) + return false; + return true; + } @Override public boolean isAccessAllowed(EntityPlayer aPlayer) { @@ -80,9 +95,9 @@ public class GT_MetaTileEntity_Hatch_Muffler extends GT_MetaTileEntity_Hatch { } return false; } - - public int calculatePollutionReduction(int aPollution){ - return (int) (aPollution *(Math.pow(0.85F, mTier - 1))); + + public int calculatePollutionReduction(int aPollution) { + return (int) (aPollution * (Math.pow(0.85F, mTier - 1))); } @Override @@ -98,51 +113,51 @@ public class GT_MetaTileEntity_Hatch_Muffler extends GT_MetaTileEntity_Hatch { @Override public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { super.onPostTick(aBaseMetaTileEntity, aTick); - if(aBaseMetaTileEntity.isClientSide() && this.getBaseMetaTileEntity().isActive()) - pollutionParticles(this.getBaseMetaTileEntity().getWorld(),"largesmoke"); - } - - public void pollutionParticles(World aWorld,String name){ - boolean chk1,chk2,chk3; - float ran1=XSTR_INSTANCE.nextFloat(),ran2=0,ran3=0; - chk1=ran1*100= GT_Mod.gregtechproxy.mPollutionSmogLimit){ - ran2=XSTR_INSTANCE.nextFloat(); - ran3=XSTR_INSTANCE.nextFloat(); - chk2=ran2*100= GT_Mod.gregtechproxy.mPollutionSmogLimit) { + ran2 = XSTR_INSTANCE.nextFloat(); + ran3 = XSTR_INSTANCE.nextFloat(); + chk2 = ran2 * 100 < calculatePollutionReduction(100); + chk3 = ran3 * 100 < calculatePollutionReduction(100); + if (!(chk1 || chk2 || chk3)) return; + } else { + if (!chk1) return; + chk2 = chk3 = false; } - IGregTechTileEntity aMuffler=this.getBaseMetaTileEntity(); - ForgeDirection aDir=ForgeDirection.getOrientation(aMuffler.getFrontFacing()); - float xPos=aDir.offsetX*0.76F+aMuffler.getXCoord()+0.25F; - float yPos=aDir.offsetY*0.76F+aMuffler.getYCoord()+0.25F; - float zPos=aDir.offsetZ*0.76F+aMuffler.getZCoord()+0.25F; + IGregTechTileEntity aMuffler = this.getBaseMetaTileEntity(); + ForgeDirection aDir = ForgeDirection.getOrientation(aMuffler.getFrontFacing()); + float xPos = aDir.offsetX * 0.76F + aMuffler.getXCoord() + 0.25F; + float yPos = aDir.offsetY * 0.76F + aMuffler.getYCoord() + 0.25F; + float zPos = aDir.offsetZ * 0.76F + aMuffler.getZCoord() + 0.25F; - float ySpd=aDir.offsetY*0.1F+0.2F+0.1F*XSTR_INSTANCE.nextFloat(); + float ySpd = aDir.offsetY * 0.1F + 0.2F + 0.1F * XSTR_INSTANCE.nextFloat(); float xSpd; float zSpd; - if(aDir.offsetY==-1){ - float temp=XSTR_INSTANCE.nextFloat()*2*(float)Math.PI; - xSpd=(float)Math.sin(temp)*0.1F; - zSpd=(float)Math.cos(temp)*0.1F; - }else{ - xSpd=aDir.offsetX*(0.1F+0.2F*XSTR_INSTANCE.nextFloat()); - zSpd=aDir.offsetZ*(0.1F+0.2F*XSTR_INSTANCE.nextFloat()); + if (aDir.offsetY == -1) { + float temp = XSTR_INSTANCE.nextFloat() * 2 * (float) Math.PI; + xSpd = (float) Math.sin(temp) * 0.1F; + zSpd = (float) Math.cos(temp) * 0.1F; + } else { + xSpd = aDir.offsetX * (0.1F + 0.2F * XSTR_INSTANCE.nextFloat()); + zSpd = aDir.offsetZ * (0.1F + 0.2F * XSTR_INSTANCE.nextFloat()); } - if(chk1) - aWorld.spawnParticle(name, xPos + ran1*0.5F, yPos + XSTR_INSTANCE.nextFloat()*0.5F, zPos + XSTR_INSTANCE.nextFloat()*0.5F, xSpd, ySpd, zSpd); + if (chk1) + aWorld.spawnParticle(name, xPos + ran1 * 0.5F, yPos + XSTR_INSTANCE.nextFloat() * 0.5F, zPos + XSTR_INSTANCE.nextFloat() * 0.5F, xSpd, ySpd, zSpd); - if(chk2) - aWorld.spawnParticle(name, xPos + ran2*0.5F, yPos + XSTR_INSTANCE.nextFloat()*0.5F, zPos + XSTR_INSTANCE.nextFloat()*0.5F, xSpd, ySpd, zSpd); + if (chk2) + aWorld.spawnParticle(name, xPos + ran2 * 0.5F, yPos + XSTR_INSTANCE.nextFloat() * 0.5F, zPos + XSTR_INSTANCE.nextFloat() * 0.5F, xSpd, ySpd, zSpd); - if(chk3) - aWorld.spawnParticle(name, xPos + ran3*0.5F, yPos + XSTR_INSTANCE.nextFloat()*0.5F, zPos + XSTR_INSTANCE.nextFloat()*0.5F, xSpd, ySpd, zSpd); + if (chk3) + aWorld.spawnParticle(name, xPos + ran3 * 0.5F, yPos + XSTR_INSTANCE.nextFloat() * 0.5F, zPos + XSTR_INSTANCE.nextFloat() * 0.5F, xSpd, ySpd, zSpd); } } -- cgit From 7c495e8f38795ced3d8156cea253cea63a0bc46a Mon Sep 17 00:00:00 2001 From: botn365 <42187820+botn365@users.noreply.github.com> Date: Mon, 19 Oct 2020 03:53:55 +0200 Subject: allow to pull items from input bus --- .../implementations/GT_MetaTileEntity_Hatch_InputBus.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/main/java/gregtech/api') diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBus.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBus.java index 8c36c2af65..0111d932ae 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBus.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBus.java @@ -160,7 +160,7 @@ public class GT_MetaTileEntity_Hatch_InputBus extends GT_MetaTileEntity_Hatch { @Override public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return false; + return true; } @Override -- cgit From 2914c59e4261c91994ca329105c986d959e5d47b Mon Sep 17 00:00:00 2001 From: botn365 <42187820+botn365@users.noreply.github.com> Date: Mon, 19 Oct 2020 04:05:15 +0200 Subject: allow only from input side --- .../implementations/GT_MetaTileEntity_Hatch_InputBus.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/main/java/gregtech/api') diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBus.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBus.java index 0111d932ae..dfac210915 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBus.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBus.java @@ -160,7 +160,7 @@ public class GT_MetaTileEntity_Hatch_InputBus extends GT_MetaTileEntity_Hatch { @Override public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return true; + return aSide == getBaseMetaTileEntity().getFrontFacing(); } @Override -- cgit From 2763104566be435df158ca11a96f51503857e11f Mon Sep 17 00:00:00 2001 From: bartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com> Date: Mon, 19 Oct 2020 12:56:06 +0200 Subject: Unf****d build.gradle Signed-off-by: bartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com> --- build.gradle | 98 +++++++++++----------- .../implementations/GT_MetaPipeEntity_Fluid.java | 38 ++++++--- 2 files changed, 73 insertions(+), 63 deletions(-) (limited to 'src/main/java/gregtech/api') diff --git a/build.gradle b/build.gradle index 2f28009a4c..4ed676b8c4 100644 --- a/build.gradle +++ b/build.gradle @@ -17,6 +17,7 @@ buildscript { apply plugin: 'forge' apply plugin: 'idea' +apply plugin: 'java' apply plugin: 'signing' file "build.properties" withReader { @@ -29,30 +30,21 @@ version = "${config.gt.version}" group= "gregtech" archivesBaseName = "gregtech" - sourceCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8 -sourceCompatibility = 1.8 -targetCompatibility = 1.8 +compileJava.options.encoding("UTF-8") minecraft { version = "${config.minecraft.version}-${config.forge.version}" - runDir = "eclipse" - + runDir = "run" } -idea { module { inheritOutputDirs = true } } - -configurations { - provided - embedded - compile.extendsFrom provided, embedded -} +idea.module.inheritOutputDirs = true repositories { maven { - name 'Forge' - url 'http://files.minecraftforge.net/maven' + name = 'Forge' + url = 'http://files.minecraftforge.net/maven' } maven { name = "chickenbones" @@ -63,58 +55,58 @@ repositories { url = "http://maven.ic2.player.to/" } maven { // EnderIO & EnderCore - name 'tterrag Repo' - url "http://maven.tterrag.com" + name = 'tterrag Repo' + url = "http://maven.tterrag.com" } maven { // TConstruct - name 'DVS1 Maven FS' - url 'http://dvs1.progwml6.com/files/maven' + name = 'DVS1 Maven FS' + url = 'http://dvs1.progwml6.com/files/maven' } maven { // AppleCore - url "http://www.ryanliptak.com/maven/" + url = "http://www.ryanliptak.com/maven/" } maven { // GalacticGreg, YAMCore,.. - name 'UsrvDE' - url "http://jenkins.usrv.eu:8081/nexus/content/repositories/releases/" + name = 'UsrvDE' + url = "http://jenkins.usrv.eu:8081/nexus/content/repositories/releases/" } ivy { - name 'gtnh_download_source_stupid_underscore_typo' - artifactPattern "http://downloads.gtnewhorizons.com/Mods_for_Jenkins/[module]_[revision].[ext]" + name = 'gtnh_download_source_stupid_underscore_typo' + artifactPattern("http://downloads.gtnewhorizons.com/Mods_for_Jenkins/[module]_[revision].[ext]") } ivy { - name 'gtnh_download_source' - artifactPattern "http://downloads.gtnewhorizons.com/Mods_for_Jenkins/[module]-[revision].[ext]" + name = 'gtnh_download_source' + artifactPattern("http://downloads.gtnewhorizons.com/Mods_for_Jenkins/[module]-[revision].[ext]") } } dependencies { - compile "eu.usrv:YAMCore:${config.minecraft.version}-${config.yamcore.version}:deobf" - compile "tconstruct:TConstruct:${config.minecraft.version}-${config.tconstruct.version}:deobf" - compile "mantle:Mantle:${config.minecraft.version}-${config.mantle.version}:deobf" - provided ("appeng:appliedenergistics2:${config.ae2.version}:dev") { + compileOnly "eu.usrv:YAMCore:${config.minecraft.version}-${config.yamcore.version}:deobf" + compileOnly "tconstruct:TConstruct:${config.minecraft.version}-${config.tconstruct.version}:deobf" + //compile "mantle:Mantle:${config.minecraft.version}-${config.mantle.version}:deobf" + compileOnly ("appeng:appliedenergistics2:${config.ae2.version}:dev") { exclude module: '*' } - provided "codechicken:CodeChickenLib:${config.minecraft.version}-${config.codechickenlib.version}:dev" - provided "codechicken:CodeChickenCore:${config.minecraft.version}-${config.codechickencore.version}:dev" - provided "codechicken:NotEnoughItems:${config.minecraft.version}-${config.nei.version}:dev" - provided "codechicken:Translocator:${config.minecraft.version}-${config.translocators.version}:dev" - provided "net.industrial-craft:industrialcraft-2:${config.ic2.version}:dev" - provided "net.sengir.forestry:forestry_${config.minecraft.version}:${config.forestry.version}:dev" - provided "applecore:AppleCore:${config.applecore.version}:api" - provided "com.enderio.core:EnderCore:${config.enderiocore.version}:dev" - provided ("com.enderio:EnderIO:${config.enderio.version}:dev") { + compileOnly "codechicken:CodeChickenLib:${config.minecraft.version}-${config.codechickenlib.version}:dev" + compileOnly "codechicken:CodeChickenCore:${config.minecraft.version}-${config.codechickencore.version}:dev" + compileOnly "codechicken:NotEnoughItems:${config.minecraft.version}-${config.nei.version}:dev" + compileOnly "codechicken:Translocator:${config.minecraft.version}-${config.translocators.version}:dev" + compile "net.industrial-craft:industrialcraft-2:${config.ic2.version}:dev" + compileOnly "net.sengir.forestry:forestry_${config.minecraft.version}:${config.forestry.version}:dev" + compileOnly "applecore:AppleCore:${config.applecore.version}:api" + compileOnly "com.enderio.core:EnderCore:${config.enderiocore.version}:dev" + compileOnly ("com.enderio:EnderIO:${config.enderio.version}:dev") { transitive = false } - compile files("libs/Galacticraft-API-1.7-${config.gc.version}.jar") - compile files("libs/GalacticraftCore-Dev-${config.gc.version}.jar") - provided name: "Galacticraft-API", version: config.gc.version, ext: 'jar' - provided name: "GalacticraftCore-Dev", version: config.gc.version, ext: 'jar' - provided name: 'CoFHLib', version: config.cofhlib.version, ext: 'jar' - provided name: 'CoFHCore', version: config.cofhcore.version, ext: 'jar' - provided name: 'Railcraft', version: config.railcraft.version, ext: 'jar' - provided name: 'IC2NuclearControl', version: config.nc.version, ext: 'jar' + compileOnly files("libs/Galacticraft-API-1.7-${config.gc.version}.jar") + compileOnly files("libs/GalacticraftCore-Dev-${config.gc.version}.jar") + compileOnly name: "Galacticraft-API", version: config.gc.version, ext: 'jar' + compileOnly name: "GalacticraftCore-Dev", version: config.gc.version, ext: 'jar' + compileOnly name: 'CoFHLib', version: config.cofhlib.version, ext: 'jar' + //compileOnly name: 'CoFHCore', version: config.cofhcore.version, ext: 'jar' + compileOnly name: 'Railcraft', version: config.railcraft.version, ext: 'jar' + compileOnly name: 'IC2NuclearControl', version: config.nc.version, ext: 'jar' //provided name: 'ImmersiveEngineering', version: config.immeng.version, ext: 'jar' //provided name: 'magneticraft', version: config.magneticraft.version, ext: 'jar' @@ -149,14 +141,18 @@ task sourceJar(type: Jar) { task devJar(type: Jar) { from sourceSets.main.output classifier = 'dev' - manifest { - //attributes 'FMLCorePlugin': 'WhateverLoaderClass' - //attributes 'FMLCorePluginContainsFMLMod': 'true' - } +} + +task apiJar(type: Jar) { + from sourceSets.main.allSource + include("gregtech/api/**") + classifier = 'api' } artifacts { - archives devJar + archives(devJar) + archives(sourceJar) + archives(apiJar) } task signJar(dependsOn: 'reobf'){ 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 23afaa84f7..1d1b1a9ea0 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 @@ -1,8 +1,12 @@ package gregtech.api.metatileentity.implementations; +import cpw.mods.fml.common.Optional; import gregtech.GT_Mod; import gregtech.api.GregTech_API; -import gregtech.api.enums.*; +import gregtech.api.enums.Dyes; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.ICoverable; @@ -389,36 +393,46 @@ public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity { @Override public boolean canConnect(byte aSide, TileEntity tTileEntity) { - if (tTileEntity == null) return false; + if (tTileEntity == null) + return false; final byte tSide = (byte)ForgeDirection.getOrientation(aSide).getOpposite().ordinal(); final IGregTechTileEntity baseMetaTile = getBaseMetaTileEntity(); - if (baseMetaTile == null) return false; + if (baseMetaTile == null) + return false; final GT_CoverBehavior coverBehavior = baseMetaTile.getCoverBehaviorAtSide(aSide); final IGregTechTileEntity gTileEntity = (tTileEntity instanceof IGregTechTileEntity) ? (IGregTechTileEntity) tTileEntity : null; - if (coverBehavior instanceof GT_Cover_Drain) return true; - - // Tinker Construct Faucets return a null tank info, so check the class - if (GregTech_API.mTConstruct && tTileEntity instanceof tconstruct.smeltery.logic.FaucetLogic) return true; + if (coverBehavior instanceof GT_Cover_Drain || isTConstructFaucet(tTileEntity)) + return true; final IFluidHandler fTileEntity = (tTileEntity instanceof IFluidHandler) ? (IFluidHandler) tTileEntity : null; if (fTileEntity != null) { FluidTankInfo[] tInfo = fTileEntity.getTankInfo(ForgeDirection.getOrientation(tSide)); if (tInfo != null) { - if (tInfo.length > 0) return true; - - // Translocators return a TankInfo, but it's of 0 length - so check the class if we see this pattern - if (GregTech_API.mTranslocator && tTileEntity instanceof codechicken.translocator.TileLiquidTranslocator) return true; - if (gTileEntity != null && gTileEntity.getCoverBehaviorAtSide(tSide) instanceof GT_Cover_FluidRegulator) return true; + return tInfo.length > 0 + || isTranslocator(tTileEntity) + || gTileEntity != null && gTileEntity.getCoverBehaviorAtSide(tSide) instanceof GT_Cover_FluidRegulator; } } return false; } + @Optional.Method(modid = "TConstruct") + private boolean isTConstructFaucet(TileEntity tTileEntity){ + // Tinker Construct Faucets return a null tank info, so check the class + return GregTech_API.mTConstruct && tTileEntity instanceof tconstruct.smeltery.logic.FaucetLogic; + } + + @Optional.Method(modid = "Translocator") + private boolean isTranslocator(TileEntity tTileEntity){ + // Translocators return a TankInfo, but it's of 0 length - so check the class if we see this pattern + return GregTech_API.mTranslocator && tTileEntity instanceof codechicken.translocator.TileLiquidTranslocator; + } + @Override public boolean getGT6StyleConnection() { // Yes if GT6 pipes are enabled -- cgit From 1661004faa9a3e1839b544b6cf4ac1479ea60a67 Mon Sep 17 00:00:00 2001 From: bartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com> Date: Mon, 19 Oct 2020 14:02:28 +0200 Subject: Lift checks out of Stripped Methodes to prevent NoSuchMethodErrors Signed-off-by: bartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com> --- .../metatileentity/implementations/GT_MetaPipeEntity_Fluid.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/main/java/gregtech/api') 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 1d1b1a9ea0..8a28301fdf 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 @@ -404,7 +404,7 @@ public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity { final GT_CoverBehavior coverBehavior = baseMetaTile.getCoverBehaviorAtSide(aSide); final IGregTechTileEntity gTileEntity = (tTileEntity instanceof IGregTechTileEntity) ? (IGregTechTileEntity) tTileEntity : null; - if (coverBehavior instanceof GT_Cover_Drain || isTConstructFaucet(tTileEntity)) + if (coverBehavior instanceof GT_Cover_Drain || (GregTech_API.mTConstruct && isTConstructFaucet(tTileEntity))) return true; final IFluidHandler fTileEntity = (tTileEntity instanceof IFluidHandler) ? (IFluidHandler) tTileEntity : null; @@ -413,7 +413,7 @@ public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity { FluidTankInfo[] tInfo = fTileEntity.getTankInfo(ForgeDirection.getOrientation(tSide)); if (tInfo != null) { return tInfo.length > 0 - || isTranslocator(tTileEntity) + || (GregTech_API.mTranslocator && isTranslocator(tTileEntity)) || gTileEntity != null && gTileEntity.getCoverBehaviorAtSide(tSide) instanceof GT_Cover_FluidRegulator; } @@ -424,13 +424,13 @@ public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity { @Optional.Method(modid = "TConstruct") private boolean isTConstructFaucet(TileEntity tTileEntity){ // Tinker Construct Faucets return a null tank info, so check the class - return GregTech_API.mTConstruct && tTileEntity instanceof tconstruct.smeltery.logic.FaucetLogic; + return tTileEntity instanceof tconstruct.smeltery.logic.FaucetLogic; } @Optional.Method(modid = "Translocator") private boolean isTranslocator(TileEntity tTileEntity){ // Translocators return a TankInfo, but it's of 0 length - so check the class if we see this pattern - return GregTech_API.mTranslocator && tTileEntity instanceof codechicken.translocator.TileLiquidTranslocator; + return tTileEntity instanceof codechicken.translocator.TileLiquidTranslocator; } @Override -- cgit From 4b802f15c5af0f69a3275fd5951e65145083acf6 Mon Sep 17 00:00:00 2001 From: botn365 <42187820+botn365@users.noreply.github.com> Date: Sun, 25 Oct 2020 21:27:07 +0100 Subject: fix acidental perfect OC on all multies (#332) --- .../implementations/GT_MetaTileEntity_MultiBlockBase.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/main/java/gregtech/api') 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 6d2110baee..202e542c88 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 @@ -628,7 +628,7 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { } else { - xEUt <<= ocTimeShift; + xEUt <<= 2; } } if(xEUt > Integer.MAX_VALUE - 1) { -- cgit From e13b3764e3e452ba14a96f49fdc32a520c7f2085 Mon Sep 17 00:00:00 2001 From: Prometheus0000000 Date: Tue, 3 Nov 2020 03:25:11 -0500 Subject: Added IV HOG only LCE --- src/main/java/gregtech/api/enums/ItemList.java | 2 + src/main/java/gregtech/api/enums/Textures.java | 3 + .../gregtech/common/blocks/GT_Block_Casings8.java | 6 +- .../GT_MetaTileEntity_ExtremeDieselEngine.java | 289 +++++++++++++++++++++ .../preload/GT_Loader_MetaTileEntities.java | 7 +- .../MACHINE_CASING_EXTREME_ENGINE_INTAKE.png | Bin 0 -> 585 bytes .../OVERLAY_FRONT_EXTREME_DIESEL_ENGINE.png | Bin 0 -> 439 bytes .../OVERLAY_FRONT_EXTREME_DIESEL_ENGINE_ACTIVE.png | Bin 0 -> 457 bytes .../gui/multimachines/LargeExtremeDieselEngine.png | Bin 0 -> 1673 bytes 9 files changed, 305 insertions(+), 2 deletions(-) create mode 100644 src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ExtremeDieselEngine.java create mode 100644 src/main/resources/assets/gregtech/textures/blocks/iconsets/MACHINE_CASING_EXTREME_ENGINE_INTAKE.png create mode 100644 src/main/resources/assets/gregtech/textures/blocks/iconsets/OVERLAY_FRONT_EXTREME_DIESEL_ENGINE.png create mode 100644 src/main/resources/assets/gregtech/textures/blocks/iconsets/OVERLAY_FRONT_EXTREME_DIESEL_ENGINE_ACTIVE.png create mode 100644 src/main/resources/assets/gregtech/textures/gui/multimachines/LargeExtremeDieselEngine.png (limited to 'src/main/java/gregtech/api') diff --git a/src/main/java/gregtech/api/enums/ItemList.java b/src/main/java/gregtech/api/enums/ItemList.java index 6f7a0567a1..8830ab50a5 100644 --- a/src/main/java/gregtech/api/enums/ItemList.java +++ b/src/main/java/gregtech/api/enums/ItemList.java @@ -1427,6 +1427,7 @@ public enum ItemList implements IItemContainer { Casing_Turbine2, Casing_Turbine3, Casing_EngineIntake, + Casing_ExtremeEngineIntake, Casing_Coil_Cupronickel, Casing_Coil_Kanthal, @@ -1570,6 +1571,7 @@ public enum ItemList implements IItemContainer { CuringOven, Machine_Multi_Assemblyline, Machine_Multi_DieselEngine, + Machine_Multi_ExtremeDieselEngine, QuantumEye, QuantumStar, Gravistar, diff --git a/src/main/java/gregtech/api/enums/Textures.java b/src/main/java/gregtech/api/enums/Textures.java index 7b229550ff..38001faebb 100644 --- a/src/main/java/gregtech/api/enums/Textures.java +++ b/src/main/java/gregtech/api/enums/Textures.java @@ -267,6 +267,7 @@ public class Textures { MACHINE_CASING_FIREBOX_STEEL, MACHINE_CASING_FIREBOX_TUNGSTENSTEEL, MACHINE_CASING_ENGINE_INTAKE, + MACHINE_CASING_EXTREME_ENGINE_INTAKE,//changed color in a terrible way MACHINE_CASING_CHEMICALLY_INERT, MACHINE_COIL_CUPRONICKEL, @@ -854,6 +855,8 @@ public class Textures { OVERLAY_FRONT_OIL_DRILL, OVERLAY_FRONT_DIESEL_ENGINE_ACTIVE, OVERLAY_FRONT_DIESEL_ENGINE, + OVERLAY_FRONT_EXTREME_DIESEL_ENGINE_ACTIVE, + OVERLAY_FRONT_EXTREME_DIESEL_ENGINE, OVERLAY_FRONT_PYROLYSE_OVEN_ACTIVE, OVERLAY_FRONT_PYROLYSE_OVEN, diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Casings8.java b/src/main/java/gregtech/common/blocks/GT_Block_Casings8.java index 8d2c976b1b..0f3aac4518 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Casings8.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Casings8.java @@ -15,18 +15,20 @@ public class GT_Block_Casings8 //WATCH OUT FOR TEXTURE ID's public GT_Block_Casings8() { super(GT_Item_Casings8.class, "gt.blockcasings8", GT_Material_Casings.INSTANCE); - for (int i = 0; i < 4; i = (i + 1)) { + for (int i = 0; i < 5; i = (i + 1)) { Textures.BlockIcons.casingTexturePages[1][i+48] = new GT_CopiedBlockTexture(this, 6, i); } GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".0.name", "Chemically Inert Machine Casing"); GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".1.name", "PTFE Pipe Casing"); GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".2.name", "Mining Neutronium Casing"); GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".3.name", "Mining Black Plutonium Casing"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".4.name", "Extreme Engine Intake Casing"); ItemList.Casing_Chemically_Inert.set(new ItemStack(this, 1, 0)); ItemList.Casing_Pipe_Polytetrafluoroethylene.set(new ItemStack(this, 1, 1)); ItemList.Casing_MiningNeutronium.set(new ItemStack(this, 1, 2)); ItemList.Casing_MiningBlackPlutonium.set(new ItemStack(this, 1, 3)); + ItemList.Casing_ExtremeEngineIntake.set(new ItemStack(this, 1, 4)); } @Override @@ -41,6 +43,8 @@ public class GT_Block_Casings8 return Textures.BlockIcons.MACHINE_CASING_MINING_NEUTRONIUM.getIcon(); case 3: return Textures.BlockIcons.MACHINE_CASING_MINING_BLACKPLUTONIUM.getIcon(); + case 4: + return Textures.BlockIcons.MACHINE_CASING_EXTREME_ENGINE_INTAKE.getIcon();//changed color in a terrible way } return Textures.BlockIcons.MACHINE_CASING_ROBUST_TUNGSTENSTEEL.getIcon(); } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ExtremeDieselEngine.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ExtremeDieselEngine.java new file mode 100644 index 0000000000..f38f0a1de2 --- /dev/null +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ExtremeDieselEngine.java @@ -0,0 +1,289 @@ +package gregtech.common.tileentities.machines.multi; + +import java.util.ArrayList; +import java.util.Collection; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.Materials; +import gregtech.api.enums.Textures; +import gregtech.api.gui.GT_GUIContainer_MultiMachine; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Dynamo; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Muffler; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import net.minecraft.block.Block; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.StatCollector; +import net.minecraftforge.fluids.FluidStack; + +public class GT_MetaTileEntity_ExtremeDieselEngine extends GT_MetaTileEntity_MultiBlockBase { + protected int fuelConsumption = 0; + protected int fuelValue = 0; + protected int fuelRemaining = 0; + protected boolean boostEu = false; + + public GT_MetaTileEntity_ExtremeDieselEngine(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GT_MetaTileEntity_ExtremeDieselEngine(String aName) { + super(aName); + } + + public String[] getDescription() { + return new String[]{ + "Controller Block for the Extreme Combustion Engine", + "Size(WxHxD): 3x3x4, Controller (front centered)", + "3x3x4 of Robust Tungstensteel Machine Casing (hollow, Min 16!)", + "2x Titanium Gear Box Machine Casing inside the Hollow Casing",//todo + "8x Extreme Engine Intake Casing (around controller)", + "2x Input Hatch (HOG/Lubricant) (one of the Casings next to a Gear Box)", + "1x Input Hatch (Optional, for Liquid Oxygen) (one of the Casings next to a Gear Box)", + "1x Maintenance Hatch (one of the Casings next to a Gear Box)", + "1x Muffler Hatch (top middle back, above the rear Gear Box)", + "1x Dynamo Hatch (back centered)", + "Engine Intake Casings must not be obstructed in front (only air blocks)", + "Supply High Octane Gasoline and 8000L of Lubricant per hour to run.", + "Supply 320L of Liquid Oxygen per second to boost output (optional).", + "Default: Produces 8192EU/t at 100% efficiency", + "Boosted: Produces 32768EU/t at 400% efficiency", + "Causes " + 20 * getPollutionPerTick(null) + " Pollution per second"}; + } + + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + if (aSide == aFacing) { + return new ITexture[]{Textures.BlockIcons.casingTexturePages[0][60], new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_EXTREME_DIESEL_ENGINE_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_EXTREME_DIESEL_ENGINE)}; + } + return new ITexture[]{Textures.BlockIcons.casingTexturePages[0][60]};//controller texture? where do I find this? Copied plasma turbine + } + + @Override + public boolean isCorrectMachinePart(ItemStack aStack) { + return getMaxEfficiency(aStack) > 0; + } + + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "LargeExtremeDieselEngine.png");//change + } + + @Override + public boolean checkRecipe(ItemStack aStack) { + ArrayList tFluids = getStoredFluids(); + Collection tRecipeList = GT_Recipe.GT_Recipe_Map.sDieselFuels.mRecipeList; + + if(tFluids.contains(Materials.GasolinePremium.getFluid(4L))) { //Does input hatch contain HOG? + for (FluidStack hatchFluid1 : tFluids) { //Loops through hatches + for(GT_Recipe aFuel : tRecipeList) { //Loops through diesel fuel recipes dd. Can't remove because I suck at coding + FluidStack tLiquid; + + if ((tLiquid = GT_Utility.getFluidForFilledItem(aFuel.getRepresentativeInput(0), true)) != null) { //Create fluidstack from current recipe + if (hatchFluid1.isFluidEqual(tLiquid)) { //Has a diesel fluid + fuelConsumption = tLiquid.amount = boostEu ? (8192 / aFuel.mSpecialValue) : (2048 / aFuel.mSpecialValue); //Calc fuel consumption + if(depleteInput(tLiquid)) { //Deplete that amount ^Doesn't give bonus to fuel usage anymore + boostEu = depleteInput(Materials.LiquidOxygen.getGas(16L));//x8, and LOX instead + + if(tFluids.contains(Materials.Lubricant.getFluid(8L))) { //Has lubricant? + //Deplete Lubricant. 8000L should = 1 hour of runtime (if baseEU = 8192) + if(mRuntime % 72 == 0 || mRuntime == 0) depleteInput(Materials.Lubricant.getFluid(boostEu ? 16 : 8));//x8 + } else return false; + + fuelValue = aFuel.mSpecialValue; + fuelRemaining = hatchFluid1.amount; //Record available fuel + this.mEUt = mEfficiency < 2000 ? 0 : 8192; //Output 0 if startup is less than 20% + this.mProgresstime = 1; //will output 8192 normally, 32768 boosted + this.mMaxProgresstime = 1; + this.mEfficiencyIncrease = 15; + return true; + } + } + } + } + } + } + this.mEUt = 0; + this.mEfficiency = 0; + return false; + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + byte tSide = getBaseMetaTileEntity().getBackFacing(); + int tX = getBaseMetaTileEntity().getXCoord(); + int tY = getBaseMetaTileEntity().getYCoord(); + int tZ = getBaseMetaTileEntity().getZCoord(); + + if(getBaseMetaTileEntity().getBlockAtSideAndDistance(tSide, 1) != getGearboxBlock() && getBaseMetaTileEntity().getBlockAtSideAndDistance(tSide, 2) != getGearboxBlock()) { + return false; + } + if(getBaseMetaTileEntity().getMetaIDAtSideAndDistance(tSide, 1) != getGearboxMeta() && getBaseMetaTileEntity().getMetaIDAtSideAndDistance(tSide, 2) != getGearboxMeta()) { + return false; + } + for (byte i = -1; i < 2; i = (byte) (i + 1)) { + for (byte j = -1; j < 2; j = (byte) (j + 1)) { + if ((i != 0) || (j != 0)) { + for (byte k = 0; k < 4; k = (byte) (k + 1)) { + + final int fX = tX - (tSide == 5 ? 1 : tSide == 4 ? -1 : i), + fZ = tZ - (tSide == 2 ? -1 : tSide == 3 ? 1 : i), + aY = tY + j, + aX = tX + (tSide == 5 ? k : tSide == 4 ? -k : i), + aZ = tZ + (tSide == 2 ? -k : tSide == 3 ? k : i); + + final Block frontAir = getBaseMetaTileEntity().getBlock(fX, aY, fZ); + final String frontAirName = frontAir.getUnlocalizedName(); + if(!(getBaseMetaTileEntity().getAir(fX, aY, fZ) || frontAirName.equalsIgnoreCase("tile.air") || frontAirName.equalsIgnoreCase("tile.railcraft.residual.heat"))) { + return false; //Fail if vent blocks are obstructed + } + + if (((i == 0) || (j == 0)) && ((k == 1) || (k == 2))) { + if (getBaseMetaTileEntity().getBlock(aX, aY, aZ) == getCasingBlock() && getBaseMetaTileEntity().getMetaID(aX, aY, aZ) == getCasingMeta()) { + // Do nothing + } else if (!addMufflerToMachineList(getBaseMetaTileEntity().getIGregTechTileEntity(tX + (tSide == 5 ? 2 : tSide == 4 ? -2 : 0), tY + 1, tZ + (tSide == 3 ? 2 : tSide == 2 ? -2 : 0)), getCasingTextureIndex())) { + return false; //Fail if no muffler top middle back + } else if (!addToMachineList(getBaseMetaTileEntity().getIGregTechTileEntity(aX, aY, aZ))) { + return false; + } + } else if (k == 0) { + if(!(getBaseMetaTileEntity().getBlock(aX, aY, aZ) == getIntakeBlock() && getBaseMetaTileEntity().getMetaID(aX, aY, aZ) == getIntakeMeta())) { + return false; + } + } else if (getBaseMetaTileEntity().getBlock(aX, aY, aZ) == getCasingBlock() && getBaseMetaTileEntity().getMetaID(aX, aY, aZ) == getCasingMeta()) { + // Do nothing + } else { + return false; + } + } + } + } + } + this.mDynamoHatches.clear(); + IGregTechTileEntity tTileEntity = getBaseMetaTileEntity().getIGregTechTileEntityAtSideAndDistance(getBaseMetaTileEntity().getBackFacing(), 3); + if ((tTileEntity != null) && (tTileEntity.getMetaTileEntity() != null)) { + if ((tTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_Hatch_Dynamo)) { + this.mDynamoHatches.add((GT_MetaTileEntity_Hatch_Dynamo) tTileEntity.getMetaTileEntity()); + ((GT_MetaTileEntity_Hatch) tTileEntity.getMetaTileEntity()).updateTexture(getCasingTextureIndex()); + } else { + return false; + } + } + return true; + } + + public Block getCasingBlock() {//changed to RTSMC + return GregTech_API.sBlockCasings4; + } + + public byte getCasingMeta() {//same + return 0; + } + + public Block getIntakeBlock() { + return GregTech_API.sBlockCasings8;//added new + } + + public byte getIntakeMeta() {//same + return 4; + } + + public Block getGearboxBlock() { + return GregTech_API.sBlockCasings2; + } + + public byte getGearboxMeta() { + return 4; + } + + public byte getCasingTextureIndex() {//should be what hatches/busses change to? + return 60; + } + + private boolean addToMachineList(IGregTechTileEntity tTileEntity) { + return ((addMaintenanceToMachineList(tTileEntity, getCasingTextureIndex())) || (addInputToMachineList(tTileEntity, getCasingTextureIndex())) || (addOutputToMachineList(tTileEntity, getCasingTextureIndex())) || (addMufflerToMachineList(tTileEntity, getCasingTextureIndex()))); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_ExtremeDieselEngine(this.mName); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + } + + @Override + public int getDamageToComponent(ItemStack aStack) { + return 1; + } + + public int getMaxEfficiency(ItemStack aStack) { + return boostEu ? 40000 : 10000;//4x output if boosted instead of x3 + } + + @Override + public int getPollutionPerTick(ItemStack aStack) { + return 192;//x8 + } + + @Override + public boolean explodesOnComponentBreak(ItemStack aStack) { + return true; + } + + @Override + public String[] getInfoData() { + 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_Dynamo tHatch : mDynamoHatches) { + if (isValidMetaTileEntity(tHatch)) { + storedEnergy+=tHatch.getBaseMetaTileEntity().getStoredEU(); + maxEnergy+=tHatch.getBaseMetaTileEntity().getEUCapacity(); + } + } + + + return new String[]{ + EnumChatFormatting.BLUE+"Extreme Diesel Engine"+EnumChatFormatting.RESET, + StatCollector.translateToLocal("GT5U.multiblock.energy")+": " + + EnumChatFormatting.GREEN + Long.toString(storedEnergy) + EnumChatFormatting.RESET +" EU / "+ + EnumChatFormatting.YELLOW + Long.toString(maxEnergy) + EnumChatFormatting.RESET +" EU", + getIdealStatus() == getRepairStatus() ? + EnumChatFormatting.GREEN+StatCollector.translateToLocal("GT5U.turbine.maintenance.false")+EnumChatFormatting.RESET : + EnumChatFormatting.RED+StatCollector.translateToLocal("GT5U.turbine.maintenance.true")+EnumChatFormatting.RESET, + StatCollector.translateToLocal("GT5U.engine.output")+": " +EnumChatFormatting.RED+(-mEUt*mEfficiency/10000)+EnumChatFormatting.RESET+" EU/t", + StatCollector.translateToLocal("GT5U.engine.consumption")+": " +EnumChatFormatting.YELLOW+fuelConsumption+EnumChatFormatting.RESET+" L/t", + StatCollector.translateToLocal("GT5U.engine.value")+": " +EnumChatFormatting.YELLOW+fuelValue+EnumChatFormatting.RESET+" EU/L", + StatCollector.translateToLocal("GT5U.turbine.fuel")+": " +EnumChatFormatting.GOLD+fuelRemaining+EnumChatFormatting.RESET+" L", + StatCollector.translateToLocal("GT5U.engine.efficiency")+": " +EnumChatFormatting.YELLOW+(mEfficiency/100F)+EnumChatFormatting.YELLOW+" %", + StatCollector.translateToLocal("GT5U.multiblock.pollution")+": " + EnumChatFormatting.GREEN + mPollutionReduction+ EnumChatFormatting.RESET+" %" + + }; + } + + @Override + public boolean isGivingInformation() { + return true; + } + +} diff --git a/src/main/java/gregtech/loaders/preload/GT_Loader_MetaTileEntities.java b/src/main/java/gregtech/loaders/preload/GT_Loader_MetaTileEntities.java index 21746cb215..ef66fcd1d1 100644 --- a/src/main/java/gregtech/loaders/preload/GT_Loader_MetaTileEntities.java +++ b/src/main/java/gregtech/loaders/preload/GT_Loader_MetaTileEntities.java @@ -1253,10 +1253,15 @@ public class GT_Loader_MetaTileEntities implements Runnable {//TODO CHECK CIRCUI ItemList.Machine_Multi_Assemblyline.set(new GT_MetaTileEntity_AssemblyLine(1170, "multimachine.assemblyline", "Assembling Line").getStackForm(1L)); GT_ModHandler.addCraftingRecipe(ItemList.Machine_Multi_Assemblyline.get(1L), bitsd, new Object[]{aTextWireCoil, "EME", aTextWireCoil, 'M', ItemList.Hull_IV, 'W', ItemList.Casing_Assembler, 'E', OrePrefixes.circuit.get(Materials.Elite), 'C', ItemList.Robot_Arm_IV}); - + ItemList.Machine_Multi_DieselEngine.set(new GT_MetaTileEntity_DieselEngine(1171, "multimachine.dieselengine", "Combustion Engine").getStackForm(1L)); GT_ModHandler.addCraftingRecipe(ItemList.Machine_Multi_DieselEngine.get(1L), bitsd, new Object[]{"PCP", "EME", "GWG", 'M', ItemList.Hull_EV, 'P', ItemList.Electric_Piston_EV, 'E', ItemList.Electric_Motor_EV, 'C', OrePrefixes.circuit.get(Materials.Elite), 'W', OrePrefixes.cableGt01.get(Materials.TungstenSteel), 'G', OrePrefixes.gearGt.get(Materials.Titanium)}); GT_ModHandler.addCraftingRecipe(ItemList.Casing_EngineIntake.get(1L), bitsd, new Object[]{"PhP", "RFR", aTextPlateWrench, 'R', OrePrefixes.pipeMedium.get(Materials.Titanium), 'F', ItemList.Casing_StableTitanium, 'P', OrePrefixes.rotor.get(Materials.Titanium)}); + + //add recipe here, also # is meta (for controller at least). How do I find the next open #? + ItemList.Machine_Multi_ExtremeDieselEngine.set(new GT_MetaTileEntity_ExtremeDieselEngine(5000, "multimachine.extremedieselengine", "Extreme Combustion Engine").getStackForm(1L)); + GT_ModHandler.addCraftingRecipe(ItemList.Machine_Multi_ExtremeDieselEngine.get(1L), bitsd, new Object[]{"PCP", "EME", "GWG", 'M', ItemList.Hull_IV, 'P', ItemList.Electric_Piston_IV, 'E', ItemList.Electric_Motor_IV, 'C', OrePrefixes.circuit.get(Materials.Master), 'W', OrePrefixes.cableGt01.get(Materials.HSSG), 'G', OrePrefixes.gearGt.get(Materials.TungstenSteel)}); + GT_ModHandler.addCraftingRecipe(ItemList.Casing_ExtremeEngineIntake.get(1L), bitsd, new Object[]{"PhP", "RFR", aTextPlateWrench, 'R', OrePrefixes.pipeMedium.get(Materials.TungstenSteel), 'F', ItemList.Casing_RobustTungstenSteel, 'P', OrePrefixes.rotor.get(Materials.TungstenSteel)}); ItemList.Machine_Multi_Cleanroom.set(new GT_MetaTileEntity_Cleanroom(1172, "multimachine.cleanroom", "Cleanroom Controller").getStackForm(1)); //If Cleanroom is enabled, add a recipe, else hide from NEI. diff --git a/src/main/resources/assets/gregtech/textures/blocks/iconsets/MACHINE_CASING_EXTREME_ENGINE_INTAKE.png b/src/main/resources/assets/gregtech/textures/blocks/iconsets/MACHINE_CASING_EXTREME_ENGINE_INTAKE.png new file mode 100644 index 0000000000..b9f96fbceb Binary files /dev/null and b/src/main/resources/assets/gregtech/textures/blocks/iconsets/MACHINE_CASING_EXTREME_ENGINE_INTAKE.png differ diff --git a/src/main/resources/assets/gregtech/textures/blocks/iconsets/OVERLAY_FRONT_EXTREME_DIESEL_ENGINE.png b/src/main/resources/assets/gregtech/textures/blocks/iconsets/OVERLAY_FRONT_EXTREME_DIESEL_ENGINE.png new file mode 100644 index 0000000000..bc1dd3f5f0 Binary files /dev/null and b/src/main/resources/assets/gregtech/textures/blocks/iconsets/OVERLAY_FRONT_EXTREME_DIESEL_ENGINE.png differ diff --git a/src/main/resources/assets/gregtech/textures/blocks/iconsets/OVERLAY_FRONT_EXTREME_DIESEL_ENGINE_ACTIVE.png b/src/main/resources/assets/gregtech/textures/blocks/iconsets/OVERLAY_FRONT_EXTREME_DIESEL_ENGINE_ACTIVE.png new file mode 100644 index 0000000000..b57178136f Binary files /dev/null and b/src/main/resources/assets/gregtech/textures/blocks/iconsets/OVERLAY_FRONT_EXTREME_DIESEL_ENGINE_ACTIVE.png differ diff --git a/src/main/resources/assets/gregtech/textures/gui/multimachines/LargeExtremeDieselEngine.png b/src/main/resources/assets/gregtech/textures/gui/multimachines/LargeExtremeDieselEngine.png new file mode 100644 index 0000000000..cfe27fccf1 Binary files /dev/null and b/src/main/resources/assets/gregtech/textures/gui/multimachines/LargeExtremeDieselEngine.png differ -- cgit From 861d9e5f29aecd68220841a66f75e7ce0bc107c2 Mon Sep 17 00:00:00 2001 From: Prometheus0000000 Date: Tue, 3 Nov 2020 19:21:06 -0500 Subject: Minor text fixes --- src/main/java/gregtech/api/util/GT_Recipe.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/main/java/gregtech/api') diff --git a/src/main/java/gregtech/api/util/GT_Recipe.java b/src/main/java/gregtech/api/util/GT_Recipe.java index 2ae67a572a..82e466257b 100644 --- a/src/main/java/gregtech/api/util/GT_Recipe.java +++ b/src/main/java/gregtech/api/util/GT_Recipe.java @@ -614,12 +614,12 @@ public class GT_Recipe implements Comparable { public static final GT_Recipe_Map sHammerRecipes = new GT_Recipe_Map(new HashSet<>(3800), "gt.recipe.hammer", "Forge Hammer", null, RES_PATH_GUI + "basicmachines/Hammer", 1, 1, 1, 0, 1, E, 1, E, true, true); public static final GT_Recipe_Map sAmplifiers = new GT_Recipe_Map(new HashSet<>(2), "gt.recipe.uuamplifier", "Amplifabricator", null, RES_PATH_GUI + "basicmachines/Amplifabricator", 1, 0, 1, 0, 1, E, 1, E, true, true); public static final GT_Recipe_Map sMassFabFakeRecipes = new GT_Recipe_Map(new HashSet<>(2), "gt.recipe.massfab", "Mass Fabrication", null, RES_PATH_GUI + "basicmachines/Massfabricator", 1, 0, 1, 0, 10, E, 1, E, true, true); - public static final GT_Recipe_Map_Fuel sDieselFuels = new GT_Recipe_Map_Fuel(new HashSet<>(20), "gt.recipe.dieselgeneratorfuel", "Diesel Generator Fuel", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); + public static final GT_Recipe_Map_Fuel sDieselFuels = new GT_Recipe_Map_Fuel(new HashSet<>(20), "gt.recipe.dieselgeneratorfuel", "Combustion Generator Fuels", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); public static final GT_Recipe_Map_Fuel sTurbineFuels = new GT_Recipe_Map_Fuel(new HashSet<>(25), "gt.recipe.gasturbinefuel", "Gas Turbine Fuel", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); - public static final GT_Recipe_Map_Fuel sHotFuels = new GT_Recipe_Map_Fuel(new HashSet<>(10), "gt.recipe.thermalgeneratorfuel", "Thermal Generator Fuel", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, false); + public static final GT_Recipe_Map_Fuel sHotFuels = new GT_Recipe_Map_Fuel(new HashSet<>(10), "gt.recipe.thermalgeneratorfuel", "Thermal Generator Fuels", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, false); public static final GT_Recipe_Map_Fuel sDenseLiquidFuels = new GT_Recipe_Map_Fuel(new HashSet<>(15), "gt.recipe.semifluidboilerfuels", "Semifluid Boiler Fuels", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); public static final GT_Recipe_Map_Fuel sPlasmaFuels = new GT_Recipe_Map_Fuel(new HashSet<>(100), "gt.recipe.plasmageneratorfuels", "Plasma Generator Fuels", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); - public static final GT_Recipe_Map_Fuel sMagicFuels = new GT_Recipe_Map_Fuel(new HashSet<>(100), "gt.recipe.magicfuels", "Magic Energy Absorber", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); + public static final GT_Recipe_Map_Fuel sMagicFuels = new GT_Recipe_Map_Fuel(new HashSet<>(100), "gt.recipe.magicfuels", "Magic Energy Absorber Fuels", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); public static final GT_Recipe_Map_Fuel sSmallNaquadahReactorFuels = new GT_Recipe_Map_Fuel(new HashSet<>(1), "gt.recipe.smallnaquadahreactor", "Naquadah Reactor MkI", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); public static final GT_Recipe_Map_Fuel sLargeNaquadahReactorFuels = new GT_Recipe_Map_Fuel(new HashSet<>(1), "gt.recipe.largenaquadahreactor", "Naquadah Reactor MkII", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); public static final GT_Recipe_Map_Fuel sHugeNaquadahReactorFuels = new GT_Recipe_Map_Fuel(new HashSet<>(1), "gt.recipe.fluidnaquadahreactor", "Naquadah Reactor MkIII", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); -- cgit From 9db3e6c47eb404abffe662573d7b1d7fa5302db6 Mon Sep 17 00:00:00 2001 From: bartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com> Date: Tue, 10 Nov 2020 17:40:35 +0100 Subject: Cleanroom Callback Rework --- .../metatileentity/IMachineCallback.java | 7 +++ .../GT_MetaTileEntity_BasicMachine.java | 49 +++++++++++++++----- .../multi/GT_MetaTileEntity_Cleanroom.java | 53 +++++++++++++--------- 3 files changed, 77 insertions(+), 32 deletions(-) create mode 100644 src/main/java/gregtech/api/interfaces/metatileentity/IMachineCallback.java (limited to 'src/main/java/gregtech/api') diff --git a/src/main/java/gregtech/api/interfaces/metatileentity/IMachineCallback.java b/src/main/java/gregtech/api/interfaces/metatileentity/IMachineCallback.java new file mode 100644 index 0000000000..9306ef28f3 --- /dev/null +++ b/src/main/java/gregtech/api/interfaces/metatileentity/IMachineCallback.java @@ -0,0 +1,7 @@ +package gregtech.api.interfaces.metatileentity; + +public interface IMachineCallback { + Machinetype getCallbackBase(); + void setCallbackBase(Machinetype callback); + Class getType(); +} \ No newline at end of file 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 1c5b90f7db..97daa6fc71 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 @@ -7,6 +7,7 @@ import gregtech.api.enums.Textures; import gregtech.api.gui.GT_Container_BasicMachine; import gregtech.api.gui.GT_GUIContainer_BasicMachine; import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMachineCallback; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.objects.GT_ItemStack; import gregtech.api.objects.GT_RenderedTexture; @@ -15,6 +16,7 @@ import gregtech.api.util.GT_OreDictUnificator; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Recipe.GT_Recipe_Map; import gregtech.api.util.GT_Utility; +import gregtech.common.tileentities.machines.multi.GT_MetaTileEntity_Cleanroom; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; @@ -37,7 +39,8 @@ import static gregtech.api.enums.GT_Values.debugCleanroom; * This is the main construct for my Basic Machines such as the Automatic Extractor * Extend this class to make a simple Machine */ -public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_BasicTank { +public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_BasicTank implements IMachineCallback { + /** * return values for checkRecipe() */ @@ -51,8 +54,11 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B public boolean mAllowInputFromOutputSide = false, mFluidTransfer = false, mItemTransfer = false, mHasBeenUpdated = false, mStuttering = false, mCharge = false, mDecharge = false; public int mMainFacing = -1, mProgresstime = 0, mMaxProgresstime = 0, mEUt = 0, mOutputBlocked = 0; public FluidStack mOutputFluid; - public String mGUIName = "", mNEIName = ""; - public GT_MetaTileEntity_MultiBlockBase mCleanroom; + public String mGUIName, mNEIName; + + + @Deprecated + public GT_MetaTileEntity_Cleanroom mCleanroom; /** * Contains the Recipe which has been previously used, or null if there was no previous Recipe, which could have been buffered */ @@ -125,6 +131,21 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B return true; } + @Override + public GT_MetaTileEntity_Cleanroom getCallbackBase() { + return this.mCleanroom; + } + + @Override + public void setCallbackBase(GT_MetaTileEntity_Cleanroom callback) { + this.mCleanroom = callback; + } + + @Override + public Class getType() { + return GT_MetaTileEntity_Cleanroom.class; + } + @Override public ITexture[][][] getTextureSet(ITexture[] aTextures) { ITexture[][][] rTextures = new ITexture[14][17][]; @@ -449,7 +470,7 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B if (getDrainableStack() == null) setDrainableStack(mOutputFluid.copy()); else if (mOutputFluid.isFluidEqual(getDrainableStack())) getDrainableStack().amount += mOutputFluid.amount; - for (int i = 0; i < mOutputItems.length; i++) mOutputItems[i] = null; + Arrays.fill(mOutputItems, null); mOutputFluid = null; mEUt = 0; mProgresstime = 0; @@ -518,7 +539,7 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B startProcess(); } else { mMaxProgresstime = 0; - for (int i = 0; i < mOutputItems.length; i++) mOutputItems[i] = null; + Arrays.fill(mOutputItems, null); mOutputFluid = null; } } @@ -584,7 +605,7 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B //Long EUt calculation long xEUt=aEUt; //Isnt too low EUt check? - long tempEUt = xEUt mCleanroom.mEfficiency) + if (mOutputItems[i] != null && getBaseMetaTileEntity().getRandomNumber(10000) > getCallbackBase().mEfficiency) { if (debugCleanroom) { GT_Log.out.println( "BasicMachine: Voiding output due to efficiency failure. mEfficiency = " + - mCleanroom.mEfficiency + getCallbackBase().mEfficiency ); } mOutputItems[i] = null; diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_Cleanroom.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_Cleanroom.java index 6ceebc3877..21a407f6e2 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_Cleanroom.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_Cleanroom.java @@ -5,10 +5,10 @@ import gregtech.api.enums.GT_Values; import gregtech.api.enums.Textures; import gregtech.api.gui.GT_GUIContainer_MultiMachine; import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMachineCallback; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicHull; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachine; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_Log; @@ -16,9 +16,9 @@ import gregtech.api.util.GT_Recipe; import net.minecraft.block.Block; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; import static gregtech.api.enums.GT_Values.debugCleanroom; -import static gregtech.api.enums.GT_Values.V; public class GT_MetaTileEntity_Cleanroom extends GT_MetaTileEntity_MultiBlockBase { private int mHeight = -1; @@ -207,24 +207,8 @@ public class GT_MetaTileEntity_Cleanroom extends GT_MetaTileEntity_MultiBlockBas if (this.mMaintenanceHatches.size() != 1 || this.mEnergyHatches.size() != 1 || mDoorCount != 2 || mHullCount > 10) { return false; } - for (int dX = -x + 1; dX <= x - 1; dX++) { - for (int dZ = -z + 1; dZ <= z - 1; dZ++) { - for (int dY = -1; dY >= y + 1; dY--) { - IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(dX, dY, dZ); - if (tTileEntity != null) { - IMetaTileEntity aMetaTileEntity = tTileEntity.getMetaTileEntity(); - if (aMetaTileEntity instanceof GT_MetaTileEntity_BasicMachine) { - if (debugCleanroom) { - GT_Log.out.println( - "Cleanroom: Machine detected, adding pointer back to cleanroom" - ); - } - ((GT_MetaTileEntity_BasicMachine) aMetaTileEntity).mCleanroom = this; - } - } - } - } - } + + setCallbacks(x, y, z, aBaseMetaTileEntity); if (doorState) { this.mEfficiency = Math.max(0, this.mEfficiency - 200); @@ -240,7 +224,34 @@ public class GT_MetaTileEntity_Cleanroom extends GT_MetaTileEntity_MultiBlockBas return mPlascreteCount>=20 && mGlassCount < (int) Math.floor(ratio); } - + + private void setCallbacks(int x, int y, int z, IGregTechTileEntity aBaseMetaTileEntity){ + for (int dX = -x + 1; dX <= x - 1; dX++) + for (int dZ = -z + 1; dZ <= z - 1; dZ++) + for (int dY = -1; dY >= y + 1; dY--) { + TileEntity tTileEntity = aBaseMetaTileEntity.getTileEntityOffset(dX, dY, dZ); + + if (tTileEntity instanceof IGregTechTileEntity) { + IMetaTileEntity iMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity(); + + if (iMetaTileEntity instanceof IMachineCallback) + checkAndSetCallback((IMachineCallback) iMetaTileEntity); + + } else if (tTileEntity instanceof IMachineCallback) + checkAndSetCallback((IMachineCallback) tTileEntity); + } + } + + @SuppressWarnings("unchecked") + private void checkAndSetCallback(IMachineCallback iMachineCallback) { + if (debugCleanroom) + GT_Log.out.println( + "Cleanroom: IMachineCallback detected, checking for cleanroom: " + (iMachineCallback.getType() == this.getClass()) + ); + if (iMachineCallback.getType() == this.getClass()) + ((IMachineCallback) iMachineCallback).setCallbackBase(this); + } + @Override public boolean allowGeneralRedstoneOutput(){ return true; -- cgit From b0b861120f91a2bf060c0fc6c6a2c0b20bce06df Mon Sep 17 00:00:00 2001 From: repo_alt Date: Sat, 14 Nov 2020 01:48:21 +0300 Subject: Miners may actually detect ores by the oredict https://github.com/GTNewHorizons/GT-New-Horizons-Modpack/issues/5468 --- src/main/java/gregtech/api/util/GT_Utility.java | 8 ++++++++ .../machines/basic/GT_MetaTileEntity_Miner.java | 19 ++++--------------- .../multi/GT_MetaTileEntity_OreDrillingPlantBase.java | 16 ++-------------- 3 files changed, 14 insertions(+), 29 deletions(-) (limited to 'src/main/java/gregtech/api') diff --git a/src/main/java/gregtech/api/util/GT_Utility.java b/src/main/java/gregtech/api/util/GT_Utility.java index a65ed00aed..cf7b86fe94 100644 --- a/src/main/java/gregtech/api/util/GT_Utility.java +++ b/src/main/java/gregtech/api/util/GT_Utility.java @@ -65,6 +65,7 @@ import net.minecraftforge.event.ForgeEventFactory; import net.minecraftforge.event.world.BlockEvent; import net.minecraftforge.fluids.*; import net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData; +import net.minecraftforge.oredict.OreDictionary; import java.lang.reflect.Constructor; import java.lang.reflect.Field; @@ -2489,5 +2490,12 @@ public class GT_Utility { public static boolean isPartOfOrePrefix(ItemStack aStack, OrePrefixes aPrefix){ return GT_OreDictUnificator.getAssociation(aStack) != null ? GT_OreDictUnificator.getAssociation(aStack).mPrefix.equals(aPrefix) : false; } + public static boolean isOre(ItemStack aStack) { + for (int id: OreDictionary.getOreIDs(aStack)) { + if (OreDictionary.getOreName(id).startsWith("ore")) + return true; + } + return false; + } } diff --git a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Miner.java b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Miner.java index 67683e4635..0db6b09a73 100644 --- a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Miner.java +++ b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Miner.java @@ -6,19 +6,14 @@ import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachine; import gregtech.api.objects.GT_RenderedTexture; -import gregtech.api.objects.ItemData; import gregtech.api.util.GT_Log; import gregtech.api.util.GT_ModHandler; -import gregtech.api.util.GT_OreDictUnificator; import gregtech.api.util.GT_Utility; -import gregtech.common.blocks.GT_Block_Ores_Abstract; -import gregtech.common.blocks.GT_TileEntity_Ores; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; import net.minecraft.world.ChunkPosition; @@ -192,15 +187,8 @@ public class GT_MetaTileEntity_Miner extends GT_MetaTileEntity_BasicMachine { for (int x = -radiusConfig; x <= radiusConfig; ++x) { Block block = aBaseMetaTileEntity.getBlockOffset(x, drillY, z); int blockMeta = aBaseMetaTileEntity.getMetaIDOffset(x, drillY, z); - if (block instanceof GT_Block_Ores_Abstract) { - TileEntity tTileEntity = getBaseMetaTileEntity().getTileEntityOffset(x, drillY, z); - if (tTileEntity instanceof GT_TileEntity_Ores && ((GT_TileEntity_Ores) tTileEntity).mNatural) - oreBlockPositions.add(new ChunkPosition(x, drillY, z)); - } else { - ItemData association = GT_OreDictUnificator.getAssociation(new ItemStack(block, 1, blockMeta)); - if (association != null && association.mPrefix.toString().startsWith("ore")) - oreBlockPositions.add(new ChunkPosition(x, drillY, z)); - } + if (GT_Utility.isOre(new ItemStack(block, 1, blockMeta))) + oreBlockPositions.add(new ChunkPosition(x, drillY, z)); } } } @@ -253,7 +241,8 @@ public class GT_MetaTileEntity_Miner extends GT_MetaTileEntity_BasicMachine { } public void mineBlock(IGregTechTileEntity aBaseMetaTileEntity, int x, int y, int z) { - if (!GT_Utility.eraseBlockByFakePlayer(getFakePlayer(aBaseMetaTileEntity), aBaseMetaTileEntity.getXCoord() + x, aBaseMetaTileEntity.getYCoord() + y, aBaseMetaTileEntity.getZCoord() + z, true)); + if (!GT_Utility.eraseBlockByFakePlayer(getFakePlayer(aBaseMetaTileEntity), aBaseMetaTileEntity.getXCoord() + x, aBaseMetaTileEntity.getYCoord() + y, aBaseMetaTileEntity.getZCoord() + z, true)) + return; ArrayList drops = getBlockDrops(aBaseMetaTileEntity.getBlockOffset(x, y, z), aBaseMetaTileEntity.getXCoord() + x, aBaseMetaTileEntity.getYCoord() + y, aBaseMetaTileEntity.getZCoord() + z); if (drops.size() > 0) mOutputItems[0] = drops.get(0); diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlantBase.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlantBase.java index 3c59bee520..3bfb18be2b 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlantBase.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlantBase.java @@ -11,8 +11,6 @@ import gregtech.api.objects.ItemData; import gregtech.api.util.GT_OreDictUnificator; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; -import gregtech.common.blocks.GT_Block_Ores_Abstract; -import gregtech.common.blocks.GT_TileEntity_Ores; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; @@ -318,17 +316,8 @@ public abstract class GT_MetaTileEntity_OreDrillingPlantBase extends GT_MetaTile Block block = getBaseMetaTileEntity().getBlock(x, y, z); int blockMeta = getBaseMetaTileEntity().getMetaID(x, y, z); ChunkPosition blockPos = new ChunkPosition(x, y, z); - if (oreBlockPositions.contains(blockPos)) - return; - if (block instanceof GT_Block_Ores_Abstract) { - TileEntity tTileEntity = getBaseMetaTileEntity().getTileEntity(x, y, z); - if (tTileEntity instanceof GT_TileEntity_Ores && ((GT_TileEntity_Ores) tTileEntity).mNatural) - oreBlockPositions.add(blockPos); - } else { - ItemData association = GT_OreDictUnificator.getAssociation(new ItemStack(block, 1, blockMeta)); - if (association != null && association.mPrefix.toString().startsWith("ore")) - oreBlockPositions.add(blockPos); - } + if (!oreBlockPositions.contains(blockPos) && GT_Utility.isOre(new ItemStack(block, 1, blockMeta))) + oreBlockPositions.add(blockPos); } protected abstract int getRadiusInChunks(); @@ -337,7 +326,6 @@ public abstract class GT_MetaTileEntity_OreDrillingPlantBase extends GT_MetaTile protected String[] getDescriptionInternal(String tierSuffix) { String casings = getCasingBlockItem().get(0).getDisplayName(); - int d = getRadiusInChunks() * 2; return new String[]{ "Controller Block for the Ore Drilling Plant " + (tierSuffix != null ? tierSuffix : ""), "Size(WxHxD): 3x7x3, Controller (Front middle bottom)", -- cgit From 5b19a45b3a5278213da2181c11c9b3084f0e4a14 Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Sun, 15 Nov 2020 14:33:11 +0800 Subject: Clean up Extreme Diesel Engine Signed-off-by: Glease <4586901+Glease@users.noreply.github.com> --- src/main/java/gregtech/GT_Mod.java | 1 + src/main/java/gregtech/api/util/GT_Recipe.java | 1 + .../multi/GT_MetaTileEntity_DieselEngine.java | 7 +- .../GT_MetaTileEntity_ExtremeDieselEngine.java | 152 ++------------------- .../postload/GT_ExtremeDieselFuelLoader.java | 19 +++ 5 files changed, 42 insertions(+), 138 deletions(-) create mode 100644 src/main/java/gregtech/loaders/postload/GT_ExtremeDieselFuelLoader.java (limited to 'src/main/java/gregtech/api') diff --git a/src/main/java/gregtech/GT_Mod.java b/src/main/java/gregtech/GT_Mod.java index 27932b98c2..55ee8f3c55 100644 --- a/src/main/java/gregtech/GT_Mod.java +++ b/src/main/java/gregtech/GT_Mod.java @@ -936,6 +936,7 @@ public class GT_Mod implements IGT_Mod { Items.diamond_axe.setMaxDamage(768); Items.diamond_hoe.setMaxDamage(768); } + new GT_ExtremeDieselFuelLoader().run(); GT_Log.out.println("GT_Mod: Adding buffered Recipes."); GT_ModHandler.stopBufferingCraftingRecipes(); diff --git a/src/main/java/gregtech/api/util/GT_Recipe.java b/src/main/java/gregtech/api/util/GT_Recipe.java index 2ae67a572a..abbb6aef1b 100644 --- a/src/main/java/gregtech/api/util/GT_Recipe.java +++ b/src/main/java/gregtech/api/util/GT_Recipe.java @@ -615,6 +615,7 @@ public class GT_Recipe implements Comparable { public static final GT_Recipe_Map sAmplifiers = new GT_Recipe_Map(new HashSet<>(2), "gt.recipe.uuamplifier", "Amplifabricator", null, RES_PATH_GUI + "basicmachines/Amplifabricator", 1, 0, 1, 0, 1, E, 1, E, true, true); public static final GT_Recipe_Map sMassFabFakeRecipes = new GT_Recipe_Map(new HashSet<>(2), "gt.recipe.massfab", "Mass Fabrication", null, RES_PATH_GUI + "basicmachines/Massfabricator", 1, 0, 1, 0, 10, E, 1, E, true, true); public static final GT_Recipe_Map_Fuel sDieselFuels = new GT_Recipe_Map_Fuel(new HashSet<>(20), "gt.recipe.dieselgeneratorfuel", "Diesel Generator Fuel", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); + public static final GT_Recipe_Map_Fuel sExtremeDieselFuels = new GT_Recipe_Map_Fuel(new HashSet<>(20), "gt.recipe.extremedieselgeneratorfuel", "Extreme Diesel Engine Fuel", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); public static final GT_Recipe_Map_Fuel sTurbineFuels = new GT_Recipe_Map_Fuel(new HashSet<>(25), "gt.recipe.gasturbinefuel", "Gas Turbine Fuel", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); public static final GT_Recipe_Map_Fuel sHotFuels = new GT_Recipe_Map_Fuel(new HashSet<>(10), "gt.recipe.thermalgeneratorfuel", "Thermal Generator Fuel", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, false); public static final GT_Recipe_Map_Fuel sDenseLiquidFuels = new GT_Recipe_Map_Fuel(new HashSet<>(15), "gt.recipe.semifluidboilerfuels", "Semifluid Boiler Fuels", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DieselEngine.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DieselEngine.java index c37a5a9976..a957535990 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DieselEngine.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DieselEngine.java @@ -74,10 +74,15 @@ public class GT_MetaTileEntity_DieselEngine extends GT_MetaTileEntity_MultiBlock return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "LargeDieselEngine.png"); } + // can't use getRecipeMap() or else the fluid hatch will reject oxygen + protected GT_Recipe.GT_Recipe_Map_Fuel getFuelMap() { + return GT_Recipe.GT_Recipe_Map.sDieselFuels; + } + @Override public boolean checkRecipe(ItemStack aStack) { ArrayList tFluids = getStoredFluids(); - Collection tRecipeList = GT_Recipe.GT_Recipe_Map.sDieselFuels.mRecipeList; + Collection tRecipeList = getFuelMap().mRecipeList; if(tFluids.size() > 0 && tRecipeList != null) { //Does input hatch have a diesel fuel? for (FluidStack hatchFluid1 : tFluids) { //Loops through hatches diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ExtremeDieselEngine.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ExtremeDieselEngine.java index f38f0a1de2..b13ed587e3 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ExtremeDieselEngine.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ExtremeDieselEngine.java @@ -25,7 +25,7 @@ import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; import net.minecraftforge.fluids.FluidStack; -public class GT_MetaTileEntity_ExtremeDieselEngine extends GT_MetaTileEntity_MultiBlockBase { +public class GT_MetaTileEntity_ExtremeDieselEngine extends GT_MetaTileEntity_DieselEngine { protected int fuelConsumption = 0; protected int fuelValue = 0; protected int fuelRemaining = 0; @@ -39,6 +39,7 @@ public class GT_MetaTileEntity_ExtremeDieselEngine extends GT_MetaTileEntity_Mul super(aName); } + @Override public String[] getDescription() { return new String[]{ "Controller Block for the Extreme Combustion Engine", @@ -59,6 +60,12 @@ public class GT_MetaTileEntity_ExtremeDieselEngine extends GT_MetaTileEntity_Mul "Causes " + 20 * getPollutionPerTick(null) + " Pollution per second"}; } + @Override + protected GT_Recipe.GT_Recipe_Map_Fuel getFuelMap() { + return GT_Recipe.GT_Recipe_Map.sExtremeDieselFuels; + } + + @Override public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { if (aSide == aFacing) { return new ITexture[]{Textures.BlockIcons.casingTexturePages[0][60], new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_EXTREME_DIESEL_ENGINE_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_EXTREME_DIESEL_ENGINE)}; @@ -67,181 +74,58 @@ public class GT_MetaTileEntity_ExtremeDieselEngine extends GT_MetaTileEntity_Mul } @Override - public boolean isCorrectMachinePart(ItemStack aStack) { - return getMaxEfficiency(aStack) > 0; - } - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "LargeExtremeDieselEngine.png");//change } - - @Override - public boolean checkRecipe(ItemStack aStack) { - ArrayList tFluids = getStoredFluids(); - Collection tRecipeList = GT_Recipe.GT_Recipe_Map.sDieselFuels.mRecipeList; - - if(tFluids.contains(Materials.GasolinePremium.getFluid(4L))) { //Does input hatch contain HOG? - for (FluidStack hatchFluid1 : tFluids) { //Loops through hatches - for(GT_Recipe aFuel : tRecipeList) { //Loops through diesel fuel recipes dd. Can't remove because I suck at coding - FluidStack tLiquid; - - if ((tLiquid = GT_Utility.getFluidForFilledItem(aFuel.getRepresentativeInput(0), true)) != null) { //Create fluidstack from current recipe - if (hatchFluid1.isFluidEqual(tLiquid)) { //Has a diesel fluid - fuelConsumption = tLiquid.amount = boostEu ? (8192 / aFuel.mSpecialValue) : (2048 / aFuel.mSpecialValue); //Calc fuel consumption - if(depleteInput(tLiquid)) { //Deplete that amount ^Doesn't give bonus to fuel usage anymore - boostEu = depleteInput(Materials.LiquidOxygen.getGas(16L));//x8, and LOX instead - if(tFluids.contains(Materials.Lubricant.getFluid(8L))) { //Has lubricant? - //Deplete Lubricant. 8000L should = 1 hour of runtime (if baseEU = 8192) - if(mRuntime % 72 == 0 || mRuntime == 0) depleteInput(Materials.Lubricant.getFluid(boostEu ? 16 : 8));//x8 - } else return false; - - fuelValue = aFuel.mSpecialValue; - fuelRemaining = hatchFluid1.amount; //Record available fuel - this.mEUt = mEfficiency < 2000 ? 0 : 8192; //Output 0 if startup is less than 20% - this.mProgresstime = 1; //will output 8192 normally, 32768 boosted - this.mMaxProgresstime = 1; - this.mEfficiencyIncrease = 15; - return true; - } - } - } - } - } - } - this.mEUt = 0; - this.mEfficiency = 0; - return false; - } - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - byte tSide = getBaseMetaTileEntity().getBackFacing(); - int tX = getBaseMetaTileEntity().getXCoord(); - int tY = getBaseMetaTileEntity().getYCoord(); - int tZ = getBaseMetaTileEntity().getZCoord(); - - if(getBaseMetaTileEntity().getBlockAtSideAndDistance(tSide, 1) != getGearboxBlock() && getBaseMetaTileEntity().getBlockAtSideAndDistance(tSide, 2) != getGearboxBlock()) { - return false; - } - if(getBaseMetaTileEntity().getMetaIDAtSideAndDistance(tSide, 1) != getGearboxMeta() && getBaseMetaTileEntity().getMetaIDAtSideAndDistance(tSide, 2) != getGearboxMeta()) { - return false; - } - for (byte i = -1; i < 2; i = (byte) (i + 1)) { - for (byte j = -1; j < 2; j = (byte) (j + 1)) { - if ((i != 0) || (j != 0)) { - for (byte k = 0; k < 4; k = (byte) (k + 1)) { - - final int fX = tX - (tSide == 5 ? 1 : tSide == 4 ? -1 : i), - fZ = tZ - (tSide == 2 ? -1 : tSide == 3 ? 1 : i), - aY = tY + j, - aX = tX + (tSide == 5 ? k : tSide == 4 ? -k : i), - aZ = tZ + (tSide == 2 ? -k : tSide == 3 ? k : i); - - final Block frontAir = getBaseMetaTileEntity().getBlock(fX, aY, fZ); - final String frontAirName = frontAir.getUnlocalizedName(); - if(!(getBaseMetaTileEntity().getAir(fX, aY, fZ) || frontAirName.equalsIgnoreCase("tile.air") || frontAirName.equalsIgnoreCase("tile.railcraft.residual.heat"))) { - return false; //Fail if vent blocks are obstructed - } - - if (((i == 0) || (j == 0)) && ((k == 1) || (k == 2))) { - if (getBaseMetaTileEntity().getBlock(aX, aY, aZ) == getCasingBlock() && getBaseMetaTileEntity().getMetaID(aX, aY, aZ) == getCasingMeta()) { - // Do nothing - } else if (!addMufflerToMachineList(getBaseMetaTileEntity().getIGregTechTileEntity(tX + (tSide == 5 ? 2 : tSide == 4 ? -2 : 0), tY + 1, tZ + (tSide == 3 ? 2 : tSide == 2 ? -2 : 0)), getCasingTextureIndex())) { - return false; //Fail if no muffler top middle back - } else if (!addToMachineList(getBaseMetaTileEntity().getIGregTechTileEntity(aX, aY, aZ))) { - return false; - } - } else if (k == 0) { - if(!(getBaseMetaTileEntity().getBlock(aX, aY, aZ) == getIntakeBlock() && getBaseMetaTileEntity().getMetaID(aX, aY, aZ) == getIntakeMeta())) { - return false; - } - } else if (getBaseMetaTileEntity().getBlock(aX, aY, aZ) == getCasingBlock() && getBaseMetaTileEntity().getMetaID(aX, aY, aZ) == getCasingMeta()) { - // Do nothing - } else { - return false; - } - } - } - } - } - this.mDynamoHatches.clear(); - IGregTechTileEntity tTileEntity = getBaseMetaTileEntity().getIGregTechTileEntityAtSideAndDistance(getBaseMetaTileEntity().getBackFacing(), 3); - if ((tTileEntity != null) && (tTileEntity.getMetaTileEntity() != null)) { - if ((tTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_Hatch_Dynamo)) { - this.mDynamoHatches.add((GT_MetaTileEntity_Hatch_Dynamo) tTileEntity.getMetaTileEntity()); - ((GT_MetaTileEntity_Hatch) tTileEntity.getMetaTileEntity()).updateTexture(getCasingTextureIndex()); - } else { - return false; - } - } - return true; - } - public Block getCasingBlock() {//changed to RTSMC return GregTech_API.sBlockCasings4; } + @Override public byte getCasingMeta() {//same return 0; } + @Override public Block getIntakeBlock() { return GregTech_API.sBlockCasings8;//added new } + @Override public byte getIntakeMeta() {//same return 4; } + @Override public Block getGearboxBlock() { return GregTech_API.sBlockCasings2; } + @Override public byte getGearboxMeta() { return 4; } + @Override public byte getCasingTextureIndex() {//should be what hatches/busses change to? return 60; } - private boolean addToMachineList(IGregTechTileEntity tTileEntity) { - return ((addMaintenanceToMachineList(tTileEntity, getCasingTextureIndex())) || (addInputToMachineList(tTileEntity, getCasingTextureIndex())) || (addOutputToMachineList(tTileEntity, getCasingTextureIndex())) || (addMufflerToMachineList(tTileEntity, getCasingTextureIndex()))); - } - @Override public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { return new GT_MetaTileEntity_ExtremeDieselEngine(this.mName); } @Override - public void saveNBTData(NBTTagCompound aNBT) { - super.saveNBTData(aNBT); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - super.loadNBTData(aNBT); - } - - @Override - public int getDamageToComponent(ItemStack aStack) { - return 1; - } - public int getMaxEfficiency(ItemStack aStack) { return boostEu ? 40000 : 10000;//4x output if boosted instead of x3 } @Override public int getPollutionPerTick(ItemStack aStack) { - return 192;//x8 - } - - @Override - public boolean explodesOnComponentBreak(ItemStack aStack) { - return true; + return super.getPollutionPerTick(aStack) * 8;//x8 } @Override @@ -280,10 +164,4 @@ public class GT_MetaTileEntity_ExtremeDieselEngine extends GT_MetaTileEntity_Mul }; } - - @Override - public boolean isGivingInformation() { - return true; - } - } diff --git a/src/main/java/gregtech/loaders/postload/GT_ExtremeDieselFuelLoader.java b/src/main/java/gregtech/loaders/postload/GT_ExtremeDieselFuelLoader.java new file mode 100644 index 0000000000..9828ea33af --- /dev/null +++ b/src/main/java/gregtech/loaders/postload/GT_ExtremeDieselFuelLoader.java @@ -0,0 +1,19 @@ +package gregtech.loaders.postload; + +import gregtech.api.enums.Materials; +import gregtech.api.util.GT_Log; +import gregtech.api.util.GT_Recipe; + +public class GT_ExtremeDieselFuelLoader implements Runnable { + @Override + public void run() { + GT_Log.out.println("GT_Mod: Adding extreme diesel fuel."); + for (GT_Recipe r : GT_Recipe.GT_Recipe_Map.sDieselFuels.mRecipeList) { + if (r.mFluidInputs.length == 1 && Materials.GasolinePremium.getFluid(1).isFluidEqual(r.mFluidInputs[0])) { + GT_Recipe.GT_Recipe_Map.sExtremeDieselFuels.add(r); + return; + } + } + GT_Log.out.println("GT_Mod: No extreme diesel fuel found."); + } +} -- cgit From 9b78fafdd1c78ff95c095cf25c2c54c368a7cf23 Mon Sep 17 00:00:00 2001 From: korneel vandamme Date: Mon, 16 Nov 2020 00:40:25 +0100 Subject: add moveMultipleItemStacks to utils --- src/main/java/gregtech/api/util/GT_Utility.java | 103 +++++++++++++++++++++++- 1 file changed, 102 insertions(+), 1 deletion(-) (limited to 'src/main/java/gregtech/api') diff --git a/src/main/java/gregtech/api/util/GT_Utility.java b/src/main/java/gregtech/api/util/GT_Utility.java index cf7b86fe94..9f39ac3522 100644 --- a/src/main/java/gregtech/api/util/GT_Utility.java +++ b/src/main/java/gregtech/api/util/GT_Utility.java @@ -522,6 +522,107 @@ public class GT_Utility { return aSlot < aTileEntity.getSizeInventory() && aTileEntity.isItemValidForSlot(aSlot, aStack); } + /** + * moves multiple stacks from Inv-Side to Inv-Side + * + * @return the Amount of moved Items + */ + + public static int moveMultipleItemStacks(Object aTileEntity1, Object aTileEntity2, byte aGrabFrom, byte aPutTo, List aFilter, boolean aInvertFilter, byte aMaxTargetStackSize, byte aMinTargetStackSize, byte aMaxMoveAtOnce, byte aMinMoveAtOnce,int aStackAmount) { + if (aTileEntity1 instanceof IInventory) + return moveMultipleItemStacks((IInventory) aTileEntity1, aTileEntity2, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce,aStackAmount, true); + return 0; + } + + public static int moveMultipleItemStacks(IInventory aTileEntity1, Object aTileEntity2, byte aGrabFrom, byte aPutTo, List aFilter, boolean aInvertFilter, byte aMaxTargetStackSize, byte aMinTargetStackSize, byte aMaxMoveAtOnce, byte aMinMoveAtOnce,int aMaxStackTransfer, boolean aDoCheckChests) { + if (aTileEntity1 == null || aMaxTargetStackSize <= 0 || aMinTargetStackSize <= 0 || aMaxMoveAtOnce <= 0 || aMinTargetStackSize > aMaxTargetStackSize || aMinMoveAtOnce > aMaxMoveAtOnce || aMaxStackTransfer == 0) + return 0; + int tGrabInventorySize = aTileEntity1.getSizeInventory(); + if (aTileEntity2 instanceof IInventory) + { + IInventory tPutInventory = (IInventory) aTileEntity2; + int tPutInventorySize = tPutInventory.getSizeInventory(); + int tFirstsValidSlot = 0,tStacksMoved = 0,tTotalItemsMoved = 0; + for (int tGrabSlot = 0;tGrabSlot= aMinMoveAtOnce && isAllowedToTakeFromSlot(aTileEntity1, tGrabSlot, aGrabFrom, tGrabStack))) { + int tStackSize = tGrabStack.stackSize; + int tMovedItems = 0; + for (int tPutSlot = tFirstsValidSlot;tPutSlot 0) { + if (++tStacksMoved >= aMaxStackTransfer) + return tTotalItemsMoved; + } + } + } + if (aDoCheckChests && aTileEntity1 instanceof TileEntityChest) { + TileEntityChest tTileEntity1 = (TileEntityChest) aTileEntity1; + int tAmount = 0; + int maxStackTransfer = aMaxStackTransfer - tStacksMoved; + if (tTileEntity1.adjacentChestXNeg != null) { + tAmount = moveMultipleItemStacks(tTileEntity1.adjacentChestXNeg, aTileEntity2, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce,maxStackTransfer, false); + } else if (tTileEntity1.adjacentChestZNeg != null) { + tAmount = moveMultipleItemStacks(tTileEntity1.adjacentChestZNeg, aTileEntity2, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce,maxStackTransfer, false); + } else if (tTileEntity1.adjacentChestXPos != null) { + tAmount = moveMultipleItemStacks(tTileEntity1.adjacentChestXPos, aTileEntity2, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce,maxStackTransfer, false); + } else if (tTileEntity1.adjacentChestZPos != null) { + tAmount = moveMultipleItemStacks(tTileEntity1.adjacentChestZPos, aTileEntity2, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce,maxStackTransfer, false); + } + if (tAmount != 0) return tAmount+tTotalItemsMoved; + } + + if (aDoCheckChests && aTileEntity2 instanceof TileEntityChest) { + TileEntityChest tTileEntity2 = (TileEntityChest) aTileEntity2; + if (tTileEntity2.adjacentChestChecked) { + int tAmount = 0; + int maxStackTransfer = aMaxStackTransfer - tStacksMoved; + if (tTileEntity2.adjacentChestXNeg != null) { + tAmount = moveMultipleItemStacks(aTileEntity1, tTileEntity2.adjacentChestXNeg, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce,maxStackTransfer, false); + } else if (tTileEntity2.adjacentChestZNeg != null) { + tAmount = moveMultipleItemStacks(aTileEntity1, tTileEntity2.adjacentChestZNeg, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce,maxStackTransfer, false); + } else if (tTileEntity2.adjacentChestXPos != null) { + tAmount = moveMultipleItemStacks(aTileEntity1, tTileEntity2.adjacentChestXPos, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce,maxStackTransfer, false); + } else if (tTileEntity2.adjacentChestZPos != null) { + tAmount = moveMultipleItemStacks(aTileEntity1, tTileEntity2.adjacentChestZPos, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce,maxStackTransfer, false); + } + if (tAmount != 0) return tAmount+tTotalItemsMoved; + } + } + + return tTotalItemsMoved; + + } + //there should be a function to transfer more then 1 stack in a pipe + //ut i dont see any ways to improve it too much work for what it is worth + int[] tGrabSlots = new int[tGrabInventorySize]; + for (int i = 0; i < tGrabInventorySize; i++) { + tGrabSlots[i] = i; + } + int tTotalItemsMoved = 0; + for (int i = 0; i < tGrabInventorySize; i++) { + int tMoved = moveStackIntoPipe(aTileEntity1, aTileEntity2, tGrabSlots, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce, aDoCheckChests); + if (tMoved == 0) + return tTotalItemsMoved; + else + tTotalItemsMoved += tMoved; + } + return 0; + } + + /** * Moves Stack from Inv-Side to Inv-Side. * @@ -539,7 +640,7 @@ public class GT_Utility { private static byte moveOneItemStack(IInventory aTileEntity1, Object aTileEntity2, byte aGrabFrom, byte aPutTo, List aFilter, boolean aInvertFilter, byte aMaxTargetStackSize, byte aMinTargetStackSize, byte aMaxMoveAtOnce, byte aMinMoveAtOnce, boolean aDoCheckChests) { if (aTileEntity1 == null || aMaxTargetStackSize <= 0 || aMinTargetStackSize <= 0 || aMaxMoveAtOnce <= 0 || aMinTargetStackSize > aMaxTargetStackSize || aMinMoveAtOnce > aMaxMoveAtOnce) return 0; - + int[] tGrabSlots = null; if (aTileEntity1 instanceof ISidedInventory) tGrabSlots = ((ISidedInventory) aTileEntity1).getAccessibleSlotsFromSide(aGrabFrom); -- cgit From 997abcd915717c11dd7bd1423e41512cb1446e53 Mon Sep 17 00:00:00 2001 From: korneel vandamme Date: Mon, 16 Nov 2020 00:40:58 +0100 Subject: use moveMultipleItemStacks to variuos functions --- .../implementations/GT_MetaPipeEntity_Item.java | 2 +- .../GT_MetaTileEntity_BasicMachine.java | 16 ++++++++--- .../implementations/GT_MetaTileEntity_Buffer.java | 4 +-- .../GT_MetaTileEntity_Hatch_OutputBus.java | 11 +++++--- .../gregtech/common/covers/GT_Cover_Conveyor.java | 32 +++++++++++++++------- 5 files changed, 44 insertions(+), 21 deletions(-) (limited to 'src/main/java/gregtech/api') diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Item.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Item.java index 650e9a031e..c73e95e95b 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Item.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Item.java @@ -270,7 +270,7 @@ public class GT_MetaPipeEntity_Item extends MetaPipeEntity implements IMetaTileE TileEntity tInventory = getBaseMetaTileEntity().getTileEntityAtSide(aSide); if (tInventory != null && !(tInventory instanceof BaseMetaPipeEntity)) { if ((!(tInventory instanceof TileEntityHopper) && !(tInventory instanceof TileEntityDispenser)) || getBaseMetaTileEntity().getMetaIDAtSide(aSide) != GT_Utility.getOppositeSide(aSide)) { - return GT_Utility.moveOneItemStack(aSender, tInventory, (byte) 6, GT_Utility.getOppositeSide(aSide), null, false, (byte) 64, (byte) 1, (byte) 64, (byte) 1) > 0; + return GT_Utility.moveMultipleItemStacks(aSender, tInventory, (byte) 6, GT_Utility.getOppositeSide(aSide), null, false, (byte) 64, (byte) 1, (byte) 64, (byte) 1,1) > 0; } } } 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 97daa6fc71..2c632c596b 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 @@ -32,6 +32,7 @@ import java.util.Arrays; import static gregtech.api.enums.GT_Values.V; import static gregtech.api.enums.GT_Values.debugCleanroom; +import static gregtech.api.util.GT_Utility.moveMultipleItemStacks; /** * NEVER INCLUDE THIS FILE IN YOUR MOD!!! @@ -510,10 +511,17 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B if (doesAutoOutput() && !isOutputEmpty() && aBaseMetaTileEntity.getFrontFacing() != mMainFacing && (tSucceeded || mOutputBlocked % 300 == 1 || aBaseMetaTileEntity.hasInventoryBeenModified() || aTick % 600 == 0)) { TileEntity tTileEntity2 = aBaseMetaTileEntity.getTileEntityAtSide(aBaseMetaTileEntity.getFrontFacing()); - for (int i = 0, tCosts = 1; i < mOutputItems.length && tCosts > 0 && aBaseMetaTileEntity.isUniversalEnergyStored(128); i++) { - tCosts = GT_Utility.moveOneItemStack(aBaseMetaTileEntity, tTileEntity2, aBaseMetaTileEntity.getFrontFacing(), aBaseMetaTileEntity.getBackFacing(), null, false, (byte) 64, (byte) 1, (byte) 64, (byte) 1); - if (tCosts > 0) aBaseMetaTileEntity.decreaseStoredEnergyUnits(tCosts, true); - } + long tStoredEnergy = aBaseMetaTileEntity.getUniversalEnergyStored(); + int tMaxStacks = (int)(tStoredEnergy/64l); + if (tMaxStacks > mOutputItems.length) + tMaxStacks = mOutputItems.length; + + int tCost = moveMultipleItemStacks(aBaseMetaTileEntity, tTileEntity2, aBaseMetaTileEntity.getFrontFacing(), aBaseMetaTileEntity.getBackFacing(), null, false, (byte) 64, (byte) 1, (byte) 64, (byte) 1,tMaxStacks); + aBaseMetaTileEntity.decreaseStoredEnergyUnits(tCost, true); +// for (int i = 0, tCosts = 1; i < mOutputItems.length && tCosts > 0 && aBaseMetaTileEntity.isUniversalEnergyStored(128); i++) { +// tCosts = GT_Utility.moveOneItemStack(aBaseMetaTileEntity, tTileEntity2, aBaseMetaTileEntity.getFrontFacing(), aBaseMetaTileEntity.getBackFacing(), null, false, (byte) 64, (byte) 1, (byte) 64, (byte) 1); +// if (tCosts > 0) aBaseMetaTileEntity.decreaseStoredEnergyUnits(tCosts, true); +// } } if (mOutputBlocked != 0) if (isOutputEmpty()) mOutputBlocked = 0; 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 645836a801..7284cd3c01 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 @@ -259,9 +259,9 @@ public abstract class GT_MetaTileEntity_Buffer extends GT_MetaTileEntity_TieredM protected void moveItems(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { int tCost; if( bStockingMode ) - tCost = GT_Utility.moveOneItemStack(aBaseMetaTileEntity, aBaseMetaTileEntity.getTileEntityAtSide(aBaseMetaTileEntity.getBackFacing()), aBaseMetaTileEntity.getBackFacing(), aBaseMetaTileEntity.getFrontFacing(), null, false, mTargetStackSize == 0 ? 64 : (byte) mTargetStackSize, mTargetStackSize == 0 ? 1 : (byte) mTargetStackSize, (byte) 64, (byte) 1); + tCost = GT_Utility.moveMultipleItemStacks(aBaseMetaTileEntity, aBaseMetaTileEntity.getTileEntityAtSide(aBaseMetaTileEntity.getBackFacing()), aBaseMetaTileEntity.getBackFacing(), aBaseMetaTileEntity.getFrontFacing(), null, false, mTargetStackSize == 0 ? 64 : (byte) mTargetStackSize, mTargetStackSize == 0 ? 1 : (byte) mTargetStackSize, (byte) 64, (byte) 1,1); else - tCost = GT_Utility.moveOneItemStack(aBaseMetaTileEntity, aBaseMetaTileEntity.getTileEntityAtSide(aBaseMetaTileEntity.getBackFacing()), aBaseMetaTileEntity.getBackFacing(), aBaseMetaTileEntity.getFrontFacing(), null, false, (byte) 64, (byte) 1, mTargetStackSize == 0 ? 64 : (byte) mTargetStackSize, mTargetStackSize == 0 ? 1 : (byte) mTargetStackSize); + tCost = GT_Utility.moveMultipleItemStacks(aBaseMetaTileEntity, aBaseMetaTileEntity.getTileEntityAtSide(aBaseMetaTileEntity.getBackFacing()), aBaseMetaTileEntity.getBackFacing(), aBaseMetaTileEntity.getFrontFacing(), null, false, (byte) 64, (byte) 1, mTargetStackSize == 0 ? 64 : (byte) mTargetStackSize, mTargetStackSize == 0 ? 1 : (byte) mTargetStackSize,1); if (tCost > 0 || aBaseMetaTileEntity.hasInventoryBeenModified()) { mSuccess = 50; 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 6c56ac6a74..1dafbcce5a 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 @@ -12,6 +12,8 @@ import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; +import static gregtech.api.util.GT_Utility.*; + public class GT_MetaTileEntity_Hatch_OutputBus extends GT_MetaTileEntity_Hatch { public GT_MetaTileEntity_Hatch_OutputBus(int aID, String aName, String aNameRegional, int aTier) { super(aID, aName, aNameRegional, aTier, getSlots(aTier), new String[]{"Item Output for Multiblocks", @@ -112,10 +114,11 @@ public class GT_MetaTileEntity_Hatch_OutputBus extends GT_MetaTileEntity_Hatch { if (aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.isAllowedToWork() && (aTick&0x7)==0) { IInventory tTileEntity =aBaseMetaTileEntity.getIInventoryAtSide(aBaseMetaTileEntity.getFrontFacing()); if(tTileEntity!=null){ - for (ItemStack aMInventory : mInventory) - GT_Utility.moveOneItemStack(aBaseMetaTileEntity, tTileEntity, - aBaseMetaTileEntity.getFrontFacing(), aBaseMetaTileEntity.getBackFacing(), - null, false, (byte) 64, (byte) 1, (byte) 64, (byte) 1); + moveMultipleItemStacks(aBaseMetaTileEntity,tTileEntity,aBaseMetaTileEntity.getFrontFacing(),aBaseMetaTileEntity.getBackFacing(),null,false,(byte)64,(byte)1,(byte)64,(byte)1,mInventory.length); + +// GT_Utility.moveOneItemStack(aBaseMetaTileEntity, tTileEntity, +// aBaseMetaTileEntity.getFrontFacing(), aBaseMetaTileEntity.getBackFacing(), +// null, false, (byte) 64, (byte) 1, (byte)( 64 * aBaseMetaTileEntity.getSizeInventory()), (byte) 1); } } } diff --git a/src/main/java/gregtech/common/covers/GT_Cover_Conveyor.java b/src/main/java/gregtech/common/covers/GT_Cover_Conveyor.java index 303f358a34..aee46b7aab 100644 --- a/src/main/java/gregtech/common/covers/GT_Cover_Conveyor.java +++ b/src/main/java/gregtech/common/covers/GT_Cover_Conveyor.java @@ -14,6 +14,8 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.fluids.Fluid; +import static gregtech.api.util.GT_Utility.moveMultipleItemStacks; + public class GT_Cover_Conveyor extends GT_CoverBehavior { public final int mTickRate; private final int mMaxStacks; @@ -42,19 +44,29 @@ public class GT_Cover_Conveyor extends GT_CoverBehavior { boolean costsEnergy = ((aCoverVariable % 2 == 0) || (aSide != 1)) && ((aCoverVariable % 2 != 0) || (aSide != 0)) && (aTileEntity.getUniversalEnergyCapacity() >= 128L); byte moved; - for(int i=0 ; i < this.mMaxStacks ; i++) { - // Costs energy but we don't have enough, bail - if ((costsEnergy && !aTileEntity.isUniversalEnergyStored(256L))) - break; - moved = GT_Utility.moveOneItemStack(fromEntity, toEntity, fromSide , toSide, null, false, (byte) 64, (byte) 1, (byte) 64, (byte) 1); + if (costsEnergy) { + long tStoredEnergy = aTileEntity.getUniversalEnergyStored(); + int tMaxStacks = (int)(tStoredEnergy/(4*64*this.mMaxStacks)); + if (tMaxStacks > this.mMaxStacks) + tMaxStacks = this.mMaxStacks; + int tCost = moveMultipleItemStacks(fromEntity, toEntity, fromSide , toSide, null, false, (byte) 64, (byte) 1, (byte) 64, (byte) 1,tMaxStacks); + aTileEntity.decreaseStoredEnergyUnits(4 * tCost, true); + } else { + moveMultipleItemStacks(fromEntity, toEntity, fromSide , toSide, null, false, (byte) 64, (byte) 1, (byte) 64, (byte) 1,this.mMaxStacks); + } - if(moved == 0) - break; - if (costsEnergy) - aTileEntity.decreaseStoredEnergyUnits(4 * moved, true); - } +// for(int i=0 ; i < this.mMaxStacks ; i++) { +// // Costs energy but we don't have enough, bail +// if ((costsEnergy && !aTileEntity.isUniversalEnergyStored(256L))) +// break; +// +// moved = GT_Utility.moveOneItemStack(fromEntity, toEntity, fromSide , toSide, null, false, (byte) 64, (byte) 1, (byte) 64, (byte) 1); +// +// if(moved == 0) +// break; +// } return aCoverVariable; } -- cgit From 26fa46e05a12d507b484c86935574a078b58164b Mon Sep 17 00:00:00 2001 From: Prometheus0000000 Date: Wed, 18 Nov 2020 22:12:43 -0500 Subject: Add new method of displaying MB tooltips. LCR as example for now --- .../api/util/GT_Multiblock_Tooltip_Builder.java | 309 +++++++++++++++++++++ .../GT_MetaTileEntity_LargeChemicalReactor.java | 40 ++- src/main/resources/assets/gregtech/lang/en_US.lang | 21 ++ 3 files changed, 356 insertions(+), 14 deletions(-) create mode 100644 src/main/java/gregtech/api/util/GT_Multiblock_Tooltip_Builder.java (limited to 'src/main/java/gregtech/api') diff --git a/src/main/java/gregtech/api/util/GT_Multiblock_Tooltip_Builder.java b/src/main/java/gregtech/api/util/GT_Multiblock_Tooltip_Builder.java new file mode 100644 index 0000000000..c8914c0b7d --- /dev/null +++ b/src/main/java/gregtech/api/util/GT_Multiblock_Tooltip_Builder.java @@ -0,0 +1,309 @@ +package gregtech.api.util; + +import java.util.LinkedList; +import java.util.List; + +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.StatCollector; + +/** + * This makes it easier to build multi tooltips, with a standardized format.
+ * Info section order should be:
+ * addMachineType
+ * addInfo, for what it does, special notes, etc.
+ * addSeparator, if you need it
+ * addPollutionAmount
+ *
+ * Structure order should be:
+ * beginStructureBlock
+ * addController
+ * addCasingInfo
+ * addOtherStructurePart, for secondary structure block info (pipes, coils, etc)
+ * addEnergyHatch/addDynamoHatch
+ * addMaintenanceHatch
+ * addMufflerHatch
+ * addInputBus/addInputHatch/addOutputBus/addOutputHatch, in that order
+ * Use addStructureInfo for any comments on nonstandard structure info wherever needed + *
+ * toolTipFinisher
+ *
+ * Originally created by kekzdealer + */ +public class GT_Multiblock_Tooltip_Builder { + private static final String TAB = " "; + private static final String COLON = ": "; + + private final List iLines; + private final List sLines; + + private String[] iArray; + private String[] sArray; + + //Localized tooltips + private static final String TT_machineType = StatCollector.translateToLocal("GT5U.MBTT.MachineType"); + private static final String TT_dimensions = StatCollector.translateToLocal("GT5U.MBTT.Dimensions"); + private static final String TT_structure = StatCollector.translateToLocal("GT5U.MBTT.Structure"); + private static final String TT_controller = StatCollector.translateToLocal("GT5U.MBTT.Controller"); + private static final String TT_minimum = StatCollector.translateToLocal("GT5U.MBTT.Minimum"); + private static final String TT_maintenancehatch = StatCollector.translateToLocal("GT5U.MBTT.MaintenanceHatch"); + private static final String TT_energyhatch = StatCollector.translateToLocal("GT5U.MBTT.EnergyHatch"); + private static final String TT_dynamohatch = StatCollector.translateToLocal("GT5U.MBTT.DynamoHatch"); + private static final String TT_mufflerhatch = StatCollector.translateToLocal("GT5U.MBTT.MufflerHatch"); + private static final String TT_inputbus = StatCollector.translateToLocal("GT5U.MBTT.InputBus"); + private static final String TT_inputhatch = StatCollector.translateToLocal("GT5U.MBTT.InputHatch"); + private static final String TT_outputbus = StatCollector.translateToLocal("GT5U.MBTT.OutputBus"); + private static final String TT_outputhatch = StatCollector.translateToLocal("GT5U.MBTT.OutputHatch"); + private static final String TT_causes = StatCollector.translateToLocal("GT5U.MBTT.Causes"); + private static final String TT_pps = StatCollector.translateToLocal("GT5U.MBTT.PPS"); + private static final String TT_hold = StatCollector.translateToLocal("GT5U.MBTT.Hold"); + private static final String TT_todisplay = StatCollector.translateToLocal("GT5U.MBTT.Display"); + private static final String TT_mod = StatCollector.translateToLocal("GT5U.MBTT.Mod"); + + public GT_Multiblock_Tooltip_Builder() { + iLines = new LinkedList<>(); + sLines = new LinkedList<>(); + } + + /** + * Add a line telling you what the machine type is. Usually, this will be the name of a SB version.
+ * Machine Type: machine + * + * @param machine + * Name of the machine type + * + * @return Instance this method was called on. + */ + public GT_Multiblock_Tooltip_Builder addMachineType(String machine) { + iLines.add(TT_machineType + EnumChatFormatting.YELLOW + machine + EnumChatFormatting.RESET); + return this; + } + + /** + * Add a basic line of information about this structure + * + * @param info + * The line to be added. + * @return Instance this method was called on. + */ + public GT_Multiblock_Tooltip_Builder addInfo(String info) { + iLines.add(info); + return this; + } + + /** + * Add a separator line like this:
+ * ----------------------------------------- + * + * @return Instance this method was called on. + */ + public GT_Multiblock_Tooltip_Builder addSeparator() { + iLines.add("-----------------------------------------"); + return this; + } + + /** + * Add a line telling you what the machine type is. Usually, this will be the name of a SB version.
+ * Machine Type: machine + * + * @param machine + * Name of the machine type + * + * @return Instance this method was called on. + */ + public GT_Multiblock_Tooltip_Builder addPollutionAmount(int pollution) { + iLines.add(TT_causes + " " + EnumChatFormatting.DARK_PURPLE + pollution + " " + TT_pps + EnumChatFormatting.RESET); + return this; + } + + /** + * Begin adding structural information by adding a line about the structure's dimensions + * and then inserting a "Structure:" line. + * + * @param w + * Structure width. + * @param h + * Structure height. + * @param l + * Structure depth/length. + * @return Instance this method was called on. + */ + public GT_Multiblock_Tooltip_Builder beginStructureBlock(int w, int h, int l) { + sLines.add(TT_dimensions + w + "x" + h + "x" + l + " (WxHxL)"); + sLines.add(TT_structure); + return this; + } + + /** + * Add a line of information about the structure:
+ * (indent)Controller: info + * @param info + * Positional information. + * @return Instance this method was called on. + */ + public GT_Multiblock_Tooltip_Builder addController(String info) { + sLines.add(TAB + TT_controller + info); + return this; + } + + /** + * Add a line of information about the structure:
+ * (indent)minCountx casingName (minimum) + * @param casingName + * Name of the Casing. + * @param minCount + * Minimum needed for valid structure check. + * @return Instance this method was called on. + */ + public GT_Multiblock_Tooltip_Builder addCasingInfo(String casingName, int minCount) { + sLines.add(TAB + minCount +"x " + casingName + " " + TT_minimum); + return this; + } + + /** + * Use this method to add a structural part that isn't covered by the other methods.
+ * (indent)name: info + * @param name + * Name of the hatch or other component. + * @param info + * Positional information. + * @return Instance this method was called on. + */ + public GT_Multiblock_Tooltip_Builder addOtherStructurePart(String name, String info) { + sLines.add(TAB + name + info); + return this; + } + + /** + * Add a line of information about the structure:
+ * (indent)Maintenance Hatch: info + * @param info + * Positional information. + * @return Instance this method was called on. + */ + public GT_Multiblock_Tooltip_Builder addMaintenanceHatch(String info) { + sLines.add(TAB + TT_maintenancehatch + info); + return this; + } + + /** + * Add a line of information about the structure:
+ * (indent)Muffler Hatch: info + * @param info + * Location where the hatch goes + * @return Instance this method was called on. + */ + public GT_Multiblock_Tooltip_Builder addMufflerHatch(String info) { + sLines.add(TAB + TT_mufflerhatch + info); + return this; + } + + /** + * Add a line of information about the structure:
+ * (indent)Energy Hatch: info + * @param info + * Positional information. + * @return Instance this method was called on. + */ + public GT_Multiblock_Tooltip_Builder addEnergyHatch(String info) { + sLines.add(TAB + TT_energyhatch + info); + return this; + } + + /** + * Add a line of information about the structure:
+ * (indent)Dynamo Hatch: info + * @param info + * Positional information. + * @return Instance this method was called on. + */ + public GT_Multiblock_Tooltip_Builder addDynamoHatch(String info) { + sLines.add(TAB + TT_dynamohatch + info); + return this; + } + + /** + * Add a line of information about the structure:
+ * (indent)Input Bus: info + * @param info + * Location where the bus goes + * @return Instance this method was called on. + */ + public GT_Multiblock_Tooltip_Builder addInputBus(String info) { + sLines.add(TAB + TT_inputbus + info); + return this; + } + + /** + * Add a line of information about the structure:
+ * (indent)Input Hatch: info + * @param info + * Location where the hatch goes + * @return Instance this method was called on. + */ + public GT_Multiblock_Tooltip_Builder addInputHatch(String info) { + sLines.add(TAB + TT_inputhatch + info); + return this; + } + + /** + * Add a line of information about the structure:
+ * (indent)Output Bus: info + * @param info + * Location where the bus goes + * @return Instance this method was called on. + */ + public GT_Multiblock_Tooltip_Builder addOutputBus(String info) { + sLines.add(TAB + TT_outputbus + info); + return this; + } + + /** + * Add a line of information about the structure:
+ * (indent)Output Hatch: info + * @param info + * Location where the bus goes + * @return Instance this method was called on. + */ + public GT_Multiblock_Tooltip_Builder addOutputHatch(String info) { + sLines.add(TAB + TT_outputhatch + info); + return this; + } + + /** + * Use this method to add non-standard structural info.
+ * (indent)info + * @param info + * The line to be added. + * @return Instance this method was called on. + */ + public GT_Multiblock_Tooltip_Builder addStructureInfo(String info) { + sLines.add(TAB + info); + return this; + } + + /** + * Call at the very end.
+ * Adds a final line with the mod name and information on how to display the structure guidelines.
+ * Ends the building process. + * + * @param mod + * Name of the mod that adds this multiblock machine + */ + public void toolTipFinisher(String mod) { + iLines.add(TT_hold + " " + EnumChatFormatting.BOLD + "[LSHIFT]" + EnumChatFormatting.RESET + EnumChatFormatting.GRAY + " " + TT_todisplay); + iLines.add(TT_mod + " " + EnumChatFormatting.GREEN + mod + EnumChatFormatting.RESET); + iArray = new String[iLines.size()]; + sArray = new String[sLines.size()]; + iLines.toArray(iArray); + sLines.toArray(sArray); + } + + public String[] getInformation() { + return iArray; + } + + public String[] getStructureInformation() { + return sArray; + } + +} diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeChemicalReactor.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeChemicalReactor.java index fad880e5e4..c5f1852629 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeChemicalReactor.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeChemicalReactor.java @@ -8,6 +8,7 @@ import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; import net.minecraft.block.Block; @@ -18,6 +19,8 @@ import net.minecraftforge.fluids.FluidStack; import java.util.ArrayList; +import org.lwjgl.input.Keyboard; + public class GT_MetaTileEntity_LargeChemicalReactor extends GT_MetaTileEntity_MultiBlockBase { private final int CASING_INDEX = 176; @@ -37,20 +40,29 @@ public class GT_MetaTileEntity_LargeChemicalReactor extends GT_MetaTileEntity_Mu @Override public String[] getDescription() { - return new String[] { - "Controller block for the Large Chemical Reactor", - "Has the same recipes as the Chemical Reactor", - "Does not lose efficiency when overclocked", - "Accepts fluids instead of fluid cells", - "Size(WxHxD): 3x3x3", - "3x3x3 of Chemically Inert Machine Casings (hollow, min 8!)", - "Controller (Front centered)", - "1x PTFE Pipe Machine Casing (inside the hollow casings)", - "1x Cupronickel Coil Block (next to PTFE Pipe Machine Casing)", - "1x Input Bus/Hatch (Any inert casing)", - "1x Output Bus/Hatch (Any inert casing)", - "1x Maintenance Hatch (Any inert casing)", - "1x Energy Hatch (Any inert casing)"}; + final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType("Chemical Reactor") + .addInfo("Controller block for the Large Chemical Reactor") + .addInfo("Does not lose efficiency when overclocked") + .addInfo("Accepts fluids instead of fluid cells") + .beginStructureBlock(3, 3, 3) + .addController("Front centered") + .addCasingInfo("Chemically Inert Machine Casings", 8) + .addOtherStructurePart("PTFE Pipe Machine Casing", "Center") + .addOtherStructurePart("Cupronickel Coil Block", "Adjacent to the PTFE Pipe Machine Casing") + .addEnergyHatch("Any Casing") + .addMaintenanceHatch("Any Casing") + .addInputBus("Any Casing") + .addInputHatch("Any Casing") + .addOutputBus("Any Casing") + .addOutputHatch("Any Casing") + .addStructureInfo("You can have multiple I/O hatches/busses") + .toolTipFinisher("Gregtech"); + if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { + return tt.getInformation(); + } else { + return tt.getStructureInformation(); + } } @Override diff --git a/src/main/resources/assets/gregtech/lang/en_US.lang b/src/main/resources/assets/gregtech/lang/en_US.lang index 88616c6041..53970634f9 100644 --- a/src/main/resources/assets/gregtech/lang/en_US.lang +++ b/src/main/resources/assets/gregtech/lang/en_US.lang @@ -1,3 +1,24 @@ +# Multiblock Tooltip Builder Keywords +# Context can be found in the class gregtech.api.util.GT_Multiblock_Tooltip_Builder +GT5U.MBTT.MachineType=Machine Type: +GT5U.MBTT.Dimensions=Dimensions: +GT5U.MBTT.Structure=Structure: +GT5U.MBTT.Controller=Controller: +GT5U.MBTT.Minimum=(minimum) +GT5U.MBTT.MaintenanceHatch=Maintenance Hatch: +GT5U.MBTT.MufflerHatch=Muffler Hatch: +GT5U.MBTT.EnergyHatch=Energy Hatch: +GT5U.MBTT.DynamoHatch=Dynamo Hatch: +GT5U.MBTT.InputBus=Input Bus/ses: +GT5U.MBTT.InputHatch=Input Hatch/es: +GT5U.MBTT.OutputBus=Output Bus/ses: +GT5U.MBTT.OutputHatch=Output Hatch/es: +GT5U.MBTT.Causes=Causes: +GT5U.MBTT.PPS=pollution per second +GT5U.MBTT.Hold=Hold +GT5U.MBTT.Display=to display structure guidelines +GT5U.MBTT.Mod=Added by + GT5U.turbine.running.true=Turbine running GT5U.turbine.running.false=Turbine stopped GT5U.turbine.maintenance.false=No Maintainance issues -- cgit From dc56ad792448b7e5caa489841c71926a81afb840 Mon Sep 17 00:00:00 2001 From: korneel vandamme Date: Fri, 20 Nov 2020 03:15:33 +0100 Subject: add suport for drawers and barrels --- src/main/java/gregtech/api/util/GT_Utility.java | 39 +++++++++++++------------ 1 file changed, 20 insertions(+), 19 deletions(-) (limited to 'src/main/java/gregtech/api') diff --git a/src/main/java/gregtech/api/util/GT_Utility.java b/src/main/java/gregtech/api/util/GT_Utility.java index 9f39ac3522..b06cc1d82a 100644 --- a/src/main/java/gregtech/api/util/GT_Utility.java +++ b/src/main/java/gregtech/api/util/GT_Utility.java @@ -546,27 +546,28 @@ public class GT_Utility { for (int tGrabSlot = 0;tGrabSlot= aMinMoveAtOnce && isAllowedToTakeFromSlot(aTileEntity1, tGrabSlot, aGrabFrom, tGrabStack))) { - int tStackSize = tGrabStack.stackSize; - int tMovedItems = 0; - for (int tPutSlot = tFirstsValidSlot;tPutSlot= aMinMoveAtOnce && isAllowedToTakeFromSlot(aTileEntity1, tGrabSlot, aGrabFrom, tGrabStack))) { + int tStackSize = tGrabStack.stackSize; + tMovedItems = 0; + for (int tPutSlot = tFirstsValidSlot; tPutSlot < tPutInventorySize; tPutSlot++) { + if (isAllowedToPutIntoSlot(tPutInventory, tPutSlot, aPutTo, tGrabStack, (byte) 64)) { + int tMoved = moveStackFromSlotAToSlotB(aTileEntity1, tPutInventory, tGrabSlot, tPutSlot, aMaxTargetStackSize, aMinTargetStackSize, (byte) (aMaxMoveAtOnce - tMovedItems), aMinMoveAtOnce); + tTotalItemsMoved += tMoved; + tMovedItems += tMoved; + if (tMovedItems == tStackSize) + break; + } + } + if (tMovedItems > 0) { + if (++tStacksMoved >= aMaxStackTransfer) + return tTotalItemsMoved; } } - if (tMovedItems > 0) { - if (++tStacksMoved >= aMaxStackTransfer) - return tTotalItemsMoved; - } - } + } while (tGrabInventorySize == 2 && tMovedItems > 0); //to suport draweres and barrels } if (aDoCheckChests && aTileEntity1 instanceof TileEntityChest) { TileEntityChest tTileEntity1 = (TileEntityChest) aTileEntity1; -- cgit From 9d13d05f76fb34c5827959acb802b519531d3289 Mon Sep 17 00:00:00 2001 From: Prometheus0000000 Date: Thu, 19 Nov 2020 23:28:05 -0500 Subject: Change all the multi tooltips over. Also changed tooltip class a bit --- .../api/util/GT_Multiblock_Tooltip_Builder.java | 75 ++++++++++++++++------ .../multi/GT_MetaTileEntity_AssemblyLine.java | 42 ++++++++---- .../GT_MetaTileEntity_BrickedBlastFurnace.java | 29 +++++++-- .../GT_MetaTileEntity_BronzeBlastFurnace.java | 5 +- .../multi/GT_MetaTileEntity_Charcoal_Pit.java | 31 ++++++--- .../multi/GT_MetaTileEntity_Cleanroom.java | 43 ++++++++----- .../GT_MetaTileEntity_ConcreteBackfiller2.java | 42 ++++++++---- .../GT_MetaTileEntity_ConcreteBackfillerBase.java | 38 ++++++++--- .../multi/GT_MetaTileEntity_DieselEngine.java | 47 +++++++++----- .../multi/GT_MetaTileEntity_DistillationTower.java | 35 ++++++---- .../GT_MetaTileEntity_ElectricBlastFurnace.java | 48 +++++++++----- .../multi/GT_MetaTileEntity_FusionComputer1.java | 33 ++++++++-- .../multi/GT_MetaTileEntity_FusionComputer2.java | 34 +++++++--- .../multi/GT_MetaTileEntity_FusionComputer3.java | 34 +++++++--- .../multi/GT_MetaTileEntity_HeatExchanger.java | 37 ++++++++--- .../GT_MetaTileEntity_ImplosionCompressor.java | 35 ++++++---- .../multi/GT_MetaTileEntity_LargeBoiler.java | 44 ++++++++----- .../GT_MetaTileEntity_LargeChemicalReactor.java | 21 +++--- .../multi/GT_MetaTileEntity_LargeTurbine_Gas.java | 33 ++++++---- .../GT_MetaTileEntity_LargeTurbine_HPSteam.java | 35 ++++++---- .../GT_MetaTileEntity_LargeTurbine_Plasma.java | 32 ++++++--- .../GT_MetaTileEntity_LargeTurbine_Steam.java | 35 ++++++---- .../multi/GT_MetaTileEntity_MultiFurnace.java | 37 +++++++---- .../multi/GT_MetaTileEntity_OilCracker.java | 38 +++++++---- .../multi/GT_MetaTileEntity_OilDrillBase.java | 39 +++++++---- .../GT_MetaTileEntity_OreDrillingPlantBase.java | 46 ++++++++----- .../multi/GT_MetaTileEntity_ProcessingArray.java | 39 +++++++---- .../multi/GT_MetaTileEntity_PyrolyseOven.java | 44 ++++++++----- .../multi/GT_MetaTileEntity_VacuumFreezer.java | 30 ++++++--- src/main/resources/assets/gregtech/lang/en_US.lang | 27 ++++---- 30 files changed, 766 insertions(+), 342 deletions(-) (limited to 'src/main/java/gregtech/api') diff --git a/src/main/java/gregtech/api/util/GT_Multiblock_Tooltip_Builder.java b/src/main/java/gregtech/api/util/GT_Multiblock_Tooltip_Builder.java index c8914c0b7d..e30fe5d606 100644 --- a/src/main/java/gregtech/api/util/GT_Multiblock_Tooltip_Builder.java +++ b/src/main/java/gregtech/api/util/GT_Multiblock_Tooltip_Builder.java @@ -25,7 +25,7 @@ import net.minecraft.util.StatCollector; * addInputBus/addInputHatch/addOutputBus/addOutputHatch, in that order
* Use addStructureInfo for any comments on nonstandard structure info wherever needed *
- * toolTipFinisher
+ * toolTipFinisher goes at the very end
*
* Originally created by kekzdealer */ @@ -42,6 +42,7 @@ public class GT_Multiblock_Tooltip_Builder { //Localized tooltips private static final String TT_machineType = StatCollector.translateToLocal("GT5U.MBTT.MachineType"); private static final String TT_dimensions = StatCollector.translateToLocal("GT5U.MBTT.Dimensions"); + private static final String TT_hollow = StatCollector.translateToLocal("GT5U.MBTT.Hollow"); private static final String TT_structure = StatCollector.translateToLocal("GT5U.MBTT.Structure"); private static final String TT_controller = StatCollector.translateToLocal("GT5U.MBTT.Controller"); private static final String TT_minimum = StatCollector.translateToLocal("GT5U.MBTT.Minimum"); @@ -74,7 +75,7 @@ public class GT_Multiblock_Tooltip_Builder { * @return Instance this method was called on. */ public GT_Multiblock_Tooltip_Builder addMachineType(String machine) { - iLines.add(TT_machineType + EnumChatFormatting.YELLOW + machine + EnumChatFormatting.RESET); + iLines.add(TT_machineType + COLON + EnumChatFormatting.YELLOW + machine + EnumChatFormatting.RESET); return this; } @@ -111,7 +112,7 @@ public class GT_Multiblock_Tooltip_Builder { * @return Instance this method was called on. */ public GT_Multiblock_Tooltip_Builder addPollutionAmount(int pollution) { - iLines.add(TT_causes + " " + EnumChatFormatting.DARK_PURPLE + pollution + " " + TT_pps + EnumChatFormatting.RESET); + iLines.add(TT_causes + COLON + EnumChatFormatting.DARK_PURPLE + pollution + " " + EnumChatFormatting.GRAY + TT_pps); return this; } @@ -125,12 +126,50 @@ public class GT_Multiblock_Tooltip_Builder { * Structure height. * @param l * Structure depth/length. + * @param hollow + * T/F, adds a (hollow) comment if true * @return Instance this method was called on. */ - public GT_Multiblock_Tooltip_Builder beginStructureBlock(int w, int h, int l) { - sLines.add(TT_dimensions + w + "x" + h + "x" + l + " (WxHxL)"); - sLines.add(TT_structure); - return this; + public GT_Multiblock_Tooltip_Builder beginStructureBlock(int w, int h, int l, boolean hollow) { + if (hollow) { + sLines.add(TT_dimensions + COLON + w + "x" + h + "x" + l + " (WxHxL) " + TT_hollow); + } + else { + sLines.add(TT_dimensions + COLON + w + "x" + h + "x" + l + " (WxHxL)"); + } + sLines.add(TT_structure + COLON); + return this; + } + + /** + * Begin adding structural information by adding a line about the structure's dimensions
+ * and then inserting a "Structure:" line. Variable version displays min and max + * + * @param wmin + * Structure min width. + * @param wmax + * Structure max width. + * @param hmin + * Structure min height. + * @param hmax + * Structure max height. + * @param lmin + * Structure min depth/length. + * @param lmax + * Structure max depth/length. + * @param hollow + * T/F, adds a (hollow) comment if true + * @return Instance this method was called on. + */ + public GT_Multiblock_Tooltip_Builder beginVariableStructureBlock(int wmin, int wmax, int hmin, int hmax, int lmin, int lmax, boolean hollow) { + if (hollow) { + sLines.add(TT_dimensions + COLON + wmin + "-" + wmax + "x" + hmin + "-" + hmax + "x" + lmin + "-" + lmax + " (WxHxL) " + TT_hollow); + } + else { + sLines.add(TT_dimensions + COLON + wmin + "-" + wmax + "x" + hmin + "-" + hmax + "x" + lmin + "-" + lmax + " (WxHxL)"); + } + sLines.add(TT_structure + COLON); + return this; } /** @@ -141,7 +180,7 @@ public class GT_Multiblock_Tooltip_Builder { * @return Instance this method was called on. */ public GT_Multiblock_Tooltip_Builder addController(String info) { - sLines.add(TAB + TT_controller + info); + sLines.add(TAB + TT_controller + COLON + info); return this; } @@ -169,7 +208,7 @@ public class GT_Multiblock_Tooltip_Builder { * @return Instance this method was called on. */ public GT_Multiblock_Tooltip_Builder addOtherStructurePart(String name, String info) { - sLines.add(TAB + name + info); + sLines.add(TAB + name + COLON + info); return this; } @@ -181,7 +220,7 @@ public class GT_Multiblock_Tooltip_Builder { * @return Instance this method was called on. */ public GT_Multiblock_Tooltip_Builder addMaintenanceHatch(String info) { - sLines.add(TAB + TT_maintenancehatch + info); + sLines.add(TAB + TT_maintenancehatch + COLON + info); return this; } @@ -193,7 +232,7 @@ public class GT_Multiblock_Tooltip_Builder { * @return Instance this method was called on. */ public GT_Multiblock_Tooltip_Builder addMufflerHatch(String info) { - sLines.add(TAB + TT_mufflerhatch + info); + sLines.add(TAB + TT_mufflerhatch + COLON + info); return this; } @@ -205,7 +244,7 @@ public class GT_Multiblock_Tooltip_Builder { * @return Instance this method was called on. */ public GT_Multiblock_Tooltip_Builder addEnergyHatch(String info) { - sLines.add(TAB + TT_energyhatch + info); + sLines.add(TAB + TT_energyhatch + COLON + info); return this; } @@ -217,7 +256,7 @@ public class GT_Multiblock_Tooltip_Builder { * @return Instance this method was called on. */ public GT_Multiblock_Tooltip_Builder addDynamoHatch(String info) { - sLines.add(TAB + TT_dynamohatch + info); + sLines.add(TAB + TT_dynamohatch + COLON + info); return this; } @@ -229,7 +268,7 @@ public class GT_Multiblock_Tooltip_Builder { * @return Instance this method was called on. */ public GT_Multiblock_Tooltip_Builder addInputBus(String info) { - sLines.add(TAB + TT_inputbus + info); + sLines.add(TAB + TT_inputbus + COLON + info); return this; } @@ -241,7 +280,7 @@ public class GT_Multiblock_Tooltip_Builder { * @return Instance this method was called on. */ public GT_Multiblock_Tooltip_Builder addInputHatch(String info) { - sLines.add(TAB + TT_inputhatch + info); + sLines.add(TAB + TT_inputhatch + COLON + info); return this; } @@ -253,7 +292,7 @@ public class GT_Multiblock_Tooltip_Builder { * @return Instance this method was called on. */ public GT_Multiblock_Tooltip_Builder addOutputBus(String info) { - sLines.add(TAB + TT_outputbus + info); + sLines.add(TAB + TT_outputbus + COLON + info); return this; } @@ -265,7 +304,7 @@ public class GT_Multiblock_Tooltip_Builder { * @return Instance this method was called on. */ public GT_Multiblock_Tooltip_Builder addOutputHatch(String info) { - sLines.add(TAB + TT_outputhatch + info); + sLines.add(TAB + TT_outputhatch + COLON + info); return this; } @@ -291,7 +330,7 @@ public class GT_Multiblock_Tooltip_Builder { */ public void toolTipFinisher(String mod) { iLines.add(TT_hold + " " + EnumChatFormatting.BOLD + "[LSHIFT]" + EnumChatFormatting.RESET + EnumChatFormatting.GRAY + " " + TT_todisplay); - iLines.add(TT_mod + " " + EnumChatFormatting.GREEN + mod + EnumChatFormatting.RESET); + iLines.add(TT_mod + COLON + EnumChatFormatting.GREEN + mod + EnumChatFormatting.GRAY); iArray = new String[iLines.size()]; sArray = new String[sLines.size()]; iLines.toArray(iArray); diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AssemblyLine.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AssemblyLine.java index 67ce33f104..c90df2a7a7 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AssemblyLine.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AssemblyLine.java @@ -2,6 +2,8 @@ package gregtech.common.tileentities.machines.multi; import java.util.ArrayList; +import org.lwjgl.input.Keyboard; + import gregtech.api.GregTech_API; import gregtech.api.enums.GT_Values; import gregtech.api.enums.ItemList; @@ -14,6 +16,7 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_DataAccess; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; import net.minecraft.entity.player.InventoryPlayer; @@ -42,17 +45,34 @@ public class GT_MetaTileEntity_AssemblyLine } public String[] getDescription() { - return new String[]{"Assembling Line", - "Size: 3x(5-16)x4, variable length", - "From Bottom to Top, Left to Right", - "Layer 1 - Solid Steel Machine Casing, Input Bus (last is Output Bus), Solid Steel Machine Casing", - " - Casings can be replaced by Maint or Input Hatch", - "Layer 2 - Reinforced Glass, Assembling Line Casing, Reinforced Glass", - "Layer 3 - Grate Machine Casing, Assembler Machine Casing, Grate Machine Casing", - "Layer 4 - Empty, Solid Steel Machine Casing, Empty - Casing can be replaced by Energy Hatch", - "Up to 16 repeating slices, First replaces 1 Grate with Assembly Line,", - "Last has Output Bus instead of Input Bus", - "Optional - Replace 1x Grate with Data Access Hatch next to the Controller"}; + final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType("Assembling Line") + .addInfo("Controller block for the Assembling Line") + .addInfo("Used to make complex machine parts (LuV+)") + .addInfo("Does not make Assembler items") + .addSeparator() + .beginVariableStructureBlock(5, 15, 4, 4, 3, 3, false)//? + .addStructureInfo("From Bottom to Top, Left to Right") + .addStructureInfo("Layer 1 - Solid Steel Machine Casing, Input Bus (last is Output Bus), Solid Steel Machine Casing") + .addStructureInfo("Layer 2 - Reinforced Glass, Assembling Line Casing, Reinforced Glass") + .addStructureInfo("Layer 3 - Grate Machine Casing, Assembler Machine Casing, Grate Machine Casing") + .addStructureInfo("Layer 4 - Empty, Solid Steel Machine Casing, Empty") + .addStructureInfo("Up to 16 repeating slices, each one allows for 1 more item in recipes, aside from the last") + .addStructureInfo("Optional - Replace 1x Grate with (Advanced) Data Access Hatch next to the Controller") + .addStructureInfo("Optional - Replace 1x Grate with (Advanced) Data Access Hatch next to the Controller")//TT + + .addController("Either Grate on layer 3 of the first slice") + .addEnergyHatch("Any layer 4 casing") + .addMaintenanceHatch("Any layer 1 casing") + .addInputBus("As specified on layer 1") + .addInputHatch("Any layer 1 casing") + .addOutputBus("Replaces Input Bus on final slice") + .toolTipFinisher("Gregtech"); + if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { + return tt.getInformation(); + } else { + return tt.getStructureInformation(); + } } public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_BrickedBlastFurnace.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_BrickedBlastFurnace.java index 95b45e2cc4..eb1ce1348f 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_BrickedBlastFurnace.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_BrickedBlastFurnace.java @@ -1,11 +1,14 @@ package gregtech.common.tileentities.machines.multi; +import org.lwjgl.input.Keyboard; + import gregtech.api.GregTech_API; import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import net.minecraft.block.Block; public class GT_MetaTileEntity_BrickedBlastFurnace extends GT_MetaTileEntity_PrimitiveBlastFurnace{ @@ -26,13 +29,25 @@ public class GT_MetaTileEntity_BrickedBlastFurnace extends GT_MetaTileEntity_Pri } public String[] getDescription() { - return new String[]{ - "Controller Block for the Bricked Blast Furnace", - "Controller has to be placed in the (front) center of the second layer", - "Useable for Steel and general Pyrometallurgy", - "Size(WxHxD): 3x4x3 (Hollow, with opening on top)", - "Built from 32 Firebricks", - "Causes 200 Pollution per second"}; + final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType("Blast Furnace") + .addInfo("Controller Block for the Bricked Blast Furnace") + .addInfo("Usable for Steel and general Pyrometallurgy") + .addInfo("Has a useful interface, unlike other gregtech multis") + .addPollutionAmount(200) + .addSeparator() + .beginStructureBlock(3, 4, 3, true) + .addController("Front center") + .addOtherStructurePart("Firebricks", "Everything except the controller") + .addStructureInfo("The top block is also empty") + .addStructureInfo("You can share the walls of GT multis, so") + .addStructureInfo("each additional one costs less, up to 4") + .toolTipFinisher("Gregtech"); + if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { + return tt.getInformation(); + } else { + return tt.getStructureInformation(); + } } public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_BronzeBlastFurnace.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_BronzeBlastFurnace.java index 0ca5b79d68..af388a790d 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_BronzeBlastFurnace.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_BronzeBlastFurnace.java @@ -27,12 +27,13 @@ public class GT_MetaTileEntity_BronzeBlastFurnace } public String[] getDescription() { - return new String[]{ + return new String[]{"Disabled"}; + /*return new String[]{ "Controller Block for the Bronze Blast Furnace", "Useable for Steel and general Pyrometallurgy", "Size(WxHxD): 3x4x3 (Hollow, with opening on top)", "Built from 32 Bronze Plated Bricks", - "Causes 200 Pollution per second"}; + "Causes 200 Pollution per second"};*/ } public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_Charcoal_Pit.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_Charcoal_Pit.java index 8be3b10f54..8459f5e84b 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_Charcoal_Pit.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_Charcoal_Pit.java @@ -2,6 +2,8 @@ package gregtech.common.tileentities.machines.multi; import java.util.ArrayList; +import org.lwjgl.input.Keyboard; + import gregtech.api.GregTech_API; import gregtech.api.enums.OrePrefixes; import gregtech.api.enums.Textures; @@ -10,6 +12,7 @@ import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; import gregtech.common.GT_Pollution; import net.minecraft.block.Block; @@ -38,15 +41,25 @@ public class GT_MetaTileEntity_Charcoal_Pit extends GT_MetaTileEntity_MultiBlock } public String[] getDescription() { - return new String[]{ - "Controller for the Charcoal Pit", - "Converts Logs into Brittle Charcoal blocks", - "Max Size(WxHxD): 11x6x11, Controller (Top layer, centered)", - "11x1x11 of Bricks (Bottom layer only)", - "11x5x11 of Logs (Above bottom Brick layer)", - "Only grass/dirt can touch Log blocks", - "No air between logs allowed", - "Causes 100 Pollution per second"}; + final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType("Charcoal Pile Igniter") + .addInfo("Controller for the Charcoal Pit") + .addInfo("Converts Logs into Brittle Charcoal blocks") + .addInfo("Will automatically start when valid") + .addPollutionAmount(100) + .addSeparator() + .beginVariableStructureBlock(3, 11, 3, 6, 3, 11, false) + .addStructureInfo("Can be up to 11x6x11 in size, shape doesn't matter") + .addOtherStructurePart("Bricks", "Bottom layer, under all wood logs") + .addOtherStructurePart("Dirt/Grass", "All logs must be covered by these, the controller, or bricks") + .addOtherStructurePart("Wood Logs", "Inside the previously mentioned blocks") + .addStructureInfo("No air between logs allowed") + .toolTipFinisher("Gregtech"); + if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { + return tt.getInformation(); + } else { + return tt.getStructureInformation(); + } } public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_Cleanroom.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_Cleanroom.java index 21a407f6e2..606c63110f 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_Cleanroom.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_Cleanroom.java @@ -12,6 +12,7 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicHull; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_Log; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; import net.minecraft.block.Block; import net.minecraft.entity.player.InventoryPlayer; @@ -20,6 +21,8 @@ import net.minecraft.tileentity.TileEntity; import static gregtech.api.enums.GT_Values.debugCleanroom; +import org.lwjgl.input.Keyboard; + public class GT_MetaTileEntity_Cleanroom extends GT_MetaTileEntity_MultiBlockBase { private int mHeight = -1; @@ -38,21 +41,31 @@ public class GT_MetaTileEntity_Cleanroom extends GT_MetaTileEntity_MultiBlockBas @Override public String[] getDescription() { - return new String[]{ - "Controller Block for the Cleanroom", - "Min(WxHxD): 3x4x3 (Hollow), Max(WxHxD): 15x15x15 (Hollow)", - "Controller (Top center)", - "Top besides contoller and edges: Filter Machine Casing", - "1 Reinforced Door (keep closed for 100% efficency)", - "1x LV or 1x MV Energy Hatch, 1x Maintainance Hatch", - "Up to 10 Machine Hull Item & Energy transfer through walls", - "Remaining Blocks: Plascrete, 20 min", - GT_Values.cleanroomGlass+"% of the Plascrete can be Reinforced Glass (min 20 Plascrete still apply)", - "Consumes 40 EU/t when first turned on and 4 EU/t once at 100% efficiency when not overclocked", - "An energy hatch accepts up to 2A, so you can use 2A LV or 1A MV", - "2 LV batteries + 1 LV generator or 1 MV generator", - "Time required to reach full efficiency is propotional to the height of empty space within.", - "Make sure your Energy Hatch matches!"}; + final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType("Cleanroom") + .addInfo("Controller block for the Cleanroom") + .addInfo("Consumes 40 EU/t when first turned on and 4 EU/t once at 100% efficiency when not overclocked")//? + .addInfo("An energy hatch accepts up to 2A, so you can use 2A LV or 1A MV") + .addInfo("2 LV batteries + 1 LV generator or 1 MV generator")//? + .addInfo("Time required to reach full efficiency is propotional to the height of empty space within") + .addInfo("Make sure your Energy Hatch matches! ?") + .addSeparator() + .beginVariableStructureBlock(3, 15, 4, 15, 3, 15, true) + .addController("Top center") + .addCasingInfo("Plascrete", 20) + .addStructureInfo(GT_Values.cleanroomGlass+"% of the Plascrete can be replaced with Reinforced Glass")//check + .addOtherStructurePart("Filter Machine Casing", "Top besides controller and edges") + .addEnergyHatch("LV or MV, any casing")//check + .addMaintenanceHatch("Any casing") + .addStructureInfo("1x Reinforced Door (keep closed or efficiency will reduce)") + .addStructureInfo("Up to 10 Machine Hulls for Item & Energy transfer through walls") + .addStructureInfo("You can also use Diodes for more power") + .toolTipFinisher("Gregtech"); + if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { + return tt.getInformation(); + } else { + return tt.getStructureInformation(); + } } @Override diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ConcreteBackfiller2.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ConcreteBackfiller2.java index 0a68bd7b03..ed6c028243 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ConcreteBackfiller2.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ConcreteBackfiller2.java @@ -4,9 +4,12 @@ import gregtech.api.enums.ItemList; import gregtech.api.enums.Materials; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import static gregtech.api.enums.GT_Values.VN; +import org.lwjgl.input.Keyboard; + public class GT_MetaTileEntity_ConcreteBackfiller2 extends GT_MetaTileEntity_ConcreteBackfillerBase { public GT_MetaTileEntity_ConcreteBackfiller2(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); @@ -19,18 +22,33 @@ public class GT_MetaTileEntity_ConcreteBackfiller2 extends GT_MetaTileEntity_Con @Override public String[] getDescription() { String casings = getCasingBlockItem().get(0).getDisplayName(); - return new String[]{ - "Controller Block for the Advanced Concrete Backfiller", - "Size(WxHxD): 3x7x3", "Controller (Front middle at bottom)", - "3x1x3 Base of " + casings, - "1x3x1 " + casings + " pillar (Center of base)", - "1x3x1 " + getFrameMaterial().mName + " Frame Boxes (Each pillar side and on top)", - "1x Input Hatch (One of base casings)", - "1x Maintenance Hatch (One of base casings)", - "1x " + VN[getMinTier()] + "+ Energy Hatch (Any bottom layer casing)", - "Put Programmed Circuits into Data Access to config radius", - "Radius = (total config value)x2 blocks", - "Default 64, Maximum 128",}; + + final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType("Concrete Backfiller") + .addInfo("Controller Block for the Advanced Concrete Backfiller") + .addInfo("Will fill in areas below it with light concrete. This goes through walls") + .addInfo("Use it to remove any spawning locations beneath your base to reduce lag") + .addInfo("Will pull back the pipes after it finishes that layer") + .addInfo("Put Programmed Circuits into a Data Access Hatch to config radius. Buggy") + .addInfo("Radius = (total config value)x2 blocks. Default 64, Maximum 128")//broken + .addSeparator() + .beginStructureBlock(3, 7, 3, false) + .addController("Front bottom") + .addStructureInfo(casings + " form the 3x1x3 Base") + .addOtherStructurePart(casings, " 1x3x1 pillar above the center of the base (2 minimum total)") + .addOtherStructurePart(getFrameMaterial().mName + " Frame Boxes", "Each pillar's side and 1x3x1 on top") + .addEnergyHatch(VN[getMinTier()] + "+, Any base casing") + .addMaintenanceHatch("Any base casing") + .addStructureInfo("Data Access Hatch: Any base casing") + .addInputBus("Mining Pipes, optional, any base casing") + .addInputHatch("GT Concrete, any base casing") + .addOutputBus("Mining Pipes, optional, any base casing") + .toolTipFinisher("Gregtech"); + if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { + return tt.getInformation(); + } else { + return tt.getStructureInformation(); + } } @Override diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ConcreteBackfillerBase.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ConcreteBackfillerBase.java index a70b5d76b8..a65f4d0e86 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ConcreteBackfillerBase.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ConcreteBackfillerBase.java @@ -4,12 +4,15 @@ import gregtech.api.GregTech_API; import gregtech.api.enums.Materials; import gregtech.api.gui.GT_GUIContainer_MultiMachine; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Utility; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import static gregtech.api.enums.GT_Values.VN; +import org.lwjgl.input.Keyboard; + public abstract class GT_MetaTileEntity_ConcreteBackfillerBase extends GT_MetaTileEntity_DrillerBase { private int mLastXOff = 0, mLastZOff = 0; @@ -24,16 +27,31 @@ public abstract class GT_MetaTileEntity_ConcreteBackfillerBase extends GT_MetaTi protected String[] getDescriptionInternal(String tierSuffix) { String casings = getCasingBlockItem().get(0).getDisplayName(); - return new String[]{ - "Controller Block for the Concrete Backfiller " + (tierSuffix != null ? tierSuffix : ""), - "Size(WxHxD): 3x7x3", "Controller (Front middle at bottom)", - "3x1x3 Base of " + casings, - "1x3x1 " + casings + " pillar (Center of base)", - "1x3x1 " + getFrameMaterial().mName + " Frame Boxes (Each pillar side and on top)", - "1x Input Hatch (One of base casings)", - "1x Maintenance Hatch (One of base casings)", - "1x " + VN[getMinTier()] + "+ Energy Hatch (Any bottom layer casing)", - "Radius is " + getRadius() + " blocks"}; + + final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType("Concrete Backfiller") + .addInfo("Controller Block for the Concrete Backfiller " + (tierSuffix != null ? tierSuffix : ""))//Unused? + .addInfo("Will fill in areas below it with light concrete. This goes through walls") + .addInfo("Use it to remove any spawning locations beneath your base to reduce lag") + .addInfo("Will pull back the pipes after it finishes that layer") + .addInfo("Radius is " + getRadius() + " blocks") + .addSeparator() + .beginStructureBlock(3, 7, 3, false) + .addController("Front bottom") + .addStructureInfo(casings + " form the 3x1x3 Base") + .addOtherStructurePart(casings, " 1x3x1 pillar above the center of the base (2 minimum total)") + .addOtherStructurePart(getFrameMaterial().mName + " Frame Boxes", "Each pillar's side and 1x3x1 on top") + .addEnergyHatch(VN[getMinTier()] + "+, Any base casing") + .addMaintenanceHatch("Any base casing") + .addInputBus("Mining Pipes, optional, any base casing") + .addInputHatch("GT Concrete, any base casing") + .addOutputBus("Mining Pipes, optional, any base casing") + .toolTipFinisher("Gregtech"); + if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { + return tt.getInformation(); + } else { + return tt.getStructureInformation(); + } } @Override diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DieselEngine.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DieselEngine.java index c37a5a9976..36e607ce93 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DieselEngine.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DieselEngine.java @@ -3,6 +3,8 @@ package gregtech.common.tileentities.machines.multi; import java.util.ArrayList; import java.util.Collection; +import org.lwjgl.input.Keyboard; + import gregtech.api.GregTech_API; import gregtech.api.enums.Materials; import gregtech.api.enums.Textures; @@ -15,6 +17,7 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Dynam import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Muffler; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; import net.minecraft.block.Block; @@ -40,22 +43,34 @@ public class GT_MetaTileEntity_DieselEngine extends GT_MetaTileEntity_MultiBlock } public String[] getDescription() { - return new String[]{ - "Controller Block for the Large Combustion Engine", - "Size(WxHxD): 3x3x4, Controller (front centered)", - "3x3x4 of Stable Titanium Machine Casing (hollow, Min 16!)", - "2x Titanium Gear Box Machine Casing inside the Hollow Casing", - "8x Engine Intake Machine Casing (around controller)", - "2x Input Hatch (Fuel/Lubricant) (one of the Casings next to a Gear Box)", - "1x Maintenance Hatch (one of the Casings next to a Gear Box)", - "1x Muffler Hatch (top middle back, next to the rear Gear Box)", - "1x Dynamo Hatch (back centered)", - "Engine Intake Casings must not be obstructed in front (only air blocks)", - "Supply Flammable Fuels and 1000L of Lubricant per hour to run.", - "Supply 40L of Oxygen per second to boost output (optional).", - "Default: Produces 2048EU/t at 100% efficiency", - "Boosted: Produces 6144EU/t at 150% efficiency", - "Causes " + 20 * getPollutionPerTick(null) + " Pollution per second"}; + final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType("Combustion Generator") + .addInfo("Controller block for the Large Combustion Engine") + .addInfo("Supply Diesel Fuels and 1000L of Lubricant per hour to run") + .addInfo("Supply 40L/s of Oxygen to boost output (optional)") + .addInfo("Default: Produces 2048EU/t at 100% fuel efficiency") + .addInfo("Boosted: Produces 6144EU/t at 150% fuel efficiency") + .addInfo("You need to wait for it to reach 300% to output full power") + .addPollutionAmount(20 * getPollutionPerTick(null)) + .addSeparator() + .beginStructureBlock(3, 3, 4, false) + .addController("Front center") + .addCasingInfo("Stable Titanium Machine Casing", 16) + .addOtherStructurePart("Titanium Gear Box Machine Casing", "Inner 2 blocks") + .addOtherStructurePart("Engine Intake Machine Casing", "8x, ring around controller") + .addStructureInfo("Engine Intake Casings must not be obstructed in front (only air blocks)") + .addDynamoHatch("Back center") + .addMaintenanceHatch("One of the casings next to a Gear Box") + .addMufflerHatch("Top middle back, above the rear Gear Box") + .addInputHatch("Diesel Fuel, next to a Gear Box") + .addInputHatch("Lubricant, next to a Gear Box") + .addInputHatch("Oxygen, optional, next to a Gear Box") + .toolTipFinisher("Gregtech"); + if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { + return tt.getInformation(); + } else { + return tt.getStructureInformation(); + } } public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DistillationTower.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DistillationTower.java index 45ba3c97f5..12ab91d876 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DistillationTower.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DistillationTower.java @@ -10,6 +10,7 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Outpu import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; import net.minecraft.block.Block; @@ -20,6 +21,8 @@ import net.minecraftforge.fluids.FluidStack; import java.util.ArrayList; +import org.lwjgl.input.Keyboard; + public class GT_MetaTileEntity_DistillationTower extends GT_MetaTileEntity_MultiBlockBase { private static final int CASING_INDEX = 49; @@ -38,18 +41,26 @@ public class GT_MetaTileEntity_DistillationTower } public String[] getDescription() { - return new String[]{ - "Controller Block for the Distillation Tower", - "Size(WxHxD): 3xhx3 (Hollow), with h ranging from 3 to 12", - "Controller (Front bottom)", - "1x Input Hatch (Any bottom layer casing)", - "2-11x Output Hatch (One per layer except bottom layer)", - "1x Output Bus (Any bottom layer casing)", - "1x Maintenance Hatch (Any casing)", - "1x Energy Hatch (Any casing)", - "Fluids are only put out at the correct height", - "The correct height equals the slot number in the NEI recipe", - "Clean Stainless Steel Machine Casings for the rest (7 x h - 5 at least!)"}; + final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType("Distillery") + .addInfo("Controller block for the Distillation Tower") + .addInfo("Fluids are only put out at the correct height") + .addInfo("The correct height equals the slot number in the NEI recipe") + .addSeparator() + .beginVariableStructureBlock(3, 3, 3, 12, 3, 3, true) + .addController("Front bottom") + .addOtherStructurePart("Clean Stainless Steel Machine Casing", "7 x h - 5 (minimum)") + .addEnergyHatch("Any casing") + .addMaintenanceHatch("Any casing") + .addInputHatch("Any bottom layer casing") + .addOutputBus("Any bottom layer casing") + .addOutputHatch("2-11x Output Hatches (One per layer except bottom layer)") + .toolTipFinisher("Gregtech"); + if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { + return tt.getInformation(); + } else { + return tt.getStructureInformation(); + } } public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ElectricBlastFurnace.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ElectricBlastFurnace.java index df3dea34fa..061db80ece 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ElectricBlastFurnace.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ElectricBlastFurnace.java @@ -5,6 +5,8 @@ import static gregtech.api.enums.GT_Values.VN; import java.util.ArrayList; +import org.lwjgl.input.Keyboard; + import gregtech.api.GregTech_API; import gregtech.api.enums.Materials; import gregtech.api.enums.Textures; @@ -18,6 +20,7 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Outpu import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; import net.minecraft.entity.player.InventoryPlayer; @@ -47,22 +50,35 @@ public class GT_MetaTileEntity_ElectricBlastFurnace } public String[] getDescription() { - return new String[]{ - "Controller Block for the Blast Furnace", - "Size(WxHxD): 3x4x3 (Hollow), Controller (Front middle bottom)", - "16x Heating Coils (Two middle Layers, hollow)", - "1x Input Hatch/Bus (Any bottom layer casing)", - "1x Output Hatch/Bus (Any bottom layer casing)", - "1x Energy Hatch (Any bottom layer casing)", - "1x Maintenance Hatch (Any bottom layer casing)", - "1x Muffler Hatch (Top middle)", - "1x Output Hatch to recover CO2/CO/SO2 (optional, any top layer casing),", - " Recovery scales with Muffler Hatch tier", - "Heat Proof Machine Casings for the rest", - "Each 900K over the min. Heat Capacity multiplies eu/t by 0.95", - "Each 1800K over the min. Heat Capacity allows for one upgraded overclock", - "Upgraded overclocks reduce recipe time to 25% and increase EU/t to 400%", - "Causes " + 20 * getPollutionPerTick(null) + " Pollution per second"}; + final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType("Blast Furnace") + .addInfo("Controller block for the Electric Blast Furnace") + .addInfo("You can use some fluids to reduce recipe time. Place the circuit in the Input Bus") + .addInfo("Each 900K over the min. Heat required multiplies EU/t by 0.95") + .addInfo("Each 1800K over the min. Heat required allows for one upgraded overclock instead of normal") + .addInfo("Upgraded overclocks reduce recipe time to 25% (instead of 50%) and increase EU/t to 400%") + .addInfo("Additionally gives +100K for every tier past MV") + .addPollutionAmount(20 * getPollutionPerTick(null)) + .addSeparator() + .beginStructureBlock(3, 4, 3, true) + .addController("Front bottom") + .addCasingInfo("Heat Proof Machine Casing", 0) + .addOtherStructurePart("Heating Coils (any tier)", "Two middle Layers") + .addEnergyHatch("Any bottom layer casing") + .addMaintenanceHatch("Any bottom layer casing") + .addMufflerHatch("Top middle") + .addInputBus("Any bottom layer casing") + .addInputHatch("Any bottom layer casing") + .addOutputBus("Any bottom layer casing") + .addOutputHatch("Gasses, Any top layer casing") + .addStructureInfo("Recovery amount scales with Muffler Hatch tier") + .addOutputHatch("Platline fluids, Any bottom layer casing") + .toolTipFinisher("Gregtech"); + if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { + return tt.getInformation(); + } else { + return tt.getStructureInformation(); + } } public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer1.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer1.java index 77290441cd..9da832c81a 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer1.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer1.java @@ -1,10 +1,13 @@ package gregtech.common.tileentities.machines.multi; +import org.lwjgl.input.Keyboard; + import gregtech.api.GregTech_API; import gregtech.api.enums.Textures; import gregtech.api.interfaces.IIconContainer; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import net.minecraft.block.Block; public class GT_MetaTileEntity_FusionComputer1 extends GT_MetaTileEntity_FusionComputer { @@ -48,13 +51,29 @@ public class GT_MetaTileEntity_FusionComputer1 extends GT_MetaTileEntity_FusionC } public String[] getDescription() { - return new String[]{ - "It's over 9000!!!", - "LuV Machine Casings around Superconducting Coil Blocks", - "2-16 Input Hatches", "1-16 Output Hatches", - "1-16 Energy Hatches", - "All Hatches must be LuV or better", - "2048EU/t and 10mio EU Cap per Energy Hatch"}; + final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType("Fusion Reactor") + .addInfo("It's over 9000!!!") + .addInfo("Controller block for the Fusion Reactor Mk I") + .addInfo("2048EU/t and 10M EU capacity per Energy Hatch") + .addInfo("If the recipe has a startup cost greater than the") + .addInfo("number of energy hatches * cap, you can't do it") + .addSeparator() + .beginStructureBlock(15, 3, 15, false) + .addController("See diagram when placed") + .addCasingInfo("LuV Machine Casing", 79) + .addStructureInfo("Cover the coils with casing") + .addOtherStructurePart("Superconducting Coil Block", "Center part of the ring") + .addEnergyHatch("1-16, Specified casings") + .addInputHatch("2-16, Specified casings") + .addOutputHatch("1-16, Specified casings") + .addStructureInfo("ALL Hatches must be LuV or better") + .toolTipFinisher("Gregtech"); + if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { + return tt.getInformation(); + } else { + return tt.getStructureInformation(); + } } @Override diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer2.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer2.java index c091d637bc..7a363f8f6f 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer2.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer2.java @@ -1,10 +1,13 @@ package gregtech.common.tileentities.machines.multi; +import org.lwjgl.input.Keyboard; + import gregtech.api.GregTech_API; import gregtech.api.enums.Textures; import gregtech.api.interfaces.IIconContainer; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import net.minecraft.block.Block; public class GT_MetaTileEntity_FusionComputer2 extends GT_MetaTileEntity_FusionComputer { @@ -48,14 +51,29 @@ public class GT_MetaTileEntity_FusionComputer2 extends GT_MetaTileEntity_FusionC } public String[] getDescription() { - return new String[]{ - "It's over 9000!!!", - "Fusion Machine Casings around Fusion Coil Blocks", - "2-16 Input Hatches", - "1-16 Output Hatches", - "1-16 Energy Hatches", - "All Hatches must be ZPMV or better", - "4096EU/t and 20mio EU Cap per Energy Hatch"}; + final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType("Fusion Reactor") + .addInfo("It's over 9000!!!") + .addInfo("Controller block for the Fusion Reactor Mk II") + .addInfo("4096EU/t and 20M EU capacity per Energy Hatch") + .addInfo("If the recipe has a startup cost greater than the") + .addInfo("number of energy hatches * cap, you can't do it") + .addSeparator() + .beginStructureBlock(15, 3, 15, false) + .addController("See diagram when placed") + .addCasingInfo("Fusion Machine Casing", 79) + .addStructureInfo("Cover the coils with casing") + .addOtherStructurePart("Fusion Coil Block", "Center part of the ring") + .addEnergyHatch("1-16, Specified casings") + .addInputHatch("2-16, Specified casings") + .addOutputHatch("1-16, Specified casings") + .addStructureInfo("ALL Hatches must be ZPM or better") + .toolTipFinisher("Gregtech"); + if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { + return tt.getInformation(); + } else { + return tt.getStructureInformation(); + } } @Override diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer3.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer3.java index bc50b5ee5f..a575427791 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer3.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer3.java @@ -1,10 +1,13 @@ package gregtech.common.tileentities.machines.multi; +import org.lwjgl.input.Keyboard; + import gregtech.api.GregTech_API; import gregtech.api.enums.Textures; import gregtech.api.interfaces.IIconContainer; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import net.minecraft.block.Block; public class GT_MetaTileEntity_FusionComputer3 extends GT_MetaTileEntity_FusionComputer { @@ -48,14 +51,29 @@ public class GT_MetaTileEntity_FusionComputer3 extends GT_MetaTileEntity_FusionC } public String[] getDescription() { - return new String[]{ - "A SUN DOWN ON EARTH", - "Fusion Machine Casings MK II around Fusion Coil Blocks", - "2-16 Input Hatches", - "1-16 Output Hatches", - "1-16 Energy Hatches", - "All Hatches must be UV or better", - "8192EU/t and 40mio EU Cap per Energy Hatch"}; + final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType("Fusion Reactor") + .addInfo("A SUN DOWN ON EARTH") + .addInfo("Controller block for the Fusion Reactor Mk III") + .addInfo("8192EU/t and 40M EU capacity per Energy Hatch") + .addInfo("If the recipe has a startup cost greater than the") + .addInfo("number of energy hatches * cap, you can't do it") + .addSeparator() + .beginStructureBlock(15, 3, 15, false) + .addController("See diagram when placed") + .addCasingInfo("Fusion Machine Casing Mk II", 79) + .addStructureInfo("Cover the coils with casing") + .addOtherStructurePart("Fusion Coil Block", "Center part of the ring") + .addEnergyHatch("1-16, Specified casings") + .addInputHatch("2-16, Specified casings") + .addOutputHatch("1-16, Specified casings") + .addStructureInfo("ALL Hatches must be UV or better") + .toolTipFinisher("Gregtech"); + if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { + return tt.getInformation(); + } else { + return tt.getStructureInformation(); + } } @Override diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_HeatExchanger.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_HeatExchanger.java index 4dcd9121a8..dfa58c6407 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_HeatExchanger.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_HeatExchanger.java @@ -1,5 +1,7 @@ package gregtech.common.tileentities.machines.multi; +import org.lwjgl.input.Keyboard; + import gregtech.api.GregTech_API; import gregtech.api.enums.Textures; import gregtech.api.gui.GT_GUIContainer_MultiMachine; @@ -13,6 +15,7 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockB import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_Log; import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import net.minecraft.block.Block; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; @@ -41,16 +44,30 @@ public class GT_MetaTileEntity_HeatExchanger extends GT_MetaTileEntity_MultiBloc } public String[] getDescription() { - return new String[]{ - "Controller Block for the Heat Exchanger", - "Size(WxHxD): 3x4x3, Controller (Front middle at bottom)", - "3x3x4 of Stable Titanium Machine Casings (hollow, Min 20!)", - "2x Titanium Pipe Casing (Inside the Hollow Machine Casings)", - "1x Distillated Water Input (Any casing)", - "1x Steam Output (Any casing)", - "1x Hot Fluid Input (Bottom center)", - "1x Cold Fluid Output (Top Center)", - "1x Maintenance Hatch (Any casing)"}; + final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType("Heat Exchanger") + .addInfo("Controller Block for the Large Heat Exchanger") + .addInfo("More complicated than a Fusion Reactor. Seriously") + .addInfo("Inputs are Hot Coolant or Lava") + .addInfo("Outputs Coolant or Pahoehoe Lava and SH Steam/Steam") + .addInfo("Read the wiki article to understand how it works") + .addInfo("Then go to the Discord to understand the wiki") + .addSeparator() + .beginStructureBlock(3, 4, 3, false) + .addController("Front bottom") + .addCasingInfo("Stable Titanium Machine Casing", 20) + .addOtherStructurePart("Titanium Pipe Casing", "Center 2 blocks") + .addMaintenanceHatch("Any casing") + .addInputHatch("Hot fluid, bottom center") + .addInputHatch("Distilled water, any casing") + .addOutputHatch("Cold fluid, top center") + .addOutputHatch("Steam/SH Steam, any casing") + .toolTipFinisher("Gregtech"); + if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { + return tt.getInformation(); + } else { + return tt.getStructureInformation(); + } } @Override diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ImplosionCompressor.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ImplosionCompressor.java index edce80fdf4..9e002badbf 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ImplosionCompressor.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ImplosionCompressor.java @@ -8,6 +8,7 @@ import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; import net.minecraft.block.Block; @@ -17,6 +18,8 @@ import net.minecraftforge.common.util.ForgeDirection; import java.util.ArrayList; +import org.lwjgl.input.Keyboard; + public class GT_MetaTileEntity_ImplosionCompressor extends GT_MetaTileEntity_MultiBlockBase { public GT_MetaTileEntity_ImplosionCompressor(int aID, String aName, String aNameRegional) { @@ -32,17 +35,27 @@ public class GT_MetaTileEntity_ImplosionCompressor } public String[] getDescription() { - return new String[]{ - "Controller Block for the Implosion Compressor", - "Size(WxHxD): 3x3x3 (Hollow), Controller (Front centered)", - "1x Input Bus (Any casing)", - "1x Output Bus (Any casing)", - "1x Maintenance Hatch (Any casing)", - "1x Muffler Hatch (Any casing)", - "1x Energy Hatch (Any casing)", - "Solid Steel Machine Casings for the rest (16 at least!)", - "Casings can be replaced with Explosion Warning Signs", - "Causes " + 20 * getPollutionPerTick(null) + " Pollution per second"}; + final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType("Implosion Compressor") + .addInfo("Explosions are fun") + .addInfo("Controller block for the Implosion Compressor") + .addPollutionAmount(20 * getPollutionPerTick(null)) + .addSeparator() + .beginStructureBlock(3, 3, 3, true) + .addController("Front center") + .addCasingInfo("Solid Steel Machine Casing", 16) + .addStructureInfo("Casings can be replaced with Explosion Warning Signs") + .addEnergyHatch("Any casing") + .addMaintenanceHatch("Any casing") + .addMufflerHatch("Any casing") + .addInputBus("Any casing") + .addOutputBus("Any casing") + .toolTipFinisher("Gregtech"); + if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { + return tt.getInformation(); + } else { + return tt.getStructureInformation(); + } } public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeBoiler.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeBoiler.java index 0781397ecc..551abdf38a 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeBoiler.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeBoiler.java @@ -18,6 +18,8 @@ import net.minecraftforge.fluids.FluidStack; import java.util.ArrayList; +import org.lwjgl.input.Keyboard; + public abstract class GT_MetaTileEntity_LargeBoiler extends GT_MetaTileEntity_MultiBlockBase { private boolean firstRun = true; @@ -35,22 +37,32 @@ public abstract class GT_MetaTileEntity_LargeBoiler } public String[] getDescription() { - return new String[]{ - "Controller Block for the Large Boiler", - "Produces " + (getEUt() * 40) * (runtimeBoost(20) / 20f) + "L of Steam with 1 Coal at " + getEUt() * 40 + "L/s", - "A programmed circuit in the main block throttles the boiler (-1000L/s per config)", - "Size(WxHxD): 3x5x3, Controller (Front middle in Fireboxes)", - "3x1x3 of "+getCasingMaterial()+" Fire Boxes (Bottom layer, Min 3)", - "3x4x3 of "+getCasingMaterial()+" " +getCasingBlockType()+ " Casings (Above Fireboxes, hollow, Min 24!)", - "3 "+getCasingMaterial()+" Pipe Casing Blocks (Inside the Hollow Casing)", - "1x Input Fuel Hatch/Bus (Any Firebox)", - "1x Input Water Hatch (Any Firebox)", - "1x Output Hatch (Any Casing)", - "1x Maintenance Hatch (Any Firebox)", - "1x Muffler Hatch (Any Firebox)", - String.format("Diesel fuels have 1/4 efficiency - Takes %.2f seconds to heat up", 500.0 / getEfficiencyIncrease()), - "Causes up to " + 20 * getPollutionPerTick(null) + " Pollution per second" -}; + final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType("Boiler") + .addInfo("Controller block for the Large " + getCasingMaterial() + " Boiler") + .addInfo("Produces " + (getEUt() * 40) * (runtimeBoost(20) / 20f) + "L of Steam with 1 Coal at " + getEUt() * 40 + "L/s")//? + .addInfo("A programmed circuit in the main block throttles the boiler (-1000L/s per config)") + .addInfo(String.format("Diesel fuels have 1/4 efficiency - Takes %.2f seconds to heat up", 500.0 / getEfficiencyIncrease()))//? check semifluid again + .addPollutionAmount(20 * getPollutionPerTick(null)) + .addSeparator() + .beginStructureBlock(3, 5, 3, false) + .addController("Front bottom") + .addCasingInfo(getCasingMaterial() + " " + getCasingBlockType() + " Casing", 24)//? + .addOtherStructurePart(getCasingMaterial() + " Fire Boxes", "Bottom layer, 3 minimum") + .addOtherStructurePart(getCasingMaterial() + " Pipe Casing Blocks", "Inner 3 blocks") + .addMaintenanceHatch("Any firebox") + .addMufflerHatch("Any firebox") + .addInputBus("Solid fuel, Any firebox") + .addInputHatch("Liquid fuel, Any firebox") + .addStructureInfo("You can use either, or both") + .addInputHatch("Water, Any firebox") + .addOutputHatch("Steam, any casing") + .toolTipFinisher("Gregtech"); + if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { + return tt.getInformation(); + } else { + return tt.getStructureInformation(); + } } public abstract String getCasingMaterial(); diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeChemicalReactor.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeChemicalReactor.java index c5f1852629..d462b9a36d 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeChemicalReactor.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeChemicalReactor.java @@ -45,18 +45,19 @@ public class GT_MetaTileEntity_LargeChemicalReactor extends GT_MetaTileEntity_Mu .addInfo("Controller block for the Large Chemical Reactor") .addInfo("Does not lose efficiency when overclocked") .addInfo("Accepts fluids instead of fluid cells") - .beginStructureBlock(3, 3, 3) - .addController("Front centered") - .addCasingInfo("Chemically Inert Machine Casings", 8) + .addSeparator() + .beginStructureBlock(3, 3, 3, false) + .addController("Front center") + .addCasingInfo("Chemically Inert Machine Casing", 8) .addOtherStructurePart("PTFE Pipe Machine Casing", "Center") .addOtherStructurePart("Cupronickel Coil Block", "Adjacent to the PTFE Pipe Machine Casing") - .addEnergyHatch("Any Casing") - .addMaintenanceHatch("Any Casing") - .addInputBus("Any Casing") - .addInputHatch("Any Casing") - .addOutputBus("Any Casing") - .addOutputHatch("Any Casing") - .addStructureInfo("You can have multiple I/O hatches/busses") + .addEnergyHatch("Any casing") + .addMaintenanceHatch("Any casing") + .addInputBus("Any casing") + .addInputHatch("Any casing") + .addOutputBus("Any casing") + .addOutputHatch("Any casing") + .addStructureInfo("You can have multiple hatches/busses") .toolTipFinisher("Gregtech"); if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { return tt.getInformation(); diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Gas.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Gas.java index 4bd44ef80c..6c482db6e7 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Gas.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Gas.java @@ -3,12 +3,15 @@ package gregtech.common.tileentities.machines.multi; import java.util.ArrayList; import java.util.Collection; +import org.lwjgl.input.Keyboard; + import gregtech.api.GregTech_API; import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Recipe.GT_Recipe_Map; import gregtech.api.util.GT_Utility; @@ -31,18 +34,26 @@ public class GT_MetaTileEntity_LargeTurbine_Gas extends GT_MetaTileEntity_LargeT return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[1][aColorIndex + 1], aFacing == aSide ? aActive ? new GT_RenderedTexture(Textures.BlockIcons.LARGETURBINE_SS_ACTIVE5) : new GT_RenderedTexture(Textures.BlockIcons.LARGETURBINE_SS5) : Textures.BlockIcons.casingTexturePages[0][58]}; } - public String[] getDescription() { - return new String[]{ - "Controller Block for the Large Gas Turbine", - "Size(WxHxD): 3x3x4 (Hollow), Controller (Front centered)", - "1x Gas Input Hatch (Side centered)", - "1x Maintenance Hatch (Side centered)", - "1x Muffler Hatch (Side centered)", - "1x Dynamo Hatch (Back centered)", - "Stainless Steel Turbine Casings for the rest (24 at least!)", - "Needs a Turbine Item (Inside controller GUI)", - "Produces " + getPollutionPerTick(null)*20 + " pollution per second"}; + final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType("Gas Turbine") + .addInfo("Controller block for the Large Gas Turbine") + .addInfo("Needs a Turbine, place inside controller") + .addPollutionAmount(20 * getPollutionPerTick(null)) + .addSeparator() + .beginStructureBlock(3, 3, 4, true) + .addController("Front center") + .addCasingInfo("Stainless Steel Turbine Casing", 24) + .addDynamoHatch("Back center") + .addMaintenanceHatch("Side centered") + .addMufflerHatch("Side centered") + .addInputHatch("Gas Fuel, Side centered") + .toolTipFinisher("Gregtech"); + if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { + return tt.getInformation(); + } else { + return tt.getStructureInformation(); + } } public int getFuelValue(FluidStack aLiquid) { diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_HPSteam.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_HPSteam.java index c6f6e36c44..2355b89fa8 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_HPSteam.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_HPSteam.java @@ -4,6 +4,8 @@ import static gregtech.api.objects.XSTR.XSTR_INSTANCE; import java.util.ArrayList; +import org.lwjgl.input.Keyboard; + import gregtech.GT_Mod; import gregtech.api.GregTech_API; import gregtech.api.enums.Textures; @@ -12,6 +14,7 @@ import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Utility; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; @@ -38,17 +41,27 @@ public class GT_MetaTileEntity_LargeTurbine_HPSteam extends GT_MetaTileEntity_La } public String[] getDescription() { - return new String[]{ - "Controller Block for the Large High Pressure Steam Turbine", - "Size(WxHxD): 3x3x4 (Hollow), Controller (Front centered)", - "1x Superheated Steam Input Hatch (Side centered)", - "1x Maintenance Hatch (Side centered)", - "1x Dynamo Hatch (Back centered)", - "1x Output Hatch for Steam (Side centered)", - "Titanium Turbine Casings for the rest (24 at least!)", - "Needs a Turbine Item (Inside controller GUI)", - "Output depending on Rotor and fitting", - "Use screwdriver to adjust fitting of turbine"}; + final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType("Steam Turbine") + .addInfo("Controller block for the Large High Pressure Steam Turbine") + .addInfo("Needs a Turbine, place inside controller") + .addInfo("Outputs Steam as well as producing power") + .addInfo("Power output depends on turbine and fitting") + .addInfo("Use screwdriver to adjust fitting of turbine") + .addSeparator() + .beginStructureBlock(3, 3, 4, true) + .addController("Front center") + .addCasingInfo("Titanium Turbine Casing", 24) + .addDynamoHatch("Back center") + .addMaintenanceHatch("Side centered") + .addInputHatch("Superheated Steam, Side centered") + .addOutputHatch("Steam, Side centered") + .toolTipFinisher("Gregtech"); + if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { + return tt.getInformation(); + } else { + return tt.getStructureInformation(); + } } @Override diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Plasma.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Plasma.java index be62ff2d97..bb5134097a 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Plasma.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Plasma.java @@ -3,6 +3,8 @@ package gregtech.common.tileentities.machines.multi; import java.util.ArrayList; import java.util.Collection; +import org.lwjgl.input.Keyboard; + import gregtech.api.GregTech_API; import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; @@ -10,6 +12,7 @@ import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.items.GT_MetaGenerated_Tool; import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Recipe.GT_Recipe_Map; import gregtech.api.util.GT_Utility; @@ -33,17 +36,26 @@ public class GT_MetaTileEntity_LargeTurbine_Plasma extends GT_MetaTileEntity_Lar return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[1][aColorIndex + 1], aFacing == aSide ? aActive ? new GT_RenderedTexture(Textures.BlockIcons.LARGETURBINE_TU_ACTIVE5) : new GT_RenderedTexture(Textures.BlockIcons.LARGETURBINE_TU5) : Textures.BlockIcons.casingTexturePages[0][60]}; } - public String[] getDescription() { - return new String[]{ - "Controller Block for the Large Plasma Generator", - "Size(WxHxD): 3x3x4 (Hollow), Controller (Front centered)", - "1x Plasma Input Hatch (Side centered)", - "1x Maintenance Hatch (Side centered)", - "1x Output Hatch (Side centered, optional)", - "1x Dynamo Hatch (Back centered)", - "Tungstensteel Turbine Casings for the rest (24 at least!)", - "Needs a Turbine Item (Inside controller GUI)"}; + final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType("Plasma Turbine") + .addInfo("Controller block for the Large Plasma Generator") + .addInfo("Needs a Turbine, place inside controller") + .addInfo("Use your Fusion Reactor to produce the Plasma") + .addSeparator() + .beginStructureBlock(3, 3, 4, true) + .addController("Front center") + .addCasingInfo("Tungstensteel Turbine Casing", 24) + .addDynamoHatch("Back center") + .addMaintenanceHatch("Side centered") + .addInputHatch("Plasma Fluid, Side centered") + .addOutputHatch("Molten Fluid, optional, Side centered") + .toolTipFinisher("Gregtech"); + if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { + return tt.getInformation(); + } else { + return tt.getStructureInformation(); + } } public int getFuelValue(FluidStack aLiquid) { diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Steam.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Steam.java index 2943f6f946..20bcbf10d0 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Steam.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Steam.java @@ -4,6 +4,8 @@ import static gregtech.api.objects.XSTR.XSTR_INSTANCE; import java.util.ArrayList; +import org.lwjgl.input.Keyboard; + import gregtech.GT_Mod; import gregtech.api.GregTech_API; import gregtech.api.enums.Textures; @@ -12,6 +14,7 @@ import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Utility; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; @@ -40,17 +43,27 @@ public class GT_MetaTileEntity_LargeTurbine_Steam extends GT_MetaTileEntity_Larg } public String[] getDescription() { - return new String[]{ - "Controller Block for the Large Steam Turbine", - "Size(WxHxD): 3x3x4 (Hollow), Controller (Front centered)", - "1x Steam Input Hatch (Side centered)", - "1x Maintenance Hatch (Side centered)", - "1x Dynamo Hatch (Back centered)", - "1x Output Hatch for Distilled Water (Side centered)", - "Turbine Casings for the rest (24 at least!)", - "Needs a Turbine Item (Inside controller GUI)", - "Output depending on Rotor and fitting", - "Use screwdriver to adjust fitting of turbine"}; + final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType("Steam Turbine") + .addInfo("Controller block for the Large Steam Turbine") + .addInfo("Needs a Turbine, place inside controller") + .addInfo("Outputs Distilled Water as well as producing power") + .addInfo("Power output depends on turbine and fitting") + .addInfo("Use screwdriver to adjust fitting of turbine") + .addSeparator() + .beginStructureBlock(3, 3, 4, true) + .addController("Front center") + .addCasingInfo("Turbine Casing", 24) + .addDynamoHatch("Back center") + .addMaintenanceHatch("Side centered") + .addInputHatch("Steam, Side centered") + .addOutputHatch("Distilled Water, Side centered") + .toolTipFinisher("Gregtech"); + if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { + return tt.getInformation(); + } else { + return tt.getStructureInformation(); + } } @Override diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_MultiFurnace.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_MultiFurnace.java index cdc68702d2..5eca30def1 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_MultiFurnace.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_MultiFurnace.java @@ -4,6 +4,8 @@ import static gregtech.api.enums.GT_Values.VN; import java.util.ArrayList; +import org.lwjgl.input.Keyboard; + import gregtech.api.GregTech_API; import gregtech.api.enums.Textures; import gregtech.api.gui.GT_GUIContainer_MultiMachine; @@ -15,6 +17,7 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Muffl import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; import net.minecraft.entity.player.InventoryPlayer; @@ -41,18 +44,28 @@ public class GT_MetaTileEntity_MultiFurnace } public String[] getDescription() { - return new String[]{ - "Controller Block for the Multi Smelter", - "Smelts up to 8-128 Items at once", - "Size(WxHxD): 3x3x3 (Hollow), Controller (Front middle at bottom)", - "8x Heating Coils (Middle layer, hollow)", - "1x Input Bus (One of bottom)", - "1x Output Bus (One of bottom)", - "1x Maintenance Hatch (One of bottom)", - "1x Muffler Hatch (Top middle)", - "1x Energy Hatch (One of bottom)", - "Heat Proof Machine Casings for the rest", - "Causes " + 20 * getPollutionPerTick(null) + " Pollution per second"}; + final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType("Furnace") + .addInfo("Controller Block for the Multi Smelter") + .addInfo("Smelts up to 8-128 items at once") + .addInfo("Items smelted increases with coil tier") + .addPollutionAmount(20 * getPollutionPerTick(null)) + .addSeparator() + .beginStructureBlock(3, 3, 3, true) + .addController("Front bottom") + .addCasingInfo("Heat Proof Machine Casing", 8) + .addOtherStructurePart("Heating Coils (any tier)", "Middle layer") + .addEnergyHatch("Any bottom casing") + .addMaintenanceHatch("Any bottom casing") + .addMufflerHatch("Top Middle") + .addInputBus("Any bottom casing") + .addOutputBus("Any bottom casing") + .toolTipFinisher("Gregtech"); + if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { + return tt.getInformation(); + } else { + return tt.getStructureInformation(); + } } public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilCracker.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilCracker.java index 9519d901d7..e4ad65e4a4 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilCracker.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilCracker.java @@ -11,6 +11,7 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; import net.minecraft.entity.player.InventoryPlayer; @@ -20,6 +21,8 @@ import net.minecraftforge.fluids.FluidStack; import java.util.ArrayList; +import org.lwjgl.input.Keyboard; + public class GT_MetaTileEntity_OilCracker extends GT_MetaTileEntity_MultiBlockBase { private ForgeDirection orientation; private int controllerX, controllerZ; @@ -33,18 +36,29 @@ public class GT_MetaTileEntity_OilCracker extends GT_MetaTileEntity_MultiBlockBa } public String[] getDescription() { - return new String[]{ - "Controller Block for the Oil Cracking Unit", - "Thermally cracks heavy hydrocarbons into lighter fractions", - "Size(WxHxD): 5x3x3 (Hollow), Controller (Front center)", - "Ring of 8 Cupronickel Coils (Each side of Controller)", - "1x Hydrocarbon Input Bus/Hatch (Any left/right side casing)", - "1x Steam/Hydrogen Input Hatch (Any middle ring casing)", - "1x Cracked Hydrocarbon Output Hatch (Any left/right side casing)", - "1x Maintenance Hatch (Any casing)", - "1x Energy Hatch (Any casing)", - "Clean Stainless Steel Machine Casings for the rest (18 at least!)", - "Input/Output Hatches must be on opposite sides"}; + final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType("Cracker") + .addInfo("Controller block for the Oil Cracking Unit") + .addInfo("Thermally cracks heavy hydrocarbons into lighter fractions") + .addInfo("More efficient than the Chemical Reactor") + .addInfo("Place the appropriate circuit in the controller") + .addSeparator() + .beginStructureBlock(5, 3, 3, true) + .addController("Front center") + .addCasingInfo("Clean Stainless Steel Machine Casing", 18) + .addOtherStructurePart("2 Rings of 8 Cupronickel Coils", "Each side of the controller") + .addEnergyHatch("Any casing") + .addMaintenanceHatch("Any casing") + .addInputHatch("Steam/Hydrogen, Any middle ring casing") + .addInputHatch("Any left/right side casing") + .addOutputHatch("Any left/right side casing") + .addStructureInfo("Input/Output Hatches must be on opposite sides!") + .toolTipFinisher("Gregtech"); + if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { + return tt.getInformation(); + } else { + return tt.getStructureInformation(); + } } public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrillBase.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrillBase.java index 76f8e7f87f..a7a7023d34 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrillBase.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrillBase.java @@ -3,6 +3,7 @@ package gregtech.common.tileentities.machines.multi; import gregtech.api.gui.GT_GUIContainer_MultiMachine; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.util.GT_Log; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Utility; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; @@ -16,6 +17,8 @@ import net.minecraftforge.fluids.FluidStack; import java.util.ArrayList; +import org.lwjgl.input.Keyboard; + import static gregtech.api.enums.GT_Values.VN; import static gregtech.api.enums.GT_Values.debugDriller; import static gregtech.common.GT_UndergroundOil.undergroundOil; @@ -55,18 +58,30 @@ public abstract class GT_MetaTileEntity_OilDrillBase extends GT_MetaTileEntity_D protected String[] getDescriptionInternal(String tierSuffix) { String casings = getCasingBlockItem().get(0).getDisplayName(); - return new String[]{ - "Controller Block for the Oil/Gas/Fluid Drilling Rig " + (tierSuffix != null ? tierSuffix : ""), - "Size(WxHxD): 3x7x3", "Controller (Front middle at bottom)", - "3x1x3 Base of " + casings, - "1x3x1 " + casings + " pillar (Center of base)", - "1x3x1 " + getFrameMaterial().mName + " Frame Boxes (Each pillar side and on top)", - "1x Output Hatch (One of base casings)", - "1x Maintenance Hatch (One of base casings)", - "1x " + VN[getMinTier()] + "+ Energy Hatch (Any bottom layer casing)", - "Working on " + getRangeInChunks() + "x" + getRangeInChunks() + " chunks", - "Use Screwdriver to configure range", - "Use Programmed Circuits to ignore near exhausted oil field"}; + + final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType("Pump") + .addInfo("Controller Block for the Oil/Gas/Fluid Drilling Rig " + (tierSuffix != null ? tierSuffix : "")) + .addInfo("Works on " + getRangeInChunks() + "x" + getRangeInChunks() + " chunks") + .addInfo("Use a Screwdriver to configure range") + .addInfo("Use Programmed Circuits to ignore near exhausted oil field") + .addInfo("If total circuit # is greater than output amount it will halt. If it worked right.")//doesn't work + .addSeparator() + .beginStructureBlock(3, 7, 3, false) + .addController("Front bottom") + .addStructureInfo(casings + " form the 3x1x3 Base") + .addOtherStructurePart(casings, " 1x3x1 pillar above the center of the base (2 minimum total)") + .addOtherStructurePart(getFrameMaterial().mName + " Frame Boxes", "Each pillar's side and 1x3x1 on top") + .addEnergyHatch(VN[getMinTier()] + "+, Any base casing") + .addMaintenanceHatch("Any base casing") + .addInputBus("Mining Pipes or Circuits, optional, any base casing") + .addOutputHatch("Any base casing") + .toolTipFinisher("Gregtech"); + if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { + return tt.getInformation(); + } else { + return tt.getStructureInformation(); + } } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlantBase.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlantBase.java index 5ead0bf896..2e367e63e8 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlantBase.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlantBase.java @@ -8,6 +8,7 @@ import gregtech.api.interfaces.IChunkLoader; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.objects.GT_ChunkManager; import gregtech.api.objects.ItemData; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_OreDictUnificator; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; @@ -32,6 +33,8 @@ import java.util.Collection; import java.util.Collections; import java.util.HashSet; +import org.lwjgl.input.Keyboard; + import static gregtech.api.enums.GT_Values.VN; public abstract class GT_MetaTileEntity_OreDrillingPlantBase extends GT_MetaTileEntity_DrillerBase implements IChunkLoader { @@ -335,22 +338,33 @@ public abstract class GT_MetaTileEntity_OreDrillingPlantBase extends GT_MetaTile protected String[] getDescriptionInternal(String tierSuffix) { String casings = getCasingBlockItem().get(0).getDisplayName(); - return new String[]{ - "Controller Block for the Ore Drilling Plant " + (tierSuffix != null ? tierSuffix : ""), - "Size(WxHxD): 3x7x3, Controller (Front middle bottom)", - "3x1x3 Base of " + casings, - "1x3x1 " + casings + " pillar (Center of base)", - "1x3x1 " + getFrameMaterial().mName + " Frame Boxes (Each pillar side and on top)", - "1x Input Hatch for drilling fluid (Any bottom layer casing)", - "1x Input Bus for mining pipes (Any bottom layer casing; not necessary)", - "1x Output Bus (Any bottom layer casing)", - "1x Maintenance Hatch (Any bottom layer casing)", - "1x " + VN[getMinTier()] + "+ Energy Hatch (Any bottom layer casing)", - "Use Screwdriver to configure block radius", - "Use Soldering iron to turn off chunk mode", - "Maximum radius is " + (getRadiusInChunks() << 4) + " blocks", - "In chunk mode working area center is the chunk corner nearest to the drill", - "Fortune bonus of " + (mTier + 3)}; + + final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType("Miner") + .addInfo("Controller Block for the Ore Drilling Plant " + (tierSuffix != null ? tierSuffix : "")) + .addInfo("Use a Screwdriver to configure block radius") + .addInfo("Maximum radius is " + (getRadiusInChunks() << 4) + " blocks") + .addInfo("Use Soldering iron to turn off chunk mode") + .addInfo("In chunk mode, working area center is the chunk corner nearest to the drill") + .addInfo("Gives ~3x as much crushed ore vs normal processing") + .addInfo("Fortune bonus of " + (mTier + 3) + ". Only works on small ores") + .addSeparator() + .beginStructureBlock(3, 7, 3, false) + .addController("Front bottom") + .addStructureInfo(casings + " form the 3x1x3 Base") + .addOtherStructurePart(casings, " 1x3x1 pillar above the center of the base (2 minimum total)") + .addOtherStructurePart(getFrameMaterial().mName + " Frame Boxes", "Each pillar's side and 1x3x1 on top") + .addEnergyHatch(VN[getMinTier()] + "+, Any base casing") + .addMaintenanceHatch("Any base casing") + .addInputBus("Mining Pipes, optional, any base casing") + .addInputHatch("Drilling Fluid, any base casing") + .addOutputBus("Any base casing") + .toolTipFinisher("Gregtech"); + if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { + return tt.getInformation(); + } else { + return tt.getStructureInformation(); + } } @Override diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ProcessingArray.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ProcessingArray.java index 850908104b..2496d02a42 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ProcessingArray.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ProcessingArray.java @@ -12,6 +12,7 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBus; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_ProcessingArray_Manager; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Recipe.GT_Recipe_Map; @@ -25,6 +26,7 @@ import net.minecraft.util.StatCollector; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; import org.apache.commons.lang3.ArrayUtils; +import org.lwjgl.input.Keyboard; import java.util.ArrayList; import java.util.Arrays; @@ -54,18 +56,31 @@ public class GT_MetaTileEntity_ProcessingArray extends GT_MetaTileEntity_MultiBl } public String[] getDescription() { - return new String[]{ - "Controller Block for the Processing Array", - "Runs supplied machines as if placed in the world", - "Size(WxHxD): 3x3x3 (Hollow), Controller (Front centered)", - "1x Input Hatch/Bus (Any casing)", - "1x Output Hatch/Bus (Any casing)", - "1x Maintenance Hatch (Any casing)", - "1x Energy Hatch (Any casing)", - "Robust Tungstensteel Machine Casings for the rest (14 at least!)", - "Place up to 64 Single Block GT Machines into the Controller Inventory", - "Use screwdriver to enable separate input busses", - "Maximal overclockedness of machines inside: Tier 9"}; + final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType("Processing Array") + .addInfo("Runs supplied machines as if placed in the world") + .addInfo("Place up to 64 singleblock GT machines into the controller") + .addInfo("Note that tou still need to supply power to them all") + .addInfo("Use a screwdriver to enable separate input busses") + .addInfo("Maximal overclockedness of machines inside: Tier 9") + .addInfo("Doesn't work on certain machines, deal with it") + .addInfo("Use it if you hate GT++, or want even more speed later on") + .addSeparator() + .beginStructureBlock(3, 3, 3, true) + .addController("Front center") + .addCasingInfo("Robust Tungstensteel Machine Casing", 14) + .addEnergyHatch("Any casing") + .addMaintenanceHatch("Any casing") + .addInputBus("Any casing") + .addInputHatch("Any casing") + .addOutputBus("Any casing") + .addOutputHatch("Any casing") + .toolTipFinisher("Gregtech"); + if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { + return tt.getInformation(); + } else { + return tt.getStructureInformation(); + } } public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PyrolyseOven.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PyrolyseOven.java index eee88dfb21..1d9b360338 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PyrolyseOven.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PyrolyseOven.java @@ -10,6 +10,7 @@ import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; import gregtech.loaders.oreprocessing.ProcessingLog; @@ -23,6 +24,8 @@ import net.minecraftforge.oredict.OreDictionary; import java.util.ArrayList; import java.util.Arrays; +import org.lwjgl.input.Keyboard; + public class GT_MetaTileEntity_PyrolyseOven extends GT_MetaTileEntity_MultiBlockBase { private int coilMetaID; @@ -38,21 +41,32 @@ public class GT_MetaTileEntity_PyrolyseOven extends GT_MetaTileEntity_MultiBlock } public String[] getDescription() { - return new String[]{ - "Controller Block for the Pyrolyse Oven", - "Industrial Charcoal producer and Oil from Plants", - "Size(WxHxD): 5x4x5, Controller (Bottom center)", - "3x1x3 of Heating Coils (At the center of the bottom layer)", - "1x Input Hatch/Bus (Centered 3x1x3 area in Top layer)", - "1x Output Hatch/Bus (Any bottom layer casing)", - "1x Maintenance Hatch (Any bottom layer casing)", - "1x Muffler Hatch (Centered 3x1x3 area in Top layer)", - "1x Energy Hatch (Any bottom layer casing)", - "Pyrolyse Oven Casings for the rest (60 at least!)", - "Processing speed scales linearly with Coil tier:", - "CuNi: 50%, FeAlCr: 100%, Ni4Cr: 150%, Fe50CW: 200%, etc.", - "EU/t is not affected by Coil tier", - "Causes " + 20 * getPollutionPerTick(null) + " Pollution per second"}; + final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType("Coke Oven") + .addInfo("Controller block for the Pyrolyse Oven") + .addInfo("Industrial Charcoal producer") + .addInfo("Processing speed scales linearly with Coil tier:") + .addInfo("CuNi: 50%, FeAlCr: 100%, Ni4Cr: 150%, Fe50CW: 200%, etc.") + .addInfo("EU/t is not affected by Coil tier") + .addPollutionAmount(20 * getPollutionPerTick(null)) + .addSeparator() + .beginStructureBlock(5, 4, 5, true) + .addController("Front center") + .addCasingInfo("Pyrolyse Oven Casing", 60) + .addOtherStructurePart("Heating Coils (any tier)", "Center 3x1x3 of the bottom layer") + .addEnergyHatch("Any bottom layer casing") + .addMaintenanceHatch("Any bottom layer casing") + .addMufflerHatch("Center 3x1x3 area in top layer") + .addInputBus("Center 3x1x3 area in top layer") + .addInputHatch("Center 3x1x3 area in top layer") + .addOutputBus("Any bottom layer casing") + .addOutputHatch("Any bottom layer casing") + .toolTipFinisher("Gregtech"); + if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { + return tt.getInformation(); + } else { + return tt.getStructureInformation(); + } } public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_VacuumFreezer.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_VacuumFreezer.java index 834b97aa9d..bf4b1e9db7 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_VacuumFreezer.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_VacuumFreezer.java @@ -8,6 +8,7 @@ import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; import net.minecraft.entity.player.InventoryPlayer; @@ -16,6 +17,8 @@ import net.minecraftforge.common.util.ForgeDirection; import java.util.ArrayList; +import org.lwjgl.input.Keyboard; + public class GT_MetaTileEntity_VacuumFreezer extends GT_MetaTileEntity_MultiBlockBase { public GT_MetaTileEntity_VacuumFreezer(int aID, String aName, String aNameRegional) { @@ -31,15 +34,24 @@ public class GT_MetaTileEntity_VacuumFreezer } public String[] getDescription() { - return new String[]{ - "Controller Block for the Vacuum Freezer", - "Super cools hot ingots and cells", - "Size(WxHxD): 3x3x3 (Hollow), Controller (Front centered)", - "1x Input Bus (Any casing)", - "1x Output Bus (Any casing)", - "1x Maintenance Hatch (Any casing)", - "1x Energy Hatch (Any casing)", - "Frost Proof Machine Casings for the rest (16 at least!)"}; + final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType("Vacuum Freezer") + .addInfo("Controller Block for the Vacuum Freezer") + .addInfo("Cools hot ingots and cells") + .addSeparator() + .beginStructureBlock(3, 3, 3, true) + .addController("Front center") + .addCasingInfo("Frost Proof Machine Casing", 16) + .addEnergyHatch("Any casing") + .addMaintenanceHatch("Any casing") + .addInputBus("Any casing") + .addOutputBus("Any casing") + .toolTipFinisher("Gregtech"); + if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { + return tt.getInformation(); + } else { + return tt.getStructureInformation(); + } } public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { diff --git a/src/main/resources/assets/gregtech/lang/en_US.lang b/src/main/resources/assets/gregtech/lang/en_US.lang index 53970634f9..c3c5a574af 100644 --- a/src/main/resources/assets/gregtech/lang/en_US.lang +++ b/src/main/resources/assets/gregtech/lang/en_US.lang @@ -1,19 +1,20 @@ # Multiblock Tooltip Builder Keywords # Context can be found in the class gregtech.api.util.GT_Multiblock_Tooltip_Builder -GT5U.MBTT.MachineType=Machine Type: -GT5U.MBTT.Dimensions=Dimensions: -GT5U.MBTT.Structure=Structure: -GT5U.MBTT.Controller=Controller: +GT5U.MBTT.MachineType=Machine Type +GT5U.MBTT.Dimensions=Dimensions +GT5U.MBTT.Hollow=(Hollow) +GT5U.MBTT.Structure=Structure +GT5U.MBTT.Controller=Controller GT5U.MBTT.Minimum=(minimum) -GT5U.MBTT.MaintenanceHatch=Maintenance Hatch: -GT5U.MBTT.MufflerHatch=Muffler Hatch: -GT5U.MBTT.EnergyHatch=Energy Hatch: -GT5U.MBTT.DynamoHatch=Dynamo Hatch: -GT5U.MBTT.InputBus=Input Bus/ses: -GT5U.MBTT.InputHatch=Input Hatch/es: -GT5U.MBTT.OutputBus=Output Bus/ses: -GT5U.MBTT.OutputHatch=Output Hatch/es: -GT5U.MBTT.Causes=Causes: +GT5U.MBTT.MaintenanceHatch=Maintenance Hatch +GT5U.MBTT.MufflerHatch=Muffler Hatch +GT5U.MBTT.EnergyHatch=Energy Hatch +GT5U.MBTT.DynamoHatch=Dynamo Hatch +GT5U.MBTT.InputBus=Input Bus +GT5U.MBTT.InputHatch=Input Hatch +GT5U.MBTT.OutputBus=Output Bus +GT5U.MBTT.OutputHatch=Output Hatch +GT5U.MBTT.Causes=Causes GT5U.MBTT.PPS=pollution per second GT5U.MBTT.Hold=Hold GT5U.MBTT.Display=to display structure guidelines -- cgit From 5679f2c3aa052b4f5909a04cb350fd1da08b39ff Mon Sep 17 00:00:00 2001 From: Prometheus0000000 Date: Fri, 20 Nov 2020 01:12:02 -0500 Subject: Fix merger problem --- src/main/java/gregtech/api/util/GT_Recipe.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/main/java/gregtech/api') diff --git a/src/main/java/gregtech/api/util/GT_Recipe.java b/src/main/java/gregtech/api/util/GT_Recipe.java index abbb6aef1b..a9a001a0d4 100644 --- a/src/main/java/gregtech/api/util/GT_Recipe.java +++ b/src/main/java/gregtech/api/util/GT_Recipe.java @@ -614,7 +614,7 @@ public class GT_Recipe implements Comparable { public static final GT_Recipe_Map sHammerRecipes = new GT_Recipe_Map(new HashSet<>(3800), "gt.recipe.hammer", "Forge Hammer", null, RES_PATH_GUI + "basicmachines/Hammer", 1, 1, 1, 0, 1, E, 1, E, true, true); public static final GT_Recipe_Map sAmplifiers = new GT_Recipe_Map(new HashSet<>(2), "gt.recipe.uuamplifier", "Amplifabricator", null, RES_PATH_GUI + "basicmachines/Amplifabricator", 1, 0, 1, 0, 1, E, 1, E, true, true); public static final GT_Recipe_Map sMassFabFakeRecipes = new GT_Recipe_Map(new HashSet<>(2), "gt.recipe.massfab", "Mass Fabrication", null, RES_PATH_GUI + "basicmachines/Massfabricator", 1, 0, 1, 0, 10, E, 1, E, true, true); - public static final GT_Recipe_Map_Fuel sDieselFuels = new GT_Recipe_Map_Fuel(new HashSet<>(20), "gt.recipe.dieselgeneratorfuel", "Diesel Generator Fuel", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); + public static final GT_Recipe_Map_Fuel sDieselFuels = new GT_Recipe_Map_Fuel(new HashSet<>(20), "gt.recipe.dieselgeneratorfuel", "Combustion Generator Fuels", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); public static final GT_Recipe_Map_Fuel sExtremeDieselFuels = new GT_Recipe_Map_Fuel(new HashSet<>(20), "gt.recipe.extremedieselgeneratorfuel", "Extreme Diesel Engine Fuel", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); public static final GT_Recipe_Map_Fuel sTurbineFuels = new GT_Recipe_Map_Fuel(new HashSet<>(25), "gt.recipe.gasturbinefuel", "Gas Turbine Fuel", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); public static final GT_Recipe_Map_Fuel sHotFuels = new GT_Recipe_Map_Fuel(new HashSet<>(10), "gt.recipe.thermalgeneratorfuel", "Thermal Generator Fuel", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, false); -- cgit From a65bc5d9189095398d85b36cb0e2890ef5f106ce Mon Sep 17 00:00:00 2001 From: Uristqwerty Date: Thu, 26 Nov 2020 04:29:20 -0500 Subject: isRecipeInputEqual optimization (#351) * Optimize GT_Recipe.isRecipeInputEqual Used HEAVILY to catch duplicate recipes during game startup. Worst-case, it would result in 5 GT_OreDictUnificator.get calls for each pair of inputs. Instead, this is closer to 1 + 1/N, and as an added bonus, the modified unification it now uses doesn't copy its output only for it to be discarded immediately after comparison. Apart from inproved startup times, this might make a small difference when machines switch recipes. I am making an assumption that GT_OreDictUnificator.get(true, GT_OreDictUnificator.get(false, stack)) is equivalent to a just GT_OreDictUnificator.get(false, stack), and the original code only double-unificated because it was easier to code. If this turns out to be false, there's still some performance gain from factoring out the tStack unification, but some of the optimization here would be lost. * Changed method visibility according to PR feedback --- .../gregtech/api/util/GT_OreDictUnificator.java | 53 ++++++++++++++++++++++ src/main/java/gregtech/api/util/GT_Recipe.java | 5 +- 2 files changed, 56 insertions(+), 2 deletions(-) (limited to 'src/main/java/gregtech/api') diff --git a/src/main/java/gregtech/api/util/GT_OreDictUnificator.java b/src/main/java/gregtech/api/util/GT_OreDictUnificator.java index 9d9b45cecf..188af9cfaa 100644 --- a/src/main/java/gregtech/api/util/GT_OreDictUnificator.java +++ b/src/main/java/gregtech/api/util/GT_OreDictUnificator.java @@ -156,6 +156,59 @@ public class GT_OreDictUnificator { return GT_Utility.copyAmount(aStack.stackSize, rStack); } + /** Doesn't copy the returned stack or set quantity. Be careful and do not mutate it; + * intended only to optimize comparisons */ + static ItemStack get_nocopy(boolean aUseBlackList, ItemStack aStack) { + if (GT_Utility.isStackInvalid(aStack)) return null; + ItemData tPrefixMaterial = getAssociation(aStack); + ItemStack rStack = null; + if (tPrefixMaterial == null || !tPrefixMaterial.hasValidPrefixMaterialData() || (aUseBlackList && tPrefixMaterial.mBlackListed)) + return aStack; + if (aUseBlackList && !GregTech_API.sUnificationEntriesRegistered && isBlacklisted(aStack)) { + tPrefixMaterial.mBlackListed = true; + return aStack; + } + if (tPrefixMaterial.mUnificationTarget == null) + tPrefixMaterial.mUnificationTarget = sName2StackMap.get(tPrefixMaterial.toString()); + rStack = tPrefixMaterial.mUnificationTarget; + if (GT_Utility.isStackInvalid(rStack)) return aStack; + assert rStack != null; + rStack.setTagCompound(aStack.getTagCompound()); + return rStack; + } + + /** Compares the first argument against an already-unificated second argument as if + * aUseBlackList was both true and false. */ + public static boolean isInputStackEqual(ItemStack aStack, ItemStack unified_tStack) { + boolean alreadyCompared = false; + if (GT_Utility.isStackInvalid(aStack)) return false; + ItemData tPrefixMaterial = getAssociation(aStack); + ItemStack rStack = null; + if (tPrefixMaterial == null || !tPrefixMaterial.hasValidPrefixMaterialData()) + return GT_Utility.areStacksEqual(aStack, unified_tStack, true); + else if(tPrefixMaterial.mBlackListed) { + if (GT_Utility.areStacksEqual(aStack, unified_tStack, true)) + return true; + else + alreadyCompared = true; + } + if (!alreadyCompared && !GregTech_API.sUnificationEntriesRegistered && isBlacklisted(aStack)) { + tPrefixMaterial.mBlackListed = true; + if (GT_Utility.areStacksEqual(aStack, unified_tStack, true)) + return true; + else + alreadyCompared = true; + } + if (tPrefixMaterial.mUnificationTarget == null) + tPrefixMaterial.mUnificationTarget = sName2StackMap.get(tPrefixMaterial.toString()); + rStack = tPrefixMaterial.mUnificationTarget; + if (GT_Utility.isStackInvalid(rStack)) + return !alreadyCompared && GT_Utility.areStacksEqual(aStack, unified_tStack, true); + assert rStack != null; + rStack.setTagCompound(aStack.getTagCompound()); + return GT_Utility.areStacksEqual(rStack, unified_tStack, true); + } + public static List getNonUnifiedStacks(Object obj) { synchronized (sUnificationTable) { if (sUnificationTable.isEmpty() && !sItemStack2DataMap.isEmpty()) { diff --git a/src/main/java/gregtech/api/util/GT_Recipe.java b/src/main/java/gregtech/api/util/GT_Recipe.java index bf091695c7..537d92b365 100644 --- a/src/main/java/gregtech/api/util/GT_Recipe.java +++ b/src/main/java/gregtech/api/util/GT_Recipe.java @@ -389,11 +389,12 @@ public class GT_Recipe implements Comparable { if (mInputs.length > 0 && aInputs == null) return false; for (ItemStack tStack : mInputs) { - if (tStack != null) { + ItemStack unified_tStack = GT_OreDictUnificator.get_nocopy(true, tStack); + if (unified_tStack != null) { amt = tStack.stackSize; boolean temp = true; for (ItemStack aStack : aInputs) { - if ((GT_Utility.areUnificationsEqual(aStack, tStack, true) || GT_Utility.areUnificationsEqual(GT_OreDictUnificator.get(false, aStack), tStack, true))) { + if (GT_OreDictUnificator.isInputStackEqual(aStack, unified_tStack)) { if (GTppRecipeHelper) {//remove once the fix is out if (GT_Utility.areStacksEqual(aStack, Ic2Items.FluidCell.copy(), true) || GT_Utility.areStacksEqual(aStack, ItemList.Tool_DataStick.get(1L), true) || GT_Utility.areStacksEqual(aStack, ItemList.Tool_DataOrb.get(1L), true)) { if (!GT_Utility.areStacksEqual(aStack, tStack, false)) -- cgit From 98e9d3a4a2a9a5246608387d305818c52879c9c8 Mon Sep 17 00:00:00 2001 From: botn365 <42187820+botn365@users.noreply.github.com> Date: Fri, 27 Nov 2020 00:24:32 +0100 Subject: fix-infinit-while fix porention infinit while loop wit barrels/drawers --- src/main/java/gregtech/api/util/GT_Utility.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/main/java/gregtech/api') diff --git a/src/main/java/gregtech/api/util/GT_Utility.java b/src/main/java/gregtech/api/util/GT_Utility.java index b06cc1d82a..05e0874e7a 100644 --- a/src/main/java/gregtech/api/util/GT_Utility.java +++ b/src/main/java/gregtech/api/util/GT_Utility.java @@ -546,13 +546,14 @@ public class GT_Utility { for (int tGrabSlot = 0;tGrabSlot= aMinMoveAtOnce && isAllowedToTakeFromSlot(aTileEntity1, tGrabSlot, aGrabFrom, tGrabStack))) { int tStackSize = tGrabStack.stackSize; - tMovedItems = 0; + for (int tPutSlot = tFirstsValidSlot; tPutSlot < tPutInventorySize; tPutSlot++) { if (isAllowedToPutIntoSlot(tPutInventory, tPutSlot, aPutTo, tGrabStack, (byte) 64)) { int tMoved = moveStackFromSlotAToSlotB(aTileEntity1, tPutInventory, tGrabSlot, tPutSlot, aMaxTargetStackSize, aMinTargetStackSize, (byte) (aMaxMoveAtOnce - tMovedItems), aMinMoveAtOnce); -- cgit From 9576c7981e8663c7d9bf9e66ea78e3b5c50fcee4 Mon Sep 17 00:00:00 2001 From: DreamMasterXXL Date: Sun, 29 Nov 2020 20:28:44 +0100 Subject: add(BloodArsenal)add blood infused iron to metal and add fine wires for the vampire ring --- src/main/java/gregtech/api/enums/Materials.java | 1 + src/main/java/gregtech/api/enums/OrePrefixes.java | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'src/main/java/gregtech/api') diff --git a/src/main/java/gregtech/api/enums/Materials.java b/src/main/java/gregtech/api/enums/Materials.java index c7df2b219d..b46d26e02d 100644 --- a/src/main/java/gregtech/api/enums/Materials.java +++ b/src/main/java/gregtech/api/enums/Materials.java @@ -1778,6 +1778,7 @@ public class Materials implements IColorModulationContainer, ISubTagContainer { Inolashite, Mercassium, MeteoricIron, + BloodInfusedIron, MeteoricSteel, Naquadah, diff --git a/src/main/java/gregtech/api/enums/OrePrefixes.java b/src/main/java/gregtech/api/enums/OrePrefixes.java index 86c2812c5c..59c20d412b 100644 --- a/src/main/java/gregtech/api/enums/OrePrefixes.java +++ b/src/main/java/gregtech/api/enums/OrePrefixes.java @@ -731,7 +731,7 @@ public enum OrePrefixes { //Fine Wire if (!enableUnusedFineWires && !(aMaterial == Materials.Steel || aMaterial == Materials.AnnealedCopper || aMaterial == Materials.Platinum || aMaterial == Materials.Osmium || aMaterial == Materials.Tin || aMaterial == Materials.Lead || aMaterial == Materials.SolderingAlloy || aMaterial == Materials.Copper || aMaterial == Materials.Electrum || - aMaterial == Materials.Gold || aMaterial == Materials.RedAlloy || aMaterial == Materials.Graphene || aMaterial == Materials.NiobiumTitanium || aMaterial == Materials.YttriumBariumCuprate )) + aMaterial == Materials.Gold || aMaterial == Materials.RedAlloy || aMaterial == Materials.Graphene || aMaterial == Materials.NiobiumTitanium || aMaterial == Materials.YttriumBariumCuprate || aMaterial == Materials.BloodInfusedIron)) wireFine.mDisabledItems.add(aMaterial); //Gears if (!enableUnusedGears && !(aMaterial == Materials.Aluminium || aMaterial == Materials.Titanium || aMaterial == Materials.Iron || aMaterial == Materials.Copper || -- cgit From 81008e38ac10436a7d447a20d8deac693e311bdf Mon Sep 17 00:00:00 2001 From: David Lindström Date: Sat, 5 Dec 2020 02:14:43 +0100 Subject: This makes batteries drain/charge their tier loss extra charging their contained machines buffer --- src/main/java/gregtech/api/util/GT_ModHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/main/java/gregtech/api') diff --git a/src/main/java/gregtech/api/util/GT_ModHandler.java b/src/main/java/gregtech/api/util/GT_ModHandler.java index 4d264bec9b..5cfcac0a89 100644 --- a/src/main/java/gregtech/api/util/GT_ModHandler.java +++ b/src/main/java/gregtech/api/util/GT_ModHandler.java @@ -1685,7 +1685,7 @@ public class GT_ModHandler { int tTier = ((ic2.api.item.IElectricItem) aStack.getItem()).getTier(aStack); if (tTier < 0 || tTier == aTier || aTier == Integer.MAX_VALUE) { if (!aIgnoreLimit && tTier >= 0) - aCharge = (int) Math.min(aCharge, V[Math.max(0, Math.min(V.length - 1, tTier))]); + aCharge = (int) Math.min(aCharge, V[Math.max(0, Math.min(V.length - 1, tTier))] + B[Math.max(0, Math.min(V.length - 1, tTier))]); if (aCharge > 0) { // int rCharge = Math.max(0, ic2.api.item.ElectricItem.manager.discharge(aStack, aCharge + (aCharge * 4 > aTier ? aTier : 0), tTier, T, aSimulate)); int rCharge = (int) Math.max(0, ic2.api.item.ElectricItem.manager.discharge(aStack, aCharge + (aCharge * 4 > aTier ? aTier : 0), tTier, true, !aIgnoreDischargability, aSimulate)); -- cgit From d66962ed18b3f8d15889ce0b5545427311b24f94 Mon Sep 17 00:00:00 2001 From: botn365 <42187820+botn365@users.noreply.github.com> Date: Thu, 10 Dec 2020 12:45:04 +0100 Subject: add the option to disable input filter (#365) --- .../implementations/GT_MetaTileEntity_Hatch_InputBus.java | 9 ++++++++- src/main/resources/assets/gregtech/lang/en_US.lang | 3 ++- 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'src/main/java/gregtech/api') diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBus.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBus.java index dfac210915..f2f76dca4f 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBus.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBus.java @@ -13,10 +13,12 @@ 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.StatCollector; public class GT_MetaTileEntity_Hatch_InputBus extends GT_MetaTileEntity_Hatch { public GT_Recipe_Map mRecipeMap = null; public boolean disableSort; + public boolean disableFilter = false; public GT_MetaTileEntity_Hatch_InputBus(int aID, String aName, String aNameRegional, int aTier) { super(aID, aName, aNameRegional, aTier, getSlots(aTier), new String[]{ @@ -136,12 +138,14 @@ public class GT_MetaTileEntity_Hatch_InputBus extends GT_MetaTileEntity_Hatch { public void saveNBTData(NBTTagCompound aNBT) { super.saveNBTData(aNBT); aNBT.setBoolean("disableSort", disableSort); + aNBT.setBoolean("disableFilter", disableFilter); } @Override public void loadNBTData(NBTTagCompound aNBT) { super.loadNBTData(aNBT); disableSort = aNBT.getBoolean("disableSort"); + disableFilter = aNBT.getBoolean("disableFilter"); } @Override @@ -151,6 +155,9 @@ public class GT_MetaTileEntity_Hatch_InputBus extends GT_MetaTileEntity_Hatch { if (aPlayer.isSneaking()) { disableSort = !disableSort; GT_Utility.sendChatToPlayer(aPlayer, trans("200", "Sort mode: " + (disableSort ? "Disabled" : "Enabled"))); + } else { + disableFilter = !disableFilter; + GT_Utility.sendChatToPlayer(aPlayer, StatCollector.translateToLocal("GT5U.hatch.disableFilter."+disableFilter)); } } @@ -165,6 +172,6 @@ public class GT_MetaTileEntity_Hatch_InputBus extends GT_MetaTileEntity_Hatch { @Override public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return aSide == getBaseMetaTileEntity().getFrontFacing() && (mRecipeMap == null || mRecipeMap.containsInput(aStack)); + return aSide == getBaseMetaTileEntity().getFrontFacing() && (mRecipeMap == null || disableFilter || mRecipeMap.containsInput(aStack)); } } diff --git a/src/main/resources/assets/gregtech/lang/en_US.lang b/src/main/resources/assets/gregtech/lang/en_US.lang index c3c5a574af..158d108278 100644 --- a/src/main/resources/assets/gregtech/lang/en_US.lang +++ b/src/main/resources/assets/gregtech/lang/en_US.lang @@ -66,7 +66,8 @@ GT5U.machines.minermulti=Multiblock Miner GT5U.machines.voidoveflow.enabled=Overflow voiding enabled GT5U.machines.voidoveflow.disabled=Overflow voiding disabled - +GT5U.hatch.disableFilter.true=Input Filter Off +GT5U.hatch.disableFilter.false=Input Filter On GT5U.multiblock.pollution=Pollution reduced to GT5U.multiblock.energy=Stored Energy -- cgit From b3789aebb681711a91ec51cdd390a47dc36282dd Mon Sep 17 00:00:00 2001 From: Léa Gris Date: Fri, 4 Dec 2020 16:40:24 +0100 Subject: fix(rendering): UV Mapping on tiles - Fix all faces use the same UV mapping and orientation to be same as standard vanilla full blocks Vanilla blocks's face rendering. - Fix the orientation of bottom-face's arrow overlay with fixed UV of the `GT_MetaTileEntity_Buffer` type machines (filters, buffers, regulators) - Fix UV mapping of item pipes restrictor overlay - Fix UV mapping of fluid pipes blocked input overlay orientation on all sides - Fix UV mappiong of thick covers - Remove the now useless and broken custom UVMapped vertices at the bottom face. ![](https://i.imgur.com/MImsbQY.png) --- .../implementations/GT_MetaPipeEntity_Fluid.java | 2 +- .../implementations/GT_MetaTileEntity_Buffer.java | 133 ++++++++++++--------- .../gregtech/api/objects/GT_RenderedTexture.java | 77 +++++------- .../java/gregtech/api/objects/GT_SidedTexture.java | 98 +++++---------- .../gregtech/common/render/GT_Renderer_Block.java | 58 ++++----- 5 files changed, 160 insertions(+), 208 deletions(-) (limited to 'src/main/java/gregtech/api') 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 8a28301fdf..2afc996df2 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 @@ -111,7 +111,7 @@ public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity { if (aSide >= 0 && aSide < 6) { for (byte i = 0; i < 4; i++) if (isInputDisabledAtSide(sRestrictionArray[aSide][i])) tMask |= 1 << i; //Full block size renderer flips side 5 and 2 textures, flip restrictor textures to compensate - if (tThickNess >= 0.99F && (aSide == 5 || aSide == 2)) + if (aSide == 5 || aSide == 2 || aSide == 0) if (tMask > 3 && tMask < 12) tMask = (byte) (tMask ^ 12); } 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 7284cd3c01..8758ea1a02 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 @@ -8,10 +8,18 @@ import gregtech.api.util.GT_Utility; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.ForgeDirection; import static gregtech.api.enums.GT_Values.V; public abstract class GT_MetaTileEntity_Buffer extends GT_MetaTileEntity_TieredMachineBlock { + private static final int OUTPUT_INDEX = 0; + private static final int ARROW_RIGHT_INDEX = 1; + private static final int ARROW_DOWN_INDEX = 2; + private static final int ARROW_LEFT_INDEX = 3; + private static final int ARROW_UP_INDEX = 4; + private static final int FRONT_INDEX = 5; + public boolean bOutput = false, bRedstoneIfFull = false, bInvert = false, bStockingMode = false; public int mSuccess = 0, mTargetStackSize = 0; @@ -33,74 +41,85 @@ public abstract class GT_MetaTileEntity_Buffer extends GT_MetaTileEntity_TieredM @Override public ITexture[][][] getTextureSet(ITexture[] aTextures) { - ITexture[][][] rTextures = new ITexture[6][17][]; - ITexture tIcon = getOverlayIcon(), tOut = new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT), tUp = new GT_RenderedTexture(Textures.BlockIcons.ARROW_UP), tDown = new GT_RenderedTexture(Textures.BlockIcons.ARROW_DOWN), tLeft = new GT_RenderedTexture(Textures.BlockIcons.ARROW_LEFT), tRight = new GT_RenderedTexture(Textures.BlockIcons.ARROW_RIGHT); - for (byte i = -1; i < 16; i++) { - rTextures[0][i + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], tOut}; - rTextures[1][i + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], tRight, tIcon}; - rTextures[2][i + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], tDown, tIcon}; - rTextures[3][i + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], tLeft, tIcon}; - rTextures[4][i + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], tUp, tIcon}; - rTextures[5][i + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], tIcon}; + ITexture[][][] rTextures = new ITexture[ForgeDirection.VALID_DIRECTIONS.length][17][]; + ITexture tIcon = getOverlayIcon(); + ITexture tOut = new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT); + ITexture tUp = new GT_RenderedTexture(Textures.BlockIcons.ARROW_UP); + ITexture tDown = new GT_RenderedTexture(Textures.BlockIcons.ARROW_DOWN); + ITexture tLeft = new GT_RenderedTexture(Textures.BlockIcons.ARROW_LEFT); + ITexture tRight = new GT_RenderedTexture(Textures.BlockIcons.ARROW_RIGHT); + for (int i = 0; i < rTextures[0].length; i++) { + rTextures[OUTPUT_INDEX][i] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][i], tOut}; + rTextures[ARROW_RIGHT_INDEX][i] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][i], tRight, tIcon}; + rTextures[ARROW_DOWN_INDEX][i] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][i], tDown, tIcon}; + rTextures[ARROW_LEFT_INDEX][i] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][i], tLeft, tIcon}; + rTextures[ARROW_UP_INDEX][i] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][i], tUp, tIcon}; + rTextures[FRONT_INDEX][i] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][i], tIcon}; } return rTextures; } @Override public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { - if (aSide == aFacing) return mTextures[5][aColorIndex + 1]; - if (GT_Utility.getOppositeSide(aSide) == aFacing) return mTextures[0][aColorIndex + 1]; - switch (aFacing) { - case 0: - return mTextures[4][aColorIndex + 1]; - case 1: - return mTextures[2][aColorIndex + 1]; - case 2: - switch (aSide) { - case 0: - return mTextures[2][aColorIndex + 1]; - case 1: - return mTextures[2][aColorIndex + 1]; - case 4: - return mTextures[1][aColorIndex + 1]; - case 5: - return mTextures[3][aColorIndex + 1]; + int colorIndex = aColorIndex + 1; + ForgeDirection side = ForgeDirection.VALID_DIRECTIONS[aSide]; + ForgeDirection facing = ForgeDirection.VALID_DIRECTIONS[aFacing]; + if (side == facing) return mTextures[FRONT_INDEX][colorIndex]; + if (ForgeDirection.OPPOSITES[aSide] == aFacing) return mTextures[OUTPUT_INDEX][colorIndex]; + switch (facing) { + case DOWN: + return mTextures[ARROW_UP_INDEX][colorIndex]; // ARROW_UP + case UP: + return mTextures[ARROW_DOWN_INDEX][colorIndex]; // ARROW_DOWN + case NORTH: + switch (side) { + case DOWN: + case UP: + return mTextures[ARROW_DOWN_INDEX][colorIndex]; // ARROW_DOWN + case WEST: + return mTextures[ARROW_RIGHT_INDEX][colorIndex]; // ARROW_RIGHT + case EAST: + return mTextures[ARROW_LEFT_INDEX][colorIndex]; // ARROW_LEFT + default: } - case 3: - switch (aSide) { - case 0: - return mTextures[4][aColorIndex + 1]; - case 1: - return mTextures[4][aColorIndex + 1]; - case 4: - return mTextures[3][aColorIndex + 1]; - case 5: - return mTextures[1][aColorIndex + 1]; + break; + case SOUTH: + switch (side) { + case DOWN: + case UP: + return mTextures[ARROW_UP_INDEX][colorIndex]; // ARROW_UP + case WEST: + return mTextures[ARROW_LEFT_INDEX][colorIndex]; // ARROW_LEFT + case EAST: + return mTextures[ARROW_RIGHT_INDEX][colorIndex]; // ARROW_RIGHT + default: } - case 4: - switch (aSide) { - case 0: - return mTextures[3][aColorIndex + 1]; - case 1: - return mTextures[1][aColorIndex + 1]; - case 2: - return mTextures[3][aColorIndex + 1]; - case 3: - return mTextures[1][aColorIndex + 1]; + break; + case WEST: + switch (side) { + case DOWN: + case UP: + case SOUTH: + return mTextures[ARROW_RIGHT_INDEX][colorIndex]; // ARROW_RIGHT + case NORTH: + return mTextures[ARROW_LEFT_INDEX][colorIndex]; // ARROW_LEFT + default: } - case 5: - switch (aSide) { - case 0: - return mTextures[1][aColorIndex + 1]; - case 1: - return mTextures[3][aColorIndex + 1]; - case 2: - return mTextures[1][aColorIndex + 1]; - case 3: - return mTextures[3][aColorIndex + 1]; + break; + case EAST: + switch (side) { + case DOWN: + case UP: + case SOUTH: + return mTextures[ARROW_LEFT_INDEX][colorIndex]; // ARROW_LEFT + case NORTH: + return mTextures[ARROW_RIGHT_INDEX][colorIndex]; // ARROW_RIGHT + default: } + break; + default: } - return mTextures[5][aColorIndex + 1]; + return mTextures[FRONT_INDEX][colorIndex]; } @Override diff --git a/src/main/java/gregtech/api/objects/GT_RenderedTexture.java b/src/main/java/gregtech/api/objects/GT_RenderedTexture.java index 70b71cf125..074cabf341 100644 --- a/src/main/java/gregtech/api/objects/GT_RenderedTexture.java +++ b/src/main/java/gregtech/api/objects/GT_RenderedTexture.java @@ -37,94 +37,77 @@ public class GT_RenderedTexture implements ITexture, IColorModulationContainer { @Override public void renderXPos(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { - Tessellator.instance.setColorRGBA((int) (mRGBa[0] * 0.6F), (int) (mRGBa[1] * 0.6F), (int) (mRGBa[2] * 0.6F), mAllowAlpha ? 255 - mRGBa[3] : 255); + final Tessellator tesselator = Tessellator.instance; + tesselator.setColorRGBA((int) (mRGBa[0] * 0.6F), (int) (mRGBa[1] * 0.6F), (int) (mRGBa[2] * 0.6F), mAllowAlpha ? 255 - mRGBa[3] : 255); + aRenderer.field_152631_f = true; aRenderer.renderFaceXPos(aBlock, aX, aY, aZ, mIconContainer.getIcon()); if (mIconContainer.getOverlayIcon() != null) { - Tessellator.instance.setColorRGBA(153, 153, 153, 255); + tesselator.setColorRGBA(153, 153, 153, 255); aRenderer.renderFaceXPos(aBlock, aX, aY, aZ, mIconContainer.getOverlayIcon()); } + aRenderer.field_152631_f = false; } + @Override public void renderXNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { - Tessellator.instance.setColorRGBA((int) (mRGBa[0] * 0.6F), (int) (mRGBa[1] * 0.6F), (int) (mRGBa[2] * 0.6F), mAllowAlpha ? 255 - mRGBa[3] : 255); + final Tessellator tesselator = Tessellator.instance; + tesselator.setColorRGBA((int) (mRGBa[0] * 0.6F), (int) (mRGBa[1] * 0.6F), (int) (mRGBa[2] * 0.6F), mAllowAlpha ? 255 - mRGBa[3] : 255); aRenderer.renderFaceXNeg(aBlock, aX, aY, aZ, mIconContainer.getIcon()); if (mIconContainer.getOverlayIcon() != null) { - Tessellator.instance.setColorRGBA(153, 153, 153, 255); + tesselator.setColorRGBA(153, 153, 153, 255); aRenderer.renderFaceXNeg(aBlock, aX, aY, aZ, mIconContainer.getOverlayIcon()); } } @Override public void renderYPos(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { - Tessellator.instance.setColorRGBA((int) (mRGBa[0] * 1.0F), (int) (mRGBa[1] * 1.0F), (int) (mRGBa[2] * 1.0F), mAllowAlpha ? 255 - mRGBa[3] : 255); + final Tessellator tesselator = Tessellator.instance; + tesselator.setColorRGBA((int) (mRGBa[0] * 1.0F), (int) (mRGBa[1] * 1.0F), (int) (mRGBa[2] * 1.0F), mAllowAlpha ? 255 - mRGBa[3] : 255); aRenderer.renderFaceYPos(aBlock, aX, aY, aZ, mIconContainer.getIcon()); if (mIconContainer.getOverlayIcon() != null) { - Tessellator.instance.setColorRGBA(255, 255, 255, 255); + tesselator.setColorRGBA(255, 255, 255, 255); aRenderer.renderFaceYPos(aBlock, aX, aY, aZ, mIconContainer.getOverlayIcon()); } } @Override public void renderYNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { - Tessellator.instance.setColorRGBA((int) (mRGBa[0] * 0.5F), (int) (mRGBa[1] * 0.5F), (int) (mRGBa[2] * 0.5F), mAllowAlpha ? 255 - mRGBa[3] : 255); - IIcon aIcon = mIconContainer.getIcon(); - - float d_16 = 16.0F; - float d3 = (float)aIcon.getInterpolatedU(aRenderer.renderMaxX * d_16); - float d4 = (float)aIcon.getInterpolatedU(aRenderer.renderMinX * d_16); - float d5 = (float)aIcon.getInterpolatedV(aRenderer.renderMinZ * d_16); - float d6 = (float)aIcon.getInterpolatedV(aRenderer.renderMaxZ * d_16); - - if (aRenderer.renderMinX < 0.0D || aRenderer.renderMaxX > 1.0D) { - d3 = aIcon.getMaxU(); - d4 = aIcon.getMinU(); - } - - if (aRenderer.renderMinZ < 0.0D || aRenderer.renderMaxZ > 1.0D) { - d5 = aIcon.getMinV(); - d6 = aIcon.getMaxV(); - } - - float d11 = aX + (float)aRenderer.renderMinX; - float d12 = aX + (float)aRenderer.renderMaxX; - float d13 = aY + (float)aRenderer.renderMinY; - float d14 = aZ + (float)aRenderer.renderMinZ; - float d15 = aZ + (float)aRenderer.renderMaxZ; - - Tessellator.instance.addVertexWithUV((double)d11, (double)d13, (double)d15, (double)d3, (double)d6); - Tessellator.instance.addVertexWithUV((double)d11, (double)d13, (double)d14, (double)d3, (double)d5); - Tessellator.instance.addVertexWithUV((double)d12, (double)d13, (double)d14, (double)d4, (double)d5); - Tessellator.instance.addVertexWithUV((double)d12, (double)d13, (double)d15, (double)d4, (double)d6); - - if ((aIcon = mIconContainer.getOverlayIcon()) != null) { - Tessellator.instance.setColorRGBA(128, 128, 128, 255); - - Tessellator.instance.addVertexWithUV((double)d11, (double)d13, (double)d15, (double)d3, (double)d6); - Tessellator.instance.addVertexWithUV((double)d11, (double)d13, (double)d14, (double)d3, (double)d5); - Tessellator.instance.addVertexWithUV((double)d12, (double)d13, (double)d14, (double)d4, (double)d5); - Tessellator.instance.addVertexWithUV((double)d12, (double)d13, (double)d15, (double)d4, (double)d6); + final Tessellator tesselator = Tessellator.instance; + tesselator.setColorRGBA((int) (mRGBa[0] * 0.5F), (int) (mRGBa[1] * 0.5F), (int) (mRGBa[2] * 0.5F), mAllowAlpha ? 255 - mRGBa[3] : 255); + aRenderer.field_152631_f = true; + aRenderer.flipTexture = true; + aRenderer.renderFaceYNeg(aBlock, aX, aY, aZ, mIconContainer.getIcon()); + if (mIconContainer.getOverlayIcon() != null) { + tesselator.setColorRGBA(128, 128, 128, 255); + aRenderer.renderFaceYNeg(aBlock, aX, aY, aZ, mIconContainer.getOverlayIcon()); } + aRenderer.field_152631_f = false; + aRenderer.flipTexture = false; } @Override public void renderZPos(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { - Tessellator.instance.setColorRGBA((int) (mRGBa[0] * 0.8F), (int) (mRGBa[1] * 0.8F), (int) (mRGBa[2] * 0.8F), mAllowAlpha ? 255 - mRGBa[3] : 255); + final Tessellator tesselator = Tessellator.instance; + tesselator.setColorRGBA((int) (mRGBa[0] * 0.8F), (int) (mRGBa[1] * 0.8F), (int) (mRGBa[2] * 0.8F), mAllowAlpha ? 255 - mRGBa[3] : 255); aRenderer.renderFaceZPos(aBlock, aX, aY, aZ, mIconContainer.getIcon()); if (mIconContainer.getOverlayIcon() != null) { - Tessellator.instance.setColorRGBA(204, 204, 204, 255); + tesselator.setColorRGBA(204, 204, 204, 255); aRenderer.renderFaceZPos(aBlock, aX, aY, aZ, mIconContainer.getOverlayIcon()); } } @Override public void renderZNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { - Tessellator.instance.setColorRGBA((int) (mRGBa[0] * 0.8F), (int) (mRGBa[1] * 0.8F), (int) (mRGBa[2] * 0.8F), mAllowAlpha ? 255 - mRGBa[3] : 255); + final Tessellator tesselator = Tessellator.instance; + tesselator.setColorRGBA((int) (mRGBa[0] * 0.8F), (int) (mRGBa[1] * 0.8F), (int) (mRGBa[2] * 0.8F), mAllowAlpha ? 255 - mRGBa[3] : 255); + aRenderer.field_152631_f = true; aRenderer.renderFaceZNeg(aBlock, aX, aY, aZ, mIconContainer.getIcon()); if (mIconContainer.getOverlayIcon() != null) { - Tessellator.instance.setColorRGBA(204, 204, 204, 255); + tesselator.setColorRGBA(204, 204, 204, 255); aRenderer.renderFaceZNeg(aBlock, aX, aY, aZ, mIconContainer.getOverlayIcon()); } + aRenderer.field_152631_f = false; } @Override diff --git a/src/main/java/gregtech/api/objects/GT_SidedTexture.java b/src/main/java/gregtech/api/objects/GT_SidedTexture.java index 2b4f144393..ab88225781 100644 --- a/src/main/java/gregtech/api/objects/GT_SidedTexture.java +++ b/src/main/java/gregtech/api/objects/GT_SidedTexture.java @@ -7,7 +7,6 @@ import gregtech.api.interfaces.ITexture; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.Tessellator; -import net.minecraft.util.IIcon; public class GT_SidedTexture implements ITexture, IColorModulationContainer { private final IIconContainer[] mIconContainer; @@ -45,115 +44,76 @@ public class GT_SidedTexture implements ITexture, IColorModulationContainer { @Override public void renderXPos(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { - Tessellator.instance.setColorRGBA((int) (mRGBa[0] * 0.6F), (int) (mRGBa[1] * 0.6F), (int) (mRGBa[2] * 0.6F), mAllowAlpha ? 255 - mRGBa[3] : 255); + final Tessellator tessellator = Tessellator.instance; + tessellator.setColorRGBA((int) (mRGBa[0] * 0.6F), (int) (mRGBa[1] * 0.6F), (int) (mRGBa[2] * 0.6F), mAllowAlpha ? 255 - mRGBa[3] : 255); + aRenderer.field_152631_f = true; aRenderer.renderFaceXPos(aBlock, aX, aY, aZ, mIconContainer[5].getIcon()); if (mIconContainer[5].getOverlayIcon() != null) { - Tessellator.instance.setColorRGBA(153, 153, 153, 255); + tessellator.setColorRGBA(153, 153, 153, 255); aRenderer.renderFaceXPos(aBlock, aX, aY, aZ, mIconContainer[5].getOverlayIcon()); } + aRenderer.field_152631_f = false; } @Override public void renderXNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { - Tessellator.instance.setColorRGBA((int) (mRGBa[0] * 0.6F), (int) (mRGBa[1] * 0.6F), (int) (mRGBa[2] * 0.6F), mAllowAlpha ? 255 - mRGBa[3] : 255); + final Tessellator tessellator = Tessellator.instance; + tessellator.setColorRGBA((int) (mRGBa[0] * 0.6F), (int) (mRGBa[1] * 0.6F), (int) (mRGBa[2] * 0.6F), mAllowAlpha ? 255 - mRGBa[3] : 255); aRenderer.renderFaceXNeg(aBlock, aX, aY, aZ, mIconContainer[4].getIcon()); if (mIconContainer[4].getOverlayIcon() != null) { - Tessellator.instance.setColorRGBA(153, 153, 153, 255); + tessellator.setColorRGBA(153, 153, 153, 255); aRenderer.renderFaceXNeg(aBlock, aX, aY, aZ, mIconContainer[4].getOverlayIcon()); } } @Override public void renderYPos(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { - Tessellator.instance.setColorRGBA((int) (mRGBa[0] * 1.0F), (int) (mRGBa[1] * 1.0F), (int) (mRGBa[2] * 1.0F), mAllowAlpha ? 255 - mRGBa[3] : 255); + final Tessellator tessellator = Tessellator.instance; + tessellator.setColorRGBA((int) (mRGBa[0] * 1.0F), (int) (mRGBa[1] * 1.0F), (int) (mRGBa[2] * 1.0F), mAllowAlpha ? 255 - mRGBa[3] : 255); aRenderer.renderFaceYPos(aBlock, aX, aY, aZ, mIconContainer[1].getIcon()); if (mIconContainer[1].getOverlayIcon() != null) { - Tessellator.instance.setColorRGBA(255, 255, 255, 255); + tessellator.setColorRGBA(255, 255, 255, 255); aRenderer.renderFaceYPos(aBlock, aX, aY, aZ, mIconContainer[1].getOverlayIcon()); } } @Override public void renderYNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { - Tessellator.instance.setColorRGBA((int) (mRGBa[0] * 0.5F), (int) (mRGBa[1] * 0.5F), (int) (mRGBa[2] * 0.5F), mAllowAlpha ? 255 - mRGBa[3] : 255); - IIcon aIcon = mIconContainer[0].getIcon(); - - float d_16 = 16.0F; - float d3 = (float)aIcon.getInterpolatedU(aRenderer.renderMaxX * d_16); - float d4 = (float)aIcon.getInterpolatedU(aRenderer.renderMinX * d_16); - float d5 = (float)aIcon.getInterpolatedV(aRenderer.renderMinZ * d_16); - float d6 = (float)aIcon.getInterpolatedV(aRenderer.renderMaxZ * d_16); - - if (aRenderer.renderMinX < 0.0D || aRenderer.renderMaxX > 1.0D) { - d3 = aIcon.getMaxU(); - d4 = aIcon.getMinU(); - } - - if (aRenderer.renderMinZ < 0.0D || aRenderer.renderMaxZ > 1.0D) { - d5 = aIcon.getMinV(); - d6 = aIcon.getMaxV(); - } - - float d11 = aX + (float)aRenderer.renderMinX; - float d12 = aX + (float)aRenderer.renderMaxX; - float d13 = aY + (float)aRenderer.renderMinY; - float d14 = aZ + (float)aRenderer.renderMinZ; - float d15 = aZ + (float)aRenderer.renderMaxZ; - - Tessellator.instance.addVertexWithUV((double)d11, (double)d13, (double)d15, (double)d3, (double)d6); - Tessellator.instance.addVertexWithUV((double)d11, (double)d13, (double)d14, (double)d3, (double)d5); - Tessellator.instance.addVertexWithUV((double)d12, (double)d13, (double)d14, (double)d4, (double)d5); - Tessellator.instance.addVertexWithUV((double)d12, (double)d13, (double)d15, (double)d4, (double)d6); - - if ((aIcon = mIconContainer[0].getOverlayIcon()) != null) { - Tessellator.instance.setColorRGBA(128, 128, 128, 255); - - d3 = (float)aIcon.getInterpolatedU(aRenderer.renderMaxX * d_16); - d4 = (float)aIcon.getInterpolatedU(aRenderer.renderMinX * d_16); - d5 = (float)aIcon.getInterpolatedV(aRenderer.renderMinZ * d_16); - d6 = (float)aIcon.getInterpolatedV(aRenderer.renderMaxZ * d_16); - - if (aRenderer.renderMinX < 0.0D || aRenderer.renderMaxX > 1.0D) { - d3 = aIcon.getMaxU(); - d4 = aIcon.getMinU(); - } - - if (aRenderer.renderMinZ < 0.0D || aRenderer.renderMaxZ > 1.0D) { - d5 = aIcon.getMinV(); - d6 = aIcon.getMaxV(); - } - - d11 = aX + (float)aRenderer.renderMinX; - d12 = aX + (float)aRenderer.renderMaxX; - d13 = aY + (float)aRenderer.renderMinY; - d14 = aZ + (float)aRenderer.renderMinZ; - d15 = aZ + (float)aRenderer.renderMaxZ; - - Tessellator.instance.addVertexWithUV((double)d11, (double)d13, (double)d15, (double)d3, (double)d6); - Tessellator.instance.addVertexWithUV((double)d11, (double)d13, (double)d14, (double)d3, (double)d5); - Tessellator.instance.addVertexWithUV((double)d12, (double)d13, (double)d14, (double)d4, (double)d5); - Tessellator.instance.addVertexWithUV((double)d12, (double)d13, (double)d15, (double)d4, (double)d6); + final Tessellator tessellator = Tessellator.instance; + tessellator.setColorRGBA((int) (mRGBa[0] * 0.5F), (int) (mRGBa[1] * 0.5F), (int) (mRGBa[2] * 0.5F), mAllowAlpha ? 255 - mRGBa[3] : 255); + aRenderer.field_152631_f = true; + aRenderer.flipTexture = true; + aRenderer.renderFaceYNeg(aBlock, aX, aY, aZ, mIconContainer[1].getIcon()); + if (mIconContainer[0].getOverlayIcon() != null) { + tessellator.setColorRGBA(128, 128, 128, 255); + aRenderer.renderFaceYNeg(aBlock, aX, aY, aZ, mIconContainer[1].getOverlayIcon()); } + aRenderer.field_152631_f = false; + aRenderer.flipTexture = false; } @Override public void renderZPos(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { - Tessellator.instance.setColorRGBA((int) (mRGBa[0] * 0.8F), (int) (mRGBa[1] * 0.8F), (int) (mRGBa[2] * 0.8F), mAllowAlpha ? 255 - mRGBa[3] : 255); + final Tessellator tessellator = Tessellator.instance; + tessellator.setColorRGBA((int) (mRGBa[0] * 0.8F), (int) (mRGBa[1] * 0.8F), (int) (mRGBa[2] * 0.8F), mAllowAlpha ? 255 - mRGBa[3] : 255); aRenderer.renderFaceZPos(aBlock, aX, aY, aZ, mIconContainer[3].getIcon()); if (mIconContainer[3].getOverlayIcon() != null) { - Tessellator.instance.setColorRGBA(204, 204, 204, 255); + tessellator.setColorRGBA(204, 204, 204, 255); aRenderer.renderFaceZPos(aBlock, aX, aY, aZ, mIconContainer[3].getOverlayIcon()); } } @Override public void renderZNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { - Tessellator.instance.setColorRGBA((int) (mRGBa[0] * 0.8F), (int) (mRGBa[1] * 0.8F), (int) (mRGBa[2] * 0.8F), mAllowAlpha ? 255 - mRGBa[3] : 255); + final Tessellator tessellator = Tessellator.instance; + tessellator.setColorRGBA((int) (mRGBa[0] * 0.8F), (int) (mRGBa[1] * 0.8F), (int) (mRGBa[2] * 0.8F), mAllowAlpha ? 255 - mRGBa[3] : 255); + aRenderer.field_152631_f = true; aRenderer.renderFaceZNeg(aBlock, aX, aY, aZ, mIconContainer[2].getIcon()); if (mIconContainer[2].getOverlayIcon() != null) { - Tessellator.instance.setColorRGBA(204, 204, 204, 255); + tessellator.setColorRGBA(204, 204, 204, 255); aRenderer.renderFaceZNeg(aBlock, aX, aY, aZ, mIconContainer[2].getOverlayIcon()); } + aRenderer.field_152631_f = false; } @Override diff --git a/src/main/java/gregtech/common/render/GT_Renderer_Block.java b/src/main/java/gregtech/common/render/GT_Renderer_Block.java index 795e93f582..5ee32f8dc6 100644 --- a/src/main/java/gregtech/common/render/GT_Renderer_Block.java +++ b/src/main/java/gregtech/common/render/GT_Renderer_Block.java @@ -154,7 +154,7 @@ public class GT_Renderer_Block } boolean[] tIsCovered = new boolean[6]; for (byte i = 0; i < 6; i = (byte) (i + 1)) { - tIsCovered[i] = (aTileEntity.getCoverIDAtSide(i) != 0 ? true : false); + tIsCovered[i] = (aTileEntity.getCoverIDAtSide(i) != 0); } if ((tIsCovered[0]) && (tIsCovered[1]) && (tIsCovered[2]) && (tIsCovered[3]) && (tIsCovered[4]) && (tIsCovered[5])) { return renderStandardBlock(aWorld, aX, aY, aZ, aBlock, aRenderer); @@ -420,20 +420,17 @@ public class GT_Renderer_Block } public static void renderNegativeYFacing(IBlockAccess aWorld, RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ, ITexture[] aIcon, boolean aFullBlock) { - if (aWorld != null) { - if ((aFullBlock) && (!aBlock.shouldSideBeRendered(aWorld, aX, aY - 1, aZ, 0))) { - return; - } - Tessellator.instance.setBrightness(aBlock.getMixedBrightnessForBlock(aWorld, aX, aFullBlock ? aY - 1 : aY, aZ)); - } + if (aWorld == null) return; + if ((aFullBlock) && (!aBlock.shouldSideBeRendered(aWorld, aX, aY - 1, aZ, 0))) return; + Tessellator.instance.setBrightness(aBlock.getMixedBrightnessForBlock(aWorld, aX, aFullBlock ? aY - 1 : aY, aZ)); + if (aIcon != null) { - for (int i = 0; i < aIcon.length; i++) { - if (aIcon[i] != null) { - aIcon[i].renderYNeg(aRenderer, aBlock, aX, aY, aZ); + for (ITexture iTexture : aIcon) { + if (iTexture != null) { + iTexture.renderYNeg(aRenderer, aBlock, aX, aY, aZ); } } } - aRenderer.flipTexture = false; } public static void renderPositiveYFacing(IBlockAccess aWorld, RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ, ITexture[] aIcon, boolean aFullBlock) { @@ -444,13 +441,12 @@ public class GT_Renderer_Block Tessellator.instance.setBrightness(aBlock.getMixedBrightnessForBlock(aWorld, aX, aFullBlock ? aY + 1 : aY, aZ)); } if (aIcon != null) { - for (int i = 0; i < aIcon.length; i++) { - if (aIcon[i] != null) { - aIcon[i].renderYPos(aRenderer, aBlock, aX, aY, aZ); + for (ITexture iTexture : aIcon) { + if (iTexture != null) { + iTexture.renderYPos(aRenderer, aBlock, aX, aY, aZ); } } } - aRenderer.flipTexture = false; } public static void renderNegativeZFacing(IBlockAccess aWorld, RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ, ITexture[] aIcon, boolean aFullBlock) { @@ -460,15 +456,13 @@ public class GT_Renderer_Block } Tessellator.instance.setBrightness(aBlock.getMixedBrightnessForBlock(aWorld, aX, aY, aFullBlock ? aZ - 1 : aZ)); } - aRenderer.flipTexture = (!aFullBlock); if (aIcon != null) { - for (int i = 0; i < aIcon.length; i++) { - if (aIcon[i] != null) { - aIcon[i].renderZNeg(aRenderer, aBlock, aX, aY, aZ); + for (ITexture iTexture : aIcon) { + if (iTexture != null) { + iTexture.renderZNeg(aRenderer, aBlock, aX, aY, aZ); } } } - aRenderer.flipTexture = false; } public static void renderPositiveZFacing(IBlockAccess aWorld, RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ, ITexture[] aIcon, boolean aFullBlock) { @@ -479,13 +473,12 @@ public class GT_Renderer_Block Tessellator.instance.setBrightness(aBlock.getMixedBrightnessForBlock(aWorld, aX, aY, aFullBlock ? aZ + 1 : aZ)); } if (aIcon != null) { - for (int i = 0; i < aIcon.length; i++) { - if (aIcon[i] != null) { - aIcon[i].renderZPos(aRenderer, aBlock, aX, aY, aZ); + for (ITexture iTexture : aIcon) { + if (iTexture != null) { + iTexture.renderZPos(aRenderer, aBlock, aX, aY, aZ); } } } - aRenderer.flipTexture = false; } public static void renderNegativeXFacing(IBlockAccess aWorld, RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ, ITexture[] aIcon, boolean aFullBlock) { @@ -496,13 +489,12 @@ public class GT_Renderer_Block Tessellator.instance.setBrightness(aBlock.getMixedBrightnessForBlock(aWorld, aFullBlock ? aX - 1 : aX, aY, aZ)); } if (aIcon != null) { - for (int i = 0; i < aIcon.length; i++) { - if (aIcon[i] != null) { - aIcon[i].renderXNeg(aRenderer, aBlock, aX, aY, aZ); + for (ITexture iTexture : aIcon) { + if (iTexture != null) { + iTexture.renderXNeg(aRenderer, aBlock, aX, aY, aZ); } } } - aRenderer.flipTexture = false; } public static void renderPositiveXFacing(IBlockAccess aWorld, RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ, ITexture[] aIcon, boolean aFullBlock) { @@ -512,15 +504,13 @@ public class GT_Renderer_Block } Tessellator.instance.setBrightness(aBlock.getMixedBrightnessForBlock(aWorld, aFullBlock ? aX + 1 : aX, aY, aZ)); } - aRenderer.flipTexture = (!aFullBlock); if (aIcon != null) { - for (int i = 0; i < aIcon.length; i++) { - if (aIcon[i] != null) { - aIcon[i].renderXPos(aRenderer, aBlock, aX, aY, aZ); + for (ITexture iTexture : aIcon) { + if (iTexture != null) { + iTexture.renderXPos(aRenderer, aBlock, aX, aY, aZ); } } } - aRenderer.flipTexture = false; } public void renderInventoryBlock(Block aBlock, int aMeta, int aModelID, RenderBlocks aRenderer) { @@ -579,7 +569,7 @@ public class GT_Renderer_Block if (aTileEntity == null) { return false; } - if (((aTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) aTileEntity).getMetaTileEntity() != null) && (((IGregTechTileEntity) aTileEntity).getMetaTileEntity().renderInWorld(aWorld, aX, aY, aZ, aBlock, aRenderer))) { + if (aTileEntity instanceof IGregTechTileEntity && (((IGregTechTileEntity) aTileEntity).getMetaTileEntity() != null) && (((IGregTechTileEntity) aTileEntity).getMetaTileEntity().renderInWorld(aWorld, aX, aY, aZ, aBlock, aRenderer))) { return true; } if ((aTileEntity instanceof IPipeRenderedTileEntity)) { -- cgit