diff options
Diffstat (limited to 'src/main/java/gregtech')
57 files changed, 2218 insertions, 1364 deletions
diff --git a/src/main/java/gregtech/api/enums/GT_Values.java b/src/main/java/gregtech/api/enums/GT_Values.java index 4911801025..2ee24b8b5a 100644 --- a/src/main/java/gregtech/api/enums/GT_Values.java +++ b/src/main/java/gregtech/api/enums/GT_Values.java @@ -257,8 +257,9 @@ public class GT_Values { /** * NBT String Keys */ - public static class NBT { + public static final class NBT { public static final String COLOR = "gt.color", // Integer + COVERS = "gt.covers", // String CUSTOM_NAME = "name", // String DISPAY = "gt.display", // String FACING = "gt.facing", // Byte @@ -274,14 +275,15 @@ public class GT_Values { // Machines ACTIVE = "gt.active", // Boolean FLUID_OUT = "gt.fluidout", // Output Fluid - INV_OUT = "gt.invout", // ItemStack PARALLEL = "gt.parallel", // Number TANK_CAPACITY = "gt.tankcap", // Number TANK_IN = "gt.tank.in.", // FluidStack TANK_OUT = "gt.tank.out.", // FluidStack TEXTURE = "gt.texture", // String - INV_SIZE = "gt.invsize", // Number - INV_LIST = "gt.invlist", // NBT List + INV_INPUT_SIZE = "gt.invsize.in", // Number + INV_OUTPUT_SIZE = "gt.invsize.out", // Number + INV_INPUT_LIST = "gt.invlist.in", // NBT List + INV_OUTPUT_LIST = "gt.invlist.out", // NBT List // MultiBlock STRUCTURE_OK = "gt.structure.ok", @@ -291,6 +293,8 @@ public class GT_Values { TARGET_X = "gt.target.x", // Number TARGET_Y = "gt.target.y", // Number TARGET_Z = "gt.target.z", // Number + LOCKED_INVENTORY = "gt.locked.inventory", // String + LOCKED_INVENTORY_INDEX = "gt.locked.inventory.index", // Number empty_ = ""; } diff --git a/src/main/java/gregtech/api/graphs/GenerateNodeMap.java b/src/main/java/gregtech/api/graphs/GenerateNodeMap.java index c0ee8b9490..8085421576 100644 --- a/src/main/java/gregtech/api/graphs/GenerateNodeMap.java +++ b/src/main/java/gregtech/api/graphs/GenerateNodeMap.java @@ -1,5 +1,6 @@ package gregtech.api.graphs; +import static gregtech.api.enums.GT_Values.ALL_VALID_SIDES; import static gregtech.api.util.GT_Utility.getOppositeSide; import gregtech.api.graphs.consumers.ConsumerNode; @@ -15,7 +16,7 @@ public abstract class GenerateNodeMap { // clearing the node map to make sure it is gone on reset public static void clearNodeMap(Node aNode, int aReturnNodeValue) { if (aNode.mTileEntity instanceof BaseMetaPipeEntity) { - BaseMetaPipeEntity tPipe = (BaseMetaPipeEntity) aNode.mTileEntity; + final BaseMetaPipeEntity tPipe = (BaseMetaPipeEntity) aNode.mTileEntity; tPipe.setNode(null); tPipe.setNodePath(null); if (aNode.mSelfPath != null) { @@ -23,24 +24,24 @@ public abstract class GenerateNodeMap { aNode.mSelfPath = null; } } - for (int i = 0; i < 6; i++) { - NodePath tPath = aNode.mNodePaths[i]; + for (byte side : ALL_VALID_SIDES) { + final NodePath tPath = aNode.mNodePaths[side]; if (tPath != null) { tPath.clearPath(); - aNode.mNodePaths[i] = null; + aNode.mNodePaths[side] = null; } - Node tNextNode = aNode.mNeighbourNodes[i]; + final Node tNextNode = aNode.mNeighbourNodes[side]; if (tNextNode == null) continue; if (tNextNode.mNodeValue != aReturnNodeValue) clearNodeMap(tNextNode, aNode.mNodeValue); - aNode.mNeighbourNodes[i] = null; + aNode.mNeighbourNodes[side] = null; } } // get how many connections the pipe have private static int getNumberOfConnections(MetaPipeEntity aPipe) { int tCons = 0; - for (int i = 0; i < 6; i++) { - if (aPipe.isConnectedAtSide(i)) tCons++; + for (byte side : ALL_VALID_SIDES) { + if (aPipe.isConnectedAtSide(side)) tCons++; } return tCons; } @@ -53,17 +54,17 @@ public abstract class GenerateNodeMap { int aNextNodeValue, ArrayList<ConsumerNode> tConsumers, HashSet<Node> tNodeMap) { - MetaPipeEntity tMetaPipe = (MetaPipeEntity) aPipe.getMetaTileEntity(); - for (byte i = 0; i < 6; i++) { - if (i == aInvalidSide) { + final MetaPipeEntity tMetaPipe = (MetaPipeEntity) aPipe.getMetaTileEntity(); + for (byte side : ALL_VALID_SIDES) { + if (side == aInvalidSide) { continue; } - TileEntity tNextTileEntity = aPipe.getTileEntityAtSide(i); - if (tNextTileEntity == null || (tMetaPipe != null && !tMetaPipe.isConnectedAtSide(i))) continue; - ArrayList<MetaPipeEntity> tNewPipes = new ArrayList<>(); - Pair nextTileEntity = getNextValidTileEntity(tNextTileEntity, tNewPipes, i, tNodeMap); + final TileEntity tNextTileEntity = aPipe.getTileEntityAtSide(side); + if (tNextTileEntity == null || (tMetaPipe != null && !tMetaPipe.isConnectedAtSide(side))) continue; + final ArrayList<MetaPipeEntity> tNewPipes = new ArrayList<>(); + final Pair nextTileEntity = getNextValidTileEntity(tNextTileEntity, tNewPipes, side, tNodeMap); if (nextTileEntity != null) { - Node tNextNode = generateNode( + final Node tNextNode = generateNode( nextTileEntity.mTileEntity, aPipeNode, aNextNodeValue + 1, @@ -74,10 +75,10 @@ public abstract class GenerateNodeMap { if (tNextNode != null) { aNextNodeValue = tNextNode.mHighestNodeValue; aPipeNode.mHighestNodeValue = tNextNode.mHighestNodeValue; - aPipeNode.mNeighbourNodes[i] = tNextNode; - aPipeNode.mNodePaths[i] = aPipeNode.returnValues.mReturnPath; - aPipeNode.locks[i] = aPipeNode.returnValues.returnLock; - aPipeNode.mNodePaths[i].reloadLocks(); + aPipeNode.mNeighbourNodes[side] = tNextNode; + aPipeNode.mNodePaths[side] = aPipeNode.returnValues.mReturnPath; + aPipeNode.locks[side] = aPipeNode.returnValues.returnLock; + aPipeNode.mNodePaths[side].reloadLocks(); } } } @@ -94,14 +95,14 @@ public abstract class GenerateNodeMap { ArrayList<ConsumerNode> aConsumers, HashSet<Node> aNodeMap) { if (aTileEntity.isInvalid()) return null; - byte tSideOp = getOppositeSide(aSide); - byte tInvalidSide = aPreviousNode == null ? -1 : tSideOp; + final byte tSideOp = getOppositeSide(aSide); + final byte tInvalidSide = aPreviousNode == null ? -1 : tSideOp; Node tThisNode = null; if (isPipe(aTileEntity)) { - BaseMetaPipeEntity tPipe = (BaseMetaPipeEntity) aTileEntity; - MetaPipeEntity tMetaPipe = (MetaPipeEntity) tPipe.getMetaTileEntity(); - int tConnections = getNumberOfConnections(tMetaPipe); - Node tPipeNode; + final BaseMetaPipeEntity tPipe = (BaseMetaPipeEntity) aTileEntity; + final MetaPipeEntity tMetaPipe = (MetaPipeEntity) tPipe.getMetaTileEntity(); + final int tConnections = getNumberOfConnections(tMetaPipe); + final Node tPipeNode; if (tConnections == 1) { tPipeNode = getEmptyNode(aNextNodeValue, tSideOp, aTileEntity, aConsumers); if (tPipeNode == null) return null; @@ -115,7 +116,7 @@ public abstract class GenerateNodeMap { if (tInvalidSide > -1) { tPipeNode.mNeighbourNodes[tInvalidSide] = aPreviousNode; tPipeNode.mNodePaths[tInvalidSide] = getNewPath(aPipes.toArray(new MetaPipeEntity[0])); - Lock lock = new Lock(); + final Lock lock = new Lock(); tPipeNode.mNodePaths[tSideOp].lock = lock; tPipeNode.locks[tInvalidSide] = lock; aPreviousNode.returnValues.mReturnPath = tPipeNode.mNodePaths[tInvalidSide]; @@ -124,10 +125,10 @@ public abstract class GenerateNodeMap { if (tConnections > 1) generateNextNode(tPipe, tPipeNode, tInvalidSide, aNextNodeValue, aConsumers, aNodeMap); } else if (addConsumer(aTileEntity, tSideOp, aNextNodeValue, aConsumers)) { - ConsumerNode tConsumeNode = aConsumers.get(aConsumers.size() - 1); + final ConsumerNode tConsumeNode = aConsumers.get(aConsumers.size() - 1); tConsumeNode.mNeighbourNodes[tSideOp] = aPreviousNode; tConsumeNode.mNodePaths[tSideOp] = getNewPath(aPipes.toArray(new MetaPipeEntity[0])); - Lock lock = new Lock(); + final Lock lock = new Lock(); tConsumeNode.mNodePaths[tSideOp].lock = lock; aPreviousNode.returnValues.mReturnPath = tConsumeNode.mNodePaths[tSideOp]; aPreviousNode.returnValues.returnLock = lock; @@ -140,18 +141,18 @@ public abstract class GenerateNodeMap { protected Pair getNextValidTileEntity( TileEntity aTileEntity, ArrayList<MetaPipeEntity> aPipes, byte aSide, HashSet<Node> aNodeMap) { if (isPipe(aTileEntity)) { - BaseMetaPipeEntity tPipe = (BaseMetaPipeEntity) aTileEntity; - MetaPipeEntity tMetaPipe = (MetaPipeEntity) tPipe.getMetaTileEntity(); - Node tNode = tPipe.getNode(); + final BaseMetaPipeEntity tPipe = (BaseMetaPipeEntity) aTileEntity; + final MetaPipeEntity tMetaPipe = (MetaPipeEntity) tPipe.getMetaTileEntity(); + final Node tNode = tPipe.getNode(); if (tNode != null) { if (aNodeMap.contains(tNode)) return null; } - int tConnections = getNumberOfConnections(tMetaPipe); + final int tConnections = getNumberOfConnections(tMetaPipe); if (tConnections == 2) { - byte tSideOp = getOppositeSide(aSide); - for (byte i = 0; i < 6; i++) { + final byte tSideOp = getOppositeSide(aSide); + for (byte i : ALL_VALID_SIDES) { if (i == tSideOp || !(tMetaPipe.isConnectedAtSide(i))) continue; - TileEntity tNewTileEntity = tPipe.getTileEntityAtSide(i); + final TileEntity tNewTileEntity = tPipe.getTileEntityAtSide(i); if (tNewTileEntity == null) continue; if (isPipe(tNewTileEntity)) { aPipes.add(tMetaPipe); diff --git a/src/main/java/gregtech/api/gui/modularui/GT_UIInfos.java b/src/main/java/gregtech/api/gui/modularui/GT_UIInfos.java index 2d776ce71e..d1e699bb40 100644 --- a/src/main/java/gregtech/api/gui/modularui/GT_UIInfos.java +++ b/src/main/java/gregtech/api/gui/modularui/GT_UIInfos.java @@ -70,9 +70,9 @@ public class GT_UIInfos { side, UIBuilder.of() .container((player, world, x, y, z) -> { - TileEntity te = world.getTileEntity(x, y, z); + final TileEntity te = world.getTileEntity(x, y, z); if (!(te instanceof ICoverable)) return null; - ICoverable gtTileEntity = (ICoverable) te; + final ICoverable gtTileEntity = (ICoverable) te; GT_CoverBehaviorBase<?> cover = gtTileEntity.getCoverBehaviorAtSideNew(side); return createCoverContainer( player, @@ -84,10 +84,10 @@ public class GT_UIInfos { }) .gui((player, world, x, y, z) -> { if (!world.isRemote) return null; - TileEntity te = world.getTileEntity(x, y, z); + final TileEntity te = world.getTileEntity(x, y, z); if (!(te instanceof ICoverable)) return null; - ICoverable gtTileEntity = (ICoverable) te; - GT_CoverBehaviorBase<?> cover = gtTileEntity.getCoverBehaviorAtSideNew(side); + final ICoverable gtTileEntity = (ICoverable) te; + final GT_CoverBehaviorBase<?> cover = gtTileEntity.getCoverBehaviorAtSideNew(side); return createCoverGuiContainer( player, cover::createWindow, @@ -148,11 +148,9 @@ public class GT_UIInfos { Function<UIBuildContext, ModularWindow> windowCreator, Runnable onWidgetUpdate, ContainerConstructor containerCreator) { - UIBuildContext buildContext = new UIBuildContext(player); - ModularWindow window = windowCreator.apply(buildContext); - if (window == null) { - return null; - } + final UIBuildContext buildContext = new UIBuildContext(player); + final ModularWindow window = windowCreator.apply(buildContext); + if (window == null) return null; return containerCreator.of(new ModularUIContext(buildContext, onWidgetUpdate), window); } @@ -161,10 +159,9 @@ public class GT_UIInfos { EntityPlayer player, Function<UIBuildContext, ModularWindow> windowCreator, ContainerConstructor containerConstructor) { - ModularUIContainer container = createTileEntityContainer(player, windowCreator, null, containerConstructor); - if (container == null) { - return null; - } + final ModularUIContainer container = + createTileEntityContainer(player, windowCreator, null, containerConstructor); + if (container == null) return null; return new ModularGui(container); } @@ -175,11 +172,9 @@ public class GT_UIInfos { int coverID, byte side, ICoverable tile) { - GT_CoverUIBuildContext buildContext = new GT_CoverUIBuildContext(player, coverID, side, tile, false); - ModularWindow window = windowCreator.apply(buildContext); - if (window == null) { - return null; - } + final GT_CoverUIBuildContext buildContext = new GT_CoverUIBuildContext(player, coverID, side, tile, false); + final ModularWindow window = windowCreator.apply(buildContext); + if (window == null) return null; return new ModularUIContainer(new ModularUIContext(buildContext, onWidgetUpdate), window); } @@ -190,7 +185,7 @@ public class GT_UIInfos { int coverID, byte side, ICoverable tile) { - ModularUIContainer container = createCoverContainer(player, windowCreator, null, coverID, side, tile); + final ModularUIContainer container = createCoverContainer(player, windowCreator, null, coverID, side, tile); if (container == null) { return null; } diff --git a/src/main/java/gregtech/api/gui/modularui/GT_UITextures.java b/src/main/java/gregtech/api/gui/modularui/GT_UITextures.java index a92ff64df6..3ca1e6d45e 100644 --- a/src/main/java/gregtech/api/gui/modularui/GT_UITextures.java +++ b/src/main/java/gregtech/api/gui/modularui/GT_UITextures.java @@ -347,4 +347,8 @@ public class GT_UITextures { public static final UITexture PICTURE_SQUARE_LIGHT_GRAY = UITexture.fullImage(MODID, "gui/picture/square_light_gray"); public static final UITexture PICTURE_GAUGE = UITexture.fullImage(MODID, "gui/picture/gauge"); + public static final UITexture PICTURE_ITEM_IN = UITexture.fullImage(MODID, "gui/picture/item_in"); + public static final UITexture PICTURE_ITEM_OUT = UITexture.fullImage(MODID, "gui/picture/item_out"); + public static final UITexture PICTURE_FLUID_IN = UITexture.fullImage(MODID, "gui/picture/fluid_in"); + public static final UITexture PICTURE_FLUID_OUT = UITexture.fullImage(MODID, "gui/picture/fluid_out"); } diff --git a/src/main/java/gregtech/api/gui/widgets/GT_GuiCoverTabLine.java b/src/main/java/gregtech/api/gui/widgets/GT_GuiCoverTabLine.java index 525618589b..d5e383ed50 100644 --- a/src/main/java/gregtech/api/gui/widgets/GT_GuiCoverTabLine.java +++ b/src/main/java/gregtech/api/gui/widgets/GT_GuiCoverTabLine.java @@ -79,7 +79,7 @@ public class GT_GuiCoverTabLine extends GT_GuiTabLine { */ private void setupTabs() { for (byte tSide = 0; tSide < 6; tSide++) { - ItemStack cover = tile.getCoverItemAtSide(tSide); + final ItemStack cover = tile.getCoverItemAtSide(tSide); if (cover != null) { addCoverToTabs(tSide, cover); } @@ -114,7 +114,7 @@ public class GT_GuiCoverTabLine extends GT_GuiTabLine { * @param cover */ private void addCoverToTabs(byte side, ItemStack cover) { - boolean enabled = this.tile.getCoverBehaviorAtSideNew(side).hasCoverGUI(); + final boolean enabled = this.tile.getCoverBehaviorAtSideNew(side).hasCoverGUI(); this.setTab(side, cover, null, getTooltipForCoverTab(side, cover, enabled)); this.setTabEnabled(side, enabled); } @@ -127,7 +127,7 @@ public class GT_GuiCoverTabLine extends GT_GuiTabLine { * @return This cover tab's tooltip */ private String[] getTooltipForCoverTab(byte side, ItemStack cover, boolean enabled) { - List<String> tooltip = cover.getTooltip(Minecraft.getMinecraft().thePlayer, true); + final List<String> tooltip = cover.getTooltip(Minecraft.getMinecraft().thePlayer, true); tooltip.set( 0, (enabled ? EnumChatFormatting.UNDERLINE : EnumChatFormatting.DARK_GRAY) @@ -158,9 +158,9 @@ public class GT_GuiCoverTabLine extends GT_GuiTabLine { static class CoverTabLineNEIHandler extends INEIGuiAdapter { @Override public boolean hideItemPanelSlot(GuiContainer gui, int x, int y, int w, int h) { - Rectangle neiSlotArea = new Rectangle(x, y, w, h); + final Rectangle neiSlotArea = new Rectangle(x, y, w, h); if (gui instanceof GT_GUIContainerMetaTile_Machine) { - GT_GuiTabLine tabLine = ((GT_GUIContainerMetaTile_Machine) gui).coverTabs; + final GT_GuiTabLine tabLine = ((GT_GUIContainerMetaTile_Machine) gui).coverTabs; if (!tabLine.visible) { return false; } diff --git a/src/main/java/gregtech/api/interfaces/covers/IControlsWorkCover.java b/src/main/java/gregtech/api/interfaces/covers/IControlsWorkCover.java index 7c2361af83..47edc7af93 100644 --- a/src/main/java/gregtech/api/interfaces/covers/IControlsWorkCover.java +++ b/src/main/java/gregtech/api/interfaces/covers/IControlsWorkCover.java @@ -1,5 +1,7 @@ package gregtech.api.interfaces.covers; +import static gregtech.api.enums.GT_Values.ALL_VALID_SIDES; + import gregtech.api.interfaces.tileentity.ICoverable; import gregtech.api.interfaces.tileentity.IMachineProgress; @@ -15,9 +17,9 @@ public interface IControlsWorkCover { * @return true if the cover is the first (side) one **/ static boolean makeSureOnlyOne(byte aMySide, ICoverable aTileEntity) { - for (byte i = 0; i < 6; i++) { - if (aTileEntity.getCoverBehaviorAtSideNew(i) instanceof IControlsWorkCover && i < aMySide) { - aTileEntity.dropCover(i, i, true); + for (byte tSide : ALL_VALID_SIDES) { + if (aTileEntity.getCoverBehaviorAtSideNew(tSide) instanceof IControlsWorkCover && tSide < aMySide) { + aTileEntity.dropCover(tSide, tSide, true); aTileEntity.markDirty(); return false; } diff --git a/src/main/java/gregtech/api/interfaces/metatileentity/IMetaTileEntityItemPipe.java b/src/main/java/gregtech/api/interfaces/metatileentity/IMetaTileEntityItemPipe.java index 1b1ce36871..5375ea85ee 100644 --- a/src/main/java/gregtech/api/interfaces/metatileentity/IMetaTileEntityItemPipe.java +++ b/src/main/java/gregtech/api/interfaces/metatileentity/IMetaTileEntityItemPipe.java @@ -1,5 +1,7 @@ package gregtech.api.interfaces.metatileentity; +import static gregtech.api.enums.GT_Values.ALL_VALI |
