diff --git a/src/main/java/gregtech/api/events/BlockScanningEvent.java b/src/main/java/gregtech/api/events/BlockScanningEvent.java index 27eb375a6f5..bc2a33bcea1 100644 --- a/src/main/java/gregtech/api/events/BlockScanningEvent.java +++ b/src/main/java/gregtech/api/events/BlockScanningEvent.java @@ -6,6 +6,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.event.world.WorldEvent; import cpw.mods.fml.common.eventhandler.Cancelable; @@ -16,7 +17,7 @@ public class BlockScanningEvent extends WorldEvent { public final EntityPlayer mPlayer; public final int mX, mY, mZ, mScanLevel; public final ArrayList mList; - public final byte mSide; + public final ForgeDirection mSide; public final float mClickX, mClickY, mClickZ; public final TileEntity mTileEntity; public final Block mBlock; @@ -26,15 +27,16 @@ public class BlockScanningEvent extends WorldEvent { */ public int mEUCost = 0; - public BlockScanningEvent(World aWorld, EntityPlayer aPlayer, int aX, int aY, int aZ, byte aSide, int aScanLevel, - Block aBlock, TileEntity aTileEntity, ArrayList aList, float aClickX, float aClickY, float aClickZ) { + public BlockScanningEvent(World aWorld, EntityPlayer aPlayer, int aX, int aY, int aZ, ForgeDirection side, + int aScanLevel, Block aBlock, TileEntity aTileEntity, ArrayList aList, float aClickX, float aClickY, + float aClickZ) { super(aWorld); mPlayer = aPlayer; mScanLevel = aScanLevel; mTileEntity = aTileEntity; mBlock = aBlock; mList = aList; - mSide = aSide; + mSide = side; mX = aX; mY = aY; mZ = aZ; diff --git a/src/main/java/gregtech/api/graphs/GenerateNodeMap.java b/src/main/java/gregtech/api/graphs/GenerateNodeMap.java index bbdfa40a10d..7289f0faad1 100644 --- a/src/main/java/gregtech/api/graphs/GenerateNodeMap.java +++ b/src/main/java/gregtech/api/graphs/GenerateNodeMap.java @@ -1,12 +1,12 @@ package gregtech.api.graphs; import static gregtech.api.enums.GT_Values.ALL_VALID_SIDES; -import static gregtech.api.util.GT_Utility.getOppositeSide; import java.util.ArrayList; import java.util.HashSet; import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.util.ForgeDirection; import gregtech.api.graphs.consumers.ConsumerNode; import gregtech.api.graphs.paths.NodePath; @@ -42,17 +42,17 @@ public static void clearNodeMap(Node aNode, int aReturnNodeValue) { // get how many connections the pipe have private static int getNumberOfConnections(MetaPipeEntity aPipe) { int tCons = 0; - for (byte side : ALL_VALID_SIDES) { + for (final ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { if (aPipe.isConnectedAtSide(side)) tCons++; } return tCons; } // gets the next node - protected void generateNextNode(BaseMetaPipeEntity aPipe, Node aPipeNode, byte aInvalidSide, int aNextNodeValue, - ArrayList tConsumers, HashSet tNodeMap) { + protected void generateNextNode(BaseMetaPipeEntity aPipe, Node aPipeNode, ForgeDirection aInvalidSide, + int aNextNodeValue, ArrayList tConsumers, HashSet tNodeMap) { final MetaPipeEntity tMetaPipe = (MetaPipeEntity) aPipe.getMetaTileEntity(); - for (byte side : ALL_VALID_SIDES) { + for (final ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { if (side == aInvalidSide) { continue; } @@ -70,12 +70,13 @@ protected void generateNextNode(BaseMetaPipeEntity aPipe, Node aPipeNode, byte a tConsumers, tNodeMap); if (tNextNode != null) { + final int i = side.ordinal(); aNextNodeValue = tNextNode.mHighestNodeValue; aPipeNode.mHighestNodeValue = tNextNode.mHighestNodeValue; - aPipeNode.mNeighbourNodes[side] = tNextNode; - aPipeNode.mNodePaths[side] = aPipeNode.returnValues.mReturnPath; - aPipeNode.locks[side] = aPipeNode.returnValues.returnLock; - aPipeNode.mNodePaths[side].reloadLocks(); + aPipeNode.mNeighbourNodes[i] = tNextNode; + aPipeNode.mNodePaths[i] = aPipeNode.returnValues.mReturnPath; + aPipeNode.locks[i] = aPipeNode.returnValues.returnLock; + aPipeNode.mNodePaths[i].reloadLocks(); } } } @@ -84,10 +85,11 @@ protected void generateNextNode(BaseMetaPipeEntity aPipe, Node aPipeNode, byte a // on a valid tile entity create a new node protected Node generateNode(TileEntity aTileEntity, Node aPreviousNode, int aNextNodeValue, - ArrayList aPipes, int aSide, ArrayList aConsumers, HashSet aNodeMap) { + ArrayList aPipes, ForgeDirection side, ArrayList aConsumers, + HashSet aNodeMap) { if (aTileEntity.isInvalid()) return null; - final byte tSideOp = getOppositeSide(aSide); - final byte tInvalidSide = aPreviousNode == null ? -1 : tSideOp; + final ForgeDirection oppositeSide = side.getOpposite(); + final ForgeDirection tInvalidSide = aPreviousNode == null ? ForgeDirection.UNKNOWN : oppositeSide; Node tThisNode = null; if (isPipe(aTileEntity)) { final BaseMetaPipeEntity tPipe = (BaseMetaPipeEntity) aTileEntity; @@ -95,33 +97,35 @@ protected Node generateNode(TileEntity aTileEntity, Node aPreviousNode, int aNex final int tConnections = getNumberOfConnections(tMetaPipe); final Node tPipeNode; if (tConnections == 1) { - tPipeNode = getEmptyNode(aNextNodeValue, tSideOp, aTileEntity, aConsumers); + tPipeNode = getEmptyNode(aNextNodeValue, oppositeSide, aTileEntity, aConsumers); if (tPipeNode == null) return null; } else { - tPipeNode = getPipeNode(aNextNodeValue, tSideOp, aTileEntity, aConsumers); + tPipeNode = getPipeNode(aNextNodeValue, oppositeSide, aTileEntity, aConsumers); } tPipe.setNode(tPipeNode); aNodeMap.add(tPipeNode); tPipeNode.mSelfPath = getNewPath(new MetaPipeEntity[] { tMetaPipe }); tThisNode = tPipeNode; - if (tInvalidSide > -1) { - tPipeNode.mNeighbourNodes[tInvalidSide] = aPreviousNode; - tPipeNode.mNodePaths[tInvalidSide] = getNewPath(aPipes.toArray(new MetaPipeEntity[0])); + if (tInvalidSide != ForgeDirection.UNKNOWN) { + final int iInvalid = tInvalidSide.ordinal(); + tPipeNode.mNeighbourNodes[iInvalid] = aPreviousNode; + tPipeNode.mNodePaths[iInvalid] = getNewPath(aPipes.toArray(new MetaPipeEntity[0])); final Lock lock = new Lock(); - tPipeNode.mNodePaths[tSideOp].lock = lock; - tPipeNode.locks[tInvalidSide] = lock; - aPreviousNode.returnValues.mReturnPath = tPipeNode.mNodePaths[tInvalidSide]; + tPipeNode.mNodePaths[oppositeSide.ordinal()].lock = lock; + tPipeNode.locks[iInvalid] = lock; + aPreviousNode.returnValues.mReturnPath = tPipeNode.mNodePaths[iInvalid]; aPreviousNode.returnValues.returnLock = lock; } if (tConnections > 1) generateNextNode(tPipe, tPipeNode, tInvalidSide, aNextNodeValue, aConsumers, aNodeMap); - } else if (addConsumer(aTileEntity, tSideOp, aNextNodeValue, aConsumers)) { + } else if (addConsumer(aTileEntity, oppositeSide, aNextNodeValue, aConsumers)) { + final int oppositeSideOrdinal = oppositeSide.ordinal(); final ConsumerNode tConsumeNode = aConsumers.get(aConsumers.size() - 1); - tConsumeNode.mNeighbourNodes[tSideOp] = aPreviousNode; - tConsumeNode.mNodePaths[tSideOp] = getNewPath(aPipes.toArray(new MetaPipeEntity[0])); + tConsumeNode.mNeighbourNodes[oppositeSideOrdinal] = aPreviousNode; + tConsumeNode.mNodePaths[oppositeSideOrdinal] = getNewPath(aPipes.toArray(new MetaPipeEntity[0])); final Lock lock = new Lock(); - tConsumeNode.mNodePaths[tSideOp].lock = lock; - aPreviousNode.returnValues.mReturnPath = tConsumeNode.mNodePaths[tSideOp]; + tConsumeNode.mNodePaths[oppositeSideOrdinal].lock = lock; + aPreviousNode.returnValues.mReturnPath = tConsumeNode.mNodePaths[oppositeSideOrdinal]; aPreviousNode.returnValues.returnLock = lock; tThisNode = tConsumeNode; } @@ -129,7 +133,7 @@ protected Node generateNode(TileEntity aTileEntity, Node aPreviousNode, int aNex } // go over the pipes until we see a valid tile entity that needs a node - protected Pair getNextValidTileEntity(TileEntity aTileEntity, ArrayList aPipes, byte aSide, + protected Pair getNextValidTileEntity(TileEntity aTileEntity, ArrayList aPipes, ForgeDirection side, HashSet aNodeMap) { if (isPipe(aTileEntity)) { final BaseMetaPipeEntity tPipe = (BaseMetaPipeEntity) aTileEntity; @@ -140,23 +144,23 @@ protected Pair getNextValidTileEntity(TileEntity aTileEntity, ArrayList aConsumers); // get correct pathClass that you need for your node network protected abstract NodePath getNewPath(MetaPipeEntity[] aPipes); // used for if you need to use dead ends for something can be null - protected Node getEmptyNode(int aNodeValue, byte aSide, TileEntity aTileEntity, + protected Node getEmptyNode(int aNodeValue, ForgeDirection side, TileEntity aTileEntity, ArrayList aConsumers) { return null; } // get correct node type you need for your network - protected Node getPipeNode(int aNodeValue, byte aSide, TileEntity aTileEntity, ArrayList aConsumers) { + protected Node getPipeNode(int aNodeValue, ForgeDirection side, TileEntity aTileEntity, + ArrayList aConsumers) { return new Node(aNodeValue, aTileEntity, aConsumers); } private static class Pair { - public byte mSide; + public ForgeDirection mSide; public TileEntity mTileEntity; - public Pair(TileEntity aTileEntity, byte aSide) { + public Pair(TileEntity aTileEntity, ForgeDirection side) { this.mTileEntity = aTileEntity; - this.mSide = aSide; + this.mSide = side; } } } diff --git a/src/main/java/gregtech/api/graphs/GenerateNodeMapPower.java b/src/main/java/gregtech/api/graphs/GenerateNodeMapPower.java index f2a2e95df82..95f9aee32d8 100644 --- a/src/main/java/gregtech/api/graphs/GenerateNodeMapPower.java +++ b/src/main/java/gregtech/api/graphs/GenerateNodeMapPower.java @@ -27,7 +27,7 @@ public class GenerateNodeMapPower extends GenerateNodeMap { public GenerateNodeMapPower(BaseMetaPipeEntity aTileEntity) { - generateNode(aTileEntity, null, 1, null, -1, new ArrayList<>(), new HashSet<>()); + generateNode(aTileEntity, null, 1, null, ForgeDirection.UNKNOWN, new ArrayList<>(), new HashSet<>()); } @Override @@ -37,27 +37,27 @@ protected boolean isPipe(TileEntity aTileEntity) { } @Override - protected boolean addConsumer(TileEntity aTileEntity, byte aSide, int aNodeValue, + protected boolean addConsumer(TileEntity aTileEntity, ForgeDirection side, int aNodeValue, ArrayList aConsumers) { if (aTileEntity instanceof BaseMetaTileEntity tBaseTileEntity) { - if (tBaseTileEntity.inputEnergyFrom(aSide, false)) { - ConsumerNode tConsumerNode = new NodeGTBaseMetaTile(aNodeValue, tBaseTileEntity, aSide, aConsumers); + if (tBaseTileEntity.inputEnergyFrom(side, false)) { + ConsumerNode tConsumerNode = new NodeGTBaseMetaTile(aNodeValue, tBaseTileEntity, side, aConsumers); aConsumers.add(tConsumerNode); return true; } } else if (aTileEntity instanceof IEnergyConnected tTileEntity) { - if (tTileEntity.inputEnergyFrom(aSide, false)) { - ConsumerNode tConsumerNode = new NodeEnergyConnected(aNodeValue, tTileEntity, aSide, aConsumers); + if (tTileEntity.inputEnergyFrom(side, false)) { + ConsumerNode tConsumerNode = new NodeEnergyConnected(aNodeValue, tTileEntity, side, aConsumers); aConsumers.add(tConsumerNode); return true; } - } else if (aTileEntity instanceof IEnergySink) { + } else if (aTileEntity instanceof IEnergySink sink) { // ic2 wants the tilentity next to it of that side not going to add a bunch of arguments just for ic2 // crossborder checks to not load chuncks just to make sure - int dX = aTileEntity.xCoord + ForgeDirection.getOrientation(aSide).offsetX; - int dY = aTileEntity.yCoord + ForgeDirection.getOrientation(aSide).offsetY; - int dZ = aTileEntity.zCoord + ForgeDirection.getOrientation(aSide).offsetZ; + int dX = aTileEntity.xCoord + side.offsetX; + int dY = aTileEntity.yCoord + side.offsetY; + int dZ = aTileEntity.zCoord + side.offsetZ; boolean crossesChuncks = dX >> 4 != aTileEntity.xCoord >> 4 || dZ >> 4 != aTileEntity.zCoord >> 4; TileEntity tNextTo = null; if (!crossesChuncks || !aTileEntity.getWorldObj() @@ -65,21 +65,17 @@ protected boolean addConsumer(TileEntity aTileEntity, byte aSide, int aNodeValue tNextTo = aTileEntity.getWorldObj() .getTileEntity(dX, dY, dZ); - if (((IEnergySink) aTileEntity).acceptsEnergyFrom(tNextTo, ForgeDirection.getOrientation(aSide))) { + if (sink.acceptsEnergyFrom(tNextTo, side)) { ConsumerNode tConsumerNode = new NodeEnergySink( aNodeValue, (IEnergySink) aTileEntity, - aSide, + side, aConsumers); aConsumers.add(tConsumerNode); return true; } - } else if (GregTech_API.mOutputRF && aTileEntity instanceof IEnergyReceiver) { - ConsumerNode tConsumerNode = new NodeEnergyReceiver( - aNodeValue, - (IEnergyReceiver) aTileEntity, - aSide, - aConsumers); + } else if (GregTech_API.mOutputRF && aTileEntity instanceof IEnergyReceiver receiver) { + ConsumerNode tConsumerNode = new NodeEnergyReceiver(aNodeValue, receiver, side, aConsumers); aConsumers.add(tConsumerNode); return true; } @@ -93,15 +89,16 @@ protected NodePath getNewPath(MetaPipeEntity[] aPipes) { // used to apply voltage on dead ends @Override - protected Node getEmptyNode(int aNodeValue, byte aSide, TileEntity aTileEntity, + protected Node getEmptyNode(int aNodeValue, ForgeDirection side, TileEntity aTileEntity, ArrayList aConsumers) { - ConsumerNode tNode = new EmptyPowerConsumer(aNodeValue, aTileEntity, aSide, aConsumers); + ConsumerNode tNode = new EmptyPowerConsumer(aNodeValue, aTileEntity, side, aConsumers); aConsumers.add(tNode); return tNode; } @Override - protected Node getPipeNode(int aNodeValue, byte aSide, TileEntity aTileEntity, ArrayList aConsumers) { + protected Node getPipeNode(int aNodeValue, ForgeDirection side, TileEntity aTileEntity, + ArrayList aConsumers) { return new PowerNode(aNodeValue, aTileEntity, aConsumers); } } diff --git a/src/main/java/gregtech/api/graphs/PowerNodes.java b/src/main/java/gregtech/api/graphs/PowerNodes.java index be94d2312ae..98d35e29713 100644 --- a/src/main/java/gregtech/api/graphs/PowerNodes.java +++ b/src/main/java/gregtech/api/graphs/PowerNodes.java @@ -120,13 +120,13 @@ protected static long powerNodeAbove(Node aCurrentNode, Node aPreviousNode, Node return tAmpsUsed; } - protected static long processNextNode(Node aCurrentNode, Node aNextNode, NodeList aConsumers, int aSide, + protected static long processNextNode(Node aCurrentNode, Node aNextNode, NodeList aConsumers, int ordinalSide, long aMaxAmps, long aVoltage) { - if (aCurrentNode.locks[aSide].isLocked()) { + if (aCurrentNode.locks[ordinalSide].isLocked()) { aConsumers.getNextNode(); return 0; } - final PowerNodePath tPath = (PowerNodePath) aCurrentNode.mNodePaths[aSide]; + final PowerNodePath tPath = (PowerNodePath) aCurrentNode.mNodePaths[ordinalSide]; final PowerNodePath tSelfPath = (PowerNodePath) aCurrentNode.mSelfPath; long tVoltLoss = 0; if (tSelfPath != null) { @@ -141,13 +141,13 @@ protected static long processNextNode(Node aCurrentNode, Node aNextNode, NodeLis return tAmps; } - protected static long processNextNodeAbove(Node aCurrentNode, Node aNextNode, NodeList aConsumers, int aSide, + protected static long processNextNodeAbove(Node aCurrentNode, Node aNextNode, NodeList aConsumers, int ordinalSide, long aMaxAmps, long aVoltage) { - if (aCurrentNode.locks[aSide].isLocked()) { + if (aCurrentNode.locks[ordinalSide].isLocked()) { aConsumers.getNextNode(); return 0; } - final PowerNodePath tPath = (PowerNodePath) aCurrentNode.mNodePaths[aSide]; + final PowerNodePath tPath = (PowerNodePath) aCurrentNode.mNodePaths[ordinalSide]; final PowerNodePath tSelfPath = (PowerNodePath) aCurrentNode.mSelfPath; long tVoltLoss = 0; if (tSelfPath != null) { @@ -162,10 +162,10 @@ protected static long processNextNodeAbove(Node aCurrentNode, Node aNextNode, No return tAmps; } - protected static long processNodeInject(Node aCurrentNode, ConsumerNode aConsumer, int aSide, long aMaxAmps, + protected static long processNodeInject(Node aCurrentNode, ConsumerNode aConsumer, int ordinalSide, long aMaxAmps, long aVoltage) { - if (aCurrentNode.locks[aSide].isLocked()) return 0; - final PowerNodePath tPath = (PowerNodePath) aCurrentNode.mNodePaths[aSide]; + if (aCurrentNode.locks[ordinalSide].isLocked()) return 0; + final PowerNodePath tPath = (PowerNodePath) aCurrentNode.mNodePaths[ordinalSide]; final PowerNodePath tSelfPath = (PowerNodePath) aCurrentNode.mSelfPath; long tVoltLoss = 0; if (tSelfPath != null) { diff --git a/src/main/java/gregtech/api/graphs/consumers/ConsumerNode.java b/src/main/java/gregtech/api/graphs/consumers/ConsumerNode.java index f82798f09bc..04d7ebbe5a7 100644 --- a/src/main/java/gregtech/api/graphs/consumers/ConsumerNode.java +++ b/src/main/java/gregtech/api/graphs/consumers/ConsumerNode.java @@ -3,17 +3,19 @@ import java.util.ArrayList; import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.util.ForgeDirection; import gregtech.api.graphs.Node; // node attached to a tile entity that can consume stuff from the network public class ConsumerNode extends Node { - public byte mSide; + public ForgeDirection mSide; - public ConsumerNode(int aNodeValue, TileEntity aTileEntity, byte aSide, ArrayList aConsumers) { + public ConsumerNode(int aNodeValue, TileEntity aTileEntity, ForgeDirection side, + ArrayList aConsumers) { super(aNodeValue, aTileEntity, aConsumers); - this.mSide = aSide; + this.mSide = side; } public boolean needsEnergy() { diff --git a/src/main/java/gregtech/api/graphs/consumers/EmptyPowerConsumer.java b/src/main/java/gregtech/api/graphs/consumers/EmptyPowerConsumer.java index 6507d0f8e46..48cf330bdb9 100644 --- a/src/main/java/gregtech/api/graphs/consumers/EmptyPowerConsumer.java +++ b/src/main/java/gregtech/api/graphs/consumers/EmptyPowerConsumer.java @@ -3,6 +3,7 @@ import java.util.ArrayList; import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.util.ForgeDirection; import gregtech.api.graphs.paths.PowerNodePath; import gregtech.api.metatileentity.BaseMetaPipeEntity; @@ -10,8 +11,9 @@ // this is here to apply voltage to dead ends public class EmptyPowerConsumer extends ConsumerNode { - public EmptyPowerConsumer(int aNodeValue, TileEntity aTileEntity, byte aSide, ArrayList aConsumers) { - super(aNodeValue, aTileEntity, aSide, aConsumers); + public EmptyPowerConsumer(int aNodeValue, TileEntity aTileEntity, ForgeDirection side, + ArrayList aConsumers) { + super(aNodeValue, aTileEntity, side, aConsumers); } @Override diff --git a/src/main/java/gregtech/api/graphs/consumers/NodeEnergyConnected.java b/src/main/java/gregtech/api/graphs/consumers/NodeEnergyConnected.java index 65dd50f9df8..6daeae8c9c5 100644 --- a/src/main/java/gregtech/api/graphs/consumers/NodeEnergyConnected.java +++ b/src/main/java/gregtech/api/graphs/consumers/NodeEnergyConnected.java @@ -3,14 +3,15 @@ import java.util.ArrayList; import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.util.ForgeDirection; import gregtech.api.interfaces.tileentity.IEnergyConnected; public class NodeEnergyConnected extends ConsumerNode { - public NodeEnergyConnected(int aNodeValue, IEnergyConnected aTileEntity, byte aSide, + public NodeEnergyConnected(int aNodeValue, IEnergyConnected aTileEntity, ForgeDirection side, ArrayList aConsumers) { - super(aNodeValue, (TileEntity) aTileEntity, aSide, aConsumers); + super(aNodeValue, (TileEntity) aTileEntity, side, aConsumers); } @Override diff --git a/src/main/java/gregtech/api/graphs/consumers/NodeEnergyReceiver.java b/src/main/java/gregtech/api/graphs/consumers/NodeEnergyReceiver.java index 4e84b04e2ae..4f359220296 100644 --- a/src/main/java/gregtech/api/graphs/consumers/NodeEnergyReceiver.java +++ b/src/main/java/gregtech/api/graphs/consumers/NodeEnergyReceiver.java @@ -21,14 +21,14 @@ public class NodeEnergyReceiver extends ConsumerNode { int mRestRF = 0; - public NodeEnergyReceiver(int aNodeValue, IEnergyReceiver aTileEntity, byte aSide, + public NodeEnergyReceiver(int aNodeValue, IEnergyReceiver aTileEntity, ForgeDirection side, ArrayList aConsumers) { - super(aNodeValue, (TileEntity) aTileEntity, aSide, aConsumers); + super(aNodeValue, (TileEntity) aTileEntity, side, aConsumers); } @Override public int injectEnergy(long aVoltage, long aMaxAmps) { - ForgeDirection tDirection = ForgeDirection.getOrientation(mSide); + ForgeDirection tDirection = mSide; int rfOut = GT_Utility.safeInt(aVoltage * GregTech_API.mEUtoRF / 100); int ampsUsed = 0; if (mRestRF < rfOut) { diff --git a/src/main/java/gregtech/api/graphs/consumers/NodeEnergySink.java b/src/main/java/gregtech/api/graphs/consumers/NodeEnergySink.java index d978a99d0bd..44fb88e5e8a 100644 --- a/src/main/java/gregtech/api/graphs/consumers/NodeEnergySink.java +++ b/src/main/java/gregtech/api/graphs/consumers/NodeEnergySink.java @@ -10,7 +10,8 @@ // consumer for IC2 machines public class NodeEnergySink extends ConsumerNode { - public NodeEnergySink(int nodeValue, IEnergySink tileEntity, byte side, ArrayList consumers) { + public NodeEnergySink(int nodeValue, IEnergySink tileEntity, ForgeDirection side, + ArrayList consumers) { super(nodeValue, (TileEntity) tileEntity, side, consumers); } @@ -23,9 +24,7 @@ public boolean needsEnergy() { public int injectEnergy(long aVoltage, long aMaxAmps) { int tUsedAmps = 0; while (aMaxAmps > tUsedAmps && ((IEnergySink) mTileEntity).getDemandedEnergy() > 0 - && ((IEnergySink) mTileEntity).injectEnergy(ForgeDirection.getOrientation(mSide), aVoltage, aVoltage) - < aVoltage) - tUsedAmps++; + && ((IEnergySink) mTileEntity).injectEnergy(mSide, aVoltage, aVoltage) < aVoltage) tUsedAmps++; return tUsedAmps; } } diff --git a/src/main/java/gregtech/api/graphs/consumers/NodeGTBaseMetaTile.java b/src/main/java/gregtech/api/graphs/consumers/NodeGTBaseMetaTile.java index ec75468db5f..e8d8304eb39 100644 --- a/src/main/java/gregtech/api/graphs/consumers/NodeGTBaseMetaTile.java +++ b/src/main/java/gregtech/api/graphs/consumers/NodeGTBaseMetaTile.java @@ -2,15 +2,17 @@ import java.util.ArrayList; +import net.minecraftforge.common.util.ForgeDirection; + import gregtech.api.interfaces.tileentity.IEnergyConnected; import gregtech.api.metatileentity.BaseMetaTileEntity; // consumer for gt machines public class NodeGTBaseMetaTile extends ConsumerNode { - public NodeGTBaseMetaTile(int aNodeValue, BaseMetaTileEntity aTileEntity, byte aSide, + public NodeGTBaseMetaTile(int aNodeValue, BaseMetaTileEntity aTileEntity, ForgeDirection side, ArrayList aConsumers) { - super(aNodeValue, aTileEntity, aSide, aConsumers); + super(aNodeValue, aTileEntity, side, aConsumers); } @Override diff --git a/src/main/java/gregtech/api/gui/modularui/GT_CoverUIBuildContext.java b/src/main/java/gregtech/api/gui/modularui/GT_CoverUIBuildContext.java index 62a933cfa61..20586b9c480 100644 --- a/src/main/java/gregtech/api/gui/modularui/GT_CoverUIBuildContext.java +++ b/src/main/java/gregtech/api/gui/modularui/GT_CoverUIBuildContext.java @@ -1,6 +1,7 @@ package gregtech.api.gui.modularui; import net.minecraft.entity.player.EntityPlayer; +import net.minecraftforge.common.util.ForgeDirection; import com.gtnewhorizons.modularui.api.screen.UIBuildContext; import gregtech.api.interfaces.tileentity.ICoverable; @@ -9,7 +10,7 @@ public class GT_CoverUIBuildContext extends UIBuildContext { // cover data is not synced to client, while ID is private final int coverID; - private final byte side; + private final ForgeDirection side; private final ICoverable tile; private final boolean anotherWindow; private final int guiColorization; @@ -22,8 +23,8 @@ public class GT_CoverUIBuildContext extends UIBuildContext { * @param anotherWindow If cover UI is shown on top of another window * @param guiColorization The color used to render machine's GUI */ - public GT_CoverUIBuildContext(EntityPlayer player, int coverID, byte side, ICoverable tile, boolean anotherWindow, - int guiColorization) { + public GT_CoverUIBuildContext(EntityPlayer player, int coverID, ForgeDirection side, ICoverable tile, + boolean anotherWindow, int guiColorization) { super(player); this.coverID = coverID; this.side = side; @@ -39,7 +40,8 @@ public GT_CoverUIBuildContext(EntityPlayer player, int coverID, byte side, ICove * @param tile Tile this cover is attached to * @param anotherWindow If cover GUI is shown in opened on top of another window */ - public GT_CoverUIBuildContext(EntityPlayer player, int coverID, byte side, ICoverable tile, boolean anotherWindow) { + public GT_CoverUIBuildContext(EntityPlayer player, int coverID, ForgeDirection side, ICoverable tile, + boolean anotherWindow) { this(player, coverID, side, tile, anotherWindow, tile.getGUIColorization()); } @@ -47,7 +49,7 @@ public int getCoverID() { return coverID; } - public byte getCoverSide() { + public ForgeDirection getCoverSide() { return side; } 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 b132f33d63d..afa60e5583d 100644 --- a/src/main/java/gregtech/api/gui/modularui/GT_UIInfos.java +++ b/src/main/java/gregtech/api/gui/modularui/GT_UIInfos.java @@ -40,23 +40,16 @@ public class GT_UIInfos { .of() .container((player, world, x, y, z) -> { TileEntity te = world.getTileEntity(x, y, z); - if (te instanceof ITileWithModularUI) { - return createTileEntityContainer( - player, - ((ITileWithModularUI) te)::createWindow, - te::markDirty, - containerConstructor); + if (te instanceof ITileWithModularUI mui) { + return createTileEntityContainer(player, mui::createWindow, te::markDirty, containerConstructor); } return null; }) .gui(((player, world, x, y, z) -> { if (!world.isRemote) return null; TileEntity te = world.getTileEntity(x, y, z); - if (te instanceof ITileWithModularUI) { - return createTileEntityGuiContainer( - player, - ((ITileWithModularUI) te)::createWindow, - containerConstructor); + if (te instanceof ITileWithModularUI mui) { + return createTileEntityGuiContainer(player, mui::createWindow, containerConstructor); } return null; })) @@ -64,18 +57,17 @@ public class GT_UIInfos { private static final UIInfo GTTileEntityDefaultUI = GTTileEntityUIFactory.apply(ModularUIContainer::new); - private static final Map> coverUI = new HashMap<>(); + private static final Map> coverUI = new HashMap<>(); static { - for (byte i = 0; i < ForgeDirection.VALID_DIRECTIONS.length; i++) { - final byte side = i; + for (final ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { coverUI.put( side, UIBuilder.of() .container((player, world, x, y, z) -> { final TileEntity te = world.getTileEntity(x, y, z); if (!(te instanceof ICoverable gtTileEntity)) return null; - GT_CoverBehaviorBase cover = gtTileEntity.getCoverBehaviorAtSideNew(side); + final GT_CoverBehaviorBase cover = gtTileEntity.getCoverBehaviorAtSideNew(side); return createCoverContainer( player, cover::createWindow, @@ -116,7 +108,7 @@ public static void openGTTileEntityUI(IHasWorldObjectAndCoords aTileEntity, Enti /** * Opens cover UI, created by {@link GT_CoverBehaviorBase#createWindow}. */ - public static void openCoverUI(ICoverable tileEntity, EntityPlayer player, byte side) { + public static void openCoverUI(ICoverable tileEntity, EntityPlayer player, ForgeDirection side) { if (tileEntity.isClientSide()) return; GT_Values.NW.sendToPlayer( @@ -167,8 +159,8 @@ private static ModularGui createTileEntityGuiContainer(EntityPlayer player, } private static ModularUIContainer createCoverContainer(EntityPlayer player, - Function windowCreator, Runnable onWidgetUpdate, int coverID, byte side, - ICoverable tile) { + Function windowCreator, Runnable onWidgetUpdate, int coverID, + ForgeDirection side, ICoverable tile) { final GT_CoverUIBuildContext buildContext = new GT_CoverUIBuildContext(player, coverID, side, tile, false); final ModularWindow window = windowCreator.apply(buildContext); if (window == null) return null; @@ -177,7 +169,8 @@ private static ModularUIContainer createCoverContainer(EntityPlayer player, @SideOnly(Side.CLIENT) private static ModularGui createCoverGuiContainer(EntityPlayer player, - Function windowCreator, int coverID, byte side, ICoverable tile) { + Function windowCreator, int coverID, ForgeDirection side, + ICoverable 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/widgets/GT_GuiCoverTabLine.java b/src/main/java/gregtech/api/gui/widgets/GT_GuiCoverTabLine.java index 9694316bee2..890e6298c97 100644 --- a/src/main/java/gregtech/api/gui/widgets/GT_GuiCoverTabLine.java +++ b/src/main/java/gregtech/api/gui/widgets/GT_GuiCoverTabLine.java @@ -8,6 +8,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; +import net.minecraftforge.common.util.ForgeDirection; import org.lwjgl.opengl.GL11; @@ -66,10 +67,10 @@ public GT_GuiCoverTabLine(GT_GUIContainerMetaTile_Machine gui, int tabLineLeft, * Add a tab for each existing cover on this IGregTechTileEntity at creation time */ private void setupTabs() { - for (byte tSide = 0; tSide < 6; tSide++) { - final ItemStack cover = tile.getCoverItemAtSide(tSide); + for (final ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + final ItemStack cover = tile.getCoverItemAtSide(side); if (cover != null) { - addCoverToTabs(tSide, cover); + addCoverToTabs(side, cover); } } } @@ -101,26 +102,27 @@ protected void tabClicked(int tabId, int mouseButton) { /** * Add the cover on this side of the IGregTechTileEntity to the tabs - * + * * @param side * @param cover */ - private void addCoverToTabs(byte side, ItemStack cover) { + private void addCoverToTabs(ForgeDirection side, ItemStack cover) { final boolean enabled = this.tile.getCoverBehaviorAtSideNew(side) .hasCoverGUI(); - this.setTab(side, cover, null, getTooltipForCoverTab(side, cover, enabled)); - this.setTabEnabled(side, enabled); + final int ordinalSide = side.ordinal(); + this.setTab(ordinalSide, cover, null, getTooltipForCoverTab(side, cover, enabled)); + this.setTabEnabled(ordinalSide, enabled); } /** * Decorate the cover's tooltips according to the side it's on and on whether the tab is enabled or not - * + * * @param side * @param cover * @param enabled * @return This cover tab's tooltip */ - private String[] getTooltipForCoverTab(byte side, ItemStack cover, boolean enabled) { + private String[] getTooltipForCoverTab(ForgeDirection side, ItemStack cover, boolean enabled) { final List tooltip = cover.getTooltip(Minecraft.getMinecraft().thePlayer, true); tooltip.set( 0, @@ -132,16 +134,17 @@ private String[] getTooltipForCoverTab(byte side, ItemStack cover, boolean enabl /** * Get the translated name for a side of the IGregTechTileEntity - * + * * @param side * @return translated name for a side of the IGregTechTileEntity */ - private String getSideDescription(byte side) { - if (side < SIDES.length) { - if (this.translatedSides[side] == null) { - this.translatedSides[side] = StatCollector.translateToLocal(SIDES[side]); + private String getSideDescription(ForgeDirection side) { + final int ordinalSide = side.ordinal(); + if (ordinalSide < SIDES.length) { + if (this.translatedSides[ordinalSide] == null) { + this.translatedSides[ordinalSide] = StatCollector.translateToLocal(SIDES[ordinalSide]); } - return this.translatedSides[side]; + return this.translatedSides[ordinalSide]; } return null; } diff --git a/src/main/java/gregtech/api/interfaces/IItemBehaviour.java b/src/main/java/gregtech/api/interfaces/IItemBehaviour.java index 1f67b9c1a8d..67bb505c6bc 100644 --- a/src/main/java/gregtech/api/interfaces/IItemBehaviour.java +++ b/src/main/java/gregtech/api/interfaces/IItemBehaviour.java @@ -10,6 +10,7 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; import gregtech.api.enums.SubTag; import gregtech.api.items.GT_MetaBase_Item; @@ -18,11 +19,11 @@ public interface IItemBehaviour { boolean onLeftClickEntity(E aItem, ItemStack aStack, EntityPlayer aPlayer, Entity aEntity); - boolean onItemUse(E aItem, ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, int aSide, - float hitX, float hitY, float hitZ); + boolean onItemUse(E aItem, ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, + int ordinalSide, float hitX, float hitY, float hitZ); boolean onItemUseFirst(E aItem, ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, - int aSide, float hitX, float hitY, float hitZ); + ForgeDirection side, float hitX, float hitY, float hitZ); ItemStack onItemRightClick(E aItem, ItemStack aStack, World aWorld, EntityPlayer aPlayer); diff --git a/src/main/java/gregtech/api/interfaces/IRedstoneCircuitBlock.java b/src/main/java/gregtech/api/interfaces/IRedstoneCircuitBlock.java index 91219368b78..0eea6ca3a49 100644 --- a/src/main/java/gregtech/api/interfaces/IRedstoneCircuitBlock.java +++ b/src/main/java/gregtech/api/interfaces/IRedstoneCircuitBlock.java @@ -2,6 +2,7 @@ import net.minecraft.block.Block; import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.util.ForgeDirection; import gregtech.api.interfaces.tileentity.ICoverable; import gregtech.api.util.GT_CoverBehavior; @@ -14,47 +15,47 @@ public interface IRedstoneCircuitBlock { /** * The Output Direction the Circuit Block is Facing */ - byte getOutputFacing(); + ForgeDirection getOutputFacing(); /** * sets Output Redstone State at Side */ - boolean setRedstone(byte aStrength, byte aSide); + boolean setRedstone(byte aStrength, ForgeDirection side); /** * returns Output Redstone State at Side Note that setRedstone checks if there is a Difference between the old and * the new Setting before consuming any Energy */ - byte getOutputRedstone(byte aSide); + byte getOutputRedstone(ForgeDirection side); /** * returns Input Redstone Signal at Side */ - byte getInputRedstone(byte aSide); + byte getInputRedstone(ForgeDirection side); /** * If this Side is Covered up and therefor not doing any Redstone */ - GT_CoverBehavior getCover(byte aSide); + GT_CoverBehavior getCover(ForgeDirection side); - int getCoverID(byte aSide); + int getCoverID(ForgeDirection side); - int getCoverVariable(byte aSide); + int getCoverVariable(ForgeDirection side); /** * returns whatever Block-ID is adjacent to the Redstone Circuit Block */ - Block getBlockAtSide(byte aSide); + Block getBlockAtSide(ForgeDirection side); /** * returns whatever Meta-Value is adjacent to the Redstone Circuit Block */ - byte getMetaIDAtSide(byte aSide); + byte getMetaIDAtSide(ForgeDirection side); /** * returns whatever TileEntity is adjacent to the Redstone Circuit Block */ - TileEntity getTileEntityAtSide(byte aSide); + TileEntity getTileEntityAtSide(ForgeDirection side); /** * returns whatever TileEntity is used by the Redstone Circuit Block diff --git a/src/main/java/gregtech/api/interfaces/covers/IControlsWorkCover.java b/src/main/java/gregtech/api/interfaces/covers/IControlsWorkCover.java index cef20ac3b77..d4cd1e9ec2e 100644 --- a/src/main/java/gregtech/api/interfaces/covers/IControlsWorkCover.java +++ b/src/main/java/gregtech/api/interfaces/covers/IControlsWorkCover.java @@ -1,6 +1,6 @@ package gregtech.api.interfaces.covers; -import static gregtech.api.enums.GT_Values.ALL_VALID_SIDES; +import net.minecraftforge.common.util.ForgeDirection; import gregtech.api.interfaces.tileentity.ICoverable; import gregtech.api.interfaces.tileentity.IMachineProgress; @@ -16,10 +16,11 @@ public interface IControlsWorkCover { * * @return true if the cover is the first (side) one **/ - static boolean makeSureOnlyOne(byte aMySide, ICoverable aTileEntity) { - for (byte tSide : ALL_VALID_SIDES) { - if (aTileEntity.getCoverBehaviorAtSideNew(tSide) instanceof IControlsWorkCover && tSide < aMySide) { - aTileEntity.dropCover(tSide, tSide, true); + static boolean makeSureOnlyOne(ForgeDirection aMySide, ICoverable aTileEntity) { + for (final ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + if (aTileEntity.getCoverBehaviorAtSideNew(side) instanceof IControlsWorkCover + && side.ordinal() < aMySide.ordinal()) { + aTileEntity.dropCover(side, side, true); aTileEntity.markDirty(); return false; } diff --git a/src/main/java/gregtech/api/interfaces/metatileentity/IConnectable.java b/src/main/java/gregtech/api/interfaces/metatileentity/IConnectable.java index 76d8d082ef8..0ca519d40b2 100644 --- a/src/main/java/gregtech/api/interfaces/metatileentity/IConnectable.java +++ b/src/main/java/gregtech/api/interfaces/metatileentity/IConnectable.java @@ -1,5 +1,7 @@ package gregtech.api.interfaces.metatileentity; +import net.minecraftforge.common.util.ForgeDirection; + /** * For pipes, wires, and other MetaTiles which need to be decided whether they should connect to the block at each side. */ @@ -21,12 +23,12 @@ public interface IConnectable { * Try to connect to the Block at the specified side returns the connection state. Non-positive values for failed, * others for succeeded. */ - int connect(byte aSide); + int connect(ForgeDirection side); /** * Try to disconnect to the Block at the specified side */ - void disconnect(byte aSide); + void disconnect(ForgeDirection side); - boolean isConnectedAtSide(int aSide); + boolean isConnectedAtSide(ForgeDirection side); } diff --git a/src/main/java/gregtech/api/interfaces/metatileentity/IMetaTileEntity.java b/src/main/java/gregtech/api/interfaces/metatileentity/IMetaTileEntity.java index a24e05f1a2b..c9377d10beb 100644 --- a/src/main/java/gregtech/api/interfaces/metatileentity/IMetaTileEntity.java +++ b/src/main/java/gregtech/api/interfaces/metatileentity/IMetaTileEntity.java @@ -16,6 +16,7 @@ import net.minecraft.util.AxisAlignedBB; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.IFluidHandler; import net.minecraftforge.fluids.IFluidTank; @@ -125,28 +126,30 @@ public interface IMetaTileEntity extends ISidedInventory, IFluidTank, IFluidHand * If a Cover of that Type can be placed on this Side. Also Called when the Facing of the Block Changes and a Cover * is on said Side. */ - boolean allowCoverOnSide(byte aSide, GT_ItemStack aStack); + boolean allowCoverOnSide(ForgeDirection side, GT_ItemStack aStack); /** * When a Player rightclicks the Facing with a Screwdriver. */ - void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ); + void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ); /** - * When a Player rightclicks the Facing with a Wrench. + * When a Player right-clicks the Facing with a Wrench. */ - boolean onWrenchRightClick(byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, float aZ); + boolean onWrenchRightClick(ForgeDirection side, ForgeDirection wrenchingSide, EntityPlayer entityPlayer, float aX, + float aY, float aZ); /** - * When a Player rightclicks the Facing with a wire cutter. + * When a Player right-clicks the Facing with a wire cutter. */ - boolean onWireCutterRightClick(byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, float aZ); + boolean onWireCutterRightClick(ForgeDirection side, ForgeDirection wrenchingSide, EntityPlayer entityPlayer, + float aX, float aY, float aZ); /** - * When a Player rightclicks the Facing with a soldering iron. + * When a Player right-clicks the Facing with a soldering iron. */ - boolean onSolderingToolRightClick(byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, - float aZ); + boolean onSolderingToolRightClick(ForgeDirection side, ForgeDirection wrenchingSide, EntityPlayer entityPlayer, + float aX, float aY, float aZ); /** * Called right before this Machine explodes @@ -181,10 +184,10 @@ boolean onSolderingToolRightClick(byte aSide, byte aWrenchingSide, EntityPlayer void onRemoval(); /** - * @param aFacing + * @param facing * @return if aFacing would be a valid Facing for this Device. Used for wrenching. */ - boolean isFacingValid(byte aFacing); + boolean isFacingValid(ForgeDirection facing); /** * @return the Server Side Container @@ -214,12 +217,12 @@ default boolean useModularUI() { /** * From new ISidedInventory */ - boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack); + boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, ItemStack aStack); /** * From new ISidedInventory */ - boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack); + boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, ItemStack aStack); /** * @return if aIndex is a valid Slot. false for things like HoloSlots. Is used for determining if an Item is dropped @@ -243,12 +246,12 @@ default boolean useModularUI() { /** * If this Side can connect to inputting pipes */ - boolean isLiquidInput(byte aSide); + boolean isLiquidInput(ForgeDirection side); /** * If this Side can connect to outputting pipes */ - boolean isLiquidOutput(byte aSide); + boolean isLiquidOutput(ForgeDirection side); /** * Just an Accessor for the Name variable. @@ -261,12 +264,12 @@ default boolean useModularUI() { boolean isAccessAllowed(EntityPlayer aPlayer); /** - * a Player rightclicks the Machine Sneaky rightclicks are not getting passed to this! + * a Player right-clicks the Machine Sneaky right clicks are not getting passed to this! * * @return */ - boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, byte aSide, float aX, float aY, - float aZ); + boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, ForgeDirection side, float aX, + float aY, float aZ); /** * a Player leftclicks the Machine Sneaky leftclicks are getting passed to this unlike with the rightclicks. @@ -364,22 +367,17 @@ default Power getPower() { /** * Icon of the Texture. If this returns null then it falls back to getTextureIndex. * - * @param aSide is the Side of the Block - * @param aFacing is the direction the Block is facing (or a Bitmask of all Connections in case of Pipes) - * @param aColorIndex The Minecraft Color the Block is having - * @param aActive if the Machine is currently active (use this instead of calling - * mBaseMetaTileEntity.mActive!!!). Note: In case of Pipes this means if this Side is connected - * to something or not. - * @param aRedstone if the Machine is currently outputting a RedstoneSignal (use this instead of calling - * mBaseMetaTileEntity.mRedstone!!!) + * @param side is the Side of the Block + * @param facing is the direction the Block is facing + * @param colorIndex The Minecraft Color the Block is having + * @param active if the Machine is currently active (use this instead of calling + * {@code mBaseMetaTileEntity.mActive)}. Note: In case of Pipes this means if this Side is + * connected to something or not. + * @param redstoneLevel if the Machine is currently outputting a RedstoneSignal (use this instead of calling + * {@code mBaseMetaTileEntity.mRedstone} !!!) */ - ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, - boolean aActive, boolean aRedstone); - - /** - * The Textures used for the Item rendering. Return null if you want the regular 3D Block Rendering. - */ - // public ITexture[] getItemTexture(ItemStack aStack); + ITexture[] getTexture(IGregTechTileEntity baseMetaTileEntity, ForgeDirection side, ForgeDirection facing, + int colorIndex, boolean active, boolean redstoneLevel); /** * Register Icons here. This gets called when the Icons get initialized by the Base Block Best is you put your Icons @@ -405,9 +403,9 @@ ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte /** * Gets the Output for the comparator on the given Side */ - byte getComparatorValue(byte aSide); + byte getComparatorValue(ForgeDirection side); - float getExplosionResistance(byte aSide); + float getExplosionResistance(ForgeDirection side); String[] getInfoData(); @@ -415,7 +413,7 @@ ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte ItemStack[] getRealInventory(); - boolean connectsToItemPipe(byte aSide); + boolean connectsToItemPipe(ForgeDirection side); void onColorChangeServer(byte aColor); diff --git a/src/main/java/gregtech/api/interfaces/metatileentity/IMetaTileEntityCable.java b/src/main/java/gregtech/api/interfaces/metatileentity/IMetaTileEntityCable.java index 3f7bc73383f..a2d672e7653 100644 --- a/src/main/java/gregtech/api/interfaces/metatileentity/IMetaTileEntityCable.java +++ b/src/main/java/gregtech/api/interfaces/metatileentity/IMetaTileEntityCable.java @@ -4,14 +4,16 @@ import java.util.HashSet; import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.util.ForgeDirection; -public interface IMetaTileEntityCable extends IMetaTileEntity { +public interface IMetaTileEntityCable extends IMetaTileEntityPipe { @Deprecated - long transferElectricity(byte aSide, long aVoltage, long aAmperage, + long transferElectricity(ForgeDirection side, long aVoltage, long aAmperage, ArrayList aAlreadyPassedTileEntityList); - default long transferElectricity(byte aSide, long aVoltage, long aAmperage, HashSet aAlreadyPassedSet) { - return transferElectricity(aSide, aVoltage, aAmperage, new ArrayList<>(aAlreadyPassedSet)); + default long transferElectricity(ForgeDirection side, long aVoltage, long aAmperage, + HashSet aAlreadyPassedSet) { + return transferElectricity(side, aVoltage, aAmperage, new ArrayList<>(aAlreadyPassedSet)); } } diff --git a/src/main/java/gregtech/api/interfaces/metatileentity/IMetaTileEntityItemPipe.java b/src/main/java/gregtech/api/interfaces/metatileentity/IMetaTileEntityItemPipe.java index 76d3f56e748..0c2c5ebf28f 100644 --- a/src/main/java/gregtech/api/interfaces/metatileentity/IMetaTileEntityItemPipe.java +++ b/src/main/java/gregtech/api/interfaces/metatileentity/IMetaTileEntityItemPipe.java @@ -1,14 +1,13 @@ package gregtech.api.interfaces.metatileentity; -import static gregtech.api.enums.GT_Values.ALL_VALID_SIDES; - import java.util.Map; +import net.minecraftforge.common.util.ForgeDirection; + import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.BaseMetaPipeEntity; -import gregtech.api.util.GT_Utility; -public interface IMetaTileEntityItemPipe extends IMetaTileEntity { +public interface IMetaTileEntityItemPipe extends IMetaTileEntityPipe { /** * @return if this Pipe can still be used. @@ -32,10 +31,10 @@ public interface IMetaTileEntityItemPipe extends IMetaTileEntity { * Executes the Sending Code for inserting Stacks into the TileEntities. * * @param aSender the BaseMetaTileEntity sending the Stack. - * @param aSide the Side of the PIPE facing the TileEntity. + * @param side the Side of the PIPE facing the TileEntity. * @return if this Side was allowed to Output into the Block. */ - boolean insertItemStackIntoTileEntity(Object aSender, byte aSide); + boolean insertItemStackIntoTileEntity(Object aSender, ForgeDirection side); /** * Can be used to make flow control Pipes, like Redpowers Restriction Tubes. Every normal Pipe returns a Value of @@ -59,11 +58,10 @@ public static Map scanPipes(IMetaTileEntityItemPi if (aMap.get(aMetaTileEntity) == null || aMap.get(aMetaTileEntity) > aStep) { final IGregTechTileEntity aBaseMetaTileEntity = aMetaTileEntity.getBaseMetaTileEntity(); aMap.put(aMetaTileEntity, aStep); - byte oppositeSide; - for (byte side : ALL_VALID_SIDES) { + for (final ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { if (aMetaTileEntity instanceof IConnectable && !((IConnectable) aMetaTileEntity).isConnectedAtSide(side)) continue; - oppositeSide = GT_Utility.getOppositeSide(side); + final ForgeDirection oppositeSide = side.getOpposite(); if (aSuckItems) { if (aBaseMetaTileEntity.getCoverInfoAtSide(side) .letsItemsIn(-2)) { diff --git a/src/main/java/gregtech/api/interfaces/metatileentity/IMetaTileEntityPipe.java b/src/main/java/gregtech/api/interfaces/metatileentity/IMetaTileEntityPipe.java new file mode 100644 index 00000000000..0ac29b2e45f --- /dev/null +++ b/src/main/java/gregtech/api/interfaces/metatileentity/IMetaTileEntityPipe.java @@ -0,0 +1,24 @@ +package gregtech.api.interfaces.metatileentity; + +import net.minecraftforge.common.util.ForgeDirection; + +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; + +public interface IMetaTileEntityPipe extends IMetaTileEntity { + + /** + * Icon of the Texture. If this returns null then it falls back to getTextureIndex. + * + * @param side is the Side of the Block + * @param facingBitMask is the Bitmask of all Connections + * @param colorIndex The Minecraft Color the Block is having + * @param active if the Machine is currently active (use this instead of calling + * mBaseMetaTileEntity.mActive!!!). Note: In case of Pipes this means if this Side is connected + * to something or not. + * @param redstoneLevel if the Machine is currently outputting a RedstoneSignal (use this instead of calling + * mBaseMetaTileEntity.mRedstone!!!) + */ + ITexture[] getTexture(IGregTechTileEntity baseMetaTileEntity, ForgeDirection side, int facingBitMask, + int colorIndex, boolean active, boolean redstoneLevel); +} diff --git a/src/main/java/gregtech/api/interfaces/tileentity/IBasicEnergyContainer.java b/src/main/java/gregtech/api/interfaces/tileentity/IBasicEnergyContainer.java index 4e64742db0e..37d62894bb3 100644 --- a/src/main/java/gregtech/api/interfaces/tileentity/IBasicEnergyContainer.java +++ b/src/main/java/gregtech/api/interfaces/tileentity/IBasicEnergyContainer.java @@ -1,5 +1,7 @@ package gregtech.api.interfaces.tileentity; +import net.minecraftforge.common.util.ForgeDirection; + /** * Interface for internal Code, which is mainly used for independent Energy conversion. */ @@ -57,7 +59,7 @@ public interface IBasicEnergyContainer extends IEnergyConnected, IHasWorldObject /** * Drain Energy Call for Electricity. */ - boolean drainEnergyUnits(byte aSide, long aVoltage, long aAmperage); + boolean drainEnergyUnits(ForgeDirection side, long aVoltage, long aAmperage); /** * returns the amount of Electricity, accepted by this Block the last 5 ticks as Average. diff --git a/src/main/java/gregtech/api/interfaces/tileentity/ICoverable.java b/src/main/java/gregtech/api/interfaces/tileentity/ICoverable.java index d3186258ef5..112a7035d76 100644 --- a/src/main/java/gregtech/api/interfaces/tileentity/ICoverable.java +++ b/src/main/java/gregtech/api/interfaces/tileentity/ICoverable.java @@ -2,6 +2,7 @@ import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; import gregtech.api.util.GT_CoverBehavior; import gregtech.api.util.GT_CoverBehaviorBase; @@ -10,80 +11,81 @@ public interface ICoverable extends IRedstoneTileEntity, IHasInventory, IBasicEnergyContainer { - boolean canPlaceCoverIDAtSide(byte aSide, int aID); + boolean canPlaceCoverIDAtSide(ForgeDirection side, int aID); - boolean canPlaceCoverItemAtSide(byte aSide, ItemStack aCover); + boolean canPlaceCoverItemAtSide(ForgeDirection side, ItemStack aCover); - boolean dropCover(byte aSide, byte aDroppedSide, boolean aForced); + boolean dropCover(ForgeDirection side, ForgeDirection droppedSide, boolean aForced); @Deprecated - void setCoverDataAtSide(byte aSide, int aData); + void setCoverDataAtSide(ForgeDirection side, int aData); - default void setCoverDataAtSide(byte aSide, ISerializableObject aData) { + default void setCoverDataAtSide(ForgeDirection side, ISerializableObject aData) { if (aData instanceof ISerializableObject.LegacyCoverData) - setCoverDataAtSide(aSide, ((ISerializableObject.LegacyCoverData) aData).get()); + setCoverDataAtSide(side, ((ISerializableObject.LegacyCoverData) aData).get()); } - void setCoverIdAndDataAtSide(byte aSide, int aId, ISerializableObject aData); + void setCoverIdAndDataAtSide(ForgeDirection side, int aId, ISerializableObject aData); - void setCoverIDAtSide(byte aSide, int aID); + void setCoverIDAtSide(ForgeDirection side, int aID); - boolean setCoverIDAtSideNoUpdate(byte aSide, int aID); + boolean setCoverIDAtSideNoUpdate(ForgeDirection side, int aID); - void setCoverItemAtSide(byte aSide, ItemStack aCover); + void setCoverItemAtSide(ForgeDirection side, ItemStack aCover); @Deprecated - int getCoverDataAtSide(byte aSide); + int getCoverDataAtSide(ForgeDirection side); - default CoverInfo getCoverInfoAtSide(byte aSide) { + default CoverInfo getCoverInfoAtSide(ForgeDirection side) { return null; } - default ISerializableObject getComplexCoverDataAtSide(byte aSide) { - return new ISerializableObject.LegacyCoverData(getCoverDataAtSide(aSide)); + default ISerializableObject getComplexCoverDataAtSide(ForgeDirection side) { + return new ISerializableObject.LegacyCoverData(getCoverDataAtSide(side)); } - int getCoverIDAtSide(byte aSide); + int getCoverIDAtSide(ForgeDirection side); - ItemStack getCoverItemAtSide(byte aSide); + ItemStack getCoverItemAtSide(ForgeDirection side); @Deprecated - GT_CoverBehavior getCoverBehaviorAtSide(byte aSide); + GT_CoverBehavior getCoverBehaviorAtSide(ForgeDirection side); - default GT_CoverBehaviorBase getCoverBehaviorAtSideNew(byte aSide) { - return getCoverBehaviorAtSide(aSide); + default GT_CoverBehaviorBase getCoverBehaviorAtSideNew(ForgeDirection side) { + return getCoverBehaviorAtSide(side); } /** * For use by the regular MetaTileEntities. Returns the Cover Manipulated input Redstone. Don't use this if you are * a Cover Behavior. Only for MetaTileEntities. */ - byte getInternalInputRedstoneSignal(byte aSide); + byte getInternalInputRedstoneSignal(ForgeDirection side); /** * For use by the regular MetaTileEntities. This makes it not conflict with Cover based Redstone Signals. Don't use * this if you are a Cover Behavior. Only for MetaTileEntities. */ - void setInternalOutputRedstoneSignal(byte aSide, byte aStrength); + void setInternalOutputRedstoneSignal(ForgeDirection side, byte aStrength); /** * Causes a general Cover Texture update. Sends 6 Integers to Client + causes @issueTextureUpdate() */ - void issueCoverUpdate(byte aSide); + void issueCoverUpdate(ForgeDirection side); /** * Receiving a packet with cover data. */ - void receiveCoverData(byte coverSide, int coverID, int coverData); + void receiveCoverData(ForgeDirection coverSide, int coverID, int coverData); /** * Receiving a packet with cover data. - * - * @param aPlayer the player who made the change + * + * @param coverSide + * @param aPlayer the player who made the change */ - default void receiveCoverData(byte aCoverSide, int aCoverID, ISerializableObject aCoverData, + default void receiveCoverData(ForgeDirection coverSide, int aCoverID, ISerializableObject aCoverData, EntityPlayerMP aPlayer) { if (aCoverData instanceof ISerializableObject.LegacyCoverData) - receiveCoverData(aCoverSide, aCoverID, ((ISerializableObject.LegacyCoverData) aCoverData).get()); + receiveCoverData(coverSide, aCoverID, ((ISerializableObject.LegacyCoverData) aCoverData).get()); } } diff --git a/src/main/java/gregtech/api/interfaces/tileentity/IEnergyConnected.java b/src/main/java/gregtech/api/interfaces/tileentity/IEnergyConnected.java index 55de2db0884..f866092d38d 100644 --- a/src/main/java/gregtech/api/interfaces/tileentity/IEnergyConnected.java +++ b/src/main/java/gregtech/api/interfaces/tileentity/IEnergyConnected.java @@ -24,28 +24,28 @@ public interface IEnergyConnected extends IColoredTileEntity { *

* Note: you have to check for @inputEnergyFrom because the Network won't check for that by itself. * - * @param aSide 0 - 5 = Vanilla Directions of YOUR Block the Energy gets inserted to. 6 = No specific Side (don't do - * Side checks for this Side) + * @param side 0 - 5 = Vanilla Directions of YOUR Block the Energy gets inserted to. 6 = No specific Side (don't do + * Side checks for this Side) * @return amount of used Amperes. 0 if not accepted anything. */ - long injectEnergyUnits(byte aSide, long aVoltage, long aAmperage); + long injectEnergyUnits(ForgeDirection side, long aVoltage, long aAmperage); /** * Sided Energy Input */ - boolean inputEnergyFrom(byte aSide); + boolean inputEnergyFrom(ForgeDirection side); - default boolean inputEnergyFrom(byte aSide, boolean waitForActive) { - return inputEnergyFrom(aSide); + default boolean inputEnergyFrom(ForgeDirection side, boolean waitForActive) { + return inputEnergyFrom(side); } /** * Sided Energy Output */ - boolean outputsEnergyTo(byte aSide); + boolean outputsEnergyTo(ForgeDirection side); - default boolean outputsEnergyTo(byte aSide, boolean waitForActive) { - return outputsEnergyTo(aSide); + default boolean outputsEnergyTo(ForgeDirection side, boolean waitForActive) { + return outputsEnergyTo(side); } /** @@ -64,43 +64,38 @@ public static long emitEnergyToNetwork(long aVoltage, long aAmperage, IEnergyCon return 0; } - for (byte i = 0, j = 0; i < 6 && aAmperage > rUsedAmperes; i++) { - if (!aEmitter.outputsEnergyTo(i)) { + for (final ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + if (rUsedAmperes > aAmperage) break; + if (!aEmitter.outputsEnergyTo(side)) { continue; } - j = GT_Utility.getOppositeSide(i); - final TileEntity tTileEntity = emitterTile.getTileEntityAtSide(i); + final ForgeDirection oppositeSide = side.getOpposite(); + final TileEntity tTileEntity = emitterTile.getTileEntityAtSide(side); if (tTileEntity instanceof PowerLogicHost host) { - PowerLogic logic = host.getPowerLogic(ForgeDirection.getOrientation(j)); + final PowerLogic logic = host.getPowerLogic(oppositeSide); if (logic == null || logic.isEnergyReceiver()) { continue; } rUsedAmperes += logic.injectEnergy(aVoltage, aAmperage - rUsedAmperes); - } else if (tTileEntity instanceof IEnergyConnected) { + } else if (tTileEntity instanceof IEnergyConnected energyConnected) { if (aEmitter.getColorization() >= 0) { - final byte tColor = ((IEnergyConnected) tTileEntity).getColorization(); + final byte tColor = energyConnected.getColorization(); if (tColor >= 0 && tColor != aEmitter.getColorization()) continue; } - rUsedAmperes += ((IEnergyConnected) tTileEntity) - .injectEnergyUnits(j, aVoltage, aAmperage - rUsedAmperes); + rUsedAmperes += energyConnected.injectEnergyUnits(oppositeSide, aVoltage, aAmperage - rUsedAmperes); - } else if (tTileEntity instanceof IEnergySink) { - if (((IEnergySink) tTileEntity) - .acceptsEnergyFrom((TileEntity) aEmitter, ForgeDirection.getOrientation(j))) { - while (aAmperage > rUsedAmperes && ((IEnergySink) tTileEntity).getDemandedEnergy() > 0 - && ((IEnergySink) tTileEntity) - .injectEnergy(ForgeDirection.getOrientation(j), aVoltage, aVoltage) < aVoltage) - rUsedAmperes++; + } else if (tTileEntity instanceof IEnergySink sink) { + if (sink.acceptsEnergyFrom((TileEntity) aEmitter, oppositeSide)) { + while (aAmperage > rUsedAmperes && sink.getDemandedEnergy() > 0 + && sink.injectEnergy(oppositeSide, aVoltage, aVoltage) < aVoltage) rUsedAmperes++; } - } else if (GregTech_API.mOutputRF && tTileEntity instanceof IEnergyReceiver) { - final ForgeDirection tDirection = ForgeDirection.getOrientation(i) - .getOpposite(); + } else if (GregTech_API.mOutputRF && tTileEntity instanceof IEnergyReceiver receiver) { final int rfOut = GT_Utility.safeInt(aVoltage * GregTech_API.mEUtoRF / 100); - if (((IEnergyReceiver) tTileEntity).receiveEnergy(tDirection, rfOut, true) == rfOut) { - ((IEnergyReceiver) tTileEntity).receiveEnergy(tDirection, rfOut, false); + if (receiver.receiveEnergy(oppositeSide, rfOut, true) == rfOut) { + receiver.receiveEnergy(oppositeSide, rfOut, false); rUsedAmperes++; } } diff --git a/src/main/java/gregtech/api/interfaces/tileentity/IExperimentalEnergyTileEntity.java b/src/main/java/gregtech/api/interfaces/tileentity/IExperimentalEnergyTileEntity.java deleted file mode 100644 index aa1b9a11c6b..00000000000 --- a/src/main/java/gregtech/api/interfaces/tileentity/IExperimentalEnergyTileEntity.java +++ /dev/null @@ -1,112 +0,0 @@ -package gregtech.api.interfaces.tileentity; - -import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.util.ForgeDirection; - -import cofh.api.energy.IEnergyReceiver; -import gregtech.api.enums.SubTag; -import gregtech.api.util.GT_Utility; -import ic2.api.energy.tile.IEnergySink; - -/** - * THIS IS GOING TO BE USED IN 1.8 - *

- * Interface for getting Connected to the GregTech Energy Network. - *

- * This is all you need to connect to the GT Network. IColoredTileEntity is needed for not connecting differently - * coloured Blocks to each other. IHasWorldObjectAndCoords is needed for the InWorld related Stuff. @BaseTileEntity does - * implement most of that Interface. - */ -public interface IExperimentalEnergyTileEntity extends IColoredTileEntity, IHasWorldObjectAndCoords { - - /** - * Inject Energy Call for Electricity. Gets called by EnergyEmitters to inject Energy into your Block - *

- * Note: you have to check for @inputEnergyFrom because the Network won't check for that by itself. - * - * @param aSide 0 - 5 = Vanilla Directions of YOUR Block the Energy gets inserted to. 6 = No specific Side (don't do - * Side checks for this Side) - * @return amount of used Amperes. 0 if not accepted anything. - */ - long injectEnergy(SubTag aEnergyType, byte aSide, long aPrimary, long aSecondary); - - /** - * Sided Energy Input - */ - boolean inputEnergyFrom(SubTag aEnergyType, byte aSide); - - /** - * Sided Energy Output - */ - boolean outputsEnergyTo(SubTag aEnergyType, byte aSide); - - /** - * Utility for the Network - */ - class Util { - - public static int RF_PER_EU = 4; - private static boolean RF_ENERGY = false, IC_ENERGY = false, CHECK_ALL = true; - - private static void checkAvailabilities() { - if (CHECK_ALL) { - try { - Class tClass = cofh.api.energy.IEnergyReceiver.class; - tClass.getCanonicalName(); - RF_ENERGY = true; - } catch (Throwable e) { - /**/ - } - try { - Class tClass = ic2.api.energy.tile.IEnergySink.class; - tClass.getCanonicalName(); - IC_ENERGY = true; - } catch (Throwable e) { - /**/ - } - CHECK_ALL = false; - } - } - - /** - * Emits Energy to the adjacent Blocks. Also compatible with adjacent IC2 TileEntities when electric and RF - * TileEntities when RedstoneFlux. - * - * @return the amount of used secondary value. - */ - public static final long emitEnergyToNetwork(SubTag aEnergyType, long aPrimary, long aSecondary, - IExperimentalEnergyTileEntity aEmitter) { - long rUsedSecondary = 0; - checkAvailabilities(); - for (byte i = 0, j = 0; i < 6 && aSecondary > rUsedSecondary; i++) - if (aEmitter.outputsEnergyTo(aEnergyType, i)) { - j = GT_Utility.getOppositeSide(i); - TileEntity tTileEntity = aEmitter.getTileEntityAtSide(i); - if (tTileEntity instanceof IExperimentalEnergyTileEntity) { - if (aEmitter.getColorization() >= 0) { - byte tColor = ((IExperimentalEnergyTileEntity) tTileEntity).getColorization(); - if (tColor >= 0 && tColor != aEmitter.getColorization()) continue; - } - rUsedSecondary += ((IExperimentalEnergyTileEntity) tTileEntity) - .injectEnergy(aEnergyType, j, aPrimary, aSecondary - rUsedSecondary); - } else if (IC_ENERGY && aEnergyType == SubTag.ENERGY_ELECTRICITY - && tTileEntity instanceof IEnergySink) { - if (((IEnergySink) tTileEntity) - .acceptsEnergyFrom((TileEntity) aEmitter, ForgeDirection.getOrientation(j))) { - while (aSecondary > rUsedSecondary - && ((IEnergySink) tTileEntity).getDemandedEnergy() > 0 - && ((IEnergySink) tTileEntity) - .injectEnergy(ForgeDirection.getOrientation(j), aPrimary, aPrimary) < aPrimary) - rUsedSecondary++; - } - } else if (RF_ENERGY && aEnergyType == SubTag.ENERGY_REDSTONE_FLUX - && tTileEntity instanceof IEnergyReceiver - && ((IEnergyReceiver) tTileEntity).canConnectEnergy(ForgeDirection.getOrientation(j))) { - rUsedSecondary += ((IEnergyReceiver) tTileEntity) - .receiveEnergy(ForgeDirection.getOrientation(j), (int) aSecondary, false); - } - } - return rUsedSecondary; - } - } -} diff --git a/src/main/java/gregtech/api/interfaces/tileentity/IFibreConnected.java b/src/main/java/gregtech/api/interfaces/tileentity/IFibreConnected.java index a301c21a766..2f7f26e7230 100644 --- a/src/main/java/gregtech/api/interfaces/tileentity/IFibreConnected.java +++ b/src/main/java/gregtech/api/interfaces/tileentity/IFibreConnected.java @@ -1,5 +1,7 @@ package gregtech.api.interfaces.tileentity; +import net.minecraftforge.common.util.ForgeDirection; + /** * This File has just internal Information about the Fibre Redstone State of a TileEntity */ @@ -8,25 +10,25 @@ public interface IFibreConnected extends IColoredTileEntity, IHasWorldObjectAndC /** * If this Blocks accepts Fibre from this Side */ - void inputFibreFrom(byte aSide); + void inputFibreFrom(ForgeDirection side); /** * If this Blocks emits Fibre to this Side */ - void outputsFibreTo(byte aSide); + void outputsFibreTo(ForgeDirection side); /** * Sets the Signal this Blocks outputs to this Fibre Color */ - void setFibreOutput(byte aSide, byte aColor, byte aRedstoneStrength); + void setFibreOutput(ForgeDirection side, byte aColor, byte aRedstoneStrength); /** * Gets the Signal this Blocks outputs to this Fibre Color */ - byte getFibreOutput(byte aSide, byte aColor); + byte getFibreOutput(ForgeDirection side, byte aColor); /** * Gets the Signal this Blocks receives from this Fibre Color */ - byte getFibreInput(byte aSide, byte aColor); + byte getFibreInput(ForgeDirection side, byte aColor); } diff --git a/src/main/java/gregtech/api/interfaces/tileentity/IGearEnergyTileEntity.java b/src/main/java/gregtech/api/interfaces/tileentity/IGearEnergyTileEntity.java index 31e9b51719c..eefcbcb5ac0 100644 --- a/src/main/java/gregtech/api/interfaces/tileentity/IGearEnergyTileEntity.java +++ b/src/main/java/gregtech/api/interfaces/tileentity/IGearEnergyTileEntity.java @@ -1,18 +1,21 @@ package gregtech.api.interfaces.tileentity; +import net.minecraftforge.common.util.ForgeDirection; + public interface IGearEnergyTileEntity { /** * If Rotation Energy can be accepted on this Side. This means that the Gear/Axle will connect to this Side, and can * cause the Gear/Axle to stop if the Energy isn't accepted. */ - boolean acceptsRotationalEnergy(byte aSide); + boolean acceptsRotationalEnergy(ForgeDirection side); /** * Inject Energy Call for Rotational Energy. Rotation Energy can't be stored, this is just for things like internal * Dynamos, which convert it into Energy, or into Progress. * + * @param side * @param aSpeed Positive = Clockwise, Negative = Counterclockwise */ - boolean injectRotationalEnergy(byte aSide, long aSpeed, long aEnergy); + boolean injectRotationalEnergy(ForgeDirection side, long aSpeed, long aEnergy); } diff --git a/src/main/java/gregtech/api/interfaces/tileentity/IGregTechTileEntity.java b/src/main/java/gregtech/api/interfaces/tileentity/IGregTechTileEntity.java index 23e4d662c9d..5062f0fce59 100644 --- a/src/main/java/gregtech/api/interfaces/tileentity/IGregTechTileEntity.java +++ b/src/main/java/gregtech/api/interfaces/tileentity/IGregTechTileEntity.java @@ -10,6 +10,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.AxisAlignedBB; import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.IFluidHandler; import cpw.mods.fml.relauncher.Side; @@ -128,9 +129,9 @@ public interface IGregTechTileEntity extends ITexturedTileEntity, IGearEnergyTil /** * Called when rightclicking the TileEntity */ - boolean onRightclick(EntityPlayer aPlayer, byte aSide, float aX, float aY, float aZ); + boolean onRightclick(EntityPlayer aPlayer, ForgeDirection side, float aX, float aY, float aZ); - float getBlastResistance(byte aSide); + float getBlastResistance(ForgeDirection side); default void onBlockDestroyed() {} diff --git a/src/main/java/gregtech/api/interfaces/tileentity/IHasWorldObjectAndCoords.java b/src/main/java/gregtech/api/interfaces/tileentity/IHasWorldObjectAndCoords.java index f02672365ed..64d206aff77 100644 --- a/src/main/java/gregtech/api/interfaces/tileentity/IHasWorldObjectAndCoords.java +++ b/src/main/java/gregtech/api/interfaces/tileentity/IHasWorldObjectAndCoords.java @@ -8,6 +8,7 @@ import net.minecraft.util.ChunkCoordinates; import net.minecraft.world.World; import net.minecraft.world.biome.BiomeGenBase; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.IFluidHandler; /** @@ -43,91 +44,91 @@ default ChunkCoordinates getCoords() { TileEntity getTileEntityOffset(int aX, int aY, int aZ); - TileEntity getTileEntityAtSide(byte aSide); + TileEntity getTileEntityAtSide(ForgeDirection side); - TileEntity getTileEntityAtSideAndDistance(byte aSide, int aDistance); + TileEntity getTileEntityAtSideAndDistance(ForgeDirection side, int aDistance); IInventory getIInventory(int aX, int aY, int aZ); IInventory getIInventoryOffset(int aX, int aY, int aZ); - IInventory getIInventoryAtSide(byte aSide); + IInventory getIInventoryAtSide(ForgeDirection side); - IInventory getIInventoryAtSideAndDistance(byte aSide, int aDistance); + IInventory getIInventoryAtSideAndDistance(ForgeDirection side, int aDistance); IFluidHandler getITankContainer(int aX, int aY, int aZ); IFluidHandler getITankContainerOffset(int aX, int aY, int aZ); - IFluidHandler getITankContainerAtSide(byte aSide); + IFluidHandler getITankContainerAtSide(ForgeDirection side); - IFluidHandler getITankContainerAtSideAndDistance(byte aSide, int aDistance); + IFluidHandler getITankContainerAtSideAndDistance(ForgeDirection side, int aDistance); IGregTechTileEntity getIGregTechTileEntity(int aX, int aY, int aZ); IGregTechTileEntity getIGregTechTileEntityOffset(int aX, int aY, int aZ); - IGregTechTileEntity getIGregTechTileEntityAtSide(byte aSide); + IGregTechTileEntity getIGregTechTileEntityAtSide(ForgeDirection side); - IGregTechTileEntity getIGregTechTileEntityAtSideAndDistance(byte aSide, int aDistance); + IGregTechTileEntity getIGregTechTileEntityAtSideAndDistance(ForgeDirection side, int aDistance); Block getBlock(int aX, int aY, int aZ); Block getBlockOffset(int aX, int aY, int aZ); - Block getBlockAtSide(byte aSide); + Block getBlockAtSide(ForgeDirection side); - Block getBlockAtSideAndDistance(byte aSide, int aDistance); + Block getBlockAtSideAndDistance(ForgeDirection side, int aDistance); byte getMetaID(int aX, int aY, int aZ); byte getMetaIDOffset(int aX, int aY, int aZ); - byte getMetaIDAtSide(byte aSide); + byte getMetaIDAtSide(ForgeDirection side); - byte getMetaIDAtSideAndDistance(byte aSide, int aDistance); + byte getMetaIDAtSideAndDistance(ForgeDirection side, int aDistance); byte getLightLevel(int aX, int aY, int aZ); byte getLightLevelOffset(int aX, int aY, int aZ); - byte getLightLevelAtSide(byte aSide); + byte getLightLevelAtSide(ForgeDirection side); - byte getLightLevelAtSideAndDistance(byte aSide, int aDistance); + byte getLightLevelAtSideAndDistance(ForgeDirection side, int aDistance); boolean getOpacity(int aX, int aY, int aZ); boolean getOpacityOffset(int aX, int aY, int aZ); - boolean getOpacityAtSide(byte aSide); + boolean getOpacityAtSide(ForgeDirection side); - boolean getOpacityAtSideAndDistance(byte aSide, int aDistance); + boolean getOpacityAtSideAndDistance(ForgeDirection side, int aDistance); boolean getSky(int aX, int aY, int aZ); boolean getSkyOffset(int aX, int aY, int aZ); - boolean getSkyAtSide(byte aSide); + boolean getSkyAtSide(ForgeDirection side); - boolean getSkyAtSideAndDistance(byte aSide, int aDistance); + boolean getSkyAtSideAndDistance(ForgeDirection side, int aDistance); boolean getAir(int aX, int aY, int aZ); boolean getAirOffset(int aX, int aY, int aZ); - boolean getAirAtSide(byte aSide); + boolean getAirAtSide(ForgeDirection side); - boolean getAirAtSideAndDistance(byte aSide, int aDistance); + boolean getAirAtSideAndDistance(ForgeDirection side, int aDistance); BiomeGenBase getBiome(); BiomeGenBase getBiome(int aX, int aZ); - int getOffsetX(byte aSide, int aMultiplier); + int getOffsetX(ForgeDirection side, int aMultiplier); - short getOffsetY(byte aSide, int aMultiplier); + short getOffsetY(ForgeDirection side, int aMultiplier); - int getOffsetZ(byte aSide, int aMultiplier); + int getOffsetZ(ForgeDirection side, int aMultiplier); /** * Checks if the TileEntity is Invalid or Unloaded. Stupid Minecraft cannot do that btw. @@ -168,7 +169,7 @@ default ChunkCoordinates getCoords() { /** * Opens the GUI with this ID of this MetaTileEntity - * + * * @deprecated Use ModularUI */ @Deprecated @@ -178,7 +179,7 @@ default boolean openGUI(EntityPlayer aPlayer, int aID) { /** * Opens the GUI with the ID = 0 of this TileEntity - * + * * @deprecated Use ModularUI */ @Deprecated diff --git a/src/main/java/gregtech/api/interfaces/tileentity/IPipeRenderedTileEntity.java b/src/main/java/gregtech/api/interfaces/tileentity/IPipeRenderedTileEntity.java index 3cc3c6404d9..ab476449f05 100644 --- a/src/main/java/gregtech/api/interfaces/tileentity/IPipeRenderedTileEntity.java +++ b/src/main/java/gregtech/api/interfaces/tileentity/IPipeRenderedTileEntity.java @@ -1,5 +1,7 @@ package gregtech.api.interfaces.tileentity; +import net.minecraftforge.common.util.ForgeDirection; + import gregtech.api.interfaces.ITexture; public interface IPipeRenderedTileEntity extends ICoverable, ITexturedTileEntity { @@ -8,9 +10,9 @@ public interface IPipeRenderedTileEntity extends ICoverable, ITexturedTileEntity byte getConnections(); - ITexture[] getTextureUncovered(byte aSide); + ITexture[] getTextureUncovered(ForgeDirection side); - default ITexture[] getTextureCovered(byte aSide) { - return getTextureUncovered(aSide); + default ITexture[] getTextureCovered(ForgeDirection side) { + return getTextureUncovered(side); } } diff --git a/src/main/java/gregtech/api/interfaces/tileentity/IRedstoneEmitter.java b/src/main/java/gregtech/api/interfaces/tileentity/IRedstoneEmitter.java index fba20ee79dc..1b280184ce7 100644 --- a/src/main/java/gregtech/api/interfaces/tileentity/IRedstoneEmitter.java +++ b/src/main/java/gregtech/api/interfaces/tileentity/IRedstoneEmitter.java @@ -1,5 +1,7 @@ package gregtech.api.interfaces.tileentity; +import net.minecraftforge.common.util.ForgeDirection; + /** * This File has just internal Information about the Redstone State of a TileEntity */ @@ -7,8 +9,11 @@ public interface IRedstoneEmitter extends IHasWorldObjectAndCoords { /** * gets the Redstone Level the TileEntity should emit to the given Output Side + * + * @param side the {@link ForgeDirection} side + * @return the Redstone Level the TileEntity */ - byte getOutputRedstoneSignal(byte aSide); + byte getOutputRedstoneSignal(ForgeDirection side); /** * sets the Redstone Level the TileEntity should emit to the given Output Side @@ -17,12 +22,12 @@ public interface IRedstoneEmitter extends IHasWorldObjectAndCoords { * internal Output Redstone, so that it doesnt conflict with Cover Redstone. This sets the true Redstone Output * Signal. Only Cover Behaviors should use it, not MetaTileEntities. */ - void setOutputRedstoneSignal(byte aSide, byte aStrength); + void setOutputRedstoneSignal(ForgeDirection side, byte aStrength); /** * gets the Redstone Level the TileEntity should emit to the given Output Side */ - byte getStrongOutputRedstoneSignal(byte aSide); + byte getStrongOutputRedstoneSignal(ForgeDirection side); /** * sets the Redstone Level the TileEntity should emit to the given Output Side @@ -31,17 +36,17 @@ public interface IRedstoneEmitter extends IHasWorldObjectAndCoords { * internal Output Redstone, so that it doesnt conflict with Cover Redstone. This sets the true Redstone Output * Signal. Only Cover Behaviors should use it, not MetaTileEntities. */ - void setStrongOutputRedstoneSignal(byte aSide, byte aStrength); + void setStrongOutputRedstoneSignal(ForgeDirection side, byte aStrength); /** * Gets the Output for the comparator on the given Side */ - byte getComparatorValue(byte aSide); + byte getComparatorValue(ForgeDirection side); /** * Get the redstone output signal strength for a given side */ - default byte getGeneralRS(byte aSide) { + default byte getGeneralRS(ForgeDirection side) { return 0; } } diff --git a/src/main/java/gregtech/api/interfaces/tileentity/IRedstoneReceiver.java b/src/main/java/gregtech/api/interfaces/tileentity/IRedstoneReceiver.java index d5fb814c524..a41e9aaf7af 100644 --- a/src/main/java/gregtech/api/interfaces/tileentity/IRedstoneReceiver.java +++ b/src/main/java/gregtech/api/interfaces/tileentity/IRedstoneReceiver.java @@ -1,5 +1,7 @@ package gregtech.api.interfaces.tileentity; +import net.minecraftforge.common.util.ForgeDirection; + /** * This File has just internal Information about the Redstone State of a TileEntity */ @@ -12,7 +14,7 @@ public interface IRedstoneReceiver extends IHasWorldObjectAndCoords { * Input Redstone This returns the true incoming Redstone Signal. Only Cover Behaviors should check it, not * MetaTileEntities. */ - byte getInputRedstoneSignal(byte aSide); + byte getInputRedstoneSignal(ForgeDirection side); /** * gets the strongest Redstone Level the TileEntity receives @@ -27,5 +29,5 @@ public interface IRedstoneReceiver extends IHasWorldObjectAndCoords { /** * gets if the TileEntity receives Redstone at this Side */ - boolean getRedstone(byte aSide); + boolean getRedstone(ForgeDirection side); } diff --git a/src/main/java/gregtech/api/interfaces/tileentity/ITexturedTileEntity.java b/src/main/java/gregtech/api/interfaces/tileentity/ITexturedTileEntity.java index d6024b612e1..379111b07e9 100644 --- a/src/main/java/gregtech/api/interfaces/tileentity/ITexturedTileEntity.java +++ b/src/main/java/gregtech/api/interfaces/tileentity/ITexturedTileEntity.java @@ -1,6 +1,7 @@ package gregtech.api.interfaces.tileentity; import net.minecraft.block.Block; +import net.minecraftforge.common.util.ForgeDirection; import gregtech.api.interfaces.ITexture; @@ -9,5 +10,5 @@ public interface ITexturedTileEntity { /** * @return the Textures rendered by the GT Rendering */ - ITexture[] getTexture(Block aBlock, byte aSide); + ITexture[] getTexture(Block aBlock, ForgeDirection side); } diff --git a/src/main/java/gregtech/api/interfaces/tileentity/ITurnable.java b/src/main/java/gregtech/api/interfaces/tileentity/ITurnable.java index e54a85090e5..64cc8675ef1 100644 --- a/src/main/java/gregtech/api/interfaces/tileentity/ITurnable.java +++ b/src/main/java/gregtech/api/interfaces/tileentity/ITurnable.java @@ -1,6 +1,6 @@ package gregtech.api.interfaces.tileentity; -import static gregtech.api.enums.GT_Values.ALL_VALID_SIDES; +import net.minecraftforge.common.util.ForgeDirection; /** * Implemented by all my Machines. However without any security checks, if the Players are even allowed to rotate it. @@ -12,34 +12,34 @@ public interface ITurnable { * * @return front Block facing */ - byte getFrontFacing(); + ForgeDirection getFrontFacing(); /** * Set the block's facing * - * @param aSide facing to set the block to + * @param side facing to set the block to */ - void setFrontFacing(byte aSide); + void setFrontFacing(ForgeDirection side); /** * Get the block's back facing. * * @return opposite Block facing */ - byte getBackFacing(); + ForgeDirection getBackFacing(); /** * Determine if the wrench can be used to set the block's facing. */ - boolean isValidFacing(byte aSide); + boolean isValidFacing(ForgeDirection side); /** * Get the list of valid facings */ default boolean[] getValidFacings() { final boolean[] validFacings = new boolean[6]; - for (byte facing : ALL_VALID_SIDES) { - validFacings[facing] = isValidFacing(facing); + for (final ForgeDirection facing : ForgeDirection.VALID_DIRECTIONS) { + validFacings[facing.ordinal()] = isValidFacing(facing); } return validFacings; } diff --git a/src/main/java/gregtech/api/items/GT_Block_LongDistancePipe.java b/src/main/java/gregtech/api/items/GT_Block_LongDistancePipe.java index dbd8ffecf67..31a44f3dbc4 100644 --- a/src/main/java/gregtech/api/items/GT_Block_LongDistancePipe.java +++ b/src/main/java/gregtech/api/items/GT_Block_LongDistancePipe.java @@ -90,7 +90,7 @@ public String getLocalizedName() { } @Override - public IIcon getIcon(int aSide, int aMeta) { + public IIcon getIcon(int ordinalSide, int aMeta) { return mIcons[aMeta % mIcons.length].getIcon(); } 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 f1646529ea2..4b3c713f229 100644 --- a/src/main/java/gregtech/api/items/GT_MetaBase_Item.java +++ b/src/main/java/gregtech/api/items/GT_MetaBase_Item.java @@ -19,6 +19,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.IFluidContainerItem; @@ -139,14 +140,14 @@ public boolean onLeftClickEntity(ItemStack aStack, EntityPlayer aPlayer, Entity } @Override - public boolean onItemUse(ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, int aSide, - float hitX, float hitY, float hitZ) { + public boolean onItemUse(ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, + int ordinalSide, float hitX, float hitY, float hitZ) { use(aStack, 0, aPlayer); isItemStackUsable(aStack); ArrayList> tList = mItemBehaviors.get((short) getDamage(aStack)); try { if (tList != null) for (IItemBehaviour tBehavior : tList) - if (tBehavior.onItemUse(this, aStack, aPlayer, aWorld, aX, aY, aZ, aSide, hitX, hitY, hitZ)) { + if (tBehavior.onItemUse(this, aStack, aPlayer, aWorld, aX, aY, aZ, ordinalSide, hitX, hitY, hitZ)) { if (aStack.stackSize <= 0) aPlayer.destroyCurrentEquippedItem(); return true; } @@ -162,13 +163,23 @@ public boolean onItemUse(ItemStack aStack, EntityPlayer aPlayer, World aWorld, i @Override public boolean onItemUseFirst(ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, - int aSide, float hitX, float hitY, float hitZ) { + int ordinalSide, float hitX, float hitY, float hitZ) { use(aStack, 0, aPlayer); isItemStackUsable(aStack); ArrayList> tList = mItemBehaviors.get((short) getDamage(aStack)); try { - if (tList != null) for (IItemBehaviour tBehavior : tList) - if (tBehavior.onItemUseFirst(this, aStack, aPlayer, aWorld, aX, aY, aZ, aSide, hitX, hitY, hitZ)) { + if (tList != null) for (IItemBehaviour tBehavior : tList) if (tBehavior.onItemUseFirst( + this, + aStack, + aPlayer, + aWorld, + aX, + aY, + aZ, + ForgeDirection.getOrientation(ordinalSide), + hitX, + hitY, + hitZ)) { if (aStack.stackSize <= 0) aPlayer.destroyCurrentEquippedItem(); return true; } diff --git a/src/main/java/gregtech/api/items/GT_SolderingTool_Item.java b/src/main/java/gregtech/api/items/GT_SolderingTool_Item.java index 07a0c3bd9b3..6ec06c91a55 100644 --- a/src/main/java/gregtech/api/items/GT_SolderingTool_Item.java +++ b/src/main/java/gregtech/api/items/GT_SolderingTool_Item.java @@ -46,8 +46,8 @@ public void addAdditionalToolTips(List aList, ItemStack aStack, EntityPl @Override public boolean onItemUseFirst(ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, - int aSide, float hitX, float hitY, float hitZ) { - super.onItemUseFirst(aStack, aPlayer, aWorld, aX, aY, aZ, aSide, hitX, hitY, hitZ); + int ordinalSide, float hitX, float hitY, float hitZ) { + super.onItemUseFirst(aStack, aPlayer, aWorld, aX, aY, aZ, ordinalSide, hitX, hitY, hitZ); return false; } } diff --git a/src/main/java/gregtech/api/items/GT_Spray_Bug_Item.java b/src/main/java/gregtech/api/items/GT_Spray_Bug_Item.java index 29df584326e..0716ca9dc13 100644 --- a/src/main/java/gregtech/api/items/GT_Spray_Bug_Item.java +++ b/src/main/java/gregtech/api/items/GT_Spray_Bug_Item.java @@ -38,8 +38,8 @@ public GT_Spray_Bug_Item(String aUnlocalized, String aEnglish, int aMaxDamage, i */ @Override public boolean onItemUseFirst(ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, - int aSide, float hitX, float hitY, float hitZ) { - super.onItemUseFirst(aStack, aPlayer, aWorld, aX, aY, aZ, aSide, hitX, hitY, hitZ); + int ordinalSide, float hitX, float hitY, float hitZ) { + super.onItemUseFirst(aStack, aPlayer, aWorld, aX, aY, aZ, ordinalSide, hitX, hitY, hitZ); if (aWorld.isRemote) { return false; } diff --git a/src/main/java/gregtech/api/items/GT_Spray_Foam_Item.java b/src/main/java/gregtech/api/items/GT_Spray_Foam_Item.java index 0a68e222f8a..6bdca0da1ca 100644 --- a/src/main/java/gregtech/api/items/GT_Spray_Foam_Item.java +++ b/src/main/java/gregtech/api/items/GT_Spray_Foam_Item.java @@ -32,22 +32,10 @@ public GT_Spray_Foam_Item(String aUnlocalized, String aEnglish, int aMaxDamage, */ } - /* - * @Override public ItemStack getEmptiedItem(ItemStack aStack) { return ItemList.Spray_Empty.get(1); } public void - * switchMode(ItemStack aStack, EntityPlayer aPlayer) { setMode(aStack, (getMode(aStack) + 1) % 3); switch - * (getMode(aStack)) { case 0: GT_Utility.sendChatToPlayer(aPlayer, "Single Block Mode"); break; case 1: - * GT_Utility.sendChatToPlayer(aPlayer, "4m Line Mode"); break; case 2: GT_Utility.sendChatToPlayer(aPlayer, - * "3mx3m Area Mode"); break; } } - * @Override public void addAdditionalToolTips(List aList, ItemStack aStack) { super.addAdditionalToolTips(aList, - * aStack); switch (getMode(aStack)) { case 0: aList.add("Single Block Mode"); break; case 1: - * aList.add("4m Line Mode"); break; case 2: aList.add("3mx3m Area Mode"); break; } } - * @Override public ItemStack onItemRightClick(ItemStack aStack, World aWorld, EntityPlayer aPlayer) { if - * (aPlayer.isSneaking()) switchMode(aStack, aPlayer); return super.onItemRightClick(aStack, aWorld, aPlayer); } - */ @Override public boolean onItemUseFirst(ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, - int aSide, float hitX, float hitY, float hitZ) { - super.onItemUseFirst(aStack, aPlayer, aWorld, aX, aY, aZ, aSide, hitX, hitY, hitZ); + int ordinalSide, float hitX, float hitY, float hitZ) { + super.onItemUseFirst(aStack, aPlayer, aWorld, aX, aY, aZ, ordinalSide, hitX, hitY, hitZ); if (aPlayer.isSneaking()) return false; if (aWorld.isRemote) { return false; @@ -82,9 +70,9 @@ public boolean onItemUseFirst(ItemStack aStack, EntityPlayer aPlayer, World aWor return true; } - aX += ForgeDirection.getOrientation(aSide).offsetX; - aY += ForgeDirection.getOrientation(aSide).offsetY; - aZ += ForgeDirection.getOrientation(aSide).offsetZ; + aX += ForgeDirection.getOrientation(ordinalSide).offsetX; + aY += ForgeDirection.getOrientation(ordinalSide).offsetY; + aZ += ForgeDirection.getOrientation(ordinalSide).offsetZ; ItemStack tStack = GT_ModHandler.getIC2Item("constructionFoam", 1); if (tStack != null && tStack.getItem() instanceof ItemBlock) { diff --git a/src/main/java/gregtech/api/items/GT_Spray_Hardener_Item.java b/src/main/java/gregtech/api/items/GT_Spray_Hardener_Item.java index 1f6d49e8da6..2fecc77c147 100644 --- a/src/main/java/gregtech/api/items/GT_Spray_Hardener_Item.java +++ b/src/main/java/gregtech/api/items/GT_Spray_Hardener_Item.java @@ -32,8 +32,8 @@ public GT_Spray_Hardener_Item(String aUnlocalized, String aEnglish, int aMaxDama @Override public boolean onItemUseFirst(ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, - int aSide, float hitX, float hitY, float hitZ) { - super.onItemUseFirst(aStack, aPlayer, aWorld, aX, aY, aZ, aSide, hitX, hitY, hitZ); + int ordinalSide, float hitX, float hitY, float hitZ) { + super.onItemUseFirst(aStack, aPlayer, aWorld, aX, aY, aZ, ordinalSide, hitX, hitY, hitZ); if (aWorld.isRemote) { return false; } diff --git a/src/main/java/gregtech/api/items/GT_Spray_Hydration_Item.java b/src/main/java/gregtech/api/items/GT_Spray_Hydration_Item.java index dd10b419d46..6589beb94c1 100644 --- a/src/main/java/gregtech/api/items/GT_Spray_Hydration_Item.java +++ b/src/main/java/gregtech/api/items/GT_Spray_Hydration_Item.java @@ -28,8 +28,8 @@ public GT_Spray_Hydration_Item(String aUnlocalized, String aEnglish, int aMaxDam @Override public boolean onItemUseFirst(ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, - int aSide, float hitX, float hitY, float hitZ) { - super.onItemUseFirst(aStack, aPlayer, aWorld, aX, aY, aZ, aSide, hitX, hitY, hitZ); + int ordinalSide, float hitX, float hitY, float hitZ) { + super.onItemUseFirst(aStack, aPlayer, aWorld, aX, aY, aZ, ordinalSide, hitX, hitY, hitZ); if (aWorld.isRemote) { return false; } diff --git a/src/main/java/gregtech/api/items/GT_Spray_Ice_Item.java b/src/main/java/gregtech/api/items/GT_Spray_Ice_Item.java index 402b6556921..dab2515b720 100644 --- a/src/main/java/gregtech/api/items/GT_Spray_Ice_Item.java +++ b/src/main/java/gregtech/api/items/GT_Spray_Ice_Item.java @@ -52,14 +52,14 @@ public GT_Spray_Ice_Item(String aUnlocalized, String aEnglish, int aMaxDamage, i @Override public boolean onItemUseFirst(ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, - int aSide, float hitX, float hitY, float hitZ) { - super.onItemUseFirst(aStack, aPlayer, aWorld, aX, aY, aZ, aSide, hitX, hitY, hitZ); + int ordinalSide, float hitX, float hitY, float hitZ) { + super.onItemUseFirst(aStack, aPlayer, aWorld, aX, aY, aZ, ordinalSide, hitX, hitY, hitZ); if (aWorld.isRemote) { return false; } - aX += ForgeDirection.getOrientation(aSide).offsetX; - aY += ForgeDirection.getOrientation(aSide).offsetY; - aZ += ForgeDirection.getOrientation(aSide).offsetZ; + aX += ForgeDirection.getOrientation(ordinalSide).offsetX; + aY += ForgeDirection.getOrientation(ordinalSide).offsetY; + aZ += ForgeDirection.getOrientation(ordinalSide).offsetZ; Block aBlock = aWorld.getBlock(aX, aY, aZ); if (aBlock == null) return false; byte aMeta = (byte) aWorld.getBlockMetadata(aX, aY, aZ); diff --git a/src/main/java/gregtech/api/items/GT_Spray_Pepper_Item.java b/src/main/java/gregtech/api/items/GT_Spray_Pepper_Item.java index 1607ae7d5b8..29f6348d829 100644 --- a/src/main/java/gregtech/api/items/GT_Spray_Pepper_Item.java +++ b/src/main/java/gregtech/api/items/GT_Spray_Pepper_Item.java @@ -46,8 +46,8 @@ public void addAdditionalToolTips(List aList, ItemStack aStack, EntityPl @Override public boolean onItemUseFirst(ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, - int aSide, float hitX, float hitY, float hitZ) { - super.onItemUseFirst(aStack, aPlayer, aWorld, aX, aY, aZ, aSide, hitX, hitY, hitZ); + int ordinalSide, float hitX, float hitY, float hitZ) { + super.onItemUseFirst(aStack, aPlayer, aWorld, aX, aY, aZ, ordinalSide, hitX, hitY, hitZ); if (aWorld.isRemote) { return false; } diff --git a/src/main/java/gregtech/api/logic/interfaces/PowerLogicHost.java b/src/main/java/gregtech/api/logic/interfaces/PowerLogicHost.java index 1a66e5fe83e..8604c160fba 100644 --- a/src/main/java/gregtech/api/logic/interfaces/PowerLogicHost.java +++ b/src/main/java/gregtech/api/logic/interfaces/PowerLogicHost.java @@ -6,7 +6,7 @@ public interface PowerLogicHost { - PowerLogic getPowerLogic(ForgeDirection facing); + PowerLogic getPowerLogic(ForgeDirection side); default boolean isEnergyReceiver() { return false; diff --git a/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java b/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java index 36d4aadcd5d..6ea66d4956b 100644 --- a/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java +++ b/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java @@ -76,9 +76,9 @@ public void setNodePath(NodePath nodePath) { this.nodePath = nodePath; } - public void addToLock(TileEntity tileEntity, int side) { + public void addToLock(TileEntity tileEntity, ForgeDirection side) { if (node != null) { - final Lock lock = node.locks[side]; + final Lock lock = node.locks[side.ordinal()]; if (lock != null) { lock.addTileEntity(tileEntity); } @@ -87,9 +87,9 @@ public void addToLock(TileEntity tileEntity, int side) { } } - public void removeFromLock(TileEntity tileEntity, int side) { + public void removeFromLock(TileEntity tileEntity, ForgeDirection side) { if (node != null) { - final Lock lock = node.locks[side]; + final Lock lock = node.locks[side.ordinal()]; if (lock != null) { lock.removeTileEntity(tileEntity); } @@ -288,12 +288,12 @@ private void sendClientData() { (short) yCoord, zCoord, mID, - getCoverInfoAtSide((byte) 0).getCoverID(), - getCoverInfoAtSide((byte) 1).getCoverID(), - getCoverInfoAtSide((byte) 2).getCoverID(), - getCoverInfoAtSide((byte) 3).getCoverID(), - getCoverInfoAtSide((byte) 4).getCoverID(), - getCoverInfoAtSide((byte) 5).getCoverID(), + getCoverInfoAtSide(ForgeDirection.DOWN).getCoverID(), + getCoverInfoAtSide(ForgeDirection.UP).getCoverID(), + getCoverInfoAtSide(ForgeDirection.NORTH).getCoverID(), + getCoverInfoAtSide(ForgeDirection.SOUTH).getCoverID(), + getCoverInfoAtSide(ForgeDirection.WEST).getCoverID(), + getCoverInfoAtSide(ForgeDirection.EAST).getCoverID(), oTextureData = mConnections, oUpdateData = hasValidMetaTileEntity() ? mMetaTileEntity.getUpdateData() : 0, oRedstoneData = (byte) (((mSidedRedstone[0] > 0) ? 1 : 0) | ((mSidedRedstone[1] > 0) ? 2 : 0) @@ -317,12 +317,12 @@ public final void receiveMetaTileEntityData(short aID, int aCover0, int aCover1, createNewMetatileEntity(mID); } - setCoverIDAtSide((byte) 0, aCover0); - setCoverIDAtSide((byte) 1, aCover1); - setCoverIDAtSide((byte) 2, aCover2); - setCoverIDAtSide((byte) 3, aCover3); - setCoverIDAtSide((byte) 4, aCover4); - setCoverIDAtSide((byte) 5, aCover5); + setCoverIDAtSide(ForgeDirection.DOWN, aCover0); + setCoverIDAtSide(ForgeDirection.UP, aCover1); + setCoverIDAtSide(ForgeDirection.NORTH, aCover2); + setCoverIDAtSide(ForgeDirection.SOUTH, aCover3); + setCoverIDAtSide(ForgeDirection.WEST, aCover4); + setCoverIDAtSide(ForgeDirection.EAST, aCover5); receiveClientEvent(GregTechTileClientEvents.CHANGE_COMMON_DATA, aTextureData); receiveClientEvent(GregTechTileClientEvents.CHANGE_CUSTOM_DATA, aUpdateData); @@ -436,17 +436,17 @@ public boolean isGivingInformation() { } @Override - public byte getBackFacing() { - return GT_Utility.getOppositeSide(getFrontFacing()); + public ForgeDirection getBackFacing() { + return getFrontFacing().getOpposite(); } @Override - public byte getFrontFacing() { - return 6; + public ForgeDirection getFrontFacing() { + return ForgeDirection.UNKNOWN; } @Override - public void setFrontFacing(byte aFacing) { + public void setFrontFacing(ForgeDirection aFacing) { doEnetUpdate(); } @@ -640,22 +640,22 @@ public boolean increaseStoredEnergyUnits(long aEnergy, boolean aIgnoreTooMuchEne } @Override - public boolean inputEnergyFrom(byte aSide) { + public boolean inputEnergyFrom(ForgeDirection side) { return false; } @Override - public boolean inputEnergyFrom(byte aSide, boolean waitForActive) { + public boolean inputEnergyFrom(ForgeDirection side, boolean waitForActive) { return false; } @Override - public boolean outputsEnergyTo(byte aSide) { + public boolean outputsEnergyTo(ForgeDirection side) { return false; } @Override - public boolean outputsEnergyTo(byte aSide, boolean waitForActive) { + public boolean outputsEnergyTo(ForgeDirection side, boolean waitForActive) { return false; } @@ -700,16 +700,16 @@ public long getEUCapacity() { } @Override - public ITexture[] getTexture(Block aBlock, byte aSide) { - final ITexture rIcon = getCoverTexture(aSide); + public ITexture[] getTexture(Block aBlock, ForgeDirection side) { + final ITexture rIcon = getCoverTexture(side); if (rIcon != null) return new ITexture[] { rIcon }; - return getTextureUncovered(aSide); + return getTextureUncovered(side); } @Override - public ITexture[] getTextureCovered(byte aSide) { - final ITexture coverTexture = getCoverTexture(aSide); - final ITexture[] textureUncovered = getTextureUncovered(aSide); + public ITexture[] getTextureCovered(ForgeDirection side) { + final ITexture coverTexture = getCoverTexture(side); + final ITexture[] textureUncovered = getTextureUncovered(side); final ITexture[] textureCovered; if (coverTexture != null) { textureCovered = Arrays.copyOf(textureUncovered, textureUncovered.length + 1); @@ -721,24 +721,24 @@ public ITexture[] getTextureCovered(byte aSide) { } @Override - public ITexture[] getTextureUncovered(byte aSide) { + public ITexture[] getTextureUncovered(ForgeDirection sideDirection) { if ((mConnections & IConnectable.HAS_FRESHFOAM) != 0) return Textures.BlockIcons.FRESHFOAM; if ((mConnections & IConnectable.HAS_HARDENEDFOAM) != 0) return Textures.BlockIcons.HARDENEDFOAMS[mColor]; if ((mConnections & IConnectable.HAS_FOAM) != 0) return Textures.BlockIcons.ERROR_RENDERING; - byte tConnections = mConnections; + int tConnections = mConnections; if (tConnections == IConnectable.CONNECTED_WEST || tConnections == IConnectable.CONNECTED_EAST) - tConnections = (byte) (IConnectable.CONNECTED_WEST | IConnectable.CONNECTED_EAST); + tConnections = IConnectable.CONNECTED_WEST | IConnectable.CONNECTED_EAST; else if (tConnections == IConnectable.CONNECTED_DOWN || tConnections == IConnectable.CONNECTED_UP) - tConnections = (byte) (IConnectable.CONNECTED_DOWN | IConnectable.CONNECTED_UP); + tConnections = IConnectable.CONNECTED_DOWN | IConnectable.CONNECTED_UP; else if (tConnections == IConnectable.CONNECTED_NORTH || tConnections == IConnectable.CONNECTED_SOUTH) - tConnections = (byte) (IConnectable.CONNECTED_NORTH | IConnectable.CONNECTED_SOUTH); + tConnections = IConnectable.CONNECTED_NORTH | IConnectable.CONNECTED_SOUTH; if (hasValidMetaTileEntity()) return mMetaTileEntity.getTexture( this, - aSide, + sideDirection, tConnections, - (byte) (mColor - 1), - tConnections == 0 || (tConnections & (1 << aSide)) != 0, - getOutputRedstoneSignal(aSide) > 0); + (int) (mColor - 1), + tConnections == 0 || (tConnections & (1 << sideDirection.ordinal())) != 0, + getOutputRedstoneSignal(sideDirection) > 0); return Textures.BlockIcons.ERROR_RENDERING; } @@ -775,14 +775,15 @@ public boolean shouldDropItemAt(int index) { } @Override - public boolean onRightclick(EntityPlayer aPlayer, byte aSide, float aX, float aY, float aZ) { + public boolean onRightclick(EntityPlayer aPlayer, ForgeDirection side, float aX, float aY, float aZ) { if (isClientSide()) { // Configure Cover, sneak can also be: screwdriver, wrench, side cutter, soldering iron if (aPlayer.isSneaking()) { - final byte tSide = (getCoverIDAtSide(aSide) == 0) ? GT_Utility.determineWrenchingSide(aSide, aX, aY, aZ) - : aSide; + final ForgeDirection tSide = (getCoverIDAtSide(side) == 0) + ? GT_Utility.determineWrenchingSide(side, aX, aY, aZ) + : side; return (getCoverInfoAtSide(tSide).hasCoverGUI()); - } else if (getCoverBehaviorAtSideNew(aSide).onCoverRightclickClient(aSide, this, aPlayer, aX, aY, aZ)) { + } else if (getCoverBehaviorAtSideNew(side).onCoverRightclickClient(side, this, aPlayer, aX, aY, aZ)) { return true; } } @@ -796,9 +797,9 @@ public boolean onRightclick(EntityPlayer aPlayer, byte aSide, float aX, float aY setColorization((byte) -1); return true; } - final byte tSide = GT_Utility.determineWrenchingSide(aSide, aX, aY, aZ); + final ForgeDirection tSide = GT_Utility.determineWrenchingSide(side, aX, aY, aZ); if (GT_Utility.isStackInList(tCurrentItem, GregTech_API.sWrenchList)) { - if (mMetaTileEntity.onWrenchRightClick(aSide, tSide, aPlayer, aX, aY, aZ)) { + if (mMetaTileEntity.onWrenchRightClick(side, tSide, aPlayer, aX, aY, aZ)) { mMetaTileEntity.markDirty(); GT_ModHandler.damageOrDechargeItem(tCurrentItem, 1, 1000, aPlayer); GT_Utility.sendSoundToPlayers( @@ -813,7 +814,7 @@ public boolean onRightclick(EntityPlayer aPlayer, byte aSide, float aX, float aY return true; } if (GT_Utility.isStackInList(tCurrentItem, GregTech_API.sScrewdriverList)) { - if (getCoverIDAtSide(aSide) == 0 && getCoverIDAtSide(tSide) != 0) { + if (getCoverIDAtSide(side) == 0 && getCoverIDAtSide(tSide) != 0) { if (GT_ModHandler.damageOrDechargeItem(tCurrentItem, 1, 200, aPlayer)) { setCoverDataAtSide( tSide, @@ -832,9 +833,9 @@ public boolean onRightclick(EntityPlayer aPlayer, byte aSide, float aX, float aY } else { if (GT_ModHandler.damageOrDechargeItem(tCurrentItem, 1, 1000, aPlayer)) { setCoverDataAtSide( - aSide, - getCoverInfoAtSide(aSide).onCoverScrewdriverClick(aPlayer, aX, aY, aZ)); - mMetaTileEntity.onScrewdriverRightClick(aSide, aPlayer, aX, aY, aZ); + side, + getCoverInfoAtSide(side).onCoverScrewdriverClick(aPlayer, aX, aY, aZ)); + mMetaTileEntity.onScrewdriverRightClick(side, aPlayer, aX, aY, aZ); mMetaTileEntity.markDirty(); GT_Utility.sendSoundToPlayers( worldObj, @@ -880,7 +881,7 @@ public boolean onRightclick(EntityPlayer aPlayer, byte aSide, float aX, float aY } if (GT_Utility.isStackInList(tCurrentItem, GregTech_API.sWireCutterList)) { - if (mMetaTileEntity.onWireCutterRightClick(aSide, tSide, aPlayer, aX, aY, aZ)) { + if (mMetaTileEntity.onWireCutterRightClick(side, tSide, aPlayer, aX, aY, aZ)) { mMetaTileEntity.markDirty(); // logic handled internally GT_Utility.sendSoundToPlayers( @@ -897,7 +898,7 @@ public boolean onRightclick(EntityPlayer aPlayer, byte aSide, float aX, float aY } if (GT_Utility.isStackInList(tCurrentItem, GregTech_API.sSolderingToolList)) { - if (mMetaTileEntity.onSolderingToolRightClick(aSide, tSide, aPlayer, aX, aY, aZ)) { + if (mMetaTileEntity.onSolderingToolRightClick(side, tSide, aPlayer, aX, aY, aZ)) { mMetaTileEntity.markDirty(); // logic handled internally GT_Utility.sendSoundToPlayers( @@ -910,12 +911,12 @@ public boolean onRightclick(EntityPlayer aPlayer, byte aSide, float aX, float aY zCoord); } else if (GT_ModHandler.useSolderingIron(tCurrentItem, aPlayer)) { mMetaTileEntity.markDirty(); - mStrongRedstone ^= (1 << tSide); + mStrongRedstone ^= (1 << tSide.ordinal()); GT_Utility.sendChatToPlayer( aPlayer, GT_Utility.trans("091", "Redstone Output at Side ") + tSide + GT_Utility.trans("092", " set to: ") - + ((mStrongRedstone & (1 << tSide)) != 0 ? GT_Utility.trans("093", "Strong") + + ((mStrongRedstone & (1 << tSide.ordinal())) != 0 ? GT_Utility.trans("093", "Strong") : GT_Utility.trans("094", "Weak"))); GT_Utility.sendSoundToPlayers( worldObj, @@ -931,8 +932,8 @@ public boolean onRightclick(EntityPlayer aPlayer, byte aSide, float aX, float aY return true; } - byte coverSide = aSide; - if (getCoverIDAtSide(aSide) == 0) coverSide = tSide; + ForgeDirection coverSide = side; + if (getCoverIDAtSide(side) == 0) coverSide = tSide; final CoverInfo coverInfo = getCoverInfoAtSide(coverSide); @@ -966,26 +967,26 @@ public boolean onRightclick(EntityPlayer aPlayer, byte aSide, float aX, float aY xCoord, yCoord, zCoord); - dropCover(coverSide, aSide, false); + dropCover(coverSide, side, false); mMetaTileEntity.markDirty(); } return true; } } } else if (aPlayer.isSneaking()) { // Sneak click, no tool -> open cover config or turn back. - aSide = (getCoverIDAtSide(aSide) == 0) ? GT_Utility.determineWrenchingSide(aSide, aX, aY, aZ) : aSide; - final CoverInfo coverInfo = getCoverInfoAtSide(aSide); + side = (getCoverIDAtSide(side) == 0) ? GT_Utility.determineWrenchingSide(side, aX, aY, aZ) : side; + final CoverInfo coverInfo = getCoverInfoAtSide(side); return coverInfo.isValid() && coverInfo.onCoverShiftRightClick(aPlayer); } - if (getCoverInfoAtSide(aSide).onCoverRightClick(aPlayer, aX, aY, aZ)) return true; + if (getCoverInfoAtSide(side).onCoverRightClick(aPlayer, aX, aY, aZ)) return true; } - if (!getCoverInfoAtSide(aSide).isGUIClickable()) return false; + if (!getCoverInfoAtSide(side).isGUIClickable()) return false; try { if (!aPlayer.isSneaking() && hasValidMetaTileEntity()) { - final boolean handled = mMetaTileEntity.onRightclick(this, aPlayer, aSide, aX, aY, aZ); + final boolean handled = mMetaTileEntity.onRightclick(this, aPlayer, side, aX, aY, aZ); if (handled) { mMetaTileEntity.markDirty(); } @@ -1040,10 +1041,10 @@ public boolean isItemValidForSlot(int aIndex, ItemStack aStack) { * following two Functions. */ @Override - public int[] getAccessibleSlotsFromSide(int aSide) { - final CoverInfo coverInfo = getCoverInfoAtSide((byte) aSide); + public int[] getAccessibleSlotsFromSide(int ordinalSide) { + final CoverInfo coverInfo = getCoverInfoAtSide(ForgeDirection.getOrientation(ordinalSide)); if (canAccessData() && (coverInfo.letsItemsOut(-1) || coverInfo.letsItemsIn(-1))) - return mMetaTileEntity.getAccessibleSlotsFromSide(aSide); + return mMetaTileEntity.getAccessibleSlotsFromSide(ordinalSide); return GT_Values.emptyIntArray; } @@ -1051,22 +1052,21 @@ public int[] getAccessibleSlotsFromSide(int aSide) { * Can put aStack into Slot at Side */ @Override - public boolean canInsertItem(int aIndex, ItemStack aStack, int aSide) { - return canAccessData() && getCoverInfoAtSide((byte) aSide).letsItemsIn(aIndex) - && mMetaTileEntity.canInsertItem(aIndex, aStack, aSide); + public boolean canInsertItem(int aIndex, ItemStack aStack, int ordinalSide) { + return canAccessData() && getCoverInfoAtSide(ForgeDirection.getOrientation(ordinalSide)).letsItemsIn(aIndex) + && mMetaTileEntity.canInsertItem(aIndex, aStack, ordinalSide); } /** * Can pull aStack out of Slot from Side */ @Override - public boolean canExtractItem(int aIndex, ItemStack aStack, int aSide) { - return canAccessData() && getCoverBehaviorAtSideNew((byte) aSide).letsItemsOut( - (byte) aSide, - getCoverIDAtSide((byte) aSide), - getComplexCoverDataAtSide((byte) aSide), - aIndex, - this) && mMetaTileEntity.canExtractItem(aIndex, aStack, aSide); + public boolean canExtractItem(int aIndex, ItemStack aStack, int ordinalSide) { + final ForgeDirection side = ForgeDirection.getOrientation(ordinalSide); + return canAccessData() + && getCoverBehaviorAtSideNew(side) + .letsItemsOut(side, getCoverIDAtSide(side), getComplexCoverDataAtSide(side), aIndex, this) + && mMetaTileEntity.canExtractItem(aIndex, aStack, ordinalSide); } @Override @@ -1152,8 +1152,8 @@ public UUID getOwnerUuid() { public void setOwnerUuid(UUID uuid) {} @Override - public byte getComparatorValue(byte aSide) { - return canAccessData() ? mMetaTileEntity.getComparatorValue(aSide) : 0; + public byte getComparatorValue(ForgeDirection side) { + return canAccessData() ? mMetaTileEntity.getComparatorValue(side) : 0; } @Override @@ -1166,96 +1166,92 @@ public ItemStack decrStackSize(int aIndex, int aAmount) { } @Override - public long injectEnergyUnits(byte aSide, long aVoltage, long aAmperage) { - if (canAccessData()) return mMetaTileEntity.injectEnergyUnits(aSide, aVoltage, aAmperage); + public long injectEnergyUnits(ForgeDirection side, long aVoltage, long aAmperage) { + if (canAccessData()) return mMetaTileEntity.injectEnergyUnits(side, aVoltage, aAmperage); return 0; } @Override - public boolean drainEnergyUnits(byte aSide, long aVoltage, long aAmperage) { + public boolean drainEnergyUnits(ForgeDirection side, long aVoltage, long aAmperage) { return false; } @Override - public boolean acceptsRotationalEnergy(byte aSide) { - if (!canAccessData() || getCoverIDAtSide(aSide) != 0) return false; - return mMetaTileEntity.acceptsRotationalEnergy(aSide); + public boolean acceptsRotationalEnergy(ForgeDirection side) { + if (!canAccessData() || getCoverIDAtSide(side) != 0) return false; + return mMetaTileEntity.acceptsRotationalEnergy(side); } @Override - public boolean injectRotationalEnergy(byte aSide, long aSpeed, long aEnergy) { - if (!canAccessData() || getCoverIDAtSide(aSide) != 0) return false; - return mMetaTileEntity.injectRotationalEnergy(aSide, aSpeed, aEnergy); + public boolean injectRotationalEnergy(ForgeDirection side, long aSpeed, long aEnergy) { + if (!canAccessData() || getCoverIDAtSide(side) != 0) return false; + return mMetaTileEntity.injectRotationalEnergy(side, aSpeed, aEnergy); } - private boolean canMoveFluidOnSide(ForgeDirection aSide, Fluid aFluid, boolean isFill) { - if (aSide == ForgeDirection.UNKNOWN) return true; + private boolean canMoveFluidOnSide(ForgeDirection side, Fluid fluid, boolean isFill) { + if (side == ForgeDirection.UNKNOWN) return true; - final IFluidHandler tTileEntity = getITankContainerAtSide((byte) aSide.ordinal()); + final IFluidHandler tTileEntity = getITankContainerAtSide(side); // Only require a connection if there's something to connect to - Allows fluid cells & buckets to interact with // the pipe - if (tTileEntity != null && !mMetaTileEntity.isConnectedAtSide((byte) aSide.ordinal())) return false; + if (tTileEntity != null && !mMetaTileEntity.isConnectedAtSide(side)) return false; - if (isFill && mMetaTileEntity.isLiquidInput((byte) aSide.ordinal()) - && getCoverInfoAtSide((byte) aSide.ordinal()).letsFluidIn(aFluid)) return true; + if (isFill && mMetaTileEntity.isLiquidInput(side) && getCoverInfoAtSide(side).letsFluidIn(fluid)) return true; - if (!isFill && mMetaTileEntity.isLiquidOutput((byte) aSide.ordinal()) - && getCoverInfoAtSide((byte) aSide.ordinal()).letsFluidOut(aFluid)) return true; - - return false; + return !isFill && mMetaTileEntity.isLiquidOutput(side) && getCoverInfoAtSide(side).letsFluidOut(fluid); } @Override - public int fill(ForgeDirection aSide, FluidStack aFluidStack, boolean doFill) { + public int fill(ForgeDirection side, FluidStack aFluidStack, boolean doFill) { if (mTickTimer > 5 && canAccessData() - && canMoveFluidOnSide(aSide, aFluidStack == null ? null : aFluidStack.getFluid(), true)) - return mMetaTileEntity.fill(aSide, aFluidStack, doFill); + && canMoveFluidOnSide(side, aFluidStack == null ? null : aFluidStack.getFluid(), true)) + return mMetaTileEntity.fill(side, aFluidStack, doFill); return 0; } @Override - public FluidStack drain(ForgeDirection aSide, int maxDrain, boolean doDrain) { + public FluidStack drain(ForgeDirection side, int maxDrain, boolean doDrain) { if (mTickTimer > 5 && canAccessData() && canMoveFluidOnSide( - aSide, + side, mMetaTileEntity.getFluid() == null ? null : mMetaTileEntity.getFluid() .getFluid(), false)) - return mMetaTileEntity.drain(aSide, maxDrain, doDrain); + return mMetaTileEntity.drain(side, maxDrain, doDrain); return null; } @Override - public FluidStack drain(ForgeDirection aSide, FluidStack aFluidStack, boolean doDrain) { + public FluidStack drain(ForgeDirection side, FluidStack aFluidStack, boolean doDrain) { if (mTickTimer > 5 && canAccessData() - && canMoveFluidOnSide(aSide, aFluidStack == null ? null : aFluidStack.getFluid(), false)) - return mMetaTileEntity.drain(aSide, aFluidStack, doDrain); + && canMoveFluidOnSide(side, aFluidStack == null ? null : aFluidStack.getFluid(), false)) + return mMetaTileEntity.drain(side, aFluidStack, doDrain); return null; } @Override - public boolean canFill(ForgeDirection aSide, Fluid aFluid) { - if (mTickTimer > 5 && canAccessData() && canMoveFluidOnSide(aSide, aFluid, true)) - return mMetaTileEntity.canFill(aSide, aFluid); + public boolean canFill(ForgeDirection side, Fluid aFluid) { + if (mTickTimer > 5 && canAccessData() && canMoveFluidOnSide(side, aFluid, true)) + return mMetaTileEntity.canFill(side, aFluid); return false; } @Override - public boolean canDrain(ForgeDirection aSide, Fluid aFluid) { - if (mTickTimer > 5 && canAccessData() && canMoveFluidOnSide(aSide, aFluid, false)) - return mMetaTileEntity.canDrain(aSide, aFluid); + public boolean canDrain(ForgeDirection side, Fluid aFluid) { + if (mTickTimer > 5 && canAccessData() && canMoveFluidOnSide(side, aFluid, false)) + return mMetaTileEntity.canDrain(side, aFluid); return false; } @Override - public FluidTankInfo[] getTankInfo(ForgeDirection aSide) { - final CoverInfo coverInfo = getCoverInfoAtSide((byte) aSide.ordinal()); - if (canAccessData() && (aSide == ForgeDirection.UNKNOWN - || (mMetaTileEntity.isLiquidInput((byte) aSide.ordinal()) && coverInfo.letsFluidIn(null)) - || (mMetaTileEntity.isLiquidOutput((byte) aSide.ordinal()) && coverInfo.letsFluidOut(null)) - // Doesn't need to be connected to get Tank Info -- otherwise things can't connect - )) return mMetaTileEntity.getTankInfo(aSide); + public FluidTankInfo[] getTankInfo(ForgeDirection side) { + final CoverInfo coverInfo = getCoverInfoAtSide(side); + if (canAccessData() + && (side == ForgeDirection.UNKNOWN || (mMetaTileEntity.isLiquidInput(side) && coverInfo.letsFluidIn(null)) + || (mMetaTileEntity.isLiquidOutput(side) && coverInfo.letsFluidOut(null)) + // Doesn't need to be connected to get Tank Info -- otherwise things can't connect + )) return mMetaTileEntity.getTankInfo(side); return new FluidTankInfo[] {}; } @@ -1302,13 +1298,13 @@ public float getThickNess() { return 1.0F; } - public boolean renderInside(byte aSide) { - if (canAccessData()) return mMetaTileEntity.renderInside(aSide); + public boolean renderInside(ForgeDirection side) { + if (canAccessData()) return mMetaTileEntity.renderInside(side); return false; } @Override - public float getBlastResistance(byte aSide) { + public float getBlastResistance(ForgeDirection side) { return (mConnections & IConnectable.HAS_FOAM) != 0 ? 50.0F : 5.0F; } @@ -1339,10 +1335,8 @@ public boolean isUniversalEnergyStored(long aEnergyAmount) { @Override public String[] getInfoData() { - { - if (canAccessData()) return getMetaTileEntity().getInfoData(); - return new String[] {}; - } + if (canAccessData()) return getMetaTileEntity().getInfoData(); + return new String[] {}; } @Override diff --git a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java index 55be6c6d926..b994826d873 100644 --- a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java @@ -1,7 +1,6 @@ package gregtech.api.metatileentity; import static gregtech.GT_Mod.GT_FML_LOGGER; -import static gregtech.api.enums.GT_Values.ALL_VALID_SIDES; import static gregtech.api.enums.GT_Values.NW; import static gregtech.api.enums.GT_Values.V; import static gregtech.api.objects.XSTR.XSTR_INSTANCE; @@ -100,8 +99,8 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec private boolean oRedstone = false; private byte mColor = 0, oColor = 0, oStrongRedstone = 0, oRedstoneData = 63, oTextureData = 0, oUpdateData = 0, oTexturePage = 0; - private byte oLightValueClient = 0, oLightValue = -1, mLightValue = 0, mOtherUpgrades = 0, mFacing = 0, oFacing = 0, - mWorkData = 0; + private byte oLightValueClient = 0, oLightValue = -1, mLightValue = 0, mOtherUpgrades = 0, mWorkData = 0; + private ForgeDirection mFacing, oFacing; private int mDisplayErrorCode = 0, oX = 0, oY = 0, oZ = 0, mTimeStatisticsIndex = 0, mLagWarningCount = 0; private long oOutput = 0, mAcceptedAmperes = Long.MAX_VALUE; private long mLastCheckTick = 0; @@ -128,7 +127,7 @@ public void writeToNBT(NBTTagCompound aNBT) { aNBT.setByte("mLightValue", mLightValue); aNBT.setByte("mOtherUpgrades", mOtherUpgrades); aNBT.setByte("mWorkData", mWorkData); - aNBT.setShort("mFacing", mFacing); + aNBT.setShort("mFacing", (short) mFacing.ordinal()); aNBT.setString("mOwnerName", mOwnerName); aNBT.setString("mOwnerUuid", mOwnerUuid == null ? "" : mOwnerUuid.toString()); aNBT.setBoolean("mLockUpgrade", mLockUpgrade); @@ -168,7 +167,7 @@ public void setInitialValuesAsNBT(NBTTagCompound aNBT, short aID) { mColor = aNBT.getByte("mColor"); mLightValue = aNBT.getByte("mLightValue"); mWorkData = aNBT.getByte("mWorkData"); - mFacing = oFacing = (byte) aNBT.getShort("mFacing"); + mFacing = oFacing = ForgeDirection.getOrientation(aNBT.getShort("mFacing")); mOwnerName = aNBT.getString("mOwnerName"); try { mOwnerUuid = UUID.fromString(aNBT.getString("mOwnerUuid")); @@ -252,14 +251,15 @@ public boolean isRainExposed() { final int precipitationHeightAtSide3 = worldObj.getPrecipitationHeight(xCoord, zCoord + 1); final int precipitationHeightAtSide4 = worldObj.getPrecipitationHeight(xCoord - 1, zCoord); final int precipitationHeightAtSide5 = worldObj.getPrecipitationHeight(xCoord + 1, zCoord); - return (getCoverIDAtSide((byte) 1) == 0 && worldObj.getPrecipitationHeight(xCoord, zCoord) - 2 < yCoord) - || (getCoverIDAtSide((byte) 2) == 0 && precipitationHeightAtSide2 - 1 < yCoord + return (getCoverIDAtSide(ForgeDirection.UP) == 0 + && worldObj.getPrecipitationHeight(xCoord, zCoord) - 2 < yCoord) + || (getCoverIDAtSide(ForgeDirection.NORTH) == 0 && precipitationHeightAtSide2 - 1 < yCoord && precipitationHeightAtSide2 > -1) - || (getCoverIDAtSide((byte) 3) == 0 && precipitationHeightAtSide3 - 1 < yCoord + || (getCoverIDAtSide(ForgeDirection.SOUTH) == 0 && precipitationHeightAtSide3 - 1 < yCoord && precipitationHeightAtSide3 > -1) - || (getCoverIDAtSide((byte) 4) == 0 && precipitationHeightAtSide4 - 1 < yCoord + || (getCoverIDAtSide(ForgeDirection.WEST) == 0 && precipitationHeightAtSide4 - 1 < yCoord && precipitationHeightAtSide4 > -1) - || (getCoverIDAtSide((byte) 5) == 0 && precipitationHeightAtSide5 - 1 < yCoord + || (getCoverIDAtSide(ForgeDirection.EAST) == 0 && precipitationHeightAtSide5 - 1 < yCoord && precipitationHeightAtSide5 > -1); } @@ -370,14 +370,15 @@ public void updateEntity() { } if (mMetaTileEntity.isEnetOutput() || mMetaTileEntity.isEnetInput()) { - for (byte i : ALL_VALID_SIDES) { - boolean temp = isEnergyInputSide(i); - if (temp != mActiveEUInputs[i]) { - mActiveEUInputs[i] = temp; + for (final ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + final int ordinalSide = side.ordinal(); + boolean temp = isEnergyInputSide(side); + if (temp != mActiveEUInputs[ordinalSide]) { + mActiveEUInputs[ordinalSide] = temp; } - temp = isEnergyOutputSide(i); - if (temp != mActiveEUOutputs[i]) { - mActiveEUOutputs[i] = temp; + temp = isEnergyOutputSide(side); + if (temp != mActiveEUOutputs[ordinalSide]) { + mActiveEUOutputs[ordinalSide] = temp; } } } @@ -397,7 +398,7 @@ public void updateEntity() { } if (getEUCapacity() > 0) { if (GregTech_API.sMachineFireExplosions && getRandomNumber(1000) == 0) { - final Block tBlock = getBlockAtSide((byte) getRandomNumber(6)); + final Block tBlock = getBlockAtSide(ForgeDirection.getOrientation(getRandomNumber(6))); if (tBlock instanceof BlockFire) doEnergyExplosion(); } @@ -536,7 +537,7 @@ < getEUCapacity()) { } if (mTickTimer > 10) { - byte tData = (byte) ((mFacing & 7) | (mActive ? 8 : 0) + byte tData = (byte) ((mFacing.ordinal() & 7) | (mActive ? 8 : 0) | (mRedstone ? 16 : 0) | (mLockUpgrade ? 32 : 0) | (mWorks ? 64 : 0) @@ -613,12 +614,12 @@ && getMetaTileEntity().doTickProfilingMessageDuringThisTick() } @Override - public void getWailaBody(ItemStack itemStack, List currenttip, IWailaDataAccessor accessor, + public void getWailaBody(ItemStack itemStack, List currentTip, IWailaDataAccessor accessor, IWailaConfigHandler config) { if (hasValidMetaTileEntity()) { - getMetaTileEntity().getWailaBody(itemStack, currenttip, accessor, config); + getMetaTileEntity().getWailaBody(itemStack, currentTip, accessor, config); } - super.getWailaBody(itemStack, currenttip, accessor, config); + super.getWailaBody(itemStack, currentTip, accessor, config); } @Override @@ -639,13 +640,13 @@ private void sendClientData() { (short) yCoord, zCoord, mID, - getCoverInfoAtSide((byte) 0).getCoverID(), - getCoverInfoAtSide((byte) 1).getCoverID(), - getCoverInfoAtSide((byte) 2).getCoverID(), - getCoverInfoAtSide((byte) 3).getCoverID(), - getCoverInfoAtSide((byte) 4).getCoverID(), - getCoverInfoAtSide((byte) 5).getCoverID(), - oTextureData = (byte) ((mFacing & 7) | (mActive ? 8 : 0) + getCoverInfoAtSide(ForgeDirection.DOWN).getCoverID(), + getCoverInfoAtSide(ForgeDirection.UP).getCoverID(), + getCoverInfoAtSide(ForgeDirection.NORTH).getCoverID(), + getCoverInfoAtSide(ForgeDirection.SOUTH).getCoverID(), + getCoverInfoAtSide(ForgeDirection.WEST).getCoverID(), + getCoverInfoAtSide(ForgeDirection.EAST).getCoverID(), + oTextureData = (byte) ((mFacing.ordinal() & 7) | (mActive ? 8 : 0) | (mRedstone ? 16 : 0) | (mLockUpgrade ? 32 : 0) | (mWorks ? 64 : 0)), @@ -675,12 +676,12 @@ public final void receiveMetaTileEntityData(short aID, int aCover0, int aCover1, createNewMetatileEntity(mID); } - setCoverIDAtSide((byte) 0, aCover0); - setCoverIDAtSide((byte) 1, aCover1); - setCoverIDAtSide((byte) 2, aCover2); - setCoverIDAtSide((byte) 3, aCover3); - setCoverIDAtSide((byte) 4, aCover4); - setCoverIDAtSide((byte) 5, aCover5); + setCoverIDAtSide(ForgeDirection.DOWN, aCover0); + setCoverIDAtSide(ForgeDirection.UP, aCover1); + setCoverIDAtSide(ForgeDirection.NORTH, aCover2); + setCoverIDAtSide(ForgeDirection.SOUTH, aCover3); + setCoverIDAtSide(ForgeDirection.WEST, aCover4); + setCoverIDAtSide(ForgeDirection.EAST, aCover5); receiveClientEvent(GregTechTileClientEvents.CHANGE_COMMON_DATA, aTextureData); receiveClientEvent(GregTechTileClientEvents.CHANGE_CUSTOM_DATA, aUpdateData & 0x7F); @@ -725,7 +726,7 @@ public boolean receiveClientEvent(int aEventID, int aValue) { issueTextureUpdate(); switch (aEventID) { case GregTechTileClientEvents.CHANGE_COMMON_DATA -> { - mFacing = (byte) (aValue & 7); + mFacing = ForgeDirection.getOrientation((byte) (aValue & 7)); mActive = ((aValue & 8) != 0); mRedstone = ((aValue & 16) != 0); // mLockUpgrade = ((aValue&32) != 0); @@ -844,17 +845,17 @@ public boolean isGivingInformation() { } @Override - public byte getBackFacing() { - return GT_Utility.getOppositeSide(mFacing); + public ForgeDirection getBackFacing() { + return mFacing.getOpposite(); } @Override - public byte getFrontFacing() { + public ForgeDirection getFrontFacing() { return mFacing; } @Override - public void setFrontFacing(byte aFacing) { + public void setFrontFacing(ForgeDirection aFacing) { if (isValidFacing(aFacing)) { mFacing = aFacing; mMetaTileEntity.onFacingChange(); @@ -1075,29 +1076,27 @@ public boolean increaseStoredEnergyUnits(long aEnergy, boolean aIgnoreTooMuchEne } @Override - public boolean inputEnergyFrom(byte aSide) { - return inputEnergyFrom(aSide, true); + public boolean inputEnergyFrom(ForgeDirection side) { + return inputEnergyFrom(side, true); } @Override - public boolean inputEnergyFrom(byte aSide, boolean waitForActive) { - if (aSide == 6) return true; - if (isServerSide() && waitForActive) - return ((aSide >= 0 && aSide < 6) && mActiveEUInputs[aSide]) && !mReleaseEnergy; - return isEnergyInputSide(aSide); + public boolean inputEnergyFrom(ForgeDirection side, boolean waitForActive) { + if (side == ForgeDirection.UNKNOWN) return true; + if (isServerSide() && waitForActive) return mActiveEUInputs[side.ordinal()] && !mReleaseEnergy; + return isEnergyInputSide(side); } @Override - public boolean outputsEnergyTo(byte aSide) { - return outputsEnergyTo(aSide, true); + public boolean outputsEnergyTo(ForgeDirection side) { + return outputsEnergyTo(side, true); } @Override - public boolean outputsEnergyTo(byte aSide, boolean waitForActive) { - if (aSide == 6) return true; - if (isServerSide() && waitForActive) - return ((aSide >= 0 && aSide < 6) && mActiveEUOutputs[aSide]) || mReleaseEnergy; - return isEnergyOutputSide(aSide); + public boolean outputsEnergyTo(ForgeDirection side, boolean waitForActive) { + if (side == ForgeDirection.UNKNOWN) return true; + if (isServerSide() && waitForActive) return (mActiveEUOutputs[side.ordinal()]) || mReleaseEnergy; + return isEnergyOutputSide(side); } @Override @@ -1114,9 +1113,9 @@ public void generatePowerNodes() { if (isServerSide() && (isEnetInput() || isEnetOutput())) { final int time = MinecraftServer.getServer() .getTickCounter(); - for (byte i : ALL_VALID_SIDES) { - if (outputsEnergyTo(i, false) || inputEnergyFrom(i, false)) { - final IGregTechTileEntity TE = getIGregTechTileEntityAtSide(i); + for (final ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + if (outputsEnergyTo(side, false) || inputEnergyFrom(side, false)) { + final IGregTechTileEntity TE = getIGregTechTileEntityAtSide(side); if (TE instanceof BaseMetaPipeEntity) { final Node node = ((BaseMetaPipeEntity) TE).getNode(); if (node == null) { @@ -1201,11 +1200,11 @@ public long getSteamCapacity() { } @Override - public ITexture[] getTexture(Block aBlock, byte aSide) { - final ITexture coverTexture = getCoverTexture(aSide); + public ITexture[] getTexture(Block aBlock, ForgeDirection side) { + final ITexture coverTexture = getCoverTexture(side); final ITexture[] textureUncovered = hasValidMetaTileEntity() ? mMetaTileEntity - .getTexture(this, aSide, mFacing, (byte) (mColor - 1), mActive, getOutputRedstoneSignal(aSide) > 0) + .getTexture(this, side, mFacing, (byte) (mColor - 1), mActive, getOutputRedstoneSignal(side) > 0) : Textures.BlockIcons.ERROR_RENDERING; final ITexture[] textureCovered; if (coverTexture != null) { @@ -1217,22 +1216,22 @@ public ITexture[] getTexture(Block aBlock, byte aSide) { } } - private boolean isEnergyInputSide(byte aSide) { - if (aSide >= 0 && aSide < 6) { - if (!getCoverInfoAtSide(aSide).letsEnergyIn()) return false; + private boolean isEnergyInputSide(ForgeDirection side) { + if (side != ForgeDirection.UNKNOWN) { + if (!getCoverInfoAtSide(side).letsEnergyIn()) return false; if (isInvalid() || mReleaseEnergy) return false; if (canAccessData() && mMetaTileEntity.isElectric() && mMetaTileEntity.isEnetInput()) - return mMetaTileEntity.isInputFacing(aSide); + return mMetaTileEntity.isInputFacing(side); } return false; } - private boolean isEnergyOutputSide(byte aSide) { - if (aSide >= 0 && aSide < 6) { - if (!getCoverInfoAtSide(aSide).letsEnergyOut()) return false; + private boolean isEnergyOutputSide(ForgeDirection side) { + if (side != ForgeDirection.UNKNOWN) { + if (!getCoverInfoAtSide(side).letsEnergyOut()) return false; if (isInvalid() || mReleaseEnergy) return mReleaseEnergy; if (canAccessData() && mMetaTileEntity.isElectric() && mMetaTileEntity.isEnetOutput()) - return mMetaTileEntity.isOutputFacing(aSide); + return mMetaTileEntity.isOutputFacing(side); } return false; } @@ -1414,18 +1413,19 @@ public int getUpgradeCount() { } @Override - public boolean onRightclick(EntityPlayer aPlayer, byte aSide, float aX, float aY, float aZ) { + public boolean onRightclick(EntityPlayer aPlayer, ForgeDirection side, float aX, float aY, float aZ) { if (isClientSide()) { // Configure Cover, sneak can also be: screwdriver, wrench, side cutter, soldering iron if (aPlayer.isSneaking()) { - final byte tSide = (getCoverIDAtSide(aSide) == 0) ? GT_Utility.determineWrenchingSide(aSide, aX, aY, aZ) - : aSide; + final ForgeDirection tSide = (getCoverIDAtSide(side) == 0) + ? GT_Utility.determineWrenchingSide(side, aX, aY, aZ) + : side; return (getCoverBehaviorAtSideNew(tSide).hasCoverGUI()); - } else if (getCoverBehaviorAtSideNew(aSide).onCoverRightclickClient(aSide, this, aPlayer, aX, aY, aZ)) { + } else if (getCoverBehaviorAtSideNew(side).onCoverRightclickClient(side, this, aPlayer, aX, aY, aZ)) { return true; } - if (!getCoverInfoAtSide(aSide).isGUIClickable()) return false; + if (!getCoverInfoAtSide(side).isGUIClickable()) return false; } if (isServerSide()) { @@ -1442,7 +1442,7 @@ public boolean onRightclick(EntityPlayer aPlayer, byte aSide, float aX, float aY if (GT_Utility.isStackInList(tCurrentItem, GregTech_API.sWrenchList)) { if (aPlayer.isSneaking() && mMetaTileEntity instanceof GT_MetaTileEntity_BasicMachine && ((GT_MetaTileEntity_BasicMachine) mMetaTileEntity) - .setMainFacing(GT_Utility.determineWrenchingSide(aSide, aX, aY, aZ))) { + .setMainFacing(GT_Utility.determineWrenchingSide(side, aX, aY, aZ))) { GT_ModHandler.damageOrDechargeItem(tCurrentItem, 1, 1000, aPlayer); GT_Utility.sendSoundToPlayers( worldObj, @@ -1454,8 +1454,8 @@ public boolean onRightclick(EntityPlayer aPlayer, byte aSide, float aX, float aY zCoord); cableUpdateDelay = 10; } else if (mMetaTileEntity.onWrenchRightClick( - aSide, - GT_Utility.determineWrenchingSide(aSide, aX, aY, aZ), + side, + GT_Utility.determineWrenchingSide(side, aX, aY, aZ), aPlayer, aX, aY, @@ -1477,17 +1477,17 @@ public boolean onRightclick(EntityPlayer aPlayer, byte aSide, float aX, float aY if (GT_Utility.isStackInList(tCurrentItem, GregTech_API.sScrewdriverList)) { if (GT_ModHandler.damageOrDechargeItem(tCurrentItem, 1, 200, aPlayer)) { setCoverDataAtSide( - aSide, - getCoverBehaviorAtSideNew(aSide).onCoverScrewdriverClick( - aSide, - getCoverIDAtSide(aSide), - getComplexCoverDataAtSide(aSide), + side, + getCoverBehaviorAtSideNew(side).onCoverScrewdriverClick( + side, + getCoverIDAtSide(side), + getComplexCoverDataAtSide(side), this, aPlayer, aX, aY, aZ)); - mMetaTileEntity.onScrewdriverRightClick(aSide, aPlayer, aX, aY, aZ); + mMetaTileEntity.onScrewdriverRightClick(side, aPlayer, aX, aY, aZ); GT_Utility.sendSoundToPlayers( worldObj, SoundResource.IC2_TOOLS_WRENCH, @@ -1548,8 +1548,8 @@ public boolean onRightclick(EntityPlayer aPlayer, byte aSide, float aX, float aY } if (GT_Utility.isStackInList(tCurrentItem, GregTech_API.sSolderingToolList)) { - final byte tSide = GT_Utility.determineWrenchingSide(aSide, aX, aY, aZ); - if (mMetaTileEntity.onSolderingToolRightClick(aSide, tSide, aPlayer, aX, aY, aZ)) { + final ForgeDirection tSide = GT_Utility.determineWrenchingSide(side, aX, aY, aZ); + if (mMetaTileEntity.onSolderingToolRightClick(side, tSide, aPlayer, aX, aY, aZ)) { // logic handled internally GT_Utility.sendSoundToPlayers( worldObj, @@ -1560,12 +1560,13 @@ public boolean onRightclick(EntityPlayer aPlayer, byte aSide, float aX, float aY yCoord, zCoord); } else if (GT_ModHandler.useSolderingIron(tCurrentItem, aPlayer)) { - mStrongRedstone ^= (1 << tSide); + mStrongRedstone ^= (1 << tSide.ordinal()); GT_Utility.sendChatToPlayer( aPlayer, GT_Utility.trans("091", "Redstone Output at Side ") + tSide + GT_Utility.trans("092", " set to: ") - + ((mStrongRedstone & (1 << tSide)) != 0 ? GT_Utility.trans("093", "Strong") + + ((mStrongRedstone & (1 << tSide.ordinal())) != 0 + ? GT_Utility.trans("093", "Strong") : GT_Utility.trans("094", "Weak"))); GT_Utility.sendSoundToPlayers( worldObj, @@ -1583,8 +1584,8 @@ public boolean onRightclick(EntityPlayer aPlayer, byte aSide, float aX, float aY } if (GT_Utility.isStackInList(tCurrentItem, GregTech_API.sWireCutterList)) { - final byte tSide = GT_Utility.determineWrenchingSide(aSide, aX, aY, aZ); - if (mMetaTileEntity.onWireCutterRightClick(aSide, tSide, aPlayer, aX, aY, aZ)) { + final ForgeDirection tSide = GT_Utility.determineWrenchingSide(side, aX, aY, aZ); + if (mMetaTileEntity.onWireCutterRightClick(side, tSide, aPlayer, aX, aY, aZ)) { // logic handled internally GT_Utility.sendSoundToPlayers( worldObj, @@ -1600,8 +1601,8 @@ public boolean onRightclick(EntityPlayer aPlayer, byte aSide, float aX, float aY return true; } - byte coverSide = aSide; - if (getCoverIDAtSide(aSide) == 0) coverSide = GT_Utility.determineWrenchingSide(aSide, aX, aY, aZ); + ForgeDirection coverSide = side; + if (getCoverIDAtSide(side) == 0) coverSide = GT_Utility.determineWrenchingSide(side, aX, aY, aZ); if (getCoverIDAtSide(coverSide) == 0) { if (GT_Utility.isStackInList(tCurrentItem, GregTech_API.sCovers.keySet())) { @@ -1633,34 +1634,33 @@ public boolean onRightclick(EntityPlayer aPlayer, byte aSide, float aX, float aY xCoord, yCoord, zCoord); - dropCover(coverSide, aSide, false); + dropCover(coverSide, side, false); } return true; } } // End item != null } else if (aPlayer.isSneaking()) { // Sneak click, no tool -> open cover config if possible. - aSide = (getCoverIDAtSide(aSide) == 0) ? GT_Utility.determineWrenchingSide(aSide, aX, aY, aZ) - : aSide; - return getCoverIDAtSide(aSide) > 0 && getCoverBehaviorAtSideNew(aSide).onCoverShiftRightClick( - aSide, - getCoverIDAtSide(aSide), - getComplexCoverDataAtSide(aSide), + side = (getCoverIDAtSide(side) == 0) ? GT_Utility.determineWrenchingSide(side, aX, aY, aZ) : side; + return getCoverIDAtSide(side) > 0 && getCoverBehaviorAtSideNew(side).onCoverShiftRightClick( + side, + getCoverIDAtSide(side), + getComplexCoverDataAtSide(side), this, aPlayer); } - if (getCoverBehaviorAtSideNew(aSide).onCoverRightClick( - aSide, - getCoverIDAtSide(aSide), - getComplexCoverDataAtSide(aSide), + if (getCoverBehaviorAtSideNew(side).onCoverRightClick( + side, + getCoverIDAtSide(side), + getComplexCoverDataAtSide(side), this, aPlayer, aX, aY, aZ)) return true; - if (!getCoverInfoAtSide(aSide).isGUIClickable()) return false; + if (!getCoverInfoAtSide(side).isGUIClickable()) return false; if (isUpgradable() && tCurrentItem != null) { if (ItemList.Upgrade_Muffler.isStackEqual(aPlayer.inventory.getCurrentItem())) { @@ -1700,7 +1700,7 @@ public boolean onRightclick(EntityPlayer aPlayer, byte aSide, float aX, float aY try { if (!aPlayer.isSneaking() && hasValidMetaTileEntity()) - return mMetaTileEntity.onRightclick(this, aPlayer, aSide, aX, aY, aZ); + return mMetaTileEntity.onRightclick(this, aPlayer, side, aX, aY, aZ); } catch (Throwable e) { GT_Log.err.println( "Encountered Exception while rightclicking TileEntity, the Game should've crashed now, but I prevented that. Please report immediately to GregTech Intergalactical!!!"); @@ -1758,10 +1758,10 @@ public boolean isItemValidForSlot(int aIndex, ItemStack aStack) { * following two Functions. */ @Override - public int[] getAccessibleSlotsFromSide(int aSide) { - final CoverInfo coverInfo = getCoverInfoAtSide((byte) aSide); + public int[] getAccessibleSlotsFromSide(int ordinalSide) { + final CoverInfo coverInfo = getCoverInfoAtSide(ForgeDirection.getOrientation(ordinalSide)); if (canAccessData() && (coverInfo.letsItemsOut(-1) || coverInfo.letsItemsIn(-1))) - return mMetaTileEntity.getAccessibleSlotsFromSide(aSide); + return mMetaTileEntity.getAccessibleSlotsFromSide(ordinalSide); return GT_Values.emptyIntArray; } @@ -1769,25 +1769,22 @@ public int[] getAccessibleSlotsFromSide(int aSide) { * Can put aStack into Slot at Side */ @Override - public boolean canInsertItem(int aIndex, ItemStack aStack, int aSide) { + public boolean canInsertItem(int slotIndex, ItemStack stack, int ordinalSide) { return canAccessData() && (mRunningThroughTick || !mInputDisabled) - && getCoverInfoAtSide((byte) aSide).letsItemsIn(aIndex) - && mMetaTileEntity.canInsertItem(aIndex, aStack, aSide); + && getCoverInfoAtSide(ForgeDirection.getOrientation(ordinalSide)).letsItemsIn(slotIndex) + && mMetaTileEntity.canInsertItem(slotIndex, stack, ordinalSide); } /** - * Can pull aStack out of Slot from Side + * Can pull stack out of Slot from Side */ @Override - public boolean canExtractItem(int aIndex, ItemStack aStack, int aSide) { + public boolean canExtractItem(int slotIndex, ItemStack stack, int ordinalSide) { + final ForgeDirection side = ForgeDirection.getOrientation(ordinalSide); return canAccessData() && (mRunningThroughTick || !mOutputDisabled) - && getCoverBehaviorAtSideNew((byte) aSide).letsItemsOut( - (byte) aSide, - getCoverIDAtSide((byte) aSide), - getComplexCoverDataAtSide((byte) aSide), - aIndex, - this) - && mMetaTileEntity.canExtractItem(aIndex, aStack, aSide); + && getCoverBehaviorAtSideNew(side) + .letsItemsOut(side, getCoverIDAtSide(side), getComplexCoverDataAtSide(side), slotIndex, this) + && mMetaTileEntity.canExtractItem(slotIndex, stack, ordinalSide); } @Override @@ -1796,9 +1793,9 @@ public boolean isUpgradable() { } @Override - public byte getGeneralRS(byte aSide) { + public byte getGeneralRS(ForgeDirection side) { if (mMetaTileEntity == null) return 0; - return mMetaTileEntity.allowGeneralRedstoneOutput() ? mSidedRedstone[aSide] : 0; + return mMetaTileEntity.allowGeneralRedstoneOutput() ? mSidedRedstone[side.ordinal()] : 0; } @Override @@ -1894,11 +1891,11 @@ public long getAverageElectricOutput() { } @Override - protected void updateOutputRedstoneSignal(byte aSide) { + protected void updateOutputRedstoneSignal(ForgeDirection side) { if (mMetaTileEntity.hasSidedRedstoneOutputBehavior()) { - setOutputRedstoneSignal(aSide, (byte) 0); + setOutputRedstoneSignal(side, (byte) 0); } else { - setOutputRedstoneSignal(aSide, (byte) 15); + setOutputRedstoneSignal(side, (byte) 15); } } @@ -1925,8 +1922,8 @@ public void setOwnerUuid(UUID uuid) { } @Override - public byte getComparatorValue(byte aSide) { - return canAccessData() ? mMetaTileEntity.getComparatorValue(aSide) : 0; + public byte getComparatorValue(ForgeDirection side) { + return canAccessData() ? mMetaTileEntity.getComparatorValue(side) : 0; } @Override @@ -1939,9 +1936,9 @@ public ItemStack decrStackSize(int aIndex, int aAmount) { } @Override - public long injectEnergyUnits(byte aSide, long aVoltage, long aAmperage) { + public long injectEnergyUnits(ForgeDirection side, long aVoltage, long aAmperage) { if (!canAccessData() || !mMetaTileEntity.isElectric() - || !inputEnergyFrom(aSide) + || !inputEnergyFrom(side) || aAmperage <= 0 || aVoltage <= 0 || getStoredEU() >= getEUCapacity() @@ -1967,9 +1964,9 @@ public long injectEnergyUnits(byte aSide, long aVoltage, long aAmperage) { } @Override - public boolean drainEnergyUnits(byte aSide, long aVoltage, long aAmperage) { + public boolean drainEnergyUnits(ForgeDirection side, long aVoltage, long aAmperage) { if (!canAccessData() || !mMetaTileEntity.isElectric() - || !outputsEnergyTo(aSide) + || !outputsEnergyTo(side) || getStoredEU() - (aVoltage * aAmperage) < mMetaTileEntity.getMinimumStoredEU()) return false; if (decreaseStoredEU(aVoltage * aAmperage, false)) { mAverageEUOutput[mAverageEUOutputIndex] += aVoltage * aAmperage; @@ -1979,78 +1976,76 @@ public boolean drainEnergyUnits(byte aSide, long aVoltage, long aAmperage) { } @Override - public boolean acceptsRotationalEnergy(byte aSide) { - if (!canAccessData() || getCoverIDAtSide(aSide) != 0) return false; - return mMetaTileEntity.acceptsRotationalEnergy(aSide); + public boolean acceptsRotationalEnergy(ForgeDirection side) { + if (!canAccessData() || getCoverIDAtSide(side) != 0) return false; + return mMetaTileEntity.acceptsRotationalEnergy(side); } @Override - public boolean injectRotationalEnergy(byte aSide, long aSpeed, long aEnergy) { - if (!canAccessData() || getCoverIDAtSide(aSide) != 0) return false; - return mMetaTileEntity.injectRotationalEnergy(aSide, aSpeed, aEnergy); + public boolean injectRotationalEnergy(ForgeDirection side, long aSpeed, long aEnergy) { + if (!canAccessData() || getCoverIDAtSide(side) != 0) return false; + return mMetaTileEntity.injectRotationalEnergy(side, aSpeed, aEnergy); } @Override - public int fill(ForgeDirection aSide, FluidStack aFluid, boolean doFill) { + public int fill(ForgeDirection side, FluidStack aFluid, boolean doFill) { if (mTickTimer > 5 && canAccessData() && (mRunningThroughTick || !mInputDisabled) - && (aSide == ForgeDirection.UNKNOWN || (mMetaTileEntity.isLiquidInput((byte) aSide.ordinal()) - && getCoverInfoAtSide((byte) aSide.ordinal()).letsFluidIn(aFluid == null ? null : aFluid.getFluid())))) - return mMetaTileEntity.fill(aSide, aFluid, doFill); + && (side == ForgeDirection.UNKNOWN || (mMetaTileEntity.isLiquidInput(side) + && getCoverInfoAtSide(side).letsFluidIn(aFluid == null ? null : aFluid.getFluid())))) + return mMetaTileEntity.fill(side, aFluid, doFill); return 0; } @Override - public FluidStack drain(ForgeDirection aSide, int maxDrain, boolean doDrain) { + public FluidStack drain(ForgeDirection side, int maxDrain, boolean doDrain) { if (mTickTimer > 5 && canAccessData() && (mRunningThroughTick || !mOutputDisabled) - && (aSide == ForgeDirection.UNKNOWN || (mMetaTileEntity.isLiquidOutput((byte) aSide.ordinal()) - && getCoverInfoAtSide((byte) aSide.ordinal()).letsFluidOut( + && (side == ForgeDirection.UNKNOWN + || (mMetaTileEntity.isLiquidOutput(side) && getCoverInfoAtSide(side).letsFluidOut( mMetaTileEntity.getFluid() == null ? null : mMetaTileEntity.getFluid() .getFluid())))) - return mMetaTileEntity.drain(aSide, maxDrain, doDrain); + return mMetaTileEntity.drain(side, maxDrain, doDrain); return null; } @Override - public FluidStack drain(ForgeDirection aSide, FluidStack aFluid, boolean doDrain) { + public FluidStack drain(ForgeDirection side, FluidStack aFluid, boolean doDrain) { if (mTickTimer > 5 && canAccessData() && (mRunningThroughTick || !mOutputDisabled) - && (aSide == ForgeDirection.UNKNOWN || (mMetaTileEntity.isLiquidOutput((byte) aSide.ordinal()) - && getCoverInfoAtSide((byte) aSide.ordinal()).letsFluidOut(aFluid == null ? null : aFluid.getFluid())))) - return mMetaTileEntity.drain(aSide, aFluid, doDrain); + && (side == ForgeDirection.UNKNOWN || (mMetaTileEntity.isLiquidOutput(side) + && getCoverInfoAtSide(side).letsFluidOut(aFluid == null ? null : aFluid.getFluid())))) + return mMetaTileEntity.drain(side, aFluid, doDrain); return null; } @Override - public boolean canFill(ForgeDirection aSide, Fluid aFluid) { + public boolean canFill(ForgeDirection side, Fluid aFluid) { if (mTickTimer > 5 && canAccessData() && (mRunningThroughTick || !mInputDisabled) - && (aSide == ForgeDirection.UNKNOWN || (mMetaTileEntity.isLiquidInput((byte) aSide.ordinal()) - && getCoverInfoAtSide((byte) aSide.ordinal()).letsFluidIn(aFluid)))) - return mMetaTileEntity.canFill(aSide, aFluid); + && (side == ForgeDirection.UNKNOWN + || (mMetaTileEntity.isLiquidInput(side) && getCoverInfoAtSide(side).letsFluidIn(aFluid)))) + return mMetaTileEntity.canFill(side, aFluid); return false; } @Override - public boolean canDrain(ForgeDirection aSide, Fluid aFluid) { + public boolean canDrain(ForgeDirection side, Fluid aFluid) { if (mTickTimer > 5 && canAccessData() && (mRunningThroughTick || !mOutputDisabled) - && (aSide == ForgeDirection.UNKNOWN || (mMetaTileEntity.isLiquidOutput((byte) aSide.ordinal()) - && getCoverInfoAtSide((byte) aSide.ordinal()).letsFluidOut(aFluid)))) - return mMetaTileEntity.canDrain(aSide, aFluid); + && (side == ForgeDirection.UNKNOWN + || (mMetaTileEntity.isLiquidOutput(side) && getCoverInfoAtSide(side).letsFluidOut(aFluid)))) + return mMetaTileEntity.canDrain(side, aFluid); return false; } @Override - public FluidTankInfo[] getTankInfo(ForgeDirection aSide) { - final byte tSide = (byte) aSide.ordinal(); - - if (canAccessData() && (aSide == ForgeDirection.UNKNOWN - || (mMetaTileEntity.isLiquidInput(tSide) && getCoverInfoAtSide(tSide).letsFluidIn(null)) - || (mMetaTileEntity.isLiquidOutput(tSide) && getCoverInfoAtSide(tSide).letsFluidOut(null)))) - return mMetaTileEntity.getTankInfo(aSide); + public FluidTankInfo[] getTankInfo(ForgeDirection side) { + if (canAccessData() && (side == ForgeDirection.UNKNOWN + || (mMetaTileEntity.isLiquidInput(side) && getCoverInfoAtSide(side).letsFluidIn(null)) + || (mMetaTileEntity.isLiquidOutput(side) && getCoverInfoAtSide(side).letsFluidOut(null)))) + return mMetaTileEntity.getTankInfo(side); return new FluidTankInfo[] {}; } @@ -2058,7 +2053,7 @@ public double getOutputEnergyUnitsPerTick() { return oOutput; } - public boolean isTeleporterCompatible(ForgeDirection aSide) { + public boolean isTeleporterCompatible(ForgeDirection side) { return canAccessData() && mMetaTileEntity.isTeleporterCompatible(); } @@ -2068,15 +2063,15 @@ public double demandedEnergyUnits() { } public double injectEnergyUnits(ForgeDirection aDirection, double aAmount) { - return injectEnergyUnits((byte) aDirection.ordinal(), (int) aAmount, 1) > 0 ? 0 : aAmount; + return injectEnergyUnits(aDirection, (int) aAmount, 1) > 0 ? 0 : aAmount; } public boolean acceptsEnergyFrom(TileEntity aEmitter, ForgeDirection aDirection) { - return inputEnergyFrom((byte) aDirection.ordinal()); + return inputEnergyFrom(aDirection); } public boolean emitsEnergyTo(TileEntity aReceiver, ForgeDirection aDirection) { - return outputsEnergyTo((byte) aDirection.ordinal()); + return outputsEnergyTo(aDirection); } public double getOfferedEnergy() { @@ -2091,7 +2086,7 @@ public void drawEnergy(double amount) { } public int injectEnergy(ForgeDirection aForgeDirection, int aAmount) { - return injectEnergyUnits((byte) aForgeDirection.ordinal(), aAmount, 1) > 0 ? 0 : aAmount; + return injectEnergyUnits(aForgeDirection, aAmount, 1) > 0 ? 0 : aAmount; } public int addEnergy(int aEnergy) { @@ -2136,34 +2131,34 @@ public int getOutput() { } public int injectEnergy(Direction aDirection, int aAmount) { - return injectEnergyUnits((byte) aDirection.toSideValue(), aAmount, 1) > 0 ? 0 : aAmount; + return injectEnergyUnits(aDirection.toForgeDirection(), aAmount, 1) > 0 ? 0 : aAmount; } - public boolean isTeleporterCompatible(Direction aSide) { + public boolean isTeleporterCompatible(Direction ignoredDirection) { return canAccessData() && mMetaTileEntity.isTeleporterCompatible(); } - public boolean acceptsEnergyFrom(TileEntity aReceiver, Direction aDirection) { - return inputEnergyFrom((byte) aDirection.toSideValue()); + public boolean acceptsEnergyFrom(TileEntity ignoredTileEntity, Direction aDirection) { + return inputEnergyFrom(aDirection.toForgeDirection()); } - public boolean emitsEnergyTo(TileEntity aReceiver, Direction aDirection) { - return outputsEnergyTo((byte) aDirection.toSideValue()); + public boolean emitsEnergyTo(TileEntity ignoredTileEntity, Direction aDirection) { + return outputsEnergyTo(aDirection.toForgeDirection()); } @Override - public boolean addStackToSlot(int aIndex, ItemStack aStack) { - if (GT_Utility.isStackInvalid(aStack)) return true; - if (aIndex < 0 || aIndex >= getSizeInventory()) return false; - final ItemStack tStack = getStackInSlot(aIndex); - if (GT_Utility.isStackInvalid(tStack)) { - setInventorySlotContents(aIndex, aStack); + public boolean addStackToSlot(int slotIndex, ItemStack stack) { + if (GT_Utility.isStackInvalid(stack)) return true; + if (slotIndex < 0 || slotIndex >= getSizeInventory()) return false; + final ItemStack toStack = getStackInSlot(slotIndex); + if (GT_Utility.isStackInvalid(toStack)) { + setInventorySlotContents(slotIndex, stack); return true; } - aStack = GT_OreDictUnificator.get(aStack); - if (GT_Utility.areStacksEqual(tStack, aStack) - && tStack.stackSize + aStack.stackSize <= Math.min(aStack.getMaxStackSize(), getInventoryStackLimit())) { - tStack.stackSize += aStack.stackSize; + final ItemStack fromStack = GT_OreDictUnificator.get(stack); + if (GT_Utility.areStacksEqual(toStack, fromStack) && toStack.stackSize + fromStack.stackSize + <= Math.min(fromStack.getMaxStackSize(), getInventoryStackLimit())) { + toStack.stackSize += fromStack.stackSize; markDirty(); return true; } @@ -2189,8 +2184,8 @@ public byte setColorization(byte aColor) { } @Override - public float getBlastResistance(byte aSide) { - return canAccessData() ? Math.max(0, getMetaTileEntity().getExplosionResistance(aSide)) : 10.0F; + public float getBlastResistance(ForgeDirection side) { + return canAccessData() ? Math.max(0, getMetaTileEntity().getExplosionResistance(side)) : 10.0F; } @Override @@ -2332,7 +2327,7 @@ protected int migrateInventoryIndex(int slotIndex, int nbtVersion) { @Override public IGridNode getGridNode(ForgeDirection forgeDirection) { - if (mFacing != forgeDirection.ordinal()) return null; + if (mFacing != forgeDirection) return null; final AENetworkProxy gp = getProxy(); return gp != null ? gp.getNode() : null; } diff --git a/src/main/java/gregtech/api/metatileentity/BaseTileEntity.java b/src/main/java/gregtech/api/metatileentity/BaseTileEntity.java index 2b9894a616f..618dc9b6625 100644 --- a/src/main/java/gregtech/api/metatileentity/BaseTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/BaseTileEntity.java @@ -1,6 +1,5 @@ package gregtech.api.metatileentity; -import static gregtech.api.enums.GT_Values.ALL_VALID_SIDES; import static gregtech.api.enums.GT_Values.COMPASS_DIRECTIONS; import static gregtech.api.enums.GT_Values.GT; import static gregtech.api.enums.GT_Values.NW; @@ -103,16 +102,17 @@ public abstract class BaseTileEntity extends TileEntity implements IHasWorldObje private final ChunkCoordinates mReturnedCoordinates = new ChunkCoordinates(); - public static byte getSideForPlayerPlacing(Entity aPlayer, byte aDefaultFacing, boolean[] aAllowedFacings) { + public static ForgeDirection getSideForPlayerPlacing(Entity aPlayer, ForgeDirection defaultFacing, + boolean[] aAllowedFacings) { if (aPlayer != null) { - if (aPlayer.rotationPitch >= 65 && aAllowedFacings[SIDE_UP]) return SIDE_UP; - if (aPlayer.rotationPitch <= -65 && aAllowedFacings[SIDE_DOWN]) return SIDE_DOWN; + if (aPlayer.rotationPitch >= 65 && aAllowedFacings[SIDE_UP]) return ForgeDirection.UP; + if (aPlayer.rotationPitch <= -65 && aAllowedFacings[SIDE_DOWN]) return ForgeDirection.DOWN; final byte rFacing = COMPASS_DIRECTIONS[MathHelper.floor_double(0.5D + 4.0F * aPlayer.rotationYaw / 360.0F) & 0x3]; - if (aAllowedFacings[rFacing]) return rFacing; + if (aAllowedFacings[rFacing]) return ForgeDirection.getOrientation(rFacing); } - for (final byte tSide : ALL_VALID_SIDES) if (aAllowedFacings[tSide]) return tSide; - return aDefaultFacing; + for (final ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) if (aAllowedFacings[dir.ordinal()]) return dir; + return defaultFacing; } private void clearNullMarkersFromTileEntityBuffer() { @@ -156,18 +156,18 @@ public ChunkCoordinates getCoords() { } @Override - public final int getOffsetX(byte aSide, int aMultiplier) { - return xCoord + ForgeDirection.getOrientation(aSide).offsetX * aMultiplier; + public final int getOffsetX(ForgeDirection side, int aMultiplier) { + return xCoord + side.offsetX * aMultiplier; } @Override - public final short getOffsetY(byte aSide, int aMultiplier) { - return (short) (yCoord + ForgeDirection.getOrientation(aSide).offsetY * aMultiplier); + public final short getOffsetY(ForgeDirection side, int aMultiplier) { + return (short) (yCoord + side.offsetY * aMultiplier); } @Override - public final int getOffsetZ(byte aSide, int aMultiplier) { - return zCoord + ForgeDirection.getOrientation(aSide).offsetZ * aMultiplier; + public final int getOffsetZ(ForgeDirection side, int aMultiplier) { + return zCoord + side.offsetZ * aMultiplier; } @Override @@ -224,13 +224,13 @@ public final Block getBlockOffset(int aX, int aY, int aZ) { } @Override - public final Block getBlockAtSide(byte aSide) { - return getBlockAtSideAndDistance(aSide, 1); + public final Block getBlockAtSide(ForgeDirection side) { + return getBlockAtSideAndDistance(side, 1); } @Override - public final Block getBlockAtSideAndDistance(byte aSide, int aDistance) { - return getBlock(getOffsetX(aSide, aDistance), getOffsetY(aSide, aDistance), getOffsetZ(aSide, aDistance)); + public final Block getBlockAtSideAndDistance(ForgeDirection side, int aDistance) { + return getBlock(getOffsetX(side, aDistance), getOffsetY(side, aDistance), getOffsetZ(side, aDistance)); } @Override @@ -239,13 +239,13 @@ public final byte getMetaIDOffset(int aX, int aY, int aZ) { } @Override - public final byte getMetaIDAtSide(byte aSide) { - return getMetaIDAtSideAndDistance(aSide, 1); + public final byte getMetaIDAtSide(ForgeDirection side) { + return getMetaIDAtSideAndDistance(side, 1); } @Override - public final byte getMetaIDAtSideAndDistance(byte aSide, int aDistance) { - return getMetaID(getOffsetX(aSide, aDistance), getOffsetY(aSide, aDistance), getOffsetZ(aSide, aDistance)); + public final byte getMetaIDAtSideAndDistance(ForgeDirection side, int aDistance) { + return getMetaID(getOffsetX(side, aDistance), getOffsetY(side, aDistance), getOffsetZ(side, aDistance)); } @Override @@ -254,13 +254,13 @@ public final byte getLightLevelOffset(int aX, int aY, int aZ) { } @Override - public final byte getLightLevelAtSide(byte aSide) { - return getLightLevelAtSideAndDistance(aSide, 1); + public final byte getLightLevelAtSide(ForgeDirection side) { + return getLightLevelAtSideAndDistance(side, 1); } @Override - public final byte getLightLevelAtSideAndDistance(byte aSide, int aDistance) { - return getLightLevel(getOffsetX(aSide, aDistance), getOffsetY(aSide, aDistance), getOffsetZ(aSide, aDistance)); + public final byte getLightLevelAtSideAndDistance(ForgeDirection side, int aDistance) { + return getLightLevel(getOffsetX(side, aDistance), getOffsetY(side, aDistance), getOffsetZ(side, aDistance)); } @Override @@ -269,13 +269,13 @@ public final boolean getOpacityOffset(int aX, int aY, int aZ) { } @Override - public final boolean getOpacityAtSide(byte aSide) { - return getOpacityAtSideAndDistance(aSide, 1); + public final boolean getOpacityAtSide(ForgeDirection side) { + return getOpacityAtSideAndDistance(side, 1); } @Override - public final boolean getOpacityAtSideAndDistance(byte aSide, int aDistance) { - return getOpacity(getOffsetX(aSide, aDistance), getOffsetY(aSide, aDistance), getOffsetZ(aSide, aDistance)); + public final boolean getOpacityAtSideAndDistance(ForgeDirection side, int aDistance) { + return getOpacity(getOffsetX(side, aDistance), getOffsetY(side, aDistance), getOffsetZ(side, aDistance)); } @Override @@ -284,13 +284,13 @@ public final boolean getSkyOffset(int aX, int aY, int aZ) { } @Override - public final boolean getSkyAtSide(byte aSide) { - return getSkyAtSideAndDistance(aSide, 1); + public final boolean getSkyAtSide(ForgeDirection side) { + return getSkyAtSideAndDistance(side, 1); } @Override - public final boolean getSkyAtSideAndDistance(byte aSide, int aDistance) { - return getSky(getOffsetX(aSide, aDistance), getOffsetY(aSide, aDistance), getOffsetZ(aSide, aDistance)); + public final boolean getSkyAtSideAndDistance(ForgeDirection side, int aDistance) { + return getSky(getOffsetX(side, aDistance), getOffsetY(side, aDistance), getOffsetZ(side, aDistance)); } @Override @@ -299,13 +299,13 @@ public final boolean getAirOffset(int aX, int aY, int aZ) { } @Override - public final boolean getAirAtSide(byte aSide) { - return getAirAtSideAndDistance(aSide, 1); + public final boolean getAirAtSide(ForgeDirection side) { + return getAirAtSideAndDistance(side, 1); } @Override - public final boolean getAirAtSideAndDistance(byte aSide, int aDistance) { - return getAir(getOffsetX(aSide, aDistance), getOffsetY(aSide, aDistance), getOffsetZ(aSide, aDistance)); + public final boolean getAirAtSideAndDistance(ForgeDirection side, int aDistance) { + return getAir(getOffsetX(side, aDistance), getOffsetY(side, aDistance), getOffsetZ(side, aDistance)); } @Override @@ -314,9 +314,9 @@ public final TileEntity getTileEntityOffset(int aX, int aY, int aZ) { } @Override - public final TileEntity getTileEntityAtSideAndDistance(byte aSide, int aDistance) { - if (aDistance == 1) return getTileEntityAtSide(aSide); - return getTileEntity(getOffsetX(aSide, aDistance), getOffsetY(aSide, aDistance), getOffsetZ(aSide, aDistance)); + public final TileEntity getTileEntityAtSideAndDistance(ForgeDirection side, int aDistance) { + if (aDistance == 1) return getTileEntityAtSide(side); + return getTileEntity(getOffsetX(side, aDistance), getOffsetY(side, aDistance), getOffsetZ(side, aDistance)); } @Override @@ -334,15 +334,15 @@ public final IInventory getIInventoryOffset(int aX, int aY, int aZ) { } @Override - public final IInventory getIInventoryAtSide(byte aSide) { - final TileEntity tTileEntity = getTileEntityAtSide(aSide); + public final IInventory getIInventoryAtSide(ForgeDirection side) { + final TileEntity tTileEntity = getTileEntityAtSide(side); if (tTileEntity instanceof IInventory) return (IInventory) tTileEntity; return null; } @Override - public final IInventory getIInventoryAtSideAndDistance(byte aSide, int aDistance) { - final TileEntity tTileEntity = getTileEntityAtSideAndDistance(aSide, aDistance); + public final IInventory getIInventoryAtSideAndDistance(ForgeDirection side, int aDistance) { + final TileEntity tTileEntity = getTileEntityAtSideAndDistance(side, aDistance); if (tTileEntity instanceof IInventory) return (IInventory) tTileEntity; return null; } @@ -362,15 +362,15 @@ public final IFluidHandler getITankContainerOffset(int aX, int aY, int aZ) { } @Override - public final IFluidHandler getITankContainerAtSide(byte aSide) { - final TileEntity tTileEntity = getTileEntityAtSide(aSide); + public final IFluidHandler getITankContainerAtSide(ForgeDirection side) { + final TileEntity tTileEntity = getTileEntityAtSide(side); if (tTileEntity instanceof IFluidHandler) return (IFluidHandler) tTileEntity; return null; } @Override - public final IFluidHandler getITankContainerAtSideAndDistance(byte aSide, int aDistance) { - final TileEntity tTileEntity = getTileEntityAtSideAndDistance(aSide, aDistance); + public final IFluidHandler getITankContainerAtSideAndDistance(ForgeDirection side, int aDistance) { + final TileEntity tTileEntity = getTileEntityAtSideAndDistance(side, aDistance); if (tTileEntity instanceof IFluidHandler) return (IFluidHandler) tTileEntity; return null; } @@ -390,15 +390,15 @@ public final IGregTechTileEntity getIGregTechTileEntityOffset(int aX, int aY, in } @Override - public final IGregTechTileEntity getIGregTechTileEntityAtSide(byte aSide) { - final TileEntity tTileEntity = getTileEntityAtSide(aSide); + public final IGregTechTileEntity getIGregTechTileEntityAtSide(ForgeDirection side) { + final TileEntity tTileEntity = getTileEntityAtSide(side); if (tTileEntity instanceof IGregTechTileEntity) return (IGregTechTileEntity) tTileEntity; return null; } @Override - public final IGregTechTileEntity getIGregTechTileEntityAtSideAndDistance(byte aSide, int aDistance) { - final TileEntity tTileEntity = getTileEntityAtSideAndDistance(aSide, aDistance); + public final IGregTechTileEntity getIGregTechTileEntityAtSideAndDistance(ForgeDirection side, int aDistance) { + final TileEntity tTileEntity = getTileEntityAtSideAndDistance(side, aDistance); if (tTileEntity instanceof IGregTechTileEntity) return (IGregTechTileEntity) tTileEntity; return null; } @@ -453,30 +453,31 @@ public TileEntity getTileEntity(int aX, int aY, int aZ) { } @Override - public final TileEntity getTileEntityAtSide(byte aSide) { - if (aSide < 0 || aSide >= 6 || mBufferedTileEntities[aSide] == this) return null; - final int tX = getOffsetX(aSide, 1); - final int tY = getOffsetY(aSide, 1); - final int tZ = getOffsetZ(aSide, 1); + public final TileEntity getTileEntityAtSide(ForgeDirection side) { + final int ordinalSide = side.ordinal(); + if (side == ForgeDirection.UNKNOWN || mBufferedTileEntities[ordinalSide] == this) return null; + final int tX = getOffsetX(side, 1); + final int tY = getOffsetY(side, 1); + final int tZ = getOffsetZ(side, 1); if (crossedChunkBorder(tX, tZ)) { - mBufferedTileEntities[aSide] = null; + mBufferedTileEntities[ordinalSide] = null; if (ignoreUnloadedChunks && !worldObj.blockExists(tX, tY, tZ)) return null; } - if (mBufferedTileEntities[aSide] == null) { - mBufferedTileEntities[aSide] = worldObj.getTileEntity(tX, tY, tZ); - if (mBufferedTileEntities[aSide] == null) { - mBufferedTileEntities[aSide] = this; + if (mBufferedTileEntities[ordinalSide] == null) { + mBufferedTileEntities[ordinalSide] = worldObj.getTileEntity(tX, tY, tZ); + if (mBufferedTileEntities[ordinalSide] == null) { + mBufferedTileEntities[ordinalSide] = this; return null; } - return mBufferedTileEntities[aSide]; + return mBufferedTileEntities[ordinalSide]; } - if (mBufferedTileEntities[aSide].isInvalid()) { - mBufferedTileEntities[aSide] = null; - return getTileEntityAtSide(aSide); + if (mBufferedTileEntities[ordinalSide].isInvalid()) { + mBufferedTileEntities[ordinalSide] = null; + return getTileEntityAtSide(side); } - if (mBufferedTileEntities[aSide].xCoord == tX && mBufferedTileEntities[aSide].yCoord == tY - && mBufferedTileEntities[aSide].zCoord == tZ) { - return mBufferedTileEntities[aSide]; + if (mBufferedTileEntities[ordinalSide].xCoord == tX && mBufferedTileEntities[ordinalSide].yCoord == tY + && mBufferedTileEntities[ordinalSide].zCoord == tZ) { + return mBufferedTileEntities[ordinalSide]; } return null; } @@ -518,7 +519,7 @@ public void updateEntity() { isDead = false; } - public final void onAdjacentBlockChange(int aX, int aY, int aZ) { + public final void onAdjacentBlockChange(int ignoredAX, int ignoredAY, int ignoredAZ) { clearNullMarkersFromTileEntityBuffer(); } @@ -709,7 +710,6 @@ protected void addTitleTextStyle(ModularWindow.Builder builder, String title) { int titleWidth = 0, titleHeight = 0; if (NetworkUtils.isClient()) { final FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer; - // noinspection unchecked final List titleLines = fontRenderer .listFormattedStringToWidth(title, getGUIWidth() - (TAB_PADDING + TITLE_PADDING) * 2); titleWidth = titleLines.size() > 1 ? getGUIWidth() - (TAB_PADDING + TITLE_PADDING) * 2 diff --git a/src/main/java/gregtech/api/metatileentity/CommonMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/CommonMetaTileEntity.java index 5fa9cbfaeee..157bef793c8 100644 --- a/src/main/java/gregtech/api/metatileentity/CommonMetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/CommonMetaTileEntity.java @@ -6,6 +6,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.network.Packet; +import net.minecraftforge.common.util.ForgeDirection; import com.gtnewhorizons.modularui.api.forge.ItemStackHandler; import com.gtnewhorizons.modularui.api.screen.ModularWindow; @@ -140,8 +141,8 @@ public void issueBlockUpdate() { } @Override - public boolean isValidFacing(byte aSide) { - if (canAccessData()) return getMetaTileEntity().isFacingValid(aSide); + public boolean isValidFacing(ForgeDirection side) { + if (canAccessData()) return getMetaTileEntity().isFacingValid(side); return false; } @@ -163,13 +164,13 @@ public boolean isStillValid() { } @Override - public boolean allowCoverOnSide(byte aSide, GT_ItemStack aCoverID) { - return hasValidMetaTileEntity() && getMetaTileEntity().allowCoverOnSide(aSide, aCoverID); + public boolean allowCoverOnSide(ForgeDirection side, GT_ItemStack aCoverID) { + return hasValidMetaTileEntity() && getMetaTileEntity().allowCoverOnSide(side, aCoverID); } @Override - public void issueCoverUpdate(byte aSide) { - super.issueCoverUpdate(aSide); + public void issueCoverUpdate(ForgeDirection side) { + super.issueCoverUpdate(side); issueClientUpdate(); } diff --git a/src/main/java/gregtech/api/metatileentity/CoverableTileEntity.java b/src/main/java/gregtech/api/metatileentity/CoverableTileEntity.java index f2cd7e30194..0370965f61b 100644 --- a/src/main/java/gregtech/api/metatileentity/CoverableTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/CoverableTileEntity.java @@ -1,6 +1,5 @@ package gregtech.api.metatileentity; -import static gregtech.api.enums.GT_Values.ALL_VALID_SIDES; import static gregtech.api.enums.GT_Values.E; import static gregtech.api.enums.GT_Values.NW; import static gregtech.api.util.GT_LanguageManager.FACES; @@ -9,9 +8,9 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; +import java.util.Comparator; import java.util.List; import java.util.Objects; -import java.util.stream.IntStream; import mcp.mobius.waila.api.IWailaConfigHandler; import mcp.mobius.waila.api.IWailaDataAccessor; @@ -98,14 +97,14 @@ protected void writeCoverNBT(NBTTagCompound aNBT, boolean isDrop) { final NBTTagList tList = new NBTTagList(); final int[] coverSides = new int[] { 0, 0, 0, 0, 0, 0 }; - for (byte i = 0; i < coverInfos.length; i++) { - final CoverInfo coverInfo = getCoverInfoAtSide(i); + for (final ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + final CoverInfo coverInfo = getCoverInfoAtSide(side); if (!coverInfo.isValid()) continue; // Backwards compat, in case of a revert... for now tList.appendTag(coverInfo.writeToNBT(new NBTTagCompound())); aNBT.setTag( - COVER_DATA_NBT_KEYS[i], + COVER_DATA_NBT_KEYS[side.ordinal()], coverInfo.getCoverData() .saveDataToNBT()); } @@ -142,7 +141,7 @@ public void readCoverInfoNBT(NBTTagCompound aNBT) { final NBTTagCompound tNBT = tList.getCompoundTagAt(i); final CoverInfo coverInfo = new CoverInfo(this, tNBT); this.setCoverInfoAtSide(coverInfo.getSide(), coverInfo); - if (coverInfo.isDataNeededOnClient()) issueCoverUpdate(i); + if (coverInfo.isDataNeededOnClient()) issueCoverUpdate(ForgeDirection.getOrientation(i)); } } @@ -152,58 +151,60 @@ public void readLegacyCoverInfoNBT(NBTTagCompound aNBT) { final boolean hasOldCoverData = (aNBT.hasKey("mCoverData", 11) && aNBT.getIntArray("mCoverData").length == 6); final int[] tOldData = hasOldCoverData ? aNBT.getIntArray("mCoverData") : new int[] {}; - for (byte i : ALL_VALID_SIDES) { - if (coverIDs[i] == 0) continue; + for (final ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + final int ordinalSide = side.ordinal(); + if (coverIDs[ordinalSide] == 0) continue; - final CoverInfo coverInfo = new CoverInfo(i, coverIDs[i], this, null); + final CoverInfo coverInfo = new CoverInfo(side, coverIDs[ordinalSide], this, null); final GT_CoverBehaviorBase coverBehavior = coverInfo.getCoverBehavior(); if (coverBehavior == GregTech_API.sNoBehavior) continue; ISerializableObject coverData = null; if (hasOldCoverData) { if (coverBehavior instanceof GT_Cover_Fluidfilter) { - final String filterKey = String.format("fluidFilter%d", i); + final String filterKey = String.format("fluidFilter%d", ordinalSide); if (aNBT.hasKey(filterKey)) { coverData = coverInfo.getCoverBehavior() .createDataObject( - (tOldData[i] & 7) | (FluidRegistry.getFluidID(aNBT.getString(filterKey)) << 3)); + (tOldData[ordinalSide] & 7) + | (FluidRegistry.getFluidID(aNBT.getString(filterKey)) << 3)); } } else { - coverData = coverBehavior.createDataObject(tOldData[i]); + coverData = coverBehavior.createDataObject(tOldData[ordinalSide]); } } else { - if (aNBT.hasKey(COVER_DATA_NBT_KEYS[i])) - coverData = coverBehavior.createDataObject(aNBT.getTag(COVER_DATA_NBT_KEYS[i])); + if (aNBT.hasKey(COVER_DATA_NBT_KEYS[ordinalSide])) + coverData = coverBehavior.createDataObject(aNBT.getTag(COVER_DATA_NBT_KEYS[ordinalSide])); } if (coverData != null) coverInfo.setCoverData(coverData); - setCoverInfoAtSide(i, coverInfo); - if (coverInfo.isDataNeededOnClient()) issueCoverUpdate(i); + setCoverInfoAtSide(side, coverInfo); + if (coverInfo.isDataNeededOnClient()) issueCoverUpdate(side); } } public abstract boolean isStillValid(); protected boolean doCoverThings() { - for (byte i : ALL_VALID_SIDES) { - if (!tickCoverAtSide(i)) return false; + for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + if (!tickCoverAtSide(side)) return false; } return true; } - public boolean tickCoverAtSide(byte aSide) { - return tickCoverAtSide(aSide, mTickTimer); + public boolean tickCoverAtSide(ForgeDirection side) { + return tickCoverAtSide(side, mTickTimer); } /** * Returns false if the tile is no longer valid after ticking the cover */ - public boolean tickCoverAtSide(byte aSide, long aTickTimer) { - final CoverInfo coverInfo = getCoverInfoAtSide(aSide); + public boolean tickCoverAtSide(ForgeDirection side, long aTickTimer) { + final CoverInfo coverInfo = getCoverInfoAtSide(side); if (!coverInfo.isValid()) return true; final int tCoverTickRate = coverInfo.getTickRate(); if (tCoverTickRate > 0 && aTickTimer % tCoverTickRate == 0) { - final byte tRedstone = coverInfo.isRedstoneSensitive(aTickTimer) ? getInputRedstoneSignal(aSide) : 0; + final byte tRedstone = coverInfo.isRedstoneSensitive(aTickTimer) ? getInputRedstoneSignal(side) : 0; coverInfo.setCoverData(coverInfo.doCoverThings(aTickTimer, tRedstone)); return isStillValid(); } @@ -211,33 +212,33 @@ public boolean tickCoverAtSide(byte aSide, long aTickTimer) { return true; } - public abstract boolean allowCoverOnSide(byte aSide, GT_ItemStack aCoverID); + public abstract boolean allowCoverOnSide(ForgeDirection side, GT_ItemStack aCoverID); protected void checkDropCover() { - for (byte i : ALL_VALID_SIDES) { - final int coverId = getCoverIDAtSide(i); - if (coverId != 0) if (!allowCoverOnSide(i, new GT_ItemStack(coverId))) dropCover(i, i, true); + for (final ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + final int coverId = getCoverIDAtSide(side); + if (coverId != 0 && !allowCoverOnSide(side, new GT_ItemStack(coverId))) dropCover(side, side, true); } } protected void updateCoverBehavior() { - for (byte i : ALL_VALID_SIDES) { - final CoverInfo coverInfo = getCoverInfoAtSide(i); + for (final ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + final CoverInfo coverInfo = getCoverInfoAtSide(side); if (coverInfo.isValid()) coverInfo.updateCoverBehavior(); } } @Override - public void issueCoverUpdate(byte aSide) { + public void issueCoverUpdate(ForgeDirection side) { // If we've got a null worldObj we're getting called as a part of readingNBT from a non tickable MultiTileEntity // on chunk load before the world is set // so we'll want to send a cover update. - final CoverInfo coverInfo = getCoverInfoAtSide(aSide); + final CoverInfo coverInfo = getCoverInfoAtSide(side); if (worldObj == null || (isServerSide() && coverInfo.isDataNeededOnClient())) coverInfo.setNeedsUpdate(true); } - public final ITexture getCoverTexture(byte aSide) { - final CoverInfo coverInfo = getCoverInfoAtSide(aSide); + public final ITexture getCoverTexture(ForgeDirection side) { + final CoverInfo coverInfo = getCoverInfoAtSide(side); if (!coverInfo.isValid()) return null; if (GT_Mod.instance.isClientSide() && (GT_Client.hideValue & 0x1) != 0) { return Textures.BlockIcons.HIDDEN_TEXTURE[0]; // See through @@ -245,41 +246,40 @@ public final ITexture getCoverTexture(byte aSide) { final ITexture coverTexture = (!(this instanceof BaseMetaPipeEntity)) ? coverInfo.getSpecialCoverFGTexture() : coverInfo.getSpecialCoverTexture(); - return coverTexture != null ? coverTexture - : GregTech_API.sCovers.get(new GT_ItemStack(getCoverIDAtSide(aSide))); + return coverTexture != null ? coverTexture : GregTech_API.sCovers.get(new GT_ItemStack(getCoverIDAtSide(side))); } protected void requestCoverDataIfNeeded() { if (worldObj == null || !worldObj.isRemote) return; - for (byte i : ALL_VALID_SIDES) { - final CoverInfo coverInfo = getCoverInfoAtSide(i); + for (final ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + final CoverInfo coverInfo = getCoverInfoAtSide(side); if (coverInfo.isDataNeededOnClient()) NW.sendToServer(new GT_Packet_RequestCoverData(coverInfo, this)); } } @Override - public void setCoverIdAndDataAtSide(byte aSide, int aId, ISerializableObject aData) { - if (setCoverIDAtSideNoUpdate(aSide, aId, aData)) { - issueCoverUpdate(aSide); + public void setCoverIdAndDataAtSide(ForgeDirection side, int aId, ISerializableObject aData) { + if (setCoverIDAtSideNoUpdate(side, aId, aData)) { + issueCoverUpdate(side); issueBlockUpdate(); } } @Override - public void setCoverIDAtSide(byte aSide, int aID) { - setCoverIdAndDataAtSide(aSide, aID, null); + public void setCoverIDAtSide(ForgeDirection side, int aID) { + setCoverIdAndDataAtSide(side, aID, null); } @Override - public boolean setCoverIDAtSideNoUpdate(byte aSide, int aID) { - return setCoverIDAtSideNoUpdate(aSide, aID, null); + public boolean setCoverIDAtSideNoUpdate(ForgeDirection side, int aID) { + return setCoverIDAtSideNoUpdate(side, aID, null); } - public boolean setCoverIDAtSideNoUpdate(byte aSide, int aID, ISerializableObject aData) { - final CoverInfo oldCoverInfo = getCoverInfoAtSide(aSide); - if (aSide >= 0 && aSide < 6 && oldCoverInfo.getCoverID() != aID) { + public boolean setCoverIDAtSideNoUpdate(ForgeDirection side, int aID, ISerializableObject aData) { + final CoverInfo oldCoverInfo = getCoverInfoAtSide(side); + if (side != ForgeDirection.UNKNOWN && oldCoverInfo.getCoverID() != aID) { if (aID == 0 && isClientSide()) oldCoverInfo.onDropped(); - setCoverInfoAtSide(aSide, new CoverInfo(aSide, aID, this, aData)); + setCoverInfoAtSide(side, new CoverInfo(side, aID, this, aData)); return true; } return false; @@ -287,57 +287,57 @@ public boolean setCoverIDAtSideNoUpdate(byte aSide, int aID, ISerializableObject @Override @Deprecated - public void setCoverDataAtSide(byte aSide, int aData) { - final CoverInfo coverInfo = getCoverInfoAtSide(aSide); + public void setCoverDataAtSide(ForgeDirection side, int aData) { + final CoverInfo coverInfo = getCoverInfoAtSide(side); if (coverInfo.isValid() && coverInfo.getCoverData() instanceof ISerializableObject.LegacyCoverData) coverInfo.setCoverData(new ISerializableObject.LegacyCoverData(aData)); } @Override - public void setCoverDataAtSide(byte aSide, ISerializableObject aData) { - final CoverInfo coverInfo = getCoverInfoAtSide(aSide); + public void setCoverDataAtSide(ForgeDirection side, ISerializableObject aData) { + final CoverInfo coverInfo = getCoverInfoAtSide(side); if (coverInfo.isValid() && coverInfo.getCoverBehavior() .cast(aData) != null) coverInfo.setCoverData(aData); } @Override @Deprecated - public GT_CoverBehavior getCoverBehaviorAtSide(byte aSide) { - final GT_CoverBehaviorBase behavior = getCoverInfoAtSide(aSide).getCoverBehavior(); + public GT_CoverBehavior getCoverBehaviorAtSide(ForgeDirection side) { + final GT_CoverBehaviorBase behavior = getCoverInfoAtSide(side).getCoverBehavior(); if (behavior instanceof GT_CoverBehavior) return (GT_CoverBehavior) behavior; return GregTech_API.sNoBehavior; } @Override - public void setCoverItemAtSide(byte aSide, ItemStack aCover) { + public void setCoverItemAtSide(ForgeDirection side, ItemStack aCover) { GregTech_API.getCoverBehaviorNew(aCover) - .placeCover(aSide, aCover, this); + .placeCover(side, aCover, this); } @Override - public int getCoverIDAtSide(byte aSide) { - return getCoverInfoAtSide(aSide).getCoverID(); + public int getCoverIDAtSide(ForgeDirection side) { + return getCoverInfoAtSide(side).getCoverID(); } @Override - public ItemStack getCoverItemAtSide(byte aSide) { - return getCoverInfoAtSide(aSide).getDisplayStack(); + public ItemStack getCoverItemAtSide(ForgeDirection side) { + return getCoverInfoAtSide(side).getDisplayStack(); } @Override - public boolean canPlaceCoverIDAtSide(byte aSide, int aID) { - return getCoverIDAtSide(aSide) == 0; + public boolean canPlaceCoverIDAtSide(ForgeDirection side, int aID) { + return getCoverIDAtSide(side) == 0; } @Override - public boolean canPlaceCoverItemAtSide(byte aSide, ItemStack aCover) { - return getCoverIDAtSide(aSide) == 0; + public boolean canPlaceCoverItemAtSide(ForgeDirection side, ItemStack aCover) { + return getCoverIDAtSide(side) == 0; } @Override @Deprecated - public int getCoverDataAtSide(byte aSide) { - final ISerializableObject coverData = getCoverInfoAtSide(aSide).getCoverData(); + public int getCoverDataAtSide(ForgeDirection side) { + final ISerializableObject coverData = getCoverInfoAtSide(side).getCoverData(); if (coverData instanceof ISerializableObject.LegacyCoverData) { return ((ISerializableObject.LegacyCoverData) coverData).get(); } @@ -345,37 +345,38 @@ public int getCoverDataAtSide(byte aSide) { } @Override - public ISerializableObject getComplexCoverDataAtSide(byte aSide) { - return getCoverInfoAtSide(aSide).getCoverData(); + public ISerializableObject getComplexCoverDataAtSide(ForgeDirection side) { + return getCoverInfoAtSide(side).getCoverData(); } @Override - public GT_CoverBehaviorBase getCoverBehaviorAtSideNew(byte aSide) { - return getCoverInfoAtSide(aSide).getCoverBehavior(); + public GT_CoverBehaviorBase getCoverBehaviorAtSideNew(ForgeDirection side) { + return getCoverInfoAtSide(side).getCoverBehavior(); } - public void setCoverInfoAtSide(byte aSide, CoverInfo coverInfo) { - if (aSide >= 0 && aSide < 6) coverInfos[aSide] = coverInfo; + public void setCoverInfoAtSide(ForgeDirection side, CoverInfo coverInfo) { + if (side != ForgeDirection.UNKNOWN) coverInfos[side.ordinal()] = coverInfo; } @Override - public CoverInfo getCoverInfoAtSide(byte aSide) { - if (aSide >= 0 && aSide < 6) { - if (coverInfos[aSide] == null) coverInfos[aSide] = new CoverInfo(aSide, this); - return coverInfos[aSide]; + public CoverInfo getCoverInfoAtSide(ForgeDirection side) { + final int ordinalSide = side.ordinal(); + if (side != ForgeDirection.UNKNOWN) { + if (coverInfos[ordinalSide] == null) coverInfos[ordinalSide] = new CoverInfo(side, this); + return coverInfos[side.ordinal()]; } return CoverInfo.EMPTY_INFO; } - public void clearCoverInfoAtSide(byte aSide) { - if (aSide >= 0 && aSide < 6) { - setCoverIDAtSide(aSide, 0); + public void clearCoverInfoAtSide(ForgeDirection side) { + if (side != ForgeDirection.UNKNOWN) { + setCoverIDAtSide(side, 0); } } @Override - public boolean dropCover(byte aSide, byte aDroppedSide, boolean aForced) { - final CoverInfo coverInfo = getCoverInfoAtSide(aSide); + public boolean dropCover(ForgeDirection side, ForgeDirection droppedSide, boolean aForced) { + final CoverInfo coverInfo = getCoverInfoAtSide(side); if (!coverInfo.isValid()) return false; if (!coverInfo.onCoverRemoval(aForced) && !aForced) return false; final ItemStack tStack = coverInfo.getDrop(); @@ -383,84 +384,88 @@ public boolean dropCover(byte aSide, byte aDroppedSide, boolean aForced) { coverInfo.onDropped(); final EntityItem tEntity = new EntityItem( worldObj, - getOffsetX(aDroppedSide, 1) + 0.5, - getOffsetY(aDroppedSide, 1) + 0.5, - getOffsetZ(aDroppedSide, 1) + 0.5, + getOffsetX(droppedSide, 1) + 0.5, + getOffsetY(droppedSide, 1) + 0.5, + getOffsetZ(droppedSide, 1) + 0.5, tStack); tEntity.motionX = 0; tEntity.motionY = 0; tEntity.motionZ = 0; worldObj.spawnEntityInWorld(tEntity); } - clearCoverInfoAtSide(aSide); - updateOutputRedstoneSignal(aSide); + clearCoverInfoAtSide(side); + updateOutputRedstoneSignal(side); return true; } protected void onBaseTEDestroyed() { - for (byte side : ALL_VALID_SIDES) { + for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { final CoverInfo coverInfo = getCoverInfoAtSide(side); if (coverInfo.isValid()) coverInfo.onBaseTEDestroyed(); } } @Override - public void setOutputRedstoneSignal(byte aSide, byte aStrength) { - aStrength = (byte) Math.min(Math.max(0, aStrength), 15); - if (aSide < 0 || aSide >= 6) return; + public void setOutputRedstoneSignal(ForgeDirection side, byte strength) { + final byte cappedStrength = (byte) Math.min(Math.max(0, strength), 15); + if (side == ForgeDirection.UNKNOWN) return; - if (mSidedRedstone[aSide] != aStrength || (mStrongRedstone & (1 << aSide)) > 0) { - if ((mStrongRedstone & (1 << aSide)) > 0) { - mStrongRedstone ^= (1 << aSide); + final int ordinalSide = side.ordinal(); + if (mSidedRedstone[ordinalSide] != cappedStrength || (mStrongRedstone & (1 << ordinalSide)) > 0) { + if ((mStrongRedstone & (1 << ordinalSide)) > 0) { + mStrongRedstone ^= (1 << ordinalSide); issueBlockUpdate(); } - mSidedRedstone[aSide] = aStrength; + mSidedRedstone[ordinalSide] = cappedStrength; issueBlockUpdate(); } } @Override - public void setStrongOutputRedstoneSignal(byte aSide, byte aStrength) { - aStrength = (byte) Math.min(Math.max(0, aStrength), 15); - if (aSide < 0 || aSide >= 6) return; + public void setStrongOutputRedstoneSignal(ForgeDirection side, byte strength) { + final byte cappedStrength = (byte) Math.min(Math.max(0, strength), 15); + if (side == ForgeDirection.UNKNOWN) return; - if (mSidedRedstone[aSide] != aStrength || (mStrongRedstone & (1 << aSide)) == 0) { - mStrongRedstone |= (1 << aSide); - mSidedRedstone[aSide] = aStrength; + final int ordinalSide = side.ordinal(); + if (mSidedRedstone[ordinalSide] != cappedStrength || (mStrongRedstone & (1 << ordinalSide)) == 0) { + mStrongRedstone |= (1 << ordinalSide); + mSidedRedstone[ordinalSide] = cappedStrength; issueBlockUpdate(); } } @Override - public void setInternalOutputRedstoneSignal(byte aSide, byte aStrength) { - if (!getCoverBehaviorAtSideNew(aSide) - .manipulatesSidedRedstoneOutput(aSide, getCoverIDAtSide(aSide), getComplexCoverDataAtSide(aSide), this)) - setOutputRedstoneSignal(aSide, aStrength); + public void setInternalOutputRedstoneSignal(ForgeDirection side, byte aStrength) { + if (!getCoverBehaviorAtSideNew(side) + .manipulatesSidedRedstoneOutput(side, getCoverIDAtSide(side), getComplexCoverDataAtSide(side), this)) + setOutputRedstoneSignal(side, aStrength); } @Override public boolean getRedstone() { - return IntStream.range(1, 6) - .anyMatch(i -> getRedstone((byte) i)); + return Arrays.stream(ForgeDirection.VALID_DIRECTIONS) + .anyMatch(this::getRedstone); } @Override - public boolean getRedstone(byte aSide) { - return getInternalInputRedstoneSignal(aSide) > 0; + public boolean getRedstone(ForgeDirection side) { + return getInternalInputRedstoneSignal(side) > 0; } @Override public byte getStrongestRedstone() { - return (byte) IntStream.range(1, 6) - .map(i -> getInternalInputRedstoneSignal((byte) i)) - .max() - .orElse(0); + return Arrays.stream(ForgeDirection.VALID_DIRECTIONS) + .map(this::getInternalInputRedstoneSignal) + .max(Comparator.comparing(Byte::valueOf)) + .orElse((byte) 0); } @Override - public byte getStrongOutputRedstoneSignal(byte aSide) { - return aSide >= 0 && aSide < 6 && (mStrongRedstone & (1 << aSide)) != 0 ? (byte) (mSidedRedstone[aSide] & 15) + public byte getStrongOutputRedstoneSignal(ForgeDirection side) { + final int ordinalSide = side.ordinal(); + return side != ForgeDirection.UNKNOWN && (mStrongRedstone & (1 << ordinalSide)) != 0 + ? (byte) (mSidedRedstone[ordinalSide] & 15) : 0; } @@ -470,64 +475,65 @@ public void setGenericRedstoneOutput(boolean aOnOff) { } @Override - public byte getInternalInputRedstoneSignal(byte aSide) { - return (byte) (getCoverBehaviorAtSideNew(aSide).getRedstoneInput( - aSide, - getInputRedstoneSignal(aSide), - getCoverIDAtSide(aSide), - getComplexCoverDataAtSide(aSide), + public byte getInternalInputRedstoneSignal(ForgeDirection side) { + return (byte) (getCoverBehaviorAtSideNew(side).getRedstoneInput( + side, + getInputRedstoneSignal(side), + getCoverIDAtSide(side), + getComplexCoverDataAtSide(side), this) & 15); } @Override - public byte getInputRedstoneSignal(byte aSide) { + public byte getInputRedstoneSignal(ForgeDirection side) { return (byte) (worldObj - .getIndirectPowerLevelTo(getOffsetX(aSide, 1), getOffsetY(aSide, 1), getOffsetZ(aSide, 1), aSide) & 15); + .getIndirectPowerLevelTo(getOffsetX(side, 1), getOffsetY(side, 1), getOffsetZ(side, 1), side.ordinal()) + & 15); } @Override - public byte getOutputRedstoneSignal(byte aSide) { - return getCoverBehaviorAtSideNew(aSide) - .manipulatesSidedRedstoneOutput(aSide, getCoverIDAtSide(aSide), getComplexCoverDataAtSide(aSide), this) - ? mSidedRedstone[aSide] - : getGeneralRS(aSide); + public byte getOutputRedstoneSignal(ForgeDirection side) { + return getCoverBehaviorAtSideNew(side) + .manipulatesSidedRedstoneOutput(side, getCoverIDAtSide(side), getComplexCoverDataAtSide(side), this) + ? mSidedRedstone[side.ordinal()] + : getGeneralRS(side); } - protected void updateOutputRedstoneSignal(byte aSide) { - setOutputRedstoneSignal(aSide, (byte) 0); + protected void updateOutputRedstoneSignal(ForgeDirection side) { + setOutputRedstoneSignal(side, (byte) 0); } @Override - public void receiveCoverData(byte aCoverSide, int aCoverID, int aCoverData) { - if (aCoverSide < 0 || aCoverSide >= 6) return; - final CoverInfo oldCoverInfo = getCoverInfoAtSide(aCoverSide); + public void receiveCoverData(ForgeDirection coverSide, int aCoverID, int aCoverData) { + if (coverSide != ForgeDirection.UNKNOWN) return; + final CoverInfo oldCoverInfo = getCoverInfoAtSide(coverSide); if (!oldCoverInfo.isValid()) return; - setCoverIDAtSideNoUpdate(aCoverSide, aCoverID); - setCoverDataAtSide(aCoverSide, aCoverData); + setCoverIDAtSideNoUpdate(coverSide, aCoverID); + setCoverDataAtSide(coverSide, aCoverData); } @Override - public void receiveCoverData(byte aCoverSide, int aCoverID, ISerializableObject aCoverData, + public void receiveCoverData(ForgeDirection coverSide, int aCoverID, ISerializableObject aCoverData, EntityPlayerMP aPlayer) { - if (aCoverSide < 0 || aCoverSide >= 6) return; + if (coverSide != ForgeDirection.UNKNOWN) return; - final CoverInfo oldCoverInfo = getCoverInfoAtSide(aCoverSide); + final CoverInfo oldCoverInfo = getCoverInfoAtSide(coverSide); if (!oldCoverInfo.isValid()) return; oldCoverInfo.preDataChanged(aCoverID, aCoverData); - setCoverIDAtSideNoUpdate(aCoverSide, aCoverID, aCoverData); - setCoverDataAtSide(aCoverSide, aCoverData); + setCoverIDAtSideNoUpdate(coverSide, aCoverID, aCoverData); + setCoverDataAtSide(coverSide, aCoverData); if (isClientSide()) { - getCoverInfoAtSide(aCoverSide).onDataChanged(); + getCoverInfoAtSide(coverSide).onDataChanged(); } } protected void sendCoverDataIfNeeded() { if (worldObj == null || worldObj.isRemote) return; - for (byte i : ALL_VALID_SIDES) { - final CoverInfo coverInfo = getCoverInfoAtSide(i); + for (final ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + final CoverInfo coverInfo = getCoverInfoAtSide(side); if (coverInfo.needsUpdate()) { NW.sendPacketToAllPlayersInRange( worldObj, @@ -540,11 +546,10 @@ protected void sendCoverDataIfNeeded() { } @Override - public void getWailaBody(ItemStack itemStack, List currenttip, IWailaDataAccessor accessor, + public void getWailaBody(ItemStack itemStack, List currentTip, IWailaDataAccessor accessor, IWailaConfigHandler config) { final NBTTagCompound tag = accessor.getNBTData(); - final byte currentFacing = (byte) accessor.getSide() - .ordinal(); + final ForgeDirection currentFacing = accessor.getSide(); final NBTTagList tList = tag.getTagList(GT_Values.NBT.COVERS, 10); for (byte i = 0; i < tList.tagCount(); i++) { @@ -554,18 +559,18 @@ public void getWailaBody(ItemStack itemStack, List currenttip, IWailaDat final ItemStack coverStack = coverInfo.getDisplayStack(); if (coverStack != null) { - currenttip.add( + currentTip.add( StatCollector.translateToLocalFormatted( "GT5U.waila.cover", currentFacing == coverInfo.getSide() ? StatCollector.translateToLocal("GT5U.waila.cover.current_facing") : StatCollector.translateToLocal( - "GT5U.interface.coverTabs." + ForgeDirection.getOrientation(coverInfo.getSide()) + "GT5U.interface.coverTabs." + coverInfo.getSide() .toString() .toLowerCase()), coverStack.getDisplayName())); final String behaviorDesc = coverInfo.getBehaviorDescription(); - if (!Objects.equals(behaviorDesc, E)) currenttip.add(behaviorDesc); + if (!Objects.equals(behaviorDesc, E)) currentTip.add(behaviorDesc); } } @@ -602,7 +607,9 @@ public static void addInstalledCoversInformation(NBTTagCompound aNBT, List behavior = GregTech_API.getCoverBehaviorNew(coverId); if (behavior == null || behavior == GregTech_API.sNoBehavior) continue; - if (!aNBT.hasKey(CoverableTileEntity.COVER_DATA_NBT_KEYS[tSide])) continue; + if (!aNBT.hasKey(CoverableTileEntity.COVER_DATA_NBT_KEYS[i])) continue; final ISerializableObject dataObject = behavior - .createDataObject(aNBT.getTag(CoverableTileEntity.COVER_DATA_NBT_KEYS[tSide])); + .createDataObject(aNBT.getTag(CoverableTileEntity.COVER_DATA_NBT_KEYS[i])); final ItemStack coverStack = behavior.getDisplayStack(coverId, dataObject); if (coverStack != null) { aList.add( - String.format( - "Cover on %s side: %s", - getTranslation(FACES[tSide]), - coverStack.getDisplayName())); + String + .format("Cover on %s side: %s", getTranslation(FACES[i]), coverStack.getDisplayName())); } } } } } - protected ModularWindow createCoverWindow(EntityPlayer player, byte side) { + protected ModularWindow createCoverWindow(EntityPlayer player, ForgeDirection side) { return getCoverInfoAtSide(side).createWindow(player); } @@ -659,8 +665,9 @@ public void addCoverTabs(ModularWindow.Builder builder, UIBuildContext buildCont .setSpace(COVER_TAB_SPACING); for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) { - final byte side = (byte) direction.ordinal(); - buildContext.addSyncedWindow(side + COVER_WINDOW_ID_START, player -> createCoverWindow(player, side)); + buildContext.addSyncedWindow( + direction.ordinal() + COVER_WINDOW_ID_START, + player -> createCoverWindow(player, direction)); columnWidget.addChild(new MultiChildWidget().addChild(new ButtonWidget() { @Override @@ -668,7 +675,7 @@ public IDrawable[] getBackground() { final List backgrounds = new ArrayList<>(); final GUITextureSet tabIconSet = getGUITextureSet(); - if (getCoverBehaviorAtSideNew(side).hasCoverGUI()) { + if (getCoverBehaviorAtSideNew(direction).hasCoverGUI()) { if (isHovering()) { backgrounds.add( flipHorizontally ? tabIconSet.getCoverTabHighlightFlipped() @@ -685,20 +692,20 @@ public IDrawable[] getBackground() { } return backgrounds.toArray(new IDrawable[] {}); } - }.setOnClick((clickData, widget) -> onTabClicked(clickData, widget, side)) - .dynamicTooltip(() -> getCoverTabTooltip(side)) + }.setOnClick((clickData, widget) -> onTabClicked(clickData, widget, direction)) + .dynamicTooltip(() -> getCoverTabTooltip(direction)) .setSize(COVER_TAB_WIDTH, COVER_TAB_HEIGHT)) .addChild( - new ItemDrawable(() -> getCoverItemAtSide(side)).asWidget() + new ItemDrawable(() -> getCoverItemAtSide(direction)).asWidget() .setPos( (COVER_TAB_WIDTH - ICON_SIZE) / 2 + (flipHorizontally ? -1 : 1), (COVER_TAB_HEIGHT - ICON_SIZE) / 2)) - .setEnabled(widget -> getCoverItemAtSide(side) != null)); + .setEnabled(widget -> getCoverItemAtSide(direction) != null)); } } @SideOnly(Side.CLIENT) - protected List getCoverTabTooltip(byte side) { + protected List getCoverTabTooltip(ForgeDirection side) { final String[] SIDE_TOOLTIPS = new String[] { "GT5U.interface.coverTabs.down", "GT5U.interface.coverTabs.up", "GT5U.interface.coverTabs.north", "GT5U.interface.coverTabs.south", "GT5U.interface.coverTabs.west", "GT5U.interface.coverTabs.east" }; @@ -707,14 +714,13 @@ protected List getCoverTabTooltip(byte side) { if (coverItem == null) return Collections.emptyList(); final boolean coverHasGUI = coverInfo.hasCoverGUI(); - // noinspection unchecked final List tooltip = coverItem.getTooltip(Minecraft.getMinecraft().thePlayer, true); for (int i = 0; i < tooltip.size(); i++) { if (i == 0) { tooltip.set( 0, (coverHasGUI ? EnumChatFormatting.UNDERLINE : EnumChatFormatting.DARK_GRAY) - + StatCollector.translateToLocal(SIDE_TOOLTIPS[side]) + + StatCollector.translateToLocal(SIDE_TOOLTIPS[side.ordinal()]) + (coverHasGUI ? EnumChatFormatting.RESET + ": " : ": " + EnumChatFormatting.RESET) + tooltip.get(0)); } else { @@ -724,12 +730,12 @@ protected List getCoverTabTooltip(byte side) { return tooltip; } - protected void onTabClicked(Widget.ClickData clickData, Widget widget, byte side) { + protected void onTabClicked(Widget.ClickData ignoredClickData, Widget widget, ForgeDirection side) { if (isClientSide()) return; final CoverInfo coverInfo = getCoverInfoAtSide(side); if (coverInfo.useModularUI()) { widget.getContext() - .openSyncedWindow(side + COVER_WINDOW_ID_START); + .openSyncedWindow(side.ordinal() + COVER_WINDOW_ID_START); } else { final GT_Packet_TileEntityCoverGUI packet = new GT_Packet_TileEntityCoverGUI( coverInfo, diff --git a/src/main/java/gregtech/api/metatileentity/MetaPipeEntity.java b/src/main/java/gregtech/api/metatileentity/MetaPipeEntity.java index c8657fbcff2..2ecdd7f2ca5 100644 --- a/src/main/java/gregtech/api/metatileentity/MetaPipeEntity.java +++ b/src/main/java/gregtech/api/metatileentity/MetaPipeEntity.java @@ -6,6 +6,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Locale; +import java.util.Objects; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; @@ -33,13 +34,22 @@ import gregtech.api.GregTech_API; import gregtech.api.enums.Dyes; import gregtech.api.enums.GT_Values; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IConnectable; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IColoredTileEntity; import gregtech.api.interfaces.tileentity.ICoverable; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.objects.GT_ItemStack; -import gregtech.api.util.*; +import gregtech.api.util.GT_Config; +import gregtech.api.util.GT_CoverBehavior; +import gregtech.api.util.GT_CoverBehaviorBase; +import gregtech.api.util.GT_LanguageManager; +import gregtech.api.util.GT_Util; +import gregtech.api.util.GT_Utility; +import gregtech.api.util.ISerializableObject; +import gregtech.api.util.WorldSpawnedEventBuilder; import gregtech.common.GT_Client; import gregtech.common.covers.CoverInfo; @@ -114,7 +124,7 @@ protected final void addInfo(int aID) { if (!GT.isClientSide()) return; ItemStack tStack = new ItemStack(GregTech_API.sBlockMachines, 1, aID); - tStack.getItem() + Objects.requireNonNull(tStack.getItem()) .addInformation(tStack, null, new ArrayList<>(), true); } @@ -134,12 +144,23 @@ public MetaPipeEntity(String aName, int aInvSlotCount) { /** * For Pipe Rendering */ - public abstract boolean renderInside(byte aSide); + public abstract boolean renderInside(ForgeDirection side); public boolean isDisplaySecondaryDescription() { return false; } + @Override + public ITexture[] getTexture(IGregTechTileEntity baseMetaTileEntity, ForgeDirection side, ForgeDirection facing, + int colorIndex, boolean active, boolean redstoneLevel) { + return Textures.BlockIcons.ERROR_RENDERING; + } + + public ITexture[] getTexture(IGregTechTileEntity baseMetaTileEntity, ForgeDirection sideDirection, int connections, + int colorIndex, boolean active, boolean redstoneLevel) { + return Textures.BlockIcons.ERROR_RENDERING; + } + @Override public IGregTechTileEntity getBaseMetaTileEntity() { return mBaseMetaTileEntity; @@ -164,33 +185,33 @@ public ItemStack getStackForm(long aAmount) { } public boolean isCoverOnSide(BaseMetaPipeEntity aPipe, EntityLivingBase aEntity) { - byte aSide = 6; + ForgeDirection side = ForgeDirection.UNKNOWN; double difference = aEntity.posY - (double) aPipe.yCoord; if (difference > 0.6 && difference < 0.99) { - aSide = 1; + side = ForgeDirection.UP; } if (difference < -1.5 && difference > -1.99) { - aSide = 0; + side = ForgeDirection.DOWN; } difference = aEntity.posZ - (double) aPipe.zCoord; if (difference < -0.05 && difference > -0.4) { - aSide = 2; + side = ForgeDirection.NORTH; } if (difference > 1.05 && difference < 1.4) { - aSide = 3; + side = ForgeDirection.SOUTH; } difference = aEntity.posX - (double) aPipe.xCoord; if (difference < -0.05 && difference > -0.4) { - aSide = 4; + side = ForgeDirection.WEST; } if (difference > 1.05 && difference < 1.4) { - aSide = 5; + side = ForgeDirection.EAST; } boolean tCovered = false; - if (aSide < 6 && mBaseMetaTileEntity.getCoverIDAtSide(aSide) > 0) { + if (side != ForgeDirection.UNKNOWN && mBaseMetaTileEntity.getCoverIDAtSide(side) > 0) { tCovered = true; } - if (isConnectedAtSide(aSide)) { + if (isConnectedAtSide(side)) { tCovered = true; } // GT_FML_LOGGER.info("Cover: "+mBaseMetaTileEntity.getCoverIDAtSide(aSide)); @@ -230,30 +251,30 @@ public void registerIcons(IIconRegister aBlockIconRegister) { } @Override - public boolean allowCoverOnSide(byte aSide, GT_ItemStack aCoverID) { + public boolean allowCoverOnSide(ForgeDirection side, GT_ItemStack aCoverID) { return true; } @Override - public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + public void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { /* Do nothing */ } @Override - public boolean onWrenchRightClick(byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, - float aZ) { + public boolean onWrenchRightClick(ForgeDirection side, ForgeDirection wrenchingSide, EntityPlayer entityPlayer, + float aX, float aY, float aZ) { return false; } @Override - public boolean onWireCutterRightClick(byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, - float aZ) { + public boolean onWireCutterRightClick(ForgeDirection side, ForgeDirection wrenchingSide, EntityPlayer aPlayer, + float aX, float aY, float aZ) { return false; } @Override - public boolean onSolderingToolRightClick(byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, - float aZ) { + public boolean onSolderingToolRightClick(ForgeDirection side, ForgeDirection wrenchingSide, EntityPlayer aPlayer, + float aX, float aY, float aZ) { return false; } @@ -317,8 +338,8 @@ public void onCloseGUI() { * a Player rightclicks the Machine Sneaky rightclicks are not getting passed to this! */ @Override - public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, byte aSide, float aX, - float aY, float aZ) { + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, ForgeDirection side, + float aX, float aY, float aZ) { return false; } @@ -371,7 +392,7 @@ public final void sendLoopEnd(byte aIndex) { } @Override - public boolean isFacingValid(byte aFacing) { + public boolean isFacingValid(ForgeDirection facing) { return false; } @@ -402,12 +423,12 @@ public ArrayList getSpecialDebugInfo(IGregTechTileEntity aBaseMetaTileEn } @Override - public boolean isLiquidInput(byte aSide) { + public boolean isLiquidInput(ForgeDirection side) { return false; } @Override - public boolean isLiquidOutput(byte aSide) { + public boolean isLiquidOutput(ForgeDirection side) { return false; } @@ -487,17 +508,17 @@ public boolean isSimpleMachine() { } @Override - public byte getComparatorValue(byte aSide) { + public byte getComparatorValue(ForgeDirection side) { return 0; } @Override - public boolean acceptsRotationalEnergy(byte aSide) { + public boolean acceptsRotationalEnergy(ForgeDirection side) { return false; } @Override - public boolean injectRotationalEnergy(byte aSide, long aSpeed, long aEnergy) { + public boolean injectRotationalEnergy(ForgeDirection side, long aSpeed, long aEnergy) { return false; } @@ -538,8 +559,8 @@ public int getSizeInventory() { } @Override - public ItemStack getStackInSlot(int aIndex) { - if (aIndex >= 0 && aIndex < mInventory.length) return mInventory[aIndex]; + public ItemStack getStackInSlot(int slotIndex) { + if (slotIndex >= 0 && slotIndex < mInventory.length) return mInventory[slotIndex]; return null; } @@ -582,10 +603,10 @@ public ItemStack decrStackSize(int aIndex, int aAmount) { } @Override - public int[] getAccessibleSlotsFromSide(int aSide) { + public int[] getAccessibleSlotsFromSide(int ordinalSide) { final TIntList tList = new TIntArrayList(); final IGregTechTileEntity tTileEntity = getBaseMetaTileEntity(); - final CoverInfo tileCoverInfo = tTileEntity.getCoverInfoAtSide((byte) aSide); + final CoverInfo tileCoverInfo = tTileEntity.getCoverInfoAtSide(ForgeDirection.getOrientation(ordinalSide)); final boolean tSkip = tileCoverInfo.letsItemsIn(-2) || tileCoverInfo.letsItemsOut(-2); for (int i = 0; i < getSizeInventory(); i++) { if (isValidSlot(i) && (tSkip || tileCoverInfo.letsItemsOut(i) || tileCoverInfo.letsItemsIn(i))) { @@ -596,54 +617,58 @@ public int[] getAccessibleSlotsFromSide(int aSide) { } @Override - public boolean canInsertItem(int aIndex, ItemStack aStack, int aSide) { - return isValidSlot(aIndex) && aStack != null - && aIndex < mInventory.length - && (mInventory[aIndex] == null || GT_Utility.areStacksEqual(aStack, mInventory[aIndex])) - && allowPutStack(getBaseMetaTileEntity(), aIndex, (byte) aSide, aStack); + public boolean canInsertItem(int slotIndex, ItemStack itemStack, int ordinalSide) { + return isValidSlot(slotIndex) && itemStack != null + && slotIndex < mInventory.length + && (mInventory[slotIndex] == null || GT_Utility.areStacksEqual(itemStack, mInventory[slotIndex])) + && allowPutStack(getBaseMetaTileEntity(), slotIndex, ForgeDirection.getOrientation(ordinalSide), itemStack); } @Override - public boolean canExtractItem(int aIndex, ItemStack aStack, int aSide) { - return isValidSlot(aIndex) && aStack != null - && aIndex < mInventory.length - && allowPullStack(getBaseMetaTileEntity(), aIndex, (byte) aSide, aStack); + public boolean canExtractItem(int slotIndex, ItemStack itemStack, int ordinalSide) { + return isValidSlot(slotIndex) && itemStack != null + && slotIndex < mInventory.length + && allowPullStack( + getBaseMetaTileEntity(), + slotIndex, + ForgeDirection.getOrientation(ordinalSide), + itemStack); } @Override - public boolean canFill(ForgeDirection aSide, Fluid aFluid) { - return fill(aSide, new FluidStack(aFluid, 1), false) == 1; + public boolean canFill(ForgeDirection side, Fluid aFluid) { + return fill(side, new FluidStack(aFluid, 1), false) == 1; } @Override - public boolean canDrain(ForgeDirection aSide, Fluid aFluid) { - return drain(aSide, new FluidStack(aFluid, 1), false) != null; + public boolean canDrain(ForgeDirection side, Fluid aFluid) { + return drain(side, new FluidStack(aFluid, 1), false) != null; } @Override - public FluidTankInfo[] getTankInfo(ForgeDirection aSide) { + public FluidTankInfo[] getTankInfo(ForgeDirection side) { if (getCapacity() <= 0 && !getBaseMetaTileEntity().hasSteamEngineUpgrade()) return new FluidTankInfo[] {}; return new FluidTankInfo[] { getInfo() }; } - public int fill_default(ForgeDirection aSide, FluidStack aFluid, boolean doFill) { + public int fill_default(ForgeDirection side, FluidStack aFluid, boolean doFill) { return fill(aFluid, doFill); } @Override - public int fill(ForgeDirection aSide, FluidStack aFluid, boolean doFill) { - return fill_default(aSide, aFluid, doFill); + public int fill(ForgeDirection side, FluidStack aFluid, boolean doFill) { + return fill_default(side, aFluid, doFill); } @Override - public FluidStack drain(ForgeDirection aSide, FluidStack aFluid, boolean doDrain) { + public FluidStack drain(ForgeDirection side, FluidStack aFluid, boolean doDrain) { if (getFluid() != null && aFluid != null && getFluid().isFluidEqual(aFluid)) return drain(aFluid.amount, doDrain); return null; } @Override - public FluidStack drain(ForgeDirection aSide, int maxDrain, boolean doDrain) { + public FluidStack drain(ForgeDirection side, int maxDrain, boolean doDrain) { return drain(maxDrain, doDrain); } @@ -678,7 +703,7 @@ public boolean isUseableByPlayer(EntityPlayer entityplayer) { } @Override - public boolean connectsToItemPipe(byte aSide) { + public boolean connectsToItemPipe(ForgeDirection side) { return false; } @@ -703,7 +728,7 @@ public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechT } @Override - public float getExplosionResistance(byte aSide) { + public float getExplosionResistance(ForgeDirection side) { return 10.0F; } @@ -736,7 +761,7 @@ public void setCheckConnections() { mCheckConnections = true; } - public long injectEnergyUnits(byte aSide, long aVoltage, long aAmperage) { + public long injectEnergyUnits(ForgeDirection side, long aVoltage, long aAmperage) { return 0; } @@ -822,7 +847,7 @@ private boolean connectableColor(TileEntity tTileEntity) { if (tTileEntity instanceof IColoredTileEntity) { if (getBaseMetaTileEntity().getColorization() >= 0) { final byte tColor = ((IColoredTileEntity) tTileEntity).getColorization(); - if (tColor >= 0 && tColor != getBaseMetaTileEntity().getColorization()) return false; + return tColor < 0 || tColor == getBaseMetaTileEntity().getColorization(); } } @@ -830,21 +855,21 @@ private boolean connectableColor(TileEntity tTileEntity) { } @Override - public int connect(byte aSide) { - if (aSide >= 6) return 0; + public int connect(ForgeDirection side) { + if (side == ForgeDirection.UNKNOWN) return 0; - final byte tSide = GT_Utility.getOppositeSide(aSide); + final ForgeDirection oppositeSide = side.getOpposite(); final IGregTechTileEntity baseMetaTile = getBaseMetaTileEntity(); if (baseMetaTile == null || !baseMetaTile.isServerSide()) return 0; - final CoverInfo coverInfo = baseMetaTile.getCoverInfoAtSide(aSide); + final CoverInfo coverInfo = baseMetaTile.getCoverInfoAtSide(side); final boolean alwaysLookConnected = coverInfo.alwaysLookConnected(); final boolean letsIn = letsIn(coverInfo); final boolean letsOut = letsOut(coverInfo); // Careful - tTileEntity might be null, and that's ok -- so handle it - final TileEntity tTileEntity = baseMetaTile.getTileEntityAtSide(aSide); + final TileEntity tTileEntity = baseMetaTile.getTileEntityAtSide(side); if (!connectableColor(tTileEntity)) return 0; if ((alwaysLookConnected || letsIn || letsOut)) { @@ -854,23 +879,21 @@ public int connect(byte aSide) { : null; if (getClass().isInstance(tPipe) || (tPipe != null && tPipe.getClass() .isInstance(this))) { - connectAtSide(aSide); - if (!((MetaPipeEntity) tPipe).isConnectedAtSide(tSide)) { + connectAtSide(side); + if (!((IConnectable) tPipe).isConnectedAtSide(oppositeSide)) { // Make sure pipes all get together -- connect back to us if we're connecting to a pipe - ((MetaPipeEntity) tPipe).connect(tSide); + ((IConnectable) tPipe).connect(oppositeSide); } return 1; - } else - if ((getGT6StyleConnection() && baseMetaTile.getAirAtSide(aSide)) || canConnect(aSide, tTileEntity)) { - // Allow open connections to Air, if the GT6 style pipe/cables are enabled, so that it'll connect to - // the - // next block placed down next to it - connectAtSide(aSide); - return 1; - } + } else if ((getGT6StyleConnection() && baseMetaTile.getAirAtSide(side)) || canConnect(side, tTileEntity)) { + // Allow open connections to Air, if the GT6 style pipe/cables are enabled, so that it'll connect to + // the next block placed down next to it + connectAtSide(side); + return 1; + } if (!baseMetaTile.getWorld() .getChunkProvider() - .chunkExists(baseMetaTile.getOffsetX(aSide, 1) >> 4, baseMetaTile.getOffsetZ(aSide, 1) >> 4)) { + .chunkExists(baseMetaTile.getOffsetX(side, 1) >> 4, baseMetaTile.getOffsetZ(side, 1) >> 4)) { // Target chunk unloaded return -1; } @@ -881,38 +904,40 @@ public int connect(byte aSide) { protected void checkConnections() { // Verify connections around us. If GT6 style cables are not enabled then revert to old behavior and try // connecting to everything around us - for (byte aSide = 0; aSide < 6; aSide++) { - if ((!getGT6StyleConnection() || isConnectedAtSide(aSide)) && connect(aSide) == 0) { - disconnect(aSide); + for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + if ((!getGT6StyleConnection() || isConnectedAtSide(side)) && connect(side) == 0) { + disconnect(side); } } mCheckConnections = false; } - private void connectAtSide(byte aSide) { - mConnections |= (1 << aSide); + private void connectAtSide(ForgeDirection side) { + mConnections |= (1 << side.ordinal()); } @Override - public void disconnect(byte aSide) { - if (aSide >= 6) return; - mConnections &= ~(1 << aSide); - byte tSide = GT_Utility.getOppositeSide(aSide); - IGregTechTileEntity tTileEntity = getBaseMetaTileEntity().getIGregTechTileEntityAtSide(aSide); + public void disconnect(ForgeDirection side) { + if (side == ForgeDirection.UNKNOWN) return; + mConnections &= ~(1 << side.ordinal()); + final ForgeDirection oppositeSide = side.getOpposite(); + IGregTechTileEntity tTileEntity = getBaseMetaTileEntity().getIGregTechTileEntityAtSide(side); IMetaTileEntity tPipe = tTileEntity == null ? null : tTileEntity.getMetaTileEntity(); if ((this.getClass() .isInstance(tPipe) || (tPipe != null && tPipe.getClass() .isInstance(this))) - && ((MetaPipeEntity) tPipe).isConnectedAtSide(tSide)) ((MetaPipeEntity) tPipe).disconnect(tSide); + && ((IConnectable) tPipe).isConnectedAtSide(oppositeSide)) { + ((IConnectable) tPipe).disconnect(oppositeSide); + } } @Override - public boolean isConnectedAtSide(int aSide) { - return (mConnections & (1 << aSide)) != 0; + public boolean isConnectedAtSide(ForgeDirection sideDirection) { + return (mConnections & (1 << sideDirection.ordinal())) != 0; } - public boolean letsIn(GT_CoverBehavior coverBehavior, byte aSide, int aCoverID, int aCoverVariable, + public boolean letsIn(GT_CoverBehavior coverBehavior, ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return false; } @@ -921,7 +946,7 @@ public boolean letsIn(CoverInfo coverInfo) { return false; } - public boolean letsOut(GT_CoverBehavior coverBehavior, byte aSide, int aCoverID, int aCoverVariable, + public boolean letsOut(GT_CoverBehavior coverBehavior, ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return false; } @@ -930,17 +955,17 @@ public boolean letsOut(CoverInfo coverInfo) { return false; } - public boolean letsIn(GT_CoverBehaviorBase coverBehavior, byte aSide, int aCoverID, + public boolean letsIn(GT_CoverBehaviorBase coverBehavior, ForgeDirection side, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) { return false; } - public boolean letsOut(GT_CoverBehaviorBase coverBehavior, byte aSide, int aCoverID, + public boolean letsOut(GT_CoverBehaviorBase coverBehavior, ForgeDirection side, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) { return false; } - public boolean canConnect(byte aSide, TileEntity tTileEntity) { + public boolean canConnect(ForgeDirection side, TileEntity tTileEntity) { return false; } diff --git a/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java index 3acbb2ce2d3..f6cba8a8493 100644 --- a/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java @@ -217,51 +217,51 @@ public void registerIcons(IIconRegister aBlockIconRegister) { } @Override - public boolean allowCoverOnSide(byte aSide, GT_ItemStack aStack) { + public boolean allowCoverOnSide(ForgeDirection side, GT_ItemStack aStack) { return true; } @Override - public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + public void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { /* Do nothing */ } @Override - public boolean onWrenchRightClick(byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, - float aZ) { - if (getBaseMetaTileEntity().isValidFacing(aWrenchingSide)) { - getBaseMetaTileEntity().setFrontFacing(aWrenchingSide); + public boolean onWrenchRightClick(ForgeDirection side, ForgeDirection wrenchingSide, EntityPlayer entityPlayer, + float aX, float aY, float aZ) { + if (getBaseMetaTileEntity().isValidFacing(wrenchingSide)) { + getBaseMetaTileEntity().setFrontFacing(wrenchingSide); return true; } return false; } @Override - public boolean onWireCutterRightClick(byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, - float aZ) { + public boolean onWireCutterRightClick(ForgeDirection side, ForgeDirection wrenchingSide, EntityPlayer aPlayer, + float aX, float aY, float aZ) { if (!aPlayer.isSneaking()) return false; - byte tSide = GT_Utility.getOppositeSide(aWrenchingSide); - TileEntity tTileEntity = getBaseMetaTileEntity().getTileEntityAtSide(aWrenchingSide); - if ((tTileEntity instanceof IGregTechTileEntity) - && (((IGregTechTileEntity) tTileEntity).getMetaTileEntity() instanceof GT_MetaPipeEntity_Cable)) { + final ForgeDirection oppositeSide = wrenchingSide.getOpposite(); + final TileEntity tTileEntity = getBaseMetaTileEntity().getTileEntityAtSide(wrenchingSide); + if ((tTileEntity instanceof IGregTechTileEntity gtTE) + && (gtTE.getMetaTileEntity() instanceof GT_MetaPipeEntity_Cable)) { // The tile entity we're facing is a cable, let's try to connect to it - return ((IGregTechTileEntity) tTileEntity).getMetaTileEntity() - .onWireCutterRightClick(aWrenchingSide, tSide, aPlayer, aX, aY, aZ); + return gtTE.getMetaTileEntity() + .onWireCutterRightClick(wrenchingSide, oppositeSide, aPlayer, aX, aY, aZ); } return false; } @Override - public boolean onSolderingToolRightClick(byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, - float aZ) { + public boolean onSolderingToolRightClick(ForgeDirection side, ForgeDirection wrenchingSide, EntityPlayer aPlayer, + float aX, float aY, float aZ) { if (!aPlayer.isSneaking()) return false; - byte tSide = GT_Utility.getOppositeSide(aWrenchingSide); - TileEntity tTileEntity = getBaseMetaTileEntity().getTileEntityAtSide(aWrenchingSide); - if ((tTileEntity instanceof IGregTechTileEntity) - && (((IGregTechTileEntity) tTileEntity).getMetaTileEntity() instanceof GT_MetaPipeEntity_Cable)) { + final ForgeDirection oppositeSide = wrenchingSide.getOpposite(); + TileEntity tTileEntity = getBaseMetaTileEntity().getTileEntityAtSide(wrenchingSide); + if ((tTileEntity instanceof IGregTechTileEntity gtTE) + && (gtTE.getMetaTileEntity() instanceof GT_MetaPipeEntity_Cable)) { // The tile entity we're facing is a cable, let's try to connect to it - return ((IGregTechTileEntity) tTileEntity).getMetaTileEntity() - .onSolderingToolRightClick(aWrenchingSide, tSide, aPlayer, aX, aY, aZ); + return gtTE.getMetaTileEntity() + .onSolderingToolRightClick(wrenchingSide, oppositeSide, aPlayer, aX, aY, aZ); } return false; } @@ -342,8 +342,8 @@ public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlaye } @Override - public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, byte aSide, float aX, - float aY, float aZ) { + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, ForgeDirection side, + float aX, float aY, float aZ) { return onRightclick(aBaseMetaTileEntity, aPlayer); } @@ -492,14 +492,14 @@ public long maxAmperesIn() { /** * @return true if that Side is an Output. */ - public boolean isOutputFacing(byte aSide) { + public boolean isOutputFacing(ForgeDirection side) { return false; } /** * @return true if that Side is an Input. */ - public boolean isInputFacing(byte aSide) { + public boolean isInputFacing(ForgeDirection side) { return false; } @@ -511,7 +511,7 @@ public boolean isTransformingLowEnergy() { } @Override - public boolean isFacingValid(byte aFacing) { + public boolean isFacingValid(ForgeDirection facing) { return false; } @@ -640,12 +640,12 @@ public ArrayList getSpecialDebugInfo(IGregTechTileEntity aBaseMetaTileEn } @Override - public boolean isLiquidInput(byte aSide) { + public boolean isLiquidInput(ForgeDirection side) { return true; } @Override - public boolean isLiquidOutput(byte aSide) { + public boolean isLiquidOutput(ForgeDirection side) { return true; } @@ -774,17 +774,17 @@ public boolean willExplodeInRain() { * Gets the Output for the comparator on the given Side */ @Override - public byte getComparatorValue(byte aSide) { + public byte getComparatorValue(ForgeDirection side) { return 0; } @Override - public boolean acceptsRotationalEnergy(byte aSide) { + public boolean acceptsRotationalEnergy(ForgeDirection side) { return false; } @Override - public boolean injectRotationalEnergy(byte aSide, long aSpeed, long aEnergy) { + public boolean injectRotationalEnergy(ForgeDirection side, long aSpeed, long aEnergy) { return false; } @@ -879,10 +879,10 @@ public ItemStack decrStackSize(int aIndex, int aAmount) { } @Override - public int[] getAccessibleSlotsFromSide(int aSide) { + public int[] getAccessibleSlotsFromSide(int ordinalSide) { final TIntList tList = new TIntArrayList(); final IGregTechTileEntity tTileEntity = getBaseMetaTileEntity(); - final CoverInfo tileCoverInfo = tTileEntity.getCoverInfoAtSide((byte) aSide); + final CoverInfo tileCoverInfo = tTileEntity.getCoverInfoAtSide(ForgeDirection.getOrientation(ordinalSide)); final boolean tSkip = tileCoverInfo.letsItemsIn(-2) || tileCoverInfo.letsItemsOut(-2); for (int i = 0; i < getSizeInventory(); i++) { if (isValidSlot(i) && (tSkip || tileCoverInfo.letsItemsOut(i) || tileCoverInfo.letsItemsIn(i))) { @@ -893,43 +893,43 @@ public int[] getAccessibleSlotsFromSide(int aSide) { } @Override - public boolean canInsertItem(int aIndex, ItemStack aStack, int aSide) { + public boolean canInsertItem(int aIndex, ItemStack aStack, int ordinalSide) { return isValidSlot(aIndex) && aStack != null && aIndex < mInventory.length && (mInventory[aIndex] == null || GT_Utility.areStacksEqual(aStack, mInventory[aIndex])) - && allowPutStack(getBaseMetaTileEntity(), aIndex, (byte) aSide, aStack); + && allowPutStack(getBaseMetaTileEntity(), aIndex, ForgeDirection.getOrientation(ordinalSide), aStack); } @Override - public boolean canExtractItem(int aIndex, ItemStack aStack, int aSide) { + public boolean canExtractItem(int aIndex, ItemStack aStack, int ordinalSide) { return isValidSlot(aIndex) && aStack != null && aIndex < mInventory.length - && allowPullStack(getBaseMetaTileEntity(), aIndex, (byte) aSide, aStack); + && allowPullStack(getBaseMetaTileEntity(), aIndex, ForgeDirection.getOrientation(ordinalSide), aStack); } @Override - public boolean canFill(ForgeDirection aSide, Fluid aFluid) { - return fill(aSide, new FluidStack(aFluid, 1), false) == 1; + public boolean canFill(ForgeDirection side, Fluid aFluid) { + return fill(side, new FluidStack(aFluid, 1), false) == 1; } @Override - public boolean canDrain(ForgeDirection aSide, Fluid aFluid) { - return drain(aSide, new FluidStack(aFluid, 1), false) != null; + public boolean canDrain(ForgeDirection side, Fluid aFluid) { + return drain(side, new FluidStack(aFluid, 1), false) != null; } @Override - public FluidTankInfo[] getTankInfo(ForgeDirection aSide) { + public FluidTankInfo[] getTankInfo(ForgeDirection side) { if (getCapacity() <= 0 && !getBaseMetaTileEntity().hasSteamEngineUpgrade()) return new FluidTankInfo[] {}; return new FluidTankInfo[] { getInfo() }; } - public int fill_default(ForgeDirection aSide, FluidStack aFluid, boolean doFill) { + public int fill_default(ForgeDirection side, FluidStack aFluid, boolean doFill) { markDirty(); return fill(aFluid, doFill); } @Override - public int fill(ForgeDirection aSide, FluidStack aFluid, boolean doFill) { + public int fill(ForgeDirection side, FluidStack aFluid, boolean doFill) { if (getBaseMetaTileEntity().hasSteamEngineUpgrade() && GT_ModHandler.isSteam(aFluid) && aFluid.amount > 1) { int tSteam = (int) Math.min( Integer.MAX_VALUE, @@ -942,20 +942,20 @@ public int fill(ForgeDirection aSide, FluidStack aFluid, boolean doFill) { return tSteam * 2; } } else { - return fill_default(aSide, aFluid, doFill); + return fill_default(side, aFluid, doFill); } return 0; } @Override - public FluidStack drain(ForgeDirection aSide, FluidStack aFluid, boolean doDrain) { + public FluidStack drain(ForgeDirection side, FluidStack aFluid, boolean doDrain) { if (getFluid() != null && aFluid != null && getFluid().isFluidEqual(aFluid)) return drain(aFluid.amount, doDrain); return null; } @Override - public FluidStack drain(ForgeDirection aSide, int maxDrain, boolean doDrain) { + public FluidStack drain(ForgeDirection side, int maxDrain, boolean doDrain) { return drain(maxDrain, doDrain); } @@ -1030,12 +1030,12 @@ public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechT } @Override - public boolean connectsToItemPipe(byte aSide) { + public boolean connectsToItemPipe(ForgeDirection side) { return false; } @Override - public float getExplosionResistance(byte aSide) { + public float getExplosionResistance(ForgeDirection side) { return 10.0F; } @@ -1048,11 +1048,11 @@ public ItemStack[] getRealInventory() { public void onColorChangeServer(byte aColor) { final IGregTechTileEntity meta = getBaseMetaTileEntity(); final int aX = meta.getXCoord(), aY = meta.getYCoord(), aZ = meta.getZCoord(); - for (byte aSide = 0; aSide < 6; aSide++) { + for (final ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { // Flag surrounding pipes/cables to revaluate their connection with us if we got painted - final TileEntity tTileEntity = meta.getTileEntityAtSide(aSide); - if ((tTileEntity instanceof BaseMetaPipeEntity)) { - ((BaseMetaPipeEntity) tTileEntity).onNeighborBlockChange(aX, aY, aZ); + final TileEntity tTileEntity = meta.getTileEntityAtSide(side); + if (tTileEntity instanceof BaseMetaPipeEntity pipe) { + pipe.onNeighborBlockChange(aX, aY, aZ); } } } @@ -1163,12 +1163,12 @@ public void getWailaBody(ItemStack itemStack, List currenttip, IWailaDat currenttip.add( String.format( "Facing: %s", - ForgeDirection.getOrientation(mBaseMetaTileEntity.getFrontFacing()) + mBaseMetaTileEntity.getFrontFacing() .name())); if (this instanceof IPowerChannelState state) { // adapted from PowerStateWailaDataProvider - NBTTagCompound tag = accessor.getNBTData(); + final NBTTagCompound tag = accessor.getNBTData(); final boolean isActive = tag.getBoolean("isActive"); final boolean isPowered = tag.getBoolean("isPowered"); final boolean isBooting = tag.getBoolean("isBooting"); diff --git a/src/main/java/gregtech/api/metatileentity/TileIC2EnergySink.java b/src/main/java/gregtech/api/metatileentity/TileIC2EnergySink.java index da86635fea8..91b6d5a117d 100644 --- a/src/main/java/gregtech/api/metatileentity/TileIC2EnergySink.java +++ b/src/main/java/gregtech/api/metatileentity/TileIC2EnergySink.java @@ -59,7 +59,7 @@ public double getDemandedEnergy() { /** * Determine the tier of this energy sink. 1 = LV, 2 = MV, 3 = HV, 4 = EV etc. - * + * * @note Return Integer.MAX_VALUE to allow any voltage. * * @return tier of this energy sink @@ -92,13 +92,12 @@ public double injectEnergy(ForgeDirection directionFrom, double amount, double v final long usedAmps; if (cableMeta != null) { usedAmps = ((IMetaTileEntityCable) metaTile).transferElectricity( - (byte) directionFrom.ordinal(), + directionFrom, Math.min(euPerAmp, cableMeta.mVoltage), amps, Sets.newHashSet((TileEntity) myMeta)); - } else usedAmps = myMeta - .injectEnergyUnits((byte) directionFrom.ordinal(), Math.min(euPerAmp, myMeta.getInputVoltage()), amps); + } else usedAmps = myMeta.injectEnergyUnits(directionFrom, Math.min(euPerAmp, myMeta.getInputVoltage()), amps); return amount - (usedAmps * euPerAmp); // transferElectricity for cables @@ -116,8 +115,9 @@ public double injectEnergy(ForgeDirection directionFrom, double amount, double v @Override public boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction) { final IMetaTileEntity metaTile = myMeta.getMetaTileEntity(); - if (metaTile instanceof IMetaTileEntityCable && (direction == ForgeDirection.UNKNOWN - || ((IConnectable) metaTile).isConnectedAtSide(direction.ordinal()))) return true; - else return myMeta.inputEnergyFrom((byte) direction.ordinal(), false); + if (metaTile instanceof IMetaTileEntityCable + && (direction == ForgeDirection.UNKNOWN || ((IConnectable) metaTile).isConnectedAtSide(direction))) + return true; + else return myMeta.inputEnergyFrom(direction, false); } } diff --git a/src/main/java/gregtech/api/metatileentity/examples/GT_MetaTileEntity_E_Furnace.java b/src/main/java/gregtech/api/metatileentity/examples/GT_MetaTileEntity_E_Furnace.java index 83cebbb08df..83c61744382 100644 --- a/src/main/java/gregtech/api/metatileentity/examples/GT_MetaTileEntity_E_Furnace.java +++ b/src/main/java/gregtech/api/metatileentity/examples/GT_MetaTileEntity_E_Furnace.java @@ -3,6 +3,7 @@ import static gregtech.api.enums.Textures.BlockIcons.*; import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; import gregtech.api.enums.SoundResource; import gregtech.api.interfaces.ITexture; @@ -107,9 +108,9 @@ public int checkRecipe() { } @Override - protected boolean allowPutStackValidated(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, + protected boolean allowPutStackValidated(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, ItemStack aStack) { - return super.allowPutStackValidated(aBaseMetaTileEntity, aIndex, aSide, aStack) + return super.allowPutStackValidated(aBaseMetaTileEntity, aIndex, side, aStack) && GT_ModHandler.getSmeltingOutput(GT_Utility.copyAmount(64, aStack), false, null) != null; } 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 122a5f51281..699b0d57973 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 @@ -1,7 +1,7 @@ package gregtech.api.metatileentity.implementations; -import static gregtech.api.enums.GT_Values.ALL_VALID_SIDES; import static gregtech.api.enums.Mods.GalacticraftCore; +import static net.minecraftforge.common.util.ForgeDirection.DOWN; import java.util.ArrayList; import java.util.HashSet; @@ -111,54 +111,52 @@ public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { } @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aConnections, - byte aColorIndex, boolean aConnected, boolean aRedstone) { - if (!mInsulated) return new ITexture[] { TextureFactory.of( - mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], - Dyes.getModulation(aColorIndex, mMaterial.mRGBa)) }; - if (aConnected) { + public ITexture[] getTexture(IGregTechTileEntity baseMetaTileEntity, ForgeDirection sideDirection, + int facingDirection, int colorIndex, boolean active, boolean redstoneLevel) { + if (!mInsulated) return new ITexture[] { TextureFactory + .of(mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], Dyes.getModulation(colorIndex, mMaterial.mRGBa)) }; + if (active) { float tThickNess = getThickNess(); - if (tThickNess < 0.124F) return new ITexture[] { TextureFactory.of( - Textures.BlockIcons.INSULATION_FULL, - Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa)) }; + if (tThickNess < 0.124F) return new ITexture[] { TextureFactory + .of(Textures.BlockIcons.INSULATION_FULL, Dyes.getModulation(colorIndex, Dyes.CABLE_INSULATION.mRGBa)) }; if (tThickNess < 0.374F) // 0.375 x1 return new ITexture[] { TextureFactory.of(mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], mMaterial.mRGBa), TextureFactory.of( Textures.BlockIcons.INSULATION_TINY, - Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa)) }; + Dyes.getModulation(colorIndex, Dyes.CABLE_INSULATION.mRGBa)) }; if (tThickNess < 0.499F) // 0.500 x2 return new ITexture[] { TextureFactory.of(mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], mMaterial.mRGBa), TextureFactory.of( Textures.BlockIcons.INSULATION_SMALL, - Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa)) }; + Dyes.getModulation(colorIndex, Dyes.CABLE_INSULATION.mRGBa)) }; if (tThickNess < 0.624F) // 0.625 x4 return new ITexture[] { TextureFactory.of(mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], mMaterial.mRGBa), TextureFactory.of( Textures.BlockIcons.INSULATION_MEDIUM, - Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa)) }; + Dyes.getModulation(colorIndex, Dyes.CABLE_INSULATION.mRGBa)) }; if (tThickNess < 0.749F) // 0.750 x8 return new ITexture[] { TextureFactory.of(mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], mMaterial.mRGBa), TextureFactory.of( Textures.BlockIcons.INSULATION_MEDIUM_PLUS, - Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa)) }; + Dyes.getModulation(colorIndex, Dyes.CABLE_INSULATION.mRGBa)) }; if (tThickNess < 0.874F) // 0.825 x12 return new ITexture[] { TextureFactory.of(mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], mMaterial.mRGBa), TextureFactory.of( Textures.BlockIcons.INSULATION_LARGE, - Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa)) }; + Dyes.getModulation(colorIndex, Dyes.CABLE_INSULATION.mRGBa)) }; return new ITexture[] { TextureFactory.of(mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], mMaterial.mRGBa), TextureFactory.of( Textures.BlockIcons.INSULATION_HUGE, - Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa)) }; + Dyes.getModulation(colorIndex, Dyes.CABLE_INSULATION.mRGBa)) }; } return new ITexture[] { TextureFactory - .of(Textures.BlockIcons.INSULATION_FULL, Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa)) }; + .of(Textures.BlockIcons.INSULATION_FULL, Dyes.getModulation(colorIndex, Dyes.CABLE_INSULATION.mRGBa)) }; } @Override @@ -178,7 +176,7 @@ public boolean isSimpleMachine() { } @Override - public boolean isFacingValid(byte aFacing) { + public boolean isFacingValid(ForgeDirection facing) { return false; } @@ -188,7 +186,7 @@ public boolean isValidSlot(int aIndex) { } @Override - public final boolean renderInside(byte aSide) { + public final boolean renderInside(ForgeDirection side) { return false; } @@ -203,42 +201,40 @@ public int maxProgresstime() { } @Override - public long injectEnergyUnits(byte aSide, long aVoltage, long aAmperage) { - if (!isConnectedAtSide(aSide) && aSide != 6) return 0; - if (!getBaseMetaTileEntity().getCoverInfoAtSide(aSide) + public long injectEnergyUnits(ForgeDirection side, long voltage, long amperage) { + if (!isConnectedAtSide(side) && side != ForgeDirection.UNKNOWN) return 0; + if (!getBaseMetaTileEntity().getCoverInfoAtSide(side) .letsEnergyIn()) return 0; - final HashSet nul = null; - return transferElectricity(aSide, aVoltage, aAmperage, nul); + return transferElectricity(side, voltage, amperage, (HashSet) null); } @Override @Deprecated - public long transferElectricity(byte aSide, long aVoltage, long aAmperage, + public long transferElectricity(ForgeDirection side, long aVoltage, long aAmperage, ArrayList aAlreadyPassedTileEntityList) { - return transferElectricity(aSide, aVoltage, aAmperage, new HashSet<>(aAlreadyPassedTileEntityList)); + return transferElectricity(side, aVoltage, aAmperage, new HashSet<>(aAlreadyPassedTileEntityList)); } @Override - public long transferElectricity(byte aSide, long aVoltage, long aAmperage, HashSet aAlreadyPassedSet) { - if (!getBaseMetaTileEntity().isServerSide() || !isConnectedAtSide(aSide) && aSide != 6) return 0; + public long transferElectricity(ForgeDirection side, long voltage, long amperage, + HashSet alreadyPassedSet) { + if (!getBaseMetaTileEntity().isServerSide() || !isConnectedAtSide(side) && side != ForgeDirection.UNKNOWN) + return 0; final BaseMetaPipeEntity tBase = (BaseMetaPipeEntity) getBaseMetaTileEntity(); if (!(tBase.getNode() instanceof PowerNode tNode)) return 0; - if (tNode != null) { - int tPlace = 0; - final Node[] tToPower = new Node[tNode.mConsumers.size()]; - if (tNode.mHadVoltage) { - for (ConsumerNode consumer : tNode.mConsumers) { - if (consumer.needsEnergy()) tToPower[tPlace++] = consumer; - } - } else { - tNode.mHadVoltage = true; - for (ConsumerNode consumer : tNode.mConsumers) { - tToPower[tPlace++] = consumer; - } + int tPlace = 0; + final Node[] tToPower = new Node[tNode.mConsumers.size()]; + if (tNode.mHadVoltage) { + for (ConsumerNode consumer : tNode.mConsumers) { + if (consumer.needsEnergy()) tToPower[tPlace++] = consumer; + } + } else { + tNode.mHadVoltage = true; + for (ConsumerNode consumer : tNode.mConsumers) { + tToPower[tPlace++] = consumer; } - return PowerNodes.powerNode(tNode, null, new NodeList(tToPower), (int) aVoltage, (int) aAmperage); } - return 0; + return PowerNodes.powerNode(tNode, null, new NodeList(tToPower), (int) voltage, (int) amperage); } @Override @@ -262,15 +258,15 @@ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { } @Override - public boolean onWireCutterRightClick(byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, - float aZ) { + public boolean onWireCutterRightClick(ForgeDirection side, ForgeDirection wrenchingSide, EntityPlayer aPlayer, + float aX, float aY, float aZ) { if (GT_Mod.gregtechproxy.gt6Cable && GT_ModHandler.damageOrDechargeItem(aPlayer.inventory.getCurrentItem(), 1, 500, aPlayer)) { - if (isConnectedAtSide(aWrenchingSide)) { - disconnect(aWrenchingSide); + if (isConnectedAtSide(wrenchingSide)) { + disconnect(wrenchingSide); GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("215", "Disconnected")); } else if (!GT_Mod.gregtechproxy.costlyCableConnection) { - if (connect(aWrenchingSide) > 0) + if (connect(wrenchingSide) > 0) GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("214", "Connected")); } return true; @@ -279,15 +275,15 @@ public boolean onWireCutterRightClick(byte aSide, byte aWrenchingSide, EntityPla } @Override - public boolean onSolderingToolRightClick(byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, - float aZ) { + public boolean onSolderingToolRightClick(ForgeDirection side, ForgeDirection wrenchingSide, EntityPlayer aPlayer, + float aX, float aY, float aZ) { if (GT_Mod.gregtechproxy.gt6Cable && GT_ModHandler.damageOrDechargeItem(aPlayer.inventory.getCurrentItem(), 1, 500, aPlayer)) { - if (isConnectedAtSide(aWrenchingSide)) { - disconnect(aWrenchingSide); + if (isConnectedAtSide(wrenchingSide)) { + disconnect(wrenchingSide); GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("215", "Disconnected")); } else if (!GT_Mod.gregtechproxy.costlyCableConnection || GT_ModHandler.consumeSolderingMaterial(aPlayer)) { - if (connect(aWrenchingSide) > 0) + if (connect(wrenchingSide) > 0) GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("214", "Connected")); } return true; @@ -296,27 +292,27 @@ public boolean onSolderingToolRightClick(byte aSide, byte aWrenchingSide, Entity } @Override - public boolean letsIn(GT_CoverBehavior coverBehavior, byte aSide, int aCoverID, int aCoverVariable, + public boolean letsIn(GT_CoverBehavior coverBehavior, ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { - return coverBehavior.letsEnergyIn(aSide, aCoverID, aCoverVariable, aTileEntity); + return coverBehavior.letsEnergyIn(side, aCoverID, aCoverVariable, aTileEntity); } @Override - public boolean letsOut(GT_CoverBehavior coverBehavior, byte aSide, int aCoverID, int aCoverVariable, + public boolean letsOut(GT_CoverBehavior coverBehavior, ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { - return coverBehavior.letsEnergyOut(aSide, aCoverID, aCoverVariable, aTileEntity); + return coverBehavior.letsEnergyOut(side, aCoverID, aCoverVariable, aTileEntity); } @Override - public boolean letsIn(GT_CoverBehaviorBase coverBehavior, byte aSide, int aCoverID, + public boolean letsIn(GT_CoverBehaviorBase coverBehavior, ForgeDirection side, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) { - return coverBehavior.letsEnergyIn(aSide, aCoverID, aCoverVariable, aTileEntity); + return coverBehavior.letsEnergyIn(side, aCoverID, aCoverVariable, aTileEntity); } @Override - public boolean letsOut(GT_CoverBehaviorBase coverBehavior, byte aSide, int aCoverID, + public boolean letsOut(GT_CoverBehaviorBase coverBehavior, ForgeDirection side, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) { - return coverBehavior.letsEnergyOut(aSide, aCoverID, aCoverVariable, aTileEntity); + return coverBehavior.letsEnergyOut(side, aCoverID, aCoverVariable, aTileEntity); } @Override @@ -330,18 +326,16 @@ public boolean letsOut(CoverInfo coverInfo) { } @Override - public boolean canConnect(byte aSide, TileEntity tTileEntity) { + public boolean canConnect(ForgeDirection side, TileEntity tileEntity) { final IGregTechTileEntity baseMetaTile = getBaseMetaTileEntity(); - final GT_CoverBehaviorBase coverBehavior = baseMetaTile.getCoverBehaviorAtSideNew(aSide); - final byte tSide = GT_Utility.getOppositeSide(aSide); - final ForgeDirection tDir = ForgeDirection.getOrientation(tSide); + final GT_CoverBehaviorBase coverBehavior = baseMetaTile.getCoverBehaviorAtSideNew(side); + final ForgeDirection oppositeSide = side.getOpposite(); // GT Machine handling - if ((tTileEntity instanceof PowerLogicHost - && ((PowerLogicHost) tTileEntity).getPowerLogic(ForgeDirection.getOrientation(aSide)) != null) - || ((tTileEntity instanceof IEnergyConnected) - && (((IEnergyConnected) tTileEntity).inputEnergyFrom(tSide, false) - || ((IEnergyConnected) tTileEntity).outputsEnergyTo(tSide, false)))) + if ((tileEntity instanceof PowerLogicHost powerLogic && powerLogic.getPowerLogic(side) != null) + || ((tileEntity instanceof IEnergyConnected energyConnected) + && (energyConnected.inputEnergyFrom(oppositeSide, false) + || energyConnected.outputsEnergyTo(oppositeSide, false)))) return true; // Solar Panel Compat @@ -349,47 +343,43 @@ public boolean canConnect(byte aSide, TileEntity tTileEntity) { // ((tIsGregTechTileEntity && tIsTileEntityCable) && (tAlwaysLookConnected || tLetEnergyIn || tLetEnergyOut) ) // --> Not needed - if (GalacticraftCore.isModLoaded() && GT_GC_Compat.canConnect(tTileEntity, tDir)) return true; + if (GalacticraftCore.isModLoaded() && GT_GC_Compat.canConnect(tileEntity, oppositeSide)) return true; // AE2-p2p Compat if (GT_Mod.gregtechproxy.mAE2Integration) { - if (tTileEntity instanceof appeng.tile.powersink.IC2 - && ((appeng.tile.powersink.IC2) tTileEntity).acceptsEnergyFrom((TileEntity) baseMetaTile, tDir)) - return true; + if (tileEntity instanceof appeng.tile.powersink.IC2 ic2sink + && ic2sink.acceptsEnergyFrom((TileEntity) baseMetaTile, oppositeSide)) return true; } // IC2 Compat { final TileEntity ic2Energy; - if (tTileEntity instanceof IReactorChamber) - ic2Energy = (TileEntity) ((IReactorChamber) tTileEntity).getReactor(); - else ic2Energy = (tTileEntity == null || tTileEntity instanceof IEnergyTile || EnergyNet.instance == null) - ? tTileEntity - : EnergyNet.instance.getTileEntity( - tTileEntity.getWorldObj(), - tTileEntity.xCoord, - tTileEntity.yCoord, - tTileEntity.zCoord); + if (tileEntity instanceof IReactorChamber) + ic2Energy = (TileEntity) ((IReactorChamber) tileEntity).getReactor(); + else ic2Energy = (tileEntity == null || tileEntity instanceof IEnergyTile || EnergyNet.instance == null) + ? tileEntity + : EnergyNet.instance + .getTileEntity(tileEntity.getWorldObj(), tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord); // IC2 Sink Compat if ((ic2Energy instanceof IEnergySink) - && ((IEnergySink) ic2Energy).acceptsEnergyFrom((TileEntity) baseMetaTile, tDir)) return true; + && ((IEnergySink) ic2Energy).acceptsEnergyFrom((TileEntity) baseMetaTile, oppositeSide)) return true; // IC2 Source Compat if (GT_Mod.gregtechproxy.ic2EnergySourceCompat && (ic2Energy instanceof IEnergySource)) { - if (((IEnergySource) ic2Energy).emitsEnergyTo((TileEntity) baseMetaTile, tDir)) { + if (((IEnergySource) ic2Energy).emitsEnergyTo((TileEntity) baseMetaTile, oppositeSide)) { return true; } } } // RF Output Compat - if (GregTech_API.mOutputRF && tTileEntity instanceof IEnergyReceiver - && ((IEnergyReceiver) tTileEntity).canConnectEnergy(tDir)) return true; + if (GregTech_API.mOutputRF && tileEntity instanceof IEnergyReceiver + && ((IEnergyReceiver) tileEntity).canConnectEnergy(oppositeSide)) return true; // RF Input Compat - return GregTech_API.mInputRF && (tTileEntity instanceof IEnergyEmitter - && ((IEnergyEmitter) tTileEntity).emitsEnergyTo((TileEntity) baseMetaTile, tDir)); + return GregTech_API.mInputRF && (tileEntity instanceof IEnergyEmitter + && ((IEnergyEmitter) tileEntity).emitsEnergyTo((TileEntity) baseMetaTile, oppositeSide)); } @Override @@ -399,12 +389,14 @@ public boolean getGT6StyleConnection() { } @Override - public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { return false; } @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { return false; } @@ -508,48 +500,53 @@ public AxisAlignedBB getCollisionBoundingBoxFromPool(World aWorld, int aX, int a private AxisAlignedBB getActualCollisionBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ) { float tSpace = (1f - mThickNess) / 2; - float tSide0 = tSpace; - float tSide1 = 1f - tSpace; - float tSide2 = tSpace; - float tSide3 = 1f - tSpace; - float tSide4 = tSpace; - float tSide5 = 1f - tSpace; - - if (getBaseMetaTileEntity().getCoverIDAtSide((byte) 0) != 0) { - tSide0 = tSide2 = tSide4 = 0; - tSide3 = tSide5 = 1; + float spaceDown = tSpace; + float spaceUp = 1f - tSpace; + float spaceNorth = tSpace; + float spaceSouth = 1f - tSpace; + float spaceWest = tSpace; + float spaceEast = 1f - tSpace; + + if (getBaseMetaTileEntity().getCoverIDAtSide(DOWN) != 0) { + spaceDown = spaceNorth = spaceWest = 0; + spaceSouth = spaceEast = 1; } - if (getBaseMetaTileEntity().getCoverIDAtSide((byte) 1) != 0) { - tSide2 = tSide4 = 0; - tSide1 = tSide3 = tSide5 = 1; + if (getBaseMetaTileEntity().getCoverIDAtSide(ForgeDirection.UP) != 0) { + spaceNorth = spaceWest = 0; + spaceUp = spaceSouth = spaceEast = 1; } - if (getBaseMetaTileEntity().getCoverIDAtSide((byte) 2) != 0) { - tSide0 = tSide2 = tSide4 = 0; - tSide1 = tSide5 = 1; + if (getBaseMetaTileEntity().getCoverIDAtSide(ForgeDirection.NORTH) != 0) { + spaceDown = spaceNorth = spaceWest = 0; + spaceUp = spaceEast = 1; } - if (getBaseMetaTileEntity().getCoverIDAtSide((byte) 3) != 0) { - tSide0 = tSide4 = 0; - tSide1 = tSide3 = tSide5 = 1; + if (getBaseMetaTileEntity().getCoverIDAtSide(ForgeDirection.SOUTH) != 0) { + spaceDown = spaceWest = 0; + spaceUp = spaceSouth = spaceEast = 1; } - if (getBaseMetaTileEntity().getCoverIDAtSide((byte) 4) != 0) { - tSide0 = tSide2 = tSide4 = 0; - tSide1 = tSide3 = 1; + if (getBaseMetaTileEntity().getCoverIDAtSide(ForgeDirection.WEST) != 0) { + spaceDown = spaceNorth = spaceWest = 0; + spaceUp = spaceSouth = 1; } - if (getBaseMetaTileEntity().getCoverIDAtSide((byte) 5) != 0) { - tSide0 = tSide2 = 0; - tSide1 = tSide3 = tSide5 = 1; + if (getBaseMetaTileEntity().getCoverIDAtSide(ForgeDirection.EAST) != 0) { + spaceDown = spaceNorth = 0; + spaceUp = spaceSouth = spaceEast = 1; } byte tConn = ((BaseMetaPipeEntity) getBaseMetaTileEntity()).mConnections; - if ((tConn & (1 << ForgeDirection.DOWN.ordinal())) != 0) tSide0 = 0f; - if ((tConn & (1 << ForgeDirection.UP.ordinal())) != 0) tSide1 = 1f; - if ((tConn & (1 << ForgeDirection.NORTH.ordinal())) != 0) tSide2 = 0f; - if ((tConn & (1 << ForgeDirection.SOUTH.ordinal())) != 0) tSide3 = 1f; - if ((tConn & (1 << ForgeDirection.WEST.ordinal())) != 0) tSide4 = 0f; - if ((tConn & (1 << ForgeDirection.EAST.ordinal())) != 0) tSide5 = 1f; + if ((tConn & (1 << DOWN.ordinal())) != 0) spaceDown = 0f; + if ((tConn & (1 << ForgeDirection.UP.ordinal())) != 0) spaceUp = 1f; + if ((tConn & (1 << ForgeDirection.NORTH.ordinal())) != 0) spaceNorth = 0f; + if ((tConn & (1 << ForgeDirection.SOUTH.ordinal())) != 0) spaceSouth = 1f; + if ((tConn & (1 << ForgeDirection.WEST.ordinal())) != 0) spaceWest = 0f; + if ((tConn & (1 << ForgeDirection.EAST.ordinal())) != 0) spaceEast = 1f; - return AxisAlignedBB - .getBoundingBox(aX + tSide4, aY + tSide0, aZ + tSide2, aX + tSide5, aY + tSide1, aZ + tSide3); + return AxisAlignedBB.getBoundingBox( + aX + spaceWest, + aY + spaceDown, + aZ + spaceNorth, + aX + spaceEast, + aY + spaceUp, + aZ + spaceSouth); } @Override @@ -568,18 +565,20 @@ public boolean shouldJoinIc2Enet() { if (mConnections != 0) { final IGregTechTileEntity baseMeta = getBaseMetaTileEntity(); - for (byte aSide = 0; aSide < 6; aSide++) if (isConnectedAtSide(aSide)) { - final TileEntity tTileEntity = baseMeta.getTileEntityAtSide(aSide); - final TileEntity tEmitter = (tTileEntity == null || tTileEntity instanceof IEnergyTile - || EnergyNet.instance == null) - ? tTileEntity - : EnergyNet.instance.getTileEntity( - tTileEntity.getWorldObj(), - tTileEntity.xCoord, - tTileEntity.yCoord, - tTileEntity.zCoord); - - if (tEmitter instanceof IEnergyEmitter) return true; + for (final ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + if (isConnectedAtSide(side)) { + final TileEntity tTileEntity = baseMeta.getTileEntityAtSide(side); + final TileEntity tEmitter = (tTileEntity == null || tTileEntity instanceof IEnergyTile + || EnergyNet.instance == null) + ? tTileEntity + : EnergyNet.instance.getTileEntity( + tTileEntity.getWorldObj(), + tTileEntity.xCoord, + tTileEntity.yCoord, + tTileEntity.zCoord); + + if (tEmitter instanceof IEnergyEmitter) return true; + } } } return false; @@ -589,22 +588,22 @@ public boolean shouldJoinIc2Enet() { public void reloadLocks() { final BaseMetaPipeEntity pipe = (BaseMetaPipeEntity) getBaseMetaTileEntity(); if (pipe.getNode() != null) { - for (byte tSide : ALL_VALID_SIDES) { - if (isConnectedAtSide(tSide)) { - final CoverInfo coverInfo = pipe.getCoverInfoAtSide(tSide); + for (final ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + if (isConnectedAtSide(side)) { + final CoverInfo coverInfo = pipe.getCoverInfoAtSide(side); if (coverInfo.getCoverBehavior() instanceof GT_Cover_None) continue; if (!letsIn(coverInfo) || !letsOut(coverInfo)) { - pipe.addToLock(pipe, tSide); + pipe.addToLock(pipe, side); } else { - pipe.removeFromLock(pipe, tSide); + pipe.removeFromLock(pipe, side); } } } } else { boolean dontAllow = false; - for (byte tSide : ALL_VALID_SIDES) { - if (isConnectedAtSide(tSide)) { - final CoverInfo coverInfo = pipe.getCoverInfoAtSide(tSide); + for (final ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + if (isConnectedAtSide(side)) { + final CoverInfo coverInfo = pipe.getCoverInfoAtSide(side); if (coverInfo.getCoverBehavior() instanceof GT_Cover_None) continue; if (!letsIn(coverInfo) || !letsOut(coverInfo)) { @@ -613,9 +612,9 @@ public void reloadLocks() { } } if (dontAllow) { - pipe.addToLock(pipe, 0); + pipe.addToLock(pipe, DOWN); } else { - pipe.removeFromLock(pipe, 0); + pipe.removeFromLock(pipe, DOWN); } } } 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 76c7f418e98..e19d6574c33 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,5 +1,6 @@ package gregtech.api.metatileentity.implementations; +import static gregtech.api.enums.GT_Values.ALL_VALID_SIDES; import static gregtech.api.enums.GT_Values.D1; import static gregtech.api.objects.XSTR.XSTR_INSTANCE; @@ -108,54 +109,57 @@ public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { } @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aConnections, - byte aColorIndex, boolean aConnected, boolean aRedstone) { + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, int aConnections, + int colorIndex, boolean aConnected, boolean redstoneLevel) { + final int ordinalSide = side.ordinal(); final float tThickNess = getThickNess(); if (mDisableInput == 0) - return new ITexture[] { aConnected ? getBaseTexture(tThickNess, mPipeAmount, mMaterial, aColorIndex) + return new ITexture[] { aConnected ? getBaseTexture(tThickNess, mPipeAmount, mMaterial, colorIndex) : TextureFactory.of( mMaterial.mIconSet.mTextures[OrePrefixes.pipe.mTextureIndex], - Dyes.getModulation(aColorIndex, mMaterial.mRGBa)) }; + Dyes.getModulation(colorIndex, mMaterial.mRGBa)) }; byte tMask = 0; final byte[][] sRestrictionArray = { { 2, 3, 5, 4 }, { 2, 3, 4, 5 }, { 1, 0, 4, 5 }, { 1, 0, 4, 5 }, { 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 (side != ForgeDirection.UNKNOWN) { + for (byte i = 0; i < 4; i++) + if (isInputDisabledAtSide(ForgeDirection.getOrientation(sRestrictionArray[ordinalSide][i]))) + tMask |= 1 << i; // Full block size renderer flips side 5 and 2 textures, flip restrictor textures to compensate - if (aSide == 5 || aSide == 2) if (tMask > 3 && tMask < 12) tMask = (byte) (tMask ^ 12); + if (ordinalSide == 5 || ordinalSide == 2) if (tMask > 3 && tMask < 12) tMask = (byte) (tMask ^ 12); } - return new ITexture[] { aConnected ? getBaseTexture(tThickNess, mPipeAmount, mMaterial, aColorIndex) + return new ITexture[] { aConnected ? getBaseTexture(tThickNess, mPipeAmount, mMaterial, colorIndex) : TextureFactory.of( mMaterial.mIconSet.mTextures[OrePrefixes.pipe.mTextureIndex], - Dyes.getModulation(aColorIndex, mMaterial.mRGBa)), + Dyes.getModulation(colorIndex, mMaterial.mRGBa)), getRestrictorTexture(tMask) }; } - protected static ITexture getBaseTexture(float aThickNess, int aPipeAmount, Materials aMaterial, byte aColorIndex) { + protected static ITexture getBaseTexture(float aThickNess, int aPipeAmount, Materials aMaterial, int colorIndex) { if (aPipeAmount >= 9) return TextureFactory.of( aMaterial.mIconSet.mTextures[OrePrefixes.pipeNonuple.mTextureIndex], - Dyes.getModulation(aColorIndex, aMaterial.mRGBa)); + Dyes.getModulation(colorIndex, aMaterial.mRGBa)); if (aPipeAmount >= 4) return TextureFactory.of( aMaterial.mIconSet.mTextures[OrePrefixes.pipeQuadruple.mTextureIndex], - Dyes.getModulation(aColorIndex, aMaterial.mRGBa)); + Dyes.getModulation(colorIndex, aMaterial.mRGBa)); if (aThickNess < 0.124F) return TextureFactory.of( aMaterial.mIconSet.mTextures[OrePrefixes.pipe.mTextureIndex], - Dyes.getModulation(aColorIndex, aMaterial.mRGBa)); + Dyes.getModulation(colorIndex, aMaterial.mRGBa)); if (aThickNess < 0.374F) return TextureFactory.of( aMaterial.mIconSet.mTextures[OrePrefixes.pipeTiny.mTextureIndex], - Dyes.getModulation(aColorIndex, aMaterial.mRGBa)); + Dyes.getModulation(colorIndex, aMaterial.mRGBa)); if (aThickNess < 0.499F) return TextureFactory.of( aMaterial.mIconSet.mTextures[OrePrefixes.pipeSmall.mTextureIndex], - Dyes.getModulation(aColorIndex, aMaterial.mRGBa)); + Dyes.getModulation(colorIndex, aMaterial.mRGBa)); if (aThickNess < 0.749F) return TextureFactory.of( aMaterial.mIconSet.mTextures[OrePrefixes.pipeMedium.mTextureIndex], - Dyes.getModulation(aColorIndex, aMaterial.mRGBa)); + Dyes.getModulation(colorIndex, aMaterial.mRGBa)); if (aThickNess < 0.874F) return TextureFactory.of( aMaterial.mIconSet.mTextures[OrePrefixes.pipeLarge.mTextureIndex], - Dyes.getModulation(aColorIndex, aMaterial.mRGBa)); + Dyes.getModulation(colorIndex, aMaterial.mRGBa)); return TextureFactory.of( aMaterial.mIconSet.mTextures[OrePrefixes.pipeHuge.mTextureIndex], - Dyes.getModulation(aColorIndex, aMaterial.mRGBa)); + Dyes.getModulation(colorIndex, aMaterial.mRGBa)); } protected static ITexture getRestrictorTexture(byte aMask) { @@ -195,7 +199,7 @@ public boolean isSimpleMachine() { } @Override - public boolean isFacingValid(byte aFacing) { + public boolean isFacingValid(ForgeDirection facing) { return false; } @@ -205,7 +209,7 @@ public boolean isValidSlot(int aIndex) { } @Override - public final boolean renderInside(byte aSide) { + public final boolean renderInside(ForgeDirection side) { return false; } @@ -376,22 +380,22 @@ private void distributeFluid(int index, IGregTechTileEntity aBaseMetaTileEntity) // Tank, From, Amount to receive final List> tTanks = new ArrayList<>(); final int amount = tFluid.amount; - - for (byte aSide, i = 0, j = (byte) aBaseMetaTileEntity.getRandomNumber(6); i < 6; i++) { + final byte tOffset = (byte) getBaseMetaTileEntity().getRandomNumber(6); + for (final byte i : ALL_VALID_SIDES) { // Get a list of tanks accepting fluids, and what side they're on - aSide = (byte) ((i + j) % 6); - final byte tSide = GT_Utility.getOppositeSide(aSide); - final IFluidHandler tTank = aBaseMetaTileEntity.getITankContainerAtSide(aSide); + final ForgeDirection side = ForgeDirection.getOrientation((i + tOffset) % 6); + final ForgeDirection oppositeSide = side.getOpposite(); + final IFluidHandler tTank = aBaseMetaTileEntity.getITankContainerAtSide(side); final IGregTechTileEntity gTank = tTank instanceof IGregTechTileEntity ? (IGregTechTileEntity) tTank : null; - if (isConnectedAtSide(aSide) && tTank != null - && (mLastReceivedFrom & (1 << aSide)) == 0 - && getBaseMetaTileEntity().getCoverInfoAtSide(aSide) + if (isConnectedAtSide(side) && tTank != null + && (mLastReceivedFrom & (1 << side.ordinal())) == 0 + && getBaseMetaTileEntity().getCoverInfoAtSide(side) .letsFluidOut(tFluid.getFluid()) - && (gTank == null || gTank.getCoverInfoAtSide(tSide) + && (gTank == null || gTank.getCoverInfoAtSide(oppositeSide) .letsFluidIn(tFluid.getFluid()))) { - if (tTank.fill(ForgeDirection.getOrientation(tSide), tFluid, false) > 0) { - tTanks.add(new MutableTriple<>(tTank, ForgeDirection.getOrientation(tSide), 0)); + if (tTank.fill(oppositeSide, tFluid, false) > 0) { + tTanks.add(new MutableTriple<>(tTank, oppositeSide, 0)); } tFluid.amount = amount; // Because some mods do actually modify input fluid stack } @@ -399,19 +403,19 @@ && getBaseMetaTileEntity().getCoverInfoAtSide(aSide) // How much of this fluid is available for distribution? final double tAmount = Math.max(1, Math.min(mCapacity * 10, tFluid.amount)); - final double tNumTanks = tTanks.size(); + final FluidStack maxFluid = tFluid.copy(); maxFluid.amount = Integer.MAX_VALUE; double availableCapacity = 0; // Calculate available capacity for distribution from all tanks - for (MutableTriple tEntry : tTanks) { + for (final MutableTriple tEntry : tTanks) { tEntry.right = tEntry.left.fill(tEntry.middle, maxFluid, false); availableCapacity += tEntry.right; } // Now distribute - for (MutableTriple tEntry : tTanks) { + for (final MutableTriple tEntry : tTanks) { // Distribue fluids based on percentage available space at destination if (availableCapacity > tAmount) tEntry.right = (int) Math.floor(tEntry.right * tAmount / availableCapacity); @@ -431,26 +435,27 @@ && getBaseMetaTileEntity().getCoverInfoAtSide(aSide) } @Override - public boolean onWrenchRightClick(byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, - float aZ) { + public boolean onWrenchRightClick(ForgeDirection side, ForgeDirection wrenchingSide, EntityPlayer entityPlayer, + float aX, float aY, float aZ) { if (GT_Mod.gregtechproxy.gt6Pipe) { - final byte tSide = GT_Utility.determineWrenchingSide(aSide, aX, aY, aZ); - final byte tMask = (byte) (1 << tSide); - if (aPlayer.isSneaking()) { + final ForgeDirection tSide = GT_Utility.determineWrenchingSide(side, aX, aY, aZ); + final byte tMask = (byte) (1 << tSide.ordinal()); + if (entityPlayer.isSneaking()) { if (isInputDisabledAtSide(tSide)) { mDisableInput &= ~tMask; - GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("212", "Input enabled")); + GT_Utility.sendChatToPlayer(entityPlayer, GT_Utility.trans("212", "Input enabled")); if (!isConnectedAtSide(tSide)) connect(tSide); } else { mDisableInput |= tMask; - GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("213", "Input disabled")); + GT_Utility.sendChatToPlayer(entityPlayer, GT_Utility.trans("213", "Input disabled")); } } else { if (!isConnectedAtSide(tSide)) { - if (connect(tSide) > 0) GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("214", "Connected")); + if (connect(tSide) > 0) + GT_Utility.sendChatToPlayer(entityPlayer, GT_Utility.trans("214", "Connected")); } else { disconnect(tSide); - GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("215", "Disconnected")); + GT_Utility.sendChatToPlayer(entityPlayer, GT_Utility.trans("215", "Disconnected")); } } return true; @@ -459,27 +464,27 @@ public boolean onWrenchRightClick(byte aSide, byte aWrenchingSide, EntityPlayer } @Override - public boolean letsIn(GT_CoverBehavior coverBehavior, byte aSide, int aCoverID, int aCoverVariable, + public boolean letsIn(GT_CoverBehavior coverBehavior, ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { - return coverBehavior.letsFluidIn(aSide, aCoverID, aCoverVariable, null, aTileEntity); + return coverBehavior.letsFluidIn(side, aCoverID, aCoverVariable, null, aTileEntity); } @Override - public boolean letsOut(GT_CoverBehavior coverBehavior, byte aSide, int aCoverID, int aCoverVariable, + public boolean letsOut(GT_CoverBehavior coverBehavior, ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { - return coverBehavior.letsFluidOut(aSide, aCoverID, aCoverVariable, null, aTileEntity); + return coverBehavior.letsFluidOut(side, aCoverID, aCoverVariable, null, aTileEntity); } @Override - public boolean letsIn(GT_CoverBehaviorBase coverBehavior, byte aSide, int aCoverID, + public boolean letsIn(GT_CoverBehaviorBase coverBehavior, ForgeDirection side, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) { - return coverBehavior.letsFluidIn(aSide, aCoverID, aCoverVariable, null, aTileEntity); + return coverBehavior.letsFluidIn(side, aCoverID, aCoverVariable, null, aTileEntity); } @Override - public boolean letsOut(GT_CoverBehaviorBase coverBehavior, byte aSide, int aCoverID, + public boolean letsOut(GT_CoverBehaviorBase coverBehavior, ForgeDirection side, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) { - return coverBehavior.letsFluidOut(aSide, aCoverID, aCoverVariable, null, aTileEntity); + return coverBehavior.letsFluidOut(side, aCoverID, aCoverVariable, null, aTileEntity); } @Override @@ -493,29 +498,27 @@ public boolean letsOut(CoverInfo coverInfo) { } @Override - public boolean canConnect(byte aSide, TileEntity tTileEntity) { - if (tTileEntity == null) return false; + public boolean canConnect(ForgeDirection side, TileEntity tileEntity) { + if (tileEntity == null) return false; - final byte tSide = (byte) ForgeDirection.getOrientation(aSide) - .getOpposite() - .ordinal(); + final ForgeDirection tSide = side.getOpposite(); final IGregTechTileEntity baseMetaTile = getBaseMetaTileEntity(); if (baseMetaTile == null) return false; - final GT_CoverBehaviorBase coverBehavior = baseMetaTile.getCoverBehaviorAtSideNew(aSide); - final IGregTechTileEntity gTileEntity = (tTileEntity instanceof IGregTechTileEntity) - ? (IGregTechTileEntity) tTileEntity + final GT_CoverBehaviorBase coverBehavior = baseMetaTile.getCoverBehaviorAtSideNew(side); + final IGregTechTileEntity gTileEntity = (tileEntity instanceof IGregTechTileEntity) + ? (IGregTechTileEntity) tileEntity : null; - if (coverBehavior instanceof GT_Cover_Drain || (GregTech_API.mTConstruct && isTConstructFaucet(tTileEntity))) + if (coverBehavior instanceof GT_Cover_Drain || (GregTech_API.mTConstruct && isTConstructFaucet(tileEntity))) return true; - final IFluidHandler fTileEntity = (tTileEntity instanceof IFluidHandler) ? (IFluidHandler) tTileEntity : null; + final IFluidHandler fTileEntity = (tileEntity instanceof IFluidHandler) ? (IFluidHandler) tileEntity : null; if (fTileEntity != null) { - final FluidTankInfo[] tInfo = fTileEntity.getTankInfo(ForgeDirection.getOrientation(tSide)); + final FluidTankInfo[] tInfo = fTileEntity.getTankInfo(tSide); if (tInfo != null) { - return tInfo.length > 0 || (GregTech_API.mTranslocator && isTranslocator(tTileEntity)) + return tInfo.length > 0 || (GregTech_API.mTranslocator && isTranslocator(tileEntity)) || gTileEntity != null && gTileEntity.getCoverBehaviorAtSideNew(tSide) instanceof GT_Cover_FluidRegulator; } @@ -578,7 +581,7 @@ public FluidTankInfo getInfo() { } @Override - public FluidTankInfo[] getTankInfo(ForgeDirection aSide) { + public FluidTankInfo[] getTankInfo(ForgeDirection side) { if (getCapacity() <= 0 && !getBaseMetaTileEntity().hasSteamEngineUpgrade()) return new FluidTankInfo[] {}; ArrayList tList = new ArrayList<>(); for (FluidStack tFluid : mFluids) tList.add(new FluidTankInfo(tFluid, mCapacity * 20)); @@ -586,12 +589,14 @@ public FluidTankInfo[] getTankInfo(ForgeDirection aSide) { } @Override - public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { return false; } @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { return false; } @@ -613,7 +618,7 @@ public final int getFluidAmount() { } @Override - public final int fill_default(ForgeDirection aSide, FluidStack aFluid, boolean doFill) { + public final int fill_default(ForgeDirection side, FluidStack aFluid, boolean doFill) { if (aFluid == null || aFluid.getFluid() .getID() <= 0) return 0; @@ -628,26 +633,28 @@ public final int fill_default(ForgeDirection aSide, FluidStack aFluid, boolean d } } - return fill_default_intoIndex(aSide, aFluid, doFill, index); + return fill_default_intoIndex(side, aFluid, doFill, index); } - private int fill_default_intoIndex(ForgeDirection aSide, FluidStack aFluid, boolean doFill, int index) { + private int fill_default_intoIndex(ForgeDirection side, FluidStack aFluid, boolean doFill, int index) { if (index < 0 || index >= mPipeAmount) return 0; if (aFluid == null || aFluid.getFluid() .getID() <= 0) return 0; + final int ordinalSide = side.ordinal(); + if (mFluids[index] == null || mFluids[index].getFluid() .getID() <= 0) { if (aFluid.amount * mPipeAmount <= getCapacity()) { if (doFill) { mFluids[index] = aFluid.copy(); - mLastReceivedFrom |= (1 << aSide.ordinal()); + mLastReceivedFrom |= (1 << ordinalSide); } return aFluid.amount; } if (doFill) { mFluids[index] = aFluid.copy(); - mLastReceivedFrom |= (1 << aSide.ordinal()); + mLastReceivedFrom |= (1 << ordinalSide); mFluids[index].amount = getCapacity() / mPipeAmount; } return getCapacity() / mPipeAmount; @@ -659,13 +666,13 @@ private int fill_default_intoIndex(ForgeDirection aSide, FluidStack aFluid, bool if (aFluid.amount <= space) { if (doFill) { mFluids[index].amount += aFluid.amount; - mLastReceivedFrom |= (1 << aSide.ordinal()); + mLastReceivedFrom |= (1 << ordinalSide); } return aFluid.amount; } if (doFill) { mFluids[index].amount = getCapacity() / mPipeAmount; - mLastReceivedFrom |= (1 << aSide.ordinal()); + mLastReceivedFrom |= (1 << ordinalSide); } return space; } @@ -742,17 +749,17 @@ public float getThickNess() { } @Override - public boolean isLiquidInput(byte aSide) { - return !isInputDisabledAtSide(aSide); + public boolean isLiquidInput(ForgeDirection side) { + return !isInputDisabledAtSide(side); } @Override - public boolean isLiquidOutput(byte aSide) { + public boolean isLiquidOutput(ForgeDirection side) { return true; } - public boolean isInputDisabledAtSide(int aSide) { - return (mDisableInput & (1 << aSide)) != 0; + public boolean isInputDisabledAtSide(ForgeDirection side) { + return (mDisableInput & (1 << side.ordinal())) != 0; } @Override @@ -771,27 +778,27 @@ private AxisAlignedBB getActualCollisionBoundingBoxFromPool(World aWorld, int aX float tSide4 = tSpace; float tSide5 = 1f - tSpace; - if (getBaseMetaTileEntity().getCoverIDAtSide((byte) 0) != 0) { + if (getBaseMetaTileEntity().getCoverIDAtSide(ForgeDirection.DOWN) != 0) { tSide0 = tSide2 = tSide4 = 0; tSide3 = tSide5 = 1; } - if (getBaseMetaTileEntity().getCoverIDAtSide((byte) 1) != 0) { + if (getBaseMetaTileEntity().getCoverIDAtSide(ForgeDirection.UP) != 0) { tSide2 = tSide4 = 0; tSide1 = tSide3 = tSide5 = 1; } - if (getBaseMetaTileEntity().getCoverIDAtSide((byte) 2) != 0) { + if (getBaseMetaTileEntity().getCoverIDAtSide(ForgeDirection.NORTH) != 0) { tSide0 = tSide2 = tSide4 = 0; tSide1 = tSide5 = 1; } - if (getBaseMetaTileEntity().getCoverIDAtSide((byte) 3) != 0) { + if (getBaseMetaTileEntity().getCoverIDAtSide(ForgeDirection.SOUTH) != 0) { tSide0 = tSide4 = 0; tSide1 = tSide3 = tSide5 = 1; } - if (getBaseMetaTileEntity().getCoverIDAtSide((byte) 4) != 0) { + if (getBaseMetaTileEntity().getCoverIDAtSide(ForgeDirection.WEST) != 0) { tSide0 = tSide2 = tSide4 = 0; tSide1 = tSide3 = 1; } - if (getBaseMetaTileEntity().getCoverIDAtSide((byte) 5) != 0) { + if (getBaseMetaTileEntity().getCoverIDAtSide(ForgeDirection.EAST) != 0) { tSide0 = tSide2 = 0; tSide1 = tSide3 = tSide5 = 1; } @@ -819,7 +826,7 @@ public void addCollisionBoxesToList(World aWorld, int aX, int aY, int aZ, AxisAl } @Override - public FluidStack drain(ForgeDirection aSide, FluidStack aFluid, boolean doDrain) { + public FluidStack drain(ForgeDirection side, FluidStack aFluid, boolean doDrain) { if (aFluid == null) return null; for (int i = 0; i < mFluids.length; ++i) { final FluidStack f = mFluids[i]; diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Frame.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Frame.java index 9ccb43e7337..83e658cbfc3 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Frame.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Frame.java @@ -5,6 +5,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.ForgeDirection; import gregtech.api.enums.*; import gregtech.api.interfaces.ITexture; @@ -62,11 +63,11 @@ public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { } @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aConnections, - byte aColorIndex, boolean aConnected, boolean aRedstone) { + public ITexture[] getTexture(IGregTechTileEntity baseMetaTileEntity, ForgeDirection sideDirection, int connections, + int colorIndex, boolean active, boolean redstoneLevel) { return new ITexture[] { TextureFactory.of( mMaterial.mIconSet.mTextures[OrePrefixes.frameGt.mTextureIndex], - Dyes.getModulation(aColorIndex, mMaterial.mRGBa)) }; + Dyes.getModulation(colorIndex, mMaterial.mRGBa)) }; } @Override @@ -80,7 +81,7 @@ public final boolean isSimpleMachine() { } @Override - public final boolean isFacingValid(byte aFacing) { + public final boolean isFacingValid(ForgeDirection facing) { return false; } @@ -90,7 +91,7 @@ public final boolean isValidSlot(int aIndex) { } @Override - public final boolean renderInside(byte aSide) { + public final boolean renderInside(ForgeDirection side) { return true; } @@ -110,24 +111,24 @@ public final void loadNBTData(NBTTagCompound aNBT) { } @Override - public final boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, + public final boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, ItemStack aStack) { return false; } @Override - public final boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, + public final boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, ItemStack aStack) { return false; } @Override - public int connect(byte aSide) { + public int connect(ForgeDirection side) { return 0; } @Override - public void disconnect(byte aSide) { + public void disconnect(ForgeDirection side) { /* Do nothing */ } 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 f69170b83eb..0a1fe6ae7af 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 @@ -47,7 +47,7 @@ public class GT_MetaPipeEntity_Item extends MetaPipeEntity implements IMetaTileE public final int mStepSize; public final int mTickTime; public int mTransferredItems = 0; - public byte mLastReceivedFrom = 0, oLastReceivedFrom = 0; + public ForgeDirection mLastReceivedFrom = ForgeDirection.UNKNOWN, oLastReceivedFrom = ForgeDirection.UNKNOWN; public boolean mIsRestrictive = false; private int[] cacheSides; @@ -95,8 +95,8 @@ public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { } @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aConnections, - byte aColorIndex, boolean aConnected, boolean aRedstone) { + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, int aConnections, + int aColorIndex, boolean aConnected, boolean redstoneLevel) { if (mIsRestrictive) { if (aConnected) { float tThickNess = getThickNess(); @@ -163,17 +163,17 @@ public boolean isSimpleMachine() { } @Override - public boolean isFacingValid(byte aFacing) { + public boolean isFacingValid(ForgeDirection facing) { return false; } @Override - public boolean isValidSlot(int aIndex) { + public boolean isValidSlot(int ignoredSlotIndex) { return true; } @Override - public final boolean renderInside(byte aSide) { + public final boolean renderInside(ForgeDirection side) { return false; } @@ -189,13 +189,13 @@ public int maxProgresstime() { @Override public void saveNBTData(NBTTagCompound aNBT) { - aNBT.setByte("mLastReceivedFrom", mLastReceivedFrom); + aNBT.setByte("mLastReceivedFrom", (byte) mLastReceivedFrom.ordinal()); if (GT_Mod.gregtechproxy.gt6Pipe) aNBT.setByte("mConnections", mConnections); } @Override public void loadNBTData(NBTTagCompound aNBT) { - mLastReceivedFrom = aNBT.getByte("mLastReceivedFrom"); + mLastReceivedFrom = ForgeDirection.getOrientation(aNBT.getByte("mLastReceivedFrom")); if (GT_Mod.gregtechproxy.gt6Pipe) { mConnections = aNBT.getByte("mConnections"); } @@ -230,21 +230,21 @@ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { } } - if (isInventoryEmpty()) mLastReceivedFrom = 6; + if (isInventoryEmpty()) mLastReceivedFrom = ForgeDirection.UNKNOWN; oLastReceivedFrom = mLastReceivedFrom; } } @Override - public boolean onWrenchRightClick(byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, - float aZ) { + public boolean onWrenchRightClick(ForgeDirection side, ForgeDirection wrenchingSide, EntityPlayer entityPlayer, + float aX, float aY, float aZ) { if (GT_Mod.gregtechproxy.gt6Pipe) { - final byte tSide = GT_Utility.determineWrenchingSide(aSide, aX, aY, aZ); + final ForgeDirection tSide = GT_Utility.determineWrenchingSide(side, aX, aY, aZ); if (isConnectedAtSide(tSide)) { disconnect(tSide); - GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("215", "Disconnected")); + GT_Utility.sendChatToPlayer(entityPlayer, GT_Utility.trans("215", "Disconnected")); } else { - if (connect(tSide) > 0) GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("214", "Connected")); + if (connect(tSide) > 0) GT_Utility.sendChatToPlayer(entityPlayer, GT_Utility.trans("214", "Connected")); } return true; } @@ -252,27 +252,27 @@ public boolean onWrenchRightClick(byte aSide, byte aWrenchingSide, EntityPlayer } @Override - public boolean letsIn(GT_CoverBehavior coverBehavior, byte aSide, int aCoverID, int aCoverVariable, + public boolean letsIn(GT_CoverBehavior coverBehavior, ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { - return coverBehavior.letsItemsIn(aSide, aCoverID, aCoverVariable, -1, aTileEntity); + return coverBehavior.letsItemsIn(side, aCoverID, aCoverVariable, -1, aTileEntity); } @Override - public boolean letsOut(GT_CoverBehavior coverBehavior, byte aSide, int aCoverID, int aCoverVariable, + public boolean letsOut(GT_CoverBehavior coverBehavior, ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { - return coverBehavior.letsItemsOut(aSide, aCoverID, aCoverVariable, -1, aTileEntity); + return coverBehavior.letsItemsOut(side, aCoverID, aCoverVariable, -1, aTileEntity); } @Override - public boolean letsIn(GT_CoverBehaviorBase coverBehavior, byte aSide, int aCoverID, + public boolean letsIn(GT_CoverBehaviorBase coverBehavior, ForgeDirection side, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) { - return coverBehavior.letsItemsIn(aSide, aCoverID, aCoverVariable, -1, aTileEntity); + return coverBehavior.letsItemsIn(side, aCoverID, aCoverVariable, -1, aTileEntity); } @Override - public boolean letsOut(GT_CoverBehaviorBase coverBehavior, byte aSide, int aCoverID, + public boolean letsOut(GT_CoverBehaviorBase coverBehavior, ForgeDirection side, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) { - return coverBehavior.letsItemsOut(aSide, aCoverID, aCoverVariable, -1, aTileEntity); + return coverBehavior.letsItemsOut(side, aCoverID, aCoverVariable, -1, aTileEntity); } @Override @@ -286,28 +286,28 @@ public boolean letsOut(CoverInfo coverInfo) { } @Override - public boolean canConnect(byte aSide, TileEntity tTileEntity) { - if (tTileEntity == null) return false; + public boolean canConnect(ForgeDirection side, TileEntity tileEntity) { + if (tileEntity == null) return false; - final byte tSide = GT_Utility.getOppositeSide(aSide); - boolean connectable = GT_Utility.isConnectableNonInventoryPipe(tTileEntity, tSide); + final ForgeDirection oppositeSide = side.getOpposite(); + boolean connectable = GT_Utility.isConnectableNonInventoryPipe(tileEntity, oppositeSide); - final IGregTechTileEntity gTileEntity = (tTileEntity instanceof IGregTechTileEntity) - ? (IGregTechTileEntity) tTileEntity + final IGregTechTileEntity gTileEntity = (tileEntity instanceof IGregTechTileEntity) + ? (IGregTechTileEntity) tileEntity : null; if (gTileEntity != null) { if (gTileEntity.getMetaTileEntity() == null) return false; if (gTileEntity.getMetaTileEntity() - .connectsToItemPipe(tSide)) return true; + .connectsToItemPipe(oppositeSide)) return true; connectable = true; } - if (tTileEntity instanceof IInventory) { - if (((IInventory) tTileEntity).getSizeInventory() <= 0) return false; + if (tileEntity instanceof IInventory) { + if (((IInventory) tileEntity).getSizeInventory() <= 0) return false; connectable = true; } - if (tTileEntity instanceof ISidedInventory) { - final int[] tSlots = ((ISidedInventory) tTileEntity).getAccessibleSlotsFromSide(tSide); + if (tileEntity instanceof ISidedInventory) { + final int[] tSlots = ((ISidedInventory) tileEntity).getAccessibleSlotsFromSide(oppositeSide.ordinal()); if (tSlots == null || tSlots.length <= 0) return false; connectable = true; } @@ -331,9 +331,8 @@ public boolean incrementTransferCounter(int aIncrement) { public boolean sendItemStack(Object aSender) { if (pipeCapacityCheck()) { final byte tOffset = (byte) getBaseMetaTileEntity().getRandomNumber(6); - byte tSide = 0; - for (byte i : ALL_VALID_SIDES) { - tSide = (byte) ((i + tOffset) % 6); + for (final byte i : ALL_VALID_SIDES) { + final ForgeDirection tSide = ForgeDirection.getOrientation((i + tOffset) % 6); if (isConnectedAtSide(tSide) && (isInventoryEmpty() || (tSide != mLastReceivedFrom || aSender != getBaseMetaTileEntity()))) { if (insertItemStackIntoTileEntity(aSender, tSide)) return true; @@ -344,18 +343,19 @@ public boolean sendItemStack(Object aSender) { } @Override - public boolean insertItemStackIntoTileEntity(Object aSender, byte aSide) { - if (getBaseMetaTileEntity().getCoverInfoAtSide(aSide) + public boolean insertItemStackIntoTileEntity(Object aSender, ForgeDirection side) { + if (getBaseMetaTileEntity().getCoverInfoAtSide(side) .letsItemsOut(-1)) { - final TileEntity tInventory = getBaseMetaTileEntity().getTileEntityAtSide(aSide); + final TileEntity tInventory = getBaseMetaTileEntity().getTileEntityAtSide(side); if (tInventory != null && !(tInventory instanceof BaseMetaPipeEntity)) { if ((!(tInventory instanceof TileEntityHopper) && !(tInventory instanceof TileEntityDispenser)) - || getBaseMetaTileEntity().getMetaIDAtSide(aSide) != GT_Utility.getOppositeSide(aSide)) { + || getBaseMetaTileEntity().getMetaIDAtSide(side) != side.getOpposite() + .ordinal()) { return GT_Utility.moveMultipleItemStacks( aSender, tInventory, - (byte) 6, - GT_Utility.getOppositeSide(aSide), + ForgeDirection.UNKNOWN, + side.getOpposite(), null, false, (byte) 64, @@ -395,22 +395,23 @@ public int getStepSize() { } @Override - public boolean canInsertItem(int aIndex, ItemStack aStack, int aSide) { - return isConnectedAtSide(aSide) && super.canInsertItem(aIndex, aStack, aSide); + public boolean canInsertItem(int aIndex, ItemStack aStack, int ordinalSide) { + return isConnectedAtSide(ForgeDirection.getOrientation(ordinalSide)) + && super.canInsertItem(aIndex, aStack, ordinalSide); } @Override - public boolean canExtractItem(int aIndex, ItemStack aStack, int aSide) { - return isConnectedAtSide(aSide); + public boolean canExtractItem(int aIndex, ItemStack aStack, int ordinalSide) { + return isConnectedAtSide(ForgeDirection.getOrientation(ordinalSide)); } @Override - public int[] getAccessibleSlotsFromSide(int aSide) { + public int[] getAccessibleSlotsFromSide(int ordinalSide) { final IGregTechTileEntity tTileEntity = getBaseMetaTileEntity(); - final CoverInfo coverInfo = tTileEntity.getCoverInfoAtSide((byte) aSide); + final CoverInfo coverInfo = tTileEntity.getCoverInfoAtSide(ForgeDirection.getOrientation(ordinalSide)); final boolean tAllow = coverInfo.letsItemsIn(-2) || coverInfo.letsItemsOut(-2); if (tAllow) { - if (cacheSides == null) cacheSides = super.getAccessibleSlotsFromSide(aSide); + if (cacheSides == null) cacheSides = super.getAccessibleSlotsFromSide(ordinalSide); return cacheSides; } else { return GT_Values.emptyIntArray; @@ -418,15 +419,17 @@ public int[] getAccessibleSlotsFromSide(int aSide) { } @Override - public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return isConnectedAtSide(aSide); + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return isConnectedAtSide(side); } @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - if (!isConnectedAtSide(aSide)) return false; - if (isInventoryEmpty()) mLastReceivedFrom = aSide; - return mLastReceivedFrom == aSide && mInventory[aIndex] == null; + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + if (!isConnectedAtSide(side)) return false; + if (isInventoryEmpty()) mLastReceivedFrom = side; + return mLastReceivedFrom == side && mInventory[aIndex] == null; } @Override @@ -459,50 +462,55 @@ public AxisAlignedBB getCollisionBoundingBoxFromPool(World aWorld, int aX, int a else return getActualCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ); } - private AxisAlignedBB getActualCollisionBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ) { + private AxisAlignedBB getActualCollisionBoundingBoxFromPool(World ignoredAWorld, int aX, int aY, int aZ) { final float tSpace = (1f - mThickNess) / 2; - float tSide0 = tSpace; - float tSide1 = 1f - tSpace; - float tSide2 = tSpace; - float tSide3 = 1f - tSpace; - float tSide4 = tSpace; - float tSide5 = 1f - tSpace; - - if (getBaseMetaTileEntity().getCoverIDAtSide((byte) 0) != 0) { - tSide0 = tSide2 = tSide4 = 0; - tSide3 = tSide5 = 1; + float spaceDown = tSpace; + float spaceUp = 1f - tSpace; + float spaceNorth = tSpace; + float spaceSouth = 1f - tSpace; + float spaceWest = tSpace; + float spaceEast = 1f - tSpace; + + if (getBaseMetaTileEntity().getCoverIDAtSide(ForgeDirection.DOWN) != 0) { + spaceDown = spaceNorth = spaceWest = 0; + spaceSouth = spaceEast = 1; } - if (getBaseMetaTileEntity().getCoverIDAtSide((byte) 1) != 0) { - tSide2 = tSide4 = 0; - tSide1 = tSide3 = tSide5 = 1; + if (getBaseMetaTileEntity().getCoverIDAtSide(ForgeDirection.UP) != 0) { + spaceNorth = spaceWest = 0; + spaceUp = spaceSouth = spaceEast = 1; } - if (getBaseMetaTileEntity().getCoverIDAtSide((byte) 2) != 0) { - tSide0 = tSide2 = tSide4 = 0; - tSide1 = tSide5 = 1; + if (getBaseMetaTileEntity().getCoverIDAtSide(ForgeDirection.NORTH) != 0) { + spaceDown = spaceNorth = spaceWest = 0; + spaceUp = spaceEast = 1; } - if (getBaseMetaTileEntity().getCoverIDAtSide((byte) 3) != 0) { - tSide0 = tSide4 = 0; - tSide1 = tSide3 = tSide5 = 1; + if (getBaseMetaTileEntity().getCoverIDAtSide(ForgeDirection.SOUTH) != 0) { + spaceDown = spaceWest = 0; + spaceUp = spaceSouth = spaceEast = 1; } - if (getBaseMetaTileEntity().getCoverIDAtSide((byte) 4) != 0) { - tSide0 = tSide2 = tSide4 = 0; - tSide1 = tSide3 = 1; + if (getBaseMetaTileEntity().getCoverIDAtSide(ForgeDirection.WEST) != 0) { + spaceDown = spaceNorth = spaceWest = 0; + spaceUp = spaceSouth = 1; } - if (getBaseMetaTileEntity().getCoverIDAtSide((byte) 5) != 0) { - tSide0 = tSide2 = 0; - tSide1 = tSide3 = tSide5 = 1; + if (getBaseMetaTileEntity().getCoverIDAtSide(ForgeDirection.EAST) != 0) { + spaceDown = spaceNorth = 0; + spaceUp = spaceSouth = spaceEast = 1; } final byte tConn = ((BaseMetaPipeEntity) getBaseMetaTileEntity()).mConnections; - if ((tConn & (1 << ForgeDirection.DOWN.ordinal())) != 0) tSide0 = 0f; - if ((tConn & (1 << ForgeDirection.UP.ordinal())) != 0) tSide1 = 1f; - if ((tConn & (1 << ForgeDirection.NORTH.ordinal())) != 0) tSide2 = 0f; - if ((tConn & (1 << ForgeDirection.SOUTH.ordinal())) != 0) tSide3 = 1f; - if ((tConn & (1 << ForgeDirection.WEST.ordinal())) != 0) tSide4 = 0f; - if ((tConn & (1 << ForgeDirection.EAST.ordinal())) != 0) tSide5 = 1f; - - return AxisAlignedBB - .getBoundingBox(aX + tSide4, aY + tSide0, aZ + tSide2, aX + tSide5, aY + tSide1, aZ + tSide3); + if ((tConn & (1 << ForgeDirection.DOWN.ordinal())) != 0) spaceDown = 0f; + if ((tConn & (1 << ForgeDirection.UP.ordinal())) != 0) spaceUp = 1f; + if ((tConn & (1 << ForgeDirection.NORTH.ordinal())) != 0) spaceNorth = 0f; + if ((tConn & (1 << ForgeDirection.SOUTH.ordinal())) != 0) spaceSouth = 1f; + if ((tConn & (1 << ForgeDirection.WEST.ordinal())) != 0) spaceWest = 0f; + if ((tConn & (1 << ForgeDirection.EAST.ordinal())) != 0) spaceEast = 1f; + + return AxisAlignedBB.getBoundingBox( + aX + spaceWest, + aY + spaceDown, + aZ + spaceNorth, + aX + spaceEast, + aY + spaceUp, + aZ + spaceSouth); } @Override diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicBatteryBuffer.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicBatteryBuffer.java index ad6a7308635..a72ec19d791 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicBatteryBuffer.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicBatteryBuffer.java @@ -15,6 +15,7 @@ import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; import com.gtnewhorizons.modularui.api.screen.ModularWindow; import com.gtnewhorizons.modularui.api.screen.UIBuildContext; @@ -84,9 +85,9 @@ public ITexture[][][] getTextureSet(ITexture[] aTextures) { } @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, - boolean aActive, boolean aRedstone) { - return mTextures[aSide == aFacing ? 1 : 0][aColorIndex + 1]; + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection aFacing, + int colorIndex, boolean aActive, boolean redstoneLevel) { + return mTextures[side == aFacing ? 1 : 0][colorIndex + 1]; } @Override @@ -110,7 +111,7 @@ public boolean isValidSlot(int aIndex) { } @Override - public boolean isFacingValid(byte aFacing) { + public boolean isFacingValid(ForgeDirection facing) { return true; } @@ -125,13 +126,13 @@ public boolean isEnetOutput() { } @Override - public boolean isInputFacing(byte aSide) { - return aSide != getBaseMetaTileEntity().getFrontFacing(); + public boolean isInputFacing(ForgeDirection side) { + return side != getBaseMetaTileEntity().getFrontFacing(); } @Override - public boolean isOutputFacing(byte aSide) { - return aSide == getBaseMetaTileEntity().getFrontFacing(); + public boolean isOutputFacing(ForgeDirection side) { + return side == getBaseMetaTileEntity().getFrontFacing(); } @Override @@ -236,7 +237,8 @@ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { } @Override - public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { if (GT_ModHandler.isElectricItem(aStack) && aStack.getUnlocalizedName() .startsWith("gt.metaitem.01.")) { String name = aStack.getUnlocalizedName(); @@ -254,7 +256,8 @@ public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aInde } @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { if (!GT_Utility.isStackValid(aStack)) { return false; } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicGenerator.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicGenerator.java index ef7242b420f..0a589d69191 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicGenerator.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicGenerator.java @@ -5,6 +5,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.IFluidContainerItem; import net.minecraftforge.fluids.IFluidHandler; @@ -61,10 +62,11 @@ public ITexture[][][] getTextureSet(ITexture[] aTextures) { } @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, - boolean aActive, boolean aRedstone) { - return mTextures[(aActive ? 5 : 0) + (aSide == aFacing ? 0 - : aSide == GT_Utility.getOppositeSide(aFacing) ? 1 : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][aColorIndex + 1]; + public ITexture[] getTexture(IGregTechTileEntity baseMetaTileEntity, ForgeDirection side, + ForgeDirection facingDirection, int colorIndex, boolean active, boolean redstoneLevel) { + return mTextures[(active ? 5 : 0) + (side == facingDirection ? 0 + : side == facingDirection.getOpposite() ? 1 + : side == ForgeDirection.DOWN ? 2 : side == ForgeDirection.UP ? 3 : 4)][colorIndex + 1]; } @Override @@ -122,7 +124,7 @@ public ITexture[] getSidesActive(byte aColor) { } @Override - public boolean isFacingValid(byte aSide) { + public boolean isFacingValid(ForgeDirection side) { return true; } @@ -142,7 +144,7 @@ public boolean isEnetOutput() { } @Override - public boolean isOutputFacing(byte aSide) { + public boolean isOutputFacing(ForgeDirection side) { return true; } @@ -198,7 +200,7 @@ public boolean isFluidInputAllowed(FluidStack aFluid) { } @Override - public boolean isLiquidOutput(byte aSide) { + public boolean isLiquidOutput(ForgeDirection side) { // return super.isLiquidOutput(aSide); return false; } @@ -330,8 +332,9 @@ public ItemStack getEmptyContainer(ItemStack aStack) { } @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return super.allowPutStack(aBaseMetaTileEntity, aIndex, aSide, aStack) && (getFuelValue(aStack, true) > 0 + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return super.allowPutStack(aBaseMetaTileEntity, aIndex, side, aStack) && (getFuelValue(aStack, true) > 0 || getFuelValue(GT_Utility.getFluidForFilledItem(aStack, true), true) > 0); } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicHull.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicHull.java index ff1365a7354..e5766eee399 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicHull.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicHull.java @@ -4,6 +4,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; @@ -58,13 +59,13 @@ public boolean isAccessAllowed(EntityPlayer aPlayer) { } @Override - public boolean isInputFacing(byte aSide) { - return !isOutputFacing(aSide); + public boolean isInputFacing(ForgeDirection side) { + return !isOutputFacing(side); } @Override - public boolean isOutputFacing(byte aSide) { - return aSide == getBaseMetaTileEntity().getFrontFacing(); + public boolean isOutputFacing(ForgeDirection side) { + return side == getBaseMetaTileEntity().getFrontFacing(); } @Override @@ -93,7 +94,7 @@ public boolean isSimpleMachine() { } @Override - public boolean isFacingValid(byte aFacing) { + public boolean isFacingValid(ForgeDirection facing) { return true; } @@ -103,19 +104,21 @@ public boolean isValidSlot(int aIndex) { } @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { return true; } @Override - public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { return true; } @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, - boolean aConnected, boolean aRedstone) { - return mTextures[Math.min(2, aSide) + (aSide == aFacing ? 3 : 0)][aColorIndex + 1]; + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection aFacing, + int colorIndex, boolean aConnected, boolean redstoneLevel) { + return mTextures[Math.min(2, side.ordinal()) + (side == aFacing ? 3 : 0)][colorIndex + 1]; } @Override diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicHull_NonElectric.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicHull_NonElectric.java index c9b66e6bafb..b6584b50ab1 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicHull_NonElectric.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicHull_NonElectric.java @@ -1,5 +1,7 @@ package gregtech.api.metatileentity.implementations; +import net.minecraftforge.common.util.ForgeDirection; + import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; @@ -21,9 +23,9 @@ public GT_MetaTileEntity_BasicHull_NonElectric(String aName, int aTier, String[] } @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aConnections, - byte aColorIndex, boolean aConnected, boolean aRedstone) { - return mTextures[Math.min(2, aSide)][aColorIndex + 1]; + public ITexture[] getTexture(IGregTechTileEntity baseMetaTileEntity, ForgeDirection sideDirection, + ForgeDirection facingDirection, int colorIndex, boolean active, boolean redstoneLevel) { + return mTextures[Math.min(2, sideDirection.ordinal())][colorIndex + 1]; } @Override @@ -42,12 +44,12 @@ public boolean isEnetOutput() { } @Override - public boolean isInputFacing(byte aSide) { + public boolean isInputFacing(ForgeDirection side) { return false; } @Override - public boolean isOutputFacing(byte aSide) { + public boolean isOutputFacing(ForgeDirection side) { return false; } 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 4868200bf13..b798c8cfefe 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 @@ -1,6 +1,5 @@ package gregtech.api.metatileentity.implementations; -import static gregtech.api.enums.GT_Values.ALL_VALID_SIDES; import static gregtech.api.enums.GT_Values.V; import static gregtech.api.enums.GT_Values.debugCleanroom; import static gregtech.api.enums.Textures.BlockIcons.MACHINE_CASINGS; @@ -102,7 +101,8 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B mHasBeenUpdated = false, mStuttering = false, mCharge = false, mDecharge = false; public boolean mDisableFilter = true; public boolean mDisableMultiStack = true; - public int mMainFacing = -1, mProgresstime = 0, mMaxProgresstime = 0, mEUt = 0, mOutputBlocked = 0; + public int mProgresstime = 0, mMaxProgresstime = 0, mEUt = 0, mOutputBlocked = 0; + public ForgeDirection mMainFacing = ForgeDirection.UNKNOWN; public FluidStack mOutputFluid; public String mGUIName, mNEIName; protected final Power mPower; @@ -190,15 +190,15 @@ protected Power buildPower() { return new BasicMachineEUPower(mTier, mAmperage); } - protected boolean isValidMainFacing(byte aSide) { - return aSide > 1; + protected boolean isValidMainFacing(ForgeDirection side) { + return side.offsetY == 0; // Neither DOWN nor UP } - public boolean setMainFacing(byte aSide) { - if (!isValidMainFacing(aSide)) return false; - mMainFacing = aSide; + public boolean setMainFacing(ForgeDirection side) { + if (!isValidMainFacing(side)) return false; + mMainFacing = side; if (getBaseMetaTileEntity().getFrontFacing() == mMainFacing) { - getBaseMetaTileEntity().setFrontFacing(GT_Utility.getOppositeSide(aSide)); + getBaseMetaTileEntity().setFrontFacing(side.getOpposite()); } onFacingChange(); onMachineBlockUpdate(); @@ -235,39 +235,39 @@ public ITexture[][][] getTextureSet(ITexture[] aTextures) { } @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, - boolean aActive, boolean aRedstone) { + public ITexture[] getTexture(IGregTechTileEntity baseMetaTileEntity, ForgeDirection sideDirection, + ForgeDirection facingDirection, int colorIndex, boolean active, boolean redstoneLevel) { final int textureIndex; - if (mMainFacing < 2) { - if (aSide == aFacing) { - textureIndex = aActive ? 2 : 3; + if (mMainFacing.offsetY != 0) { // UP or DOWN + if (sideDirection == facingDirection) { + textureIndex = active ? 2 : 3; } else { - textureIndex = switch (aSide) { - case 0 -> aActive ? 6 : 7; - case 1 -> aActive ? 4 : 5; - default -> aActive ? 0 : 1; + textureIndex = switch (sideDirection) { + case DOWN -> active ? 6 : 7; + case UP -> active ? 4 : 5; + default -> active ? 0 : 1; }; } } else { - if (aSide == mMainFacing) { - textureIndex = aActive ? 2 : 3; + if (sideDirection == mMainFacing) { + textureIndex = active ? 2 : 3; } else { - if (showPipeFacing() && aSide == aFacing) { - textureIndex = switch (aSide) { - case 0 -> aActive ? 8 : 9; - case 1 -> aActive ? 10 : 11; - default -> aActive ? 12 : 13; + if (showPipeFacing() && sideDirection == facingDirection) { + textureIndex = switch (sideDirection) { + case DOWN -> active ? 8 : 9; + case UP -> active ? 10 : 11; + default -> active ? 12 : 13; }; } else { - textureIndex = switch (aSide) { - case 0 -> aActive ? 6 : 7; - case 1 -> aActive ? 4 : 5; - default -> aActive ? 0 : 1; + textureIndex = switch (sideDirection) { + case DOWN -> active ? 6 : 7; + case UP -> active ? 4 : 5; + default -> active ? 0 : 1; }; } } } - return mTextures[textureIndex][aColorIndex + 1]; + return mTextures[textureIndex][colorIndex + 1]; } @Override @@ -298,8 +298,8 @@ public boolean isValidSlot(int aIndex) { } @Override - public boolean isFacingValid(byte aFacing) { - return mMainFacing > 1 || aFacing > 1; + public boolean isFacingValid(ForgeDirection facing) { + return facing.offsetY == 0 || facing.offsetY == 0; } @Override @@ -308,12 +308,12 @@ public boolean isEnetInput() { } @Override - public boolean isInputFacing(byte aSide) { - return aSide != mMainFacing; + public boolean isInputFacing(ForgeDirection side) { + return side != mMainFacing; } @Override - public boolean isOutputFacing(byte aSide) { + public boolean isOutputFacing(ForgeDirection side) { return false; } @@ -323,13 +323,13 @@ public boolean isTeleporterCompatible() { } @Override - public boolean isLiquidInput(byte aSide) { - return aSide != mMainFacing && (mAllowInputFromOutputSide || aSide != getBaseMetaTileEntity().getFrontFacing()); + public boolean isLiquidInput(ForgeDirection side) { + return side != mMainFacing && (mAllowInputFromOutputSide || side != getBaseMetaTileEntity().getFrontFacing()); } @Override - public boolean isLiquidOutput(byte aSide) { - return aSide != mMainFacing; + public boolean isLiquidOutput(ForgeDirection side) { + return side != mMainFacing; } @Override @@ -490,8 +490,8 @@ public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlaye } return true; } - for (byte tSide : ALL_VALID_SIDES) { - if (aBaseMetaTileEntity.getAirAtSide(tSide)) { + for (final ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + if (aBaseMetaTileEntity.getAirAtSide(side)) { if (useModularUI()) { GT_UIInfos.openGTTileEntityUI(aBaseMetaTileEntity, aPlayer); } else { @@ -524,7 +524,7 @@ public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechT @Override public void initDefaultModes(NBTTagCompound aNBT) { - mMainFacing = -1; + mMainFacing = ForgeDirection.UNKNOWN; if (!getBaseMetaTileEntity().getWorld().isRemote) { GT_ClientPreference tPreference = GT_Mod.gregtechproxy .getClientPreference(getBaseMetaTileEntity().getOwnerUuid()); @@ -545,7 +545,7 @@ public void saveNBTData(NBTTagCompound aNBT) { aNBT.setBoolean("mDisableFilter", mDisableFilter); aNBT.setBoolean("mDisableMultiStack", mDisableMultiStack); aNBT.setInteger("mEUt", mEUt); - aNBT.setInteger("mMainFacing", mMainFacing); + aNBT.setInteger("mMainFacing", mMainFacing.ordinal()); aNBT.setInteger("mProgresstime", mProgresstime); aNBT.setInteger("mMaxProgresstime", mMaxProgresstime); if (mOutputFluid != null) aNBT.setTag("mOutputFluid", mOutputFluid.writeToNBT(new NBTTagCompound())); @@ -565,7 +565,7 @@ public void loadNBTData(NBTTagCompound aNBT) { mDisableFilter = aNBT.getBoolean("mDisableFilter"); mDisableMultiStack = aNBT.getBoolean("mDisableMultiStack"); mEUt = aNBT.getInteger("mEUt"); - mMainFacing = aNBT.getInteger("mMainFacing"); + mMainFacing = ForgeDirection.getOrientation(aNBT.getInteger("mMainFacing")); mProgresstime = aNBT.getInteger("mProgresstime"); mMaxProgresstime = aNBT.getInteger("mMaxProgresstime"); mOutputFluid = FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag("mOutputFluid")); @@ -634,12 +634,9 @@ else if (mOutputFluid.isFluidEqual(getDrainableStack())) if (tTank != null) { FluidStack tDrained = drain(1000, false); if (tDrained != null) { - int tFilledAmount = tTank - .fill(ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()), tDrained, false); - if (tFilledAmount > 0) tTank.fill( - ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()), - drain(tFilledAmount, true), - true); + final int tFilledAmount = tTank.fill(aBaseMetaTileEntity.getBackFacing(), tDrained, false); + if (tFilledAmount > 0) + tTank.fill(aBaseMetaTileEntity.getBackFacing(), drain(tFilledAmount, true), true); } } if (getDrainableStack() == null) tRemovedOutputFluid = true; @@ -726,10 +723,10 @@ && hasEnoughEnergyToCheckRecipe()) { } protected void doDisplayThings() { - if (mMainFacing < 2 && getBaseMetaTileEntity().getFrontFacing() > 1) { + if (mMainFacing.offsetY != 0 && getBaseMetaTileEntity().getFrontFacing().offsetY == 0) { mMainFacing = getBaseMetaTileEntity().getFrontFacing(); } - if (mMainFacing >= 2 && !mHasBeenUpdated) { + if (mMainFacing.offsetY == 0 && !mHasBeenUpdated) { mHasBeenUpdated = true; getBaseMetaTileEntity().setFrontFacing(getBaseMetaTileEntity().getBackFacing()); } @@ -852,12 +849,12 @@ protected boolean displaysOutputFluid() { @Override public void onValueUpdate(byte aValue) { - mMainFacing = aValue; + mMainFacing = ForgeDirection.getOrientation(aValue); } @Override public byte getUpdateData() { - return (byte) mMainFacing; + return (byte) mMainFacing.ordinal(); } @Override @@ -955,8 +952,8 @@ public boolean isGivingInformation() { } @Override - public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { - if (aSide == getBaseMetaTileEntity().getFrontFacing() || aSide == mMainFacing) { + public void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (side == getBaseMetaTileEntity().getFrontFacing() || side == mMainFacing) { if (aPlayer.isSneaking()) { mDisableFilter = !mDisableFilter; GT_Utility.sendChatToPlayer( @@ -973,44 +970,46 @@ public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, } @Override - public boolean onSolderingToolRightClick(byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, - float aZ) { - if (!aPlayer.isSneaking()) return false; - boolean click = super.onSolderingToolRightClick(aSide, aWrenchingSide, aPlayer, aX, aY, aZ); + public boolean onSolderingToolRightClick(ForgeDirection side, ForgeDirection wrenchingSide, + EntityPlayer entityPlayer, float aX, float aY, float aZ) { + if (!entityPlayer.isSneaking()) return false; + final boolean click = super.onSolderingToolRightClick(side, wrenchingSide, entityPlayer, aX, aY, aZ); if (click) return true; - if (aWrenchingSide != mMainFacing) return false; + if (wrenchingSide != mMainFacing) return false; mDisableMultiStack = !mDisableMultiStack; GT_Utility.sendChatToPlayer( - aPlayer, + entityPlayer, StatCollector.translateToLocal("GT5U.hatch.disableMultiStack." + mDisableMultiStack)); return true; } @Override - public boolean allowCoverOnSide(byte aSide, GT_ItemStack aCoverID) { - if (aSide != mMainFacing) return true; + public boolean allowCoverOnSide(ForgeDirection side, GT_ItemStack aCoverID) { + if (side != mMainFacing) return true; GT_CoverBehaviorBase tBehavior = GregTech_API.getCoverBehaviorNew(aCoverID.toStack()); return tBehavior.isGUIClickable( - aSide, + side, GT_Utility.stackToInt(aCoverID.toStack()), tBehavior.createDataObject(), getBaseMetaTileEntity()); } @Override - public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return aSide != mMainFacing && aIndex >= getOutputSlot() && aIndex < getOutputSlot() + mOutputItems.length; + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return side != mMainFacing && aIndex >= getOutputSlot() && aIndex < getOutputSlot() + mOutputItems.length; } @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - if (aSide == mMainFacing || aIndex < getInputSlot() + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + if (side == mMainFacing || aIndex < getInputSlot() || aIndex >= getInputSlot() + mInputSlotCount - || (!mAllowInputFromOutputSide && aSide == aBaseMetaTileEntity.getFrontFacing())) return false; + || (!mAllowInputFromOutputSide && side == aBaseMetaTileEntity.getFrontFacing())) return false; for (int i = getInputSlot(), j = i + mInputSlotCount; i < j; i++) if (GT_Utility.areStacksEqual(GT_OreDictUnificator.get(aStack), mInventory[i]) && mDisableMultiStack) return i == aIndex; - return mDisableFilter || allowPutStackValidated(aBaseMetaTileEntity, aIndex, aSide, aStack); + return mDisableFilter || allowPutStackValidated(aBaseMetaTileEntity, aIndex, side, aStack); } /** @@ -1018,7 +1017,7 @@ public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex * method it is ensured there is no such kind of item inside any input slots already. Otherwise, you don't need to * check for it anyway. */ - protected boolean allowPutStackValidated(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, + protected boolean allowPutStackValidated(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, ItemStack aStack) { return !mDisableMultiStack || mInventory[aIndex] == null; } @@ -1265,13 +1264,16 @@ public void getWailaNBTData(EntityPlayerMP player, TileEntity tile, NBTTagCompou tag.setInteger("progressSingleBlock", mProgresstime); tag.setInteger("maxProgressSingleBlock", mMaxProgresstime); - tag.setInteger("mainFacingSingleBlock", mMainFacing); + tag.setInteger("mainFacingSingleBlock", mMainFacing.ordinal()); tag.setBoolean("stutteringSingleBlock", mStuttering); - IGregTechTileEntity tileEntity = getBaseMetaTileEntity(); + final IGregTechTileEntity tileEntity = getBaseMetaTileEntity(); if (tileEntity != null) { tag.setBoolean("isActiveSingleBlock", tileEntity.isActive()); - tag.setInteger("outputFacingSingleBlock", tileEntity.getFrontFacing()); + tag.setInteger( + "outputFacingSingleBlock", + tileEntity.getFrontFacing() + .ordinal()); if (tileEntity.isActive()) tag.setInteger("eut", mEUt); } } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_Bronze.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_Bronze.java index 38fce536582..2ea4b258606 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_Bronze.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_Bronze.java @@ -100,7 +100,7 @@ public boolean isEnetInput() { } @Override - public boolean isInputFacing(byte aSide) { + public boolean isInputFacing(ForgeDirection side) { return false; } @@ -130,8 +130,8 @@ public boolean isSteampowered() { } @Override - public boolean isFacingValid(byte aFacing) { - return super.isFacingValid(aFacing) && aFacing != mMainFacing; + public boolean isFacingValid(ForgeDirection facing) { + return super.isFacingValid(facing) && facing != mMainFacing; } @Override @@ -145,13 +145,13 @@ public long maxSteamStore() { } @Override - public boolean isLiquidInput(byte aSide) { - return aSide != mMainFacing; + public boolean isLiquidInput(ForgeDirection side) { + return side != mMainFacing; } @Override - public boolean isLiquidOutput(byte aSide) { - return aSide != mMainFacing; + public boolean isLiquidOutput(ForgeDirection side) { + return side != mMainFacing; } @Override @@ -224,9 +224,9 @@ public void doSound(byte aIndex, double aX, double aY, double aZ) { new ParticleEventBuilder().setIdentifier(ParticleFX.CLOUD) .setWorld(getBaseMetaTileEntity().getWorld()) .setMotion( - ForgeDirection.getOrientation(getBaseMetaTileEntity().getFrontFacing()).offsetX / 5.0, - ForgeDirection.getOrientation(getBaseMetaTileEntity().getFrontFacing()).offsetY / 5.0, - ForgeDirection.getOrientation(getBaseMetaTileEntity().getFrontFacing()).offsetZ / 5.0) + getBaseMetaTileEntity().getFrontFacing().offsetX / 5.0, + getBaseMetaTileEntity().getFrontFacing().offsetY / 5.0, + getBaseMetaTileEntity().getFrontFacing().offsetZ / 5.0) .times( 8, x -> x @@ -244,9 +244,9 @@ public boolean isGivingInformation() { } @Override - public boolean allowCoverOnSide(byte aSide, GT_ItemStack aCoverID) { + public boolean allowCoverOnSide(ForgeDirection side, GT_ItemStack aCoverID) { return GregTech_API.getCoverBehaviorNew(aCoverID.toStack()) - .isSimpleCover() && super.allowCoverOnSide(aSide, aCoverID); + .isSimpleCover() && super.allowCoverOnSide(side, aCoverID); } public float getSteamDamage() { diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_GT_Recipe.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_GT_Recipe.java index a80e235a655..2d4b080093c 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_GT_Recipe.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_GT_Recipe.java @@ -7,6 +7,7 @@ import static gregtech.api.enums.Mods.BartWorks; import static gregtech.api.enums.Mods.GregTech; import static gregtech.api.objects.XSTR.XSTR_INSTANCE; +import static net.minecraftforge.common.util.ForgeDirection.UP; import java.util.Locale; @@ -559,9 +560,9 @@ public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechT } @Override - protected boolean allowPutStackValidated(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, + protected boolean allowPutStackValidated(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, ItemStack aStack) { - if (!super.allowPutStackValidated(aBaseMetaTileEntity, aIndex, aSide, aStack)) return false; + if (!super.allowPutStackValidated(aBaseMetaTileEntity, aIndex, side, aStack)) return false; switch (this.mInputSlotCount) { case 0 -> { return false; @@ -636,10 +637,8 @@ public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { // noinspection SwitchStatementWithTooFewBranches switch (this.mSpecialEffect) { case TOP_SMOKE -> { - final byte topFacing = (byte) ForgeDirection.UP.ordinal(); - if (aBaseMetaTileEntity.getFrontFacing() != topFacing - && aBaseMetaTileEntity.getCoverIDAtSide(topFacing) == 0 - && !aBaseMetaTileEntity.getOpacityAtSide(topFacing)) { + if (aBaseMetaTileEntity.getFrontFacing() != UP && aBaseMetaTileEntity.getCoverIDAtSide(UP) == 0 + && !aBaseMetaTileEntity.getOpacityAtSide(UP)) { new ParticleEventBuilder().setMotion(0.0D, 0.0D, 0.0D) .setIdentifier(ParticleFX.SMOKE) @@ -671,9 +670,9 @@ public void onRandomDisplayTick(IGregTechTileEntity aBaseMetaTileEntity) { // Random Sparkles at main face if (aBaseMetaTileEntity.isActive() && XSTR_INSTANCE.nextInt(3) == 0) { - final byte mainFacing = (byte) this.mMainFacing; + final ForgeDirection mainFacing = this.mMainFacing; - if (mainFacing > 1 && aBaseMetaTileEntity.getCoverIDAtSide(mainFacing) == 0 + if (mainFacing.ordinal() > 1 && aBaseMetaTileEntity.getCoverIDAtSide(mainFacing) == 0 && !aBaseMetaTileEntity.getOpacityAtSide(mainFacing)) { final double oX = aBaseMetaTileEntity.getXCoord(); @@ -686,17 +685,17 @@ public void onRandomDisplayTick(IGregTechTileEntity aBaseMetaTileEntity) { y = oY + XSTR_INSTANCE.nextFloat() * 10D / 16D + 5D / 16D; - if (mainFacing == ForgeDirection.WEST.ordinal()) { + if (mainFacing == ForgeDirection.WEST) { x = oX - offset; mX = -.05D; z = oZ + horizontal; mZ = 0D; - } else if (mainFacing == ForgeDirection.EAST.ordinal()) { + } else if (mainFacing == ForgeDirection.EAST) { x = oX + offset; mX = .05D; z = oZ + horizontal; mZ = 0D; - } else if (mainFacing == ForgeDirection.NORTH.ordinal()) { + } else if (mainFacing == ForgeDirection.NORTH) { x = oX + horizontal; mX = 0D; z = oZ - offset; diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicTank.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicTank.java index 7d4723d4f61..f3a0af38f52 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicTank.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicTank.java @@ -308,7 +308,7 @@ public FluidStack drain(int maxDrain, boolean doDrain) { } @Override - public FluidTankInfo[] getTankInfo(ForgeDirection aSide) { + public FluidTankInfo[] getTankInfo(ForgeDirection side) { if (getCapacity() <= 0 && !getBaseMetaTileEntity().hasSteamEngineUpgrade()) return new FluidTankInfo[] {}; if (isDrainableStackSeparate()) { return new FluidTankInfo[] { new FluidTankInfo(getFillableStack(), getCapacity()), @@ -319,12 +319,14 @@ public FluidTankInfo[] getTankInfo(ForgeDirection aSide) { } @Override - public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { return aIndex == getOutputSlot(); } @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { return aIndex == getInputSlot(); } 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 f7f69ae9240..cf1ba436e11 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 @@ -4,6 +4,7 @@ import static gregtech.api.enums.Textures.BlockIcons.*; import java.util.*; +import java.util.stream.IntStream; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -97,14 +98,12 @@ public ITexture[][][] getTextureSet(ITexture[] aTextures) { } @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, - boolean aActive, boolean aRedstone) { - 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) { + public ITexture[] getTexture(IGregTechTileEntity baseMetaTileEntity, ForgeDirection sideDirection, + ForgeDirection facingDirection, int colorIndex, boolean active, boolean redstoneLevel) { + colorIndex = colorIndex + 1; + if (sideDirection == facingDirection) return mTextures[FRONT_INDEX][colorIndex]; + if (sideDirection.getOpposite() == facingDirection) return mTextures[OUTPUT_INDEX][colorIndex]; + switch (facingDirection) { case DOWN -> { return mTextures[ARROW_UP_INDEX][colorIndex]; // ARROW_UP } @@ -112,7 +111,7 @@ public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide return mTextures[ARROW_DOWN_INDEX][colorIndex]; // ARROW_DOWN } case NORTH -> { - switch (side) { + switch (sideDirection) { case DOWN, UP -> { return mTextures[ARROW_DOWN_INDEX][colorIndex]; // ARROW_DOWN } @@ -126,7 +125,7 @@ public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide } } case SOUTH -> { - switch (side) { + switch (sideDirection) { case DOWN, UP -> { return mTextures[ARROW_UP_INDEX][colorIndex]; // ARROW_UP } @@ -140,7 +139,7 @@ public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide } } case WEST -> { - switch (side) { + switch (sideDirection) { case UP, SOUTH -> { return mTextures[ARROW_RIGHT_INDEX][colorIndex]; // ARROW_RIGHT } @@ -151,7 +150,7 @@ public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide } } case EAST -> { - switch (side) { + switch (sideDirection) { case UP, SOUTH -> { return mTextures[ARROW_LEFT_INDEX][colorIndex]; // ARROW_LEFT } @@ -177,7 +176,7 @@ public boolean isValidSlot(int aIndex) { } @Override - public boolean isFacingValid(byte aFacing) { + public boolean isFacingValid(ForgeDirection facing) { return true; } @@ -192,13 +191,13 @@ public boolean isEnetOutput() { } @Override - public boolean isInputFacing(byte aSide) { - return !isOutputFacing(aSide); + public boolean isInputFacing(ForgeDirection side) { + return !isOutputFacing(side); } @Override - public boolean isOutputFacing(byte aSide) { - return getBaseMetaTileEntity().getBackFacing() == aSide; + public boolean isOutputFacing(ForgeDirection side) { + return getBaseMetaTileEntity().getBackFacing() == side; } @Override @@ -281,8 +280,8 @@ public void setItemNBT(NBTTagCompound aNBT) { } @Override - public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { - if (aSide == getBaseMetaTileEntity().getBackFacing()) { + public void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (side == getBaseMetaTileEntity().getBackFacing()) { mTargetStackSize = (byte) ((mTargetStackSize + (aPlayer.isSneaking() ? -1 : 1)) % 65); if (mTargetStackSize < 0) { @@ -299,11 +298,11 @@ public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, } @Override - public boolean onWrenchRightClick(byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, - float aZ) { - aWrenchingSide = GT_Utility.getOppositeSide(aWrenchingSide); - if (getBaseMetaTileEntity().isValidFacing(aWrenchingSide)) { - getBaseMetaTileEntity().setFrontFacing(aWrenchingSide); + public boolean onWrenchRightClick(ForgeDirection side, ForgeDirection wrenchingSide, EntityPlayer entityPlayer, + float aX, float aY, float aZ) { + wrenchingSide = wrenchingSide.getOpposite(); + if (getBaseMetaTileEntity().isValidFacing(wrenchingSide)) { + getBaseMetaTileEntity().setFrontFacing(wrenchingSide); return true; } return false; @@ -311,18 +310,15 @@ public boolean onWrenchRightClick(byte aSide, byte aWrenchingSide, EntityPlayer protected void handleRedstoneOutput(IGregTechTileEntity aBaseMetaTileEntity) { if (bRedstoneIfFull) { - boolean hasEmptySlots = false; - for (int i = 0; i < mInventory.length; i++) { - if (isValidSlot(i) && mInventory[i] == null) { - hasEmptySlots = true; - break; - } - } - if (bInvert) hasEmptySlots = !hasEmptySlots; - for (byte b = 0; b < 6; b++) - aBaseMetaTileEntity.setInternalOutputRedstoneSignal(b, hasEmptySlots ? (byte) 0 : (byte) 15); + final boolean hasEmptySlots = IntStream.range(0, mInventory.length) + .anyMatch(i -> isValidSlot(i) && mInventory[i] == null); + Arrays.stream(ForgeDirection.VALID_DIRECTIONS) + .forEach( + side -> aBaseMetaTileEntity + .setInternalOutputRedstoneSignal(side, (byte) (bInvert ^ hasEmptySlots ? 0 : 15))); } else { - for (byte b = 0; b < 6; b++) aBaseMetaTileEntity.setInternalOutputRedstoneSignal(b, (byte) 0); + for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) + aBaseMetaTileEntity.setInternalOutputRedstoneSignal(side, (byte) 0); } } @@ -341,14 +337,15 @@ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { @Override public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) { - for (byte b = 0; b < 6; b++) aBaseMetaTileEntity.setInternalOutputRedstoneSignal(b, (byte) 0); + for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) + aBaseMetaTileEntity.setInternalOutputRedstoneSignal(side, (byte) 0); } protected void moveItems(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { moveItems(aBaseMetaTileEntity, aTimer, 1); } - protected void moveItems(IGregTechTileEntity aBaseMetaTileEntity, long aTimer, int stacks) { + protected void moveItems(IGregTechTileEntity aBaseMetaTileEntity, long ignoredTimer, int stacks) { int tCost; if (bStockingMode) tCost = GT_Utility.moveMultipleItemStacks( aBaseMetaTileEntity, @@ -381,13 +378,15 @@ protected void moveItems(IGregTechTileEntity aBaseMetaTileEntity, long aTimer, i } @Override - public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { return true; } @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return aSide != aBaseMetaTileEntity.getBackFacing(); + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return side != aBaseMetaTileEntity.getBackFacing(); } @Override @@ -432,18 +431,18 @@ protected void fillStacksIntoFirstSlots() { } @Override - public boolean onSolderingToolRightClick(byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, - float aZ) { - if (aPlayer.isSneaking()) { + public boolean onSolderingToolRightClick(ForgeDirection side, ForgeDirection wrenchingSide, + EntityPlayer entityPlayer, float aX, float aY, float aZ) { + if (entityPlayer.isSneaking()) { // I was so proud of all this but I literally just copied code from OutputBus bSortStacks = !bSortStacks; GT_Utility.sendChatToPlayer( - aPlayer, + entityPlayer, GT_Utility.trans("200", "Sort mode: ") + (bSortStacks ? GT_Utility.trans("088", "Enabled") : GT_Utility.trans("087", "Disabled"))); return true; } - return super.onSolderingToolRightClick(aSide, aWrenchingSide, aPlayer, aX, aY, aZ); + return super.onSolderingToolRightClick(side, wrenchingSide, entityPlayer, aX, aY, aZ); } @Override diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java index 6fdfa53a145..9fac4a880cc 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java @@ -76,16 +76,16 @@ public void setExtendedFacing(ExtendedFacing newExtendedFacing) { } @Override - public final boolean isFacingValid(byte aFacing) { - return canSetToDirectionAny(ForgeDirection.getOrientation(aFacing)); + public final boolean isFacingValid(ForgeDirection facing) { + return canSetToDirectionAny(facing); } @Override - public boolean onWrenchRightClick(byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, - float aZ) { - if (aWrenchingSide != getBaseMetaTileEntity().getFrontFacing()) - return super.onWrenchRightClick(aSide, aWrenchingSide, aPlayer, aX, aY, aZ); - if (aPlayer.isSneaking()) { + public boolean onWrenchRightClick(ForgeDirection side, ForgeDirection wrenchingSide, EntityPlayer entityPlayer, + float aX, float aY, float aZ) { + if (wrenchingSide != getBaseMetaTileEntity().getFrontFacing()) + return super.onWrenchRightClick(side, wrenchingSide, entityPlayer, aX, aY, aZ); + if (entityPlayer.isSneaking()) { // we won't be allowing horizontal flips, as it can be perfectly emulated by rotating twice and flipping // horizontally // allowing an extra round of flip make it hard to draw meaningful flip markers in GT_Proxy#drawGrid @@ -98,7 +98,7 @@ public boolean onWrenchRightClick(byte aSide, byte aWrenchingSide, EntityPlayer @Override public void onFacingChange() { - toolSetDirection(ForgeDirection.getOrientation(getBaseMetaTileEntity().getFrontFacing())); + toolSetDirection(getBaseMetaTileEntity().getFrontFacing()); } @Override @@ -145,7 +145,7 @@ public void saveNBTData(NBTTagCompound aNBT) { public void loadNBTData(NBTTagCompound aNBT) { super.loadNBTData(aNBT); mExtendedFacing = ExtendedFacing.of( - ForgeDirection.getOrientation(getBaseMetaTileEntity().getFrontFacing()), + getBaseMetaTileEntity().getFrontFacing(), Rotation.byIndex(aNBT.getByte("eRotation")), Flip.byIndex(aNBT.getByte("eFlip"))); } @@ -157,14 +157,14 @@ private IStructureDefinition> getCas /** * Explanation of the world coordinate these offset means: - * + *

* Imagine you stand in front of the controller, with controller facing towards you not rotated or flipped. - * + *

* The horizontalOffset would be the number of blocks on the left side of the controller, not counting controller * itself. The verticalOffset would be the number of blocks on the top side of the controller, not counting * controller itself. The depthOffset would be the number of blocks between you and controller, not counting * controller itself. - * + *

* All these offsets can be negative. */ protected final boolean checkPiece(String piece, int horizontalOffset, int verticalOffset, int depthOffset) { diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch.java index f0ce474fd17..ec6d1fe11f5 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch.java @@ -1,6 +1,7 @@ package gregtech.api.metatileentity.implementations; import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.ForgeDirection; import gregtech.api.enums.GT_Values; import gregtech.api.enums.Textures; @@ -61,16 +62,16 @@ public ITexture[][][] getTextureSet(ITexture[] aTextures) { public abstract ITexture[] getTexturesInactive(ITexture aBaseTexture); @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, - boolean aActive, boolean aRedstone) { + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection aFacing, + int colorIndex, boolean aActive, boolean redstoneLevel) { int texturePointer = (byte) (actualTexture & 0x7F); // just to be sure, from my testing the 8th bit cannot be // set clientside int textureIndex = texturePointer | (mTexturePage << 7); // Shift seven since one page is 128 textures! try { - if (aSide != aFacing) { + if (side != aFacing) { if (textureIndex > 0) return new ITexture[] { Textures.BlockIcons.casingTexturePages[mTexturePage][texturePointer] }; - else return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex + 1] }; + else return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][colorIndex + 1] }; } else { if (textureIndex > 0) { if (aActive) @@ -78,8 +79,8 @@ public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide else return getTexturesInactive( Textures.BlockIcons.casingTexturePages[mTexturePage][texturePointer]); } else { - if (aActive) return getTexturesActive(Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex + 1]); - else return getTexturesInactive(Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex + 1]); + if (aActive) return getTexturesActive(Textures.BlockIcons.MACHINE_CASINGS[mTier][colorIndex + 1]); + else return getTexturesInactive(Textures.BlockIcons.MACHINE_CASINGS[mTier][colorIndex + 1]); } } } catch (NullPointerException npe) { @@ -108,7 +109,7 @@ public void loadNBTData(NBTTagCompound aNBT) { /** * Sets texture with page and index, called on add to machine list - * + * * @param id (page<<7)+index of the texture */ public final void updateTexture(int id) { @@ -118,7 +119,7 @@ public final void updateTexture(int id) { /** * Sets texture with page and index, rather unusable, but kept FFS - * + * * @param page page of texure * @param index index of texure */ diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_DataAccess.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_DataAccess.java index 7617725d92c..122dcfa7463 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_DataAccess.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_DataAccess.java @@ -5,6 +5,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.ForgeDirection; import com.gtnewhorizons.modularui.api.screen.ModularWindow; import com.gtnewhorizons.modularui.api.screen.UIBuildContext; @@ -58,7 +59,7 @@ public boolean isSimpleMachine() { } @Override - public boolean isFacingValid(byte aFacing) { + public boolean isFacingValid(ForgeDirection facing) { return true; } @@ -84,12 +85,14 @@ public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlaye } @Override - public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { return mTier >= 8 && !aBaseMetaTileEntity.isActive(); } @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { return mTier >= 8 && !aBaseMetaTileEntity.isActive(); } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Dynamo.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Dynamo.java index cc1d0ac4045..8e621434db3 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Dynamo.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Dynamo.java @@ -4,6 +4,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; @@ -51,7 +52,7 @@ public boolean isSimpleMachine() { } @Override - public boolean isFacingValid(byte aFacing) { + public boolean isFacingValid(ForgeDirection facing) { return true; } @@ -66,8 +67,8 @@ public boolean isEnetOutput() { } @Override - public boolean isOutputFacing(byte aSide) { - return aSide == getBaseMetaTileEntity().getFrontFacing(); + public boolean isOutputFacing(ForgeDirection side) { + return side == getBaseMetaTileEntity().getFrontFacing(); } @Override @@ -96,12 +97,14 @@ public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { } @Override - public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { return false; } @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { return false; } } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Energy.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Energy.java index 2ad670fae1d..d9be12671d0 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Energy.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Energy.java @@ -4,6 +4,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; @@ -61,7 +62,7 @@ public boolean isSimpleMachine() { } @Override - public boolean isFacingValid(byte aFacing) { + public boolean isFacingValid(ForgeDirection facing) { return true; } @@ -76,8 +77,8 @@ public boolean isEnetInput() { } @Override - public boolean isInputFacing(byte aSide) { - return aSide == getBaseMetaTileEntity().getFrontFacing(); + public boolean isInputFacing(ForgeDirection side) { + return side == getBaseMetaTileEntity().getFrontFacing(); } @Override @@ -111,12 +112,14 @@ public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { } @Override - public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { return false; } @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { return false; } } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Input.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Input.java index 408e1eca147..e659fd10a96 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Input.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Input.java @@ -6,6 +6,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; import gregtech.GT_Mod; @@ -77,7 +78,7 @@ public boolean isSimpleMachine() { } @Override - public boolean isFacingValid(byte aFacing) { + public boolean isFacingValid(ForgeDirection facing) { return true; } @@ -151,13 +152,15 @@ public boolean isFluidInputAllowed(FluidStack aFluid) { } @Override - public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return aSide == aBaseMetaTileEntity.getFrontFacing() && aIndex == 1; + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return side == aBaseMetaTileEntity.getFrontFacing() && aIndex == 1; } @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return aSide == aBaseMetaTileEntity.getFrontFacing() && aIndex == 0 + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return side == aBaseMetaTileEntity.getFrontFacing() && aIndex == 0 && (mRecipeMap == null || mRecipeMap.containsInput(aStack) || mRecipeMap.containsInput(GT_Utility.getFluidForFilledItem(aStack, true))); } 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 4bbb98c1dab..0a8144d6200 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 @@ -10,6 +10,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.StatCollector; +import net.minecraftforge.common.util.ForgeDirection; import com.gtnewhorizons.modularui.api.screen.ModularWindow; import com.gtnewhorizons.modularui.api.screen.UIBuildContext; @@ -94,7 +95,7 @@ public boolean isSimpleMachine() { } @Override - public boolean isFacingValid(byte aFacing) { + public boolean isFacingValid(ForgeDirection facing) { return true; } @@ -201,8 +202,8 @@ public void loadNBTData(NBTTagCompound aNBT) { } @Override - public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { - if (!getBaseMetaTileEntity().getCoverInfoAtSide(aSide) + public void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (!getBaseMetaTileEntity().getCoverInfoAtSide(side) .isGUIClickable()) return; if (aPlayer.isSneaking()) { if (disableSort) { @@ -227,14 +228,16 @@ public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, } @Override - public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { if (aIndex == getCircuitSlot()) return false; - return aSide == getBaseMetaTileEntity().getFrontFacing(); + return side == getBaseMetaTileEntity().getFrontFacing(); } @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return aSide == getBaseMetaTileEntity().getFrontFacing() && aIndex != getCircuitSlot() + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return side == getBaseMetaTileEntity().getFrontFacing() && aIndex != getCircuitSlot() && (mRecipeMap == null || disableFilter || mRecipeMap.containsInput(aStack)) && (disableLimited || limitedAllowPutStack(aIndex, aStack)); } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Maintenance.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Maintenance.java index 12a55d097c4..3b56a2dbbf4 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Maintenance.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Maintenance.java @@ -14,6 +14,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.util.FakePlayer; +import net.minecraftforge.common.util.ForgeDirection; import com.gtnewhorizons.modularui.api.screen.ModularWindow; import com.gtnewhorizons.modularui.api.screen.UIBuildContext; @@ -125,7 +126,7 @@ public boolean isSimpleMachine() { } @Override - public boolean isFacingValid(byte aFacing) { + public boolean isFacingValid(ForgeDirection facing) { return true; } @@ -147,10 +148,10 @@ public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { } @Override - public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, byte aSide, float aX, - float aY, float aZ) { + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, ForgeDirection side, + float aX, float aY, float aZ) { if (aBaseMetaTileEntity.isClientSide()) return true; - if (aSide == aBaseMetaTileEntity.getFrontFacing()) { + if (side == aBaseMetaTileEntity.getFrontFacing()) { // only allow OC robot fake player if (aPlayer instanceof FakePlayer && !aPlayer.getGameProfile() .getName() @@ -294,12 +295,14 @@ private void applyToolbox(ItemStack aStack, EntityPlayer aPlayer) { } @Override - public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { return mAuto && GT_Mod.gregtechproxy.mAMHInteraction; } @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { if (mAuto && GT_Mod.gregtechproxy.mAMHInteraction) { for (int i = 0; i < getSizeInventory(); i++) if (GT_Utility.areStacksEqual( GT_OreDictUnificator.get(false, aStack), 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 1fdafd7f353..9cec94fe9b3 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 @@ -86,12 +86,14 @@ public boolean isValidSlot(int aIndex) { } @Override - public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { return false; } @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { return false; } @@ -118,8 +120,8 @@ public Class getType() { } @Override - public boolean isFacingValid(byte aFacing) { - return facings[aFacing]; + public boolean isFacingValid(ForgeDirection facing) { + return facings[facing.ordinal()]; } @Override @@ -144,18 +146,18 @@ public void pollutionParticles(World aWorld, String name) { 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; + final IGregTechTileEntity aMuffler = this.getBaseMetaTileEntity(); + final ForgeDirection aDir = aMuffler.getFrontFacing(); + final float xPos = aDir.offsetX * 0.76F + aMuffler.getXCoord() + 0.25F; + final float yPos = aDir.offsetY * 0.76F + aMuffler.getYCoord() + 0.25F; + final float zPos = aDir.offsetZ * 0.76F + aMuffler.getZCoord() + 0.25F; - float ySpd = aDir.offsetY * 0.1F + 0.2F + 0.1F * XSTR_INSTANCE.nextFloat(); - float xSpd; - float zSpd; + final float ySpd = aDir.offsetY * 0.1F + 0.2F + 0.1F * XSTR_INSTANCE.nextFloat(); + final float xSpd; + final float zSpd; if (aDir.offsetY == -1) { - float temp = XSTR_INSTANCE.nextFloat() * 2 * (float) Math.PI; + final float temp = XSTR_INSTANCE.nextFloat() * 2 * (float) Math.PI; xSpd = (float) Math.sin(temp) * 0.1F; zSpd = (float) Math.cos(temp) * 0.1F; } else { @@ -163,7 +165,7 @@ public void pollutionParticles(World aWorld, String name) { zSpd = aDir.offsetZ * (0.1F + 0.2F * XSTR_INSTANCE.nextFloat()); } - WorldSpawnedEventBuilder.ParticleEventBuilder events = new WorldSpawnedEventBuilder.ParticleEventBuilder() + final WorldSpawnedEventBuilder.ParticleEventBuilder events = new WorldSpawnedEventBuilder.ParticleEventBuilder() .setIdentifier(name) .setWorld(aWorld) .setMotion(xSpd, ySpd, zSpd); diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Output.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Output.java index c3cc1edc9b5..a967df47f39 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Output.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Output.java @@ -92,7 +92,7 @@ public boolean isSimpleMachine() { } @Override - public boolean isFacingValid(byte aFacing) { + public boolean isFacingValid(ForgeDirection facing) { return true; } @@ -102,7 +102,7 @@ public boolean isAccessAllowed(EntityPlayer aPlayer) { } @Override - public boolean isLiquidInput(byte aSide) { + public boolean isLiquidInput(ForgeDirection side) { return false; } @@ -124,20 +124,14 @@ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { IFluidHandler tTileEntity = aBaseMetaTileEntity .getITankContainerAtSide(aBaseMetaTileEntity.getFrontFacing()); if (tTileEntity != null) { - FluidStack tDrained = aBaseMetaTileEntity.drain( - ForgeDirection.getOrientation(aBaseMetaTileEntity.getFrontFacing()), - Math.max(1, mFluid.amount), - false); + FluidStack tDrained = aBaseMetaTileEntity + .drain(aBaseMetaTileEntity.getFrontFacing(), Math.max(1, mFluid.amount), false); if (tDrained != null) { - int tFilledAmount = tTileEntity - .fill(ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()), tDrained, false); + int tFilledAmount = tTileEntity.fill(aBaseMetaTileEntity.getBackFacing(), tDrained, false); if (tFilledAmount > 0) { tTileEntity.fill( - ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()), - aBaseMetaTileEntity.drain( - ForgeDirection.getOrientation(aBaseMetaTileEntity.getFrontFacing()), - tFilledAmount, - true), + aBaseMetaTileEntity.getBackFacing(), + aBaseMetaTileEntity.drain(aBaseMetaTileEntity.getFrontFacing(), tFilledAmount, true), true); } } @@ -222,13 +216,15 @@ public boolean isValidSlot(int aIndex) { } @Override - public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return aSide == aBaseMetaTileEntity.getFrontFacing() && aIndex == 1; + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return side == aBaseMetaTileEntity.getFrontFacing() && aIndex == 1; } @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return aSide == aBaseMetaTileEntity.getFrontFacing() && aIndex == 0; + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return side == aBaseMetaTileEntity.getFrontFacing() && aIndex == 0; } @Override @@ -237,8 +233,8 @@ public int getCapacity() { } @Override - public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { - if (!getBaseMetaTileEntity().getCoverInfoAtSide(aSide) + public void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (!getBaseMetaTileEntity().getCoverInfoAtSide(side) .isGUIClickable()) return; if (aPlayer.isSneaking()) { mMode = (byte) ((mMode + 9) % 10); @@ -323,8 +319,8 @@ public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, } } - private boolean tryToLockHatch(EntityPlayer aPlayer, byte aSide) { - if (!getBaseMetaTileEntity().getCoverInfoAtSide(aSide) + private boolean tryToLockHatch(EntityPlayer aPlayer, ForgeDirection side) { + if (!getBaseMetaTileEntity().getCoverInfoAtSide(side) .isGUIClickable()) return false; if (!isFluidLocked()) return false; final ItemStack tCurrentItem = aPlayer.inventory.getCurrentItem(); @@ -371,10 +367,10 @@ public byte getMode() { } @Override - public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, byte aSide, float aX, - float aY, float aZ) { - if (tryToLockHatch(aPlayer, aSide)) return true; - return super.onRightclick(aBaseMetaTileEntity, aPlayer, aSide, aX, aY, aZ); + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, ForgeDirection side, + float aX, float aY, float aZ) { + if (tryToLockHatch(aPlayer, side)) return true; + return super.onRightclick(aBaseMetaTileEntity, aPlayer, side, aX, aY, aZ); } public boolean outputsSteam() { 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 f04840d7d3b..e3915d48541 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 @@ -7,6 +7,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; import com.gtnewhorizons.modularui.api.screen.ModularWindow; import com.gtnewhorizons.modularui.api.screen.UIBuildContext; @@ -85,7 +86,7 @@ public boolean isSimpleMachine() { } @Override - public boolean isFacingValid(byte aFacing) { + public boolean isFacingValid(ForgeDirection facing) { return true; } @@ -147,12 +148,14 @@ public boolean storeAll(ItemStack aStack) { } @Override - public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return aSide == aBaseMetaTileEntity.getFrontFacing(); + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return side == aBaseMetaTileEntity.getFrontFacing(); } @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { return false; } 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 7d37b6747f2..e6ce7d14c2b 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 @@ -136,8 +136,8 @@ public boolean isDisplaySecondaryDescription() { } @Override - public boolean allowCoverOnSide(byte aSide, GT_ItemStack aCoverID) { - return aSide != getBaseMetaTileEntity().getFrontFacing(); + public boolean allowCoverOnSide(ForgeDirection side, GT_ItemStack aCoverID) { + return side != getBaseMetaTileEntity().getFrontFacing(); } /** Override this if you are a multi-block that has added support for single recipe locking. */ @@ -146,7 +146,7 @@ public boolean supportsSingleRecipeLocking() { } @Override - public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + public void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { if (supportsSingleRecipeLocking()) { mLockedToSingleRecipe = !mLockedToSingleRecipe; if (mLockedToSingleRecipe) { @@ -166,7 +166,7 @@ public boolean isSimpleMachine() { } @Override - public boolean isFacingValid(byte aFacing) { + public boolean isFacingValid(ForgeDirection facing) { return true; } @@ -1314,12 +1314,14 @@ public boolean isGivingInformation() { } @Override - public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { return false; } @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { return false; } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SpecialFilter.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SpecialFilter.java index 9672c87f402..63b8160262e 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SpecialFilter.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SpecialFilter.java @@ -5,6 +5,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.ForgeDirection; import com.gtnewhorizons.modularui.api.drawable.Text; import com.gtnewhorizons.modularui.api.screen.ModularWindow; @@ -66,8 +67,9 @@ public void loadNBTData(NBTTagCompound aNBT) { } @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return (super.allowPutStack(aBaseMetaTileEntity, aIndex, aSide, aStack)) + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return (super.allowPutStack(aBaseMetaTileEntity, aIndex, side, aStack)) && ((this.bNBTAllowed) || (!aStack.hasTagCompound())) && (this.isStackAllowed(aStack) != this.bInvertFilter); } 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 ae706074164..4b8b59d9cba 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 @@ -86,10 +86,10 @@ public ITexture[][][] getTextureSet(ITexture[] aTextures) { } @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) - + (aBaseMetaTileEntity.isAllowedToWork() ? 0 : 6)][aColorIndex + 1]; + public ITexture[] getTexture(IGregTechTileEntity baseMetaTileEntity, ForgeDirection side, + ForgeDirection facingDirection, int colorIndex, boolean active, boolean redstoneLevel) { + return mTextures[Math.min(2, side.ordinal()) + (side == facingDirection ? 3 : 0) + + (baseMetaTileEntity.isAllowedToWork() ? 0 : 6)][colorIndex + 1]; } @Override @@ -108,7 +108,7 @@ public boolean isSimpleMachine() { } @Override - public boolean isFacingValid(byte aFacing) { + public boolean isFacingValid(ForgeDirection facing) { return true; } @@ -123,14 +123,14 @@ public boolean isEnetOutput() { } @Override - public boolean isInputFacing(byte aSide) { - return getBaseMetaTileEntity().isAllowedToWork() ? aSide == getBaseMetaTileEntity().getFrontFacing() - : aSide != getBaseMetaTileEntity().getFrontFacing(); + public boolean isInputFacing(ForgeDirection side) { + return getBaseMetaTileEntity().isAllowedToWork() ? side == getBaseMetaTileEntity().getFrontFacing() + : side != getBaseMetaTileEntity().getFrontFacing(); } @Override - public boolean isOutputFacing(byte aSide) { - return !isInputFacing(aSide); + public boolean isOutputFacing(ForgeDirection side) { + return !isInputFacing(side); } @Override @@ -172,50 +172,52 @@ public long maxAmperesIn() { public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { if (aBaseMetaTileEntity.isServerSide() && GregTech_API.mInputRF) { aBaseMetaTileEntity.setActive(aBaseMetaTileEntity.isAllowedToWork()); - for (byte i = 0; i < 6 && aBaseMetaTileEntity.getStoredEU() < aBaseMetaTileEntity.getEUCapacity(); i++) - if (aBaseMetaTileEntity.inputEnergyFrom(i)) { - TileEntity tTileEntity = aBaseMetaTileEntity.getTileEntityAtSide(i); - if (tTileEntity instanceof IEnergyProvider && ((IEnergyProvider) tTileEntity) - .extractEnergy(ForgeDirection.getOrientation(GT_Utility.getOppositeSide(i)), 1, true) == 1) { - long tEU = ((IEnergyProvider) tTileEntity).extractEnergy( - ForgeDirection.getOrientation(GT_Utility.getOppositeSide(i)), - GT_Utility.safeInt(maxEUInput() * 100L / GregTech_API.mRFtoEU), - false); + for (final ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + if (aBaseMetaTileEntity.getStoredEU() >= aBaseMetaTileEntity.getEUCapacity()) break; + if (!aBaseMetaTileEntity.inputEnergyFrom(side)) continue; + final TileEntity tTileEntity = aBaseMetaTileEntity.getTileEntityAtSide(side); + if (tTileEntity instanceof IEnergyProvider energyProvider + && energyProvider.extractEnergy(side.getOpposite(), 1, true) == 1) { + long tEU = ((IEnergyProvider) tTileEntity).extractEnergy( + side.getOpposite(), + GT_Utility.safeInt(maxEUInput() * 100L / GregTech_API.mRFtoEU), + false); + tEU = tEU * GregTech_API.mRFtoEU / 100; + aBaseMetaTileEntity.injectEnergyUnits(ForgeDirection.UNKNOWN, Math.min(tEU, maxEUInput()), 1); + } else if (tTileEntity instanceof IEnergyStorage energyStorage + && energyStorage.extractEnergy(1, true) == 1) { + long tEU = ((IEnergyStorage) tTileEntity) + .extractEnergy(GT_Utility.safeInt(maxEUInput() * 100L / GregTech_API.mRFtoEU), false); tEU = tEU * GregTech_API.mRFtoEU / 100; - aBaseMetaTileEntity.injectEnergyUnits((byte) 6, Math.min(tEU, maxEUInput()), 1); - } else if (tTileEntity instanceof IEnergyStorage - && ((IEnergyStorage) tTileEntity).extractEnergy(1, true) == 1) { - long tEU = ((IEnergyStorage) tTileEntity) - .extractEnergy(GT_Utility.safeInt(maxEUInput() * 100L / GregTech_API.mRFtoEU), false); - tEU = tEU * GregTech_API.mRFtoEU / 100; - aBaseMetaTileEntity.injectEnergyUnits((byte) 6, Math.min(tEU, maxEUInput()), 1); - } else if (GregTech_API.meIOLoaded && tTileEntity instanceof IPowerContainer - && ((IPowerContainer) tTileEntity).getEnergyStored() > 0) { - int storedRF = ((IPowerContainer) tTileEntity).getEnergyStored(); - int extractRF = GT_Utility.safeInt(maxEUInput() * 100L / GregTech_API.mRFtoEU); - long tEU = 0; - if (tTileEntity instanceof TileCapBank) { - ICapBankNetwork network = ((TileCapBank) tTileEntity).getNetwork(); - if (network != null && network.getEnergyStoredL() > 0) { - tEU = Math.min( - (Math.min( - Math.min(network.getEnergyStoredL(), storedRF - extractRF), - network.getMaxOutput())) * (long) GregTech_API.mRFtoEU / 100L, - maxEUInput()); - network.addEnergy(GT_Utility.safeInt(-(tEU * 100 / GregTech_API.mRFtoEU))); - } + aBaseMetaTileEntity.injectEnergyUnits(ForgeDirection.UNKNOWN, Math.min(tEU, maxEUInput()), 1); + } else if (GregTech_API.meIOLoaded && tTileEntity instanceof IPowerContainer powerContainer + && powerContainer.getEnergyStored() > 0) { + final int storedRF = powerContainer.getEnergyStored(); + final int extractRF = GT_Utility.safeInt(maxEUInput() * 100L / GregTech_API.mRFtoEU); + long tEU = 0; + if (tTileEntity instanceof TileCapBank capBank) { + ICapBankNetwork network = capBank.getNetwork(); + if (network != null && network.getEnergyStoredL() > 0) { + tEU = Math.min( + (Math.min( + Math.min(network.getEnergyStoredL(), storedRF - extractRF), + network.getMaxOutput())) * (long) GregTech_API.mRFtoEU / 100L, + maxEUInput()); + network.addEnergy(GT_Utility.safeInt(-(tEU * 100 / GregTech_API.mRFtoEU))); + } + } else { + if (storedRF > extractRF) { + powerContainer.setEnergyStored(storedRF - extractRF); + tEU = maxEUInput(); } else { - if (storedRF > extractRF) { - ((IPowerContainer) tTileEntity).setEnergyStored(storedRF - extractRF); - tEU = maxEUInput(); - } else { - ((IPowerContainer) tTileEntity).setEnergyStored(0); - tEU = storedRF * (long) GregTech_API.mRFtoEU / 100L; - } + powerContainer.setEnergyStored(0); + tEU = storedRF * (long) GregTech_API.mRFtoEU / 100L; } - aBaseMetaTileEntity.injectEnergyUnits((byte) 6, Math.min(tEU, maxEUInput()), 1); } - } + aBaseMetaTileEntity + .injectEnergyUnits(ForgeDirection.UNKNOWN, Math.min(tEU, maxEUInput()), 1); + } + } } } @@ -230,12 +232,14 @@ public void loadNBTData(NBTTagCompound aNBT) { } @Override - public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { return false; } @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { return false; } @@ -265,10 +269,9 @@ public boolean shouldJoinIc2Enet() { @Override public void getWailaBody(ItemStack itemStack, List currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) { - final int facing = getBaseMetaTileEntity().getFrontFacing(); + final ForgeDirection facing = getBaseMetaTileEntity().getFrontFacing(); final NBTTagCompound tag = accessor.getNBTData(); - final int side = (byte) accessor.getSide() - .ordinal(); + final ForgeDirection side = accessor.getSide(); final boolean allowedToWork = tag.getBoolean("isAllowedToWork"); final byte inputTier = GT_Utility.getTier(tag.getLong("maxEUInput")); diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Wireless_Dynamo.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Wireless_Dynamo.java index 0e313a4c004..d677b76248b 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Wireless_Dynamo.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Wireless_Dynamo.java @@ -5,6 +5,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.common.util.ForgeDirection; import gregtech.api.enums.Textures; import gregtech.api.interfaces.IGlobalWirelessEnergy; @@ -44,7 +45,7 @@ public boolean isSimpleMachine() { } @Override - public boolean isFacingValid(byte aFacing) { + public boolean isFacingValid(ForgeDirection facing) { return true; } @@ -59,8 +60,8 @@ public boolean isEnetOutput() { } @Override - public boolean isInputFacing(byte aSide) { - return aSide == getBaseMetaTileEntity().getFrontFacing(); + public boolean isInputFacing(ForgeDirection side) { + return side == getBaseMetaTileEntity().getFrontFacing(); } @Override @@ -106,12 +107,14 @@ public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { } @Override - public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { return false; } @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { return false; } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Wireless_Hatch.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Wireless_Hatch.java index c363bb6eb0d..4c1c7b4cb96 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Wireless_Hatch.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Wireless_Hatch.java @@ -7,6 +7,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.common.util.ForgeDirection; import gregtech.api.enums.Textures; import gregtech.api.interfaces.IGlobalWirelessEnergy; @@ -56,7 +57,7 @@ public boolean isSimpleMachine() { } @Override - public boolean isFacingValid(byte aFacing) { + public boolean isFacingValid(ForgeDirection facing) { return true; } @@ -71,8 +72,8 @@ public boolean isEnetInput() { } @Override - public boolean isInputFacing(byte aSide) { - return aSide == getBaseMetaTileEntity().getFrontFacing(); + public boolean isInputFacing(ForgeDirection side) { + return side == getBaseMetaTileEntity().getFrontFacing(); } @Override @@ -111,12 +112,14 @@ public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { } @Override - public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { return false; } @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { return false; } diff --git a/src/main/java/gregtech/api/multitileentity/MultiTileEntityBlock.java b/src/main/java/gregtech/api/multitileentity/MultiTileEntityBlock.java index b81961af951..7d1c74b1bcc 100644 --- a/src/main/java/gregtech/api/multitileentity/MultiTileEntityBlock.java +++ b/src/main/java/gregtech/api/multitileentity/MultiTileEntityBlock.java @@ -1,6 +1,5 @@ package gregtech.api.multitileentity; -import static gregtech.api.enums.GT_Values.ALL_VALID_SIDES; import static gregtech.api.enums.GT_Values.OFFX; import static gregtech.api.enums.GT_Values.OFFY; import static gregtech.api.enums.GT_Values.OFFZ; @@ -46,7 +45,6 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.GregTech_API; -import gregtech.api.enums.GT_Values; import gregtech.api.enums.ItemList; import gregtech.api.enums.Textures; import gregtech.api.interfaces.IDebugableBlock; @@ -66,7 +64,6 @@ import gregtech.api.objects.XSTR; import gregtech.api.util.GT_Log; import gregtech.api.util.GT_Util; -import gregtech.api.util.GT_Utility; import gregtech.common.covers.CoverInfo; import gregtech.common.render.GT_MultiTile_Renderer; @@ -229,13 +226,13 @@ public final float getBlockHardness(World aWorld, int aX, int aY, int aZ) { @SideOnly(Side.CLIENT) @Override - public IIcon getIcon(IBlockAccess aIBlockAccess, int aX, int aY, int aZ, int aSide) { + public IIcon getIcon(IBlockAccess aIBlockAccess, int aX, int aY, int aZ, int ordinalSide) { return Textures.BlockIcons.MACHINE_LV_SIDE.getIcon(); } @SideOnly(Side.CLIENT) @Override - public IIcon getIcon(int aSide, int aMeta) { + public IIcon getIcon(int ordinalSide, int aMeta) { return Textures.BlockIcons.MACHINE_LV_SIDE.getIcon(); } @@ -252,24 +249,22 @@ public final void addCollisionBoxesToList(World aWorld, int aX, int aY, int aZ, @Override public final AxisAlignedBB getCollisionBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ) { final TileEntity aTileEntity = aWorld.getTileEntity(aX, aY, aZ); - return aTileEntity instanceof IMultiTileEntity - ? ((IMultiTileEntity) aTileEntity).getCollisionBoundingBoxFromPool() + return aTileEntity instanceof IMultiTileEntity mte ? mte.getCollisionBoundingBoxFromPool() : aTileEntity == null ? null : super.getCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ); } @Override public final AxisAlignedBB getSelectedBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ) { final TileEntity aTileEntity = aWorld.getTileEntity(aX, aY, aZ); - return aTileEntity instanceof IMultiTileEntity - ? ((IMultiTileEntity) aTileEntity).getSelectedBoundingBoxFromPool() + return aTileEntity instanceof IMultiTileEntity mte ? mte.getSelectedBoundingBoxFromPool() : super.getSelectedBoundingBoxFromPool(aWorld, aX, aY, aZ); } @Override public void setBlockBoundsBasedOnState(IBlockAccess blockAccess, int aX, int aY, int aZ) { final TileEntity aTileEntity = blockAccess.getTileEntity(aX, aY, aZ); - if (aTileEntity instanceof IMultiTileEntity) { - ((IMultiTileEntity) aTileEntity).setBlockBoundsBasedOnState(this); + if (aTileEntity instanceof IMultiTileEntity mte) { + mte.setBlockBoundsBasedOnState(this); return; } super.setBlockBoundsBasedOnState(blockAccess, aX, aY, aZ); @@ -300,21 +295,20 @@ public void onNeighborBlockChange(World aWorld, int aX, int aY, int aZ, Block aB if (aTileEntity instanceof BaseTileEntity) ((BaseTileEntity) aTileEntity).onAdjacentBlockChange(aX, aY, aZ); LOCK = false; } - if (aTileEntity instanceof IMTE_OnNeighborBlockChange) - ((IMTE_OnNeighborBlockChange) aTileEntity).onNeighborBlockChange(aWorld, aBlock); + if (aTileEntity instanceof IMTE_OnNeighborBlockChange change) change.onNeighborBlockChange(aWorld, aBlock); if (aTileEntity == null) aWorld.setBlockToAir(aX, aY, aZ); } @Override public final void onBlockAdded(World aWorld, int aX, int aY, int aZ) { final TileEntity aTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (aTileEntity instanceof IMultiTileEntity) ((IMultiTileEntity) aTileEntity).onBlockAdded(); + if (aTileEntity instanceof IMultiTileEntity mte) mte.onBlockAdded(); } @Override public float getPlayerRelativeBlockHardness(EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ) { final TileEntity aTileEntity = aWorld.getTileEntity(aX, aY, aZ); - return aTileEntity instanceof IMultiTileEntity && ((IMultiTileEntity) aTileEntity).privateAccess() + return aTileEntity instanceof IMultiTileEntity mte && mte.privateAccess() && !((IMultiTileEntity) aTileEntity).playerOwnsThis(aPlayer, true) ? -1.0F : super.getPlayerRelativeBlockHardness(aPlayer, aWorld, aX, aY, aZ); } @@ -322,47 +316,47 @@ public float getPlayerRelativeBlockHardness(EntityPlayer aPlayer, World aWorld, @Override public final void onBlockClicked(World aWorld, int aX, int aY, int aZ, EntityPlayer aPlayer) { final TileEntity aTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (aTileEntity instanceof IMultiTileEntity) ((IMultiTileEntity) aTileEntity).onLeftClick(aPlayer); + if (aTileEntity instanceof IMultiTileEntity mte) mte.onLeftClick(aPlayer); else super.onBlockClicked(aWorld, aX, aY, aZ, aPlayer); } @Override - public boolean onBlockActivated(World aWorld, int aX, int aY, int aZ, EntityPlayer aPlayer, int aSide, float aHitX, - float aHitY, float aHitZ) { + public boolean onBlockActivated(World aWorld, int aX, int aY, int aZ, EntityPlayer aPlayer, int ordinalSide, + float aHitX, float aHitY, float aHitZ) { final TileEntity aTileEntity = aWorld.getTileEntity(aX, aY, aZ); if (aPlayer != null && ItemList.TC_Thaumometer.isStackEqual(aPlayer.getHeldItem(), true, true)) return false; - return aTileEntity instanceof IMultiTileEntity - && ((IMultiTileEntity) aTileEntity).onBlockActivated(aPlayer, (byte) aSide, aHitX, aHitY, aHitZ); + return aTileEntity instanceof IMultiTileEntity mte + && mte.onBlockActivated(aPlayer, ForgeDirection.getOrientation(ordinalSide), aHitX, aHitY, aHitZ); } @Override - public final int isProvidingWeakPower(IBlockAccess aWorld, int aX, int aY, int aZ, int aSide) { + public final int isProvidingWeakPower(IBlockAccess aWorld, int aX, int aY, int aZ, int ordinalSide) { final TileEntity aTileEntity = aWorld.getTileEntity(aX, aY, aZ); - return aTileEntity instanceof IMTE_IsProvidingWeakPower - ? ((IMTE_IsProvidingWeakPower) aTileEntity).isProvidingWeakPower((byte) aSide) - : super.isProvidingWeakPower(aWorld, aX, aY, aZ, aSide); + return aTileEntity instanceof IMTE_IsProvidingWeakPower power + ? power.isProvidingWeakPower(ForgeDirection.getOrientation(ordinalSide)) + : super.isProvidingWeakPower(aWorld, aX, aY, aZ, ordinalSide); } @Override - public final int isProvidingStrongPower(IBlockAccess aWorld, int aX, int aY, int aZ, int aSide) { + public final int isProvidingStrongPower(IBlockAccess aWorld, int aX, int aY, int aZ, int ordinalSide) { final TileEntity aTileEntity = aWorld.getTileEntity(aX, aY, aZ); - return aTileEntity instanceof IMTE_IsProvidingStrongPower - ? ((IMTE_IsProvidingStrongPower) aTileEntity).isProvidingStrongPower((byte) aSide) - : super.isProvidingStrongPower(aWorld, aX, aY, aZ, aSide); + return aTileEntity instanceof IMTE_IsProvidingStrongPower power + ? power.isProvidingStrongPower(ForgeDirection.getOrientation(ordinalSide)) + : super.isProvidingStrongPower(aWorld, aX, aY, aZ, ordinalSide); } @Override - public final boolean shouldCheckWeakPower(IBlockAccess aWorld, int aX, int aY, int aZ, int aSide) { + public final boolean shouldCheckWeakPower(IBlockAccess aWorld, int aX, int aY, int aZ, int ordinalSide) { final TileEntity aTileEntity = aWorld.getTileEntity(aX, aY, aZ); - return aTileEntity instanceof IMTE_ShouldCheckWeakPower - ? ((IMTE_ShouldCheckWeakPower) aTileEntity).shouldCheckWeakPower((byte) aSide) + return aTileEntity instanceof IMTE_ShouldCheckWeakPower power + ? power.shouldCheckWeakPower(ForgeDirection.getOrientation(ordinalSide)) : isNormalCube(aWorld, aX, aY, aZ); } @Override public final boolean getWeakChanges(IBlockAccess aWorld, int aX, int aY, int aZ) { final TileEntity aTileEntity = aWorld.getTileEntity(aX, aY, aZ); - return aTileEntity instanceof IMTE_GetWeakChanges ? ((IMTE_GetWeakChanges) aTileEntity).getWeakChanges() + return aTileEntity instanceof IMTE_GetWeakChanges changes ? changes.getWeakChanges() : super.getWeakChanges(aWorld, aX, aY, aZ); } @@ -379,32 +373,33 @@ public final void harvestBlock(World aWorld, EntityPlayer aPlayer, int aX, int a final ArrayList tList = ((IMultiTileEntity) aTileEntity).getDrops(aFortune, aSilkTouch); aChance = ForgeEventFactory .fireBlockHarvesting(tList, aWorld, this, aX, aY, aZ, aMeta, aFortune, aChance, aSilkTouch, aPlayer); - for (ItemStack tStack : tList) + for (final ItemStack tStack : tList) if (XSTR.XSTR_INSTANCE.nextFloat() <= aChance) dropBlockAsItem(aWorld, aX, aY, aZ, tStack); } } @Override - public final boolean shouldSideBeRendered(IBlockAccess aWorld, int aX, int aY, int aZ, int aSide) { - final TileEntity aTileEntity = aWorld.getTileEntity(aX - OFFX[aSide], aY - OFFY[aSide], aZ - OFFZ[aSide]); + public final boolean shouldSideBeRendered(IBlockAccess aWorld, int aX, int aY, int aZ, int ordinalSide) { + final TileEntity aTileEntity = aWorld + .getTileEntity(aX - OFFX[ordinalSide], aY - OFFY[ordinalSide], aZ - OFFZ[ordinalSide]); return aTileEntity instanceof IMultiTileEntity - ? ((IMultiTileEntity) aTileEntity).shouldSideBeRendered((byte) aSide) - : super.shouldSideBeRendered(aWorld, aX, aY, aZ, aSide); + ? ((IMultiTileEntity) aTileEntity).shouldSideBeRendered(ForgeDirection.getOrientation(ordinalSide)) + : super.shouldSideBeRendered(aWorld, aX, aY, aZ, ordinalSide); } @Override - public Block getFacade(IBlockAccess aWorld, int aX, int aY, int aZ, int side) { + public Block getFacade(IBlockAccess aWorld, int aX, int aY, int aZ, int ordinalSide) { final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); if (tTileEntity instanceof CoverableTileEntity tile) { - final byte aSide = (byte) side; - if (side != -1) { - final Block facadeBlock = tile.getCoverInfoAtSide(aSide) + final ForgeDirection side = ForgeDirection.getOrientation(ordinalSide); + if (ordinalSide != -1) { + final Block facadeBlock = tile.getCoverInfoAtSide(side) .getFacadeBlock(); if (facadeBlock != null) return facadeBlock; } else { // we do not allow more than one type of facade per block, so no need to check every side // see comment in gregtech.common.covers.GT_Cover_FacadeBase.isCoverPlaceable - for (byte tSide : ALL_VALID_SIDES) { + for (final ForgeDirection tSide : ForgeDirection.VALID_DIRECTIONS) { final Block facadeBlock = tile.getCoverInfoAtSide(tSide) .getFacadeBlock(); if (facadeBlock != null) { @@ -417,18 +412,18 @@ public Block getFacade(IBlockAccess aWorld, int aX, int aY, int aZ, int side) { } @Override - public int getFacadeMetadata(IBlockAccess aWorld, int aX, int aY, int aZ, int side) { + public int getFacadeMetadata(IBlockAccess aWorld, int aX, int aY, int aZ, int ordinalSide) { final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); if (tTileEntity instanceof CoverableTileEntity tile) { - final byte aSide = (byte) side; - if (side != -1) { - final CoverInfo coverInfo = tile.getCoverInfoAtSide(aSide); + final ForgeDirection side = ForgeDirection.getOrientation(ordinalSide); + if (ordinalSide != -1) { + final CoverInfo coverInfo = tile.getCoverInfoAtSide(side); final Block facadeBlock = coverInfo.getFacadeBlock(); if (facadeBlock != null) return coverInfo.getFacadeMeta(); } else { // we do not allow more than one type of facade per block, so no need to check every side // see comment in gregtech.common.covers.GT_Cover_FacadeBase.isCoverPlaceable - for (byte tSide : ALL_VALID_SIDES) { + for (final ForgeDirection tSide : ForgeDirection.VALID_DIRECTIONS) { final CoverInfo coverInfo = tile.getCoverInfoAtSide(tSide); final Block facadeBlock = coverInfo.getFacadeBlock(); if (facadeBlock != null) { @@ -477,13 +472,14 @@ public boolean hasComparatorInputOverride() { } @Override - public final int getComparatorInputOverride(World aWorld, int aX, int aY, int aZ, int aSide) { + public final int getComparatorInputOverride(World aWorld, int aX, int aY, int aZ, int ordinalSide) { final TileEntity aTileEntity = aWorld.getTileEntity(aX, aY, aZ); - return aTileEntity instanceof IMTE_GetComparatorInputOverride - ? ((IMTE_GetComparatorInputOverride) aTileEntity).getComparatorInputOverride((byte) aSide) - : aTileEntity instanceof IMTE_IsProvidingWeakPower - ? ((IMTE_IsProvidingWeakPower) aTileEntity).isProvidingWeakPower(GT_Utility.getOppositeSide(aSide)) - : super.getComparatorInputOverride(aWorld, aX, aY, aZ, aSide); + return aTileEntity instanceof IMTE_GetComparatorInputOverride override + ? override.getComparatorInputOverride(ForgeDirection.getOrientation(ordinalSide)) + : aTileEntity instanceof IMTE_IsProvidingWeakPower power ? power.isProvidingWeakPower( + ForgeDirection.getOrientation(ordinalSide) + .getOpposite()) + : super.getComparatorInputOverride(aWorld, aX, aY, aZ, ordinalSide); } @Override @@ -497,12 +493,9 @@ public final boolean isNormalCube(IBlockAccess aWorld, int aX, int aY, int aZ) { } @Override - public final boolean isSideSolid(IBlockAccess aWorld, int aX, int aY, int aZ, ForgeDirection aSide) { + public final boolean isSideSolid(IBlockAccess aWorld, int aX, int aY, int aZ, ForgeDirection side) { final TileEntity aTileEntity = aWorld.getTileEntity(aX, aY, aZ); - return aTileEntity instanceof IMultiTileEntity - ? ((IMultiTileEntity) aTileEntity) - .isSideSolid((byte) (aSide != null ? aSide.ordinal() : GT_Values.SIDE_UNKNOWN)) - : mOpaque; + return aTileEntity instanceof IMultiTileEntity mte ? mte.isSideSolid(side) : mOpaque; } @Override @@ -566,15 +559,14 @@ public final void onBlockExploded(World aWorld, int aX, int aY, int aZ, Explosio } @Override - public final boolean canConnectRedstone(IBlockAccess aWorld, int aX, int aY, int aZ, int aSide) { + public final boolean canConnectRedstone(IBlockAccess aWorld, int aX, int aY, int aZ, int ordinalSide) { return true; } @Override - public final boolean recolourBlock(World aWorld, int aX, int aY, int aZ, ForgeDirection aSide, int aColor) { + public final boolean recolourBlock(World aWorld, int aX, int aY, int aZ, ForgeDirection side, int aColor) { final TileEntity aTileEntity = aWorld.getTileEntity(aX, aY, aZ); - return aTileEntity instanceof IMultiTileEntity - && ((IMultiTileEntity) aTileEntity).recolourBlock((byte) aSide.ordinal(), (byte) aColor); + return aTileEntity instanceof IMultiTileEntity mte && mte.recolourBlock(side, (byte) aColor); } @Override @@ -627,12 +619,12 @@ public final IMultiTileEntity receiveMultiTileEntityData(IBlockAccess aWorld, in public void receiveCoverData(IMultiTileEntity mte, int aCover0, int aCover1, int aCover2, int aCover3, int aCover4, int aCover5) { boolean updated; - updated = mte.setCoverIDAtSideNoUpdate((byte) 0, aCover0); - updated |= mte.setCoverIDAtSideNoUpdate((byte) 1, aCover1); - updated |= mte.setCoverIDAtSideNoUpdate((byte) 2, aCover2); - updated |= mte.setCoverIDAtSideNoUpdate((byte) 3, aCover3); - updated |= mte.setCoverIDAtSideNoUpdate((byte) 4, aCover4); - updated |= mte.setCoverIDAtSideNoUpdate((byte) 5, aCover5); + updated = mte.setCoverIDAtSideNoUpdate(ForgeDirection.DOWN, aCover0); + updated |= mte.setCoverIDAtSideNoUpdate(ForgeDirection.UP, aCover1); + updated |= mte.setCoverIDAtSideNoUpdate(ForgeDirection.NORTH, aCover2); + updated |= mte.setCoverIDAtSideNoUpdate(ForgeDirection.SOUTH, aCover3); + updated |= mte.setCoverIDAtSideNoUpdate(ForgeDirection.WEST, aCover4); + updated |= mte.setCoverIDAtSideNoUpdate(ForgeDirection.EAST, aCover5); if (updated) { mte.issueBlockUpdate(); diff --git a/src/main/java/gregtech/api/multitileentity/MultiTileEntityBlockInternal.java b/src/main/java/gregtech/api/multitileentity/MultiTileEntityBlockInternal.java index a3637e4626e..17e217ae7e5 100644 --- a/src/main/java/gregtech/api/multitileentity/MultiTileEntityBlockInternal.java +++ b/src/main/java/gregtech/api/multitileentity/MultiTileEntityBlockInternal.java @@ -10,6 +10,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.StatCollector; import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; import gregtech.api.GregTech_API; import gregtech.api.multitileentity.interfaces.IMultiTileEntity; @@ -45,8 +46,8 @@ public final String getLocalizedName() { return StatCollector.translateToLocal(mMultiTileEntityRegistry.mNameInternal + ".name"); } - public boolean placeBlock(World aWorld, int aX, int aY, int aZ, byte aSide, short aMetaData, NBTTagCompound aNBT, - boolean aCauseBlockUpdates, boolean aForcePlacement) { + public boolean placeBlock(World aWorld, int aX, int aY, int aZ, ForgeDirection side, short aMetaData, + NBTTagCompound aNBT, boolean aCauseBlockUpdates, boolean aForcePlacement) { final MultiTileEntityContainer aMTEContainer = mMultiTileEntityRegistry .getNewTileEntityContainer(aWorld, aX, aY, aZ, aMetaData, aNBT); if (aMTEContainer == null) return false; diff --git a/src/main/java/gregtech/api/multitileentity/MultiTileEntityItemInternal.java b/src/main/java/gregtech/api/multitileentity/MultiTileEntityItemInternal.java index a37fa9956e8..07a9124df47 100644 --- a/src/main/java/gregtech/api/multitileentity/MultiTileEntityItemInternal.java +++ b/src/main/java/gregtech/api/multitileentity/MultiTileEntityItemInternal.java @@ -19,13 +19,13 @@ import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.IIcon; import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.IFluidContainerItem; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.GregTech_API; -import gregtech.api.enums.GT_Values; import gregtech.api.metatileentity.CoverableTileEntity; import gregtech.api.multitileentity.interfaces.IItemUpdatable; import gregtech.api.multitileentity.interfaces.IMultiTileEntity; @@ -83,25 +83,27 @@ public void getSubItems(Item aItem, CreativeTabs aTab, List aList) { } @Override - public boolean onItemUse(ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, int aSide, - float aHitX, float aHitY, float aHitZ) { + public boolean onItemUse(ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, + int ordinalSide, float aHitX, float aHitY, float aHitZ) { if (aY < 0 || aY > aWorld.getHeight()) return false; try { + ForgeDirection side = ForgeDirection.getOrientation(ordinalSide); final Block tClickedBlock = aWorld.getBlock(aX, aY, aZ); if (tClickedBlock instanceof BlockSnow && (aWorld.getBlockMetadata(aX, aY, aZ) & 7) < 1) { - aSide = SIDE_TOP; + ordinalSide = SIDE_TOP; + side = ForgeDirection.UP; } else if (tClickedBlock != Blocks.vine && tClickedBlock != Blocks.tallgrass && tClickedBlock != Blocks.deadbush && !tClickedBlock.isReplaceable(aWorld, aX, aY, aZ)) { - aX += GT_Values.OFFX[aSide]; - aY += GT_Values.OFFY[aSide]; - aZ += GT_Values.OFFZ[aSide]; + aX += side.offsetX; + aY += side.offsetY; + aZ += side.offsetZ; } final Block tReplacedBlock = aWorld.getBlock(aX, aY, aZ); if (!tReplacedBlock.isReplaceable(aWorld, aX, aY, aZ) - || !mBlock.canReplace(aWorld, aX, aY, aZ, aSide, aStack)) return false; - if (aStack.stackSize == 0 || (aPlayer != null && !aPlayer.canPlayerEdit(aX, aY, aZ, aSide, aStack))) + || !mBlock.canReplace(aWorld, aX, aY, aZ, ordinalSide, aStack)) return false; + if (aStack.stackSize == 0 || (aPlayer != null && !aPlayer.canPlayerEdit(aX, aY, aZ, ordinalSide, aStack))) return false; final MultiTileEntityContainer aMTEContainer = mBlock.mMultiTileEntityRegistry @@ -109,30 +111,29 @@ public boolean onItemUse(ItemStack aStack, EntityPlayer aPlayer, World aWorld, i if (aMTEContainer != null && (aPlayer == null || aPlayer.isSneaking() - || !(aMTEContainer.mTileEntity instanceof IMTE_OnlyPlaceableWhenSneaking) - || !((IMTE_OnlyPlaceableWhenSneaking) aMTEContainer.mTileEntity).onlyPlaceableWhenSneaking()) + || !(aMTEContainer.mTileEntity instanceof IMTE_OnlyPlaceableWhenSneaking mteSNeaking) + || !mteSNeaking.onlyPlaceableWhenSneaking()) && (aWorld.checkNoEntityCollision(AxisAlignedBB.getBoundingBox(aX, aY, aZ, aX + 1, aY + 1, aZ + 1)) - || (aMTEContainer.mTileEntity instanceof IMTE_IgnoreEntityCollisionWhenPlacing - && ((IMTE_IgnoreEntityCollisionWhenPlacing) aMTEContainer.mTileEntity) - .ignoreEntityCollisionWhenPlacing( - aStack, - aPlayer, - aWorld, - aX, - aY, - aZ, - (byte) aSide, - aHitX, - aHitY, - aHitZ))) - && (!(aMTEContainer.mTileEntity instanceof IMTE_CanPlace) || ((IMTE_CanPlace) aMTEContainer.mTileEntity) - .canPlace(aStack, aPlayer, aWorld, aX, aY, aZ, (byte) aSide, aHitX, aHitY, aHitZ)) + || (aMTEContainer.mTileEntity instanceof IMTE_IgnoreEntityCollisionWhenPlacing mteIgnoreCollision + && mteIgnoreCollision.ignoreEntityCollisionWhenPlacing( + aStack, + aPlayer, + aWorld, + aX, + aY, + aZ, + side, + aHitX, + aHitY, + aHitZ))) + && (!(aMTEContainer.mTileEntity instanceof IMTE_CanPlace mteCanPlace) + || mteCanPlace.canPlace(aStack, aPlayer, aWorld, aX, aY, aZ, side, aHitX, aHitY, aHitZ)) && aWorld.setBlock(aX, aY, aZ, aMTEContainer.mBlock, 15 - aMTEContainer.mBlockMetaData, 2)) { aMTEContainer.setMultiTile(aWorld, aX, aY, aZ); try { if (((IMultiTileEntity) aMTEContainer.mTileEntity) - .onPlaced(aStack, aPlayer, aWorld, aX, aY, aZ, (byte) aSide, aHitX, aHitY, aHitZ)) { + .onPlaced(aStack, aPlayer, aWorld, aX, aY, aZ, side, aHitX, aHitY, aHitZ)) { aWorld.playSoundEffect( aX + 0.5, aY + 0.5, @@ -145,9 +146,8 @@ public boolean onItemUse(ItemStack aStack, EntityPlayer aPlayer, World aWorld, i GT_FML_LOGGER.error("onPlaced", e); } try { - if (aMTEContainer.mTileEntity instanceof IMTE_HasMultiBlockMachineRelevantData - && (((IMTE_HasMultiBlockMachineRelevantData) aMTEContainer.mTileEntity) - .hasMultiBlockMachineRelevantData())) { + if (aMTEContainer.mTileEntity instanceof IMTE_HasMultiBlockMachineRelevantData mteData + && (mteData.hasMultiBlockMachineRelevantData())) { GregTech_API.causeMachineUpdate(aWorld, aX, aY, aZ); } } catch (Throwable e) { @@ -187,8 +187,8 @@ public void updateItemStack(ItemStack aStack) { if (tContainer == null) return; final MultiTileEntityContainer tTileEntityContainer = mBlock.mMultiTileEntityRegistry .getNewTileEntityContainer(aStack); - if (tTileEntityContainer != null && tTileEntityContainer.mTileEntity instanceof IItemUpdatable) { - ((IItemUpdatable) tTileEntityContainer.mTileEntity).updateItemStack(aStack); + if (tTileEntityContainer != null && tTileEntityContainer.mTileEntity instanceof IItemUpdatable itemUpdatable) { + itemUpdatable.updateItemStack(aStack); } } @@ -198,8 +198,8 @@ public void updateItemStack(ItemStack aStack, World aWorld, int aX, int aY, int if (tContainer == null) return; final MultiTileEntityContainer tTileEntityContainer = mBlock.mMultiTileEntityRegistry .getNewTileEntityContainer(aStack); - if (tTileEntityContainer != null && tTileEntityContainer.mTileEntity instanceof IItemUpdatable) { - ((IItemUpdatable) tTileEntityContainer.mTileEntity).updateItemStack(aStack, aWorld, aX, aY, aZ); + if (tTileEntityContainer != null && tTileEntityContainer.mTileEntity instanceof IItemUpdatable itemUpdatable) { + itemUpdatable.updateItemStack(aStack, aWorld, aX, aY, aZ); } } @@ -209,9 +209,9 @@ public int getItemStackLimit(ItemStack aStack) { if (tContainer == null) return 1; final MultiTileEntityContainer tTileEntityContainer = mBlock.mMultiTileEntityRegistry .getNewTileEntityContainer(aStack); - if (tTileEntityContainer != null && tTileEntityContainer.mTileEntity instanceof IMTE_GetMaxStackSize) { - return ((IMTE_GetMaxStackSize) tTileEntityContainer.mTileEntity) - .getMaxStackSize(aStack, tContainer.mStackSize); + if (tTileEntityContainer != null + && tTileEntityContainer.mTileEntity instanceof IMTE_GetMaxStackSize maxStackSize) { + return maxStackSize.getMaxStackSize(aStack, tContainer.mStackSize); } return tContainer.mStackSize; } @@ -225,8 +225,9 @@ public void onCreated(ItemStack aStack, World aWorld, EntityPlayer aPlayer) { public FluidStack getFluid(ItemStack aStack) { final MultiTileEntityContainer tTileEntityContainer = mBlock.mMultiTileEntityRegistry .getNewTileEntityContainer(aStack); - if (tTileEntityContainer != null && tTileEntityContainer.mTileEntity instanceof IFluidContainerItem) { - final FluidStack rFluid = ((IFluidContainerItem) tTileEntityContainer.mTileEntity).getFluid(aStack); + if (tTileEntityContainer != null + && tTileEntityContainer.mTileEntity instanceof IFluidContainerItem fluidContainerItem) { + final FluidStack rFluid = fluidContainerItem.getFluid(aStack); updateItemStack(aStack); return rFluid; } @@ -237,8 +238,9 @@ public FluidStack getFluid(ItemStack aStack) { public int getCapacity(ItemStack aStack) { final MultiTileEntityContainer tTileEntityContainer = mBlock.mMultiTileEntityRegistry .getNewTileEntityContainer(aStack); - if (tTileEntityContainer != null && tTileEntityContainer.mTileEntity instanceof IFluidContainerItem) { - final int rCapacity = ((IFluidContainerItem) tTileEntityContainer.mTileEntity).getCapacity(aStack); + if (tTileEntityContainer != null + && tTileEntityContainer.mTileEntity instanceof IFluidContainerItem fluidContainerItem) { + final int rCapacity = fluidContainerItem.getCapacity(aStack); updateItemStack(aStack); return rCapacity; } @@ -249,8 +251,9 @@ public int getCapacity(ItemStack aStack) { public int fill(ItemStack aStack, FluidStack aFluid, boolean aDoFill) { final MultiTileEntityContainer tTileEntityContainer = mBlock.mMultiTileEntityRegistry .getNewTileEntityContainer(aStack); - if (tTileEntityContainer != null && tTileEntityContainer.mTileEntity instanceof IFluidContainerItem) { - final int tFilled = ((IFluidContainerItem) tTileEntityContainer.mTileEntity).fill(aStack, aFluid, aDoFill); + if (tTileEntityContainer != null + && tTileEntityContainer.mTileEntity instanceof IFluidContainerItem fluidContainerItem) { + final int tFilled = fluidContainerItem.fill(aStack, aFluid, aDoFill); updateItemStack(aStack); return tFilled; } @@ -261,9 +264,9 @@ public int fill(ItemStack aStack, FluidStack aFluid, boolean aDoFill) { public FluidStack drain(ItemStack aStack, int aMaxDrain, boolean aDoDrain) { final MultiTileEntityContainer tTileEntityContainer = mBlock.mMultiTileEntityRegistry .getNewTileEntityContainer(aStack); - if (tTileEntityContainer != null && tTileEntityContainer.mTileEntity instanceof IFluidContainerItem) { - final FluidStack rFluid = ((IFluidContainerItem) tTileEntityContainer.mTileEntity) - .drain(aStack, aMaxDrain, aDoDrain); + if (tTileEntityContainer != null + && tTileEntityContainer.mTileEntity instanceof IFluidContainerItem fluidContainerItem) { + final FluidStack rFluid = fluidContainerItem.drain(aStack, aMaxDrain, aDoDrain); updateItemStack(aStack); return rFluid; } @@ -271,7 +274,7 @@ public FluidStack drain(ItemStack aStack, int aMaxDrain, boolean aDoDrain) { } @Override - public boolean func_150936_a /* canPlaceAtSide */(World aWorld, int aX, int aY, int aZ, int aSide, + public boolean func_150936_a /* canPlaceAtSide */(World aWorld, int aX, int aY, int aZ, int ordinalSide, EntityPlayer aPlayer, ItemStack aStack) { return true; } diff --git a/src/main/java/gregtech/api/multitileentity/base/MultiTileEntity.java b/src/main/java/gregtech/api/multitileentity/base/MultiTileEntity.java index 4312f99ce77..027d666a66e 100644 --- a/src/main/java/gregtech/api/multitileentity/base/MultiTileEntity.java +++ b/src/main/java/gregtech/api/multitileentity/base/MultiTileEntity.java @@ -1,7 +1,7 @@ package gregtech.api.multitileentity.base; import static gregtech.GT_Mod.GT_FML_LOGGER; -import static gregtech.api.enums.GT_Values.OPOS; +import static gregtech.api.enums.GT_Values.NBT; import static gregtech.api.enums.GT_Values.VALID_SIDES; import java.io.IOException; @@ -201,7 +201,7 @@ public ITexture getTexture(ForgeDirection side) { } @Override - public ITexture[] getTexture(Block ignoredBlock, byte ignoredSide) { + public ITexture[] getTexture(Block ignoredBlock, ForgeDirection ignoredSide) { // We are not going to be using this return null; } @@ -361,34 +361,34 @@ public void updateEntity() { public void doBlockUpdate() { final Block tBlock = getBlock(getCoords()); worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, tBlock); - if (this instanceof IMTE_IsProvidingStrongPower) for (byte tSide : GT_Values.ALL_VALID_SIDES) { - if (getBlockAtSide(tSide).isNormalCube( - worldObj, - xCoord + GT_Values.OFFX[tSide], - yCoord + GT_Values.OFFY[tSide], - zCoord + GT_Values.OFFZ[tSide])) { - worldObj.notifyBlocksOfNeighborChange( - xCoord + GT_Values.OFFX[tSide], - yCoord + GT_Values.OFFY[tSide], - zCoord + GT_Values.OFFZ[tSide], - tBlock, - OPOS[tSide]); + if (this instanceof IMTE_IsProvidingStrongPower) { + for (final ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + if (getBlockAtSide(side) + .isNormalCube(worldObj, xCoord + side.offsetX, yCoord + side.offsetY, zCoord + side.offsetZ)) { + worldObj.notifyBlocksOfNeighborChange( + xCoord + side.offsetX, + yCoord + side.offsetY, + zCoord + side.offsetZ, + tBlock, + side.getOpposite() + .ordinal()); + } } } needsBlockUpdate = false; } @Override - public boolean shouldSideBeRendered(byte aSide) { - final TileEntity tTileEntity = getTileEntityAtSideAndDistance(aSide, 1); + public boolean shouldSideBeRendered(ForgeDirection side) { + final TileEntity tTileEntity = getTileEntityAtSideAndDistance(side, 1); // TODO: check to an interface // if (getBlockAtSide(aSide) == Blocks.glass) return false; - return tTileEntity instanceof IMultiTileEntity ? !((IMultiTileEntity) tTileEntity).isSurfaceOpaque(OPOS[aSide]) - : !getBlockAtSide(aSide).isOpaqueCube(); + return tTileEntity instanceof IMultiTileEntity mte ? !mte.isSurfaceOpaque(side.getOpposite()) + : !getBlockAtSide(side).isOpaqueCube(); } @Override - public boolean isSurfaceOpaque(byte aSide) { + public boolean isSurfaceOpaque(ForgeDirection side) { return true; } @@ -430,13 +430,13 @@ public boolean paint(int aRGB) { } @Override - public boolean isFacingValid(byte aFacing) { + public boolean isFacingValid(ForgeDirection facing) { return false; } @Override - public byte getFrontFacing() { - return (byte) facing.ordinal(); + public ForgeDirection getFrontFacing() { + return facing; } /** @@ -445,9 +445,9 @@ public byte getFrontFacing() { * @return Whether the facing was changed */ @Override - public boolean setMainFacing(byte aSide) { - if (!isValidFacing(aSide)) return false; - facing = ForgeDirection.getOrientation(aSide); + public boolean setMainFacing(ForgeDirection side) { + if (!isValidFacing(side)) return false; + facing = side; issueClientUpdate(); issueBlockUpdate(); @@ -471,14 +471,13 @@ public int getPaint() { } @Override - public byte getBackFacing() { - return (byte) facing.getOpposite() - .ordinal(); + public ForgeDirection getBackFacing() { + return facing.getOpposite(); } @Override - public boolean isValidFacing(byte aSide) { - return aSide >= 0 && aSide <= 6 && getValidFacings()[aSide]; + public boolean isValidFacing(ForgeDirection side) { + return side != ForgeDirection.UNKNOWN && getValidFacings()[side.ordinal()]; } @Override @@ -487,8 +486,8 @@ public boolean[] getValidFacings() { } @Override - public void issueCoverUpdate(byte aSide) { - super.issueCoverUpdate(aSide); + public void issueCoverUpdate(ForgeDirection side) { + super.issueCoverUpdate(side); issueClientUpdate(); } @@ -643,7 +642,7 @@ public boolean isStillValid() { } @Override - public boolean allowCoverOnSide(byte aSide, GT_ItemStack aCoverID) { + public boolean allowCoverOnSide(ForgeDirection side, GT_ItemStack aCoverID) { return true; } @@ -707,10 +706,9 @@ public void setOwnerUuid(UUID uuid) { } @Override - public boolean onPlaced(ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, byte aSide, - float aHitX, float aHitY, float aHitZ) { - facing = ForgeDirection - .getOrientation(getSideForPlayerPlacing(aPlayer, (byte) facing.ordinal(), getValidFacings())); + public boolean onPlaced(ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, + ForgeDirection side, float aHitX, float aHitY, float aHitZ) { + facing = getSideForPlayerPlacing(aPlayer, facing, getValidFacings()); onFacingChange(); return true; } @@ -725,9 +723,9 @@ public boolean allowRightclick(Entity aEntity) { } @Override - public boolean onBlockActivated(EntityPlayer aPlayer, byte aSide, float aX, float aY, float aZ) { + public boolean onBlockActivated(EntityPlayer aPlayer, ForgeDirection side, float aX, float aY, float aZ) { try { - return allowRightclick(aPlayer) && onRightClick(aPlayer, aSide, aX, aY, aZ); + return allowRightclick(aPlayer) && onRightClick(aPlayer, side, aX, aY, aZ); } catch (Throwable e) { GT_FML_LOGGER.error("onBlockActivated Failed", e); e.printStackTrace(GT_Log.err); @@ -736,24 +734,25 @@ public boolean onBlockActivated(EntityPlayer aPlayer, byte aSide, float aX, floa } @Override - public boolean onRightClick(EntityPlayer aPlayer, byte aSide, float aX, float aY, float aZ) { + public boolean onRightClick(EntityPlayer aPlayer, ForgeDirection side, float aX, float aY, float aZ) { if (isClientSide()) { // Configure Cover, sneak can also be: screwdriver, wrench, side cutter, soldering iron if (aPlayer.isSneaking()) { - final byte tSide = (getCoverIDAtSide(aSide) == 0) ? GT_Utility.determineWrenchingSide(aSide, aX, aY, aZ) - : aSide; + final ForgeDirection tSide = (getCoverIDAtSide(side) == 0) + ? GT_Utility.determineWrenchingSide(side, aX, aY, aZ) + : side; return (getCoverBehaviorAtSideNew(tSide).hasCoverGUI()); - } else if (getCoverBehaviorAtSideNew(aSide).onCoverRightclickClient(aSide, this, aPlayer, aX, aY, aZ)) { + } else if (getCoverBehaviorAtSideNew(side).onCoverRightclickClient(side, this, aPlayer, aX, aY, aZ)) { return true; } - if (!getCoverInfoAtSide(aSide).isGUIClickable()) return false; + if (!getCoverInfoAtSide(side).isGUIClickable()) return false; } if (isServerSide()) { if (!privateAccess() || aPlayer.getDisplayName() .equalsIgnoreCase(getOwnerName())) { final ItemStack tCurrentItem = aPlayer.inventory.getCurrentItem(); - final byte wrenchSide = GT_Utility.determineWrenchingSide(aSide, aX, aY, aZ); + final ForgeDirection wrenchSide = GT_Utility.determineWrenchingSide(side, aX, aY, aZ); if (tCurrentItem != null) { if (getColorization() >= 0 @@ -773,7 +772,7 @@ public boolean onRightClick(EntityPlayer aPlayer, byte aSide, float aX, float aY if (GT_Utility.isStackInList(tCurrentItem, GregTech_API.sWireCutterList)) return onWireCutterRightClick(aPlayer, tCurrentItem, wrenchSide, aX, aY, aZ); - final byte coverSide = getCoverIDAtSide(aSide) == 0 ? wrenchSide : aSide; + final ForgeDirection coverSide = getCoverIDAtSide(side) == 0 ? wrenchSide : side; if (getCoverIDAtSide(coverSide) == 0) { if (GT_Utility.isStackInList(tCurrentItem, GregTech_API.sCovers.keySet())) { @@ -806,47 +805,46 @@ && allowCoverOnSide(coverSide, new GT_ItemStack(tCurrentItem))) { xCoord, yCoord, zCoord); - dropCover(coverSide, aSide, false); + dropCover(coverSide, side, false); } sendCoverDataIfNeeded(); return true; } } } else if (aPlayer.isSneaking()) { // Sneak click, no tool -> open cover config if possible. - aSide = (getCoverIDAtSide(aSide) == 0) ? GT_Utility.determineWrenchingSide(aSide, aX, aY, aZ) - : aSide; - return getCoverIDAtSide(aSide) > 0 && getCoverBehaviorAtSideNew(aSide).onCoverShiftRightClick( - aSide, - getCoverIDAtSide(aSide), - getComplexCoverDataAtSide(aSide), + side = (getCoverIDAtSide(side) == 0) ? GT_Utility.determineWrenchingSide(side, aX, aY, aZ) : side; + return getCoverIDAtSide(side) > 0 && getCoverBehaviorAtSideNew(side).onCoverShiftRightClick( + side, + getCoverIDAtSide(side), + getComplexCoverDataAtSide(side), this, aPlayer); } - if (getCoverBehaviorAtSideNew(aSide).onCoverRightClick( - aSide, - getCoverIDAtSide(aSide), - getComplexCoverDataAtSide(aSide), + if (getCoverBehaviorAtSideNew(side).onCoverRightClick( + side, + getCoverIDAtSide(side), + getComplexCoverDataAtSide(side), this, aPlayer, aX, aY, aZ)) return true; - if (!getCoverInfoAtSide(aSide).isGUIClickable()) return false; + if (!getCoverInfoAtSide(side).isGUIClickable()) return false; - return openModularUi(aPlayer, aSide); + return openModularUi(aPlayer, side); } } return false; } - public boolean hasGui(byte aSide) { + public boolean hasGui(ForgeDirection side) { return false; } - boolean openModularUi(EntityPlayer aPlayer, byte aSide) { - if (!hasGui(aSide) || !isServerSide()) { + boolean openModularUi(EntityPlayer aPlayer, ForgeDirection side) { + if (!hasGui(side) || !isServerSide()) { System.out.println("No GUI or Not Serverside"); return false; } @@ -856,8 +854,8 @@ boolean openModularUi(EntityPlayer aPlayer, byte aSide) { return true; } - public boolean onWrenchRightClick(EntityPlayer aPlayer, ItemStack tCurrentItem, byte wrenchSide, float aX, float aY, - float aZ) { + public boolean onWrenchRightClick(EntityPlayer aPlayer, ItemStack tCurrentItem, ForgeDirection wrenchSide, float aX, + float aY, float aZ) { if (setMainFacing(wrenchSide)) { GT_ModHandler.damageOrDechargeItem(tCurrentItem, 1, 1000, aPlayer); GT_Utility.sendSoundToPlayers(worldObj, SoundResource.IC2_TOOLS_WRENCH, 1.0F, -1, xCoord, yCoord, zCoord); @@ -865,8 +863,8 @@ public boolean onWrenchRightClick(EntityPlayer aPlayer, ItemStack tCurrentItem, return true; } - public boolean onScrewdriverRightClick(EntityPlayer aPlayer, ItemStack tCurrentItem, byte wrenchSide, float aX, - float aY, float aZ) { + public boolean onScrewdriverRightClick(EntityPlayer aPlayer, ItemStack tCurrentItem, ForgeDirection wrenchSide, + float aX, float aY, float aZ) { if (GT_ModHandler.damageOrDechargeItem(tCurrentItem, 1, 200, aPlayer)) { setCoverDataAtSide( wrenchSide, @@ -885,26 +883,26 @@ public boolean onScrewdriverRightClick(EntityPlayer aPlayer, ItemStack tCurrentI return true; } - public boolean onHammerRightClick(EntityPlayer aPlayer, ItemStack tCurrentItem, byte wrenchSide, float aX, float aY, - float aZ) { + public boolean onHammerRightClick(EntityPlayer aPlayer, ItemStack tCurrentItem, ForgeDirection wrenchSide, float aX, + float aY, float aZ) { return true; } - public boolean onMalletRightClick(EntityPlayer aPlayer, ItemStack tCurrentItem, byte wrenchSide, float aX, float aY, - float aZ) { + public boolean onMalletRightClick(EntityPlayer aPlayer, ItemStack tCurrentItem, ForgeDirection wrenchSide, float aX, + float aY, float aZ) { return true; } - public boolean onSolderingRightClick(EntityPlayer aPlayer, ItemStack tCurrentItem, byte wrenchSide, float aX, - float aY, float aZ) { + public boolean onSolderingRightClick(EntityPlayer aPlayer, ItemStack tCurrentItem, ForgeDirection wrenchSide, + float aX, float aY, float aZ) { return true; } - public boolean onWireCutterRightClick(EntityPlayer aPlayer, ItemStack tCurrentItem, byte wrenchSide, float aX, - float aY, float aZ) { + public boolean onWireCutterRightClick(EntityPlayer aPlayer, ItemStack tCurrentItem, ForgeDirection wrenchSide, + float aX, float aY, float aZ) { return true; } @@ -923,7 +921,7 @@ public float getExplosionResistance() { public void onExploded(Explosion aExplosion) {} @Override - public boolean isSideSolid(byte aSide) { + public boolean isSideSolid(ForgeDirection side) { return true; } @@ -949,7 +947,7 @@ public boolean getSubItems(MultiTileEntityBlockInternal aBlock, Item aItem, Crea } @Override - public boolean recolourBlock(byte aSide, byte aColor) { + public boolean recolourBlock(ForgeDirection side, byte aColor) { // if (aColor > 15 || aColor < -1) aColor = -1; // if(paint((byte) (aColor + 1))) { //// updateClientData(); @@ -994,12 +992,12 @@ public GT_Packet_MultiTileEntity getClientDataPacket() { color); packet.setCoverData( - getCoverInfoAtSide((byte) 0).getCoverID(), - getCoverInfoAtSide((byte) 1).getCoverID(), - getCoverInfoAtSide((byte) 2).getCoverID(), - getCoverInfoAtSide((byte) 3).getCoverID(), - getCoverInfoAtSide((byte) 4).getCoverID(), - getCoverInfoAtSide((byte) 5).getCoverID()); + getCoverInfoAtSide(ForgeDirection.DOWN).getCoverID(), + getCoverInfoAtSide(ForgeDirection.UP).getCoverID(), + getCoverInfoAtSide(ForgeDirection.NORTH).getCoverID(), + getCoverInfoAtSide(ForgeDirection.SOUTH).getCoverID(), + getCoverInfoAtSide(ForgeDirection.WEST).getCoverID(), + getCoverInfoAtSide(ForgeDirection.EAST).getCoverID()); packet.setRedstoneData( (byte) (((mSidedRedstone[0] > 0) ? 1 : 0) | ((mSidedRedstone[1] > 0) ? 2 : 0) @@ -1077,14 +1075,10 @@ public Packet getDescriptionPacket() { } @Override - public void getWailaBody(ItemStack itemStack, List currenttip, IWailaDataAccessor accessor, + public void getWailaBody(ItemStack itemStack, List currentTip, IWailaDataAccessor accessor, IWailaConfigHandler config) { - super.getWailaBody(itemStack, currenttip, accessor, config); - currenttip.add( - String.format( - "Facing: %s", - ForgeDirection.getOrientation(getFrontFacing()) - .name())); + super.getWailaBody(itemStack, currentTip, accessor, config); + currentTip.add(String.format("Facing: %s", getFrontFacing().name())); } @Override @@ -1125,37 +1119,37 @@ protected void addDebugInfo(EntityPlayer aPlayer, int aLogLevel, ArrayList getDrops(int aFortune, boolean aSilkTouch); - boolean isSideSolid(byte aSide); + boolean isSideSolid(ForgeDirection side); float getExplosionResistance(Entity aExploder, double aExplosionX, double aExplosionY, double aExplosionZ); @@ -169,7 +170,7 @@ default void onLeftClick(EntityPlayer aPlayer) { void onExploded(Explosion aExplosion); - boolean recolourBlock(byte aSide, byte aColor); + boolean recolourBlock(ForgeDirection side, byte aColor); /** Adds to the Creative Tab. return false to prevent it from being added. */ boolean getSubItems(MultiTileEntityBlockInternal aBlock, Item aItem, CreativeTabs aTab, List aList, @@ -177,11 +178,11 @@ boolean getSubItems(MultiTileEntityBlockInternal aBlock, Item aItem, CreativeTab ItemStack getPickBlock(MovingObjectPosition aTarget); - boolean shouldSideBeRendered(byte aSide); + boolean shouldSideBeRendered(ForgeDirection side); - boolean isSurfaceOpaque(byte aSide); + boolean isSurfaceOpaque(ForgeDirection side); - boolean onPlaced(ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, byte aSide, + boolean onPlaced(ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, ForgeDirection side, float aHitX, float aHitY, float aHitZ); // ItemStack getPickBlock(MovingObjectPosition aTarget); @@ -198,18 +199,18 @@ interface IMTE_OnNeighborBlockChange extends IMultiTileEntity { interface IMTE_IsProvidingWeakPower extends IMultiTileEntity { /** Remember that it passes the opposite Side due to the way vanilla works! */ - int isProvidingWeakPower(byte aOppositeSide); + int isProvidingWeakPower(ForgeDirection oppositeSide); } interface IMTE_IsProvidingStrongPower extends IMultiTileEntity { /** Remember that it passes the opposite Side due to the way vanilla works! */ - int isProvidingStrongPower(byte aOppositeSide); + int isProvidingStrongPower(ForgeDirection oppositeSide); } interface IMTE_ShouldCheckWeakPower extends IMultiTileEntity { - boolean shouldCheckWeakPower(byte aSide); + boolean shouldCheckWeakPower(ForgeDirection side); } interface IMTE_GetWeakChanges extends IMultiTileEntity { @@ -219,7 +220,7 @@ interface IMTE_GetWeakChanges extends IMultiTileEntity { interface IMTE_GetComparatorInputOverride extends IMultiTileEntity { - int getComparatorInputOverride(byte aSide); + int getComparatorInputOverride(ForgeDirection side); } interface IMTE_BreakBlock extends IMultiTileEntity { @@ -258,14 +259,14 @@ interface IMTE_IgnoreEntityCollisionWhenPlacing extends IMultiTileEntity { * pipes/wires. */ boolean ignoreEntityCollisionWhenPlacing(ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, - int aZ, byte aSide, float aHitX, float aHitY, float aHitZ); + int aZ, ForgeDirection side, float aHitX, float aHitY, float aHitZ); } interface IMTE_CanPlace extends IMultiTileEntity { /** Return false if this TileEntity cannot be placed at that Location. */ - boolean canPlace(ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, byte aSide, - float aHitX, float aHitY, float aHitZ); + boolean canPlace(ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, + ForgeDirection side, float aHitX, float aHitY, float aHitZ); } interface IMTE_GetMaxStackSize extends IMultiTileEntity { diff --git a/src/main/java/gregtech/api/multitileentity/machine/MultiTileBasicMachine.java b/src/main/java/gregtech/api/multitileentity/machine/MultiTileBasicMachine.java index f3cc00692c9..e36e7e60fb2 100644 --- a/src/main/java/gregtech/api/multitileentity/machine/MultiTileBasicMachine.java +++ b/src/main/java/gregtech/api/multitileentity/machine/MultiTileBasicMachine.java @@ -309,7 +309,7 @@ public void copyTextures() { @Override public ITexture getTexture(ForgeDirection side) { - ITexture texture = super.getTexture(side); + final ITexture texture = super.getTexture(side); if (side == facing) { if (isActive()) { return TextureFactory.of(texture, activeOverlayTexture, activeOverlayGlowTexture); @@ -318,7 +318,7 @@ public ITexture getTexture(ForgeDirection side) { return TextureFactory.of(texture, inactiveOverlayTexture, inactiveOverlayGlowTexture); } - return TextureFactory.of(texture, getCoverTexture((byte) side.ordinal())); + return TextureFactory.of(texture, getCoverTexture(side)); } @Override @@ -368,19 +368,19 @@ && getTileEntityOffset(0, 0, 0) == this } @Override - public boolean isLiquidInput(byte aSide) { - return facing.compareTo(ForgeDirection.getOrientation(aSide)) != 0; + public boolean isLiquidInput(ForgeDirection side) { + return side != facing; } @Override - public boolean isLiquidOutput(byte aSide) { - return facing.compareTo(ForgeDirection.getOrientation(aSide)) != 0; + public boolean isLiquidOutput(ForgeDirection side) { + return side != facing; } @Override - protected IFluidTank[] getFluidTanks(byte aSide) { - final boolean fluidInput = isLiquidInput(aSide); - final boolean fluidOutput = isLiquidOutput(aSide); + protected IFluidTank[] getFluidTanks(ForgeDirection side) { + final boolean fluidInput = isLiquidInput(side); + final boolean fluidOutput = isLiquidOutput(side); if (fluidInput && fluidOutput) { final IFluidTank[] rTanks = new IFluidTank[inputTanks.length + outputTanks.length]; @@ -396,13 +396,13 @@ protected IFluidTank[] getFluidTanks(byte aSide) { } @Override - public IFluidTank getFluidTankFillable(byte aSide, FluidStack aFluidToFill) { - return getFluidTankFillable((byte) facing.ordinal(), aSide, aFluidToFill); + public IFluidTank getFluidTankFillable(ForgeDirection side, FluidStack aFluidToFill) { + return getFluidTankFillable(facing, side, aFluidToFill); } - public IFluidTank getFluidTankFillable(byte sideSource, byte sideDestination, FluidStack fluidToFill) { - if (ForgeDirection.getOrientation(sideSource) - .compareTo(ForgeDirection.getOrientation(sideDestination)) != 0) return null; + public IFluidTank getFluidTankFillable(ForgeDirection sideSource, ForgeDirection sideDestination, + FluidStack fluidToFill) { + if (sideSource.compareTo(sideDestination) != 0) return null; for (FluidTankGT tankGT : inputTanks) if (tankGT.contains(fluidToFill)) return tankGT; // if (!mRecipes.containsInput(aFluidToFill, this, slot(mRecipes.mInputItemsCount + // mRecipes.mOutputItemsCount))) return null; @@ -411,13 +411,13 @@ public IFluidTank getFluidTankFillable(byte sideSource, byte sideDestination, Fl } @Override - protected IFluidTank getFluidTankDrainable(byte aSide, FluidStack aFluidToDrain) { - return getFluidTankDrainable((byte) facing.ordinal(), aSide, aFluidToDrain); + protected IFluidTank getFluidTankDrainable(ForgeDirection side, FluidStack aFluidToDrain) { + return getFluidTankDrainable(facing, side, aFluidToDrain); } - protected IFluidTank getFluidTankDrainable(byte sideSource, byte sideDestination, FluidStack fluidToDrain) { - if (ForgeDirection.getOrientation(sideSource) - .compareTo(ForgeDirection.getOrientation(sideDestination)) != 0) return null; + protected IFluidTank getFluidTankDrainable(ForgeDirection sideSource, ForgeDirection sideDestination, + FluidStack fluidToDrain) { + if (sideSource.compareTo(sideDestination) != 0) return null; for (FluidTankGT fluidTankGT : outputTanks) if (fluidToDrain == null ? fluidTankGT.has() : fluidTankGT.contains(fluidToDrain)) return fluidTankGT; diff --git a/src/main/java/gregtech/api/multitileentity/multiblock/base/Controller.java b/src/main/java/gregtech/api/multitileentity/multiblock/base/Controller.java index 9fdac059da1..a4fbb9f61ed 100644 --- a/src/main/java/gregtech/api/multitileentity/multiblock/base/Controller.java +++ b/src/main/java/gregtech/api/multitileentity/multiblock/base/Controller.java @@ -2,7 +2,6 @@ import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; import static gregtech.GT_Mod.GT_FML_LOGGER; -import static gregtech.api.enums.GT_Values.ALL_VALID_SIDES; import static gregtech.api.multitileentity.enums.GT_MultiTileComponentCasing.*; import static gregtech.loaders.preload.GT_Loader_MultiTileEntities.COMPONENT_CASING_REGISTRY; import static mcp.mobius.waila.api.SpecialChars.*; @@ -289,10 +288,8 @@ public void readMultiTileNBT(NBTTagCompound nbt) { if (outputTanks != null) registerFluidInventory("controller", "controller", outputTanks, Inventory.OUTPUT); structureOkay = nbt.getBoolean(NBT.STRUCTURE_OK); - extendedFacing = ExtendedFacing.of( - ForgeDirection.getOrientation(getFrontFacing()), - Rotation.byIndex(nbt.getByte(NBT.ROTATION)), - Flip.byIndex(nbt.getByte(NBT.FLIP))); + extendedFacing = ExtendedFacing + .of(getFrontFacing(), Rotation.byIndex(nbt.getByte(NBT.ROTATION)), Flip.byIndex(nbt.getByte(NBT.FLIP))); loadUpgradeInventoriesFromNBT(nbt); loadUpgradeTanksFromNBT(nbt); @@ -308,10 +305,10 @@ private void loadUpgradeInventoriesFromNBT(NBTTagCompound nbt) { .getTagList(NBT.UPGRADE_INVENTORIES_INPUT, Constants.NBT.TAG_COMPOUND); for (int i = 0; i < listInputInventories.tagCount(); i++) { final NBTTagCompound nbtInv = listInputInventories.getCompoundTagAt(i); - String invUUID = nbtInv.getString(NBT.UPGRADE_INVENTORY_UUID); - String invName = nbtInv.getString(NBT.UPGRADE_INVENTORY_NAME); - int invSize = nbtInv.getInteger(NBT.UPGRADE_INVENTORY_SIZE); - IItemHandlerModifiable inv = new ItemStackHandler(invSize); + final String invUUID = nbtInv.getString(NBT.UPGRADE_INVENTORY_UUID); + final String invName = nbtInv.getString(NBT.UPGRADE_INVENTORY_NAME); + final int invSize = nbtInv.getInteger(NBT.UPGRADE_INVENTORY_SIZE); + final IItemHandlerModifiable inv = new ItemStackHandler(invSize); loadInventory(nbtInv, inv, NBT.INV_INPUT_LIST); registerInventory(invName, invUUID, invSize, Inventory.INPUT); } @@ -320,9 +317,9 @@ private void loadUpgradeInventoriesFromNBT(NBTTagCompound nbt) { .getTagList(NBT.UPGRADE_INVENTORIES_OUTPUT, Constants.NBT.TAG_COMPOUND); for (int i = 0; i < listOutputInventories.tagCount(); i++) { final NBTTagCompound nbtInv = listOutputInventories.getCompoundTagAt(i); - String invUUID = nbtInv.getString(NBT.UPGRADE_INVENTORY_UUID); - String invName = nbtInv.getString(NBT.UPGRADE_INVENTORY_NAME); - int invSize = nbtInv.getInteger(NBT.UPGRADE_INVENTORY_SIZE); + final String invUUID = nbtInv.getString(NBT.UPGRADE_INVENTORY_UUID); + final String invName = nbtInv.getString(NBT.UPGRADE_INVENTORY_NAME); + final int invSize = nbtInv.getInteger(NBT.UPGRADE_INVENTORY_SIZE); IItemHandlerModifiable inv = new ItemStackHandler(invSize); loadInventory(nbtInv, inv, NBT.INV_OUTPUT_LIST); registerInventory(invName, invUUID, invSize, Inventory.OUTPUT); @@ -532,8 +529,8 @@ public void setExtendedFacing(ExtendedFacing newExtendedFacing) { } @Override - public boolean onWrenchRightClick(EntityPlayer aPlayer, ItemStack tCurrentItem, byte wrenchSide, float aX, float aY, - float aZ) { + public boolean onWrenchRightClick(EntityPlayer aPlayer, ItemStack tCurrentItem, ForgeDirection wrenchSide, float aX, + float aY, float aZ) { if (wrenchSide != getFrontFacing()) return super.onWrenchRightClick(aPlayer, tCurrentItem, wrenchSide, aX, aY, aZ); if (aPlayer.isSneaking()) { @@ -548,19 +545,19 @@ public boolean onWrenchRightClick(EntityPlayer aPlayer, ItemStack tCurrentItem, } @Override - public void registerCoveredPartOnSide(final int aSide, IMultiBlockPart part) { - if (aSide < 0 || aSide >= 6) return; + public void registerCoveredPartOnSide(final ForgeDirection side, IMultiBlockPart part) { + if (side == ForgeDirection.UNKNOWN) return; - final LinkedList> registeredCovers = registeredCoveredParts.get(aSide); + final LinkedList> registeredCovers = registeredCoveredParts.get(side.ordinal()); // TODO: Make sure that we're not already registered on this side registeredCovers.add(new WeakReference<>(part)); } @Override - public void unregisterCoveredPartOnSide(final int aSide, IMultiBlockPart aPart) { - if (aSide < 0 || aSide >= 6) return; + public void unregisterCoveredPartOnSide(final ForgeDirection side, IMultiBlockPart aPart) { + if (side == ForgeDirection.UNKNOWN) return; - final LinkedList> coveredParts = registeredCoveredParts.get(aSide); + final LinkedList> coveredParts = registeredCoveredParts.get(side.ordinal()); final Iterator> it = coveredParts.iterator(); while (it.hasNext()) { final IMultiBlockPart part = (it.next()).get(); @@ -579,9 +576,10 @@ public void onFirstTick(boolean isServerSide) { } private boolean tickCovers() { - for (byte side : ALL_VALID_SIDES) { + for (final ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { // TODO: Tick controller covers, if any - final LinkedList> coveredParts = this.registeredCoveredParts.get(side); + final LinkedList> coveredParts = this.registeredCoveredParts + .get(side.ordinal()); final Iterator> it = coveredParts.iterator(); while (it.hasNext()) { final IMultiBlockPart part = (it.next()).get(); @@ -626,19 +624,19 @@ protected void clearSpecialLists() { } @Override - public final boolean isFacingValid(byte aFacing) { - return canSetToDirectionAny(ForgeDirection.getOrientation(aFacing)); + public final boolean isFacingValid(ForgeDirection facing) { + return canSetToDirectionAny(facing); } @Override public void onFacingChange() { - toolSetDirection(ForgeDirection.getOrientation(getFrontFacing())); + toolSetDirection(getFrontFacing()); onStructureChange(); } @Override - public boolean allowCoverOnSide(byte aSide, GT_ItemStack aCoverID) { - return facing.compareTo(ForgeDirection.getOrientation(aSide)) != 0; + public boolean allowCoverOnSide(ForgeDirection side, GT_ItemStack aCoverID) { + return side != facing; } @Override @@ -672,14 +670,14 @@ public boolean increaseProgress(int aProgressAmountInTicks) { } @Override - public FluidStack getDrainableFluid(byte aSide) { - return getDrainableFluid(aSide, null); + public FluidStack getDrainableFluid(ForgeDirection side) { + return getDrainableFluid(side, null); } @Override - public FluidStack getDrainableFluid(byte aSide, Fluid fluidToDrain) { + public FluidStack getDrainableFluid(ForgeDirection side, Fluid fluidToDrain) { final IFluidTank tank = getFluidTankDrainable( - aSide, + side, fluidToDrain == null ? null : new FluidStack(fluidToDrain, 0)); return tank == null ? null : tank.getFluid(); } @@ -1054,22 +1052,22 @@ protected FluidTankGT[] getTanksForOutput() { return tanks.toArray(new FluidTankGT[0]); } - protected IFluidTank getFluidTankFillable(MultiBlockPart aPart, byte aSide, FluidStack aFluidToFill) { - return getFluidTankFillable(aPart.getFrontFacing(), aSide, aFluidToFill); + protected IFluidTank getFluidTankFillable(MultiBlockPart aPart, ForgeDirection side, FluidStack aFluidToFill) { + return getFluidTankFillable(side, aFluidToFill); } - protected IFluidTank getFluidTankDrainable(MultiBlockPart aPart, byte aSide, FluidStack aFluidToDrain) { - return getFluidTankDrainable(aPart.getFrontFacing(), aSide, aFluidToDrain); + protected IFluidTank getFluidTankDrainable(MultiBlockPart aPart, ForgeDirection side, FluidStack aFluidToDrain) { + return getFluidTankDrainable(side, aFluidToDrain); } - protected IFluidTank[] getFluidTanks(MultiBlockPart aPart, byte aSide) { - return getFluidTanks(aSide); + protected IFluidTank[] getFluidTanks(MultiBlockPart aPart, ForgeDirection side) { + return getFluidTanks(side); } @Override public int fill(MultiBlockPart aPart, ForgeDirection aDirection, FluidStack aFluid, boolean aDoFill) { if (aFluid == null || aFluid.amount <= 0) return 0; - final IFluidTank tTank = getFluidTankFillable(aPart, (byte) aDirection.ordinal(), aFluid); + final IFluidTank tTank = getFluidTankFillable(aPart, aDirection, aFluid); if (tTank == null) return 0; final int rFilledAmount = tTank.fill(aFluid, aDoFill); if (rFilledAmount > 0 && aDoFill) hasInventoryChanged = true; @@ -1079,7 +1077,7 @@ public int fill(MultiBlockPart aPart, ForgeDirection aDirection, FluidStack aFlu @Override public FluidStack drain(MultiBlockPart aPart, ForgeDirection aDirection, FluidStack aFluid, boolean aDoDrain) { if (aFluid == null || aFluid.amount <= 0) return null; - final IFluidTank tTank = getFluidTankDrainable(aPart, (byte) aDirection.ordinal(), aFluid); + final IFluidTank tTank = getFluidTankDrainable(aPart, aDirection, aFluid); if (tTank == null || tTank.getFluid() == null || tTank.getFluidAmount() == 0 || !tTank.getFluid() @@ -1093,7 +1091,7 @@ public FluidStack drain(MultiBlockPart aPart, ForgeDirection aDirection, FluidSt @Override public FluidStack drain(MultiBlockPart aPart, ForgeDirection aDirection, int aAmountToDrain, boolean aDoDrain) { if (aAmountToDrain <= 0) return null; - final IFluidTank tTank = getFluidTankDrainable(aPart, (byte) aDirection.ordinal(), null); + final IFluidTank tTank = getFluidTankDrainable(aPart, aDirection, null); if (tTank == null || tTank.getFluid() == null || tTank.getFluidAmount() == 0) return null; final FluidStack rDrained = tTank.drain(aAmountToDrain, aDoDrain); if (rDrained != null && aDoDrain) markInventoryBeenModified(); @@ -1103,7 +1101,7 @@ public FluidStack drain(MultiBlockPart aPart, ForgeDirection aDirection, int aAm @Override public boolean canFill(MultiBlockPart aPart, ForgeDirection aDirection, Fluid aFluid) { if (aFluid == null) return false; - final IFluidTank tTank = getFluidTankFillable(aPart, (byte) aDirection.ordinal(), new FluidStack(aFluid, 0)); + final IFluidTank tTank = getFluidTankFillable(aPart, aDirection, new FluidStack(aFluid, 0)); return tTank != null && (tTank.getFluid() == null || tTank.getFluid() .getFluid() == aFluid); } @@ -1111,14 +1109,14 @@ public boolean canFill(MultiBlockPart aPart, ForgeDirection aDirection, Fluid aF @Override public boolean canDrain(MultiBlockPart aPart, ForgeDirection aDirection, Fluid aFluid) { if (aFluid == null) return false; - final IFluidTank tTank = getFluidTankDrainable(aPart, (byte) aDirection.ordinal(), new FluidStack(aFluid, 0)); + final IFluidTank tTank = getFluidTankDrainable(aPart, aDirection, new FluidStack(aFluid, 0)); return tTank != null && (tTank.getFluid() != null && tTank.getFluid() .getFluid() == aFluid); } @Override public FluidTankInfo[] getTankInfo(MultiBlockPart aPart, ForgeDirection aDirection) { - final IFluidTank[] tTanks = getFluidTanks(aPart, (byte) aDirection.ordinal()); + final IFluidTank[] tTanks = getFluidTanks(aPart, aDirection); if (tTanks == null || tTanks.length <= 0) return GT_Values.emptyFluidTankInfo; final FluidTankInfo[] rInfo = new FluidTankInfo[tTanks.length]; for (int i = 0; i < tTanks.length; i++) rInfo[i] = new FluidTankInfo(tTanks[i]); @@ -1143,15 +1141,15 @@ public IFluidTank[] getFluidTanksForGUI(MultiBlockPart aPart) { // #region Energy @Override public PowerLogic getPowerLogic(IMultiBlockPart part, ForgeDirection side) { - if (!(this instanceof PowerLogicHost)) { + if (!(this instanceof PowerLogicHost powerLogicHost)) { return null; } - if (ForgeDirection.getOrientation(part.getFrontFacing()) != side) { + if (part.getFrontFacing() != side) { return null; } - return ((PowerLogicHost) this).getPowerLogic(side); + return powerLogicHost.getPowerLogic(side); } // #endregion Energy @@ -1294,7 +1292,7 @@ protected Pair getInventory(MultiBlockPart aPar } @Override - public int[] getAccessibleSlotsFromSide(MultiBlockPart aPart, byte aSide) { + public int[] getAccessibleSlotsFromSide(MultiBlockPart aPart, ForgeDirection side) { final TIntList tList = new TIntArrayList(); final Map multiBlockInventory = getMultiBlockInventory(aPart); if (multiBlockInventory == null) return tList.toArray(); @@ -1318,7 +1316,7 @@ public int[] getAccessibleSlotsFromSide(MultiBlockPart aPart, byte aSide) { } @Override - public boolean canInsertItem(MultiBlockPart aPart, int aSlot, ItemStack aStack, byte aSide) { + public boolean canInsertItem(MultiBlockPart aPart, int aSlot, ItemStack aStack, ForgeDirection side) { final Pair tInv = getInventory(aPart, aSlot); if (tInv == null) return false; @@ -1334,7 +1332,7 @@ public boolean canInsertItem(MultiBlockPart aPart, int aSlot, ItemStack aStack, } @Override - public boolean canExtractItem(MultiBlockPart aPart, int aSlot, ItemStack aStack, byte aSide) { + public boolean canExtractItem(MultiBlockPart aPart, int aSlot, ItemStack aStack, ForgeDirection side) { final Pair tInv = getInventory(aPart, aSlot); if (tInv == null) return false; @@ -1738,7 +1736,7 @@ public ModularWindow createWindow(UIBuildContext buildContext) { } @Override - public boolean hasGui(byte aSide) { + public boolean hasGui(ForgeDirection side) { return true; } diff --git a/src/main/java/gregtech/api/multitileentity/multiblock/base/MultiBlockPart.java b/src/main/java/gregtech/api/multitileentity/multiblock/base/MultiBlockPart.java index d9d0ef46666..3b05c79f268 100644 --- a/src/main/java/gregtech/api/multitileentity/multiblock/base/MultiBlockPart.java +++ b/src/main/java/gregtech/api/multitileentity/multiblock/base/MultiBlockPart.java @@ -1,10 +1,8 @@ package gregtech.api.multitileentity.multiblock.base; import static com.google.common.math.LongMath.log2; -import static gregtech.api.enums.GT_Values.ALL_VALID_SIDES; import static gregtech.api.enums.GT_Values.B; import static gregtech.api.enums.GT_Values.NBT; -import static gregtech.api.enums.GT_Values.SIDE_UNKNOWN; import static gregtech.api.enums.Textures.BlockIcons.FLUID_IN_SIGN; import static gregtech.api.enums.Textures.BlockIcons.FLUID_OUT_SIGN; import static gregtech.api.enums.Textures.BlockIcons.ITEM_IN_SIGN; @@ -126,19 +124,19 @@ protected void addDebugInfo(EntityPlayer aPlayer, int aLogLevel, ArrayList currenttip, IWailaDataAccessor accessor, + public void getWailaBody(ItemStack itemStack, List currentTip, IWailaDataAccessor accessor, IWailaConfigHandler config) { - super.getWailaBody(itemStack, currenttip, accessor, config); - currenttip.add(String.format("Mode: %s", getModeName(mMode))); + super.getWailaBody(itemStack, currentTip, accessor, config); + currentTip.add(String.format("Mode: %s", getModeName(mMode))); if (modeSelected(FLUID_OUT)) { if (configurationTank != null && configurationTank.get() != null) { - currenttip.add( + currentTip.add( String.format( "Locked to: %s", configurationTank.get() .getLocalizedName())); } else { - currenttip.add("Locked to: Nothing"); + currentTip.add("Locked to: Nothing"); } } } @@ -164,41 +162,41 @@ public IMultiBlockController getTarget(boolean aCheckValidity) { } public void registerCovers(IMultiBlockController controller) { - for (byte i : ALL_VALID_SIDES) { - final CoverInfo coverInfo = getCoverInfoAtSide(i); + for (final ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + final CoverInfo coverInfo = getCoverInfoAtSide(side); if (coverInfo.isValid() && coverInfo.getTickRate() > 0) { - controller.registerCoveredPartOnSide(i, this); + controller.registerCoveredPartOnSide(side, this); } } } @Override - public void setCoverItemAtSide(byte aSide, ItemStack aCover) { - super.setCoverItemAtSide(aSide, aCover); + public void setCoverItemAtSide(ForgeDirection side, ItemStack aCover) { + super.setCoverItemAtSide(side, aCover); // TODO: Filter on tickable covers final IMultiBlockController tTarget = getTarget(true); if (tTarget != null) { - final CoverInfo coverInfo = getCoverInfoAtSide(aSide); + final CoverInfo coverInfo = getCoverInfoAtSide(side); if (coverInfo.isValid() && coverInfo.getTickRate() > 0) { - tTarget.registerCoveredPartOnSide(aSide, this); + tTarget.registerCoveredPartOnSide(side, this); } } } public void unregisterCovers(IMultiBlockController controller) { - for (byte i : ALL_VALID_SIDES) { - if (getCoverInfoAtSide(i).isValid()) { - controller.unregisterCoveredPartOnSide(i, this); + for (final ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + if (getCoverInfoAtSide(side).isValid()) { + controller.unregisterCoveredPartOnSide(side, this); } } } @Override - public boolean dropCover(byte aSide, byte aDroppedSide, boolean aForced) { - final boolean res = super.dropCover(aSide, aDroppedSide, aForced); + public boolean dropCover(ForgeDirection side, ForgeDirection droppedSide, boolean aForced) { + final boolean res = super.dropCover(side, droppedSide, aForced); final IMultiBlockController tTarget = getTarget(true); if (tTarget != null) { - tTarget.unregisterCoveredPartOnSide(aSide, this); + tTarget.unregisterCoveredPartOnSide(side, this); } return res; } @@ -327,13 +325,13 @@ public boolean breakBlock() { @Override public void onBlockAdded() { - for (byte tSide : ALL_VALID_SIDES) { - final TileEntity te = getTileEntityAtSide(tSide); - if (te instanceof MultiBlockPart) { - final IMultiBlockController tController = ((MultiBlockPart) te).getTarget(false); + for (final ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + final TileEntity te = getTileEntityAtSide(side); + if (te instanceof MultiBlockPart part) { + final IMultiBlockController tController = part.getTarget(false); if (tController != null) tController.onStructureChange(); - } else if (te instanceof IMultiBlockController) { - ((IMultiBlockController) te).onStructureChange(); + } else if (te instanceof IMultiBlockController controller) { + controller.onStructureChange(); } } } @@ -347,40 +345,38 @@ public ITexture getTexture(ForgeDirection side) { texture, TextureFactory.of(OVERLAY_PIPE_IN), TextureFactory.of(ITEM_IN_SIGN), - getCoverTexture((byte) side.ordinal())); + getCoverTexture(side)); } if (mMode == getModeOrdinal(ITEM_OUT)) { return TextureFactory.of( texture, TextureFactory.of(OVERLAY_PIPE_OUT), TextureFactory.of(ITEM_OUT_SIGN), - getCoverTexture((byte) side.ordinal())); + getCoverTexture(side)); } if (mMode == getModeOrdinal(FLUID_IN)) { return TextureFactory.of( texture, TextureFactory.of(OVERLAY_PIPE_IN), TextureFactory.of(FLUID_IN_SIGN), - getCoverTexture((byte) side.ordinal())); + getCoverTexture(side)); } if (mMode == getModeOrdinal(FLUID_OUT)) { return TextureFactory.of( texture, TextureFactory.of(OVERLAY_PIPE_OUT), TextureFactory.of(FLUID_OUT_SIGN), - getCoverTexture((byte) side.ordinal())); + getCoverTexture(side)); } if (mMode == getModeOrdinal(ENERGY_IN)) { - return TextureFactory - .of(texture, TextureFactory.of(OVERLAY_ENERGY_IN_MULTI), getCoverTexture((byte) side.ordinal())); + return TextureFactory.of(texture, TextureFactory.of(OVERLAY_ENERGY_IN_MULTI), getCoverTexture(side)); } if (mMode == getModeOrdinal(ENERGY_OUT)) { - return TextureFactory - .of(texture, TextureFactory.of(OVERLAY_ENERGY_OUT_MULTI), getCoverTexture((byte) side.ordinal())); + return TextureFactory.of(texture, TextureFactory.of(OVERLAY_ENERGY_OUT_MULTI), getCoverTexture(side)); } } - return TextureFactory.of(texture, getCoverTexture((byte) side.ordinal())); + return TextureFactory.of(texture, getCoverTexture(side)); } @Override @@ -418,15 +414,15 @@ protected byte getNextAllowedMode(List allowedModes) { } @Override - public boolean onMalletRightClick(EntityPlayer aPlayer, ItemStack tCurrentItem, byte wrenchSide, float aX, float aY, - float aZ) { + public boolean onMalletRightClick(EntityPlayer aPlayer, ItemStack tCurrentItem, ForgeDirection wrenchSide, float aX, + float aY, float aZ) { if (mAllowedModes == NOTHING) return true; if (mMode == NOTHING) { - facing = ForgeDirection.getOrientation(wrenchSide); + facing = wrenchSide; } mMode = getNextAllowedMode(BASIC_MODES); if (aPlayer.isSneaking()) { - facing = ForgeDirection.getOrientation(wrenchSide); + facing = wrenchSide; } GT_Utility.sendChatToPlayer(aPlayer, "Mode set to `" + getModeName(mMode) + "' (" + mMode + ")"); sendClientData((EntityPlayerMP) aPlayer); @@ -437,7 +433,7 @@ public boolean onMalletRightClick(EntityPlayer aPlayer, ItemStack tCurrentItem, public void setLightValue(byte aLightValue) {} @Override - public byte getComparatorValue(byte aSide) { + public byte getComparatorValue(ForgeDirection side) { return 0; } @@ -457,10 +453,10 @@ public String getTileEntityName() { @Override public int fill(ForgeDirection aDirection, FluidStack aFluidStack, boolean aDoFill) { if (!modeSelected(FLUID_IN)) return 0; - final byte aSide = (byte) aDirection.ordinal(); + if (aFluidStack == null || isWrongFluid(aFluidStack.getFluid())) return 0; - if (aDirection != ForgeDirection.UNKNOWN && (facing.compareTo(ForgeDirection.getOrientation(aSide)) != 0 - || !coverLetsFluidIn(aSide, aFluidStack.getFluid()))) return 0; + if (aDirection != ForgeDirection.UNKNOWN + && (facing.compareTo(aDirection) != 0 || !coverLetsFluidIn(aDirection, aFluidStack.getFluid()))) return 0; final IMultiBlockController controller = getTarget(true); return controller == null ? 0 : controller.fill(this, aDirection, aFluidStack, aDoFill); } @@ -468,10 +464,10 @@ public int fill(ForgeDirection aDirection, FluidStack aFluidStack, boolean aDoFi @Override public FluidStack drain(ForgeDirection aDirection, FluidStack aFluidStack, boolean aDoDrain) { if (!modeSelected(FLUID_OUT)) return null; - final byte aSide = (byte) aDirection.ordinal(); if (aFluidStack == null || isWrongFluid(aFluidStack.getFluid())) return null; - if (aDirection != ForgeDirection.UNKNOWN && (facing.compareTo(ForgeDirection.getOrientation(aSide)) != 0 - || !coverLetsFluidOut(aSide, aFluidStack.getFluid()))) return null; + if (aDirection != ForgeDirection.UNKNOWN + && (facing.compareTo(aDirection) != 0 || !coverLetsFluidOut(aDirection, aFluidStack.getFluid()))) + return null; final IMultiBlockController controller = getTarget(true); return controller == null ? null : controller.drain(this, aDirection, aFluidStack, aDoDrain); } @@ -479,28 +475,27 @@ public FluidStack drain(ForgeDirection aDirection, FluidStack aFluidStack, boole @Override public FluidStack drain(ForgeDirection aDirection, int aAmountToDrain, boolean aDoDrain) { if (!modeSelected(FLUID_OUT)) return null; - final byte aSide = (byte) aDirection.ordinal(); final IMultiBlockController controller = getTarget(true); if (controller == null) return null; FluidStack aFluidStack = null; if (getLockedFluid() != null) { - aFluidStack = controller.getDrainableFluid(aSide, getLockedFluid()); + aFluidStack = controller.getDrainableFluid(aDirection, getLockedFluid()); } else { - aFluidStack = controller.getDrainableFluid(aSide); + aFluidStack = controller.getDrainableFluid(aDirection); } if (aFluidStack == null || isWrongFluid(aFluidStack.getFluid())) return null; - if (aDirection != ForgeDirection.UNKNOWN && (facing.compareTo(ForgeDirection.getOrientation(aSide)) != 0 - || !coverLetsFluidOut(aSide, aFluidStack.getFluid()))) return null; + if (aDirection != ForgeDirection.UNKNOWN + && (facing.compareTo(aDirection) != 0 || !coverLetsFluidOut(aDirection, aFluidStack.getFluid()))) + return null; return controller.drain(this, aDirection, aFluidStack, aDoDrain); } @Override public boolean canFill(ForgeDirection aDirection, Fluid aFluid) { if (!modeSelected(FLUID_IN)) return false; - final byte aSide = (byte) aDirection.ordinal(); + if (aDirection != ForgeDirection.UNKNOWN - && (facing.compareTo(ForgeDirection.getOrientation(aSide)) != 0 || !coverLetsFluidIn(aSide, aFluid))) - return false; + && (facing.compareTo(aDirection) != 0 || !coverLetsFluidIn(aDirection, aFluid))) return false; if (isWrongFluid(aFluid)) return false; final IMultiBlockController controller = getTarget(true); return controller != null && controller.canFill(this, aDirection, aFluid); @@ -509,10 +504,8 @@ public boolean canFill(ForgeDirection aDirection, Fluid aFluid) { @Override public boolean canDrain(ForgeDirection aDirection, Fluid aFluid) { if (!modeSelected(FLUID_OUT)) return false; - final byte aSide = (byte) aDirection.ordinal(); if (aDirection != ForgeDirection.UNKNOWN - && (facing.compareTo(ForgeDirection.getOrientation(aSide)) != 0 || !coverLetsFluidOut(aSide, aFluid))) - return false; + && (facing.compareTo(aDirection) != 0 || !coverLetsFluidOut(aDirection, aFluid))) return false; if (isWrongFluid(aFluid)) return false; final IMultiBlockController controller = getTarget(true); return controller != null && controller.canDrain(this, aDirection, aFluid); @@ -520,17 +513,16 @@ public boolean canDrain(ForgeDirection aDirection, Fluid aFluid) { @Override public FluidTankInfo[] getTankInfo(ForgeDirection aDirection) { - final byte aSide = (byte) aDirection.ordinal(); if (!modeSelected(FLUID_IN, FLUID_OUT) - || (aSide != SIDE_UNKNOWN && facing.compareTo(ForgeDirection.getOrientation(aSide)) != 0)) + || (aDirection != ForgeDirection.UNKNOWN && facing.compareTo(aDirection) != 0)) return GT_Values.emptyFluidTankInfo; final IMultiBlockController controller = getTarget(true); if (controller == null) return GT_Values.emptyFluidTankInfo; - final CoverInfo coverInfo = getCoverInfoAtSide(aSide); + final CoverInfo coverInfo = getCoverInfoAtSide(aDirection); - if ((controller.isLiquidInput(aSide) && coverInfo.letsFluidIn(null, controller)) - || (controller.isLiquidOutput(aSide) && coverInfo.letsFluidOut(null, controller))) + if ((controller.isLiquidInput(aDirection) && coverInfo.letsFluidIn(null, controller)) + || (controller.isLiquidOutput(aDirection) && coverInfo.letsFluidOut(null, controller))) return controller.getTankInfo(this, aDirection); return GT_Values.emptyFluidTankInfo; @@ -597,31 +589,32 @@ public boolean addStackToSlot(int aIndex, ItemStack aStack, int aAmount) { } @Override - public int[] getAccessibleSlotsFromSide(int aSide) { - if (!modeSelected(ITEM_IN, ITEM_OUT) - || (facing != ForgeDirection.UNKNOWN && facing.compareTo(ForgeDirection.getOrientation(aSide)) != 0)) + public int[] getAccessibleSlotsFromSide(int ordinalSide) { + final ForgeDirection side = ForgeDirection.getOrientation(ordinalSide); + if (!modeSelected(ITEM_IN, ITEM_OUT) || (facing != ForgeDirection.UNKNOWN && facing.compareTo(side) != 0)) return GT_Values.emptyIntArray; final IMultiBlockController controller = getTarget(true); - return controller != null ? controller.getAccessibleSlotsFromSide(this, (byte) aSide) : GT_Values.emptyIntArray; + return controller != null ? controller.getAccessibleSlotsFromSide(this, side) : GT_Values.emptyIntArray; } @Override - public boolean canInsertItem(int aSlot, ItemStack aStack, int aSide) { - if (!modeSelected(ITEM_IN, ITEM_OUT) || (facing != ForgeDirection.UNKNOWN - && (facing.compareTo(ForgeDirection.getOrientation(aSide)) != 0 || !coverLetsItemsIn((byte) aSide, aSlot)))) + public boolean canInsertItem(int aSlot, ItemStack aStack, int ordinalSide) { + final ForgeDirection side = ForgeDirection.getOrientation(ordinalSide); + if (!modeSelected(ITEM_IN, ITEM_OUT) + || (facing != ForgeDirection.UNKNOWN && (facing.compareTo(side) != 0 || !coverLetsItemsIn(side, aSlot)))) return false; final IMultiBlockController controller = getTarget(true); - return (controller != null && controller.canInsertItem(this, aSlot, aStack, (byte) aSide)); + return (controller != null && controller.canInsertItem(this, aSlot, aStack, side)); } @Override - public boolean canExtractItem(int aSlot, ItemStack aStack, int aSide) { + public boolean canExtractItem(int aSlot, ItemStack aStack, int ordinalSide) { + final ForgeDirection side = ForgeDirection.getOrientation(ordinalSide); if (!modeSelected(ITEM_IN, ITEM_OUT) - || (facing != ForgeDirection.UNKNOWN && (facing.compareTo(ForgeDirection.getOrientation(aSide)) != 0 - || !coverLetsItemsOut((byte) aSide, aSlot)))) + || (facing != ForgeDirection.UNKNOWN && (facing.compareTo(side) != 0 || !coverLetsItemsOut(side, aSlot)))) return false; final IMultiBlockController controller = getTarget(true); - return (controller != null && controller.canExtractItem(this, aSlot, aStack, (byte) aSide)); + return (controller != null && controller.canExtractItem(this, aSlot, aStack, side)); } @Override @@ -695,8 +688,8 @@ public String getLocalName() { } @Override - public boolean hasGui(byte aSide) { - if (modeSelected(ENERGY_IN, ENERGY_OUT) && facing == ForgeDirection.getOrientation(aSide)) { + public boolean hasGui(ForgeDirection side) { + if (modeSelected(ENERGY_IN, ENERGY_OUT) && facing == side) { return false; } return getTarget(true) != null; diff --git a/src/main/java/gregtech/api/multitileentity/multiblock/base/WallShareablePart.java b/src/main/java/gregtech/api/multitileentity/multiblock/base/WallShareablePart.java index a391f503dc6..62beb640228 100644 --- a/src/main/java/gregtech/api/multitileentity/multiblock/base/WallShareablePart.java +++ b/src/main/java/gregtech/api/multitileentity/multiblock/base/WallShareablePart.java @@ -1,12 +1,11 @@ package gregtech.api.multitileentity.multiblock.base; -import static gregtech.api.enums.GT_Values.ALL_VALID_SIDES; - import java.util.ArrayList; import java.util.List; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ChunkCoordinates; +import net.minecraftforge.common.util.ForgeDirection; import gregtech.api.multitileentity.interfaces.IMultiBlockController; @@ -67,7 +66,7 @@ public String getTileEntityName() { @Override public boolean breakBlock() { - for (ChunkCoordinates coordinates : targetPositions) { + for (final ChunkCoordinates coordinates : targetPositions) { IMultiBlockController target = getTarget(coordinates, false); if (target == null) { continue; @@ -79,13 +78,13 @@ public boolean breakBlock() { @Override public void onBlockAdded() { - for (byte tSide : ALL_VALID_SIDES) { - final TileEntity te = getTileEntityAtSide(tSide); - if (te instanceof MultiBlockPart) { - final IMultiBlockController tController = ((MultiBlockPart) te).getTarget(false); + for (final ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + final TileEntity te = getTileEntityAtSide(side); + if (te instanceof MultiBlockPart part) { + final IMultiBlockController tController = part.getTarget(false); if (tController != null) tController.onStructureChange(); - } else if (te instanceof IMultiBlockController) { - ((IMultiBlockController) te).onStructureChange(); + } else if (te instanceof IMultiBlockController controller) { + controller.onStructureChange(); } } } diff --git a/src/main/java/gregtech/api/net/GT_Packet_GtTileEntityGuiRequest.java b/src/main/java/gregtech/api/net/GT_Packet_GtTileEntityGuiRequest.java index bccb4b2b765..dc2f88316d0 100644 --- a/src/main/java/gregtech/api/net/GT_Packet_GtTileEntityGuiRequest.java +++ b/src/main/java/gregtech/api/net/GT_Packet_GtTileEntityGuiRequest.java @@ -5,6 +5,7 @@ import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.DimensionManager; +import net.minecraftforge.common.util.ForgeDirection; import com.google.common.io.ByteArrayDataInput; @@ -88,7 +89,7 @@ public void process(IBlockAccess aWorld) { final World world = DimensionManager.getWorld(this.dimId); if (world == null) return; final TileEntity tile = world.getTileEntity(this.mX, this.mY, this.mZ); - if (!(tile instanceof BaseTileEntity baseTile) || ((BaseTileEntity) tile).isDead()) return; + if (!(tile instanceof BaseTileEntity baseTile) || baseTile.isDead()) return; final EntityPlayerMP player = (EntityPlayerMP) world.getEntityByID(playerId); final CoverableTileEntity coverableTile = (baseTile instanceof CoverableTileEntity) @@ -97,7 +98,8 @@ public void process(IBlockAccess aWorld) { // If the requested Gui ID corresponds to a cover, send the cover data to the client so they can open it. if (GT_Proxy.GUI_ID_COVER_SIDE_BASE <= guiId && guiId < GT_Proxy.GUI_ID_COVER_SIDE_BASE + 6 && coverableTile != null) { - final byte coverSide = (byte) (guiId - GT_Proxy.GUI_ID_COVER_SIDE_BASE); + final ForgeDirection coverSide = ForgeDirection + .getOrientation((byte) (guiId - GT_Proxy.GUI_ID_COVER_SIDE_BASE)); final GT_Packet_TileEntityCoverGUI packet = new GT_Packet_TileEntityCoverGUI( this.mX, this.mY, diff --git a/src/main/java/gregtech/api/net/GT_Packet_RequestCoverData.java b/src/main/java/gregtech/api/net/GT_Packet_RequestCoverData.java index 3f919dacd4e..94ae86c2d97 100644 --- a/src/main/java/gregtech/api/net/GT_Packet_RequestCoverData.java +++ b/src/main/java/gregtech/api/net/GT_Packet_RequestCoverData.java @@ -7,6 +7,7 @@ import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.DimensionManager; +import net.minecraftforge.common.util.ForgeDirection; import com.google.common.io.ByteArrayDataInput; @@ -24,7 +25,7 @@ public class GT_Packet_RequestCoverData extends GT_Packet_New { protected short mY; protected int mZ; - protected byte side; + protected ForgeDirection side; protected int coverID; protected EntityPlayerMP mPlayer; @@ -43,7 +44,7 @@ public GT_Packet_RequestCoverData(CoverInfo info, ICoverable tile) { this.coverID = info.getCoverID(); } - public GT_Packet_RequestCoverData(int mX, short mY, int mZ, byte coverSide, int coverID) { + public GT_Packet_RequestCoverData(int mX, short mY, int mZ, ForgeDirection coverSide, int coverID) { super(false); this.mX = mX; this.mY = mY; @@ -53,7 +54,7 @@ public GT_Packet_RequestCoverData(int mX, short mY, int mZ, byte coverSide, int this.coverID = coverID; } - public GT_Packet_RequestCoverData(byte coverSide, int coverID, ICoverable tile) { + public GT_Packet_RequestCoverData(ForgeDirection coverSide, int coverID, ICoverable tile) { super(false); this.mX = tile.getXCoord(); this.mY = tile.getYCoord(); @@ -74,7 +75,7 @@ public void encode(ByteBuf aOut) { aOut.writeShort(mY); aOut.writeInt(mZ); - aOut.writeByte(side); + aOut.writeByte(side.ordinal()); aOut.writeInt(coverID); } @@ -84,7 +85,7 @@ public GT_Packet_New decode(ByteArrayDataInput aData) { aData.readInt(), aData.readShort(), aData.readInt(), - aData.readByte(), + ForgeDirection.getOrientation(aData.readByte()), aData.readInt()); } diff --git a/src/main/java/gregtech/api/net/GT_Packet_SendCoverData.java b/src/main/java/gregtech/api/net/GT_Packet_SendCoverData.java index b348cbb9e3c..47f549b5b47 100644 --- a/src/main/java/gregtech/api/net/GT_Packet_SendCoverData.java +++ b/src/main/java/gregtech/api/net/GT_Packet_SendCoverData.java @@ -2,6 +2,7 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.world.IBlockAccess; +import net.minecraftforge.common.util.ForgeDirection; import com.google.common.io.ByteArrayDataInput; @@ -21,7 +22,7 @@ public class GT_Packet_SendCoverData extends GT_Packet_New { protected short mY; protected int mZ; - protected byte side; + protected ForgeDirection side; protected int coverID; protected ISerializableObject coverData; @@ -29,7 +30,7 @@ public GT_Packet_SendCoverData() { super(true); } - public GT_Packet_SendCoverData(int mX, short mY, int mZ, byte coverSide, int coverID, + public GT_Packet_SendCoverData(int mX, short mY, int mZ, ForgeDirection coverSide, int coverID, ISerializableObject coverData) { super(false); this.mX = mX; @@ -52,7 +53,8 @@ public GT_Packet_SendCoverData(CoverInfo info, ICoverable tile) { this.coverData = info.getCoverData(); } - public GT_Packet_SendCoverData(byte coverSide, int coverID, ISerializableObject coverData, ICoverable tile) { + public GT_Packet_SendCoverData(ForgeDirection coverSide, int coverID, ISerializableObject coverData, + ICoverable tile) { super(false); this.mX = tile.getXCoord(); this.mY = tile.getYCoord(); @@ -74,7 +76,7 @@ public void encode(ByteBuf aOut) { aOut.writeShort(mY); aOut.writeInt(mZ); - aOut.writeByte(side); + aOut.writeByte(side.ordinal()); aOut.writeInt(coverID); coverData.writeToByteBuf(aOut); } @@ -86,7 +88,7 @@ public GT_Packet_New decode(ByteArrayDataInput aData) { aData.readInt(), aData.readShort(), aData.readInt(), - aData.readByte(), + ForgeDirection.getOrientation(aData.readByte()), coverId = aData.readInt(), GregTech_API.getCoverBehaviorNew(coverId) .createDataObject() @@ -97,8 +99,8 @@ public GT_Packet_New decode(ByteArrayDataInput aData) { public void process(IBlockAccess aWorld) { if (aWorld != null) { final TileEntity tile = aWorld.getTileEntity(mX, mY, mZ); - if (tile instanceof CoverableTileEntity && !((CoverableTileEntity) tile).isDead()) { - ((CoverableTileEntity) tile).receiveCoverData(side, coverID, coverData, null); + if (tile instanceof CoverableTileEntity coverable && !coverable.isDead()) { + coverable.receiveCoverData(side, coverID, coverData, null); } } } diff --git a/src/main/java/gregtech/api/net/GT_Packet_TileEntityCover.java b/src/main/java/gregtech/api/net/GT_Packet_TileEntityCover.java index 0e4bedc16ed..d3642b62e8e 100644 --- a/src/main/java/gregtech/api/net/GT_Packet_TileEntityCover.java +++ b/src/main/java/gregtech/api/net/GT_Packet_TileEntityCover.java @@ -4,6 +4,7 @@ import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.DimensionManager; +import net.minecraftforge.common.util.ForgeDirection; import com.google.common.io.ByteArrayDataInput; @@ -20,14 +21,15 @@ public class GT_Packet_TileEntityCover extends GT_Packet_New { protected short mY; protected int mZ; - protected byte side; + protected ForgeDirection side; protected int coverID, coverData, dimID; public GT_Packet_TileEntityCover() { super(true); } - public GT_Packet_TileEntityCover(int mX, short mY, int mZ, byte coverSide, int coverID, int coverData, int dimID) { + public GT_Packet_TileEntityCover(int mX, short mY, int mZ, ForgeDirection coverSide, int coverID, int coverData, + int dimID) { super(false); this.mX = mX; this.mY = mY; @@ -40,7 +42,7 @@ public GT_Packet_TileEntityCover(int mX, short mY, int mZ, byte coverSide, int c this.dimID = dimID; } - public GT_Packet_TileEntityCover(byte coverSide, int coverID, int coverData, ICoverable tile) { + public GT_Packet_TileEntityCover(ForgeDirection coverSide, int coverID, int coverData, ICoverable tile) { super(false); this.mX = tile.getXCoord(); this.mY = tile.getYCoord(); @@ -64,7 +66,7 @@ public void encode(ByteBuf aOut) { aOut.writeShort(mY); aOut.writeInt(mZ); - aOut.writeByte(side); + aOut.writeByte(side.ordinal()); aOut.writeInt(coverID); aOut.writeInt(coverData); @@ -77,7 +79,7 @@ public GT_Packet_New decode(ByteArrayDataInput aData) { aData.readInt(), aData.readShort(), aData.readInt(), - aData.readByte(), + ForgeDirection.getOrientation(aData.readByte()), aData.readInt(), aData.readInt(), aData.readInt()); diff --git a/src/main/java/gregtech/api/net/GT_Packet_TileEntityCoverGUI.java b/src/main/java/gregtech/api/net/GT_Packet_TileEntityCoverGUI.java index 79156e4223d..1b61f87541d 100644 --- a/src/main/java/gregtech/api/net/GT_Packet_TileEntityCoverGUI.java +++ b/src/main/java/gregtech/api/net/GT_Packet_TileEntityCoverGUI.java @@ -7,6 +7,7 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; import com.google.common.io.ByteArrayDataInput; @@ -28,7 +29,7 @@ public class GT_Packet_TileEntityCoverGUI extends GT_Packet_New { protected short mY; protected int mZ; - protected byte side; + protected ForgeDirection side; protected int coverID, dimID, playerID; protected ISerializableObject coverData; @@ -38,8 +39,8 @@ public GT_Packet_TileEntityCoverGUI() { super(true); } - public GT_Packet_TileEntityCoverGUI(int mX, short mY, int mZ, byte coverSide, int coverID, int coverData, int dimID, - int playerID) { + public GT_Packet_TileEntityCoverGUI(int mX, short mY, int mZ, ForgeDirection coverSide, int coverID, int coverData, + int dimID, int playerID) { super(false); this.mX = mX; this.mY = mY; @@ -54,7 +55,7 @@ public GT_Packet_TileEntityCoverGUI(int mX, short mY, int mZ, byte coverSide, in this.parentGuiId = -1; } - public GT_Packet_TileEntityCoverGUI(int mX, short mY, int mZ, byte coverSide, int coverID, + public GT_Packet_TileEntityCoverGUI(int mX, short mY, int mZ, ForgeDirection coverSide, int coverID, ISerializableObject coverData, int dimID, int playerID) { super(false); this.mX = mX; @@ -85,7 +86,7 @@ public GT_Packet_TileEntityCoverGUI(CoverInfo coverInfo, int dimID, int playerID this.parentGuiId = parentGuiId; } - public GT_Packet_TileEntityCoverGUI(int mX, short mY, int mZ, byte coverSide, int coverID, + public GT_Packet_TileEntityCoverGUI(int mX, short mY, int mZ, ForgeDirection coverSide, int coverID, ISerializableObject coverData, int dimID, int playerID, int parentGuiId) { super(false); this.mX = mX; @@ -100,7 +101,7 @@ public GT_Packet_TileEntityCoverGUI(int mX, short mY, int mZ, byte coverSide, in this.parentGuiId = parentGuiId; } - public GT_Packet_TileEntityCoverGUI(byte side, int coverID, int coverData, ICoverable tile, + public GT_Packet_TileEntityCoverGUI(ForgeDirection side, int coverID, int coverData, ICoverable tile, EntityPlayerMP aPlayer) { super(false); @@ -117,7 +118,8 @@ public GT_Packet_TileEntityCoverGUI(byte side, int coverID, int coverData, ICove this.parentGuiId = -1; } - public GT_Packet_TileEntityCoverGUI(byte coverSide, int coverID, int coverData, IGregTechTileEntity tile) { + public GT_Packet_TileEntityCoverGUI(ForgeDirection coverSide, int coverID, int coverData, + IGregTechTileEntity tile) { super(false); this.mX = tile.getXCoord(); this.mY = tile.getYCoord(); @@ -131,8 +133,8 @@ public GT_Packet_TileEntityCoverGUI(byte coverSide, int coverID, int coverData, this.parentGuiId = -1; } - public GT_Packet_TileEntityCoverGUI(byte side, int coverID, ISerializableObject coverData, ICoverable tile, - EntityPlayerMP aPlayer) { + public GT_Packet_TileEntityCoverGUI(ForgeDirection side, int coverID, ISerializableObject coverData, + ICoverable tile, EntityPlayerMP aPlayer) { super(false); this.mX = tile.getXCoord(); this.mY = tile.getYCoord(); @@ -158,7 +160,7 @@ public void encode(ByteBuf aOut) { aOut.writeShort(mY); aOut.writeInt(mZ); - aOut.writeByte(side); + aOut.writeByte(side.ordinal()); aOut.writeInt(coverID); coverData.writeToByteBuf(aOut); @@ -170,12 +172,12 @@ public void encode(ByteBuf aOut) { @Override public GT_Packet_New decode(ByteArrayDataInput aData) { - int coverID; + final int coverID; return new GT_Packet_TileEntityCoverGUI( aData.readInt(), aData.readShort(), aData.readInt(), - aData.readByte(), + ForgeDirection.getOrientation(aData.readByte()), coverID = aData.readInt(), GregTech_API.getCoverBehaviorNew(coverID) .createDataObject() @@ -191,7 +193,7 @@ public void process(IBlockAccess aWorld) { // Using EntityPlayer instead of EntityClientPlayerMP so both client and server can load this final EntityPlayer thePlayer = ((EntityPlayer) ((World) aWorld).getEntityByID(playerID)); final TileEntity tile = aWorld.getTileEntity(mX, mY, mZ); - if (tile instanceof IGregTechTileEntity gtTile && !((IGregTechTileEntity) tile).isDead()) { + if (tile instanceof IGregTechTileEntity gtTile && !gtTile.isDead()) { gtTile.setCoverDataAtSide(side, coverData); // Set it client side to read later. GT_CoverBehaviorBase cover = gtTile.getCoverBehaviorAtSideNew(side); @@ -205,8 +207,8 @@ public void process(IBlockAccess aWorld) { thePlayer.worldObj); // If it's one of this mod's covers, tell it to exit to the GUI with the specified ID (-1 is // ignored) - if (gui instanceof GT_GUICover) { - ((GT_GUICover) gui).setParentGuiId(parentGuiId); + if (gui instanceof GT_GUICover guiCover) { + guiCover.setParentGuiId(parentGuiId); } Minecraft.getMinecraft() .displayGuiScreen(gui); diff --git a/src/main/java/gregtech/api/net/GT_Packet_TileEntityCoverNew.java b/src/main/java/gregtech/api/net/GT_Packet_TileEntityCoverNew.java index 89201710f3a..8fd7348b244 100644 --- a/src/main/java/gregtech/api/net/GT_Packet_TileEntityCoverNew.java +++ b/src/main/java/gregtech/api/net/GT_Packet_TileEntityCoverNew.java @@ -7,6 +7,7 @@ import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.DimensionManager; +import net.minecraftforge.common.util.ForgeDirection; import com.google.common.io.ByteArrayDataInput; @@ -25,7 +26,7 @@ public class GT_Packet_TileEntityCoverNew extends GT_Packet_New { protected short mY; protected int mZ; - protected byte side; + protected ForgeDirection side; protected int coverID, dimID; protected ISerializableObject coverData; @@ -35,7 +36,7 @@ public GT_Packet_TileEntityCoverNew() { super(true); } - public GT_Packet_TileEntityCoverNew(int mX, short mY, int mZ, byte coverSide, int coverID, + public GT_Packet_TileEntityCoverNew(int mX, short mY, int mZ, ForgeDirection coverSide, int coverID, ISerializableObject coverData, int dimID) { super(false); this.mX = mX; @@ -49,7 +50,8 @@ public GT_Packet_TileEntityCoverNew(int mX, short mY, int mZ, byte coverSide, in this.dimID = dimID; } - public GT_Packet_TileEntityCoverNew(byte coverSide, int coverID, ISerializableObject coverData, ICoverable tile) { + public GT_Packet_TileEntityCoverNew(ForgeDirection coverSide, int coverID, ISerializableObject coverData, + ICoverable tile) { super(false); this.mX = tile.getXCoord(); this.mY = tile.getYCoord(); @@ -80,7 +82,7 @@ public void encode(ByteBuf aOut) { aOut.writeShort(mY); aOut.writeInt(mZ); - aOut.writeByte(side); + aOut.writeByte(side.ordinal()); aOut.writeInt(coverID); coverData.writeToByteBuf(aOut); @@ -94,7 +96,7 @@ public GT_Packet_New decode(ByteArrayDataInput aData) { aData.readInt(), aData.readShort(), aData.readInt(), - aData.readByte(), + ForgeDirection.getOrientation(aData.readByte()), coverId = aData.readInt(), GregTech_API.getCoverBehaviorNew(coverId) .createDataObject() diff --git a/src/main/java/gregtech/api/net/GT_Packet_WirelessRedstoneCover.java b/src/main/java/gregtech/api/net/GT_Packet_WirelessRedstoneCover.java index 5121ce03df1..08628ace2bd 100644 --- a/src/main/java/gregtech/api/net/GT_Packet_WirelessRedstoneCover.java +++ b/src/main/java/gregtech/api/net/GT_Packet_WirelessRedstoneCover.java @@ -7,6 +7,7 @@ import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.DimensionManager; +import net.minecraftforge.common.util.ForgeDirection; import com.google.common.io.ByteArrayDataInput; @@ -28,14 +29,14 @@ public GT_Packet_WirelessRedstoneCover() { super(); } - public GT_Packet_WirelessRedstoneCover(int mX, short mY, int mZ, byte coverSide, int coverID, int dimID, + public GT_Packet_WirelessRedstoneCover(int mX, short mY, int mZ, ForgeDirection coverSide, int coverID, int dimID, int publicChannel, int checkBoxValue) { super(mX, mY, mZ, coverSide, coverID, 0, dimID); mPublicChannel = publicChannel; mCheckBoxValue = checkBoxValue; } - public GT_Packet_WirelessRedstoneCover(byte coverSide, int coverID, ICoverable tile, int publicChannel, + public GT_Packet_WirelessRedstoneCover(ForgeDirection coverSide, int coverID, ICoverable tile, int publicChannel, int checkBoxValue) { super(coverSide, coverID, 0, tile); mPublicChannel = publicChannel; @@ -60,7 +61,7 @@ public void encode(ByteBuf aOut) { aOut.writeShort(mY); aOut.writeInt(mZ); - aOut.writeByte(side); + aOut.writeByte(side.ordinal()); aOut.writeInt(coverID); aOut.writeInt(dimID); @@ -75,7 +76,7 @@ public GT_Packet_New decode(ByteArrayDataInput aData) { aData.readInt(), aData.readShort(), aData.readInt(), - aData.readByte(), + ForgeDirection.getOrientation(aData.readByte()), aData.readInt(), aData.readInt(), aData.readInt(), diff --git a/src/main/java/gregtech/api/objects/GT_CopiedBlockTexture.java b/src/main/java/gregtech/api/objects/GT_CopiedBlockTexture.java index 8ea4ce008d8..c5307b48039 100644 --- a/src/main/java/gregtech/api/objects/GT_CopiedBlockTexture.java +++ b/src/main/java/gregtech/api/objects/GT_CopiedBlockTexture.java @@ -15,17 +15,17 @@ public class GT_CopiedBlockTexture extends gregtech.common.render.GT_CopiedBlock @Deprecated public short[] mRGBa; - public GT_CopiedBlockTexture(Block aBlock, int aSide, int aMeta, short[] aRGBa, boolean aAllowAlpha) { - super(aBlock, aSide, aMeta, aRGBa, aAllowAlpha); + public GT_CopiedBlockTexture(Block aBlock, int ordinalSide, int aMeta, short[] aRGBa, boolean aAllowAlpha) { + super(aBlock, ordinalSide, aMeta, aRGBa, aAllowAlpha); GT_CopiedBlockTexture.this.mRGBa = aRGBa; } - public GT_CopiedBlockTexture(Block aBlock, int aSide, int aMeta, short[] aRGBa) { - this(aBlock, aSide, aMeta, aRGBa, true); + public GT_CopiedBlockTexture(Block aBlock, int ordinalSide, int aMeta, short[] aRGBa) { + this(aBlock, ordinalSide, aMeta, aRGBa, true); } - public GT_CopiedBlockTexture(Block aBlock, int aSide, int aMeta) { - this(aBlock, aSide, aMeta, Dyes._NULL.mRGBa); + public GT_CopiedBlockTexture(Block aBlock, int ordinalSide, int aMeta) { + this(aBlock, ordinalSide, aMeta, Dyes._NULL.mRGBa); } @Override diff --git a/src/main/java/gregtech/api/objects/GT_Cover_Default.java b/src/main/java/gregtech/api/objects/GT_Cover_Default.java index b6259a9366f..cc5f96eef34 100644 --- a/src/main/java/gregtech/api/objects/GT_Cover_Default.java +++ b/src/main/java/gregtech/api/objects/GT_Cover_Default.java @@ -1,6 +1,7 @@ package gregtech.api.objects; import net.minecraft.entity.player.EntityPlayer; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.Fluid; import gregtech.api.interfaces.tileentity.ICoverable; @@ -22,7 +23,7 @@ public boolean isSimpleCover() { } @Override - public int onCoverScrewdriverclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, + public int onCoverScrewdriverclick(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) { aCoverVariable = ((aCoverVariable + 1) & 15); GT_Utility.sendChatToPlayer( @@ -35,42 +36,46 @@ public int onCoverScrewdriverclick(byte aSide, int aCoverID, int aCoverVariable, } @Override - public boolean letsRedstoneGoIn(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public boolean letsRedstoneGoIn(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return (aCoverVariable & 1) != 0; } @Override - public boolean letsRedstoneGoOut(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public boolean letsRedstoneGoOut(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return (aCoverVariable & 1) != 0; } @Override - public boolean letsEnergyIn(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public boolean letsEnergyIn(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return (aCoverVariable & 2) != 0; } @Override - public boolean letsEnergyOut(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public boolean letsEnergyOut(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return (aCoverVariable & 2) != 0; } @Override - public boolean letsFluidIn(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { + public boolean letsFluidIn(ForgeDirection side, int aCoverID, int aCoverVariable, Fluid aFluid, + ICoverable aTileEntity) { return (aCoverVariable & 4) != 0; } @Override - public boolean letsFluidOut(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { + public boolean letsFluidOut(ForgeDirection side, int aCoverID, int aCoverVariable, Fluid aFluid, + ICoverable aTileEntity) { return (aCoverVariable & 4) != 0; } @Override - public boolean letsItemsIn(byte aSide, int aCoverID, int aCoverVariable, int aSlot, ICoverable aTileEntity) { + public boolean letsItemsIn(ForgeDirection side, int aCoverID, int aCoverVariable, int aSlot, + ICoverable aTileEntity) { return (aCoverVariable & 8) != 0; } @Override - public boolean letsItemsOut(byte aSide, int aCoverID, int aCoverVariable, int aSlot, ICoverable aTileEntity) { + public boolean letsItemsOut(ForgeDirection side, int aCoverID, int aCoverVariable, int aSlot, + ICoverable aTileEntity) { return (aCoverVariable & 8) != 0; } } diff --git a/src/main/java/gregtech/api/objects/GT_Cover_None.java b/src/main/java/gregtech/api/objects/GT_Cover_None.java index e0b1adf66e8..30a12d63541 100644 --- a/src/main/java/gregtech/api/objects/GT_Cover_None.java +++ b/src/main/java/gregtech/api/objects/GT_Cover_None.java @@ -4,6 +4,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.Fluid; import gregtech.api.interfaces.tileentity.ICoverable; @@ -18,76 +19,80 @@ public class GT_Cover_None extends GT_CoverBehavior { public GT_Cover_None() {} @Override - public float getBlastProofLevel(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public float getBlastProofLevel(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return 10.0F; } @Override - public boolean letsRedstoneGoIn(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public boolean letsRedstoneGoIn(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return true; } @Override - public boolean letsRedstoneGoOut(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public boolean letsRedstoneGoOut(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return true; } @Override - public boolean letsEnergyIn(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public boolean letsEnergyIn(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return true; } @Override - public boolean letsEnergyOut(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public boolean letsEnergyOut(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return true; } @Override - public boolean letsFluidIn(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { + public boolean letsFluidIn(ForgeDirection side, int aCoverID, int aCoverVariable, Fluid aFluid, + ICoverable aTileEntity) { return true; } @Override - public boolean letsFluidOut(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { + public boolean letsFluidOut(ForgeDirection side, int aCoverID, int aCoverVariable, Fluid aFluid, + ICoverable aTileEntity) { return true; } @Override - public boolean letsItemsIn(byte aSide, int aCoverID, int aCoverVariable, int aSlot, ICoverable aTileEntity) { + public boolean letsItemsIn(ForgeDirection side, int aCoverID, int aCoverVariable, int aSlot, + ICoverable aTileEntity) { return true; } @Override - public boolean letsItemsOut(byte aSide, int aCoverID, int aCoverVariable, int aSlot, ICoverable aTileEntity) { + public boolean letsItemsOut(ForgeDirection side, int aCoverID, int aCoverVariable, int aSlot, + ICoverable aTileEntity) { return true; } @Override - public boolean isGUIClickable(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public boolean isGUIClickable(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return true; } @Override - public boolean manipulatesSidedRedstoneOutput(byte aSide, int aCoverID, int aCoverVariable, + public boolean manipulatesSidedRedstoneOutput(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return false; } @Override - public boolean onCoverRightclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, + public boolean onCoverRightclick(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) { return false; } @Override - public boolean onCoverRemoval(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, + public boolean onCoverRemoval(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity, boolean aForced) { return true; } @Override - public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity, - long aTimer) { + public int doCoverThings(ForgeDirection side, byte aInputRedstone, int aCoverID, int aCoverVariable, + ICoverable aTileEntity, long aTimer) { return 0; } @@ -97,154 +102,142 @@ public boolean isSimpleCover() { } @Override - protected boolean isRedstoneSensitiveImpl(byte aSide, int aCoverID, + protected boolean isRedstoneSensitiveImpl(ForgeDirection side, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity, long aTimer) { return false; } @Override - protected ISerializableObject.LegacyCoverData doCoverThingsImpl(byte aSide, byte aInputRedstone, int aCoverID, - ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity, long aTimer) { + protected ISerializableObject.LegacyCoverData doCoverThingsImpl(ForgeDirection side, byte aInputRedstone, + int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity, long aTimer) { return aCoverVariable; } @Override - protected boolean onCoverRightClickImpl(byte aSide, int aCoverID, + protected boolean onCoverRightClickImpl(ForgeDirection side, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) { return false; } @Override - protected ISerializableObject.LegacyCoverData onCoverScrewdriverClickImpl(byte aSide, int aCoverID, + protected ISerializableObject.LegacyCoverData onCoverScrewdriverClickImpl(ForgeDirection side, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) { return aCoverVariable; } @Override - protected boolean onCoverShiftRightClickImpl(byte aSide, int aCoverID, + protected boolean onCoverShiftRightClickImpl(ForgeDirection side, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer) { return false; } @Override - protected boolean onCoverRemovalImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, - ICoverable aTileEntity, boolean aForced) { + protected boolean onCoverRemovalImpl(ForgeDirection side, int aCoverID, + ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity, boolean aForced) { return true; } @Override - protected String getDescriptionImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, - ICoverable aTileEntity) { + protected String getDescriptionImpl(ForgeDirection side, int aCoverID, + ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity) { return E; } @Override - protected float getBlastProofLevelImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, - ICoverable aTileEntity) { + protected float getBlastProofLevelImpl(ForgeDirection side, int aCoverID, + ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity) { return 10.0F; } @Override - protected boolean letsRedstoneGoInImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, - ICoverable aTileEntity) { - return true; - } - - @Override - protected boolean letsRedstoneGoOutImpl(byte aSide, int aCoverID, + protected boolean letsRedstoneGoInImpl(ForgeDirection side, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity) { return true; } @Override - protected boolean letsFibreGoInImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, - ICoverable aTileEntity) { - return true; - } - - @Override - protected boolean letsFibreGoOutImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, - ICoverable aTileEntity) { + protected boolean letsRedstoneGoOutImpl(ForgeDirection side, int aCoverID, + ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity) { return true; } @Override - protected boolean letsEnergyInImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, - ICoverable aTileEntity) { + protected boolean letsEnergyInImpl(ForgeDirection side, int aCoverID, + ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity) { return true; } @Override - protected boolean letsEnergyOutImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, - ICoverable aTileEntity) { + protected boolean letsEnergyOutImpl(ForgeDirection side, int aCoverID, + ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity) { return true; } @Override - protected boolean letsFluidInImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, - Fluid aFluid, ICoverable aTileEntity) { + protected boolean letsFluidInImpl(ForgeDirection side, int aCoverID, + ISerializableObject.LegacyCoverData aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { return true; } @Override - protected boolean letsFluidOutImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, - Fluid aFluid, ICoverable aTileEntity) { + protected boolean letsFluidOutImpl(ForgeDirection side, int aCoverID, + ISerializableObject.LegacyCoverData aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { return true; } @Override - protected boolean letsItemsInImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, - int aSlot, ICoverable aTileEntity) { + protected boolean letsItemsInImpl(ForgeDirection side, int aCoverID, + ISerializableObject.LegacyCoverData aCoverVariable, int aSlot, ICoverable aTileEntity) { return true; } @Override - protected boolean letsItemsOutImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, - int aSlot, ICoverable aTileEntity) { + protected boolean letsItemsOutImpl(ForgeDirection side, int aCoverID, + ISerializableObject.LegacyCoverData aCoverVariable, int aSlot, ICoverable aTileEntity) { return true; } @Override - protected boolean isGUIClickableImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, - ICoverable aTileEntity) { + protected boolean isGUIClickableImpl(ForgeDirection side, int aCoverID, + ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity) { return true; } @Override - protected boolean manipulatesSidedRedstoneOutputImpl(byte aSide, int aCoverID, + protected boolean manipulatesSidedRedstoneOutputImpl(ForgeDirection side, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity) { return false; } @Override - protected boolean alwaysLookConnectedImpl(byte aSide, int aCoverID, + protected boolean alwaysLookConnectedImpl(ForgeDirection side, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity) { return false; } @Override - protected byte getRedstoneInputImpl(byte aSide, byte aInputRedstone, int aCoverID, + protected byte getRedstoneInputImpl(ForgeDirection side, byte aInputRedstone, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity) { return aInputRedstone; } @Override - protected int getTickRateImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, + protected int getTickRateImpl(ForgeDirection side, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity) { return 0; } @Override - protected byte getLensColorImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, - ICoverable aTileEntity) { + protected byte getLensColorImpl(ForgeDirection side, int aCoverID, + ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity) { return -1; } @Override - protected ItemStack getDropImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, - ICoverable aTileEntity) { + protected ItemStack getDropImpl(ForgeDirection side, int aCoverID, + ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity) { return null; } } diff --git a/src/main/java/gregtech/api/objects/GT_StdRenderedTexture.java b/src/main/java/gregtech/api/objects/GT_StdRenderedTexture.java index cc7410a4811..d4b8d16da62 100644 --- a/src/main/java/gregtech/api/objects/GT_StdRenderedTexture.java +++ b/src/main/java/gregtech/api/objects/GT_StdRenderedTexture.java @@ -12,7 +12,7 @@ * This ITexture implementation extends the GT_RenderedTexture class to render with bottom side flipped as with dumb * blocks rendering. It is used in Ore blocks rendering so they better blends with dumb block ores from vanilla or other * mods, when seen from bottom. - * + * * @deprecated Replaced by the {@link gregtech.api.render.TextureFactory} API. */ @Deprecated @@ -36,10 +36,10 @@ public GT_StdRenderedTexture(IIconContainer aIcon) { public void renderYNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { LightingHelper lighting = new LightingHelper(aRenderer); lighting.setupLightingYNeg(aBlock, aX, aY, aZ) - .setupColor(ForgeDirection.DOWN.ordinal(), mRGBa); + .setupColor(ForgeDirection.DOWN, mRGBa); aRenderer.renderFaceYNeg(aBlock, aX, aY, aZ, mIconContainer.getIcon()); if (mIconContainer.getOverlayIcon() != null) { - lighting.setupColor(ForgeDirection.DOWN.ordinal(), 0xffffff); + lighting.setupColor(ForgeDirection.DOWN, 0xffffff); aRenderer.renderFaceYNeg(aBlock, aX, aY, aZ, mIconContainer.getOverlayIcon()); } } diff --git a/src/main/java/gregtech/api/threads/GT_Runnable_Cable_Update.java b/src/main/java/gregtech/api/threads/GT_Runnable_Cable_Update.java index c670307b5da..31c3c56aa8c 100644 --- a/src/main/java/gregtech/api/threads/GT_Runnable_Cable_Update.java +++ b/src/main/java/gregtech/api/threads/GT_Runnable_Cable_Update.java @@ -1,7 +1,5 @@ package gregtech.api.threads; -import static gregtech.api.enums.GT_Values.ALL_VALID_SIDES; - import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ChunkCoordinates; import net.minecraft.world.World; @@ -51,18 +49,16 @@ public void run() { // Now see if we should add the nearby blocks to the queue: // only add blocks the cable is connected to - if (tTileEntity instanceof BaseMetaPipeEntity - && ((BaseMetaPipeEntity) tTileEntity).getMetaTileEntity() instanceof GT_MetaPipeEntity_Cable) { + if (tTileEntity instanceof BaseMetaPipeEntity metaPipe + && metaPipe.getMetaTileEntity() instanceof GT_MetaPipeEntity_Cable cable) { ChunkCoordinates tCoords; - for (byte tSide : ALL_VALID_SIDES) { - if (((GT_MetaPipeEntity_Cable) ((BaseMetaPipeEntity) tTileEntity).getMetaTileEntity()) - .isConnectedAtSide(tSide)) { - final ForgeDirection offset = ForgeDirection.getOrientation(tSide); + for (final ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + if (cable.isConnectedAtSide(side)) { if (visited.add( tCoords = new ChunkCoordinates( - aCoords.posX + offset.offsetX, - aCoords.posY + offset.offsetY, - aCoords.posZ + offset.offsetZ))) + aCoords.posX + side.offsetX, + aCoords.posY + side.offsetY, + aCoords.posZ + side.offsetZ))) tQueue.add(tCoords); } } diff --git a/src/main/java/gregtech/api/util/GT_CircuitryBehavior.java b/src/main/java/gregtech/api/util/GT_CircuitryBehavior.java index b15627bb05b..d5cd50049ef 100644 --- a/src/main/java/gregtech/api/util/GT_CircuitryBehavior.java +++ b/src/main/java/gregtech/api/util/GT_CircuitryBehavior.java @@ -1,6 +1,6 @@ package gregtech.api.util; -import static gregtech.api.enums.GT_Values.ALL_VALID_SIDES; +import net.minecraftforge.common.util.ForgeDirection; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -35,7 +35,7 @@ public GT_CircuitryBehavior(int aIndex) { * returns if there is Redstone applied to any of the valid Inputs (OR) */ public static boolean getAnyRedstone(IRedstoneCircuitBlock aRedstoneCircuitBlock) { - for (byte side : ALL_VALID_SIDES) { + for (final ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { if (side != aRedstoneCircuitBlock.getOutputFacing() && aRedstoneCircuitBlock.getCover(side) .letsRedstoneGoIn( side, @@ -54,7 +54,7 @@ public static boolean getAnyRedstone(IRedstoneCircuitBlock aRedstoneCircuitBlock * returns if there is Redstone applied to all the valid Inputs (AND) */ public static boolean getAllRedstone(IRedstoneCircuitBlock aRedstoneCircuitBlock) { - for (byte side : ALL_VALID_SIDES) { + for (final ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { if (side != aRedstoneCircuitBlock.getOutputFacing() && aRedstoneCircuitBlock.getCover(side) .letsRedstoneGoIn( side, @@ -74,7 +74,7 @@ public static boolean getAllRedstone(IRedstoneCircuitBlock aRedstoneCircuitBlock */ public static boolean getOneRedstone(IRedstoneCircuitBlock aRedstoneCircuitBlock) { int tRedstoneAmount = 0; - for (byte side : ALL_VALID_SIDES) { + for (final ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { if (side != aRedstoneCircuitBlock.getOutputFacing() && aRedstoneCircuitBlock.getCover(side) .letsRedstoneGoIn( side, @@ -94,7 +94,7 @@ public static boolean getOneRedstone(IRedstoneCircuitBlock aRedstoneCircuitBlock */ public static byte getStrongestRedstone(IRedstoneCircuitBlock aRedstoneCircuitBlock) { byte tRedstoneAmount = 0; - for (byte side : ALL_VALID_SIDES) { + for (final ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { if (side != aRedstoneCircuitBlock.getOutputFacing() && aRedstoneCircuitBlock.getCover(side) .letsRedstoneGoIn( side, @@ -117,7 +117,7 @@ public static byte getStrongestRedstone(IRedstoneCircuitBlock aRedstoneCircuitBl public static byte getWeakestNonZeroRedstone(IRedstoneCircuitBlock aRedstoneCircuitBlock) { if (!getAnyRedstone(aRedstoneCircuitBlock)) return 0; byte tRedstoneAmount = 15; - for (byte side : ALL_VALID_SIDES) { + for (final ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { if (side != aRedstoneCircuitBlock.getOutputFacing() && aRedstoneCircuitBlock.getCover(side) .letsRedstoneGoIn( side, @@ -137,7 +137,7 @@ public static byte getWeakestNonZeroRedstone(IRedstoneCircuitBlock aRedstoneCirc public static byte getWeakestRedstone(IRedstoneCircuitBlock aRedstoneCircuitBlock) { if (!getAnyRedstone(aRedstoneCircuitBlock)) return 0; byte tRedstoneAmount = 15; - for (byte side : ALL_VALID_SIDES) { + for (final ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { if (side != aRedstoneCircuitBlock.getOutputFacing() && aRedstoneCircuitBlock.getCover(side) .letsRedstoneGoIn( side, diff --git a/src/main/java/gregtech/api/util/GT_CoverBehavior.java b/src/main/java/gregtech/api/util/GT_CoverBehavior.java index 60196bd2367..6441adb22b8 100644 --- a/src/main/java/gregtech/api/util/GT_CoverBehavior.java +++ b/src/main/java/gregtech/api/util/GT_CoverBehavior.java @@ -6,6 +6,7 @@ import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.Fluid; import gregtech.api.enums.GT_Values; @@ -47,172 +48,161 @@ public ISerializableObject.LegacyCoverData createDataObject(int aLegacyData) { } @Override - protected boolean isRedstoneSensitiveImpl(byte aSide, int aCoverID, + protected boolean isRedstoneSensitiveImpl(ForgeDirection side, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity, long aTimer) { - return isRedstoneSensitive(aSide, aCoverID, aCoverVariable.get(), aTileEntity, aTimer); + return isRedstoneSensitive(side, aCoverID, aCoverVariable.get(), aTileEntity, aTimer); } @Override - protected ISerializableObject.LegacyCoverData doCoverThingsImpl(byte aSide, byte aInputRedstone, int aCoverID, - ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity, long aTimer) { + protected ISerializableObject.LegacyCoverData doCoverThingsImpl(ForgeDirection side, byte aInputRedstone, + int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity, long aTimer) { if (aCoverVariable == null) aCoverVariable = new ISerializableObject.LegacyCoverData(); - aCoverVariable.set(doCoverThings(aSide, aInputRedstone, aCoverID, aCoverVariable.get(), aTileEntity, aTimer)); + aCoverVariable.set(doCoverThings(side, aInputRedstone, aCoverID, aCoverVariable.get(), aTileEntity, aTimer)); return aCoverVariable; } @Override - protected boolean onCoverRightClickImpl(byte aSide, int aCoverID, + protected boolean onCoverRightClickImpl(ForgeDirection side, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) { - return onCoverRightclick(aSide, aCoverID, convert(aCoverVariable), aTileEntity, aPlayer, aX, aY, aZ); + return onCoverRightclick(side, aCoverID, convert(aCoverVariable), aTileEntity, aPlayer, aX, aY, aZ); } @Override - protected ISerializableObject.LegacyCoverData onCoverScrewdriverClickImpl(byte aSide, int aCoverID, + protected ISerializableObject.LegacyCoverData onCoverScrewdriverClickImpl(ForgeDirection side, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) { if (aCoverVariable == null) aCoverVariable = new ISerializableObject.LegacyCoverData(); aCoverVariable - .set(onCoverScrewdriverclick(aSide, aCoverID, convert(aCoverVariable), aTileEntity, aPlayer, aX, aY, aZ)); + .set(onCoverScrewdriverclick(side, aCoverID, convert(aCoverVariable), aTileEntity, aPlayer, aX, aY, aZ)); return aCoverVariable; } @Override - protected boolean onCoverShiftRightClickImpl(byte aSide, int aCoverID, + protected boolean onCoverShiftRightClickImpl(ForgeDirection side, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer) { - return onCoverShiftRightclick(aSide, aCoverID, convert(aCoverVariable), aTileEntity, aPlayer); + return onCoverShiftRightclick(side, aCoverID, convert(aCoverVariable), aTileEntity, aPlayer); } @Deprecated @Override - protected Object getClientGUIImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, - ICoverable aTileEntity, EntityPlayer aPlayer, World aWorld) { - return getClientGUI(aSide, aCoverID, convert(aCoverVariable), aTileEntity); - } - - @Override - protected boolean onCoverRemovalImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, - ICoverable aTileEntity, boolean aForced) { - return onCoverRemoval(aSide, aCoverID, convert(aCoverVariable), aTileEntity, aForced); + protected Object getClientGUIImpl(ForgeDirection side, int aCoverID, + ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, + World aWorld) { + return getClientGUI(side, aCoverID, convert(aCoverVariable), aTileEntity); } @Override - protected String getDescriptionImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, - ICoverable aTileEntity) { - return getDescription(aSide, aCoverID, convert(aCoverVariable), aTileEntity); + protected boolean onCoverRemovalImpl(ForgeDirection side, int aCoverID, + ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity, boolean aForced) { + return onCoverRemoval(side, aCoverID, convert(aCoverVariable), aTileEntity, aForced); } @Override - protected float getBlastProofLevelImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, - ICoverable aTileEntity) { - return getBlastProofLevel(aSide, aCoverID, convert(aCoverVariable), aTileEntity); - } - - @Override - protected boolean letsRedstoneGoInImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, - ICoverable aTileEntity) { - return letsRedstoneGoIn(aSide, aCoverID, convert(aCoverVariable), aTileEntity); + protected String getDescriptionImpl(ForgeDirection side, int aCoverID, + ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity) { + return getDescription(side, aCoverID, convert(aCoverVariable), aTileEntity); } @Override - protected boolean letsRedstoneGoOutImpl(byte aSide, int aCoverID, + protected float getBlastProofLevelImpl(ForgeDirection side, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity) { - return letsRedstoneGoOut(aSide, aCoverID, convert(aCoverVariable), aTileEntity); + return getBlastProofLevel(side, aCoverID, convert(aCoverVariable), aTileEntity); } @Override - protected boolean letsFibreGoInImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, - ICoverable aTileEntity) { - return letsFibreGoIn(aSide, aCoverID, convert(aCoverVariable), aTileEntity); + protected boolean letsRedstoneGoInImpl(ForgeDirection side, int aCoverID, + ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity) { + return letsRedstoneGoIn(side, aCoverID, convert(aCoverVariable), aTileEntity); } @Override - protected boolean letsFibreGoOutImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, - ICoverable aTileEntity) { - return letsFibreGoOut(aSide, aCoverID, convert(aCoverVariable), aTileEntity); + protected boolean letsRedstoneGoOutImpl(ForgeDirection side, int aCoverID, + ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity) { + return letsRedstoneGoOut(side, aCoverID, convert(aCoverVariable), aTileEntity); } @Override - protected boolean letsEnergyInImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, - ICoverable aTileEntity) { - return letsEnergyIn(aSide, aCoverID, convert(aCoverVariable), aTileEntity); + protected boolean letsEnergyInImpl(ForgeDirection side, int aCoverID, + ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity) { + return letsEnergyIn(side, aCoverID, convert(aCoverVariable), aTileEntity); } @Override - protected boolean letsEnergyOutImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, - ICoverable aTileEntity) { - return letsEnergyOut(aSide, aCoverID, convert(aCoverVariable), aTileEntity); + protected boolean letsEnergyOutImpl(ForgeDirection side, int aCoverID, + ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity) { + return letsEnergyOut(side, aCoverID, convert(aCoverVariable), aTileEntity); } @Override - protected boolean letsFluidInImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, - Fluid aFluid, ICoverable aTileEntity) { - return letsFluidIn(aSide, aCoverID, convert(aCoverVariable), aFluid, aTileEntity); + protected boolean letsFluidInImpl(ForgeDirection side, int aCoverID, + ISerializableObject.LegacyCoverData aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { + return letsFluidIn(side, aCoverID, convert(aCoverVariable), aFluid, aTileEntity); } @Override - protected boolean letsFluidOutImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, - Fluid aFluid, ICoverable aTileEntity) { - return letsFluidOut(aSide, aCoverID, convert(aCoverVariable), aFluid, aTileEntity); + protected boolean letsFluidOutImpl(ForgeDirection side, int aCoverID, + ISerializableObject.LegacyCoverData aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { + return letsFluidOut(side, aCoverID, convert(aCoverVariable), aFluid, aTileEntity); } @Override - protected boolean letsItemsInImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, - int aSlot, ICoverable aTileEntity) { - return letsItemsIn(aSide, aCoverID, convert(aCoverVariable), aSlot, aTileEntity); + protected boolean letsItemsInImpl(ForgeDirection side, int aCoverID, + ISerializableObject.LegacyCoverData aCoverVariable, int aSlot, ICoverable aTileEntity) { + return letsItemsIn(side, aCoverID, convert(aCoverVariable), aSlot, aTileEntity); } @Override - protected boolean letsItemsOutImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, - int aSlot, ICoverable aTileEntity) { - return letsItemsOut(aSide, aCoverID, convert(aCoverVariable), aSlot, aTileEntity); + protected boolean letsItemsOutImpl(ForgeDirection side, int aCoverID, + ISerializableObject.LegacyCoverData aCoverVariable, int aSlot, ICoverable aTileEntity) { + return letsItemsOut(side, aCoverID, convert(aCoverVariable), aSlot, aTileEntity); } @Override - protected boolean isGUIClickableImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, - ICoverable aTileEntity) { - return isGUIClickable(aSide, aCoverID, convert(aCoverVariable), aTileEntity); + protected boolean isGUIClickableImpl(ForgeDirection side, int aCoverID, + ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity) { + return isGUIClickable(side, aCoverID, convert(aCoverVariable), aTileEntity); } @Override - protected boolean manipulatesSidedRedstoneOutputImpl(byte aSide, int aCoverID, + protected boolean manipulatesSidedRedstoneOutputImpl(ForgeDirection side, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity) { - return manipulatesSidedRedstoneOutput(aSide, aCoverID, convert(aCoverVariable), aTileEntity); + return manipulatesSidedRedstoneOutput(side, aCoverID, convert(aCoverVariable), aTileEntity); } @Override - protected boolean alwaysLookConnectedImpl(byte aSide, int aCoverID, + protected boolean alwaysLookConnectedImpl(ForgeDirection side, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity) { - return alwaysLookConnected(aSide, aCoverID, convert(aCoverVariable), aTileEntity); + return alwaysLookConnected(side, aCoverID, convert(aCoverVariable), aTileEntity); } @Override - protected byte getRedstoneInputImpl(byte aSide, byte aInputRedstone, int aCoverID, + protected byte getRedstoneInputImpl(ForgeDirection side, byte aInputRedstone, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity) { - return getRedstoneInput(aSide, aInputRedstone, aCoverID, convert(aCoverVariable), aTileEntity); + return getRedstoneInput(side, aInputRedstone, aCoverID, convert(aCoverVariable), aTileEntity); } @Override - protected int getTickRateImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, + protected int getTickRateImpl(ForgeDirection side, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity) { - return getTickRate(aSide, aCoverID, convert(aCoverVariable), aTileEntity); + return getTickRate(side, aCoverID, convert(aCoverVariable), aTileEntity); } @Override - protected byte getLensColorImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, - ICoverable aTileEntity) { - return getLensColor(aSide, aCoverID, convert(aCoverVariable), aTileEntity); + protected byte getLensColorImpl(ForgeDirection side, int aCoverID, + ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity) { + return getLensColor(side, aCoverID, convert(aCoverVariable), aTileEntity); } @Override - protected ItemStack getDropImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, - ICoverable aTileEntity) { - return getDrop(aSide, aCoverID, convert(aCoverVariable), aTileEntity); + protected ItemStack getDropImpl(ForgeDirection side, int aCoverID, + ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity) { + return getDrop(side, aCoverID, convert(aCoverVariable), aTileEntity); } // endregion - public boolean isRedstoneSensitive(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, + public boolean isRedstoneSensitive(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) { return true; } @@ -220,8 +210,8 @@ public boolean isRedstoneSensitive(byte aSide, int aCoverID, int aCoverVariable, /** * Called by updateEntity inside the covered TileEntity. aCoverVariable is the Value you returned last time. */ - public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity, - long aTimer) { + public int doCoverThings(ForgeDirection side, byte aInputRedstone, int aCoverID, int aCoverVariable, + ICoverable aTileEntity, long aTimer) { return aCoverVariable; } @@ -230,7 +220,7 @@ public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCov *

* return true, if something actually happens. */ - public boolean onCoverRightclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, + public boolean onCoverRightclick(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) { return false; } @@ -240,7 +230,7 @@ public boolean onCoverRightclick(byte aSide, int aCoverID, int aCoverVariable, I *

* return the new Value of the Cover Variable */ - public int onCoverScrewdriverclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, + public int onCoverScrewdriverclick(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) { return aCoverVariable; } @@ -248,17 +238,17 @@ public int onCoverScrewdriverclick(byte aSide, int aCoverID, int aCoverVariable, /** * Called when someone shift-rightclicks this Cover with no tool. Doesn't call @onCoverRightclick in this Case. */ - public boolean onCoverShiftRightclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, + public boolean onCoverShiftRightclick(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer) { if (hasCoverGUI() && aPlayer instanceof EntityPlayerMP) { lastPlayer = aPlayer; mPlayerNotified = false; if (useModularUI()) { - GT_UIInfos.openCoverUI(aTileEntity, aPlayer, aSide); + GT_UIInfos.openCoverUI(aTileEntity, aPlayer, side); } else { GT_Values.NW.sendToPlayer( new GT_Packet_TileEntityCoverGUI( - aSide, + side, aCoverID, aCoverVariable, aTileEntity, @@ -271,7 +261,7 @@ public boolean onCoverShiftRightclick(byte aSide, int aCoverID, int aCoverVariab } @Deprecated - public Object getClientGUI(byte aSide, int aCoverID, int coverData, ICoverable aTileEntity) { + public Object getClientGUI(ForgeDirection side, int aCoverID, int coverData, ICoverable aTileEntity) { return null; } @@ -279,7 +269,7 @@ public Object getClientGUI(byte aSide, int aCoverID, int coverData, ICoverable a * Removes the Cover if this returns true, or if aForced is true. Doesn't get called when the Machine Block is * getting broken, only if you break the Cover away from the Machine. */ - public boolean onCoverRemoval(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, + public boolean onCoverRemoval(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity, boolean aForced) { return true; } @@ -287,14 +277,14 @@ public boolean onCoverRemoval(byte aSide, int aCoverID, int aCoverVariable, ICov /** * Gives a small Text for the status of the Cover. */ - public String getDescription(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public String getDescription(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return E; } /** * How Blast Proof the Cover is. 30 is normal. */ - public float getBlastProofLevel(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public float getBlastProofLevel(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return 10.0F; } @@ -303,58 +293,44 @@ public float getBlastProofLevel(byte aSide, int aCoverID, int aCoverVariable, IC *

* This is just Informative so that Machines know if their Redstone Input is blocked or not */ - public boolean letsRedstoneGoIn(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public boolean letsRedstoneGoIn(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return false; } /** * If it lets RS-Signals out of the Block */ - public boolean letsRedstoneGoOut(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { - return false; - } - - /** - * If it lets Fibre-Signals into the Block - *

- * This is just Informative so that Machines know if their Redstone Input is blocked or not - */ - public boolean letsFibreGoIn(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { - return false; - } - - /** - * If it lets Fibre-Signals out of the Block - */ - public boolean letsFibreGoOut(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public boolean letsRedstoneGoOut(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return false; } /** * If it lets Energy into the Block */ - public boolean letsEnergyIn(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public boolean letsEnergyIn(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return false; } /** * If it lets Energy out of the Block */ - public boolean letsEnergyOut(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public boolean letsEnergyOut(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return false; } /** * If it lets Liquids into the Block, aFluid can be null meaning if this is generally allowing Fluids or not. */ - public boolean letsFluidIn(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { + public boolean letsFluidIn(ForgeDirection side, int aCoverID, int aCoverVariable, Fluid aFluid, + ICoverable aTileEntity) { return false; } /** * If it lets Liquids out of the Block, aFluid can be null meaning if this is generally allowing Fluids or not. */ - public boolean letsFluidOut(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { + public boolean letsFluidOut(ForgeDirection side, int aCoverID, int aCoverVariable, Fluid aFluid, + ICoverable aTileEntity) { return false; } @@ -363,7 +339,8 @@ public boolean letsFluidOut(byte aSide, int aCoverID, int aCoverVariable, Fluid * Interaction at all), aSlot = -2 means if it would accept for all Slots (return true to skip the Checks for each * Slot). */ - public boolean letsItemsIn(byte aSide, int aCoverID, int aCoverVariable, int aSlot, ICoverable aTileEntity) { + public boolean letsItemsIn(ForgeDirection side, int aCoverID, int aCoverVariable, int aSlot, + ICoverable aTileEntity) { return false; } @@ -372,21 +349,22 @@ public boolean letsItemsIn(byte aSide, int aCoverID, int aCoverVariable, int aSl * Interaction at all), aSlot = -2 means if it would accept for all Slots (return true to skip the Checks for each * Slot). */ - public boolean letsItemsOut(byte aSide, int aCoverID, int aCoverVariable, int aSlot, ICoverable aTileEntity) { + public boolean letsItemsOut(ForgeDirection side, int aCoverID, int aCoverVariable, int aSlot, + ICoverable aTileEntity) { return false; } /** * If it lets you rightclick the Machine normally */ - public boolean isGUIClickable(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public boolean isGUIClickable(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return false; } /** * Needs to return true for Covers, which have a Redstone Output on their Facing. */ - public boolean manipulatesSidedRedstoneOutput(byte aSide, int aCoverID, int aCoverVariable, + public boolean manipulatesSidedRedstoneOutput(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return false; } @@ -394,7 +372,7 @@ public boolean manipulatesSidedRedstoneOutput(byte aSide, int aCoverID, int aCov /** * if this Cover should let Pipe Connections look connected even if it is not the case. */ - public boolean alwaysLookConnected(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public boolean alwaysLookConnected(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return false; } @@ -402,9 +380,9 @@ public boolean alwaysLookConnected(byte aSide, int aCoverID, int aCoverVariable, * Called to determine the incoming Redstone Signal of a Machine. Returns the original Redstone per default. The * Cover should @letsRedstoneGoIn or the aInputRedstone Parameter is always 0. */ - public byte getRedstoneInput(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, + public byte getRedstoneInput(ForgeDirection side, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { - return letsRedstoneGoIn(aSide, aCoverID, aCoverVariable, aTileEntity) ? aInputRedstone : 0; + return letsRedstoneGoIn(side, aCoverID, aCoverVariable, aTileEntity) ? aInputRedstone : 0; } /** @@ -412,21 +390,21 @@ public byte getRedstoneInput(byte aSide, byte aInputRedstone, int aCoverID, int *

* 0 = No Ticks! Yes, 0 is Default, you have to override this */ - public int getTickRate(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public int getTickRate(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return 0; } /** * The MC Color of this Lens. -1 for no Color (meaning this isn't a Lens then). */ - public byte getLensColor(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public byte getLensColor(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return -1; } /** * @return the ItemStack dropped by this Cover */ - public ItemStack getDrop(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { - return GT_OreDictUnificator.get(true, aTileEntity.getCoverItemAtSide(aSide)); + public ItemStack getDrop(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return GT_OreDictUnificator.get(true, aTileEntity.getCoverItemAtSide(side)); } } diff --git a/src/main/java/gregtech/api/util/GT_CoverBehaviorBase.java b/src/main/java/gregtech/api/util/GT_CoverBehaviorBase.java index 1757d0375a3..8f65ae15534 100644 --- a/src/main/java/gregtech/api/util/GT_CoverBehaviorBase.java +++ b/src/main/java/gregtech/api/util/GT_CoverBehaviorBase.java @@ -13,6 +13,7 @@ import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagInt; import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.Fluid; import com.gtnewhorizons.modularui.api.ModularUITextures; @@ -89,23 +90,23 @@ private T forceCast(ISerializableObject aData) { /** * Get target facade block. Does not affect rendering of **this** block. It is only used as a hint for other block * in case of CTM - * + * * @return null if none, otherwise return facade target block */ - public final Block getFacadeBlock(byte aSide, int aCoverID, ISerializableObject aCoverVariable, + public final Block getFacadeBlock(ForgeDirection side, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) { - return getFacadeBlockImpl(aSide, aCoverID, forceCast(aCoverVariable), aTileEntity); + return getFacadeBlockImpl(side, aCoverID, forceCast(aCoverVariable), aTileEntity); } /** * Get target facade block. Does not affect rendering of **this** block. It is only used as a hint for other block * in case of CTM - * + * * @return 0 if none, otherwise return facade target meta */ - public final int getFacadeMeta(byte aSide, int aCoverID, ISerializableObject aCoverVariable, + public final int getFacadeMeta(ForgeDirection side, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) { - return getFacadeMetaImpl(aSide, aCoverID, forceCast(aCoverVariable), aTileEntity); + return getFacadeMetaImpl(side, aCoverID, forceCast(aCoverVariable), aTileEntity); } /** @@ -120,46 +121,46 @@ public final ItemStack getDisplayStack(int aCoverID, ISerializableObject aCoverV * passed to {@link gregtech.api.GregTech_API#registerCover(ItemStack, ITexture, GT_CoverBehaviorBase)} or its * overloads. */ - public final ITexture getSpecialCoverFGTexture(byte aSide, int aCoverID, ISerializableObject aCoverVariable, - ICoverable aTileEntity) { - return getSpecialCoverFGTextureImpl(aSide, aCoverID, forceCast(aCoverVariable), aTileEntity); + public final ITexture getSpecialCoverFGTexture(ForgeDirection side, int aCoverID, + ISerializableObject aCoverVariable, ICoverable aTileEntity) { + return getSpecialCoverFGTextureImpl(side, aCoverID, forceCast(aCoverVariable), aTileEntity); } /** * Get the special cover texture associated with this cover. Return null if one should use the texture passed to * {@link gregtech.api.GregTech_API#registerCover(ItemStack, ITexture, GT_CoverBehaviorBase)} or its overloads. */ - public final ITexture getSpecialCoverTexture(byte aSide, int aCoverID, ISerializableObject aCoverVariable, + public final ITexture getSpecialCoverTexture(ForgeDirection side, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) { - return getSpecialCoverTextureImpl(aSide, aCoverID, forceCast(aCoverVariable), aTileEntity); + return getSpecialCoverTextureImpl(side, aCoverID, forceCast(aCoverVariable), aTileEntity); } /** * Return whether cover data needs to be synced to client upon tile entity creation or cover placement. * * Note if you want to sync the data afterwards you will have to manually do it by calling - * {@link ICoverable#issueCoverUpdate(byte)} This option only affects the initial sync. + * {@link ICoverable#issueCoverUpdate(ForgeDirection)} This option only affects the initial sync. */ - public final boolean isDataNeededOnClient(byte aSide, int aCoverID, ISerializableObject aCoverVariable, + public final boolean isDataNeededOnClient(ForgeDirection side, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) { - return isDataNeededOnClientImpl(aSide, aCoverID, forceCast(aCoverVariable), aTileEntity); + return isDataNeededOnClientImpl(side, aCoverID, forceCast(aCoverVariable), aTileEntity); } /** * Called upon receiving data from network. Use {@link ICoverable#isClientSide()} to determine the side. */ - public final void onDataChanged(byte aSide, int aCoverID, ISerializableObject aCoverVariable, + public final void onDataChanged(ForgeDirection side, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) { - onDataChangedImpl(aSide, aCoverID, forceCast(aCoverVariable), aTileEntity); + onDataChangedImpl(side, aCoverID, forceCast(aCoverVariable), aTileEntity); } /** * Called before receiving data from network. Use {@link ICoverable#isClientSide()} to determine the side. */ - public final void preDataChanged(byte aSide, int aCoverID, int aNewCoverId, ISerializableObject aCoverVariable, - ISerializableObject aNewCoverVariable, ICoverable aTileEntity) { + public final void preDataChanged(ForgeDirection side, int aCoverID, int aNewCoverId, + ISerializableObject aCoverVariable, ISerializableObject aNewCoverVariable, ICoverable aTileEntity) { preDataChangedImpl( - aSide, + side, aCoverID, aNewCoverId, forceCast(aCoverVariable), @@ -170,21 +171,22 @@ public final void preDataChanged(byte aSide, int aCoverID, int aNewCoverId, ISer /** * Called upon cover being removed. Called on both server and client. */ - public final void onDropped(byte aSide, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) { - onDroppedImpl(aSide, aCoverID, forceCast(aCoverVariable), aTileEntity); + public final void onDropped(ForgeDirection side, int aCoverID, ISerializableObject aCoverVariable, + ICoverable aTileEntity) { + onDroppedImpl(side, aCoverID, forceCast(aCoverVariable), aTileEntity); } - public final boolean isRedstoneSensitive(byte aSide, int aCoverID, ISerializableObject aCoverVariable, + public final boolean isRedstoneSensitive(ForgeDirection side, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity, long aTimer) { - return isRedstoneSensitiveImpl(aSide, aCoverID, forceCast(aCoverVariable), aTileEntity, aTimer); + return isRedstoneSensitiveImpl(side, aCoverID, forceCast(aCoverVariable), aTileEntity, aTimer); } /** * Called by updateEntity inside the covered TileEntity. aCoverVariable is the Value you returned last time. */ - public final T doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, ISerializableObject aCoverVariable, - ICoverable aTileEntity, long aTimer) { - return doCoverThingsImpl(aSide, aInputRedstone, aCoverID, forceCast(aCoverVariable), aTileEntity, aTimer); + public final T doCoverThings(ForgeDirection side, byte aInputRedstone, int aCoverID, + ISerializableObject aCoverVariable, ICoverable aTileEntity, long aTimer) { + return doCoverThingsImpl(side, aInputRedstone, aCoverID, forceCast(aCoverVariable), aTileEntity, aTimer); } /** @@ -192,9 +194,9 @@ public final T doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, ISer *

* return true, if something actually happens. */ - public final boolean onCoverRightClick(byte aSide, int aCoverID, ISerializableObject aCoverVariable, + public final boolean onCoverRightClick(ForgeDirection side, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) { - return onCoverRightClickImpl(aSide, aCoverID, forceCast(aCoverVariable), aTileEntity, aPlayer, aX, aY, aZ); + return onCoverRightClickImpl(side, aCoverID, forceCast(aCoverVariable), aTileEntity, aPlayer, aX, aY, aZ); } /** @@ -202,65 +204,57 @@ public final boolean onCoverRightClick(byte aSide, int aCoverID, ISerializableOb *

* return the new Value of the Cover Variable */ - public final T onCoverScrewdriverClick(byte aSide, int aCoverID, ISerializableObject aCoverVariable, + public final T onCoverScrewdriverClick(ForgeDirection side, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) { - return onCoverScrewdriverClickImpl( - aSide, - aCoverID, - forceCast(aCoverVariable), - aTileEntity, - aPlayer, - aX, - aY, - aZ); + return onCoverScrewdriverClickImpl(side, aCoverID, forceCast(aCoverVariable), aTileEntity, aPlayer, aX, aY, aZ); } /** * Called when someone shift-rightclicks this Cover with no tool. Doesn't call @onCoverRightclick in this Case. */ - public final boolean onCoverShiftRightClick(byte aSide, int aCoverID, ISerializableObject aCoverVariable, + public final boolean onCoverShiftRightClick(ForgeDirection side, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer) { - return onCoverShiftRightClickImpl(aSide, aCoverID, forceCast(aCoverVariable), aTileEntity, aPlayer); + return onCoverShiftRightClickImpl(side, aCoverID, forceCast(aCoverVariable), aTileEntity, aPlayer); } @Deprecated - public final Object getClientGUI(byte aSide, int aCoverID, ISerializableObject aCoverVariable, + public final Object getClientGUI(ForgeDirection side, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, World aWorld) { - return getClientGUIImpl(aSide, aCoverID, forceCast(aCoverVariable), aTileEntity, aPlayer, aWorld); + return getClientGUIImpl(side, aCoverID, forceCast(aCoverVariable), aTileEntity, aPlayer, aWorld); } /** * Removes the Cover if this returns true, or if aForced is true. Doesn't get called when the Machine Block is * getting broken, only if you break the Cover away from the Machine. */ - public final boolean onCoverRemoval(byte aSide, int aCoverID, ISerializableObject aCoverVariable, + public final boolean onCoverRemoval(ForgeDirection side, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity, boolean aForced) { - return onCoverRemovalImpl(aSide, aCoverID, forceCast(aCoverVariable), aTileEntity, aForced); + return onCoverRemovalImpl(side, aCoverID, forceCast(aCoverVariable), aTileEntity, aForced); } /** * Called upon Base TE being destroyed (once getDrops is called), thus getting called only when destroyed in * survival. */ - public final void onBaseTEDestroyed(byte aSide, int aCoverID, ISerializableObject aCoverVariable, + public final void onBaseTEDestroyed(ForgeDirection side, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) { - onBaseTEDestroyedImpl(aSide, aCoverID, forceCast(aCoverVariable), aTileEntity); + onBaseTEDestroyedImpl(side, aCoverID, forceCast(aCoverVariable), aTileEntity); } /** * Gives a small Text for the status of the Cover. */ - public final String getDescription(byte aSide, int aCoverID, ISerializableObject aCoverVariable, + public final String getDescription(ForgeDirection side, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) { - return getDescriptionImpl(aSide, aCoverID, forceCast(aCoverVariable), aTileEntity); + return getDescriptionImpl(side, aCoverID, forceCast(aCoverVariable), aTileEntity); } /** * How Blast Proof the Cover is. 30 is normal. */ - public final float getBlastProofLevel(byte aSide, int aCoverID, ISerializableObject aCoverVariable, + public final float getBlastProofLevel(ForgeDirection side, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) { - return getBlastProofLevelImpl(aSide, aCoverID, forceCast(aCoverVariable), aTileEntity); + return getBlastProofLevelImpl(side, aCoverID, forceCast(aCoverVariable), aTileEntity); } /** @@ -268,67 +262,49 @@ public final float getBlastProofLevel(byte aSide, int aCoverID, ISerializableObj *

* This is just Informative so that Machines know if their Redstone Input is blocked or not */ - public final boolean letsRedstoneGoIn(byte aSide, int aCoverID, ISerializableObject aCoverVariable, + public final boolean letsRedstoneGoIn(ForgeDirection side, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) { - return letsRedstoneGoInImpl(aSide, aCoverID, forceCast(aCoverVariable), aTileEntity); + return letsRedstoneGoInImpl(side, aCoverID, forceCast(aCoverVariable), aTileEntity); } /** * If it lets RS-Signals out of the Block */ - public final boolean letsRedstoneGoOut(byte aSide, int aCoverID, ISerializableObject aCoverVariable, - ICoverable aTileEntity) { - return letsRedstoneGoOutImpl(aSide, aCoverID, forceCast(aCoverVariable), aTileEntity); - } - - /** - * If it lets Fibre-Signals into the Block - *

- * This is just Informative so that Machines know if their Redstone Input is blocked or not - */ - public final boolean letsFibreGoIn(byte aSide, int aCoverID, ISerializableObject aCoverVariable, - ICoverable aTileEntity) { - return letsFibreGoInImpl(aSide, aCoverID, forceCast(aCoverVariable), aTileEntity); - } - - /** - * If it lets Fibre-Signals out of the Block - */ - public final boolean letsFibreGoOut(byte aSide, int aCoverID, ISerializableObject aCoverVariable, + public final boolean letsRedstoneGoOut(ForgeDirection side, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) { - return letsFibreGoOutImpl(aSide, aCoverID, forceCast(aCoverVariable), aTileEntity); + return letsRedstoneGoOutImpl(side, aCoverID, forceCast(aCoverVariable), aTileEntity); } /** * If it lets Energy into the Block */ - public final boolean letsEnergyIn(byte aSide, int aCoverID, ISerializableObject aCoverVariable, + public final boolean letsEnergyIn(ForgeDirection side, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) { - return letsEnergyInImpl(aSide, aCoverID, forceCast(aCoverVariable), aTileEntity); + return letsEnergyInImpl(side, aCoverID, forceCast(aCoverVariable), aTileEntity); } /** * If it lets Energy out of the Block */ - public final boolean letsEnergyOut(byte aSide, int aCoverID, ISerializableObject aCoverVariable, + public final boolean letsEnergyOut(ForgeDirection side, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) { - return letsEnergyOutImpl(aSide, aCoverID, forceCast(aCoverVariable), aTileEntity); + return letsEnergyOutImpl(side, aCoverID, forceCast(aCoverVariable), aTileEntity); } /** * If it lets Liquids into the Block, aFluid can be null meaning if this is generally allowing Fluids or not. */ - public final boolean letsFluidIn(byte aSide, int aCoverID, ISerializableObject aCoverVariable, Fluid aFluid, - ICoverable aTileEntity) { - return letsFluidInImpl(aSide, aCoverID, forceCast(aCoverVariable), aFluid, aTileEntity); + public final boolean letsFluidIn(ForgeDirection side, int aCoverID, ISerializableObject aCoverVariable, + Fluid aFluid, ICoverable aTileEntity) { + return letsFluidInImpl(side, aCoverID, forceCast(aCoverVariable), aFluid, aTileEntity); } /** * If it lets Liquids out of the Block, aFluid can be null meaning if this is generally allowing Fluids or not. */ - public final boolean letsFluidOut(byte aSide, int aCoverID, ISerializableObject aCoverVariable, Fluid aFluid, - ICoverable aTileEntity) { - return letsFluidOutImpl(aSide, aCoverID, forceCast(aCoverVariable), aFluid, aTileEntity); + public final boolean letsFluidOut(ForgeDirection side, int aCoverID, ISerializableObject aCoverVariable, + Fluid aFluid, ICoverable aTileEntity) { + return letsFluidOutImpl(side, aCoverID, forceCast(aCoverVariable), aFluid, aTileEntity); } /** @@ -336,9 +312,9 @@ public final boolean letsFluidOut(byte aSide, int aCoverID, ISerializableObject * reaction at all), aSlot = -2 means if it would accept for all Slots Impl(return true to skip the Checks for each * Slot). */ - public final boolean letsItemsIn(byte aSide, int aCoverID, ISerializableObject aCoverVariable, int aSlot, + public final boolean letsItemsIn(ForgeDirection side, int aCoverID, ISerializableObject aCoverVariable, int aSlot, ICoverable aTileEntity) { - return letsItemsInImpl(aSide, aCoverID, forceCast(aCoverVariable), aSlot, aTileEntity); + return letsItemsInImpl(side, aCoverID, forceCast(aCoverVariable), aSlot, aTileEntity); } /** @@ -346,42 +322,42 @@ public final boolean letsItemsIn(byte aSide, int aCoverID, ISerializableObject a * reaction at all), aSlot = -2 means if it would accept for all Slots Impl(return true to skip the Checks for each * Slot). */ - public final boolean letsItemsOut(byte aSide, int aCoverID, ISerializableObject aCoverVariable, int aSlot, + public final boolean letsItemsOut(ForgeDirection side, int aCoverID, ISerializableObject aCoverVariable, int aSlot, ICoverable aTileEntity) { - return letsItemsOutImpl(aSide, aCoverID, forceCast(aCoverVariable), aSlot, aTileEntity); + return letsItemsOutImpl(side, aCoverID, forceCast(aCoverVariable), aSlot, aTileEntity); } /** * If it lets you rightclick the Machine normally */ - public final boolean isGUIClickable(byte aSide, int aCoverID, ISerializableObject aCoverVariable, + public final boolean isGUIClickable(ForgeDirection side, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) { - return isGUIClickableImpl(aSide, aCoverID, forceCast(aCoverVariable), aTileEntity); + return isGUIClickableImpl(side, aCoverID, forceCast(aCoverVariable), aTileEntity); } /** * Needs to return true for Covers, which have a Redstone Output on their Facing. */ - public final boolean manipulatesSidedRedstoneOutput(byte aSide, int aCoverID, ISerializableObject aCoverVariable, - ICoverable aTileEntity) { - return manipulatesSidedRedstoneOutputImpl(aSide, aCoverID, forceCast(aCoverVariable), aTileEntity); + public final boolean manipulatesSidedRedstoneOutput(ForgeDirection side, int aCoverID, + ISerializableObject aCoverVariable, ICoverable aTileEntity) { + return manipulatesSidedRedstoneOutputImpl(side, aCoverID, forceCast(aCoverVariable), aTileEntity); } /** * if this Cover should let Pipe Connections look connected even if it is not the case. */ - public final boolean alwaysLookConnected(byte aSide, int aCoverID, ISerializableObject aCoverVariable, + public final boolean alwaysLookConnected(ForgeDirection side, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) { - return alwaysLookConnectedImpl(aSide, aCoverID, forceCast(aCoverVariable), aTileEntity); + return alwaysLookConnectedImpl(side, aCoverID, forceCast(aCoverVariable), aTileEntity); } /** * Called to determine the incoming Redstone Signal of a Machine. Returns the original Redstone per default. The * Cover should @letsRedstoneGoIn or the aInputRedstone Parameter is always 0. */ - public final byte getRedstoneInput(byte aSide, byte aInputRedstone, int aCoverID, + public final byte getRedstoneInput(ForgeDirection side, byte aInputRedstone, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) { - return getRedstoneInputImpl(aSide, aInputRedstone, aCoverID, forceCast(aCoverVariable), aTileEntity); + return getRedstoneInputImpl(side, aInputRedstone, aCoverID, forceCast(aCoverVariable), aTileEntity); } /** @@ -389,24 +365,25 @@ public final byte getRedstoneInput(byte aSide, byte aInputRedstone, int aCoverID *

* 0 = No Ticks! Yes, 0 is Default, you have to override this */ - public final int getTickRate(byte aSide, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) { - return getTickRateImpl(aSide, aCoverID, forceCast(aCoverVariable), aTileEntity); + public final int getTickRate(ForgeDirection side, int aCoverID, ISerializableObject aCoverVariable, + ICoverable aTileEntity) { + return getTickRateImpl(side, aCoverID, forceCast(aCoverVariable), aTileEntity); } /** * The MC Color of this Lens. -1 for no Color (meaning this isn't a Lens then). */ - public final byte getLensColor(byte aSide, int aCoverID, ISerializableObject aCoverVariable, + public final byte getLensColor(ForgeDirection side, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) { - return getLensColorImpl(aSide, aCoverID, forceCast(aCoverVariable), aTileEntity); + return getLensColorImpl(side, aCoverID, forceCast(aCoverVariable), aTileEntity); } /** * @return the ItemStack dropped by this Cover */ - public final ItemStack getDrop(byte aSide, int aCoverID, ISerializableObject aCoverVariable, + public final ItemStack getDrop(ForgeDirection side, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) { - return getDropImpl(aSide, aCoverID, forceCast(aCoverVariable), aTileEntity); + return getDropImpl(side, aCoverID, forceCast(aCoverVariable), aTileEntity); } // endregion @@ -540,11 +517,11 @@ protected int getTextColorOrDefault(String textType, int defaultColor) { // region impl - protected Block getFacadeBlockImpl(byte aSide, int aCoverID, T aCoverVariable, ICoverable aTileEntity) { + protected Block getFacadeBlockImpl(ForgeDirection side, int aCoverID, T aCoverVariable, ICoverable aTileEntity) { return null; } - protected int getFacadeMetaImpl(byte aSide, int aCoverID, T aCoverVariable, ICoverable aTileEntity) { + protected int getFacadeMetaImpl(ForgeDirection side, int aCoverID, T aCoverVariable, ICoverable aTileEntity) { return 0; } @@ -552,37 +529,39 @@ protected ItemStack getDisplayStackImpl(int aCoverID, T aCoverVariable) { return GT_Utility.intToStack(aCoverID); } - protected ITexture getSpecialCoverFGTextureImpl(byte aSide, int aCoverID, T aCoverVariable, + protected ITexture getSpecialCoverFGTextureImpl(ForgeDirection side, int aCoverID, T aCoverVariable, ICoverable aTileEntity) { return coverFGTexture; } - protected ITexture getSpecialCoverTextureImpl(byte aSide, int aCoverID, T aCoverVariable, ICoverable aTileEntity) { + protected ITexture getSpecialCoverTextureImpl(ForgeDirection side, int aCoverID, T aCoverVariable, + ICoverable aTileEntity) { return null; } - protected boolean isDataNeededOnClientImpl(byte aSide, int aCoverID, T aCoverVariable, ICoverable aTileEntity) { + protected boolean isDataNeededOnClientImpl(ForgeDirection side, int aCoverID, T aCoverVariable, + ICoverable aTileEntity) { return false; } - protected void onDataChangedImpl(byte aSide, int aCoverID, T aCoverVariable, ICoverable aTileEntity) {} + protected void onDataChangedImpl(ForgeDirection side, int aCoverID, T aCoverVariable, ICoverable aTileEntity) {} - protected void preDataChangedImpl(byte aSide, int aCoverID, int aNewCoverId, T aCoverVariable, T aNewCoverVariable, - ICoverable aTileEntity) {} + protected void preDataChangedImpl(ForgeDirection side, int aCoverID, int aNewCoverId, T aCoverVariable, + T aNewCoverVariable, ICoverable aTileEntity) {} - protected void onDroppedImpl(byte aSide, int aCoverID, T aCoverVariable, ICoverable aTileEntity) {} + protected void onDroppedImpl(ForgeDirection side, int aCoverID, T aCoverVariable, ICoverable aTileEntity) {} - protected void onBaseTEDestroyedImpl(byte aSide, int aCoverID, T aCoverVariable, ICoverable aTileEntity) {} + protected void onBaseTEDestroyedImpl(ForgeDirection side, int aCoverID, T aCoverVariable, ICoverable aTileEntity) {} - protected boolean isRedstoneSensitiveImpl(byte aSide, int aCoverID, T aCoverVariable, ICoverable aTileEntity, - long aTimer) { + protected boolean isRedstoneSensitiveImpl(ForgeDirection side, int aCoverID, T aCoverVariable, + ICoverable aTileEntity, long aTimer) { return false; } /** * Called by updateEntity inside the covered TileEntity. aCoverVariable is the Value you returned last time. */ - protected T doCoverThingsImpl(byte aSide, byte aInputRedstone, int aCoverID, T aCoverVariable, + protected T doCoverThingsImpl(ForgeDirection side, byte aInputRedstone, int aCoverID, T aCoverVariable, ICoverable aTileEntity, long aTimer) { return aCoverVariable; } @@ -592,7 +571,7 @@ protected T doCoverThingsImpl(byte aSide, byte aInputRedstone, int aCoverID, T a *

* return true, if something actually happens. */ - protected boolean onCoverRightClickImpl(byte aSide, int aCoverID, T aCoverVariable, ICoverable aTileEntity, + protected boolean onCoverRightClickImpl(ForgeDirection side, int aCoverID, T aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) { return false; } @@ -602,7 +581,7 @@ protected boolean onCoverRightClickImpl(byte aSide, int aCoverID, T aCoverVariab *

* return the new Value of the Cover Variable */ - protected T onCoverScrewdriverClickImpl(byte aSide, int aCoverID, T aCoverVariable, ICoverable aTileEntity, + protected T onCoverScrewdriverClickImpl(ForgeDirection side, int aCoverID, T aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) { return aCoverVariable; } @@ -610,16 +589,16 @@ protected T onCoverScrewdriverClickImpl(byte aSide, int aCoverID, T aCoverVariab /** * Called when someone shift-rightclicks this Cover with no tool. Doesn't call @onCoverRightclick in this Case. */ - protected boolean onCoverShiftRightClickImpl(byte aSide, int aCoverID, T aCoverVariable, ICoverable aTileEntity, - EntityPlayer aPlayer) { + protected boolean onCoverShiftRightClickImpl(ForgeDirection side, int aCoverID, T aCoverVariable, + ICoverable aTileEntity, EntityPlayer aPlayer) { if (hasCoverGUI() && aPlayer instanceof EntityPlayerMP) { lastPlayer = aPlayer; if (useModularUI()) { - GT_UIInfos.openCoverUI(aTileEntity, aPlayer, aSide); + GT_UIInfos.openCoverUI(aTileEntity, aPlayer, side); } else { GT_Values.NW.sendToPlayer( new GT_Packet_TileEntityCoverGUI( - aSide, + side, aCoverID, aCoverVariable, aTileEntity, @@ -632,7 +611,7 @@ protected boolean onCoverShiftRightClickImpl(byte aSide, int aCoverID, T aCoverV } @Deprecated - protected Object getClientGUIImpl(byte aSide, int aCoverID, T aCoverVariable, ICoverable aTileEntity, + protected Object getClientGUIImpl(ForgeDirection side, int aCoverID, T aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, World aWorld) { return null; } @@ -641,7 +620,7 @@ protected Object getClientGUIImpl(byte aSide, int aCoverID, T aCoverVariable, IC * Removes the Cover if this returns true, or if aForced is true. Doesn't get called when the Machine Block is * getting broken, only if you break the Cover away from the Machine. */ - protected boolean onCoverRemovalImpl(byte aSide, int aCoverID, T aCoverVariable, ICoverable aTileEntity, + protected boolean onCoverRemovalImpl(ForgeDirection side, int aCoverID, T aCoverVariable, ICoverable aTileEntity, boolean aForced) { return true; } @@ -649,14 +628,15 @@ protected boolean onCoverRemovalImpl(byte aSide, int aCoverID, T aCoverVariable, /** * Gives a small Text for the status of the Cover. */ - protected String getDescriptionImpl(byte aSide, int aCoverID, T aCoverVariable, ICoverable aTileEntity) { + protected String getDescriptionImpl(ForgeDirection side, int aCoverID, T aCoverVariable, ICoverable aTileEntity) { return E; } /** * How Blast Proof the Cover is. 30 is normal. */ - protected float getBlastProofLevelImpl(byte aSide, int aCoverID, T aCoverVariable, ICoverable aTileEntity) { + protected float getBlastProofLevelImpl(ForgeDirection side, int aCoverID, T aCoverVariable, + ICoverable aTileEntity) { return 10.0F; } @@ -665,51 +645,37 @@ protected float getBlastProofLevelImpl(byte aSide, int aCoverID, T aCoverVariabl *

* This is just Informative so that Machines know if their Redstone Input is blocked or not */ - protected boolean letsRedstoneGoInImpl(byte aSide, int aCoverID, T aCoverVariable, ICoverable aTileEntity) { + protected boolean letsRedstoneGoInImpl(ForgeDirection side, int aCoverID, T aCoverVariable, + ICoverable aTileEntity) { return false; } /** * If it lets RS-Signals out of the Block */ - protected boolean letsRedstoneGoOutImpl(byte aSide, int aCoverID, T aCoverVariable, ICoverable aTileEntity) { - return false; - } - - /** - * If it lets Fibre-Signals into the Block - *

- * This is just Informative so that Machines know if their Redstone Input is blocked or not - */ - protected boolean letsFibreGoInImpl(byte aSide, int aCoverID, T aCoverVariable, ICoverable aTileEntity) { - return false; - } - - /** - * If it lets Fibre-Signals out of the Block - */ - protected boolean letsFibreGoOutImpl(byte aSide, int aCoverID, T aCoverVariable, ICoverable aTileEntity) { + protected boolean letsRedstoneGoOutImpl(ForgeDirection side, int aCoverID, T aCoverVariable, + ICoverable aTileEntity) { return false; } /** * If it lets Energy into the Block */ - protected boolean letsEnergyInImpl(byte aSide, int aCoverID, T aCoverVariable, ICoverable aTileEntity) { + protected boolean letsEnergyInImpl(ForgeDirection side, int aCoverID, T aCoverVariable, ICoverable aTileEntity) { return false; } /** * If it lets Energy out of the Block */ - protected boolean letsEnergyOutImpl(byte aSide, int aCoverID, T aCoverVariable, ICoverable aTileEntity) { + protected boolean letsEnergyOutImpl(ForgeDirection side, int aCoverID, T aCoverVariable, ICoverable aTileEntity) { return false; } /** * If it lets Liquids into the Block, aFluid can be null meaning if this is generally allowing Fluids or not. */ - protected boolean letsFluidInImpl(byte aSide, int aCoverID, T aCoverVariable, Fluid aFluid, + protected boolean letsFluidInImpl(ForgeDirection side, int aCoverID, T aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { return false; } @@ -717,7 +683,7 @@ protected boolean letsFluidInImpl(byte aSide, int aCoverID, T aCoverVariable, Fl /** * If it lets Liquids out of the Block, aFluid can be null meaning if this is generally allowing Fluids or not. */ - protected boolean letsFluidOutImpl(byte aSide, int aCoverID, T aCoverVariable, Fluid aFluid, + protected boolean letsFluidOutImpl(ForgeDirection side, int aCoverID, T aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { return false; } @@ -727,7 +693,8 @@ protected boolean letsFluidOutImpl(byte aSide, int aCoverID, T aCoverVariable, F * Interaction at all), aSlot = -2 means if it would accept for all Slots (return true to skip the Checks for each * Slot). */ - protected boolean letsItemsInImpl(byte aSide, int aCoverID, T aCoverVariable, int aSlot, ICoverable aTileEntity) { + protected boolean letsItemsInImpl(ForgeDirection side, int aCoverID, T aCoverVariable, int aSlot, + ICoverable aTileEntity) { return false; } @@ -736,21 +703,22 @@ protected boolean letsItemsInImpl(byte aSide, int aCoverID, T aCoverVariable, in * Interaction at all), aSlot = -2 means if it would accept for all Slots (return true to skip the Checks for each * Slot). */ - protected boolean letsItemsOutImpl(byte aSide, int aCoverID, T aCoverVariable, int aSlot, ICoverable aTileEntity) { + protected boolean letsItemsOutImpl(ForgeDirection side, int aCoverID, T aCoverVariable, int aSlot, + ICoverable aTileEntity) { return false; } /** * If it lets you rightclick the Machine normally */ - protected boolean isGUIClickableImpl(byte aSide, int aCoverID, T aCoverVariable, ICoverable aTileEntity) { + protected boolean isGUIClickableImpl(ForgeDirection side, int aCoverID, T aCoverVariable, ICoverable aTileEntity) { return false; } /** * Needs to return true for Covers, which have a Redstone Output on their Facing. */ - protected boolean manipulatesSidedRedstoneOutputImpl(byte aSide, int aCoverID, T aCoverVariable, + protected boolean manipulatesSidedRedstoneOutputImpl(ForgeDirection side, int aCoverID, T aCoverVariable, ICoverable aTileEntity) { return false; } @@ -758,7 +726,8 @@ protected boolean manipulatesSidedRedstoneOutputImpl(byte aSide, int aCoverID, T /** * if this Cover should let Pipe Connections look connected even if it is not the case. */ - protected boolean alwaysLookConnectedImpl(byte aSide, int aCoverID, T aCoverVariable, ICoverable aTileEntity) { + protected boolean alwaysLookConnectedImpl(ForgeDirection side, int aCoverID, T aCoverVariable, + ICoverable aTileEntity) { return false; } @@ -766,9 +735,9 @@ protected boolean alwaysLookConnectedImpl(byte aSide, int aCoverID, T aCoverVari * Called to determine the incoming Redstone Signal of a Machine. Returns the original Redstone per default. The * Cover should @letsRedstoneGoIn or the aInputRedstone Parameter is always 0. */ - protected byte getRedstoneInputImpl(byte aSide, byte aInputRedstone, int aCoverID, T aCoverVariable, + protected byte getRedstoneInputImpl(ForgeDirection side, byte aInputRedstone, int aCoverID, T aCoverVariable, ICoverable aTileEntity) { - return letsRedstoneGoIn(aSide, aCoverID, aCoverVariable, aTileEntity) ? aInputRedstone : 0; + return letsRedstoneGoIn(side, aCoverID, aCoverVariable, aTileEntity) ? aInputRedstone : 0; } /** @@ -776,22 +745,22 @@ protected byte getRedstoneInputImpl(byte aSide, byte aInputRedstone, int aCoverI *

* 0 = No Ticks! Yes, 0 is Default, you have to override this */ - protected int getTickRateImpl(byte aSide, int aCoverID, T aCoverVariable, ICoverable aTileEntity) { + protected int getTickRateImpl(ForgeDirection side, int aCoverID, T aCoverVariable, ICoverable aTileEntity) { return 0; } /** * The MC Color of this Lens. -1 for no Color (meaning this isn't a Lens then). */ - protected byte getLensColorImpl(byte aSide, int aCoverID, T aCoverVariable, ICoverable aTileEntity) { + protected byte getLensColorImpl(ForgeDirection side, int aCoverID, T aCoverVariable, ICoverable aTileEntity) { return -1; } /** * @return the ItemStack dropped by this Cover */ - protected ItemStack getDropImpl(byte aSide, int aCoverID, T aCoverVariable, ICoverable aTileEntity) { - return GT_OreDictUnificator.get(true, aTileEntity.getCoverItemAtSide(aSide)); + protected ItemStack getDropImpl(ForgeDirection side, int aCoverID, T aCoverVariable, ICoverable aTileEntity) { + return GT_OreDictUnificator.get(true, aTileEntity.getCoverItemAtSide(side)); } // endregion @@ -801,16 +770,16 @@ protected ItemStack getDropImpl(byte aSide, int aCoverID, T aCoverVariable, ICov /** * Checks if the Cover can be placed on this. */ - public boolean isCoverPlaceable(byte aSide, ItemStack aStack, ICoverable aTileEntity) { - return isCoverPlaceable(aSide, new GT_ItemStack(aStack), aTileEntity); + public boolean isCoverPlaceable(ForgeDirection side, ItemStack aStack, ICoverable aTileEntity) { + return isCoverPlaceable(side, new GT_ItemStack(aStack), aTileEntity); } /** * Checks if the Cover can be placed on this. You will probably want to call - * {@link #isCoverPlaceable(byte, ItemStack, ICoverable)} instead. + * {@link #isCoverPlaceable(ForgeDirection, ItemStack, ICoverable)} instead. */ @Deprecated - public boolean isCoverPlaceable(byte aSide, GT_ItemStack aStack, ICoverable aTileEntity) { + public boolean isCoverPlaceable(ForgeDirection side, GT_ItemStack aStack, ICoverable aTileEntity) { return true; } @@ -823,8 +792,8 @@ public boolean hasCoverGUI() { *

* return true, if something actually happens. */ - public boolean onCoverRightclickClient(byte aSide, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, - float aZ) { + public boolean onCoverRightclickClient(ForgeDirection side, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, + float aY, float aZ) { return false; } @@ -838,8 +807,8 @@ public boolean isSimpleCover() { /** * sets the Cover upon placement. */ - public void placeCover(byte aSide, ItemStack aCover, ICoverable aTileEntity) { - aTileEntity.setCoverIDAtSide(aSide, GT_Utility.stackToInt(aCover)); + public void placeCover(ForgeDirection side, ItemStack aCover, ICoverable aTileEntity) { + aTileEntity.setCoverIDAtSide(side, GT_Utility.stackToInt(aCover)); } @Deprecated diff --git a/src/main/java/gregtech/api/util/GT_HatchElementBuilder.java b/src/main/java/gregtech/api/util/GT_HatchElementBuilder.java index ba9e3b97730..8565dc21f53 100644 --- a/src/main/java/gregtech/api/util/GT_HatchElementBuilder.java +++ b/src/main/java/gregtech/api/util/GT_HatchElementBuilder.java @@ -495,7 +495,7 @@ public PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, Ite if (facing.offsetY == 0) break; } assert result != null; - ((IGregTechTileEntity) tileEntity).setFrontFacing((byte) result.ordinal()); + ((IGregTechTileEntity) tileEntity).setFrontFacing(result); } } return mNoStop ? PlaceResult.ACCEPT : PlaceResult.ACCEPT_STOP; diff --git a/src/main/java/gregtech/api/util/GT_Utility.java b/src/main/java/gregtech/api/util/GT_Utility.java index 91d5a90fe6f..7420dc14f9f 100644 --- a/src/main/java/gregtech/api/util/GT_Utility.java +++ b/src/main/java/gregtech/api/util/GT_Utility.java @@ -11,6 +11,13 @@ import static gregtech.api.enums.GT_Values.W; import static gregtech.api.enums.Materials.FLUID_MAP; import static gregtech.common.GT_UndergroundOil.undergroundOilReadInformation; +import static net.minecraftforge.common.util.ForgeDirection.DOWN; +import static net.minecraftforge.common.util.ForgeDirection.EAST; +import static net.minecraftforge.common.util.ForgeDirection.NORTH; +import static net.minecraftforge.common.util.ForgeDirection.SOUTH; +import static net.minecraftforge.common.util.ForgeDirection.UNKNOWN; +import static net.minecraftforge.common.util.ForgeDirection.UP; +import static net.minecraftforge.common.util.ForgeDirection.WEST; import java.lang.reflect.Constructor; import java.lang.reflect.Field; @@ -448,9 +455,8 @@ public static ItemStack suckOneItemStackAt(World aWorld, double aX, double aY, d return null; } - public static byte getOppositeSide(int aSide) { - return (byte) ForgeDirection.getOrientation(aSide) - .getOpposite() + public static byte getOppositeSide(ForgeDirection side) { + return (byte) side.getOpposite() .ordinal(); } @@ -501,14 +507,13 @@ public static void checkAvailabilities() { } } - public static boolean isConnectableNonInventoryPipe(Object aTileEntity, int aSide) { - if (aTileEntity == null) return false; + public static boolean isConnectableNonInventoryPipe(TileEntity tileEntity, ForgeDirection side) { + if (tileEntity == null) return false; checkAvailabilities(); - if (TE_CHECK && aTileEntity instanceof IItemDuct) return true; - if (BC_CHECK && aTileEntity instanceof buildcraft.api.transport.IPipeTile) - return ((buildcraft.api.transport.IPipeTile) aTileEntity) - .isPipeConnected(ForgeDirection.getOrientation(aSide)); - return GregTech_API.mTranslocator && aTileEntity instanceof codechicken.translocator.TileItemTranslocator; + if (TE_CHECK && tileEntity instanceof IItemDuct) return true; + if (BC_CHECK && tileEntity instanceof buildcraft.api.transport.IPipeTile pipeTile) + return pipeTile.isPipeConnected(side); + return GregTech_API.mTranslocator && tileEntity instanceof codechicken.translocator.TileItemTranslocator; } /** @@ -516,15 +521,15 @@ public static boolean isConnectableNonInventoryPipe(Object aTileEntity, int aSid * * @return the Amount of moved Items */ - public static byte moveStackIntoPipe(IInventory aTileEntity1, Object aTileEntity2, int[] aGrabSlots, int aGrabFrom, - int aPutTo, List aFilter, boolean aInvertFilter, byte aMaxTargetStackSize, byte aMinTargetStackSize, - byte aMaxMoveAtOnce, byte aMinMoveAtOnce) { + public static byte moveStackIntoPipe(IInventory aTileEntity1, Object aTileEntity2, int[] aGrabSlots, + ForgeDirection fromSide, ForgeDirection putSide, List aFilter, boolean aInvertFilter, + byte aMaxTargetStackSize, byte aMinTargetStackSize, byte aMaxMoveAtOnce, byte aMinMoveAtOnce) { return moveStackIntoPipe( aTileEntity1, aTileEntity2, aGrabSlots, - aGrabFrom, - aPutTo, + fromSide, + putSide, aFilter, aInvertFilter, aMaxTargetStackSize, @@ -535,44 +540,44 @@ public static byte moveStackIntoPipe(IInventory aTileEntity1, Object aTileEntity } /** - * Moves Stack from Inv-Slot to Inv-Slot, without checking if its even allowed. + * Moves Stack from Inv-Slot to Inv-Slot, without checking if it is even allowed. * * @return the Amount of moved Items */ - public static byte moveStackIntoPipe(IInventory aTileEntity1, Object aTileEntity2, int[] aGrabSlots, int aGrabFrom, - int aPutTo, List aFilter, boolean aInvertFilter, byte aMaxTargetStackSize, byte aMinTargetStackSize, - byte aMaxMoveAtOnce, byte aMinMoveAtOnce, boolean dropItem) { - if (aTileEntity1 == null || aMaxTargetStackSize <= 0 + public static byte moveStackIntoPipe(IInventory fromInventory, Object toObject, int[] fromSlots, + ForgeDirection fromSide, ForgeDirection putSide, List aFilter, boolean aInvertFilter, + byte aMaxTargetStackSize, byte aMinTargetStackSize, byte aMaxMoveAtOnce, byte aMinMoveAtOnce, + boolean dropItem) { + if (fromInventory == null || aMaxTargetStackSize <= 0 || aMinTargetStackSize <= 0 || aMinTargetStackSize > aMaxTargetStackSize || aMaxMoveAtOnce <= 0 || aMinMoveAtOnce > aMaxMoveAtOnce) return 0; - if (aTileEntity2 != null) { + if (toObject != null) { checkAvailabilities(); - if (TE_CHECK && aTileEntity2 instanceof IItemDuct) { - for (int aGrabSlot : aGrabSlots) { - if (listContainsItem(aFilter, aTileEntity1.getStackInSlot(aGrabSlot), true, aInvertFilter)) { + if (TE_CHECK && toObject instanceof IItemDuct itemDuct) { + for (final int aGrabSlot : fromSlots) { + if (listContainsItem(aFilter, fromInventory.getStackInSlot(aGrabSlot), true, aInvertFilter)) { if (isAllowedToTakeFromSlot( - aTileEntity1, + fromInventory, aGrabSlot, - (byte) aGrabFrom, - aTileEntity1.getStackInSlot(aGrabSlot))) { + fromSide, + fromInventory.getStackInSlot(aGrabSlot))) { if (Math.max(aMinMoveAtOnce, aMinTargetStackSize) - <= aTileEntity1.getStackInSlot(aGrabSlot).stackSize) { + <= fromInventory.getStackInSlot(aGrabSlot).stackSize) { ItemStack tStack = copyAmount( Math.min( - aTileEntity1.getStackInSlot(aGrabSlot).stackSize, + fromInventory.getStackInSlot(aGrabSlot).stackSize, Math.min(aMaxMoveAtOnce, aMaxTargetStackSize)), - aTileEntity1.getStackInSlot(aGrabSlot)); - ItemStack rStack = ((IItemDuct) aTileEntity2) - .insertItem(ForgeDirection.getOrientation(aPutTo), copyOrNull(tStack)); + fromInventory.getStackInSlot(aGrabSlot)); + ItemStack rStack = itemDuct.insertItem(putSide, copyOrNull(tStack)); byte tMovedItemCount = (byte) (tStack.stackSize - (rStack == null ? 0 : rStack.stackSize)); if (tMovedItemCount >= 1 /* Math.max(aMinMoveAtOnce, aMinTargetStackSize) */) { // ((cofh.api.transport.IItemConduit)aTileEntity2).insertItem(ForgeDirection.getOrientation(aPutTo), // copyAmount(tMovedItemCount, tStack), F); - aTileEntity1.decrStackSize(aGrabSlot, tMovedItemCount); - aTileEntity1.markDirty(); + fromInventory.decrStackSize(aGrabSlot, tMovedItemCount); + fromInventory.markDirty(); return tMovedItemCount; } } @@ -581,31 +586,27 @@ public static byte moveStackIntoPipe(IInventory aTileEntity1, Object aTileEntity } return 0; } - if (BC_CHECK && aTileEntity2 instanceof buildcraft.api.transport.IPipeTile) { - for (int aGrabSlot : aGrabSlots) { - if (listContainsItem(aFilter, aTileEntity1.getStackInSlot(aGrabSlot), true, aInvertFilter)) { + if (BC_CHECK && toObject instanceof buildcraft.api.transport.IPipeTile bcPipe) { + for (int fromSlot : fromSlots) { + if (listContainsItem(aFilter, fromInventory.getStackInSlot(fromSlot), true, aInvertFilter)) { if (isAllowedToTakeFromSlot( - aTileEntity1, - aGrabSlot, - (byte) aGrabFrom, - aTileEntity1.getStackInSlot(aGrabSlot))) { + fromInventory, + fromSlot, + fromSide, + fromInventory.getStackInSlot(fromSlot))) { if (Math.max(aMinMoveAtOnce, aMinTargetStackSize) - <= aTileEntity1.getStackInSlot(aGrabSlot).stackSize) { + <= fromInventory.getStackInSlot(fromSlot).stackSize) { ItemStack tStack = copyAmount( Math.min( - aTileEntity1.getStackInSlot(aGrabSlot).stackSize, + fromInventory.getStackInSlot(fromSlot).stackSize, Math.min(aMaxMoveAtOnce, aMaxTargetStackSize)), - aTileEntity1.getStackInSlot(aGrabSlot)); - byte tMovedItemCount = (byte) ((buildcraft.api.transport.IPipeTile) aTileEntity2) - .injectItem(copyOrNull(tStack), false, ForgeDirection.getOrientation(aPutTo)); + fromInventory.getStackInSlot(fromSlot)); + byte tMovedItemCount = (byte) bcPipe.injectItem(copyOrNull(tStack), false, putSide); if (tMovedItemCount >= Math.max(aMinMoveAtOnce, aMinTargetStackSize)) { - tMovedItemCount = (byte) (((buildcraft.api.transport.IPipeTile) aTileEntity2) - .injectItem( - copyAmount(tMovedItemCount, tStack), - true, - ForgeDirection.getOrientation(aPutTo))); - aTileEntity1.decrStackSize(aGrabSlot, tMovedItemCount); - aTileEntity1.markDirty(); + tMovedItemCount = (byte) (bcPipe + .injectItem(copyAmount(tMovedItemCount, tStack), true, putSide)); + fromInventory.decrStackSize(fromSlot, tMovedItemCount); + fromInventory.markDirty(); return tMovedItemCount; } } @@ -616,38 +617,37 @@ public static byte moveStackIntoPipe(IInventory aTileEntity1, Object aTileEntity } } - ForgeDirection tDirection = ForgeDirection.getOrientation(aGrabFrom); - if (aTileEntity1 instanceof TileEntity && tDirection != ForgeDirection.UNKNOWN - && tDirection.getOpposite() == ForgeDirection.getOrientation(aPutTo)) { - int tX = ((TileEntity) aTileEntity1).xCoord + tDirection.offsetX, - tY = ((TileEntity) aTileEntity1).yCoord + tDirection.offsetY, - tZ = ((TileEntity) aTileEntity1).zCoord + tDirection.offsetZ; - if (!hasBlockHitBox(((TileEntity) aTileEntity1).getWorldObj(), tX, tY, tZ) && dropItem) { - for (int aGrabSlot : aGrabSlots) { - if (listContainsItem(aFilter, aTileEntity1.getStackInSlot(aGrabSlot), true, aInvertFilter)) { + if (fromInventory instanceof TileEntity fromTileEntity && fromSide != ForgeDirection.UNKNOWN + && fromSide.getOpposite() == ForgeDirection.getOrientation(putSide.ordinal())) { + int tX = fromTileEntity.xCoord + fromSide.offsetX, tY = fromTileEntity.yCoord + fromSide.offsetY, + tZ = fromTileEntity.zCoord + fromSide.offsetZ; + if (!hasBlockHitBox(((TileEntity) fromInventory).getWorldObj(), tX, tY, tZ) && dropItem) { + for (final int fromSlot : fromSlots) { + if (listContainsItem(aFilter, fromInventory.getStackInSlot(fromSlot), true, aInvertFilter)) { if (isAllowedToTakeFromSlot( - aTileEntity1, - aGrabSlot, - (byte) aGrabFrom, - aTileEntity1.getStackInSlot(aGrabSlot))) { + fromInventory, + fromSlot, + fromSide, + fromInventory.getStackInSlot(fromSlot))) { if (Math.max(aMinMoveAtOnce, aMinTargetStackSize) - <= aTileEntity1.getStackInSlot(aGrabSlot).stackSize) { - ItemStack tStack = copyAmount( + <= fromInventory.getStackInSlot(fromSlot).stackSize) { + final ItemStack tStack = copyAmount( Math.min( - aTileEntity1.getStackInSlot(aGrabSlot).stackSize, + fromInventory.getStackInSlot(fromSlot).stackSize, Math.min(aMaxMoveAtOnce, aMaxTargetStackSize)), - aTileEntity1.getStackInSlot(aGrabSlot)); - EntityItem tEntity = new EntityItem( - ((TileEntity) aTileEntity1).getWorldObj(), + fromInventory.getStackInSlot(fromSlot)); + final EntityItem tEntity = new EntityItem( + ((TileEntity) fromInventory).getWorldObj(), tX + 0.5, tY + 0.5, tZ + 0.5, tStack); tEntity.motionX = tEntity.motionY = tEntity.motionZ = 0; - ((TileEntity) aTileEntity1).getWorldObj() + ((TileEntity) fromInventory).getWorldObj() .spawnEntityInWorld(tEntity); - aTileEntity1.decrStackSize(aGrabSlot, tStack.stackSize); - aTileEntity1.markDirty(); + assert tStack != null; + fromInventory.decrStackSize(fromSlot, tStack.stackSize); + fromInventory.markDirty(); return (byte) tStack.stackSize; } } @@ -667,14 +667,13 @@ public static byte moveStackIntoPipe(IInventory aTileEntity1, Object aTileEntity public static byte moveStackFromSlotAToSlotB(IInventory aTileEntity1, IInventory aTileEntity2, int aGrabFrom, int aPutTo, byte aMaxTargetStackSize, byte aMinTargetStackSize, byte aMaxMoveAtOnce, byte aMinMoveAtOnce) { if (aTileEntity1 == null || aTileEntity2 == null - || aMaxTargetStackSize <= 0 || aMinTargetStackSize <= 0 || aMinTargetStackSize > aMaxTargetStackSize || aMaxMoveAtOnce <= 0 || aMinMoveAtOnce > aMaxMoveAtOnce) return 0; ItemStack tStack1 = aTileEntity1.getStackInSlot(aGrabFrom), tStack2 = aTileEntity2.getStackInSlot(aPutTo), - tStack3 = null; + tStack3; if (tStack1 != null) { if (tStack2 != null && !areStacksEqual(tStack1, tStack2)) return 0; tStack3 = copyOrNull(tStack1); @@ -706,35 +705,27 @@ public static byte moveStackFromSlotAToSlotB(IInventory aTileEntity1, IInventory return 0; } - public static boolean isAllowedToTakeFromSlot(IInventory aTileEntity, int aSlot, byte aSide, ItemStack aStack) { - if (ForgeDirection.getOrientation(aSide) == ForgeDirection.UNKNOWN) { - return isAllowedToTakeFromSlot(aTileEntity, aSlot, (byte) 0, aStack) - || isAllowedToTakeFromSlot(aTileEntity, aSlot, (byte) 1, aStack) - || isAllowedToTakeFromSlot(aTileEntity, aSlot, (byte) 2, aStack) - || isAllowedToTakeFromSlot(aTileEntity, aSlot, (byte) 3, aStack) - || isAllowedToTakeFromSlot(aTileEntity, aSlot, (byte) 4, aStack) - || isAllowedToTakeFromSlot(aTileEntity, aSlot, (byte) 5, aStack); + public static boolean isAllowedToTakeFromSlot(IInventory aTileEntity, int aSlot, ForgeDirection side, + ItemStack aStack) { + if (side == ForgeDirection.UNKNOWN) { + return Arrays.stream(ForgeDirection.VALID_DIRECTIONS) + .anyMatch(d -> isAllowedToTakeFromSlot(aTileEntity, aSlot, d, aStack)); } - if (aTileEntity instanceof ISidedInventory) - return ((ISidedInventory) aTileEntity).canExtractItem(aSlot, aStack, aSide); + if (aTileEntity instanceof ISidedInventory sided) return sided.canExtractItem(aSlot, aStack, side.ordinal()); return true; } - public static boolean isAllowedToPutIntoSlot(IInventory aTileEntity, int aSlot, byte aSide, ItemStack aStack, - byte aMaxStackSize) { + public static boolean isAllowedToPutIntoSlot(IInventory aTileEntity, int aSlot, ForgeDirection side, + ItemStack aStack, byte aMaxStackSize) { ItemStack tStack = aTileEntity.getStackInSlot(aSlot); if (tStack != null && (!areStacksEqual(tStack, aStack) || tStack.stackSize >= tStack.getMaxStackSize())) return false; - if (ForgeDirection.getOrientation(aSide) == ForgeDirection.UNKNOWN) { - return isAllowedToPutIntoSlot(aTileEntity, aSlot, (byte) 0, aStack, aMaxStackSize) - || isAllowedToPutIntoSlot(aTileEntity, aSlot, (byte) 1, aStack, aMaxStackSize) - || isAllowedToPutIntoSlot(aTileEntity, aSlot, (byte) 2, aStack, aMaxStackSize) - || isAllowedToPutIntoSlot(aTileEntity, aSlot, (byte) 3, aStack, aMaxStackSize) - || isAllowedToPutIntoSlot(aTileEntity, aSlot, (byte) 4, aStack, aMaxStackSize) - || isAllowedToPutIntoSlot(aTileEntity, aSlot, (byte) 5, aStack, aMaxStackSize); + if (side == ForgeDirection.UNKNOWN) { + return Arrays.stream(ForgeDirection.VALID_DIRECTIONS) + .anyMatch(d -> isAllowedToPutIntoSlot(aTileEntity, aSlot, d, aStack, aMaxStackSize)); } if (aTileEntity instanceof ISidedInventory - && !((ISidedInventory) aTileEntity).canInsertItem(aSlot, aStack, aSide)) return false; + && !((ISidedInventory) aTileEntity).canInsertItem(aSlot, aStack, side.ordinal())) return false; return aSlot < aTileEntity.getSizeInventory() && aTileEntity.isItemValidForSlot(aSlot, aStack); } @@ -743,14 +734,14 @@ public static boolean isAllowedToPutIntoSlot(IInventory aTileEntity, int aSlot, * * @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) { + public static int moveMultipleItemStacks(Object aTileEntity1, Object aTileEntity2, ForgeDirection fromSide, + ForgeDirection putSide, 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, + fromSide, + putSide, aFilter, aInvertFilter, aMaxTargetStackSize, @@ -762,10 +753,11 @@ public static int moveMultipleItemStacks(Object aTileEntity1, Object aTileEntity 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 + public static int moveMultipleItemStacks(IInventory fromInventory, Object toObject, ForgeDirection fromSide, + ForgeDirection putSide, List aFilter, boolean aInvertFilter, byte aMaxTargetStackSize, + byte aMinTargetStackSize, byte aMaxMoveAtOnce, byte aMinMoveAtOnce, int aMaxStackTransfer, + boolean aDoCheckChests) { + if (fromInventory == null || aMaxTargetStackSize <= 0 || aMinTargetStackSize <= 0 || aMaxMoveAtOnce <= 0 || aMinTargetStackSize > aMaxTargetStackSize @@ -773,19 +765,19 @@ public static int moveMultipleItemStacks(IInventory aTileEntity1, Object aTileEn || aMaxStackTransfer == 0) return 0; // find where to take from - final int[] tGrabSlots = new int[aTileEntity1.getSizeInventory()]; + final int[] tGrabSlots = new int[fromInventory.getSizeInventory()]; int tGrabSlotsSize = 0; - if (aTileEntity1 instanceof ISidedInventory) { - for (int i : ((ISidedInventory) aTileEntity1).getAccessibleSlotsFromSide(aGrabFrom)) { - final ItemStack s = aTileEntity1.getStackInSlot(i); - if (s == null || !isAllowedToTakeFromSlot(aTileEntity1, i, aGrabFrom, s) + if (fromInventory instanceof ISidedInventory) { + for (int i : ((ISidedInventory) fromInventory).getAccessibleSlotsFromSide(fromSide.ordinal())) { + final ItemStack s = fromInventory.getStackInSlot(i); + if (s == null || !isAllowedToTakeFromSlot(fromInventory, i, fromSide, s) || s.stackSize < aMinMoveAtOnce || !listContainsItem(aFilter, s, true, aInvertFilter)) continue; tGrabSlots[tGrabSlotsSize++] = i; } } else { for (int i = 0; i < tGrabSlots.length; i++) { - ItemStack s = aTileEntity1.getStackInSlot(i); + ItemStack s = fromInventory.getStackInSlot(i); if (s == null || s.stackSize < aMinMoveAtOnce || !listContainsItem(aFilter, s, true, aInvertFilter)) continue; tGrabSlots[tGrabSlotsSize++] = i; @@ -795,11 +787,11 @@ public static int moveMultipleItemStacks(IInventory aTileEntity1, Object aTileEn // no source, bail out if (tGrabSlotsSize == 0) { // maybe source is a double chest. check it - if (aDoCheckChests && aTileEntity1 instanceof TileEntityChest) return moveFromAdjacentChests( - (TileEntityChest) aTileEntity1, - aTileEntity2, - aGrabFrom, - aPutTo, + if (aDoCheckChests && fromInventory instanceof TileEntityChest chest) return moveFromAdjacentChests( + chest, + toObject, + fromSide, + putSide, aFilter, aInvertFilter, aMaxTargetStackSize, @@ -811,35 +803,35 @@ public static int moveMultipleItemStacks(IInventory aTileEntity1, Object aTileEn } // if target is an inventory, e.g. chest, machine, drawers... - if (aTileEntity2 instanceof IInventory tPutInventory) { + if (toObject instanceof IInventory toInventory) { // partially filled slot spare space mapping. // value is the sum of all spare space left not counting completely empty slot - final HashMap tPutItems = new HashMap<>(tPutInventory.getSizeInventory()); + final HashMap tPutItems = new HashMap<>(toInventory.getSizeInventory()); // partially filled slot contents - final HashMap> tPutItemStacks = new HashMap<>(tPutInventory.getSizeInventory()); + final HashMap> tPutItemStacks = new HashMap<>(toInventory.getSizeInventory()); // completely empty slots - final List tPutFreeSlots = new ArrayList<>(tPutInventory.getSizeInventory()); + final List tPutFreeSlots = new ArrayList<>(toInventory.getSizeInventory()); // find possible target slots int[] accessibleSlots = null; - if (aTileEntity2 instanceof ISidedInventory) - accessibleSlots = ((ISidedInventory) tPutInventory).getAccessibleSlotsFromSide(aPutTo); - for (int i = 0; i < tPutInventory.getSizeInventory(); i++) { + if (toObject instanceof ISidedInventory sided) + accessibleSlots = sided.getAccessibleSlotsFromSide(putSide.ordinal()); + for (int i = 0; i < toInventory.getSizeInventory(); i++) { int slot = i; if (accessibleSlots != null) { if (accessibleSlots.length <= i) break; slot = accessibleSlots[slot]; } - ItemStack s = tPutInventory.getStackInSlot(slot); + ItemStack s = toInventory.getStackInSlot(slot); if (s == null) { tPutFreeSlots.add(slot); - } else if ((s.stackSize < s.getMaxStackSize() && s.stackSize < tPutInventory.getInventoryStackLimit()) + } else if ((s.stackSize < s.getMaxStackSize() && s.stackSize < toInventory.getInventoryStackLimit()) && aMinMoveAtOnce <= s.getMaxStackSize() - s.stackSize) { ItemId sID = ItemId.createNoCopy(s); tPutItems.merge( sID, - (Math.min(s.getMaxStackSize(), tPutInventory.getInventoryStackLimit()) - s.stackSize), + (Math.min(s.getMaxStackSize(), toInventory.getInventoryStackLimit()) - s.stackSize), Integer::sum); tPutItemStacks.computeIfAbsent(sID, k -> new ArrayList<>()) .add(s); @@ -849,11 +841,11 @@ public static int moveMultipleItemStacks(IInventory aTileEntity1, Object aTileEn // target completely filled, bail out if (tPutItems.isEmpty() && tPutFreeSlots.isEmpty()) { // maybe target is a double chest. check it. - if (aDoCheckChests && aTileEntity2 instanceof TileEntityChest) return moveToAdjacentChests( - aTileEntity1, - (TileEntityChest) aTileEntity2, - aGrabFrom, - aPutTo, + if (aDoCheckChests && toObject instanceof TileEntityChest chest) return moveToAdjacentChests( + fromInventory, + chest, + fromSide, + putSide, aFilter, aInvertFilter, aMaxTargetStackSize, @@ -872,7 +864,7 @@ public static int moveMultipleItemStacks(IInventory aTileEntity1, Object aTileEn int tStackSize; do { tMovedItems = 0; - final ItemStack tGrabStack = aTileEntity1.getStackInSlot(grabSlot); + final ItemStack tGrabStack = fromInventory.getStackInSlot(grabSlot); if (tGrabStack == null) break; tStackSize = tGrabStack.stackSize; final ItemId sID = ItemId.createNoCopy(tGrabStack); @@ -891,7 +883,7 @@ public static int moveMultipleItemStacks(IInventory aTileEntity1, Object aTileEn final int sToPut = Math.min( Math.min( Math.min(toPut, s.getMaxStackSize() - s.stackSize), - tPutInventory.getInventoryStackLimit() - s.stackSize), + toInventory.getInventoryStackLimit() - s.stackSize), aMaxTargetStackSize - s.stackSize); if (sToPut <= 0) continue; if (sToPut < aMinMoveAtOnce) continue; @@ -899,7 +891,7 @@ public static int moveMultipleItemStacks(IInventory aTileEntity1, Object aTileEn toPut -= sToPut; s.stackSize += sToPut; if (s.stackSize == s.getMaxStackSize() - || s.stackSize == tPutInventory.getInventoryStackLimit()) { + || s.stackSize == toInventory.getInventoryStackLimit()) { // this slot is full. remove this stack from candidate list putStack.remove(i); i--; @@ -913,11 +905,11 @@ public static int moveMultipleItemStacks(IInventory aTileEntity1, Object aTileEn // deduct spare space tPutItems.merge(sID, tMovedItems, (a, b) -> a.equals(b) ? null : a - b); - if (tStackSize == 0) aTileEntity1.setInventorySlotContents(grabSlot, null); + if (tStackSize == 0) fromInventory.setInventorySlotContents(grabSlot, null); else tGrabStack.stackSize = tStackSize; - aTileEntity1.markDirty(); - tPutInventory.markDirty(); + fromInventory.markDirty(); + toInventory.markDirty(); } } } @@ -926,11 +918,11 @@ public static int moveMultipleItemStacks(IInventory aTileEntity1, Object aTileEn if (tStackSize > 0 && !tPutFreeSlots.isEmpty()) { for (int i = 0; i < tPutFreeSlots.size(); i++) { final int tPutSlot = tPutFreeSlots.get(i); - if (isAllowedToPutIntoSlot(tPutInventory, tPutSlot, aPutTo, tGrabStack, (byte) 64)) { + if (isAllowedToPutIntoSlot(toInventory, tPutSlot, putSide, tGrabStack, (byte) 64)) { // allowed, now do moving final int tMoved = moveStackFromSlotAToSlotB( - aTileEntity1, - tPutInventory, + fromInventory, + toInventory, grabSlot, tPutSlot, aMaxTargetStackSize, @@ -938,12 +930,12 @@ public static int moveMultipleItemStacks(IInventory aTileEntity1, Object aTileEn (byte) (aMaxMoveAtOnce - tMovedItems), aMinMoveAtOnce); if (tMoved > 0) { - final ItemStack s = tPutInventory.getStackInSlot(tPutSlot); + final ItemStack s = toInventory.getStackInSlot(tPutSlot); if (s != null) { // s might be null if tPutInventory is very special, e.g. infinity chest // if s is null, we will not mark this slot as target candidate for anything final int spare = Math - .min(s.getMaxStackSize(), tPutInventory.getInventoryStackLimit()) + .min(s.getMaxStackSize(), toInventory.getInventoryStackLimit()) - s.stackSize; if (spare > 0) { final ItemId ssID = ItemId.createNoCopy(s); @@ -977,12 +969,12 @@ public static int moveMultipleItemStacks(IInventory aTileEntity1, Object aTileEn } // check if source is a double chest, if yes, try move from the adjacent as well - if (aDoCheckChests && aTileEntity1 instanceof TileEntityChest) { + if (aDoCheckChests && fromInventory instanceof TileEntityChest chest) { final int tAmount = moveFromAdjacentChests( - (TileEntityChest) aTileEntity1, - aTileEntity2, - aGrabFrom, - aPutTo, + chest, + toObject, + fromSide, + putSide, aFilter, aInvertFilter, aMaxTargetStackSize, @@ -994,12 +986,12 @@ public static int moveMultipleItemStacks(IInventory aTileEntity1, Object aTileEn } // check if target is a double chest, if yes, try move to the adjacent as well - if (aDoCheckChests && aTileEntity2 instanceof TileEntityChest) { + if (aDoCheckChests && toObject instanceof TileEntityChest chest) { final int tAmount = moveToAdjacentChests( - aTileEntity1, - (TileEntityChest) aTileEntity2, - aGrabFrom, - aPutTo, + fromInventory, + chest, + fromSide, + putSide, aFilter, aInvertFilter, aMaxTargetStackSize, @@ -1018,11 +1010,11 @@ public static int moveMultipleItemStacks(IInventory aTileEntity1, Object aTileEn final int tGrabInventorySize = tGrabSlots.length; for (int i = 0; i < tGrabInventorySize; i++) { final int tMoved = moveStackIntoPipe( - aTileEntity1, - aTileEntity2, + fromInventory, + toObject, tGrabSlots, - aGrabFrom, - aPutTo, + fromSide, + putSide, aFilter, aInvertFilter, aMaxTargetStackSize, @@ -1036,16 +1028,17 @@ public static int moveMultipleItemStacks(IInventory aTileEntity1, Object aTileEn return 0; } - private static int moveToAdjacentChests(IInventory aTileEntity1, TileEntityChest aTargetChest, byte aGrabFrom, - byte aPutTo, List aFilter, boolean aInvertFilter, byte aMaxTargetStackSize, byte aMinTargetStackSize, - byte aMaxMoveAtOnce, byte aMinMoveAtOnce, int aMaxStackTransfer) { + private static int moveToAdjacentChests(IInventory aTileEntity1, TileEntityChest aTargetChest, + ForgeDirection fromSide, ForgeDirection putSide, List aFilter, boolean aInvertFilter, + byte aMaxTargetStackSize, byte aMinTargetStackSize, byte aMaxMoveAtOnce, byte aMinMoveAtOnce, + int aMaxStackTransfer) { if (aTargetChest.adjacentChestChecked) { if (aTargetChest.adjacentChestXNeg != null) { return moveMultipleItemStacks( aTileEntity1, aTargetChest.adjacentChestXNeg, - aGrabFrom, - aPutTo, + fromSide, + putSide, aFilter, aInvertFilter, aMaxTargetStackSize, @@ -1058,8 +1051,8 @@ private static int moveToAdjacentChests(IInventory aTileEntity1, TileEntityChest return moveMultipleItemStacks( aTileEntity1, aTargetChest.adjacentChestZNeg, - aGrabFrom, - aPutTo, + fromSide, + putSide, aFilter, aInvertFilter, aMaxTargetStackSize, @@ -1072,8 +1065,8 @@ private static int moveToAdjacentChests(IInventory aTileEntity1, TileEntityChest return moveMultipleItemStacks( aTileEntity1, aTargetChest.adjacentChestXPos, - aGrabFrom, - aPutTo, + fromSide, + putSide, aFilter, aInvertFilter, aMaxTargetStackSize, @@ -1086,8 +1079,8 @@ private static int moveToAdjacentChests(IInventory aTileEntity1, TileEntityChest return moveMultipleItemStacks( aTileEntity1, aTargetChest.adjacentChestZPos, - aGrabFrom, - aPutTo, + fromSide, + putSide, aFilter, aInvertFilter, aMaxTargetStackSize, @@ -1101,15 +1094,16 @@ private static int moveToAdjacentChests(IInventory aTileEntity1, TileEntityChest return 0; } - private static int moveFromAdjacentChests(TileEntityChest aChest, Object aTileEntity2, byte aGrabFrom, byte aPutTo, - List aFilter, boolean aInvertFilter, byte aMaxTargetStackSize, byte aMinTargetStackSize, - byte aMaxMoveAtOnce, byte aMinMoveAtOnce, int aMaxStackTransfer) { - if (aChest.adjacentChestXNeg != null) { + private static int moveFromAdjacentChests(TileEntityChest fromTileEntityChest, Object toObject, + ForgeDirection fromSide, ForgeDirection putSide, List aFilter, boolean aInvertFilter, + byte aMaxTargetStackSize, byte aMinTargetStackSize, byte aMaxMoveAtOnce, byte aMinMoveAtOnce, + int aMaxStackTransfer) { + if (fromTileEntityChest.adjacentChestXNeg != null) { return moveMultipleItemStacks( - aChest.adjacentChestXNeg, - aTileEntity2, - aGrabFrom, - aPutTo, + fromTileEntityChest.adjacentChestXNeg, + toObject, + fromSide, + putSide, aFilter, aInvertFilter, aMaxTargetStackSize, @@ -1118,12 +1112,12 @@ private static int moveFromAdjacentChests(TileEntityChest aChest, Object aTileEn aMinMoveAtOnce, aMaxStackTransfer, false); - } else if (aChest.adjacentChestZNeg != null) { + } else if (fromTileEntityChest.adjacentChestZNeg != null) { return moveMultipleItemStacks( - aChest.adjacentChestZNeg, - aTileEntity2, - aGrabFrom, - aPutTo, + fromTileEntityChest.adjacentChestZNeg, + toObject, + fromSide, + putSide, aFilter, aInvertFilter, aMaxTargetStackSize, @@ -1132,12 +1126,12 @@ private static int moveFromAdjacentChests(TileEntityChest aChest, Object aTileEn aMinMoveAtOnce, aMaxStackTransfer, false); - } else if (aChest.adjacentChestXPos != null) { + } else if (fromTileEntityChest.adjacentChestXPos != null) { return moveMultipleItemStacks( - aChest.adjacentChestXPos, - aTileEntity2, - aGrabFrom, - aPutTo, + fromTileEntityChest.adjacentChestXPos, + toObject, + fromSide, + putSide, aFilter, aInvertFilter, aMaxTargetStackSize, @@ -1146,12 +1140,12 @@ private static int moveFromAdjacentChests(TileEntityChest aChest, Object aTileEn aMinMoveAtOnce, aMaxStackTransfer, false); - } else if (aChest.adjacentChestZPos != null) { + } else if (fromTileEntityChest.adjacentChestZPos != null) { return moveMultipleItemStacks( - aChest.adjacentChestZPos, - aTileEntity2, - aGrabFrom, - aPutTo, + fromTileEntityChest.adjacentChestZPos, + toObject, + fromSide, + putSide, aFilter, aInvertFilter, aMaxTargetStackSize, @@ -1169,14 +1163,14 @@ private static int moveFromAdjacentChests(TileEntityChest aChest, Object aTileEn * * @return the Amount of moved Items */ - public static byte moveOneItemStack(Object aTileEntity1, Object aTileEntity2, byte aGrabFrom, byte aPutTo, - List aFilter, boolean aInvertFilter, byte aMaxTargetStackSize, byte aMinTargetStackSize, - byte aMaxMoveAtOnce, byte aMinMoveAtOnce) { - if (aTileEntity1 instanceof IInventory) return moveOneItemStack( - (IInventory) aTileEntity1, - aTileEntity2, - aGrabFrom, - aPutTo, + public static byte moveOneItemStack(Object fromObject, Object toObject, ForgeDirection fromSide, + ForgeDirection putSide, List aFilter, boolean aInvertFilter, byte aMaxTargetStackSize, + byte aMinTargetStackSize, byte aMaxMoveAtOnce, byte aMinMoveAtOnce) { + if (fromObject instanceof IInventory inv) return moveOneItemStack( + inv, + toObject, + fromSide, + putSide, aFilter, aInvertFilter, aMaxTargetStackSize, @@ -1190,190 +1184,184 @@ public static byte moveOneItemStack(Object aTileEntity1, Object aTileEntity2, by /** * This is only because I needed an additional Parameter for the Double Chest Check. */ - 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 + private static byte moveOneItemStack(IInventory fromInventory, Object toObject, ForgeDirection fromSide, + ForgeDirection putSide, List aFilter, boolean aInvertFilter, byte aMaxTargetStackSize, + byte aMinTargetStackSize, byte aMaxMoveAtOnce, byte aMinMoveAtOnce, boolean aDoCheckChests) { + if (fromInventory == 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); + if (fromInventory instanceof ISidedInventory) + tGrabSlots = ((ISidedInventory) fromInventory).getAccessibleSlotsFromSide(fromSide.ordinal()); if (tGrabSlots == null) { - tGrabSlots = new int[aTileEntity1.getSizeInventory()]; + tGrabSlots = new int[fromInventory.getSizeInventory()]; for (int i = 0; i < tGrabSlots.length; i++) tGrabSlots[i] = i; } - if (aTileEntity2 instanceof IInventory) { + if (toObject instanceof IInventory inv) { int[] tPutSlots = null; - if (aTileEntity2 instanceof ISidedInventory) - tPutSlots = ((ISidedInventory) aTileEntity2).getAccessibleSlotsFromSide(aPutTo); + if (toObject instanceof ISidedInventory sided) + tPutSlots = sided.getAccessibleSlotsFromSide(putSide.ordinal()); if (tPutSlots == null) { - tPutSlots = new int[((IInventory) aTileEntity2).getSizeInventory()]; + tPutSlots = new int[inv.getSizeInventory()]; for (int i = 0; i < tPutSlots.length; i++) tPutSlots[i] = i; } - for (int tGrabSlot : tGrabSlots) { + for (final int tGrabSlot : tGrabSlots) { byte tMovedItemCount = 0; - ItemStack tGrabStack = aTileEntity1.getStackInSlot(tGrabSlot); - if (listContainsItem(aFilter, tGrabStack, true, aInvertFilter)) { - if (tGrabStack.stackSize >= aMinMoveAtOnce - && isAllowedToTakeFromSlot(aTileEntity1, tGrabSlot, aGrabFrom, tGrabStack)) { - for (int tPutSlot : tPutSlots) { - if (isAllowedToPutIntoSlot( - (IInventory) aTileEntity2, + final ItemStack tGrabStack = fromInventory.getStackInSlot(tGrabSlot); + if (listContainsItem(aFilter, tGrabStack, true, aInvertFilter) + && (tGrabStack.stackSize >= aMinMoveAtOnce + && isAllowedToTakeFromSlot(fromInventory, tGrabSlot, fromSide, tGrabStack))) { + for (final int tPutSlot : tPutSlots) { + if (isAllowedToPutIntoSlot(inv, tPutSlot, putSide, tGrabStack, aMaxTargetStackSize)) { + tMovedItemCount += moveStackFromSlotAToSlotB( + fromInventory, + inv, + tGrabSlot, tPutSlot, - aPutTo, - tGrabStack, - aMaxTargetStackSize)) { - tMovedItemCount += moveStackFromSlotAToSlotB( - aTileEntity1, - (IInventory) aTileEntity2, - tGrabSlot, - tPutSlot, - aMaxTargetStackSize, - aMinTargetStackSize, - (byte) (aMaxMoveAtOnce - tMovedItemCount), - aMinMoveAtOnce); - if (tMovedItemCount >= aMaxMoveAtOnce - || (tMovedItemCount > 0 && aMaxTargetStackSize < 64)) return tMovedItemCount; - } + aMaxTargetStackSize, + aMinTargetStackSize, + (byte) (aMaxMoveAtOnce - tMovedItemCount), + aMinMoveAtOnce); + if (tMovedItemCount >= aMaxMoveAtOnce || (tMovedItemCount > 0 && aMaxTargetStackSize < 64)) + return tMovedItemCount; } } + } if (tMovedItemCount > 0) return tMovedItemCount; } - if (aDoCheckChests && aTileEntity1 instanceof TileEntityChest tTileEntity1) { - if (tTileEntity1.adjacentChestChecked) { - byte tAmount = 0; - if (tTileEntity1.adjacentChestXNeg != null) { - tAmount = moveOneItemStack( - tTileEntity1.adjacentChestXNeg, - aTileEntity2, - aGrabFrom, - aPutTo, - aFilter, - aInvertFilter, - aMaxTargetStackSize, - aMinTargetStackSize, - aMaxMoveAtOnce, - aMinMoveAtOnce, - false); - } else if (tTileEntity1.adjacentChestZNeg != null) { - tAmount = moveOneItemStack( - tTileEntity1.adjacentChestZNeg, - aTileEntity2, - aGrabFrom, - aPutTo, - aFilter, - aInvertFilter, - aMaxTargetStackSize, - aMinTargetStackSize, - aMaxMoveAtOnce, - aMinMoveAtOnce, - false); - } else if (tTileEntity1.adjacentChestXPos != null) { - tAmount = moveOneItemStack( - tTileEntity1.adjacentChestXPos, - aTileEntity2, - aGrabFrom, - aPutTo, - aFilter, - aInvertFilter, - aMaxTargetStackSize, - aMinTargetStackSize, - aMaxMoveAtOnce, - aMinMoveAtOnce, - false); - } else if (tTileEntity1.adjacentChestZPos != null) { - tAmount = moveOneItemStack( - tTileEntity1.adjacentChestZPos, - aTileEntity2, - aGrabFrom, - aPutTo, - aFilter, - aInvertFilter, - aMaxTargetStackSize, - aMinTargetStackSize, - aMaxMoveAtOnce, - aMinMoveAtOnce, - false); - } - if (tAmount != 0) return tAmount; + if (aDoCheckChests && fromInventory instanceof TileEntityChest fromChest + && (fromChest.adjacentChestChecked)) { + byte tAmount = 0; + if (fromChest.adjacentChestXNeg != null) { + tAmount = moveOneItemStack( + fromChest.adjacentChestXNeg, + toObject, + fromSide, + putSide, + aFilter, + aInvertFilter, + aMaxTargetStackSize, + aMinTargetStackSize, + aMaxMoveAtOnce, + aMinMoveAtOnce, + false); + } else if (fromChest.adjacentChestZNeg != null) { + tAmount = moveOneItemStack( + fromChest.adjacentChestZNeg, + toObject, + fromSide, + putSide, + aFilter, + aInvertFilter, + aMaxTargetStackSize, + aMinTargetStackSize, + aMaxMoveAtOnce, + aMinMoveAtOnce, + false); + } else if (fromChest.adjacentChestXPos != null) { + tAmount = moveOneItemStack( + fromChest.adjacentChestXPos, + toObject, + fromSide, + putSide, + aFilter, + aInvertFilter, + aMaxTargetStackSize, + aMinTargetStackSize, + aMaxMoveAtOnce, + aMinMoveAtOnce, + false); + } else if (fromChest.adjacentChestZPos != null) { + tAmount = moveOneItemStack( + fromChest.adjacentChestZPos, + toObject, + fromSide, + putSide, + aFilter, + aInvertFilter, + aMaxTargetStackSize, + aMinTargetStackSize, + aMaxMoveAtOnce, + aMinMoveAtOnce, + false); } + if (tAmount != 0) return tAmount; + } - if (aDoCheckChests && aTileEntity2 instanceof TileEntityChest tTileEntity2) { - if (tTileEntity2.adjacentChestChecked) { - byte tAmount = 0; - if (tTileEntity2.adjacentChestXNeg != null) { - tAmount = moveOneItemStack( - aTileEntity1, - tTileEntity2.adjacentChestXNeg, - aGrabFrom, - aPutTo, - aFilter, - aInvertFilter, - aMaxTargetStackSize, - aMinTargetStackSize, - aMaxMoveAtOnce, - aMinMoveAtOnce, - false); - } else if (tTileEntity2.adjacentChestZNeg != null) { - tAmount = moveOneItemStack( - aTileEntity1, - tTileEntity2.adjacentChestZNeg, - aGrabFrom, - aPutTo, - aFilter, - aInvertFilter, - aMaxTargetStackSize, - aMinTargetStackSize, - aMaxMoveAtOnce, - aMinMoveAtOnce, - false); - } else if (tTileEntity2.adjacentChestXPos != null) { - tAmount = moveOneItemStack( - aTileEntity1, - tTileEntity2.adjacentChestXPos, - aGrabFrom, - aPutTo, - aFilter, - aInvertFilter, - aMaxTargetStackSize, - aMinTargetStackSize, - aMaxMoveAtOnce, - aMinMoveAtOnce, - false); - } else if (tTileEntity2.adjacentChestZPos != null) { - tAmount = moveOneItemStack( - aTileEntity1, - tTileEntity2.adjacentChestZPos, - aGrabFrom, - aPutTo, - aFilter, - aInvertFilter, - aMaxTargetStackSize, - aMinTargetStackSize, - aMaxMoveAtOnce, - aMinMoveAtOnce, - false); - } - if (tAmount != 0) return tAmount; + if (aDoCheckChests && toObject instanceof TileEntityChest toChest && (toChest.adjacentChestChecked)) { + byte tAmount = 0; + if (toChest.adjacentChestXNeg != null) { + tAmount = moveOneItemStack( + fromInventory, + toChest.adjacentChestXNeg, + fromSide, + putSide, + aFilter, + aInvertFilter, + aMaxTargetStackSize, + aMinTargetStackSize, + aMaxMoveAtOnce, + aMinMoveAtOnce, + false); + } else if (toChest.adjacentChestZNeg != null) { + tAmount = moveOneItemStack( + fromInventory, + toChest.adjacentChestZNeg, + fromSide, + putSide, + aFilter, + aInvertFilter, + aMaxTargetStackSize, + aMinTargetStackSize, + aMaxMoveAtOnce, + aMinMoveAtOnce, + false); + } else if (toChest.adjacentChestXPos != null) { + tAmount = moveOneItemStack( + fromInventory, + toChest.adjacentChestXPos, + fromSide, + putSide, + aFilter, + aInvertFilter, + aMaxTargetStackSize, + aMinTargetStackSize, + aMaxMoveAtOnce, + aMinMoveAtOnce, + false); + } else if (toChest.adjacentChestZPos != null) { + tAmount = moveOneItemStack( + fromInventory, + toChest.adjacentChestZPos, + fromSide, + putSide, + aFilter, + aInvertFilter, + aMaxTargetStackSize, + aMinTargetStackSize, + aMaxMoveAtOnce, + aMinMoveAtOnce, + false); } + if (tAmount != 0) return tAmount; + } } return moveStackIntoPipe( - aTileEntity1, - aTileEntity2, + fromInventory, + toObject, tGrabSlots, - aGrabFrom, - aPutTo, + fromSide, + putSide, aFilter, aInvertFilter, aMaxTargetStackSize, @@ -1388,11 +1376,10 @@ && isAllowedToTakeFromSlot(aTileEntity1, tGrabSlot, aGrabFrom, tGrabStack)) { * * @return the Amount of moved Items */ - public static byte moveOneItemStackIntoSlot(Object aTileEntity1, Object aTileEntity2, byte aGrabFrom, int aPutTo, - List aFilter, boolean aInvertFilter, byte aMaxTargetStackSize, byte aMinTargetStackSize, + public static byte moveOneItemStackIntoSlot(Object fromTileEntity, Object toTileEntity, ForgeDirection fromSide, + int putSlot, List aFilter, boolean aInvertFilter, byte aMaxTargetStackSize, byte aMinTargetStackSize, byte aMaxMoveAtOnce, byte aMinMoveAtOnce) { - if (aTileEntity1 == null || !(aTileEntity1 instanceof IInventory) - || aPutTo < 0 + if (fromTileEntity == null || !(fromTileEntity instanceof IInventory fromInv) || aMaxTargetStackSize <= 0 || aMinTargetStackSize <= 0 || aMaxMoveAtOnce <= 0 @@ -1400,36 +1387,28 @@ public static byte moveOneItemStackIntoSlot(Object aTileEntity1, Object aTileEnt || aMinMoveAtOnce > aMaxMoveAtOnce) return 0; int[] tGrabSlots = null; - if (aTileEntity1 instanceof ISidedInventory) - tGrabSlots = ((ISidedInventory) aTileEntity1).getAccessibleSlotsFromSide(aGrabFrom); + if (fromTileEntity instanceof ISidedInventory sided) + tGrabSlots = sided.getAccessibleSlotsFromSide(fromSide.ordinal()); if (tGrabSlots == null) { - tGrabSlots = new int[((IInventory) aTileEntity1).getSizeInventory()]; + tGrabSlots = new int[fromInv.getSizeInventory()]; for (int i = 0; i < tGrabSlots.length; i++) tGrabSlots[i] = i; } - if (aTileEntity2 instanceof IInventory) { - for (int tGrabSlot : tGrabSlots) { - if (listContainsItem( - aFilter, - ((IInventory) aTileEntity1).getStackInSlot(tGrabSlot), - true, - aInvertFilter)) { - if (isAllowedToTakeFromSlot( - (IInventory) aTileEntity1, - tGrabSlot, - aGrabFrom, - ((IInventory) aTileEntity1).getStackInSlot(tGrabSlot))) { + if (toTileEntity instanceof IInventory toInv) { + for (final int tGrabSlot : tGrabSlots) { + if (listContainsItem(aFilter, fromInv.getStackInSlot(tGrabSlot), true, aInvertFilter)) { + if (isAllowedToTakeFromSlot(fromInv, tGrabSlot, fromSide, fromInv.getStackInSlot(tGrabSlot))) { if (isAllowedToPutIntoSlot( - (IInventory) aTileEntity2, - aPutTo, - (byte) 6, - ((IInventory) aTileEntity1).getStackInSlot(tGrabSlot), + toInv, + putSlot, + ForgeDirection.UNKNOWN, + fromInv.getStackInSlot(tGrabSlot), aMaxTargetStackSize)) { byte tMovedItemCount = moveStackFromSlotAToSlotB( - (IInventory) aTileEntity1, - (IInventory) aTileEntity2, + fromInv, + toInv, tGrabSlot, - aPutTo, + putSlot, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, @@ -1441,12 +1420,13 @@ public static byte moveOneItemStackIntoSlot(Object aTileEntity1, Object aTileEnt } } + final ForgeDirection toSide = fromSide.getOpposite(); moveStackIntoPipe( - ((IInventory) aTileEntity1), - aTileEntity2, + fromInv, + toTileEntity, tGrabSlots, - aGrabFrom, - aPutTo, + fromSide, + ForgeDirection.UNKNOWN, aFilter, aInvertFilter, aMaxTargetStackSize, @@ -1461,28 +1441,31 @@ public static byte moveOneItemStackIntoSlot(Object aTileEntity1, Object aTileEnt * * @return the Amount of moved Items */ - public static byte moveFromSlotToSlot(IInventory aTileEntity1, IInventory aTileEntity2, int aGrabFrom, int aPutTo, + public static byte moveFromSlotToSlot(IInventory fromInv, IInventory toInv, int aGrabFrom, int aPutTo, List aFilter, boolean aInvertFilter, byte aMaxTargetStackSize, byte aMinTargetStackSize, byte aMaxMoveAtOnce, byte aMinMoveAtOnce) { - if (aTileEntity1 == null || aTileEntity2 == null + if (fromInv == null || toInv == null || aGrabFrom < 0 || aPutTo < 0 - || aMaxTargetStackSize <= 0 || aMinTargetStackSize <= 0 || aMaxMoveAtOnce <= 0 || aMinTargetStackSize > aMaxTargetStackSize || aMinMoveAtOnce > aMaxMoveAtOnce) return 0; - if (listContainsItem(aFilter, aTileEntity1.getStackInSlot(aGrabFrom), true, aInvertFilter)) { - if (isAllowedToTakeFromSlot(aTileEntity1, aGrabFrom, (byte) 6, aTileEntity1.getStackInSlot(aGrabFrom))) { + if (listContainsItem(aFilter, fromInv.getStackInSlot(aGrabFrom), true, aInvertFilter)) { + if (isAllowedToTakeFromSlot( + fromInv, + aGrabFrom, + ForgeDirection.UNKNOWN, + fromInv.getStackInSlot(aGrabFrom))) { if (isAllowedToPutIntoSlot( - aTileEntity2, + toInv, aPutTo, - (byte) 6, - aTileEntity1.getStackInSlot(aGrabFrom), + ForgeDirection.UNKNOWN, + fromInv.getStackInSlot(aGrabFrom), aMaxTargetStackSize)) { byte tMovedItemCount = moveStackFromSlotAToSlotB( - aTileEntity1, - aTileEntity2, + fromInv, + toInv, aGrabFrom, aPutTo, aMaxTargetStackSize, @@ -1501,22 +1484,23 @@ public static byte moveFromSlotToSlot(IInventory aTileEntity1, IInventory aTileE * * @return the Amount of moved Items */ - public static byte moveFromSlotToSide(IInventory fromTile, Object toTile, int aGrabFrom, byte aPutTo, + public static byte moveFromSlotToSide(IInventory fromTile, Object toTile, int fromSlot, ForgeDirection putSide, List aFilter, boolean aInvertFilter, byte aMaxTargetStackSize, byte aMinTargetStackSize, byte aMaxMoveAtOnce, byte aMinMoveAtOnce, boolean aDoCheckChests) { - if (fromTile == null || aGrabFrom < 0 + if (fromTile == null || fromSlot < 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 (!listContainsItem(aFilter, fromTile.getStackInSlot(fromSlot), true, aInvertFilter) + || !isAllowedToTakeFromSlot(fromTile, fromSlot, ForgeDirection.UNKNOWN, fromTile.getStackInSlot(fromSlot))) + return 0; if (toTile instanceof IInventory) { int[] tPutSlots = null; - if (toTile instanceof ISidedInventory) - tPutSlots = ((ISidedInventory) toTile).getAccessibleSlotsFromSide(aPutTo); + if (toTile instanceof ISidedInventory sided) + tPutSlots = sided.getAccessibleSlotsFromSide(putSide.ordinal()); if (tPutSlots == null) { tPutSlots = new int[((IInventory) toTile).getSizeInventory()]; @@ -1524,17 +1508,17 @@ public static byte moveFromSlotToSide(IInventory fromTile, Object toTile, int aG } byte tMovedItemCount = 0; - for (int tPutSlot : tPutSlots) { + for (final int tPutSlot : tPutSlots) { if (isAllowedToPutIntoSlot( (IInventory) toTile, tPutSlot, - aPutTo, - fromTile.getStackInSlot(aGrabFrom), + putSide, + fromTile.getStackInSlot(fromSlot), aMaxTargetStackSize)) { tMovedItemCount += moveStackFromSlotAToSlotB( fromTile, (IInventory) toTile, - aGrabFrom, + fromSlot, tPutSlot, aMaxTargetStackSize, aMinTargetStackSize, @@ -1553,8 +1537,8 @@ public static byte moveFromSlotToSide(IInventory fromTile, Object toTile, int aG tMovedItemCount = moveFromSlotToSide( fromTile, tTileEntity2.adjacentChestXNeg, - aGrabFrom, - aPutTo, + fromSlot, + putSide, aFilter, aInvertFilter, aMaxTargetStackSize, @@ -1566,8 +1550,8 @@ public static byte moveFromSlotToSide(IInventory fromTile, Object toTile, int aG tMovedItemCount = moveFromSlotToSide( fromTile, tTileEntity2.adjacentChestZNeg, - aGrabFrom, - aPutTo, + fromSlot, + putSide, aFilter, aInvertFilter, aMaxTargetStackSize, @@ -1579,8 +1563,8 @@ public static byte moveFromSlotToSide(IInventory fromTile, Object toTile, int aG tMovedItemCount = moveFromSlotToSide( fromTile, tTileEntity2.adjacentChestXPos, - aGrabFrom, - aPutTo, + fromSlot, + putSide, aFilter, aInvertFilter, aMaxTargetStackSize, @@ -1592,8 +1576,8 @@ public static byte moveFromSlotToSide(IInventory fromTile, Object toTile, int aG tMovedItemCount = moveFromSlotToSide( fromTile, tTileEntity2.adjacentChestZPos, - aGrabFrom, - aPutTo, + fromSlot, + putSide, aFilter, aInvertFilter, aMaxTargetStackSize, @@ -1609,9 +1593,9 @@ public static byte moveFromSlotToSide(IInventory fromTile, Object toTile, int aG return moveStackIntoPipe( fromTile, toTile, - new int[] { aGrabFrom }, - (byte) 6, - aPutTo, + new int[] { fromSlot }, + ForgeDirection.UNKNOWN, + putSide, aFilter, aInvertFilter, aMaxTargetStackSize, @@ -1621,14 +1605,14 @@ public static byte moveFromSlotToSide(IInventory fromTile, Object toTile, int aG aDoCheckChests); } - public static byte moveFromSlotToSide(IInventory fromTile, Object toTile, int aGrabFrom, byte aPutTo, + public static byte moveFromSlotToSide(IInventory fromTile, Object toTile, int fromSlot, ForgeDirection putSide, List aFilter, boolean aInvertFilter, byte aMaxTargetStackSize, byte aMinTargetStackSize, byte aMaxMoveAtOnce, byte aMinMoveAtOnce) { return moveFromSlotToSide( fromTile, toTile, - aGrabFrom, - aPutTo, + fromSlot, + putSide, aFilter, aInvertFilter, aMaxTargetStackSize, @@ -3168,7 +3152,7 @@ public static int getScaleCoordinates(double aValue, int aScale) { } public static int getCoordinateScan(ArrayList aList, EntityPlayer aPlayer, World aWorld, int aScanLevel, - int aX, int aY, int aZ, int aSide, float aClickX, float aClickY, float aClickZ) { + int aX, int aY, int aZ, ForgeDirection side, float aClickX, float aClickY, float aClickZ) { if (aList == null) return 0; ArrayList tList = new ArrayList<>(); @@ -3178,6 +3162,65 @@ public static int getCoordinateScan(ArrayList aList, EntityPlayer aPlaye final Block tBlock = aWorld.getBlock(aX, aY, aZ); + addBaseInfo(aPlayer, aWorld, aX, aY, aZ, tList, tTileEntity, tBlock); + + if (tTileEntity != null) { + rEUAmount += addFluidHandlerInfo(side, tList, tTileEntity); + + try { + if (tTileEntity instanceof ic2.api.reactor.IReactorChamber chamber) { + rEUAmount += 500; + // Redirect the rest of the scans to the reactor itself + tTileEntity = (TileEntity) chamber.getReactor(); + } + } catch (Throwable e) { + if (D1) e.printStackTrace(GT_Log.err); + } + rEUAmount += addReactorInfo(tList, tTileEntity); + rEUAmount += addAlignmentInfo(tList, tTileEntity); + rEUAmount += addIC2WrenchableInfo(aPlayer, tList, tTileEntity); + rEUAmount += addIC2EnergyConductorInfo(tList, tTileEntity); + rEUAmount += addIC2EnergyStorageInfo(tList, tTileEntity); + rEUAmount += addUpgradableMachineInfo(tList, tTileEntity); + rEUAmount += addMachineProgressInfo(tList, tTileEntity); + rEUAmount += addCoverableInfo(side, tList, tTileEntity); + addEnergyContainerInfo(tList, tTileEntity); + addOwnerInfo(tList, tTileEntity); + addDeviceInfo(tList, tTileEntity); + + rEUAmount += addIC2CropInfo(tList, tTileEntity); + + rEUAmount += addForestryLeavesInfo(tList, tTileEntity); + } + + final Chunk currentChunk = aWorld.getChunkFromBlockCoords(aX, aZ); + addUndergroundFluidInfo(aPlayer, tList, currentChunk); + addPollutionInfo(tList, currentChunk); + + rEUAmount += addDebuggableBlockInfo(aPlayer, aX, aY, aZ, tList, tBlock); + + final BlockScanningEvent tEvent = new BlockScanningEvent( + aWorld, + aPlayer, + aX, + aY, + aZ, + side, + aScanLevel, + tBlock, + tTileEntity, + tList, + aClickX, + aClickY, + aClickZ); + tEvent.mEUCost = rEUAmount; + MinecraftForge.EVENT_BUS.post(tEvent); + if (!tEvent.isCanceled()) aList.addAll(tList); + return tEvent.mEUCost; + } + + private static void addBaseInfo(EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, ArrayList tList, + TileEntity tTileEntity, Block tBlock) { tList.add( "----- X: " + EnumChatFormatting.AQUA + formatNumbers(aX) @@ -3196,23 +3239,14 @@ public static int getCoordinateScan(ArrayList aList, EntityPlayer aPlaye + EnumChatFormatting.RESET + " -----"); try { - if (tTileEntity instanceof IInventory) tList.add( - GT_Utility.trans("162", "Name: ") + EnumChatFormatting.BLUE - + ((IInventory) tTileEntity).getInventoryName() - + EnumChatFormatting.RESET - + GT_Utility.trans("163", " MetaData: ") - + EnumChatFormatting.AQUA - + aWorld.getBlockMetadata(aX, aY, aZ) - + EnumChatFormatting.RESET); - else tList.add( + tList.add( GT_Utility.trans("162", "Name: ") + EnumChatFormatting.BLUE - + tBlock.getUnlocalizedName() + + ((tTileEntity instanceof IInventory inv) ? inv.getInventoryName() : tBlock.getUnlocalizedName()) + EnumChatFormatting.RESET + GT_Utility.trans("163", " MetaData: ") + EnumChatFormatting.AQUA + aWorld.getBlockMetadata(aX, aY, aZ) + EnumChatFormatting.RESET); - tList.add( GT_Utility.trans("164", "Hardness: ") + EnumChatFormatting.YELLOW + tBlock.getBlockHardness(aWorld, aX, aY, aZ) @@ -3228,288 +3262,67 @@ public static int getCoordinateScan(ArrayList aList, EntityPlayer aPlaye } catch (Throwable e) { if (D1) e.printStackTrace(GT_Log.err); } - if (tTileEntity != null) { - try { - if (tTileEntity instanceof IFluidHandler) { - rEUAmount += 500; - final FluidTankInfo[] tTanks = ((IFluidHandler) tTileEntity) - .getTankInfo(ForgeDirection.getOrientation(aSide)); - if (tTanks != null) for (byte i = 0; i < tTanks.length; i++) { - tList.add( - GT_Utility.trans("167", "Tank ") + i - + ": " - + EnumChatFormatting.GREEN - + formatNumbers((tTanks[i].fluid == null ? 0 : tTanks[i].fluid.amount)) - + EnumChatFormatting.RESET - + " L / " - + EnumChatFormatting.YELLOW - + formatNumbers(tTanks[i].capacity) - + EnumChatFormatting.RESET - + " L " - + EnumChatFormatting.GOLD - + getFluidName(tTanks[i].fluid, true) - + EnumChatFormatting.RESET); - } - } - } catch (Throwable e) { - if (D1) e.printStackTrace(GT_Log.err); - } - try { - if (tTileEntity instanceof ic2.api.reactor.IReactorChamber) { - rEUAmount += 500; - tTileEntity = (TileEntity) (((ic2.api.reactor.IReactorChamber) tTileEntity).getReactor()); - } - } catch (Throwable e) { - if (D1) e.printStackTrace(GT_Log.err); - } - try { - if (tTileEntity instanceof ic2.api.reactor.IReactor) { - rEUAmount += 500; - tList.add( - GT_Utility.trans("168", "Heat: ") + EnumChatFormatting.GREEN - + formatNumbers(((ic2.api.reactor.IReactor) tTileEntity).getHeat()) - + EnumChatFormatting.RESET - + " / " - + EnumChatFormatting.YELLOW - + formatNumbers(((ic2.api.reactor.IReactor) tTileEntity).getMaxHeat()) - + EnumChatFormatting.RESET); - tList.add( - GT_Utility.trans("169", "HEM: ") + EnumChatFormatting.YELLOW - + ((ic2.api.reactor.IReactor) tTileEntity).getHeatEffectModifier() - + EnumChatFormatting.RESET - /* - * + GT_Utility.trans("170"," Base EU Output: ")/* + - * ((ic2.api.reactor.IReactor)tTileEntity).getOutput() - */ ); - } - } catch (Throwable e) { - if (D1) e.printStackTrace(GT_Log.err); - } - try { - if (tTileEntity instanceof IAlignmentProvider) { - final IAlignment tAlignment = ((IAlignmentProvider) tTileEntity).getAlignment(); - if (tAlignment != null) { - rEUAmount += 100; - tList.add( - GT_Utility.trans("219", "Extended Facing: ") + EnumChatFormatting.GREEN - + tAlignment.getExtendedFacing() - + EnumChatFormatting.RESET); - } - } - } catch (Throwable e) { - if (D1) e.printStackTrace(GT_Log.err); - } - try { - if (tTileEntity instanceof ic2.api.tile.IWrenchable) { - rEUAmount += 100; - tList.add( - GT_Utility.trans("171", "Facing: ") + EnumChatFormatting.GREEN - + ((ic2.api.tile.IWrenchable) tTileEntity).getFacing() - + EnumChatFormatting.RESET - + GT_Utility.trans("172", " / Chance: ") - + EnumChatFormatting.YELLOW - + (((ic2.api.tile.IWrenchable) tTileEntity).getWrenchDropRate() * 100) - + EnumChatFormatting.RESET - + "%"); - tList.add( - ((ic2.api.tile.IWrenchable) tTileEntity).wrenchCanRemove(aPlayer) - ? EnumChatFormatting.GREEN + GT_Utility.trans("173", "You can remove this with a Wrench") - + EnumChatFormatting.RESET - : EnumChatFormatting.RED + GT_Utility.trans("174", "You can NOT remove this with a Wrench") - + EnumChatFormatting.RESET); - } - } catch (Throwable e) { - if (D1) e.printStackTrace(GT_Log.err); - } - try { - if (tTileEntity instanceof ic2.api.energy.tile.IEnergyConductor) { - rEUAmount += 200; - tList.add( - GT_Utility.trans("175", "Conduction Loss: ") + EnumChatFormatting.YELLOW - + ((ic2.api.energy.tile.IEnergyConductor) tTileEntity).getConductionLoss() - + EnumChatFormatting.RESET); - } - } catch (Throwable e) { - if (D1) e.printStackTrace(GT_Log.err); - } - try { - if (tTileEntity instanceof ic2.api.tile.IEnergyStorage) { - rEUAmount += 200; - tList.add( - GT_Utility.trans("176", "Contained Energy: ") + EnumChatFormatting.YELLOW - + formatNumbers(((ic2.api.tile.IEnergyStorage) tTileEntity).getStored()) - + EnumChatFormatting.RESET - + " EU / " - + EnumChatFormatting.YELLOW - + formatNumbers(((ic2.api.tile.IEnergyStorage) tTileEntity).getCapacity()) - + EnumChatFormatting.RESET - + " EU"); - } - } catch (Throwable e) { - if (D1) e.printStackTrace(GT_Log.err); - } - try { - if (tTileEntity instanceof IUpgradableMachine) { - rEUAmount += 500; - if (((IUpgradableMachine) tTileEntity).hasMufflerUpgrade()) tList.add( - EnumChatFormatting.GREEN + GT_Utility.trans("177", "Has Muffler Upgrade") - + EnumChatFormatting.RESET); - } - } catch (Throwable e) { - if (D1) e.printStackTrace(GT_Log.err); - } - try { - if (tTileEntity instanceof IMachineProgress) { - if (((IMachineProgress) tTileEntity).isAllowedToWork()) { - tList.add(EnumChatFormatting.RED + "Disabled." + EnumChatFormatting.RESET); - } - if (((IMachineProgress) tTileEntity).wasShutdown()) { - tList.add(EnumChatFormatting.RED + "Shut down due to power loss." + EnumChatFormatting.RESET); - } - rEUAmount += 400; - int tValue = 0; - if (0 < (tValue = ((IMachineProgress) tTileEntity).getMaxProgress())) tList.add( - GT_Utility.trans("178", "Progress/Load: ") + EnumChatFormatting.GREEN - + formatNumbers(((IMachineProgress) tTileEntity).getProgress()) - + EnumChatFormatting.RESET - + " / " - + EnumChatFormatting.YELLOW - + formatNumbers(tValue) - + EnumChatFormatting.RESET); - } - } catch (Throwable e) { - if (D1) e.printStackTrace(GT_Log.err); - } - try { - if (tTileEntity instanceof ICoverable) { - rEUAmount += 300; - final String tString = ((ICoverable) tTileEntity).getCoverInfoAtSide((byte) aSide) - .getBehaviorDescription(); - if (tString != null && !tString.equals(E)) tList.add(tString); - } - } catch (Throwable e) { - if (D1) e.printStackTrace(GT_Log.err); - } - try { - if (tTileEntity instanceof IBasicEnergyContainer - && ((IBasicEnergyContainer) tTileEntity).getEUCapacity() > 0) { - tList.add( - GT_Utility.trans("179", "Max IN: ") + EnumChatFormatting.RED - + formatNumbers(((IBasicEnergyContainer) tTileEntity).getInputVoltage()) - + " (" - + GT_Values.VN[getTier(((IBasicEnergyContainer) tTileEntity).getInputVoltage())] - + ") " - + EnumChatFormatting.RESET - + GT_Utility.trans("182", " EU at ") - + EnumChatFormatting.RED - + formatNumbers(((IBasicEnergyContainer) tTileEntity).getInputAmperage()) - + EnumChatFormatting.RESET - + GT_Utility.trans("183", " A")); - tList.add( - GT_Utility.trans("181", "Max OUT: ") + EnumChatFormatting.RED - + formatNumbers(((IBasicEnergyContainer) tTileEntity).getOutputVoltage()) - + " (" - + GT_Values.VN[getTier(((IBasicEnergyContainer) tTileEntity).getOutputVoltage())] - + ") " - + EnumChatFormatting.RESET - + GT_Utility.trans("182", " EU at ") - + EnumChatFormatting.RED - + formatNumbers(((IBasicEnergyContainer) tTileEntity).getOutputAmperage()) - + EnumChatFormatting.RESET - + GT_Utility.trans("183", " A")); + } + + private static int addFluidHandlerInfo(ForgeDirection side, ArrayList tList, TileEntity tTileEntity) { + int rEUAmount = 0; + try { + if (tTileEntity instanceof IFluidHandler fluidHandler) { + rEUAmount += 500; + final FluidTankInfo[] tTanks = fluidHandler.getTankInfo(side); + if (tTanks != null) for (byte i = 0; i < tTanks.length; i++) { tList.add( - GT_Utility.trans("184", "Energy: ") + EnumChatFormatting.GREEN - + formatNumbers(((IBasicEnergyContainer) tTileEntity).getStoredEU()) + GT_Utility.trans("167", "Tank ") + i + + ": " + + EnumChatFormatting.GREEN + + formatNumbers((tTanks[i].fluid == null ? 0 : tTanks[i].fluid.amount)) + EnumChatFormatting.RESET - + " EU / " + + " L / " + EnumChatFormatting.YELLOW - + formatNumbers(((IBasicEnergyContainer) tTileEntity).getEUCapacity()) + + formatNumbers(tTanks[i].capacity) + EnumChatFormatting.RESET - + " EU"); - } - } catch (Throwable e) { - if (D1) e.printStackTrace(GT_Log.err); - } - try { - if (tTileEntity instanceof IGregTechTileEntity) { - tList.add( - GT_Utility.trans("186", "Owned by: ") + EnumChatFormatting.BLUE - + ((IGregTechTileEntity) tTileEntity).getOwnerName() + + " L " + + EnumChatFormatting.GOLD + + getFluidName(tTanks[i].fluid, true) + EnumChatFormatting.RESET); } - } catch (Throwable e) { - if (D1) e.printStackTrace(GT_Log.err); - } - try { - if (tTileEntity instanceof IGregTechDeviceInformation - && ((IGregTechDeviceInformation) tTileEntity).isGivingInformation()) { - tList.addAll(Arrays.asList(((IGregTechDeviceInformation) tTileEntity).getInfoData())); - } - } catch (Throwable e) { - if (D1) e.printStackTrace(GT_Log.err); - } - try { - if (tTileEntity instanceof ic2.api.crops.ICropTile crop) { - rEUAmount += 1000; - if (crop.getScanLevel() < 4) crop.setScanLevel((byte) 4); - if (crop.getCrop() != null) { - tList.add( - GT_Utility.trans("187", "Type -- Crop-Name: ") + crop.getCrop() - .name() - + GT_Utility.trans("188", " Growth: ") - + crop.getGrowth() - + GT_Utility.trans("189", " Gain: ") - + crop.getGain() - + GT_Utility.trans("190", " Resistance: ") - + crop.getResistance()); - } - tList.add( - GT_Utility.trans("191", "Plant -- Fertilizer: ") + crop.getNutrientStorage() - + GT_Utility.trans("192", " Water: ") - + crop.getHydrationStorage() - + GT_Utility.trans("193", " Weed-Ex: ") - + crop.getWeedExStorage() - + GT_Utility.trans("194", " Scan-Level: ") - + crop.getScanLevel()); - tList.add( - GT_Utility.trans("195", "Environment -- Nutrients: ") + crop.getNutrients() - + GT_Utility.trans("196", " Humidity: ") - + crop.getHumidity() - + GT_Utility.trans("197", " Air-Quality: ") - + crop.getAirQuality()); - if (crop.getCrop() != null) { - final StringBuilder tStringB = new StringBuilder(); - for (String tAttribute : crop.getCrop() - .attributes()) { - tStringB.append(", ") - .append(tAttribute); - } - final String tString = tStringB.toString(); - tList.add(GT_Utility.trans("198", "Attributes:") + tString.replaceFirst(",", E)); - tList.add( - GT_Utility.trans("199", "Discovered by: ") + crop.getCrop() - .discoveredBy()); - } - } - } catch (Throwable e) { - if (D1) e.printStackTrace(GT_Log.err); } + } catch (Throwable e) { + if (D1) e.printStackTrace(GT_Log.err); + } + return rEUAmount; + } - try { - if (tTileEntity instanceof forestry.arboriculture.tiles.TileLeaves tileLeaves) { - final forestry.api.arboriculture.ITree tree = tileLeaves.getTree(); - if (tree != null) { - rEUAmount += 1000; - if (!tree.isAnalyzed()) tree.analyze(); - tree.addTooltip(tList); - } - } - } catch (Throwable e) { - if (D1) e.printStackTrace(GT_Log.err); + private static int addDebuggableBlockInfo(EntityPlayer aPlayer, int aX, int aY, int aZ, ArrayList tList, + Block tBlock) { + int rEUAmount = 0; + try { + if (tBlock instanceof IDebugableBlock debugableBlock) { + rEUAmount += 500; + final ArrayList temp = debugableBlock.getDebugInfo(aPlayer, aX, aY, aZ, 3); + if (temp != null) tList.addAll(temp); } + } catch (Throwable e) { + if (D1) e.printStackTrace(GT_Log.err); } + return rEUAmount; + } - final Chunk currentChunk = aWorld.getChunkFromBlockCoords(aX, aZ); + private static void addPollutionInfo(ArrayList tList, Chunk currentChunk) { + if (GT_Pollution.hasPollution(currentChunk)) { + tList.add( + GT_Utility.trans("202", "Pollution in Chunk: ") + EnumChatFormatting.RED + + formatNumbers(GT_Pollution.getPollution(currentChunk)) + + EnumChatFormatting.RESET + + GT_Utility.trans("203", " gibbl")); + } else { + tList.add( + EnumChatFormatting.GREEN + GT_Utility.trans("204", "No Pollution in Chunk! HAYO!") + + EnumChatFormatting.RESET); + } + } + + private static void addUndergroundFluidInfo(EntityPlayer aPlayer, ArrayList tList, Chunk currentChunk) { if (aPlayer.capabilities.isCreativeMode) { final FluidStack tFluid = undergroundOilReadInformation(currentChunk); // -# to only read if (tFluid != null) tList.add( @@ -3529,47 +3342,303 @@ public static int getCoordinateScan(ArrayList aList, EntityPlayer aPlaye + EnumChatFormatting.RESET + " L"); } - // if(aPlayer.capabilities.isCreativeMode){ - if (GT_Pollution.hasPollution(currentChunk)) { - tList.add( - GT_Utility.trans("202", "Pollution in Chunk: ") + EnumChatFormatting.RED - + formatNumbers(GT_Pollution.getPollution(currentChunk)) - + EnumChatFormatting.RESET - + GT_Utility.trans("203", " gibbl")); - } else { - tList.add( - EnumChatFormatting.GREEN + GT_Utility.trans("204", "No Pollution in Chunk! HAYO!") - + EnumChatFormatting.RESET); + } + + private static int addForestryLeavesInfo(ArrayList tList, TileEntity tTileEntity) { + int rEUAmount = 0; + try { + if (tTileEntity instanceof forestry.arboriculture.tiles.TileLeaves tileLeaves) { + final forestry.api.arboriculture.ITree tree = tileLeaves.getTree(); + if (tree != null) { + rEUAmount += 1000; + if (!tree.isAnalyzed()) tree.analyze(); + tree.addTooltip(tList); + } + } + } catch (Throwable e) { + if (D1) e.printStackTrace(GT_Log.err); } + return rEUAmount; + } + private static int addIC2CropInfo(ArrayList tList, TileEntity tTileEntity) { + int rEUAmount = 0; + try { + if (tTileEntity instanceof ic2.api.crops.ICropTile crop) { + rEUAmount += 1000; + if (crop.getScanLevel() < 4) crop.setScanLevel((byte) 4); + if (crop.getCrop() != null) { + tList.add( + GT_Utility.trans("187", "Type -- Crop-Name: ") + crop.getCrop() + .name() + + GT_Utility.trans("188", " Growth: ") + + crop.getGrowth() + + GT_Utility.trans("189", " Gain: ") + + crop.getGain() + + GT_Utility.trans("190", " Resistance: ") + + crop.getResistance()); + } + tList.add( + GT_Utility.trans("191", "Plant -- Fertilizer: ") + crop.getNutrientStorage() + + GT_Utility.trans("192", " Water: ") + + crop.getHydrationStorage() + + GT_Utility.trans("193", " Weed-Ex: ") + + crop.getWeedExStorage() + + GT_Utility.trans("194", " Scan-Level: ") + + crop.getScanLevel()); + tList.add( + GT_Utility.trans("195", "Environment -- Nutrients: ") + crop.getNutrients() + + GT_Utility.trans("196", " Humidity: ") + + crop.getHumidity() + + GT_Utility.trans("197", " Air-Quality: ") + + crop.getAirQuality()); + if (crop.getCrop() != null) { + final StringBuilder tStringB = new StringBuilder(); + for (final String tAttribute : crop.getCrop() + .attributes()) { + tStringB.append(", ") + .append(tAttribute); + } + final String tString = tStringB.toString(); + tList.add(GT_Utility.trans("198", "Attributes:") + tString.replaceFirst(",", E)); + tList.add( + GT_Utility.trans("199", "Discovered by: ") + crop.getCrop() + .discoveredBy()); + } + } + } catch (Throwable e) { + if (D1) e.printStackTrace(GT_Log.err); + } + return rEUAmount; + } + + private static void addDeviceInfo(ArrayList tList, TileEntity tTileEntity) { + try { + if (tTileEntity instanceof IGregTechDeviceInformation info && info.isGivingInformation()) { + tList.addAll(Arrays.asList(info.getInfoData())); + } + } catch (Throwable e) { + if (D1) e.printStackTrace(GT_Log.err); + } + } + + private static void addOwnerInfo(ArrayList tList, TileEntity tTileEntity) { try { - if (tBlock instanceof IDebugableBlock) { + if (tTileEntity instanceof IGregTechTileEntity gtTE) { + tList.add( + GT_Utility.trans("186", "Owned by: ") + EnumChatFormatting.BLUE + + gtTE.getOwnerName() + + EnumChatFormatting.RESET); + } + } catch (Throwable e) { + if (D1) e.printStackTrace(GT_Log.err); + } + } + + private static void addEnergyContainerInfo(ArrayList tList, TileEntity tTileEntity) { + try { + if (tTileEntity instanceof IBasicEnergyContainer energyContainer && energyContainer.getEUCapacity() > 0) { + tList.add( + GT_Utility.trans("179", "Max IN: ") + EnumChatFormatting.RED + + formatNumbers(energyContainer.getInputVoltage()) + + " (" + + GT_Values.VN[getTier(energyContainer.getInputVoltage())] + + ") " + + EnumChatFormatting.RESET + + GT_Utility.trans("182", " EU at ") + + EnumChatFormatting.RED + + formatNumbers(energyContainer.getInputAmperage()) + + EnumChatFormatting.RESET + + GT_Utility.trans("183", " A")); + tList.add( + GT_Utility.trans("181", "Max OUT: ") + EnumChatFormatting.RED + + formatNumbers(energyContainer.getOutputVoltage()) + + " (" + + GT_Values.VN[getTier(energyContainer.getOutputVoltage())] + + ") " + + EnumChatFormatting.RESET + + GT_Utility.trans("182", " EU at ") + + EnumChatFormatting.RED + + formatNumbers(energyContainer.getOutputAmperage()) + + EnumChatFormatting.RESET + + GT_Utility.trans("183", " A")); + tList.add( + GT_Utility.trans("184", "Energy: ") + EnumChatFormatting.GREEN + + formatNumbers(energyContainer.getStoredEU()) + + EnumChatFormatting.RESET + + " EU / " + + EnumChatFormatting.YELLOW + + formatNumbers(energyContainer.getEUCapacity()) + + EnumChatFormatting.RESET + + " EU"); + } + } catch (Throwable e) { + if (D1) e.printStackTrace(GT_Log.err); + } + } + + private static int addCoverableInfo(ForgeDirection side, ArrayList tList, TileEntity tTileEntity) { + int rEUAmount = 0; + try { + if (tTileEntity instanceof ICoverable coverable) { + rEUAmount += 300; + final String tString = coverable.getCoverInfoAtSide(side) + .getBehaviorDescription(); + if (tString != null && !tString.equals(E)) tList.add(tString); + } + } catch (Throwable e) { + if (D1) e.printStackTrace(GT_Log.err); + } + return rEUAmount; + } + + private static int addMachineProgressInfo(ArrayList tList, TileEntity tTileEntity) { + int rEUAmount = 0; + try { + if (tTileEntity instanceof IMachineProgress progress) { + if (progress.isAllowedToWork()) { + tList.add(EnumChatFormatting.RED + "Disabled." + EnumChatFormatting.RESET); + } + if (progress.wasShutdown()) { + tList.add(EnumChatFormatting.RED + "Shut down due to power loss." + EnumChatFormatting.RESET); + } + rEUAmount += 400; + int tValue = 0; + if (0 < (tValue = progress.getMaxProgress())) tList.add( + GT_Utility.trans("178", "Progress/Load: ") + EnumChatFormatting.GREEN + + formatNumbers(progress.getProgress()) + + EnumChatFormatting.RESET + + " / " + + EnumChatFormatting.YELLOW + + formatNumbers(tValue) + + EnumChatFormatting.RESET); + } + } catch (Throwable e) { + if (D1) e.printStackTrace(GT_Log.err); + } + return rEUAmount; + } + + private static int addUpgradableMachineInfo(ArrayList tList, TileEntity tTileEntity) { + int rEUAmount = 0; + try { + if (tTileEntity instanceof IUpgradableMachine upgradableMachine) { rEUAmount += 500; - final ArrayList temp = ((IDebugableBlock) tBlock).getDebugInfo(aPlayer, aX, aY, aZ, 3); - if (temp != null) tList.addAll(temp); + if (upgradableMachine.hasMufflerUpgrade()) tList.add( + EnumChatFormatting.GREEN + GT_Utility.trans("177", "Has Muffler Upgrade") + + EnumChatFormatting.RESET); } } catch (Throwable e) { if (D1) e.printStackTrace(GT_Log.err); } + return rEUAmount; + } - final BlockScanningEvent tEvent = new BlockScanningEvent( - aWorld, - aPlayer, - aX, - aY, - aZ, - (byte) aSide, - aScanLevel, - tBlock, - tTileEntity, - tList, - aClickX, - aClickY, - aClickZ); - tEvent.mEUCost = rEUAmount; - MinecraftForge.EVENT_BUS.post(tEvent); - if (!tEvent.isCanceled()) aList.addAll(tList); - return tEvent.mEUCost; + private static int addIC2EnergyStorageInfo(ArrayList tList, TileEntity tTileEntity) { + int rEUAmount = 0; + try { + if (tTileEntity instanceof ic2.api.tile.IEnergyStorage storage) { + rEUAmount += 200; + tList.add( + GT_Utility.trans("176", "Contained Energy: ") + EnumChatFormatting.YELLOW + + formatNumbers(storage.getStored()) + + EnumChatFormatting.RESET + + " EU / " + + EnumChatFormatting.YELLOW + + formatNumbers(storage.getCapacity()) + + EnumChatFormatting.RESET + + " EU"); + } + } catch (Throwable e) { + if (D1) e.printStackTrace(GT_Log.err); + } + return rEUAmount; + } + + private static int addIC2EnergyConductorInfo(ArrayList tList, TileEntity tTileEntity) { + int rEUAmount = 0; + try { + if (tTileEntity instanceof ic2.api.energy.tile.IEnergyConductor conductor) { + rEUAmount += 200; + tList.add( + GT_Utility.trans("175", "Conduction Loss: ") + EnumChatFormatting.YELLOW + + conductor.getConductionLoss() + + EnumChatFormatting.RESET); + } + } catch (Throwable e) { + if (D1) e.printStackTrace(GT_Log.err); + } + return rEUAmount; + } + + private static int addIC2WrenchableInfo(EntityPlayer aPlayer, ArrayList tList, TileEntity tTileEntity) { + int rEUAmount = 0; + try { + if (tTileEntity instanceof ic2.api.tile.IWrenchable wrenchable) { + rEUAmount += 100; + tList.add( + GT_Utility.trans("171", "Facing: ") + EnumChatFormatting.GREEN + + wrenchable.getFacing() + + EnumChatFormatting.RESET + + GT_Utility.trans("172", " / Chance: ") + + EnumChatFormatting.YELLOW + + (wrenchable.getWrenchDropRate() * 100) + + EnumChatFormatting.RESET + + "%"); + tList.add( + wrenchable.wrenchCanRemove(aPlayer) + ? EnumChatFormatting.GREEN + GT_Utility.trans("173", "You can remove this with a Wrench") + + EnumChatFormatting.RESET + : EnumChatFormatting.RED + GT_Utility.trans("174", "You can NOT remove this with a Wrench") + + EnumChatFormatting.RESET); + } + } catch (Throwable e) { + if (D1) e.printStackTrace(GT_Log.err); + } + return rEUAmount; + } + + private static int addAlignmentInfo(ArrayList tList, TileEntity tTileEntity) { + int rEUAmount = 0; + try { + if (tTileEntity instanceof IAlignmentProvider alignmentProvider) { + final IAlignment tAlignment = alignmentProvider.getAlignment(); + if (tAlignment != null) { + rEUAmount += 100; + tList.add( + GT_Utility.trans("219", "Extended Facing: ") + EnumChatFormatting.GREEN + + tAlignment.getExtendedFacing() + + EnumChatFormatting.RESET); + } + } + } catch (Throwable e) { + if (D1) e.printStackTrace(GT_Log.err); + } + return rEUAmount; + } + + private static int addReactorInfo(ArrayList tList, TileEntity tTileEntity) { + int rEUAmount = 0; + try { + if (tTileEntity instanceof ic2.api.reactor.IReactor reactor) { + rEUAmount += 500; + tList.add( + GT_Utility.trans("168", "Heat: ") + EnumChatFormatting.GREEN + + formatNumbers(reactor.getHeat()) + + EnumChatFormatting.RESET + + " / " + + EnumChatFormatting.YELLOW + + formatNumbers(reactor.getMaxHeat()) + + EnumChatFormatting.RESET); + tList.add( + GT_Utility.trans("169", "HEM: ") + EnumChatFormatting.YELLOW + + reactor.getHeatEffectModifier() + + EnumChatFormatting.RESET); + } + } catch (Throwable e) { + if (D1) e.printStackTrace(GT_Log.err); + } + return rEUAmount; } public static String trans(String aKey, String aEnglish) { @@ -3584,14 +3653,14 @@ public static String getTrans(String aKey) { * @return an Array containing the X and the Y Coordinate of the clicked Point, with the top left Corner as Origin, * like on the Texture Sheet. return values should always be between [0.0F and 0.99F]. */ - public static float[] getClickedFacingCoords(byte aSide, float aX, float aY, float aZ) { - return switch (aSide) { - case 0 -> new float[] { Math.min(0.99F, Math.max(0, 1 - aX)), Math.min(0.99F, Math.max(0, aZ)) }; - case 1 -> new float[] { Math.min(0.99F, Math.max(0, aX)), Math.min(0.99F, Math.max(0, aZ)) }; - case 2 -> new float[] { Math.min(0.99F, Math.max(0, 1 - aX)), Math.min(0.99F, Math.max(0, 1 - aY)) }; - case 3 -> new float[] { Math.min(0.99F, Math.max(0, aX)), Math.min(0.99F, Math.max(0, 1 - aY)) }; - case 4 -> new float[] { Math.min(0.99F, Math.max(0, aZ)), Math.min(0.99F, Math.max(0, 1 - aY)) }; - case 5 -> new float[] { Math.min(0.99F, Math.max(0, 1 - aZ)), Math.min(0.99F, Math.max(0, 1 - aY)) }; + public static float[] getClickedFacingCoords(ForgeDirection side, float aX, float aY, float aZ) { + return switch (side) { + case DOWN -> new float[] { Math.min(0.99F, Math.max(0, 1 - aX)), Math.min(0.99F, Math.max(0, aZ)) }; + case UP -> new float[] { Math.min(0.99F, Math.max(0, aX)), Math.min(0.99F, Math.max(0, aZ)) }; + case NORTH -> new float[] { Math.min(0.99F, Math.max(0, 1 - aX)), Math.min(0.99F, Math.max(0, 1 - aY)) }; + case SOUTH -> new float[] { Math.min(0.99F, Math.max(0, aX)), Math.min(0.99F, Math.max(0, 1 - aY)) }; + case WEST -> new float[] { Math.min(0.99F, Math.max(0, aZ)), Math.min(0.99F, Math.max(0, 1 - aY)) }; + case EAST -> new float[] { Math.min(0.99F, Math.max(0, 1 - aZ)), Math.min(0.99F, Math.max(0, 1 - aY)) }; default -> new float[] { 0.5F, 0.5F }; }; } @@ -3600,56 +3669,56 @@ public static float[] getClickedFacingCoords(byte aSide, float aX, float aY, flo * This Function determines the direction a Block gets when being Wrenched. returns -1 if invalid. Even though that * could never happen. */ - public static byte determineWrenchingSide(byte aSide, float aX, float aY, float aZ) { - byte tBack = getOppositeSide(aSide); - switch (aSide) { - case 0, 1 -> { + public static ForgeDirection determineWrenchingSide(ForgeDirection side, float aX, float aY, float aZ) { + ForgeDirection tBack = side.getOpposite(); + switch (side) { + case DOWN, UP -> { if (aX < 0.25) { if (aZ < 0.25) return tBack; if (aZ > 0.75) return tBack; - return 4; + return WEST; } if (aX > 0.75) { if (aZ < 0.25) return tBack; if (aZ > 0.75) return tBack; - return 5; + return EAST; } - if (aZ < 0.25) return 2; - if (aZ > 0.75) return 3; - return aSide; + if (aZ < 0.25) return NORTH; + if (aZ > 0.75) return SOUTH; + return side; } - case 2, 3 -> { + case NORTH, SOUTH -> { if (aX < 0.25) { if (aY < 0.25) return tBack; if (aY > 0.75) return tBack; - return 4; + return WEST; } if (aX > 0.75) { if (aY < 0.25) return tBack; if (aY > 0.75) return tBack; - return 5; + return WEST; } - if (aY < 0.25) return 0; - if (aY > 0.75) return 1; - return aSide; + if (aY < 0.25) return DOWN; + if (aY > 0.75) return UP; + return side; } - case 4, 5 -> { + case WEST, EAST -> { if (aZ < 0.25) { if (aY < 0.25) return tBack; if (aY > 0.75) return tBack; - return 2; + return NORTH; } if (aZ > 0.75) { if (aY < 0.25) return tBack; if (aY > 0.75) return tBack; - return 3; + return SOUTH; } - if (aY < 0.25) return 0; - if (aY > 0.75) return 1; - return aSide; + if (aY < 0.25) return DOWN; + if (aY > 0.75) return UP; + return side; } } - return -1; + return UNKNOWN; } private static DecimalFormat getDecimalFormat() { @@ -3759,7 +3828,7 @@ public static boolean setBlockByFakePlayer(FakePlayer aPlayer, int aX, int aY, i if (aPlayer == null) return false; World aWorld = aPlayer.worldObj; BlockEvent.PlaceEvent event = ForgeEventFactory - .onPlayerBlockPlace(aPlayer, new BlockSnapshot(aWorld, aX, aY, aZ, aBlock, aMeta), ForgeDirection.UNKNOWN); + .onPlayerBlockPlace(aPlayer, new BlockSnapshot(aWorld, aX, aY, aZ, aBlock, aMeta), UNKNOWN); if (!event.isCanceled()) { if (!isSimulate) return aWorld.setBlock(aX, aY, aZ, aBlock, aMeta, 3); return true; diff --git a/src/main/java/gregtech/api/util/LightingHelper.java b/src/main/java/gregtech/api/util/LightingHelper.java index ad4e00fb7a9..ad2510e937e 100644 --- a/src/main/java/gregtech/api/util/LightingHelper.java +++ b/src/main/java/gregtech/api/util/LightingHelper.java @@ -14,6 +14,7 @@ import net.minecraft.client.renderer.EntityRenderer; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.Tessellator; +import net.minecraftforge.common.util.ForgeDirection; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -195,7 +196,7 @@ public LightingHelper setLightnessOverride(float lightness) { * @param side the side * @param rgba the primary short[] RGBA color array */ - public void setupColor(int side, short[] rgba) { + public void setupColor(ForgeDirection side, short[] rgba) { setupColor(side, getColor(rgba)); } @@ -205,9 +206,9 @@ public void setupColor(int side, short[] rgba) { * @param side the side * @param hexColor the primary color */ - public void setupColor(int side, int hexColor) { + public void setupColor(ForgeDirection side, int hexColor) { Tessellator tessellator = Tessellator.instance; - float lightness = hasLightnessOverride ? lightnessOverride : LIGHTNESS[side]; + float lightness = hasLightnessOverride ? lightnessOverride : LIGHTNESS[side.ordinal()]; float[] rgb = getRGB(hexColor); if (hasColorOverride && !renderBlocks.hasOverrideBlockTexture()) { @@ -306,14 +307,14 @@ public static float getMixedAo(float ao1, float ao2, double ratio) { * @see #setupLightingYPos(Block, int, int, int) * @see #setupLightingZPos(Block, int, int, int) */ - public LightingHelper setupLighting(Block block, int x, int y, int z, byte facing) { + public LightingHelper setupLighting(Block block, int x, int y, int z, ForgeDirection facing) { return switch (facing) { - case 0 -> setupLightingYNeg(block, x, y, z); - case 1 -> setupLightingYPos(block, x, y, z); - case 2 -> setupLightingZNeg(block, x, y, z); - case 3 -> setupLightingZPos(block, x, y, z); - case 4 -> setupLightingXNeg(block, x, y, z); - case 5 -> setupLightingXPos(block, x, y, z); + case DOWN -> setupLightingYNeg(block, x, y, z); + case UP -> setupLightingYPos(block, x, y, z); + case NORTH -> setupLightingZNeg(block, x, y, z); + case SOUTH -> setupLightingZPos(block, x, y, z); + case WEST -> setupLightingXNeg(block, x, y, z); + case EAST -> setupLightingXPos(block, x, y, z); default -> throw new IllegalArgumentException("Unknown side: " + facing); }; } diff --git a/src/main/java/gregtech/common/GT_Client.java b/src/main/java/gregtech/common/GT_Client.java index 4ae0204636c..5951f959942 100644 --- a/src/main/java/gregtech/common/GT_Client.java +++ b/src/main/java/gregtech/common/GT_Client.java @@ -331,9 +331,9 @@ private static void drawGrid(DrawBlockHighlightEvent aEvent, boolean showCoverCo byte tConnections = 0; if (tTile instanceof ICoverable) { if (showCoverConnections) { - for (byte tSide : ALL_VALID_SIDES) { + for (final ForgeDirection tSide : ForgeDirection.VALID_DIRECTIONS) { if (((ICoverable) tTile).getCoverIDAtSide(tSide) > 0) - tConnections = (byte) (tConnections + (1 << tSide)); + tConnections = (byte) (tConnections + (1 << tSide.ordinal())); } } else if (tTile instanceof BaseMetaPipeEntity) tConnections = ((BaseMetaPipeEntity) tTile).mConnections; } @@ -783,7 +783,7 @@ public void onDrawBlockHighlight(DrawBlockHighlightEvent aEvent) { || GT_Utility.isStackInList(aEvent.currentItem, GregTech_API.sSolderingToolList) || (GT_Utility.isStackInList(aEvent.currentItem, GregTech_API.sSoftHammerList) && aTileEntity instanceof MultiBlockPart) && aEvent.player.isSneaking()) { - if (((ICoverable) aTileEntity).getCoverIDAtSide((byte) aEvent.target.sideHit) == 0) + if (((ICoverable) aTileEntity).getCoverIDAtSide(ForgeDirection.getOrientation(aEvent.target.sideHit)) == 0) drawGrid(aEvent, false, false, aEvent.player.isSneaking()); return; } @@ -791,21 +791,23 @@ public void onDrawBlockHighlight(DrawBlockHighlightEvent aEvent) { if ((aEvent.currentItem == null && aEvent.player.isSneaking()) || GT_Utility.isStackInList(aEvent.currentItem, GregTech_API.sCrowbarList) || GT_Utility.isStackInList(aEvent.currentItem, GregTech_API.sScrewdriverList)) { - if (((ICoverable) aTileEntity).getCoverIDAtSide((byte) aEvent.target.sideHit) == 0) - for (byte tSide : ALL_VALID_SIDES) if (((ICoverable) aTileEntity).getCoverIDAtSide(tSide) > 0) { - drawGrid(aEvent, true, false, true); - return; + if (((ICoverable) aTileEntity).getCoverIDAtSide(ForgeDirection.getOrientation(aEvent.target.sideHit)) == 0) + for (final ForgeDirection tSide : ForgeDirection.VALID_DIRECTIONS) { + if (((ICoverable) aTileEntity).getCoverIDAtSide(tSide) > 0) { + drawGrid(aEvent, true, false, true); + return; + } } return; } if (GT_Utility.isStackInList(aEvent.currentItem, GregTech_API.sCovers.keySet())) { - if (((ICoverable) aTileEntity).getCoverIDAtSide((byte) aEvent.target.sideHit) == 0) + if (((ICoverable) aTileEntity).getCoverIDAtSide(ForgeDirection.getOrientation(aEvent.target.sideHit)) == 0) drawGrid(aEvent, true, false, aEvent.player.isSneaking()); } if (GT_Utility.areStacksEqual(ItemList.Tool_Cover_Copy_Paste.get(1), aEvent.currentItem, true)) { - if (((ICoverable) aTileEntity).getCoverIDAtSide((byte) aEvent.target.sideHit) == 0) + if (((ICoverable) aTileEntity).getCoverIDAtSide(ForgeDirection.getOrientation(aEvent.target.sideHit)) == 0) drawGrid(aEvent, true, false, aEvent.player.isSneaking()); } } diff --git a/src/main/java/gregtech/common/GT_Proxy.java b/src/main/java/gregtech/common/GT_Proxy.java index de36c1f1c8d..6d802a0789e 100644 --- a/src/main/java/gregtech/common/GT_Proxy.java +++ b/src/main/java/gregtech/common/GT_Proxy.java @@ -63,6 +63,7 @@ import net.minecraft.world.WorldSettings.GameType; import net.minecraft.world.gen.feature.WorldGenMinable; import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.event.ForgeEventFactory; import net.minecraftforge.event.entity.EntityJoinWorldEvent; import net.minecraftforge.event.entity.living.EnderTeleportEvent; @@ -2351,7 +2352,8 @@ public Object getClientGuiElement(int aID, EntityPlayer aPlayer, World aWorld, i if ((tTileEntity instanceof IGregTechTileEntity tile)) { if (GUI_ID_COVER_SIDE_BASE <= aID && aID < GUI_ID_COVER_SIDE_BASE + 6) { - final byte side = (byte) (aID - GT_Proxy.GUI_ID_COVER_SIDE_BASE); + final ForgeDirection side = ForgeDirection + .getOrientation((byte) (aID - GT_Proxy.GUI_ID_COVER_SIDE_BASE)); GT_CoverBehaviorBase cover = tile.getCoverBehaviorAtSideNew(side); if (cover.hasCoverGUI() && !cover.useModularUI()) { diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Casings1.java b/src/main/java/gregtech/common/blocks/GT_Block_Casings1.java index ea5c569ac71..7610bfa7691 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Casings1.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Casings1.java @@ -62,7 +62,7 @@ public int getTextureIndex(int aMeta) { } @Override - public IIcon getIcon(int aSide, int aMeta) { + public IIcon getIcon(int ordinalSide, int aMeta) { if ((aMeta >= 0) && (aMeta < 16)) { switch (aMeta) { case 10 -> { @@ -84,10 +84,10 @@ public IIcon getIcon(int aSide, int aMeta) { return Textures.BlockIcons.MACHINE_COIL_SUPERCONDUCTOR.getIcon(); } } - if (aSide == 0) { + if (ordinalSide == 0) { return Textures.BlockIcons.MACHINECASINGS_BOTTOM[aMeta].getIcon(); } - if (aSide == 1) { + if (ordinalSide == 1) { return Textures.BlockIcons.MACHINECASINGS_TOP[aMeta].getIcon(); } return Textures.BlockIcons.MACHINECASINGS_SIDE[aMeta].getIcon(); diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Casings2.java b/src/main/java/gregtech/common/blocks/GT_Block_Casings2.java index 14960eea107..c93d6139364 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Casings2.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Casings2.java @@ -67,7 +67,7 @@ public int getTextureIndex(int aMeta) { } @Override - public IIcon getIcon(int aSide, int aMeta) { + public IIcon getIcon(int ordinalSide, int aMeta) { return switch (aMeta) { case 0 -> Textures.BlockIcons.MACHINE_CASING_SOLID_STEEL.getIcon(); case 1 -> Textures.BlockIcons.MACHINE_CASING_FROST_PROOF.getIcon(); diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Casings3.java b/src/main/java/gregtech/common/blocks/GT_Block_Casings3.java index 92bb58aeadb..3d81a8de180 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Casings3.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Casings3.java @@ -51,7 +51,7 @@ public int getTextureIndex(int aMeta) { } @Override - public IIcon getIcon(int aSide, int aMeta) { + public IIcon getIcon(int ordinalSide, int aMeta) { return switch (aMeta) { case 0 -> Textures.BlockIcons.MACHINE_CASING_STRIPES_A.getIcon(); case 1 -> Textures.BlockIcons.MACHINE_CASING_STRIPES_B.getIcon(); @@ -66,11 +66,11 @@ public IIcon getIcon(int aSide, int aMeta) { case 10 -> Textures.BlockIcons.MACHINE_CASING_GRATE.getIcon(); case 11 -> Textures.BlockIcons.MACHINE_CASING_VENT.getIcon(); case 12 -> Textures.BlockIcons.MACHINE_CASING_RADIATIONPROOF.getIcon(); - case 13 -> aSide > 1 ? Textures.BlockIcons.MACHINE_CASING_FIREBOX_BRONZE.getIcon() + case 13 -> ordinalSide > 1 ? Textures.BlockIcons.MACHINE_CASING_FIREBOX_BRONZE.getIcon() : Textures.BlockIcons.MACHINE_BRONZEPLATEDBRICKS.getIcon(); - case 14 -> aSide > 1 ? Textures.BlockIcons.MACHINE_CASING_FIREBOX_STEEL.getIcon() + case 14 -> ordinalSide > 1 ? Textures.BlockIcons.MACHINE_CASING_FIREBOX_STEEL.getIcon() : Textures.BlockIcons.MACHINE_CASING_SOLID_STEEL.getIcon(); - case 15 -> aSide > 1 ? Textures.BlockIcons.MACHINE_CASING_FIREBOX_TUNGSTENSTEEL.getIcon() + case 15 -> ordinalSide > 1 ? Textures.BlockIcons.MACHINE_CASING_FIREBOX_TUNGSTENSTEEL.getIcon() : Textures.BlockIcons.MACHINE_CASING_ROBUST_TUNGSTENSTEEL.getIcon(); default -> Textures.BlockIcons.MACHINE_CASING_SOLID_STEEL.getIcon(); }; diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Casings4.java b/src/main/java/gregtech/common/blocks/GT_Block_Casings4.java index 5b1972b59ef..023f97d5b14 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Casings4.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Casings4.java @@ -86,12 +86,12 @@ public int getTextureIndex(int aMeta) { } @Override - public IIcon getIcon(int aSide, int aMeta) { + public IIcon getIcon(int ordinalSide, int aMeta) { return switch (aMeta) { case 0, 12 -> Textures.BlockIcons.MACHINE_CASING_ROBUST_TUNGSTENSTEEL.getIcon(); case 1, 10 -> Textures.BlockIcons.MACHINE_CASING_CLEAN_STAINLESSSTEEL.getIcon(); case 2, 11 -> Textures.BlockIcons.MACHINE_CASING_STABLE_TITANIUM.getIcon(); - case 3 -> aSide > 1 ? Textures.BlockIcons.MACHINE_CASING_FIREBOX_TITANIUM.getIcon() + case 3 -> ordinalSide > 1 ? Textures.BlockIcons.MACHINE_CASING_FIREBOX_TITANIUM.getIcon() : Textures.BlockIcons.MACHINE_CASING_STABLE_TITANIUM.getIcon(); case 4 -> // Do not overwrite! @@ -142,11 +142,11 @@ public IIcon getTurbineCasing(int meta, int iconIndex, boolean active, boolean h }; } - private static int isTurbineControllerWithSide(IBlockAccess aWorld, int aX, int aY, int aZ, int aSide) { + private static int isTurbineControllerWithSide(IBlockAccess aWorld, int aX, int aY, int aZ, int ordinalSide) { TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); if (!(tTileEntity instanceof IGregTechTileEntity tTile)) return 0; - if (tTile.getMetaTileEntity() instanceof GT_MetaTileEntity_LargeTurbine turbine - && tTile.getFrontFacing() == aSide) { + if (tTile.getMetaTileEntity() instanceof GT_MetaTileEntity_LargeTurbine turbine && tTile.getFrontFacing() + .ordinal() == ordinalSide) { if (turbine.isNewStyleRendering()) return 0; if (tTile.isActive()) return 1; return turbine.hasTurbine() ? 2 : 3; @@ -156,23 +156,27 @@ private static int isTurbineControllerWithSide(IBlockAccess aWorld, int aX, int @Override @SideOnly(Side.CLIENT) - public IIcon getIcon(IBlockAccess aWorld, int xCoord, int yCoord, int zCoord, int aSide) { + public IIcon getIcon(IBlockAccess aWorld, int xCoord, int yCoord, int zCoord, int ordinalSide) { aWorld = GT_RenderingWorld.getInstance(aWorld); int tMeta = aWorld.getBlockMetadata(xCoord, yCoord, zCoord); if (tMeta != 6 && tMeta != 8 && tMeta != 9 && tMeta != 10 && tMeta != 11 && tMeta != 12 || !mConnectedMachineTextures) { - return getIcon(aSide, tMeta); + return getIcon(ordinalSide, tMeta); } if (tMeta > 8 && tMeta < 13) { - int tInvertLeftRightMod = aSide % 2 * 2 - 1; - switch (aSide / 2) { + int tInvertLeftRightMod = ordinalSide % 2 * 2 - 1; + switch (ordinalSide / 2) { case 0 -> { for (int i = -1; i < 2; i++) { for (int j = -1; j < 2; j++) { if (i == 0 && j == 0) continue; int tState; - if ((tState = isTurbineControllerWithSide(aWorld, xCoord + j, yCoord, zCoord + i, aSide)) - != 0) { + if ((tState = isTurbineControllerWithSide( + aWorld, + xCoord + j, + yCoord, + zCoord + i, + ordinalSide)) != 0) { return getTurbineCasing(tMeta, 4 - i * 3 - j, tState == 1, tState == 2); } } @@ -183,8 +187,12 @@ public IIcon getIcon(IBlockAccess aWorld, int xCoord, int yCoord, int zCoord, in for (int j = -1; j < 2; j++) { if (i == 0 && j == 0) continue; int tState; - if ((tState = isTurbineControllerWithSide(aWorld, xCoord + j, yCoord + i, zCoord, aSide)) - != 0) { + if ((tState = isTurbineControllerWithSide( + aWorld, + xCoord + j, + yCoord + i, + zCoord, + ordinalSide)) != 0) { return getTurbineCasing( tMeta, 4 + i * 3 - j * tInvertLeftRightMod, @@ -199,8 +207,12 @@ public IIcon getIcon(IBlockAccess aWorld, int xCoord, int yCoord, int zCoord, in for (int j = -1; j < 2; j++) { if (i == 0 && j == 0) continue; int tState; - if ((tState = isTurbineControllerWithSide(aWorld, xCoord, yCoord + i, zCoord + j, aSide)) - != 0) { + if ((tState = isTurbineControllerWithSide( + aWorld, + xCoord, + yCoord + i, + zCoord + j, + ordinalSide)) != 0) { return getTurbineCasing( tMeta, 4 + i * 3 + j * tInvertLeftRightMod, @@ -226,7 +238,7 @@ public IIcon getIcon(IBlockAccess aWorld, int xCoord, int yCoord, int zCoord, in if (isSameBlock(aWorld, xCoord, yCoord, zCoord + 1, tMeta)) tIndexIntoMapping |= 1 << 3; if (isSameBlock(aWorld, xCoord - 1, yCoord, zCoord, tMeta)) tIndexIntoMapping |= 1 << 4; if (isSameBlock(aWorld, xCoord, yCoord, zCoord - 1, tMeta)) tIndexIntoMapping |= 1 << 5; - return Textures.BlockIcons.CONNECTED_HULLS[tStartIndex + mapping[aSide][tIndexIntoMapping]].getIcon(); + return Textures.BlockIcons.CONNECTED_HULLS[tStartIndex + mapping[ordinalSide][tIndexIntoMapping]].getIcon(); } private boolean isSameBlock(IBlockAccess aWorld, int aX, int aY, int aZ, int aMeta) { diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Casings5.java b/src/main/java/gregtech/common/blocks/GT_Block_Casings5.java index 50101dae493..d5746b43605 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Casings5.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Casings5.java @@ -57,7 +57,7 @@ public int getTextureIndex(int aMeta) { @Override @SideOnly(Side.CLIENT) - public IIcon getIcon(int aSide, int aMeta) { + public IIcon getIcon(int ordinalSide, int aMeta) { return switch (aMeta) { case 0 -> Textures.BlockIcons.MACHINE_COIL_CUPRONICKEL.getIcon(); case 1 -> Textures.BlockIcons.MACHINE_COIL_KANTHAL.getIcon(); diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Casings6.java b/src/main/java/gregtech/common/blocks/GT_Block_Casings6.java index cde7a8b5fad..d359a30df0f 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Casings6.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Casings6.java @@ -55,11 +55,11 @@ public int getTextureIndex(int aMeta) { @Override @SideOnly(Side.CLIENT) - public IIcon getIcon(int aSide, int aMeta) { - if (aSide == 0) { + public IIcon getIcon(int ordinalSide, int aMeta) { + if (ordinalSide == 0) { return Textures.BlockIcons.MACHINECASINGS_BOTTOM[aMeta].getIcon(); } - if (aSide == 1) { + if (ordinalSide == 1) { return Textures.BlockIcons.MACHINECASINGS_TOP[aMeta].getIcon(); } return switch (aMeta) { 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 b4778ec12e6..a864132549d 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Casings8.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Casings8.java @@ -74,7 +74,7 @@ public int getTextureIndex(int aMeta) { @Override @SideOnly(Side.CLIENT) - public IIcon getIcon(int aSide, int aMeta) { + public IIcon getIcon(int ordinalSide, int aMeta) { return switch (aMeta) { case 0 -> Textures.BlockIcons.MACHINE_CASING_CHEMICALLY_INERT.getIcon(); case 1 -> Textures.BlockIcons.MACHINE_CASING_PIPE_POLYTETRAFLUOROETHYLENE.getIcon(); @@ -117,11 +117,11 @@ public IIcon getTurbineCasing(int meta, int iconIndex, boolean active, boolean h }; } - private static int isTurbineControllerWithSide(IBlockAccess aWorld, int aX, int aY, int aZ, int aSide) { + private static int isTurbineControllerWithSide(IBlockAccess aWorld, int aX, int aY, int aZ, int ordinalSide) { TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); if (!(tTileEntity instanceof IGregTechTileEntity tTile)) return 0; - if (tTile.getMetaTileEntity() instanceof GT_MetaTileEntity_LargeTurbine turbine - && tTile.getFrontFacing() == aSide) { + if (tTile.getMetaTileEntity() instanceof GT_MetaTileEntity_LargeTurbine turbine && tTile.getFrontFacing() + .ordinal() == ordinalSide) { if (turbine.isNewStyleRendering()) return 0; if (tTile.isActive()) return 1; return turbine.hasTurbine() ? 2 : 3; @@ -131,22 +131,26 @@ private static int isTurbineControllerWithSide(IBlockAccess aWorld, int aX, int @Override @SideOnly(Side.CLIENT) - public IIcon getIcon(IBlockAccess aWorld, int xCoord, int yCoord, int zCoord, int aSide) { + public IIcon getIcon(IBlockAccess aWorld, int xCoord, int yCoord, int zCoord, int ordinalSide) { aWorld = GT_RenderingWorld.getInstance(aWorld); - int tMeta = aWorld.getBlockMetadata(xCoord, yCoord, zCoord); + final int tMeta = aWorld.getBlockMetadata(xCoord, yCoord, zCoord); if (tMeta != 9 || !mConnectedMachineTextures) { - return getIcon(aSide, tMeta); + return getIcon(ordinalSide, tMeta); } if (tMeta == 9) { - int tInvertLeftRightMod = aSide % 2 * 2 - 1; - switch (aSide / 2) { + int tInvertLeftRightMod = ordinalSide % 2 * 2 - 1; + switch (ordinalSide / 2) { case 0 -> { for (int i = -1; i < 2; i++) { for (int j = -1; j < 2; j++) { if (i == 0 && j == 0) continue; int tState; - if ((tState = isTurbineControllerWithSide(aWorld, xCoord + j, yCoord, zCoord + i, aSide)) - != 0) { + if ((tState = isTurbineControllerWithSide( + aWorld, + xCoord + j, + yCoord, + zCoord + i, + ordinalSide)) != 0) { return getTurbineCasing(tMeta, 4 - i * 3 - j, tState == 1, tState == 2); } } @@ -157,8 +161,12 @@ public IIcon getIcon(IBlockAccess aWorld, int xCoord, int yCoord, int zCoord, in for (int j = -1; j < 2; j++) { if (i == 0 && j == 0) continue; int tState; - if ((tState = isTurbineControllerWithSide(aWorld, xCoord + j, yCoord + i, zCoord, aSide)) - != 0) { + if ((tState = isTurbineControllerWithSide( + aWorld, + xCoord + j, + yCoord + i, + zCoord, + ordinalSide)) != 0) { return getTurbineCasing( tMeta, 4 + i * 3 - j * tInvertLeftRightMod, @@ -173,8 +181,12 @@ public IIcon getIcon(IBlockAccess aWorld, int xCoord, int yCoord, int zCoord, in for (int j = -1; j < 2; j++) { if (i == 0 && j == 0) continue; int tState; - if ((tState = isTurbineControllerWithSide(aWorld, xCoord, yCoord + i, zCoord + j, aSide)) - != 0) { + if ((tState = isTurbineControllerWithSide( + aWorld, + xCoord, + yCoord + i, + zCoord + j, + ordinalSide)) != 0) { return getTurbineCasing( tMeta, 4 + i * 3 + j * tInvertLeftRightMod, diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Casings9.java b/src/main/java/gregtech/common/blocks/GT_Block_Casings9.java index 0aa9ca916fb..3aa1756d0cb 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Casings9.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Casings9.java @@ -29,7 +29,7 @@ public int getTextureIndex(int aMeta) { @Override @SideOnly(Side.CLIENT) - public IIcon getIcon(int aSide, int aMeta) { + public IIcon getIcon(int ordinalSide, int aMeta) { return switch (aMeta) { case 0 -> Textures.BlockIcons.MACHINE_CASING_PIPE_POLYBENZIMIDAZOLE.getIcon(); case 1 -> Textures.BlockIcons.MACHINE_CASING_VENT_T2.getIcon(); diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Concretes.java b/src/main/java/gregtech/common/blocks/GT_Block_Concretes.java index ae3588cfa32..c7b7e2bb040 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Concretes.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Concretes.java @@ -63,7 +63,7 @@ public float getBlockHardness(World aWorld, int aX, int aY, int aZ) { } @Override - public IIcon getIcon(int aSide, int aMeta) { + public IIcon getIcon(int ordinalSide, int aMeta) { if ((aMeta >= 0) && (aMeta < 16)) { return gregtech.api.enums.Textures.BlockIcons.CONCRETES[aMeta].getIcon(); } diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Granites.java b/src/main/java/gregtech/common/blocks/GT_Block_Granites.java index df50c5223f8..69ebc2e7330 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Granites.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Granites.java @@ -63,7 +63,7 @@ public float getBlockHardness(World aWorld, int aX, int aY, int aZ) { } @Override - public IIcon getIcon(int aSide, int aMeta) { + public IIcon getIcon(int ordinalSide, int aMeta) { if ((aMeta >= 0) && (aMeta < 16)) { return gregtech.api.enums.Textures.BlockIcons.GRANITES[aMeta].getIcon(); } diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Machines.java b/src/main/java/gregtech/common/blocks/GT_Block_Machines.java index c9a93ecaec2..78044ed44bd 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Machines.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Machines.java @@ -1,8 +1,6 @@ package gregtech.common.blocks; import static gregtech.GT_Mod.GT_FML_LOGGER; -import static gregtech.api.enums.GT_Values.ALL_VALID_SIDES; -import static gregtech.api.enums.GT_Values.SIDE_UP; import static gregtech.api.objects.XSTR.XSTR_INSTANCE; import java.util.ArrayList; @@ -41,6 +39,7 @@ import gregtech.api.enums.Textures; import gregtech.api.interfaces.IDebugableBlock; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IColoredTileEntity; import gregtech.api.interfaces.tileentity.ICoverable; import gregtech.api.interfaces.tileentity.IDebugableTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; @@ -160,7 +159,7 @@ public boolean canCreatureSpawn(EnumCreatureType type, IBlockAccess aWorld, int } @Override - public boolean canConnectRedstone(IBlockAccess aWorld, int aX, int aY, int aZ, int aSide) { + public boolean canConnectRedstone(IBlockAccess aWorld, int aX, int aY, int aZ, int ordinalSide) { return true; } @@ -211,13 +210,13 @@ public TileEntity createNewTileEntity(World aWorld, int aMeta) { @SideOnly(Side.CLIENT) @Override - public IIcon getIcon(IBlockAccess aIBlockAccess, int aX, int aY, int aZ, int aSide) { + public IIcon getIcon(IBlockAccess aIBlockAccess, int aX, int aY, int aZ, int ordinalSide) { return Textures.BlockIcons.MACHINE_LV_SIDE.getIcon(); } @SideOnly(Side.CLIENT) @Override - public IIcon getIcon(int aSide, int aMeta) { + public IIcon getIcon(int ordinalSide, int aMeta) { return Textures.BlockIcons.MACHINE_LV_SIDE.getIcon(); } @@ -343,7 +342,7 @@ public float getPlayerRelativeBlockHardness(EntityPlayer aPlayer, World aWorld, } @Override - public boolean onBlockActivated(World aWorld, int aX, int aY, int aZ, EntityPlayer aPlayer, int aSide, + public boolean onBlockActivated(World aWorld, int aX, int aY, int aZ, EntityPlayer aPlayer, int ordinalSide, float aOffsetX, float aOffsetY, float aOffsetZ) { final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); if (tTileEntity == null) { @@ -356,15 +355,15 @@ public boolean onBlockActivated(World aWorld, int aX, int aY, int aZ, EntityPlay && !GT_Utility.isStackInList(tCurrentItem, GregTech_API.sWireCutterList) && !GT_Utility.isStackInList(tCurrentItem, GregTech_API.sSolderingToolList)) return false; } - if ((tTileEntity instanceof IGregTechTileEntity)) { - if (((IGregTechTileEntity) tTileEntity).getTimer() < 50L) { + if (tTileEntity instanceof IGregTechTileEntity gtTE) { + if (gtTE.getTimer() < 50L) { return false; } - if ((!aWorld.isRemote) && !((IGregTechTileEntity) tTileEntity).isUseableByPlayer(aPlayer)) { + if ((!aWorld.isRemote) && !gtTE.isUseableByPlayer(aPlayer)) { return true; } return ((IGregTechTileEntity) tTileEntity) - .onRightclick(aPlayer, (byte) aSide, aOffsetX, aOffsetY, aOffsetZ); + .onRightclick(aPlayer, ForgeDirection.getOrientation(ordinalSide), aOffsetX, aOffsetY, aOffsetZ); } return false; } @@ -372,16 +371,16 @@ public boolean onBlockActivated(World aWorld, int aX, int aY, int aZ, EntityPlay @Override public void onBlockClicked(World aWorld, int aX, int aY, int aZ, EntityPlayer aPlayer) { final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (tTileEntity instanceof IGregTechTileEntity) { - ((IGregTechTileEntity) tTileEntity).onLeftclick(aPlayer); + if (tTileEntity instanceof IGregTechTileEntity gtTE) { + gtTE.onLeftclick(aPlayer); } } @Override public int getDamageValue(World aWorld, int aX, int aY, int aZ) { final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (tTileEntity instanceof IGregTechTileEntity) { - return ((IGregTechTileEntity) tTileEntity).getMetaTileID(); + if (tTileEntity instanceof IGregTechTileEntity gtTE) { + return gtTE.getMetaTileID(); } return 0; } @@ -389,14 +388,14 @@ public int getDamageValue(World aWorld, int aX, int aY, int aZ) { @Override public void onBlockExploded(World aWorld, int aX, int aY, int aZ, Explosion aExplosion) { final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (tTileEntity instanceof BaseMetaTileEntity) { + if (tTileEntity instanceof BaseMetaTileEntity baseTE) { GT_Log.exp.printf( "Explosion at : %d | %d | %d DIMID: %s due to near explosion!%n", aX, aY, aZ, aWorld.provider.dimensionId); - ((BaseMetaTileEntity) tTileEntity).doEnergyExplosion(); + baseTE.doEnergyExplosion(); } super.onBlockExploded(aWorld, aX, aY, aZ, aExplosion); } @@ -405,15 +404,13 @@ public void onBlockExploded(World aWorld, int aX, int aY, int aZ, Explosion aExp public void breakBlock(World aWorld, int aX, int aY, int aZ, Block aBlock, int aMetadata) { GregTech_API.causeMachineUpdate(aWorld, aX, aY, aZ); final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (tTileEntity instanceof IGregTechTileEntity tGregTechTileEntity) { - tGregTechTileEntity.onBlockDestroyed(); - mTemporaryTileEntity.set(tGregTechTileEntity); - if (!(tGregTechTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_QuantumChest)) { - for (int i = 0; i < tGregTechTileEntity.getSizeInventory(); i++) { - final ItemStack tItem = tGregTechTileEntity.getStackInSlot(i); - if ((tItem != null) && (tItem.stackSize > 0) - && (tGregTechTileEntity.isValidSlot(i)) - && tGregTechTileEntity.shouldDropItemAt(i)) { + if (tTileEntity instanceof IGregTechTileEntity gtTE) { + gtTE.onBlockDestroyed(); + mTemporaryTileEntity.set(gtTE); + if (!(gtTE.getMetaTileEntity() instanceof GT_MetaTileEntity_QuantumChest)) { + for (int i = 0; i < gtTE.getSizeInventory(); i++) { + final ItemStack tItem = gtTE.getStackInSlot(i); + if ((tItem != null) && (tItem.stackSize > 0) && (gtTE.isValidSlot(i)) && gtTE.shouldDropItemAt(i)) { final EntityItem tItemEntity = new EntityItem( aWorld, aX + XSTR_INSTANCE.nextFloat() * 0.8F + 0.1F, @@ -431,7 +428,7 @@ public void breakBlock(World aWorld, int aX, int aY, int aZ, Block aBlock, int a tItemEntity.motionZ = (XSTR_INSTANCE.nextGaussian() * 0.05D); aWorld.spawnEntityInWorld(tItemEntity); tItem.stackSize = 0; - tGregTechTileEntity.setInventorySlotContents(i, null); + gtTE.setInventorySlotContents(i, null); } } } @@ -443,8 +440,8 @@ public void breakBlock(World aWorld, int aX, int aY, int aZ, Block aBlock, int a @Override public ArrayList getDrops(World aWorld, int aX, int aY, int aZ, int aMeta, int aFortune) { final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if ((tTileEntity instanceof IGregTechTileEntity)) { - return ((IGregTechTileEntity) tTileEntity).getDrops(); + if (tTileEntity instanceof IGregTechTileEntity gtTE) { + return gtTE.getDrops(); } final IGregTechTileEntity tGregTechTileEntity = mTemporaryTileEntity.get(); final ArrayList tDrops; @@ -470,34 +467,38 @@ public void harvestBlock(World aWorld, EntityPlayer aPlayer, int aX, int aY, int } @Override - public int getComparatorInputOverride(World aWorld, int aX, int aY, int aZ, int aSide) { + public int getComparatorInputOverride(World aWorld, int aX, int aY, int aZ, int ordinalSide) { final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (tTileEntity instanceof IGregTechTileEntity) { - return ((IGregTechTileEntity) tTileEntity).getComparatorValue((byte) aSide); + if (tTileEntity instanceof IGregTechTileEntity gtTE) { + return gtTE.getComparatorValue(ForgeDirection.getOrientation(ordinalSide)); } return 0; } @Override - public int isProvidingWeakPower(IBlockAccess aWorld, int aX, int aY, int aZ, int aSide) { - if (aSide < 0 || aSide > 5) { + public int isProvidingWeakPower(IBlockAccess aWorld, int aX, int aY, int aZ, int ordinalSide) { + if (ordinalSide < 0 || ordinalSide > 5) { return 0; } final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (tTileEntity instanceof IGregTechTileEntity) { - return ((IGregTechTileEntity) tTileEntity).getOutputRedstoneSignal(GT_Utility.getOppositeSide(aSide)); + if (tTileEntity instanceof IGregTechTileEntity gtTE) { + return gtTE.getOutputRedstoneSignal( + ForgeDirection.getOrientation(ordinalSide) + .getOpposite()); } return 0; } @Override - public int isProvidingStrongPower(IBlockAccess aWorld, int aX, int aY, int aZ, int aSide) { - if (aSide < 0 || aSide > 5) { + public int isProvidingStrongPower(IBlockAccess aWorld, int aX, int aY, int aZ, int ordinalSide) { + if (ordinalSide < 0 || ordinalSide > 5) { return 0; } final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (tTileEntity instanceof IGregTechTileEntity) { - return ((IGregTechTileEntity) tTileEntity).getStrongOutputRedstoneSignal(GT_Utility.getOppositeSide(aSide)); + if (tTileEntity instanceof IGregTechTileEntity gtTE) { + return gtTE.getStrongOutputRedstoneSignal( + ForgeDirection.getOrientation(ordinalSide) + .getOpposite()); } return 0; } @@ -508,14 +509,14 @@ public void dropBlockAsItemWithChance(World aWorld, int aX, int aY, int aZ, int if (!aWorld.isRemote) { final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); if (tTileEntity != null && (chance < 1.0F)) { - if (tTileEntity instanceof BaseMetaTileEntity && (GregTech_API.sMachineNonWrenchExplosions)) { + if (tTileEntity instanceof BaseMetaTileEntity bmte && (GregTech_API.sMachineNonWrenchExplosions)) { GT_Log.exp.printf( "Explosion at : %d | %d | %d DIMID: %s NonWrench picking/Rain!%n", aX, aY, aZ, aWorld.provider.dimensionId); - ((BaseMetaTileEntity) tTileEntity).doEnergyExplosion(); + bmte.doEnergyExplosion(); } } else { super.dropBlockAsItemWithChance(aWorld, aX, aY, aZ, aMetadata, chance, aFortune); @@ -524,7 +525,7 @@ public void dropBlockAsItemWithChance(World aWorld, int aX, int aY, int aZ, int } @Override - public boolean isSideSolid(IBlockAccess aWorld, int aX, int aY, int aZ, ForgeDirection aSide) { + public boolean isSideSolid(IBlockAccess aWorld, int aX, int aY, int aZ, ForgeDirection side) { if (aWorld.getBlockMetadata(aX, aY, aZ) == 0) { return true; } @@ -537,8 +538,7 @@ public boolean isSideSolid(IBlockAccess aWorld, int aX, int aY, int aZ, ForgeDir && (((BaseMetaPipeEntity) tTileEntity).mConnections & 0xFFFFFFC0) != 0) { return true; } - return tTileEntity instanceof ICoverable - && ((ICoverable) tTileEntity).getCoverIDAtSide((byte) aSide.ordinal()) != 0; + return tTileEntity instanceof ICoverable && ((ICoverable) tTileEntity).getCoverIDAtSide(side) != 0; } return false; } @@ -597,7 +597,7 @@ public float getExplosionResistance(Entity entity, World aWorld, int aX, int aY, double explosionY, double explosionZ) { final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); if (tTileEntity instanceof IGregTechTileEntity) { - return ((IGregTechTileEntity) tTileEntity).getBlastResistance((byte) 6); + return ((IGregTechTileEntity) tTileEntity).getBlastResistance(ForgeDirection.UNKNOWN); } return 10.0F; } @@ -617,7 +617,7 @@ public void onBlockPlacedBy(World aWorld, int aX, int aY, int aZ, EntityLivingBa final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); if (!(tTileEntity instanceof IGregTechTileEntity iGregTechTileEntity)) return; iGregTechTileEntity.setFrontFacing( - BaseTileEntity.getSideForPlayerPlacing(aPlayer, SIDE_UP, iGregTechTileEntity.getValidFacings())); + BaseTileEntity.getSideForPlayerPlacing(aPlayer, ForgeDirection.UP, iGregTechTileEntity.getValidFacings())); } @Override @@ -630,31 +630,31 @@ public ArrayList getDebugInfo(EntityPlayer aPlayer, int aX, int aY, int } @Override - public boolean recolourBlock(World aWorld, int aX, int aY, int aZ, ForgeDirection aSide, int aColor) { + public boolean recolourBlock(World aWorld, int aX, int aY, int aZ, ForgeDirection side, int aColor) { final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (tTileEntity instanceof IGregTechTileEntity) { - if (((IGregTechTileEntity) tTileEntity).getColorization() == (byte) ((~aColor) & 0xF)) { + if (tTileEntity instanceof IColoredTileEntity coloredTE) { + if (coloredTE.getColorization() == (byte) ((~aColor) & 0xF)) { return false; } - ((IGregTechTileEntity) tTileEntity).setColorization((byte) ((~aColor) & 0xF)); + coloredTE.setColorization((byte) ((~aColor) & 0xF)); return true; } return false; } @Override - public Block getFacade(IBlockAccess aWorld, int aX, int aY, int aZ, int side) { + public Block getFacade(IBlockAccess aWorld, int aX, int aY, int aZ, int ordinalSide) { final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); if (tTileEntity instanceof CoverableTileEntity tile) { - final byte aSide = (byte) side; - if (side != -1) { - final Block facadeBlock = tile.getCoverInfoAtSide(aSide) + final ForgeDirection dir = ForgeDirection.getOrientation(ordinalSide); + if (dir != ForgeDirection.UNKNOWN) { + final Block facadeBlock = tile.getCoverInfoAtSide(dir) .getFacadeBlock(); if (facadeBlock != null) return facadeBlock; } else { // we do not allow more than one type of facade per block, so no need to check every side // see comment in gregtech.common.covers.GT_Cover_FacadeBase.isCoverPlaceable - for (byte tSide : ALL_VALID_SIDES) { + for (final ForgeDirection tSide : ForgeDirection.VALID_DIRECTIONS) { final Block facadeBlock = tile.getCoverInfoAtSide(tSide) .getFacadeBlock(); if (facadeBlock != null) { @@ -667,19 +667,19 @@ public Block getFacade(IBlockAccess aWorld, int aX, int aY, int aZ, int side) { } @Override - public int getFacadeMetadata(IBlockAccess aWorld, int aX, int aY, int aZ, int side) { + public int getFacadeMetadata(IBlockAccess aWorld, int aX, int aY, int aZ, int ordinalSide) { final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); if (tTileEntity instanceof CoverableTileEntity tile) { - final byte aSide = (byte) side; - if (side != -1) { - final CoverInfo coverInfo = tile.getCoverInfoAtSide(aSide); + final ForgeDirection dir = ForgeDirection.getOrientation(ordinalSide); + if (ordinalSide != -1) { + final CoverInfo coverInfo = tile.getCoverInfoAtSide(dir); final Block facadeBlock = coverInfo.getFacadeBlock(); if (facadeBlock != null) return coverInfo.getFacadeMeta(); } else { // we do not allow more than one type of facade per block, so no need to check every side // see comment in gregtech.common.covers.GT_Cover_FacadeBase.isCoverPlaceable - for (byte tSide : ALL_VALID_SIDES) { - final CoverInfo coverInfo = tile.getCoverInfoAtSide(tSide); + for (final ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) { + final CoverInfo coverInfo = tile.getCoverInfoAtSide(d); final Block facadeBlock = coverInfo.getFacadeBlock(); if (facadeBlock != null) { return coverInfo.getFacadeMeta(); diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Metal.java b/src/main/java/gregtech/common/blocks/GT_Block_Metal.java index b8aa8b0e00b..753c590e512 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Metal.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Metal.java @@ -44,7 +44,7 @@ public GT_Block_Metal(String aName, Materials[] aMats, OrePrefixes aPrefix, IIco } @Override - public IIcon getIcon(int aSide, int aMeta) { + public IIcon getIcon(int ordinalSide, int aMeta) { if ((aMeta >= 0) && (aMeta < 16) && aMeta < mMats.length) { return mBlockIcons[aMeta].getIcon(); } diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Ores.java b/src/main/java/gregtech/common/blocks/GT_Block_Ores.java index 11768763a8d..1bfd24f75cd 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Ores.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Ores.java @@ -47,16 +47,16 @@ public String getUnlocalizedName() { @Override @SideOnly(Side.CLIENT) - public IIcon getIcon(int side, int meta) { + public IIcon getIcon(int ordinalSide, int meta) { int index = ((meta / 1000) % 16); return switch (index) { - case 1 -> Blocks.netherrack.getIcon(side, 0); - case 2 -> Blocks.end_stone.getIcon(side, 0); + case 1 -> Blocks.netherrack.getIcon(ordinalSide, 0); + case 2 -> Blocks.end_stone.getIcon(ordinalSide, 0); case 3 -> GRANITE_BLACK_STONE.getIcon(); case 4 -> GRANITE_RED_STONE.getIcon(); case 5 -> MARBLE_STONE.getIcon(); case 6 -> BASALT_STONE.getIcon(); - default -> Blocks.stone.getIcon(side, 0); + default -> Blocks.stone.getIcon(ordinalSide, 0); }; } diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Ores_Abstract.java b/src/main/java/gregtech/common/blocks/GT_Block_Ores_Abstract.java index 2a37aefa64e..8e68c5c39a9 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Ores_Abstract.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Ores_Abstract.java @@ -140,7 +140,7 @@ public String getLocalizedName(Materials aMaterial) { } @Override - public boolean onBlockActivated(World aWorld, int aX, int aY, int aZ, EntityPlayer aPlayer, int aSide, + public boolean onBlockActivated(World aWorld, int aX, int aY, int aZ, EntityPlayer aPlayer, int ordinalSide, float aOffsetX, float aOffsetY, float aOffsetZ) { if (!aPlayer.isSneaking() || !aPlayer.capabilities.isCreativeMode) { return false; @@ -233,13 +233,13 @@ public TileEntity createNewTileEntity(World aWorld, int aMeta) { @Override @SideOnly(Side.CLIENT) - public IIcon getIcon(IBlockAccess aIBlockAccess, int aX, int aY, int aZ, int aSide) { + public IIcon getIcon(IBlockAccess aIBlockAccess, int aX, int aY, int aZ, int ordinalSide) { return Blocks.stone.getIcon(0, 0); } @Override @SideOnly(Side.CLIENT) - public IIcon getIcon(int aSide, int aMeta) { + public IIcon getIcon(int ordinalSide, int aMeta) { return Blocks.stone.getIcon(0, 0); } 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 18f17fb3362..1849994e02e 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Reinforced.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Reinforced.java @@ -159,7 +159,7 @@ public int getHarvestLevel(int aMeta) { } @Override - public IIcon getIcon(int aSide, int aMeta) { + public IIcon getIcon(int ordinalSide, int aMeta) { if ((aMeta >= 0) && (aMeta < 16)) { switch (aMeta) { case 0 -> { @@ -379,15 +379,15 @@ public void onBlockExploded(World world, int x, int y, int z, Explosion explosio } @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float xOffset, - float yOffset, float zOffset) { + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int ordinalSide, + float xOffset, float yOffset, float zOffset) { if ((player.getCurrentEquippedItem() != null) && (player.getCurrentEquippedItem() .getItem() == Items.flint_and_steel) && world.getBlockMetadata(x, y, z) == 5) { removedByPlayer(world, player, x, y, z); return true; } - return super.onBlockActivated(world, x, y, z, player, side, xOffset, yOffset, zOffset); + return super.onBlockActivated(world, x, y, z, player, ordinalSide, xOffset, yOffset, zOffset); } @Override diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Stones.java b/src/main/java/gregtech/common/blocks/GT_Block_Stones.java index 253d9d21637..4ca52aee567 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Stones.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Stones.java @@ -53,7 +53,7 @@ public float getBlockHardness(World aWorld, int aX, int aY, int aZ) { } @Override - public IIcon getIcon(int aSide, int aMeta) { + public IIcon getIcon(int ordinalSide, int aMeta) { if ((aMeta >= 0) && (aMeta < 16)) { return gregtech.api.enums.Textures.BlockIcons.STONES[aMeta].getIcon(); } diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Stones_Abstract.java b/src/main/java/gregtech/common/blocks/GT_Block_Stones_Abstract.java index 45c0e38c308..138d7a6e8ab 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Stones_Abstract.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Stones_Abstract.java @@ -222,7 +222,7 @@ public boolean isNormalCube(IBlockAccess aWorld, int aX, int aY, int aZ) { } @Override - public IIcon getIcon(int aSide, int aMeta) { + public IIcon getIcon(int ordinalSide, int aMeta) { if ((aMeta >= 0) && (aMeta < 16)) { return gregtech.api.enums.Textures.BlockIcons.GRANITES[aMeta].getIcon(); } diff --git a/src/main/java/gregtech/common/blocks/GT_Cyclotron_Coils.java b/src/main/java/gregtech/common/blocks/GT_Cyclotron_Coils.java index 4e5768f1990..1a544f027f6 100644 --- a/src/main/java/gregtech/common/blocks/GT_Cyclotron_Coils.java +++ b/src/main/java/gregtech/common/blocks/GT_Cyclotron_Coils.java @@ -44,71 +44,71 @@ public int getTextureIndex(int aMeta) { } @Override - public IIcon getIcon(int aSide, int aMeta) { + public IIcon getIcon(int ordinalSide, int aMeta) { if ((aMeta >= 0) && (aMeta < 16)) { switch (aMeta) { case 0 -> { - if (aSide == 0 || aSide == 1) { + if (ordinalSide == 0 || ordinalSide == 1) { return Textures.BlockIcons.MV_TOP_CYCLOTRON_SOLENOID.getIcon(); } return Textures.BlockIcons.MV_SIDE_CYCLOTRON_SOLENOID.getIcon(); } case 1 -> { - if (aSide == 0 || aSide == 1) { + if (ordinalSide == 0 || ordinalSide == 1) { return Textures.BlockIcons.HV_TOP_CYCLOTRON_SOLENOID.getIcon(); } return Textures.BlockIcons.HV_SIDE_CYCLOTRON_SOLENOID.getIcon(); } case 2 -> { - if (aSide == 0 || aSide == 1) { + if (ordinalSide == 0 || ordinalSide == 1) { return Textures.BlockIcons.EV_TOP_CYCLOTRON_SOLENOID.getIcon(); } return Textures.BlockIcons.EV_SIDE_CYCLOTRON_SOLENOID.getIcon(); } case 3 -> { - if (aSide == 0 || aSide == 1) { + if (ordinalSide == 0 || ordinalSide == 1) { return Textures.BlockIcons.IV_TOP_CYCLOTRON_SOLENOID.getIcon(); } return Textures.BlockIcons.IV_SIDE_CYCLOTRON_SOLENOID.getIcon(); } case 4 -> { - if (aSide == 0 || aSide == 1) { + if (ordinalSide == 0 || ordinalSide == 1) { return Textures.BlockIcons.LuV_TOP_CYCLOTRON_SOLENOID.getIcon(); } return Textures.BlockIcons.LuV_SIDE_CYCLOTRON_SOLENOID.getIcon(); } case 5 -> { - if (aSide == 0 || aSide == 1) { + if (ordinalSide == 0 || ordinalSide == 1) { return Textures.BlockIcons.ZPM_TOP_CYCLOTRON_SOLENOID.getIcon(); } return Textures.BlockIcons.ZPM_SIDE_CYCLOTRON_SOLENOID.getIcon(); } case 6 -> { - if (aSide == 0 || aSide == 1) { + if (ordinalSide == 0 || ordinalSide == 1) { return Textures.BlockIcons.UV_TOP_CYCLOTRON_SOLENOID.getIcon(); } return Textures.BlockIcons.UV_SIDE_CYCLOTRON_SOLENOID.getIcon(); } case 7 -> { - if (aSide == 0 || aSide == 1) { + if (ordinalSide == 0 || ordinalSide == 1) { return Textures.BlockIcons.UHV_TOP_CYCLOTRON_SOLENOID.getIcon(); } return Textures.BlockIcons.UHV_SIDE_CYCLOTRON_SOLENOID.getIcon(); } case 8 -> { - if (aSide == 0 || aSide == 1) { + if (ordinalSide == 0 || ordinalSide == 1) { return Textures.BlockIcons.UEV_TOP_CYCLOTRON_SOLENOID.getIcon(); } return Textures.BlockIcons.UEV_SIDE_CYCLOTRON_SOLENOID.getIcon(); } case 9 -> { - if (aSide == 0 || aSide == 1) { + if (ordinalSide == 0 || ordinalSide == 1) { return Textures.BlockIcons.UIV_TOP_CYCLOTRON_SOLENOID.getIcon(); } return Textures.BlockIcons.UIV_SIDE_CYCLOTRON_SOLENOID.getIcon(); } case 10 -> { - if (aSide == 0 || aSide == 1) { + if (ordinalSide == 0 || ordinalSide == 1) { return Textures.BlockIcons.UMV_TOP_CYCLOTRON_SOLENOID.getIcon(); } return Textures.BlockIcons.UMV_SIDE_CYCLOTRON_SOLENOID.getIcon(); diff --git a/src/main/java/gregtech/common/blocks/GT_Item_Machines.java b/src/main/java/gregtech/common/blocks/GT_Item_Machines.java index 2e275bc7b3e..5bd6d0b62f8 100644 --- a/src/main/java/gregtech/common/blocks/GT_Item_Machines.java +++ b/src/main/java/gregtech/common/blocks/GT_Item_Machines.java @@ -17,6 +17,7 @@ import net.minecraft.potion.PotionEffect; import net.minecraft.util.EnumChatFormatting; import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.IFluidContainerItem; @@ -219,8 +220,8 @@ public void registerDescription(int aDamage) { } @Override - public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, - float hitX, float hitY, float hitZ) { + public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, + int ordinalSide, float hitX, float hitY, float hitZ) { return false; } @@ -270,8 +271,9 @@ public void onCreated(ItemStack aStack, World aWorld, EntityPlayer aPlayer) { } @Override - public boolean placeBlockAt(ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, int side, - float hitX, float hitY, float hitZ, int aMeta) { + public boolean placeBlockAt(ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, + int ordinalSide, float hitX, float hitY, float hitZ, int aMeta) { + final ForgeDirection side = ForgeDirection.getOrientation(ordinalSide); final short tDamage = (short) getDamage(aStack); if (tDamage > 0) { if (GregTech_API.METATILEENTITIES[tDamage] == null) { @@ -298,15 +300,15 @@ public boolean placeBlockAt(ItemStack aStack, EntityPlayer aPlayer, World aWorld } tTileEntity.getMetaTileEntity() .initDefaultModes(aStack.getTagCompound()); - final byte aSide = GT_Utility.getOppositeSide(side); - if (tTileEntity.getMetaTileEntity() instanceof IConnectable) { + final ForgeDirection oppositeSide = side.getOpposite(); + if (tTileEntity.getMetaTileEntity() instanceof IConnectable connectable) { // If we're connectable, try connecting to whatever we're up against - ((IConnectable) tTileEntity.getMetaTileEntity()).connect(aSide); + connectable.connect(oppositeSide); } else if (aPlayer != null && aPlayer.isSneaking()) { // If we're being placed against something that is connectable, try telling it to connect to us - final IGregTechTileEntity aTileEntity = tTileEntity.getIGregTechTileEntityAtSide(aSide); - if (aTileEntity != null && aTileEntity.getMetaTileEntity() instanceof IConnectable) { - ((IConnectable) aTileEntity.getMetaTileEntity()).connect((byte) side); + final IGregTechTileEntity aTileEntity = tTileEntity.getIGregTechTileEntityAtSide(oppositeSide); + if (aTileEntity != null && aTileEntity.getMetaTileEntity() instanceof IConnectable connectable) { + connectable.connect(side); } } } diff --git a/src/main/java/gregtech/common/blocks/GT_Item_Ores.java b/src/main/java/gregtech/common/blocks/GT_Item_Ores.java index 03a25915422..2ba78572b30 100644 --- a/src/main/java/gregtech/common/blocks/GT_Item_Ores.java +++ b/src/main/java/gregtech/common/blocks/GT_Item_Ores.java @@ -24,8 +24,8 @@ public GT_Item_Ores(Block block) { } @Override - public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, - float hitX, float hitY, float hitZ) { + public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, + int ordinalSide, float hitX, float hitY, float hitZ) { return false; } @@ -44,8 +44,8 @@ public String getItemStackDisplayName(ItemStack aStack) { } @Override - public boolean placeBlockAt(ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, int side, - float hitX, float hitY, float hitZ, int aMeta) { + public boolean placeBlockAt(ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, + int ordinalSide, float hitX, float hitY, float hitZ, int aMeta) { short tDamage = (short) getDamage(aStack); if (tDamage > 0) { if (!aWorld.setBlock( diff --git a/src/main/java/gregtech/common/blocks/GT_TileEntity_Ores.java b/src/main/java/gregtech/common/blocks/GT_TileEntity_Ores.java index 4add136ab52..318cfcabd10 100644 --- a/src/main/java/gregtech/common/blocks/GT_TileEntity_Ores.java +++ b/src/main/java/gregtech/common/blocks/GT_TileEntity_Ores.java @@ -12,6 +12,7 @@ import net.minecraft.network.Packet; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; import gregtech.GT_Mod; import gregtech.api.GregTech_API; @@ -387,7 +388,7 @@ public ArrayList getDrops(Block aDroppedOre, int aFortune) { } @Override - public ITexture[] getTexture(Block aBlock, byte aSide) { + public ITexture[] getTexture(Block aBlock, ForgeDirection side) { Materials aMaterial = GregTech_API.sGeneratedMaterials[(this.mMetaData % 1000)]; if ((aMaterial != null) && (this.mMetaData < 32000)) { ITexture iTexture = TextureFactory.builder() diff --git a/src/main/java/gregtech/common/covers/CoverInfo.java b/src/main/java/gregtech/common/covers/CoverInfo.java index 0c3cf6986fa..e63fe6e176f 100644 --- a/src/main/java/gregtech/common/covers/CoverInfo.java +++ b/src/main/java/gregtech/common/covers/CoverInfo.java @@ -1,13 +1,12 @@ package gregtech.common.covers; -import static gregtech.api.enums.GT_Values.SIDE_UNKNOWN; - import java.lang.ref.WeakReference; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.Fluid; import com.gtnewhorizons.modularui.api.screen.ModularWindow; @@ -23,21 +22,21 @@ public final class CoverInfo { private static final String NBT_SIDE = "s", NBT_ID = "id", NBT_DATA = "d"; - public static final CoverInfo EMPTY_INFO = new CoverInfo(SIDE_UNKNOWN, null); - private byte coverSide; + public static final CoverInfo EMPTY_INFO = new CoverInfo(ForgeDirection.UNKNOWN, null); + private final ForgeDirection coverSide; private int coverID = 0; private GT_CoverBehaviorBase coverBehavior = null; private ISerializableObject coverData = null; private final WeakReference coveredTile; private boolean needsUpdate = false; - public CoverInfo(byte aSide, ICoverable aTile) { - coverSide = aSide; + public CoverInfo(ForgeDirection side, ICoverable aTile) { + coverSide = side; coveredTile = new WeakReference<>(aTile); } - public CoverInfo(byte aSide, int aID, ICoverable aTile, ISerializableObject aCoverData) { - coverSide = aSide; + public CoverInfo(ForgeDirection side, int aID, ICoverable aTile, ISerializableObject aCoverData) { + coverSide = side; coverID = aID; coverBehavior = GregTech_API.getCoverBehaviorNew(aID); coverData = aCoverData == null ? coverBehavior.createDataObject() : aCoverData; @@ -45,7 +44,7 @@ public CoverInfo(byte aSide, int aID, ICoverable aTile, ISerializableObject aCov } public CoverInfo(ICoverable aTile, NBTTagCompound aNBT) { - coverSide = aNBT.getByte(NBT_SIDE); + coverSide = ForgeDirection.getOrientation(aNBT.getByte(NBT_SIDE)); coverID = aNBT.getInteger(NBT_ID); coverBehavior = GregTech_API.getCoverBehaviorNew(coverID); coverData = aNBT.hasKey(NBT_DATA) ? coverBehavior.createDataObject(aNBT.getTag(NBT_DATA)) @@ -54,11 +53,11 @@ public CoverInfo(ICoverable aTile, NBTTagCompound aNBT) { } public boolean isValid() { - return coverID != 0 && coverSide != SIDE_UNKNOWN; + return coverID != 0 && coverSide != ForgeDirection.UNKNOWN; } public NBTTagCompound writeToNBT(NBTTagCompound aNBT) { - aNBT.setByte(NBT_SIDE, coverSide); + aNBT.setByte(NBT_SIDE, (byte) coverSide.ordinal()); aNBT.setInteger(NBT_ID, coverID); if (coverData != null) aNBT.setTag(NBT_DATA, coverData.saveDataToNBT()); @@ -123,7 +122,7 @@ public int getTickRate() { return getCoverBehavior().getTickRate(coverSide, coverID, coverData, coveredTile.get()); } - public byte getSide() { + public ForgeDirection getSide() { return coverSide; } 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 f2c2a65f3af..6bd41e1a25f 100644 --- a/src/main/java/gregtech/common/covers/GT_Cover_Arm.java +++ b/src/main/java/gregtech/common/covers/GT_Cover_Arm.java @@ -4,6 +4,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.Fluid; import com.gtnewhorizons.modularui.api.math.MathExpression; @@ -51,14 +52,14 @@ public GT_Cover_Arm(int aTickRate, ITexture coverTexture) { } @Override - public boolean isRedstoneSensitive(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, + public boolean isRedstoneSensitive(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) { return false; } @Override - public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity, - long aTimer) { + public int doCoverThings(ForgeDirection side, byte aInputRedstone, int aCoverID, int aCoverVariable, + ICoverable aTileEntity, long aTimer) { if ((((aTileEntity instanceof IMachineProgress)) && (!((IMachineProgress) aTileEntity).isAllowedToWork()))) { return aCoverVariable; } @@ -70,41 +71,44 @@ public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCov aCoverVariable = CONVERTED_BIT | Math.min(Math.abs(aCoverVariable - 1), SLOT_ID_MASK); } - TileEntity toTile, fromTile; - int toSlot, fromSlot; + final TileEntity toTile; + final TileEntity fromTile; + final int toSlot; + final int fromSlot; if ((aCoverVariable & EXPORT_MASK) > 0) { fromTile = (TileEntity) aTileEntity; - toTile = aTileEntity.getTileEntityAtSide(aSide); + toTile = aTileEntity.getTileEntityAtSide(side); fromSlot = aCoverVariable & SLOT_ID_MASK; toSlot = (aCoverVariable >> 14) & SLOT_ID_MASK; } else { - fromTile = aTileEntity.getTileEntityAtSide(aSide); + fromTile = aTileEntity.getTileEntityAtSide(side); toTile = (TileEntity) aTileEntity; fromSlot = (aCoverVariable >> 14) & SLOT_ID_MASK; toSlot = aCoverVariable & SLOT_ID_MASK; } if (fromSlot > 0 && toSlot > 0) { - if (fromTile instanceof IInventory && toTile instanceof IInventory) GT_Utility.moveFromSlotToSlot( - (IInventory) fromTile, - (IInventory) toTile, - fromSlot - 1, - toSlot - 1, - null, - false, - (byte) 64, - (byte) 1, - (byte) 64, - (byte) 1); + if (fromTile instanceof IInventory fromInventory && toTile instanceof IInventory toInventory) + GT_Utility.moveFromSlotToSlot( + fromInventory, + toInventory, + 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); + final ForgeDirection toSide; + if ((aCoverVariable & EXPORT_MASK) > 0) toSide = side; + else toSide = side.getOpposite(); GT_Utility.moveOneItemStackIntoSlot( fromTile, toTile, - side, + toSide, toSlot - 1, null, false, @@ -113,9 +117,9 @@ public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCov (byte) 64, (byte) 1); } else if (fromSlot > 0) { - byte toSide; - if ((aCoverVariable & EXPORT_MASK) > 0) toSide = aSide; - else toSide = GT_Utility.getOppositeSide(aSide); + final ForgeDirection toSide; + if ((aCoverVariable & EXPORT_MASK) > 0) toSide = side; + else toSide = side.getOpposite(); if (fromTile instanceof IInventory) GT_Utility.moveFromSlotToSide( (IInventory) fromTile, toTile, @@ -128,13 +132,14 @@ public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCov (byte) 64, (byte) 1); } else { - byte fromSide, toSide; + final ForgeDirection fromSide; + final ForgeDirection toSide; if ((aCoverVariable & EXPORT_MASK) > 0) { - fromSide = aSide; - toSide = GT_Utility.getOppositeSide(aSide); + fromSide = side; + toSide = side.getOpposite(); } else { - fromSide = GT_Utility.getOppositeSide(aSide); - toSide = aSide; + fromSide = side.getOpposite(); + toSide = side; } GT_Utility.moveOneItemStack( fromTile, @@ -153,10 +158,10 @@ public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCov } @Override - public int onCoverScrewdriverclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, + public int onCoverScrewdriverclick(ForgeDirection side, 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) { + if (GT_Utility.getClickedFacingCoords(side, aX, aY, aZ)[0] >= 0.5F) { step += aPlayer.isSneaking() ? 256 : 16; } else { step -= aPlayer.isSneaking() ? 256 : 16; @@ -167,10 +172,10 @@ public int onCoverScrewdriverclick(byte aSide, int aCoverID, int aCoverVariable, } @Override - protected boolean onCoverRightClickImpl(byte aSide, int aCoverID, + protected boolean onCoverRightClickImpl(ForgeDirection side, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) { - int step = (GT_Utility.getClickedFacingCoords(aSide, aX, aY, aZ)[0] >= 0.5F) ? 1 : -1; + int step = (GT_Utility.getClickedFacingCoords(side, aX, aY, aZ)[0] >= 0.5F) ? 1 : -1; int tCoverVariable = getNewVar(aCoverVariable.get(), step); sendMessageToPlayer(aPlayer, tCoverVariable); aCoverVariable.set(tCoverVariable); @@ -179,12 +184,12 @@ protected boolean onCoverRightClickImpl(byte aSide, int aCoverID, @Override @SuppressWarnings("deprecation") - public boolean onCoverRightclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, + public boolean onCoverRightclick(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) { - int step = (GT_Utility.getClickedFacingCoords(aSide, aX, aY, aZ)[0] >= 0.5F) ? 1 : -1; + final int step = (GT_Utility.getClickedFacingCoords(side, aX, aY, aZ)[0] >= 0.5F) ? 1 : -1; aCoverVariable = getNewVar(aCoverVariable, step); sendMessageToPlayer(aPlayer, aCoverVariable); - aTileEntity.setCoverDataAtSide(aSide, aCoverVariable); + aTileEntity.setCoverDataAtSide(side, aCoverVariable); return true; } @@ -217,52 +222,56 @@ private int createVar(int adjSlot, int intSlot, int export) { } @Override - public boolean letsRedstoneGoIn(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public boolean letsRedstoneGoIn(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return true; } @Override - public boolean letsRedstoneGoOut(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public boolean letsRedstoneGoOut(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return true; } @Override - public boolean letsEnergyIn(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public boolean letsEnergyIn(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return true; } @Override - public boolean letsEnergyOut(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public boolean letsEnergyOut(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return true; } @Override - public boolean letsFluidIn(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { + public boolean letsFluidIn(ForgeDirection side, int aCoverID, int aCoverVariable, Fluid aFluid, + ICoverable aTileEntity) { return true; } @Override - public boolean letsFluidOut(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { + public boolean letsFluidOut(ForgeDirection side, int aCoverID, int aCoverVariable, Fluid aFluid, + ICoverable aTileEntity) { return true; } @Override - public boolean letsItemsIn(byte aSide, int aCoverID, int aCoverVariable, int aSlot, ICoverable aTileEntity) { + public boolean letsItemsIn(ForgeDirection side, int aCoverID, int aCoverVariable, int aSlot, + ICoverable aTileEntity) { return true; } @Override - public boolean letsItemsOut(byte aSide, int aCoverID, int aCoverVariable, int aSlot, ICoverable aTileEntity) { + public boolean letsItemsOut(ForgeDirection side, int aCoverID, int aCoverVariable, int aSlot, + ICoverable aTileEntity) { return true; } @Override - public boolean alwaysLookConnected(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public boolean alwaysLookConnected(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return true; } @Override - public int getTickRate(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public int getTickRate(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return this.mTickRate; } 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 872371a3553..5145777f065 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,8 @@ package gregtech.common.covers; -import static gregtech.api.enums.GT_Values.ALL_VALID_SIDES; - import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.Fluid; import com.gtnewhorizons.modularui.api.screen.ModularWindow; @@ -36,9 +35,9 @@ public GT_Cover_ControlsWork(ITexture coverTexture) { } @Override - public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity, - long aTimer) { - if (!makeSureOnlyOne(aSide, aTileEntity)) return 0; + public int doCoverThings(ForgeDirection side, byte aInputRedstone, int aCoverID, int aCoverVariable, + ICoverable aTileEntity, long aTimer) { + if (!makeSureOnlyOne(side, aTileEntity)) return 0; if (aTileEntity instanceof IMachineProgress machine) { if (aCoverVariable < 2) { if ((aInputRedstone > 0) == (aCoverVariable == 0)) { @@ -64,7 +63,7 @@ public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCov } return 2; } else { - return 3 + doCoverThings(aSide, aInputRedstone, aCoverID, aCoverVariable - 3, aTileEntity, aTimer); + return 3 + doCoverThings(side, aInputRedstone, aCoverID, aCoverVariable - 3, aTileEntity, aTimer); } } } @@ -72,7 +71,7 @@ public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCov } @Override - protected boolean isRedstoneSensitiveImpl(byte aSide, int aCoverID, + protected boolean isRedstoneSensitiveImpl(ForgeDirection side, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity, long aTimer) { return aCoverVariable.get() != 2; // always off, so no redstone needed either } @@ -83,42 +82,46 @@ protected boolean isRedstoneSensitiveImpl(byte aSide, int aCoverID, * * @return true if the cover is the first (side) one **/ - private boolean makeSureOnlyOne(byte aSide, ICoverable aTileEntity) { - return IControlsWorkCover.makeSureOnlyOne(aSide, aTileEntity); + private boolean makeSureOnlyOne(ForgeDirection side, ICoverable aTileEntity) { + return IControlsWorkCover.makeSureOnlyOne(side, aTileEntity); } @Override - public boolean letsEnergyIn(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public boolean letsEnergyIn(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return true; } @Override - public boolean letsEnergyOut(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public boolean letsEnergyOut(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return true; } @Override - public boolean letsFluidIn(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { + public boolean letsFluidIn(ForgeDirection side, int aCoverID, int aCoverVariable, Fluid aFluid, + ICoverable aTileEntity) { return true; } @Override - public boolean letsFluidOut(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { + public boolean letsFluidOut(ForgeDirection side, int aCoverID, int aCoverVariable, Fluid aFluid, + ICoverable aTileEntity) { return true; } @Override - public boolean letsItemsIn(byte aSide, int aCoverID, int aCoverVariable, int aSlot, ICoverable aTileEntity) { + public boolean letsItemsIn(ForgeDirection side, int aCoverID, int aCoverVariable, int aSlot, + ICoverable aTileEntity) { return true; } @Override - public boolean letsItemsOut(byte aSide, int aCoverID, int aCoverVariable, int aSlot, ICoverable aTileEntity) { + public boolean letsItemsOut(ForgeDirection side, int aCoverID, int aCoverVariable, int aSlot, + ICoverable aTileEntity) { return true; } @Override - public boolean onCoverRemoval(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, + public boolean onCoverRemoval(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity, boolean aForced) { if ((aTileEntity instanceof IMachineProgress)) { ((IMachineProgress) aTileEntity).enableWorking(); @@ -128,7 +131,7 @@ public boolean onCoverRemoval(byte aSide, int aCoverID, int aCoverVariable, ICov } @Override - public int onCoverScrewdriverclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, + public int onCoverScrewdriverclick(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) { aCoverVariable = (aCoverVariable + (aPlayer.isSneaking() ? -1 : 1)) % 5; if (aCoverVariable < 0) { @@ -154,14 +157,14 @@ public int onCoverScrewdriverclick(byte aSide, int aCoverID, int aCoverVariable, } @Override - public int getTickRate(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public int getTickRate(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return 1; } @Override - public boolean isCoverPlaceable(byte aSide, ItemStack aStack, ICoverable aTileEntity) { - if (!super.isCoverPlaceable(aSide, aStack, aTileEntity)) return false; - for (byte tSide : ALL_VALID_SIDES) { + public boolean isCoverPlaceable(ForgeDirection side, ItemStack aStack, ICoverable aTileEntity) { + if (!super.isCoverPlaceable(side, aStack, aTileEntity)) return false; + for (final ForgeDirection tSide : ForgeDirection.VALID_DIRECTIONS) { if (aTileEntity.getCoverBehaviorAtSideNew(tSide) instanceof IControlsWorkCover) { return false; } 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 80d7dff6aec..bbea07b450e 100644 --- a/src/main/java/gregtech/common/covers/GT_Cover_Conveyor.java +++ b/src/main/java/gregtech/common/covers/GT_Cover_Conveyor.java @@ -4,6 +4,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.Fluid; import com.gtnewhorizons.modularui.api.screen.ModularWindow; @@ -48,24 +49,24 @@ public GT_Cover_Conveyor(int aTickRate, int maxStacks, ITexture coverTexture) { } @Override - public boolean isRedstoneSensitive(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, + public boolean isRedstoneSensitive(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) { return false; } @Override - public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity, - long aTimer) { + public int doCoverThings(ForgeDirection side, byte aInputRedstone, int aCoverID, int aCoverVariable, + ICoverable aTileEntity, long aTimer) { if ((aCoverVariable % 6 > 1) && ((aTileEntity instanceof IMachineProgress))) { if (((IMachineProgress) aTileEntity).isAllowedToWork() != aCoverVariable % 6 < 4) { return aCoverVariable; } } - final TileEntity tTileEntity = aTileEntity.getTileEntityAtSide(aSide); + final TileEntity tTileEntity = aTileEntity.getTileEntityAtSide(side); final Object fromEntity = aCoverVariable % 2 == 0 ? aTileEntity : tTileEntity; final Object toEntity = aCoverVariable % 2 != 0 ? aTileEntity : tTileEntity; - final byte fromSide = aCoverVariable % 2 != 0 ? GT_Utility.getOppositeSide(aSide) : aSide; - final byte toSide = aCoverVariable % 2 == 0 ? GT_Utility.getOppositeSide(aSide) : aSide; + final ForgeDirection fromSide = aCoverVariable % 2 != 0 ? side.getOpposite() : side; + final ForgeDirection toSide = aCoverVariable % 2 == 0 ? side.getOpposite() : side; moveMultipleItemStacks( fromEntity, @@ -84,7 +85,7 @@ public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCov } @Override - public int onCoverScrewdriverclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, + public int onCoverScrewdriverclick(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) { aCoverVariable = (aCoverVariable + (aPlayer.isSneaking() ? -1 : 1)) % 12; if (aCoverVariable < 0) { @@ -111,52 +112,56 @@ public int onCoverScrewdriverclick(byte aSide, int aCoverID, int aCoverVariable, } @Override - public boolean letsRedstoneGoIn(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public boolean letsRedstoneGoIn(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return true; } @Override - public boolean letsRedstoneGoOut(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public boolean letsRedstoneGoOut(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return true; } @Override - public boolean letsEnergyIn(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public boolean letsEnergyIn(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return true; } @Override - public boolean letsEnergyOut(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public boolean letsEnergyOut(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return true; } @Override - public boolean letsFluidIn(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { + public boolean letsFluidIn(ForgeDirection side, int aCoverID, int aCoverVariable, Fluid aFluid, + ICoverable aTileEntity) { return true; } @Override - public boolean letsFluidOut(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { + public boolean letsFluidOut(ForgeDirection side, int aCoverID, int aCoverVariable, Fluid aFluid, + ICoverable aTileEntity) { return true; } @Override - public boolean letsItemsIn(byte aSide, int aCoverID, int aCoverVariable, int aSlot, ICoverable aTileEntity) { + public boolean letsItemsIn(ForgeDirection side, int aCoverID, int aCoverVariable, int aSlot, + ICoverable aTileEntity) { return (aCoverVariable >= 6) || (aCoverVariable % 2 != 0); } @Override - public boolean letsItemsOut(byte aSide, int aCoverID, int aCoverVariable, int aSlot, ICoverable aTileEntity) { + public boolean letsItemsOut(ForgeDirection side, int aCoverID, int aCoverVariable, int aSlot, + ICoverable aTileEntity) { return (aCoverVariable >= 6) || (aCoverVariable % 2 == 0); } @Override - public boolean alwaysLookConnected(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public boolean alwaysLookConnected(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return true; } @Override - public int getTickRate(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public int getTickRate(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return this.mTickRate; } @@ -285,11 +290,11 @@ private int getNewCoverVariable(int id, int coverVariable) { } private boolean getClickable(int id, int coverVariable) { - if (coverVariable < 0 | 11 < coverVariable) return false; + if (coverVariable < 0 || 11 < coverVariable) return false; return switch (id) { case 0, 1 -> (0x1 & coverVariable) != id; case 2 -> (coverVariable % 6) >= 2; - case 3 -> (coverVariable % 6) < 2 | 4 <= (coverVariable % 6); + case 3 -> (coverVariable % 6) < 2 || 4 <= (coverVariable % 6); case 4 -> (coverVariable % 6) < 4; case 5 -> coverVariable < 6; case 6 -> coverVariable >= 6; diff --git a/src/main/java/gregtech/common/covers/GT_Cover_Crafting.java b/src/main/java/gregtech/common/covers/GT_Cover_Crafting.java index 139317110bf..d985aed767b 100644 --- a/src/main/java/gregtech/common/covers/GT_Cover_Crafting.java +++ b/src/main/java/gregtech/common/covers/GT_Cover_Crafting.java @@ -4,6 +4,7 @@ import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.inventory.ContainerWorkbench; import net.minecraft.network.play.server.S2DPacketOpenWindow; +import net.minecraftforge.common.util.ForgeDirection; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.ICoverable; @@ -24,13 +25,13 @@ public GT_Cover_Crafting(ITexture coverTexture) { } @Override - public boolean isRedstoneSensitive(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, + public boolean isRedstoneSensitive(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) { return false; } @Override - public boolean onCoverRightclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, + public boolean onCoverRightclick(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) { if ((aPlayer instanceof EntityPlayerMP)) { ((EntityPlayerMP) aPlayer).getNextWindowId(); 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 367f0708480..2e60c8cad27 100644 --- a/src/main/java/gregtech/common/covers/GT_Cover_DoesWork.java +++ b/src/main/java/gregtech/common/covers/GT_Cover_DoesWork.java @@ -1,6 +1,7 @@ package gregtech.common.covers; import net.minecraft.entity.player.EntityPlayer; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.Fluid; import com.gtnewhorizons.modularui.api.screen.ModularWindow; @@ -32,39 +33,39 @@ public GT_Cover_DoesWork(ITexture coverTexture) { } @Override - public boolean isRedstoneSensitive(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, + public boolean isRedstoneSensitive(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) { return false; } @Override - public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity, - long aTimer) { + public int doCoverThings(ForgeDirection side, byte aInputRedstone, int aCoverID, int aCoverVariable, + ICoverable aTileEntity, long aTimer) { if ((aTileEntity instanceof IMachineProgress)) { if (aCoverVariable < 2) { int tScale = ((IMachineProgress) aTileEntity).getMaxProgress() / 15; if ((tScale > 0) && (((IMachineProgress) aTileEntity).hasThingsToDo())) { aTileEntity.setOutputRedstoneSignal( - aSide, + side, aCoverVariable % 2 == 0 ? (byte) (((IMachineProgress) aTileEntity).getProgress() / tScale) : (byte) (15 - ((IMachineProgress) aTileEntity).getProgress() / tScale)); } else { - aTileEntity.setOutputRedstoneSignal(aSide, (byte) (aCoverVariable % 2 == 0 ? 0 : 15)); + aTileEntity.setOutputRedstoneSignal(side, (byte) (aCoverVariable % 2 == 0 ? 0 : 15)); } } else { aTileEntity.setOutputRedstoneSignal( - aSide, + side, (byte) ((aCoverVariable % 2 == 0 ? 1 : 0) != (((IMachineProgress) aTileEntity).getMaxProgress() == 0 ? 1 : 0) ? 0 : 15)); } } else { - aTileEntity.setOutputRedstoneSignal(aSide, (byte) 0); + aTileEntity.setOutputRedstoneSignal(side, (byte) 0); } return aCoverVariable; } @Override - public int onCoverScrewdriverclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, + public int onCoverScrewdriverclick(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) { aCoverVariable = (aCoverVariable + (aPlayer.isSneaking() ? -1 : 1)) % 4; if (aCoverVariable < 0) { @@ -84,43 +85,47 @@ public int onCoverScrewdriverclick(byte aSide, int aCoverID, int aCoverVariable, } @Override - public boolean letsEnergyIn(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public boolean letsEnergyIn(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return true; } @Override - public boolean letsEnergyOut(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public boolean letsEnergyOut(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return true; } @Override - public boolean letsFluidIn(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { + public boolean letsFluidIn(ForgeDirection side, int aCoverID, int aCoverVariable, Fluid aFluid, + ICoverable aTileEntity) { return true; } @Override - public boolean letsFluidOut(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { + public boolean letsFluidOut(ForgeDirection side, int aCoverID, int aCoverVariable, Fluid aFluid, + ICoverable aTileEntity) { return true; } @Override - public boolean letsItemsIn(byte aSide, int aCoverID, int aCoverVariable, int aSlot, ICoverable aTileEntity) { + public boolean letsItemsIn(ForgeDirection side, int aCoverID, int aCoverVariable, int aSlot, + ICoverable aTileEntity) { return true; } @Override - public boolean letsItemsOut(byte aSide, int aCoverID, int aCoverVariable, int aSlot, ICoverable aTileEntity) { + public boolean letsItemsOut(ForgeDirection side, int aCoverID, int aCoverVariable, int aSlot, + ICoverable aTileEntity) { return true; } @Override - public boolean manipulatesSidedRedstoneOutput(byte aSide, int aCoverID, int aCoverVariable, + public boolean manipulatesSidedRedstoneOutput(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return true; } @Override - public int getTickRate(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public int getTickRate(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return 5; } diff --git a/src/main/java/gregtech/common/covers/GT_Cover_Drain.java b/src/main/java/gregtech/common/covers/GT_Cover_Drain.java index 82c6e78c57e..14b25e4777e 100644 --- a/src/main/java/gregtech/common/covers/GT_Cover_Drain.java +++ b/src/main/java/gregtech/common/covers/GT_Cover_Drain.java @@ -31,23 +31,23 @@ public GT_Cover_Drain(ITexture coverTexture) { } @Override - public boolean isRedstoneSensitive(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, + public boolean isRedstoneSensitive(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) { return false; } @Override - public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity, - long aTimer) { + public int doCoverThings(ForgeDirection side, byte aInputRedstone, int aCoverID, int aCoverVariable, + ICoverable aTileEntity, long aTimer) { if ((aCoverVariable % 3 > 1) && ((aTileEntity instanceof IMachineProgress))) { if (((IMachineProgress) aTileEntity).isAllowedToWork() != aCoverVariable % 3 < 2) { return aCoverVariable; } } - if (aSide != 6) { - Block tBlock = aTileEntity.getBlockAtSide(aSide); + if (side != ForgeDirection.UNKNOWN) { + final Block tBlock = aTileEntity.getBlockAtSide(side); if ((aCoverVariable < 3) && ((aTileEntity instanceof IFluidHandler))) { - if ((aSide == 1) && (aTileEntity.getWorld() + if ((side == ForgeDirection.UP) && (aTileEntity.getWorld() .isRaining()) && (aTileEntity.getWorld() .getPrecipitationHeight(aTileEntity.getXCoord(), aTileEntity.getZCoord()) - 2 @@ -55,7 +55,7 @@ public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCov int tAmount = (int) (aTileEntity.getBiome().rainfall * 10.0F); if (tAmount > 0) { ((IFluidHandler) aTileEntity).fill( - ForgeDirection.getOrientation(aSide), + side, Materials.Water.getFluid( aTileEntity.getWorld() .isThundering() ? tAmount * 2 : tAmount), @@ -65,32 +65,31 @@ public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCov FluidStack tLiquid = null; if (tBlock != null) { if (((tBlock == Blocks.water) || (tBlock == Blocks.flowing_water)) - && (aTileEntity.getMetaIDAtSide(aSide) == 0)) { + && (aTileEntity.getMetaIDAtSide(side) == 0)) { tLiquid = Materials.Water.getFluid(1000L); } else if (((tBlock == Blocks.lava) || (tBlock == Blocks.flowing_lava)) - && (aTileEntity.getMetaIDAtSide(aSide) == 0)) { + && (aTileEntity.getMetaIDAtSide(side) == 0)) { tLiquid = Materials.Lava.getFluid(1000L); } else if ((tBlock instanceof IFluidBlock)) { tLiquid = ((IFluidBlock) tBlock).drain( aTileEntity.getWorld(), - aTileEntity.getOffsetX(aSide, 1), - aTileEntity.getOffsetY(aSide, 1), - aTileEntity.getOffsetZ(aSide, 1), + aTileEntity.getOffsetX(side, 1), + aTileEntity.getOffsetY(side, 1), + aTileEntity.getOffsetZ(side, 1), false); } if ((tLiquid != null) && (tLiquid.getFluid() != null) - && ((aSide > 1) || ((aSide == 0) && (tLiquid.getFluid() + && ((side.ordinal() > 1) || ((side == ForgeDirection.DOWN) && (tLiquid.getFluid() .getDensity() <= 0)) - || ((aSide == 1) && (tLiquid.getFluid() + || ((side == ForgeDirection.UP) && (tLiquid.getFluid() .getDensity() >= 0))) - && (((IFluidHandler) aTileEntity).fill(ForgeDirection.getOrientation(aSide), tLiquid, false) - == tLiquid.amount)) { - ((IFluidHandler) aTileEntity).fill(ForgeDirection.getOrientation(aSide), tLiquid, true); + && (((IFluidHandler) aTileEntity).fill(side, tLiquid, false) == tLiquid.amount)) { + ((IFluidHandler) aTileEntity).fill(side, tLiquid, true); aTileEntity.getWorld() .setBlockToAir( - aTileEntity.getXCoord() + ForgeDirection.getOrientation(aSide).offsetX, - aTileEntity.getYCoord() + ForgeDirection.getOrientation(aSide).offsetY, - aTileEntity.getZCoord() + ForgeDirection.getOrientation(aSide).offsetZ); + aTileEntity.getXCoord() + side.offsetX, + aTileEntity.getYCoord() + side.offsetY, + aTileEntity.getZCoord() + side.offsetZ); } } } @@ -101,9 +100,9 @@ public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCov || ((tBlock instanceof IFluidBlock)))) { aTileEntity.getWorld() .setBlock( - aTileEntity.getOffsetX(aSide, 1), - aTileEntity.getOffsetY(aSide, 1), - aTileEntity.getOffsetZ(aSide, 1), + aTileEntity.getOffsetX(side, 1), + aTileEntity.getOffsetY(side, 1), + aTileEntity.getOffsetZ(side, 1), Blocks.air, 0, 0); @@ -113,7 +112,7 @@ public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCov } @Override - public int onCoverScrewdriverclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, + public int onCoverScrewdriverclick(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) { aCoverVariable = (aCoverVariable + (aPlayer.isSneaking() ? -1 : 1)) % 6; if (aCoverVariable < 0) { @@ -131,17 +130,18 @@ public int onCoverScrewdriverclick(byte aSide, int aCoverID, int aCoverVariable, } @Override - public boolean letsFluidIn(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { + public boolean letsFluidIn(ForgeDirection side, int aCoverID, int aCoverVariable, Fluid aFluid, + ICoverable aTileEntity) { return ((IMachineProgress) aTileEntity).isAllowedToWork() == aCoverVariable < 2; } @Override - public boolean alwaysLookConnected(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public boolean alwaysLookConnected(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return true; } @Override - public int getTickRate(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public int getTickRate(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return aCoverVariable < 3 ? 50 : 1; } } 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 613e1e546d8..d91e62a687d 100644 --- a/src/main/java/gregtech/common/covers/GT_Cover_EUMeter.java +++ b/src/main/java/gregtech/common/covers/GT_Cover_EUMeter.java @@ -9,6 +9,7 @@ import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.Fluid; import com.google.common.io.ByteArrayDataInput; @@ -57,8 +58,8 @@ public EUMeterData createDataObject() { } @Override - protected EUMeterData doCoverThingsImpl(byte aSide, byte aInputRedstone, int aCoverID, EUMeterData aCoverVariable, - ICoverable aTileEntity, long aTimer) { + protected EUMeterData doCoverThingsImpl(ForgeDirection side, byte aInputRedstone, int aCoverID, + EUMeterData aCoverVariable, ICoverable aTileEntity, long aTimer) { final long stored = aCoverVariable.type.getTileEntityStoredEnergy(aTileEntity); final long capacity = aCoverVariable.type.getTileEntityEnergyCapacity(aTileEntity); @@ -87,12 +88,12 @@ protected EUMeterData doCoverThingsImpl(byte aSide, byte aInputRedstone, int aCo } } - aTileEntity.setOutputRedstoneSignal(aSide, redstoneSignal); + aTileEntity.setOutputRedstoneSignal(side, redstoneSignal); return aCoverVariable; } @Override - protected EUMeterData onCoverScrewdriverClickImpl(byte aSide, int aCoverID, EUMeterData aCoverVariable, + protected EUMeterData onCoverScrewdriverClickImpl(ForgeDirection side, int aCoverID, EUMeterData aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) { int num = (aCoverVariable.getNum() + (aPlayer.isSneaking() ? -1 : 1) + EnergyType.values().length * 2) % (EnergyType.values().length * 2); @@ -119,53 +120,56 @@ protected EUMeterData onCoverScrewdriverClickImpl(byte aSide, int aCoverID, EUMe // region Static Result Methods @Override - protected boolean isRedstoneSensitiveImpl(byte aSide, int aCoverID, EUMeterData aCoverVariable, + protected boolean isRedstoneSensitiveImpl(ForgeDirection side, int aCoverID, EUMeterData aCoverVariable, ICoverable aTileEntity, long aTimer) { return false; } @Override - protected boolean letsEnergyInImpl(byte aSide, int aCoverID, EUMeterData aCoverVariable, ICoverable aTileEntity) { + protected boolean letsEnergyInImpl(ForgeDirection side, int aCoverID, EUMeterData aCoverVariable, + ICoverable aTileEntity) { return true; } @Override - protected boolean letsEnergyOutImpl(byte aSide, int aCoverID, EUMeterData aCoverVariable, ICoverable aTileEntity) { + protected boolean letsEnergyOutImpl(ForgeDirection side, int aCoverID, EUMeterData aCoverVariable, + ICoverable aTileEntity) { return true; } @Override - protected boolean letsFluidInImpl(byte aSide, int aCoverID, EUMeterData aCoverVariable, Fluid aFluid, + protected boolean letsFluidInImpl(ForgeDirection side, int aCoverID, EUMeterData aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { return true; } @Override - protected boolean letsFluidOutImpl(byte aSide, int aCoverID, EUMeterData aCoverVariable, Fluid aFluid, + protected boolean letsFluidOutImpl(ForgeDirection side, int aCoverID, EUMeterData aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { return true; } @Override - protected boolean letsItemsInImpl(byte aSide, int aCoverID, EUMeterData aCoverVariable, int aSlot, + protected boolean letsItemsInImpl(ForgeDirection side, int aCoverID, EUMeterData aCoverVariable, int aSlot, ICoverable aTileEntity) { return true; } @Override - protected boolean letsItemsOutImpl(byte aSide, int aCoverID, EUMeterData aCoverVariable, int aSlot, + protected boolean letsItemsOutImpl(ForgeDirection side, int aCoverID, EUMeterData aCoverVariable, int aSlot, ICoverable aTileEntity) { return true; } @Override - protected boolean manipulatesSidedRedstoneOutputImpl(byte aSide, int aCoverID, EUMeterData aCoverVariable, + protected boolean manipulatesSidedRedstoneOutputImpl(ForgeDirection side, int aCoverID, EUMeterData aCoverVariable, ICoverable aTileEntity) { return true; } @Override - protected int getTickRateImpl(byte aSide, int aCoverID, EUMeterData aCoverVariable, ICoverable aTileEntity) { + protected int getTickRateImpl(ForgeDirection side, int aCoverID, EUMeterData aCoverVariable, + ICoverable aTileEntity) { return 20; } // endregion diff --git a/src/main/java/gregtech/common/covers/GT_Cover_FacadeBase.java b/src/main/java/gregtech/common/covers/GT_Cover_FacadeBase.java index 87ceb052043..a8d853dc1b8 100644 --- a/src/main/java/gregtech/common/covers/GT_Cover_FacadeBase.java +++ b/src/main/java/gregtech/common/covers/GT_Cover_FacadeBase.java @@ -1,7 +1,5 @@ package gregtech.common.covers; -import static gregtech.api.enums.GT_Values.ALL_VALID_SIDES; - import javax.annotation.Nonnull; import net.minecraft.block.Block; @@ -57,7 +55,7 @@ public FacadeData createDataObject() { } @Override - protected FacadeData onCoverScrewdriverClickImpl(byte aSide, int aCoverID, FacadeData aCoverVariable, + protected FacadeData onCoverScrewdriverClickImpl(ForgeDirection side, int aCoverID, FacadeData aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) { aCoverVariable.mFlags = ((aCoverVariable.mFlags + 1) & 15); GT_Utility.sendChatToPlayer( @@ -70,55 +68,57 @@ protected FacadeData onCoverScrewdriverClickImpl(byte aSide, int aCoverID, Facad } @Override - protected boolean letsRedstoneGoInImpl(byte aSide, int aCoverID, FacadeData aCoverVariable, + protected boolean letsRedstoneGoInImpl(ForgeDirection side, int aCoverID, FacadeData aCoverVariable, ICoverable aTileEntity) { return (aCoverVariable.mFlags & 1) != 0; } @Override - protected boolean letsRedstoneGoOutImpl(byte aSide, int aCoverID, FacadeData aCoverVariable, + protected boolean letsRedstoneGoOutImpl(ForgeDirection side, int aCoverID, FacadeData aCoverVariable, ICoverable aTileEntity) { return (aCoverVariable.mFlags & 1) != 0; } @Override - protected boolean letsEnergyInImpl(byte aSide, int aCoverID, FacadeData aCoverVariable, ICoverable aTileEntity) { + protected boolean letsEnergyInImpl(ForgeDirection side, int aCoverID, FacadeData aCoverVariable, + ICoverable aTileEntity) { return (aCoverVariable.mFlags & 2) != 0; } @Override - protected boolean letsEnergyOutImpl(byte aSide, int aCoverID, FacadeData aCoverVariable, ICoverable aTileEntity) { + protected boolean letsEnergyOutImpl(ForgeDirection side, int aCoverID, FacadeData aCoverVariable, + ICoverable aTileEntity) { return (aCoverVariable.mFlags & 2) != 0; } @Override - protected boolean letsFluidInImpl(byte aSide, int aCoverID, FacadeData aCoverVariable, Fluid aFluid, + protected boolean letsFluidInImpl(ForgeDirection side, int aCoverID, FacadeData aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { return (aCoverVariable.mFlags & 4) != 0; } @Override - protected boolean letsFluidOutImpl(byte aSide, int aCoverID, FacadeData aCoverVariable, Fluid aFluid, + protected boolean letsFluidOutImpl(ForgeDirection side, int aCoverID, FacadeData aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { return (aCoverVariable.mFlags & 4) != 0; } @Override - protected boolean letsItemsInImpl(byte aSide, int aCoverID, FacadeData aCoverVariable, int aSlot, + protected boolean letsItemsInImpl(ForgeDirection side, int aCoverID, FacadeData aCoverVariable, int aSlot, ICoverable aTileEntity) { return (aCoverVariable.mFlags & 8) != 0; } @Override - protected boolean letsItemsOutImpl(byte aSide, int aCoverID, FacadeData aCoverVariable, int aSlot, + protected boolean letsItemsOutImpl(ForgeDirection side, int aCoverID, FacadeData aCoverVariable, int aSlot, ICoverable aTileEntity) { return (aCoverVariable.mFlags & 8) != 0; } @Override - public void placeCover(byte aSide, ItemStack aCover, ICoverable aTileEntity) { + public void placeCover(ForgeDirection side, ItemStack aCover, ICoverable aTileEntity) { aTileEntity.setCoverIdAndDataAtSide( - aSide, + side, GT_Utility.stackToInt(aCover), new FacadeData(GT_Utility.copyAmount(1, aCover), 0)); @@ -132,18 +132,19 @@ public void placeCover(byte aSide, ItemStack aCover, ICoverable aTileEntity) { } @Override - protected ItemStack getDropImpl(byte aSide, int aCoverID, FacadeData aCoverVariable, ICoverable aTileEntity) { + protected ItemStack getDropImpl(ForgeDirection side, int aCoverID, FacadeData aCoverVariable, + ICoverable aTileEntity) { return aCoverVariable.mStack; } @Override - protected ITexture getSpecialCoverFGTextureImpl(byte aSide, int aCoverID, FacadeData aCoverVariable, + protected ITexture getSpecialCoverFGTextureImpl(ForgeDirection side, int aCoverID, FacadeData aCoverVariable, ICoverable aTileEntity) { - return getSpecialCoverTextureImpl(aSide, aCoverID, aCoverVariable, aTileEntity); + return getSpecialCoverTextureImpl(side, aCoverID, aCoverVariable, aTileEntity); } @Override - protected ITexture getSpecialCoverTextureImpl(byte aSide, int aCoverID, FacadeData aCoverVariable, + protected ITexture getSpecialCoverTextureImpl(ForgeDirection side, int aCoverID, FacadeData aCoverVariable, ICoverable aTileEntity) { if (GT_Utility.isStackInvalid(aCoverVariable.mStack)) return Textures.BlockIcons.ERROR_RENDERING[0]; Block block = getTargetBlock(aCoverVariable.mStack); @@ -153,18 +154,20 @@ protected ITexture getSpecialCoverTextureImpl(byte aSide, int aCoverID, FacadeDa return TextureFactory.builder() .setFromBlock(block, getTargetMeta(aCoverVariable.mStack)) .useWorldCoord() - .setFromSide(ForgeDirection.getOrientation(aSide)) + .setFromSide(side) .build(); } @Override - protected Block getFacadeBlockImpl(byte aSide, int aCoverID, FacadeData aCoverVariable, ICoverable aTileEntity) { + protected Block getFacadeBlockImpl(ForgeDirection side, int aCoverID, FacadeData aCoverVariable, + ICoverable aTileEntity) { if (GT_Utility.isStackInvalid(aCoverVariable.mStack)) return null; return getTargetBlock(aCoverVariable.mStack); } @Override - protected int getFacadeMetaImpl(byte aSide, int aCoverID, FacadeData aCoverVariable, ICoverable aTileEntity) { + protected int getFacadeMetaImpl(ForgeDirection side, int aCoverID, FacadeData aCoverVariable, + ICoverable aTileEntity) { if (GT_Utility.isStackInvalid(aCoverVariable.mStack)) return 0; return getTargetMeta(aCoverVariable.mStack); } @@ -174,13 +177,14 @@ protected int getFacadeMetaImpl(byte aSide, int aCoverID, FacadeData aCoverVaria protected abstract int getTargetMeta(ItemStack aFacadeStack); @Override - protected boolean isDataNeededOnClientImpl(byte aSide, int aCoverID, FacadeData aCoverVariable, + protected boolean isDataNeededOnClientImpl(ForgeDirection side, int aCoverID, FacadeData aCoverVariable, ICoverable aTileEntity) { return true; } @Override - protected void onDataChangedImpl(byte aSide, int aCoverID, FacadeData aCoverVariable, ICoverable aTileEntity) { + protected void onDataChangedImpl(ForgeDirection side, int aCoverID, FacadeData aCoverVariable, + ICoverable aTileEntity) { if (aTileEntity.isClientSide()) GT_RenderingWorld.getInstance() .register( aTileEntity.getXCoord(), @@ -191,12 +195,12 @@ protected void onDataChangedImpl(byte aSide, int aCoverID, FacadeData aCoverVari } @Override - protected void onDroppedImpl(byte aSide, int aCoverID, FacadeData aCoverVariable, ICoverable aTileEntity) { + protected void onDroppedImpl(ForgeDirection side, int aCoverID, FacadeData aCoverVariable, ICoverable aTileEntity) { if (aTileEntity.isClientSide()) { - for (byte i : ALL_VALID_SIDES) { - if (i == aSide) continue; + for (final ForgeDirection iSide : ForgeDirection.VALID_DIRECTIONS) { + if (iSide == side) continue; // since we do not allow multiple type of facade per block, this check would be enough. - if (aTileEntity.getCoverBehaviorAtSideNew(i) instanceof GT_Cover_FacadeBase) return; + if (aTileEntity.getCoverBehaviorAtSideNew(iSide) instanceof GT_Cover_FacadeBase) return; } if (aCoverVariable.mStack != null) // mStack == null -> cover removed before data reach client @@ -211,28 +215,28 @@ protected void onDroppedImpl(byte aSide, int aCoverID, FacadeData aCoverVariable } @Override - protected boolean onCoverRightClickImpl(byte aSide, int aCoverID, FacadeData aCoverVariable, ICoverable aTileEntity, - EntityPlayer aPlayer, float aX, float aY, float aZ) { + protected boolean onCoverRightClickImpl(ForgeDirection side, int aCoverID, FacadeData aCoverVariable, + ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) { // in case cover data didn't hit client somehow. maybe he had a ridiculous view distance - aTileEntity.issueCoverUpdate(aSide); - return super.onCoverRightClickImpl(aSide, aCoverID, aCoverVariable, aTileEntity, aPlayer, aX, aY, aZ); + aTileEntity.issueCoverUpdate(side); + return super.onCoverRightClickImpl(side, aCoverID, aCoverVariable, aTileEntity, aPlayer, aX, aY, aZ); } @Override - public boolean isCoverPlaceable(byte aSide, ItemStack aStack, ICoverable aTileEntity) { + public boolean isCoverPlaceable(ForgeDirection side, ItemStack aStack, ICoverable aTileEntity) { // blocks that are not rendered in pass 0 are now accepted but rendered awkwardly // to render it correctly require changing GT_Block_Machine to render in both pass, which is not really a good // idea... - if (!super.isCoverPlaceable(aSide, aStack, aTileEntity)) return false; + if (!super.isCoverPlaceable(side, aStack, aTileEntity)) return false; final Block targetBlock = getTargetBlock(aStack); if (targetBlock == null) return false; // we allow one single type of facade on the same block for now // otherwise it's not clear which block this block should impersonate // this restriction can be lifted later by specifying a certain facade as dominate one as an extension to this // class - for (byte i : ALL_VALID_SIDES) { - if (i == aSide) continue; - final CoverInfo coverInfo = aTileEntity.getCoverInfoAtSide(i); + for (final ForgeDirection iSide : ForgeDirection.VALID_DIRECTIONS) { + if (iSide == side) continue; + final CoverInfo coverInfo = aTileEntity.getCoverInfoAtSide(iSide); if (!coverInfo.isValid()) continue; final Block facadeBlock = coverInfo.getFacadeBlock(); if (facadeBlock == null) continue; diff --git a/src/main/java/gregtech/common/covers/GT_Cover_FluidLimiter.java b/src/main/java/gregtech/common/covers/GT_Cover_FluidLimiter.java index 199d22407a5..e1832d5a54d 100644 --- a/src/main/java/gregtech/common/covers/GT_Cover_FluidLimiter.java +++ b/src/main/java/gregtech/common/covers/GT_Cover_FluidLimiter.java @@ -45,8 +45,8 @@ public GT_Cover_FluidLimiter(ITexture coverTexture) { } @Override - protected FluidLimiterData onCoverScrewdriverClickImpl(byte aSide, int aCoverID, FluidLimiterData aCoverVariable, - ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) { + protected FluidLimiterData onCoverScrewdriverClickImpl(ForgeDirection side, int aCoverID, + FluidLimiterData aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) { if (aTileEntity instanceof IFluidHandler) { adjustThreshold(aCoverVariable, !aPlayer.isSneaking()); GT_Utility.sendChatToPlayer(aPlayer, String.format("Threshold: %f", aCoverVariable.threshold)); @@ -55,13 +55,13 @@ protected FluidLimiterData onCoverScrewdriverClickImpl(byte aSide, int aCoverID, } @Override - protected boolean letsFluidInImpl(byte aSide, int aCoverID, FluidLimiterData aCoverVariable, Fluid aFluid, + protected boolean letsFluidInImpl(ForgeDirection side, int aCoverID, FluidLimiterData aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { return allowsFluidIn(aCoverVariable, aTileEntity); } @Override - protected boolean alwaysLookConnectedImpl(byte aSide, int aCoverID, FluidLimiterData aCoverVariable, + protected boolean alwaysLookConnectedImpl(ForgeDirection side, int aCoverID, FluidLimiterData aCoverVariable, ICoverable aTileEntity) { return true; } diff --git a/src/main/java/gregtech/common/covers/GT_Cover_FluidRegulator.java b/src/main/java/gregtech/common/covers/GT_Cover_FluidRegulator.java index 6af664b5948..13796e09154 100644 --- a/src/main/java/gregtech/common/covers/GT_Cover_FluidRegulator.java +++ b/src/main/java/gregtech/common/covers/GT_Cover_FluidRegulator.java @@ -87,34 +87,32 @@ public FluidRegulatorData createDataObject() { } @Override - protected boolean isRedstoneSensitiveImpl(byte aSide, int aCoverID, FluidRegulatorData aCoverVariable, + protected boolean isRedstoneSensitiveImpl(ForgeDirection side, int aCoverID, FluidRegulatorData aCoverVariable, ICoverable aTileEntity, long aTimer) { return aCoverVariable.condition.isRedstoneSensitive(); } @Override - protected FluidRegulatorData doCoverThingsImpl(byte aSide, byte aInputRedstone, int aCoverID, + protected FluidRegulatorData doCoverThingsImpl(ForgeDirection side, byte aInputRedstone, int aCoverID, FluidRegulatorData aCoverVariable, ICoverable aTileEntity, long aTimer) { - if (aCoverVariable.speed == 0 || !aCoverVariable.condition.isAllowedToWork(aSide, aCoverID, aTileEntity)) { + if (aCoverVariable.speed == 0 || !aCoverVariable.condition.isAllowedToWork(side, aCoverID, aTileEntity)) { return aCoverVariable; } if ((aTileEntity instanceof IFluidHandler)) { - IFluidHandler tTank1; - IFluidHandler tTank2; - ForgeDirection directionFrom; - ForgeDirection directionTo; + final IFluidHandler tTank1; + final IFluidHandler tTank2; + final ForgeDirection directionFrom; + final ForgeDirection directionTo; if (aCoverVariable.speed > 0) { - tTank2 = aTileEntity.getITankContainerAtSide(aSide); + tTank2 = aTileEntity.getITankContainerAtSide(side); tTank1 = (IFluidHandler) aTileEntity; - directionFrom = ForgeDirection.getOrientation(aSide); - directionTo = ForgeDirection.getOrientation(aSide) - .getOpposite(); + directionFrom = side; + directionTo = side.getOpposite(); } else { - tTank1 = aTileEntity.getITankContainerAtSide(aSide); + tTank1 = aTileEntity.getITankContainerAtSide(side); tTank2 = (IFluidHandler) aTileEntity; - directionFrom = ForgeDirection.getOrientation(aSide) - .getOpposite(); - directionTo = ForgeDirection.getOrientation(aSide); + directionFrom = side.getOpposite(); + directionTo = side; } if (tTank1 != null && tTank2 != null) { allowFluid = true; @@ -159,9 +157,9 @@ private void adjustSpeed(EntityPlayer aPlayer, FluidRegulatorData aCoverVariable } @Override - public FluidRegulatorData onCoverScrewdriverClickImpl(byte aSide, int aCoverID, FluidRegulatorData aCoverVariable, - ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) { - if (GT_Utility.getClickedFacingCoords(aSide, aX, aY, aZ)[0] >= 0.5F) { + public FluidRegulatorData onCoverScrewdriverClickImpl(ForgeDirection side, int aCoverID, + FluidRegulatorData aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (GT_Utility.getClickedFacingCoords(side, aX, aY, aZ)[0] >= 0.5F) { adjustSpeed(aPlayer, aCoverVariable, aPlayer.isSneaking() ? 256 : 16); } else { adjustSpeed(aPlayer, aCoverVariable, aPlayer.isSneaking() ? -256 : -16); @@ -170,9 +168,9 @@ public FluidRegulatorData onCoverScrewdriverClickImpl(byte aSide, int aCoverID, } @Override - protected boolean onCoverRightClickImpl(byte aSide, int aCoverID, FluidRegulatorData aCoverVariable, + protected boolean onCoverRightClickImpl(ForgeDirection side, int aCoverID, FluidRegulatorData aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) { - if (GT_Utility.getClickedFacingCoords(aSide, aX, aY, aZ)[0] >= 0.5F) { + if (GT_Utility.getClickedFacingCoords(side, aX, aY, aZ)[0] >= 0.5F) { adjustSpeed(aPlayer, aCoverVariable, 1); } else { adjustSpeed(aPlayer, aCoverVariable, -1); @@ -185,61 +183,62 @@ protected boolean canTransferFluid(FluidStack fluid) { } @Override - public boolean letsRedstoneGoInImpl(byte aSide, int aCoverID, FluidRegulatorData aCoverVariable, + public boolean letsRedstoneGoInImpl(ForgeDirection side, int aCoverID, FluidRegulatorData aCoverVariable, ICoverable aTileEntity) { return true; } @Override - public boolean letsRedstoneGoOutImpl(byte aSide, int aCoverID, FluidRegulatorData aCoverVariable, + public boolean letsRedstoneGoOutImpl(ForgeDirection side, int aCoverID, FluidRegulatorData aCoverVariable, ICoverable aTileEntity) { return true; } @Override - public boolean letsEnergyInImpl(byte aSide, int aCoverID, FluidRegulatorData aCoverVariable, + public boolean letsEnergyInImpl(ForgeDirection side, int aCoverID, FluidRegulatorData aCoverVariable, ICoverable aTileEntity) { return true; } @Override - public boolean letsEnergyOutImpl(byte aSide, int aCoverID, FluidRegulatorData aCoverVariable, + public boolean letsEnergyOutImpl(ForgeDirection side, int aCoverID, FluidRegulatorData aCoverVariable, ICoverable aTileEntity) { return true; } @Override - public boolean letsItemsInImpl(byte aSide, int aCoverID, FluidRegulatorData aCoverVariable, int aSlot, + public boolean letsItemsInImpl(ForgeDirection side, int aCoverID, FluidRegulatorData aCoverVariable, int aSlot, ICoverable aTileEntity) { return true; } @Override - public boolean letsItemsOutImpl(byte aSide, int aCoverID, FluidRegulatorData aCoverVariable, int aSlot, + public boolean letsItemsOutImpl(ForgeDirection side, int aCoverID, FluidRegulatorData aCoverVariable, int aSlot, ICoverable aTileEntity) { return true; } @Override - public boolean letsFluidInImpl(byte aSide, int aCoverID, FluidRegulatorData aCoverVariable, Fluid aFluid, + public boolean letsFluidInImpl(ForgeDirection side, int aCoverID, FluidRegulatorData aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { return allowFluid; } @Override - public boolean letsFluidOutImpl(byte aSide, int aCoverID, FluidRegulatorData aCoverVariable, Fluid aFluid, + public boolean letsFluidOutImpl(ForgeDirection side, int aCoverID, FluidRegulatorData aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { return allowFluid; } @Override - protected boolean alwaysLookConnectedImpl(byte aSide, int aCoverID, FluidRegulatorData aCoverVariable, + protected boolean alwaysLookConnectedImpl(ForgeDirection side, int aCoverID, FluidRegulatorData aCoverVariable, ICoverable aTileEntity) { return true; } @Override - protected int getTickRateImpl(byte aSide, int aCoverID, FluidRegulatorData aCoverVariable, ICoverable aTileEntity) { + protected int getTickRateImpl(ForgeDirection side, int aCoverID, FluidRegulatorData aCoverVariable, + ICoverable aTileEntity) { return aCoverVariable.tickRate; } @@ -412,21 +411,21 @@ public enum Conditional { Always(false) { @Override - boolean isAllowedToWork(byte aSide, int aCoverID, ICoverable aTileEntity) { + boolean isAllowedToWork(ForgeDirection side, int aCoverID, ICoverable aTileEntity) { return true; } }, Conditional(true) { @Override - boolean isAllowedToWork(byte aSide, int aCoverID, ICoverable aTileEntity) { + boolean isAllowedToWork(ForgeDirection side, int aCoverID, ICoverable aTileEntity) { return !(aTileEntity instanceof IMachineProgress) || ((IMachineProgress) aTileEntity).isAllowedToWork(); } }, Inverted(true) { @Override - boolean isAllowedToWork(byte aSide, int aCoverID, ICoverable aTileEntity) { + boolean isAllowedToWork(ForgeDirection side, int aCoverID, ICoverable aTileEntity) { return !(aTileEntity instanceof IMachineProgress) || !((IMachineProgress) aTileEntity).isAllowedToWork(); } @@ -439,7 +438,7 @@ boolean isAllowedToWork(byte aSide, int aCoverID, ICoverable aTileEntity) { this.redstoneSensitive = redstoneSensitive; } - abstract boolean isAllowedToWork(byte aSide, int aCoverID, ICoverable aTileEntity); + abstract boolean isAllowedToWork(ForgeDirection side, int aCoverID, ICoverable aTileEntity); boolean isRedstoneSensitive() { return redstoneSensitive; diff --git a/src/main/java/gregtech/common/covers/GT_Cover_FluidStorageMonitor.java b/src/main/java/gregtech/common/covers/GT_Cover_FluidStorageMonitor.java index 81c41bf59a6..27bab9cc55b 100644 --- a/src/main/java/gregtech/common/covers/GT_Cover_FluidStorageMonitor.java +++ b/src/main/java/gregtech/common/covers/GT_Cover_FluidStorageMonitor.java @@ -51,7 +51,7 @@ /** * TODO: Implement overlay rendering only with - * {@link GT_CoverBehaviorBase#getSpecialCoverFGTextureImpl(byte, int, ISerializableObject, ICoverable)} + * {@link GT_CoverBehaviorBase#getSpecialCoverFGTextureImpl(ForgeDirection, int, ISerializableObject, ICoverable)} */ public class GT_Cover_FluidStorageMonitor extends GT_CoverBehaviorBase { @@ -77,12 +77,12 @@ public FluidStorageData createDataObject() { } @Override - protected FluidStorageData doCoverThingsImpl(byte aSide, byte aInputRedstone, int aCoverID, + protected FluidStorageData doCoverThingsImpl(ForgeDirection side, byte aInputRedstone, int aCoverID, FluidStorageData aCoverVariable, ICoverable aTileEntity, long aTimer) { final FluidTankInfo[] tanks = getValidFluidTankInfos(aTileEntity, aCoverVariable.side); if (tanks == null) { return aCoverVariable.disable() - .issueCoverUpdateIfNeeded(aTileEntity, aSide); + .issueCoverUpdateIfNeeded(aTileEntity, side); } assert 0 < tanks.length; @@ -93,22 +93,22 @@ protected FluidStorageData doCoverThingsImpl(byte aSide, byte aInputRedstone, in final FluidTankInfo tank = tanks[aCoverVariable.slot]; if (tank == null) { return aCoverVariable.setNullTank() - .issueCoverUpdateIfNeeded(aTileEntity, aSide); + .issueCoverUpdateIfNeeded(aTileEntity, side); } return aCoverVariable.setFluid(tank.fluid) .setScale(getTankScale(tank)) - .issueCoverUpdateIfNeeded(aTileEntity, aSide); + .issueCoverUpdateIfNeeded(aTileEntity, side); } @Override - protected ITexture getSpecialCoverFGTextureImpl(byte aSide, int aCoverID, FluidStorageData aCoverVariable, + protected ITexture getSpecialCoverFGTextureImpl(ForgeDirection side, int aCoverID, FluidStorageData aCoverVariable, ICoverable aTileEntity) { - return getSpecialCoverTextureImpl(aSide, aCoverID, aCoverVariable, aTileEntity); + return getSpecialCoverTextureImpl(side, aCoverID, aCoverVariable, aTileEntity); } @Override - protected ITexture getSpecialCoverTextureImpl(byte aSide, int aCoverID, FluidStorageData aCoverVariable, + protected ITexture getSpecialCoverTextureImpl(ForgeDirection side, int aCoverID, FluidStorageData aCoverVariable, ICoverable aTileEntity) { if (aCoverVariable.slot == -1 || aCoverVariable.fluid == null || aCoverVariable.scale == 0) { return TextureFactory.of(OVERLAY_FLUID_STORAGE_MONITOR0); @@ -140,7 +140,7 @@ public ResourceLocation getTextureFile() { } @Override - protected boolean onCoverRightClickImpl(byte aSide, int aCoverID, FluidStorageData aCoverVariable, + protected boolean onCoverRightClickImpl(ForgeDirection side, int aCoverID, FluidStorageData aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) { if (aPlayer == null || aPlayer.worldObj == null || aPlayer.worldObj.isRemote) { return false; @@ -266,8 +266,8 @@ protected static void replaceHeldItemStack(@Nonnull EntityPlayer player, @Nonnul } @Override - protected FluidStorageData onCoverScrewdriverClickImpl(byte aSide, int aCoverID, FluidStorageData aCoverVariable, - ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) { + protected FluidStorageData onCoverScrewdriverClickImpl(ForgeDirection side, int aCoverID, + FluidStorageData aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) { if (aPlayer.isSneaking()) { aCoverVariable .setSide(ForgeDirection.values()[(aCoverVariable.side.ordinal() + 1) % ForgeDirection.values().length]) @@ -291,25 +291,26 @@ protected FluidStorageData onCoverScrewdriverClickImpl(byte aSide, int aCoverID, } @Override - protected boolean isDataNeededOnClientImpl(byte aSide, int aCoverID, FluidStorageData aCoverVariable, + protected boolean isDataNeededOnClientImpl(ForgeDirection side, int aCoverID, FluidStorageData aCoverVariable, ICoverable aTileEntity) { return true; } @Override - protected boolean letsFluidInImpl(byte aSide, int aCoverID, FluidStorageData aCoverVariable, Fluid aFluid, + protected boolean letsFluidInImpl(ForgeDirection side, int aCoverID, FluidStorageData aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { return true; } @Override - protected boolean letsFluidOutImpl(byte aSide, int aCoverID, FluidStorageData aCoverVariable, Fluid aFluid, + protected boolean letsFluidOutImpl(ForgeDirection side, int aCoverID, FluidStorageData aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { return true; } @Override - protected int getTickRateImpl(byte aSide, int aCoverID, FluidStorageData aCoverVariable, ICoverable aTileEntity) { + protected int getTickRateImpl(ForgeDirection side, int aCoverID, FluidStorageData aCoverVariable, + ICoverable aTileEntity) { return 10; } @@ -408,7 +409,7 @@ public FluidStorageData setNullTank() { .setScale(0); } - public FluidStorageData issueCoverUpdateIfNeeded(ICoverable tileEntity, byte side) { + public FluidStorageData issueCoverUpdateIfNeeded(ICoverable tileEntity, ForgeDirection side) { if (this.dirty) { tileEntity.issueCoverUpdate(side); this.dirty = false; 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 22db900f185..79f94f8d5b2 100644 --- a/src/main/java/gregtech/common/covers/GT_Cover_Fluidfilter.java +++ b/src/main/java/gregtech/common/covers/GT_Cover_Fluidfilter.java @@ -10,6 +10,7 @@ import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.util.Constants.NBT; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; @@ -67,7 +68,7 @@ public FluidFilterData createDataObject(int aLegacyData) { } @Override - protected String getDescriptionImpl(byte aSide, int aCoverID, FluidFilterData aCoverVariable, + protected String getDescriptionImpl(ForgeDirection side, int aCoverID, FluidFilterData aCoverVariable, ICoverable aTileEntity) { final Fluid fluid = FluidRegistry.getFluid(aCoverVariable.mFluidID); if (fluid == null) return E; @@ -78,13 +79,13 @@ protected String getDescriptionImpl(byte aSide, int aCoverID, FluidFilterData aC } @Override - protected boolean isRedstoneSensitiveImpl(byte aSide, int aCoverID, FluidFilterData aCoverVariable, + protected boolean isRedstoneSensitiveImpl(ForgeDirection side, int aCoverID, FluidFilterData aCoverVariable, ICoverable aTileEntity, long aTimer) { return false; } @Override - protected FluidFilterData doCoverThingsImpl(byte aSide, byte aInputRedstone, int aCoverID, + protected FluidFilterData doCoverThingsImpl(ForgeDirection side, byte aInputRedstone, int aCoverID, FluidFilterData aCoverVariable, ICoverable aTileEntity, long aTimer) { return aCoverVariable; } @@ -104,8 +105,8 @@ public String getFilterMode(int aFilterMode) { } @Override - protected FluidFilterData onCoverScrewdriverClickImpl(byte aSide, int aCoverID, FluidFilterData aCoverVariable, - ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) { + protected FluidFilterData onCoverScrewdriverClickImpl(ForgeDirection side, int aCoverID, + FluidFilterData aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) { aCoverVariable.mFilterMode = (aCoverVariable.mFilterMode + (aPlayer.isSneaking() ? -1 : 1)) % 8; if (aCoverVariable.mFilterMode < 0) { aCoverVariable.mFilterMode = 7; @@ -117,21 +118,20 @@ protected FluidFilterData onCoverScrewdriverClickImpl(byte aSide, int aCoverID, } @Override - protected boolean onCoverRightClickImpl(byte aSide, int aCoverID, FluidFilterData aCoverVariable, + protected boolean onCoverRightClickImpl(ForgeDirection side, int aCoverID, FluidFilterData aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) { - if (((aX > 0.375D) && (aX < 0.625D)) || ((aSide > 3) && ((aY > 0.375D) && (aY < 0.625D))) - || ((aSide < 2) && ((aZ > 0.375D) && (aZ < 0.625D))) - || (aSide == 2) - || (aSide == 3)) { - ItemStack tStack = aPlayer.inventory.getCurrentItem(); + if (((aX > 0.375D) && (aX < 0.625D)) || ((side.offsetX != 0) && ((aY > 0.375D) && (aY < 0.625D))) + || ((side.offsetY != 0) && ((aZ > 0.375D) && (aZ < 0.625D))) + || (side.offsetZ != 0)) { + final ItemStack tStack = aPlayer.inventory.getCurrentItem(); if (tStack == null) return true; - FluidStack tFluid = GT_Utility.getFluidForFilledItem(tStack, true); + final FluidStack tFluid = GT_Utility.getFluidForFilledItem(tStack, true); if (tFluid != null) { - int aFluid = tFluid.getFluidID(); + final int aFluid = tFluid.getFluidID(); aCoverVariable.mFluidID = aFluid; - aTileEntity.setCoverDataAtSide(aSide, aCoverVariable); - FluidStack sFluid = new FluidStack(FluidRegistry.getFluid(aFluid), 1000); + aTileEntity.setCoverDataAtSide(side, aCoverVariable); + final FluidStack sFluid = new FluidStack(FluidRegistry.getFluid(aFluid), 1000); GT_Utility .sendChatToPlayer(aPlayer, GT_Utility.trans("047", "Filter Fluid: ") + sFluid.getLocalizedName()); } @@ -141,43 +141,43 @@ protected boolean onCoverRightClickImpl(byte aSide, int aCoverID, FluidFilterDat } @Override - protected boolean letsRedstoneGoInImpl(byte aSide, int aCoverID, - GT_Cover_Fluidfilter.FluidFilterData aCoverVariable, ICoverable aTileEntity) { + protected boolean letsRedstoneGoInImpl(ForgeDirection side, int aCoverID, FluidFilterData aCoverVariable, + ICoverable aTileEntity) { return true; } @Override - protected boolean letsRedstoneGoOutImpl(byte aSide, int aCoverID, - GT_Cover_Fluidfilter.FluidFilterData aCoverVariable, ICoverable aTileEntity) { + protected boolean letsRedstoneGoOutImpl(ForgeDirection side, int aCoverID, FluidFilterData aCoverVariable, + ICoverable aTileEntity) { return true; } @Override - protected boolean letsEnergyInImpl(byte aSide, int aCoverID, GT_Cover_Fluidfilter.FluidFilterData aCoverVariable, + protected boolean letsEnergyInImpl(ForgeDirection side, int aCoverID, FluidFilterData aCoverVariable, ICoverable aTileEntity) { return true; } @Override - protected boolean letsEnergyOutImpl(byte aSide, int aCoverID, GT_Cover_Fluidfilter.FluidFilterData aCoverVariable, + protected boolean letsEnergyOutImpl(ForgeDirection side, int aCoverID, FluidFilterData aCoverVariable, ICoverable aTileEntity) { return true; } @Override - public boolean letsItemsInImpl(byte aSide, int aCoverID, GT_Cover_Fluidfilter.FluidFilterData aCoverVariable, - int aSlot, ICoverable aTileEntity) { + public boolean letsItemsInImpl(ForgeDirection side, int aCoverID, FluidFilterData aCoverVariable, int aSlot, + ICoverable aTileEntity) { return true; } @Override - public boolean letsItemsOutImpl(byte aSide, int aCoverID, GT_Cover_Fluidfilter.FluidFilterData aCoverVariable, - int aSlot, ICoverable aTileEntity) { + public boolean letsItemsOutImpl(ForgeDirection side, int aCoverID, FluidFilterData aCoverVariable, int aSlot, + ICoverable aTileEntity) { return true; } @Override - protected boolean letsFluidInImpl(byte aSide, int aCoverID, FluidFilterData aCoverVariable, Fluid aFluid, + protected boolean letsFluidInImpl(ForgeDirection side, int aCoverID, FluidFilterData aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { if (aFluid == null) return true; @@ -192,7 +192,7 @@ else if (aFluid.getID() == aFilterFluid) } @Override - protected boolean letsFluidOutImpl(byte aSide, int aCoverID, FluidFilterData aCoverVariable, Fluid aFluid, + protected boolean letsFluidOutImpl(ForgeDirection side, int aCoverID, FluidFilterData aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { if (aFluid == null) return true; @@ -207,13 +207,14 @@ else if (aFluid.getID() == aFilterFluid) } @Override - protected boolean alwaysLookConnectedImpl(byte aSide, int aCoverID, FluidFilterData aCoverVariable, + protected boolean alwaysLookConnectedImpl(ForgeDirection side, int aCoverID, FluidFilterData aCoverVariable, ICoverable aTileEntity) { return true; } @Override - protected int getTickRateImpl(byte aSide, int aCoverID, FluidFilterData aCoverVariable, ICoverable aTileEntity) { + protected int getTickRateImpl(ForgeDirection side, int aCoverID, FluidFilterData aCoverVariable, + ICoverable aTileEntity) { return 0; } diff --git a/src/main/java/gregtech/common/covers/GT_Cover_ItemFilter.java b/src/main/java/gregtech/common/covers/GT_Cover_ItemFilter.java index 0e5f57ad6da..c0cdee78a37 100644 --- a/src/main/java/gregtech/common/covers/GT_Cover_ItemFilter.java +++ b/src/main/java/gregtech/common/covers/GT_Cover_ItemFilter.java @@ -15,6 +15,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.Constants; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.Fluid; import com.google.common.io.ByteArrayDataInput; @@ -63,27 +64,28 @@ public ItemFilterData createDataObject() { } @Override - protected boolean isRedstoneSensitiveImpl(byte aSide, int aCoverID, ItemFilterData aCoverVariable, + protected boolean isRedstoneSensitiveImpl(ForgeDirection side, int aCoverID, ItemFilterData aCoverVariable, ICoverable aTileEntity, long aTimer) { return false; } @Override - protected ItemFilterData doCoverThingsImpl(byte aSide, byte aInputRedstone, int aCoverID, + protected ItemFilterData doCoverThingsImpl(ForgeDirection side, byte aInputRedstone, int aCoverID, ItemFilterData aCoverVariable, ICoverable aTileEntity, long aTimer) { - TileEntity tTileEntity = aTileEntity.getTileEntityAtSide(aSide); - Object fromEntity = mExport ? aTileEntity : tTileEntity, toEntity = !mExport ? aTileEntity : tTileEntity; - byte fromSide = !mExport ? GT_Utility.getOppositeSide(aSide) : aSide, - toSide = mExport ? GT_Utility.getOppositeSide(aSide) : aSide; + final TileEntity tTileEntity = aTileEntity.getTileEntityAtSide(side); + final Object fromEntity = mExport ? aTileEntity : tTileEntity; + final Object toEntity = !mExport ? aTileEntity : tTileEntity; + final ForgeDirection fromSide = !mExport ? side.getOpposite() : side; + final ForgeDirection toSide = mExport ? side.getOpposite() : side; - List Filter = Collections.singletonList(aCoverVariable.mFilter); + final List filter = Collections.singletonList(aCoverVariable.mFilter); moveMultipleItemStacks( fromEntity, toEntity, fromSide, toSide, - Filter, + filter, aCoverVariable.mWhitelist, (byte) 64, (byte) 1, @@ -95,9 +97,9 @@ protected ItemFilterData doCoverThingsImpl(byte aSide, byte aInputRedstone, int } @Override - protected boolean onCoverRightClickImpl(byte aSide, int aCoverID, ItemFilterData aCoverVariable, + protected boolean onCoverRightClickImpl(ForgeDirection side, int aCoverID, ItemFilterData aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) { - ItemStack tStack = aPlayer.inventory.getCurrentItem(); + final ItemStack tStack = aPlayer.inventory.getCurrentItem(); if (tStack != null) { aCoverVariable.mFilter = tStack; GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("299", "Item Filter: ") + tStack.getDisplayName()); @@ -109,8 +111,8 @@ protected boolean onCoverRightClickImpl(byte aSide, int aCoverID, ItemFilterData } @Override - protected ItemFilterData onCoverScrewdriverClickImpl(byte aSide, int aCoverID, ItemFilterData aCoverVariable, - ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) { + protected ItemFilterData onCoverScrewdriverClickImpl(ForgeDirection side, int aCoverID, + ItemFilterData aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) { aCoverVariable.mWhitelist = !aCoverVariable.mWhitelist; GT_Utility.sendChatToPlayer( aPlayer, @@ -120,61 +122,62 @@ protected ItemFilterData onCoverScrewdriverClickImpl(byte aSide, int aCoverID, I } @Override - protected boolean letsRedstoneGoInImpl(byte aSide, int aCoverID, ItemFilterData aCoverVariable, + protected boolean letsRedstoneGoInImpl(ForgeDirection side, int aCoverID, ItemFilterData aCoverVariable, ICoverable aTileEntity) { return true; } @Override - protected boolean letsRedstoneGoOutImpl(byte aSide, int aCoverID, ItemFilterData aCoverVariable, + protected boolean letsRedstoneGoOutImpl(ForgeDirection side, int aCoverID, ItemFilterData aCoverVariable, ICoverable aTileEntity) { return true; } @Override - protected boolean letsEnergyInImpl(byte aSide, int aCoverID, ItemFilterData aCoverVariable, + protected boolean letsEnergyInImpl(ForgeDirection side, int aCoverID, ItemFilterData aCoverVariable, ICoverable aTileEntity) { return true; } @Override - protected boolean letsEnergyOutImpl(byte aSide, int aCoverID, ItemFilterData aCoverVariable, + protected boolean letsEnergyOutImpl(ForgeDirection side, int aCoverID, ItemFilterData aCoverVariable, ICoverable aTileEntity) { return true; } @Override - protected boolean letsFluidInImpl(byte aSide, int aCoverID, ItemFilterData aCoverVariable, Fluid aFluid, + protected boolean letsFluidInImpl(ForgeDirection side, int aCoverID, ItemFilterData aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { return false; } @Override - protected boolean letsFluidOutImpl(byte aSide, int aCoverID, ItemFilterData aCoverVariable, Fluid aFluid, + protected boolean letsFluidOutImpl(ForgeDirection side, int aCoverID, ItemFilterData aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { return false; } @Override - protected boolean letsItemsInImpl(byte aSide, int aCoverID, ItemFilterData aCoverVariable, int aSlot, + protected boolean letsItemsInImpl(ForgeDirection side, int aCoverID, ItemFilterData aCoverVariable, int aSlot, ICoverable aTileEntity) { return true; } @Override - protected boolean letsItemsOutImpl(byte aSide, int aCoverID, ItemFilterData aCoverVariable, int aSlot, + protected boolean letsItemsOutImpl(ForgeDirection side, int aCoverID, ItemFilterData aCoverVariable, int aSlot, ICoverable aTileEntity) { return true; } @Override - protected boolean alwaysLookConnectedImpl(byte aSide, int aCoverID, ItemFilterData aCoverVariable, + protected boolean alwaysLookConnectedImpl(ForgeDirection side, int aCoverID, ItemFilterData aCoverVariable, ICoverable aTileEntity) { return true; } @Override - protected int getTickRateImpl(byte aSide, int aCoverID, ItemFilterData aCoverVariable, ICoverable aTileEntity) { + protected int getTickRateImpl(ForgeDirection side, int aCoverID, ItemFilterData aCoverVariable, + ICoverable aTileEntity) { return 1; } 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 99241731fcd..86c0f4c4dc0 100644 --- a/src/main/java/gregtech/common/covers/GT_Cover_ItemMeter.java +++ b/src/main/java/gregtech/common/covers/GT_Cover_ItemMeter.java @@ -8,6 +8,7 @@ import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.Fluid; import com.google.common.io.ByteArrayDataInput; @@ -71,16 +72,16 @@ public ItemMeterData createDataObject() { } @Override - protected boolean isRedstoneSensitiveImpl(byte aSide, int aCoverID, ItemMeterData aCoverVariable, + protected boolean isRedstoneSensitiveImpl(ForgeDirection side, int aCoverID, ItemMeterData aCoverVariable, ICoverable aTileEntity, long aTimer) { return false; } public static byte computeSignalBasedOnItems(ICoverable tileEntity, boolean inverted, int threshold, int slot, - int side) { + int ordinalSide) { long max = 0; long used = 0; - IMetaTileEntity mte = ((IGregTechTileEntity) tileEntity).getMetaTileEntity(); + final IMetaTileEntity mte = ((IGregTechTileEntity) tileEntity).getMetaTileEntity(); if (mte instanceof GT_MetaTileEntity_DigitalChestBase dc) { max = dc.getMaxItemCount(); used = dc.getProgresstime(); @@ -90,12 +91,12 @@ public static byte computeSignalBasedOnItems(ICoverable tileEntity, boolean inve used = 64; } } else { - int[] slots = slot >= 0 ? new int[] { slot } : tileEntity.getAccessibleSlotsFromSide(side); + final int[] slots = slot >= 0 ? new int[] { slot } : tileEntity.getAccessibleSlotsFromSide(ordinalSide); for (int i : slots) { if (i >= 0 && i < tileEntity.getSizeInventory()) { max += 64; - ItemStack stack = tileEntity.getStackInSlot(i); + final ItemStack stack = tileEntity.getStackInSlot(i); if (stack != null) used += ((long) stack.stackSize << 6) / stack.getMaxStackSize(); } } @@ -105,21 +106,21 @@ public static byte computeSignalBasedOnItems(ICoverable tileEntity, boolean inve } @Override - protected ItemMeterData doCoverThingsImpl(byte aSide, byte aInputRedstone, int aCoverID, + protected ItemMeterData doCoverThingsImpl(ForgeDirection side, byte aInputRedstone, int aCoverID, ItemMeterData aCoverVariable, ICoverable aTileEntity, long aTimer) { byte signal = computeSignalBasedOnItems( aTileEntity, aCoverVariable.inverted, aCoverVariable.threshold, aCoverVariable.slot, - aSide); - aTileEntity.setOutputRedstoneSignal(aSide, signal); + side.ordinal()); + aTileEntity.setOutputRedstoneSignal(side, signal); return aCoverVariable; } @Override - protected ItemMeterData onCoverScrewdriverClickImpl(byte aSide, int aCoverID, ItemMeterData aCoverVariable, + protected ItemMeterData onCoverScrewdriverClickImpl(ForgeDirection side, int aCoverID, ItemMeterData aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) { if (aPlayer.isSneaking()) { if (aCoverVariable.inverted) { @@ -142,48 +143,50 @@ protected ItemMeterData onCoverScrewdriverClickImpl(byte aSide, int aCoverID, It } @Override - protected boolean letsEnergyInImpl(byte aSide, int aCoverID, ItemMeterData aCoverVariable, ICoverable aTileEntity) { + protected boolean letsEnergyInImpl(ForgeDirection side, int aCoverID, ItemMeterData aCoverVariable, + ICoverable aTileEntity) { return true; } @Override - protected boolean letsEnergyOutImpl(byte aSide, int aCoverID, ItemMeterData aCoverVariable, + protected boolean letsEnergyOutImpl(ForgeDirection side, int aCoverID, ItemMeterData aCoverVariable, ICoverable aTileEntity) { return true; } @Override - protected boolean letsFluidInImpl(byte aSide, int aCoverID, ItemMeterData aCoverVariable, Fluid aFluid, + protected boolean letsFluidInImpl(ForgeDirection side, int aCoverID, ItemMeterData aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { return true; } @Override - protected boolean letsFluidOutImpl(byte aSide, int aCoverID, ItemMeterData aCoverVariable, Fluid aFluid, + protected boolean letsFluidOutImpl(ForgeDirection side, int aCoverID, ItemMeterData aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { return true; } @Override - protected boolean letsItemsInImpl(byte aSide, int aCoverID, ItemMeterData aCoverVariable, int aSlot, + protected boolean letsItemsInImpl(ForgeDirection side, int aCoverID, ItemMeterData aCoverVariable, int aSlot, ICoverable aTileEntity) { return true; } @Override - protected boolean letsItemsOutImpl(byte aSide, int aCoverID, ItemMeterData aCoverVariable, int aSlot, + protected boolean letsItemsOutImpl(ForgeDirection side, int aCoverID, ItemMeterData aCoverVariable, int aSlot, ICoverable aTileEntity) { return true; } @Override - protected boolean manipulatesSidedRedstoneOutputImpl(byte aSide, int aCoverID, ItemMeterData aCoverVariable, - ICoverable aTileEntity) { + protected boolean manipulatesSidedRedstoneOutputImpl(ForgeDirection side, int aCoverID, + ItemMeterData aCoverVariable, ICoverable aTileEntity) { return true; } @Override - protected int getTickRateImpl(byte aSide, int aCoverID, ItemMeterData aCoverVariable, ICoverable aTileEntity) { + protected int getTickRateImpl(ForgeDirection side, int aCoverID, ItemMeterData aCoverVariable, + ICoverable aTileEntity) { return 5; } diff --git a/src/main/java/gregtech/common/covers/GT_Cover_Lens.java b/src/main/java/gregtech/common/covers/GT_Cover_Lens.java index 092973767a2..9e531e552cc 100644 --- a/src/main/java/gregtech/common/covers/GT_Cover_Lens.java +++ b/src/main/java/gregtech/common/covers/GT_Cover_Lens.java @@ -1,5 +1,7 @@ package gregtech.common.covers; +import net.minecraftforge.common.util.ForgeDirection; + import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.ICoverable; import gregtech.api.util.GT_CoverBehavior; @@ -22,13 +24,13 @@ public GT_Cover_Lens(byte aColor, ITexture coverTexture) { } @Override - public boolean isRedstoneSensitive(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, + public boolean isRedstoneSensitive(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) { return false; } @Override - public byte getLensColor(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public byte getLensColor(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return this.mColor; } } 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 af97e190ce6..ef60efb01a1 100644 --- a/src/main/java/gregtech/common/covers/GT_Cover_LiquidMeter.java +++ b/src/main/java/gregtech/common/covers/GT_Cover_LiquidMeter.java @@ -34,7 +34,7 @@ /** * TODO: Implement overlay rendering only with - * {@link GT_CoverBehaviorBase#getSpecialCoverFGTextureImpl(byte, int, ISerializableObject, ICoverable)} + * {@link GT_CoverBehaviorBase#getSpecialCoverFGTextureImpl(ForgeDirection, int, ISerializableObject, ICoverable)} */ public class GT_Cover_LiquidMeter extends GT_CoverBehaviorBase { @@ -53,7 +53,7 @@ public LiquidMeterData createDataObject() { } @Override - protected boolean isRedstoneSensitiveImpl(byte aSide, int aCoverID, LiquidMeterData aCoverVariable, + protected boolean isRedstoneSensitiveImpl(ForgeDirection side, int aCoverID, LiquidMeterData aCoverVariable, ICoverable aTileEntity, long aTimer) { return false; } @@ -86,21 +86,21 @@ public static byte computeSignalBasedOnFluid(ICoverable tileEntity, boolean inve } @Override - protected LiquidMeterData doCoverThingsImpl(byte aSide, byte aInputRedstone, int aCoverID, + protected LiquidMeterData doCoverThingsImpl(ForgeDirection side, byte aInputRedstone, int aCoverID, LiquidMeterData aCoverVariable, ICoverable aTileEntity, long aTimer) { byte signal = computeSignalBasedOnFluid(aTileEntity, aCoverVariable.inverted, aCoverVariable.threshold); if (aCoverVariable.strong) { - aTileEntity.setStrongOutputRedstoneSignal(aSide, signal); + aTileEntity.setStrongOutputRedstoneSignal(side, signal); } else { - aTileEntity.setOutputRedstoneSignal(aSide, signal); + aTileEntity.setOutputRedstoneSignal(side, signal); } return aCoverVariable; } @Override - protected LiquidMeterData onCoverScrewdriverClickImpl(byte aSide, int aCoverID, LiquidMeterData aCoverVariable, - ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) { + protected LiquidMeterData onCoverScrewdriverClickImpl(ForgeDirection side, int aCoverID, + LiquidMeterData aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) { if (aCoverVariable.inverted) { aCoverVariable.inverted = false; GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("055", "Normal")); @@ -112,49 +112,50 @@ protected LiquidMeterData onCoverScrewdriverClickImpl(byte aSide, int aCoverID, } @Override - protected boolean letsEnergyInImpl(byte aSide, int aCoverID, LiquidMeterData aCoverVariable, + protected boolean letsEnergyInImpl(ForgeDirection side, int aCoverID, LiquidMeterData aCoverVariable, ICoverable aTileEntity) { return true; } @Override - protected boolean letsEnergyOutImpl(byte aSide, int aCoverID, LiquidMeterData aCoverVariable, + protected boolean letsEnergyOutImpl(ForgeDirection side, int aCoverID, LiquidMeterData aCoverVariable, ICoverable aTileEntity) { return true; } @Override - protected boolean letsFluidInImpl(byte aSide, int aCoverID, LiquidMeterData aCoverVariable, Fluid aFluid, + protected boolean letsFluidInImpl(ForgeDirection side, int aCoverID, LiquidMeterData aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { return true; } @Override - protected boolean letsFluidOutImpl(byte aSide, int aCoverID, LiquidMeterData aCoverVariable, Fluid aFluid, + protected boolean letsFluidOutImpl(ForgeDirection side, int aCoverID, LiquidMeterData aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { return true; } @Override - protected boolean letsItemsInImpl(byte aSide, int aCoverID, LiquidMeterData aCoverVariable, int aSlot, + protected boolean letsItemsInImpl(ForgeDirection side, int aCoverID, LiquidMeterData aCoverVariable, int aSlot, ICoverable aTileEntity) { return true; } @Override - protected boolean letsItemsOutImpl(byte aSide, int aCoverID, LiquidMeterData aCoverVariable, int aSlot, + protected boolean letsItemsOutImpl(ForgeDirection side, int aCoverID, LiquidMeterData aCoverVariable, int aSlot, ICoverable aTileEntity) { return true; } @Override - protected boolean manipulatesSidedRedstoneOutputImpl(byte aSide, int aCoverID, LiquidMeterData aCoverVariable, - ICoverable aTileEntity) { + protected boolean manipulatesSidedRedstoneOutputImpl(ForgeDirection side, int aCoverID, + LiquidMeterData aCoverVariable, ICoverable aTileEntity) { return true; } @Override - protected int getTickRateImpl(byte aSide, int aCoverID, LiquidMeterData aCoverVariable, ICoverable aTileEntity) { + protected int getTickRateImpl(ForgeDirection side, int aCoverID, LiquidMeterData aCoverVariable, + ICoverable aTileEntity) { return 5; } 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 5fc9354c182..712c3a94bb5 100644 --- a/src/main/java/gregtech/common/covers/GT_Cover_NeedMaintainance.java +++ b/src/main/java/gregtech/common/covers/GT_Cover_NeedMaintainance.java @@ -2,6 +2,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.Fluid; import com.gtnewhorizons.modularui.api.screen.ModularWindow; @@ -41,22 +42,22 @@ public static boolean isRotor(ItemStack rotor) { } @Override - public boolean isRedstoneSensitive(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, + public boolean isRedstoneSensitive(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) { return false; } @Override - public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity, - long aTimer) { + public int doCoverThings(ForgeDirection side, byte aInputRedstone, int aCoverID, int aCoverVariable, + ICoverable aTileEntity, long aTimer) { boolean needsRepair = false; if (aTileEntity instanceof IGregTechTileEntity tTileEntity) { - IMetaTileEntity mTileEntity = tTileEntity.getMetaTileEntity(); + final IMetaTileEntity mTileEntity = tTileEntity.getMetaTileEntity(); if (mTileEntity instanceof GT_MetaTileEntity_MultiBlockBase multi) { - int ideal = multi.getIdealStatus(); - int real = multi.getRepairStatus(); - ItemStack tRotor = multi.getRealInventory()[1]; - int coverVar = aCoverVariable >>> 1; + final int ideal = multi.getIdealStatus(); + final int real = multi.getRepairStatus(); + final ItemStack tRotor = multi.getRealInventory()[1]; + final int coverVar = aCoverVariable >>> 1; if (coverVar < 5) { if (ideal - real > coverVar) needsRepair = true; } else if (coverVar == 5 || coverVar == 6) { @@ -82,13 +83,13 @@ public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCov needsRepair = !needsRepair; } - aTileEntity.setOutputRedstoneSignal(aSide, (byte) (needsRepair ? 0 : 15)); - aTileEntity.setOutputRedstoneSignal(GT_Utility.getOppositeSide(aSide), (byte) (needsRepair ? 0 : 15)); + aTileEntity.setOutputRedstoneSignal(side, (byte) (needsRepair ? 0 : 15)); + aTileEntity.setOutputRedstoneSignal(side.getOpposite(), (byte) (needsRepair ? 0 : 15)); return aCoverVariable; } @Override - public int onCoverScrewdriverclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, + public int onCoverScrewdriverclick(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) { aCoverVariable = (aCoverVariable + (aPlayer.isSneaking() ? -1 : 1)) % 14; if (aCoverVariable < 0) { @@ -126,43 +127,47 @@ public int onCoverScrewdriverclick(byte aSide, int aCoverID, int aCoverVariable, } @Override - public boolean letsEnergyIn(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public boolean letsEnergyIn(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return true; } @Override - public boolean letsEnergyOut(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public boolean letsEnergyOut(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return true; } @Override - public boolean letsFluidIn(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { + public boolean letsFluidIn(ForgeDirection side, int aCoverID, int aCoverVariable, Fluid aFluid, + ICoverable aTileEntity) { return true; } @Override - public boolean letsFluidOut(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { + public boolean letsFluidOut(ForgeDirection side, int aCoverID, int aCoverVariable, Fluid aFluid, + ICoverable aTileEntity) { return true; } @Override - public boolean letsItemsIn(byte aSide, int aCoverID, int aCoverVariable, int aSlot, ICoverable aTileEntity) { + public boolean letsItemsIn(ForgeDirection side, int aCoverID, int aCoverVariable, int aSlot, + ICoverable aTileEntity) { return true; } @Override - public boolean letsItemsOut(byte aSide, int aCoverID, int aCoverVariable, int aSlot, ICoverable aTileEntity) { + public boolean letsItemsOut(ForgeDirection side, int aCoverID, int aCoverVariable, int aSlot, + ICoverable aTileEntity) { return true; } @Override - public boolean manipulatesSidedRedstoneOutput(byte aSide, int aCoverID, int aCoverVariable, + public boolean manipulatesSidedRedstoneOutput(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return true; } @Override - public int getTickRate(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public int getTickRate(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return 60; } 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 13054bccf62..8d0b7d46b57 100644 --- a/src/main/java/gregtech/common/covers/GT_Cover_PlayerDetector.java +++ b/src/main/java/gregtech/common/covers/GT_Cover_PlayerDetector.java @@ -2,6 +2,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.Fluid; import com.gtnewhorizons.modularui.api.screen.ModularWindow; @@ -35,14 +36,14 @@ public GT_Cover_PlayerDetector(ITexture coverTexture) { } @Override - public boolean isRedstoneSensitive(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, + public boolean isRedstoneSensitive(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) { return false; } @Override - public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity, - long aTimer) { + public int doCoverThings(ForgeDirection side, byte aInputRedstone, int aCoverID, int aCoverVariable, + ICoverable aTileEntity, long aTimer) { boolean playerDetected = false; if (aTileEntity instanceof IGregTechTileEntity) { @@ -81,12 +82,12 @@ public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCov } } - aTileEntity.setOutputRedstoneSignal(aSide, (byte) (playerDetected ? 15 : 0)); + aTileEntity.setOutputRedstoneSignal(side, (byte) (playerDetected ? 15 : 0)); return aCoverVariable; } @Override - public int onCoverScrewdriverclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, + public int onCoverScrewdriverclick(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) { aCoverVariable = (aCoverVariable + (aPlayer.isSneaking() ? -1 : 1)) % 3; if (aCoverVariable < 0) { @@ -101,43 +102,47 @@ public int onCoverScrewdriverclick(byte aSide, int aCoverID, int aCoverVariable, } @Override - public boolean letsEnergyIn(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public boolean letsEnergyIn(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return true; } @Override - public boolean letsEnergyOut(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public boolean letsEnergyOut(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return true; } @Override - public boolean letsFluidIn(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { + public boolean letsFluidIn(ForgeDirection side, int aCoverID, int aCoverVariable, Fluid aFluid, + ICoverable aTileEntity) { return true; } @Override - public boolean letsFluidOut(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { + public boolean letsFluidOut(ForgeDirection side, int aCoverID, int aCoverVariable, Fluid aFluid, + ICoverable aTileEntity) { return true; } @Override - public boolean letsItemsIn(byte aSide, int aCoverID, int aCoverVariable, int aSlot, ICoverable aTileEntity) { + public boolean letsItemsIn(ForgeDirection side, int aCoverID, int aCoverVariable, int aSlot, + ICoverable aTileEntity) { return true; } @Override - public boolean letsItemsOut(byte aSide, int aCoverID, int aCoverVariable, int aSlot, ICoverable aTileEntity) { + public boolean letsItemsOut(ForgeDirection side, int aCoverID, int aCoverVariable, int aSlot, + ICoverable aTileEntity) { return true; } @Override - public boolean manipulatesSidedRedstoneOutput(byte aSide, int aCoverID, int aCoverVariable, + public boolean manipulatesSidedRedstoneOutput(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return true; } @Override - public int getTickRate(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public int getTickRate(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return 20; } 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 045eec872c1..278bf488e35 100644 --- a/src/main/java/gregtech/common/covers/GT_Cover_Pump.java +++ b/src/main/java/gregtech/common/covers/GT_Cover_Pump.java @@ -38,59 +38,40 @@ public GT_Cover_Pump(int aTransferRate, ITexture coverTexture) { } @Override - public boolean isRedstoneSensitive(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, + public boolean isRedstoneSensitive(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) { return false; } @Override - public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity, - long aTimer) { + public int doCoverThings(ForgeDirection side, byte aInputRedstone, int aCoverID, int aCoverVariable, + ICoverable aTileEntity, long aTimer) { if ((aCoverVariable % 6 > 1) && ((aTileEntity instanceof IMachineProgress))) { if (((IMachineProgress) aTileEntity).isAllowedToWork() != aCoverVariable % 6 < 4) { return aCoverVariable; } } if ((aTileEntity instanceof IFluidHandler)) { - IFluidHandler tTank2 = aTileEntity.getITankContainerAtSide(aSide); + final IFluidHandler tTank2 = aTileEntity.getITankContainerAtSide(side); if (tTank2 != null) { // aTileEntity.decreaseStoredEnergyUnits(GT_Utility.getTier(this.mTransferRate), true); - IFluidHandler tTank1 = (IFluidHandler) aTileEntity; + final IFluidHandler tTank1 = (IFluidHandler) aTileEntity; if (aCoverVariable % 2 == 0) { - FluidStack tLiquid = tTank1.drain(ForgeDirection.getOrientation(aSide), this.mTransferRate, false); + FluidStack tLiquid = tTank1.drain(side, this.mTransferRate, false); if (tLiquid != null) { tLiquid = tLiquid.copy(); - tLiquid.amount = tTank2.fill( - ForgeDirection.getOrientation(aSide) - .getOpposite(), - tLiquid, - false); + tLiquid.amount = tTank2.fill(side.getOpposite(), tLiquid, false); if (tLiquid.amount > 0 && canTransferFluid(tLiquid)) { - tTank2.fill( - ForgeDirection.getOrientation(aSide) - .getOpposite(), - tTank1.drain(ForgeDirection.getOrientation(aSide), tLiquid.amount, true), - true); + tTank2.fill(side.getOpposite(), tTank1.drain(side, tLiquid.amount, true), true); } } } else { - FluidStack tLiquid = tTank2.drain( - ForgeDirection.getOrientation(aSide) - .getOpposite(), - this.mTransferRate, - false); + FluidStack tLiquid = tTank2.drain(side.getOpposite(), this.mTransferRate, false); if (tLiquid != null) { tLiquid = tLiquid.copy(); - tLiquid.amount = tTank1.fill(ForgeDirection.getOrientation(aSide), tLiquid, false); + tLiquid.amount = tTank1.fill(side, tLiquid, false); if (tLiquid.amount > 0 && canTransferFluid(tLiquid)) { - tTank1.fill( - ForgeDirection.getOrientation(aSide), - tTank2.drain( - ForgeDirection.getOrientation(aSide) - .getOpposite(), - tLiquid.amount, - true), - true); + tTank1.fill(side, tTank2.drain(side.getOpposite(), tLiquid.amount, true), true); } } } @@ -104,7 +85,7 @@ protected boolean canTransferFluid(FluidStack fluid) { } @Override - public int onCoverScrewdriverclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, + public int onCoverScrewdriverclick(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) { aCoverVariable = (aCoverVariable + (aPlayer.isSneaking() ? -1 : 1)) % 12; if (aCoverVariable < 0) { @@ -131,37 +112,40 @@ public int onCoverScrewdriverclick(byte aSide, int aCoverID, int aCoverVariable, } @Override - public boolean letsRedstoneGoIn(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public boolean letsRedstoneGoIn(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return true; } @Override - public boolean letsRedstoneGoOut(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public boolean letsRedstoneGoOut(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return true; } @Override - public boolean letsEnergyIn(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public boolean letsEnergyIn(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return true; } @Override - public boolean letsEnergyOut(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public boolean letsEnergyOut(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return true; } @Override - public boolean letsItemsIn(byte aSide, int aCoverID, int aCoverVariable, int aSlot, ICoverable aTileEntity) { + public boolean letsItemsIn(ForgeDirection side, int aCoverID, int aCoverVariable, int aSlot, + ICoverable aTileEntity) { return true; } @Override - public boolean letsItemsOut(byte aSide, int aCoverID, int aCoverVariable, int aSlot, ICoverable aTileEntity) { + public boolean letsItemsOut(ForgeDirection side, int aCoverID, int aCoverVariable, int aSlot, + ICoverable aTileEntity) { return true; } @Override - public boolean letsFluidIn(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { + public boolean letsFluidIn(ForgeDirection side, int aCoverID, int aCoverVariable, Fluid aFluid, + ICoverable aTileEntity) { if ((aCoverVariable > 1) && ((aTileEntity instanceof IMachineProgress))) { if (((IMachineProgress) aTileEntity).isAllowedToWork() != aCoverVariable % 6 < 4) { return false; @@ -171,7 +155,8 @@ public boolean letsFluidIn(byte aSide, int aCoverID, int aCoverVariable, Fluid a } @Override - public boolean letsFluidOut(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { + public boolean letsFluidOut(ForgeDirection side, int aCoverID, int aCoverVariable, Fluid aFluid, + ICoverable aTileEntity) { if ((aCoverVariable > 1) && ((aTileEntity instanceof IMachineProgress))) { if (((IMachineProgress) aTileEntity).isAllowedToWork() != aCoverVariable % 6 < 4) { return false; @@ -181,12 +166,12 @@ public boolean letsFluidOut(byte aSide, int aCoverID, int aCoverVariable, Fluid } @Override - public boolean alwaysLookConnected(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public boolean alwaysLookConnected(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return true; } @Override - public int getTickRate(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public int getTickRate(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return 1; } diff --git a/src/main/java/gregtech/common/covers/GT_Cover_RedstoneConductor.java b/src/main/java/gregtech/common/covers/GT_Cover_RedstoneConductor.java index 7205876fcaf..edaec13a812 100644 --- a/src/main/java/gregtech/common/covers/GT_Cover_RedstoneConductor.java +++ b/src/main/java/gregtech/common/covers/GT_Cover_RedstoneConductor.java @@ -1,6 +1,7 @@ package gregtech.common.covers; import net.minecraft.entity.player.EntityPlayer; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.Fluid; import gregtech.api.interfaces.ITexture; @@ -16,26 +17,26 @@ public class GT_Cover_RedstoneConductor extends GT_CoverBehavior { } @Override - public boolean isRedstoneSensitive(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, + public boolean isRedstoneSensitive(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) { return false; } @Override - public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity, - long aTimer) { + public int doCoverThings(ForgeDirection side, byte aInputRedstone, int aCoverID, int aCoverVariable, + ICoverable aTileEntity, long aTimer) { if (aCoverVariable == 0) { - aTileEntity.setOutputRedstoneSignal(aSide, aTileEntity.getStrongestRedstone()); + aTileEntity.setOutputRedstoneSignal(side, aTileEntity.getStrongestRedstone()); } else if (aCoverVariable < 7) { aTileEntity.setOutputRedstoneSignal( - aSide, - aTileEntity.getInternalInputRedstoneSignal((byte) (aCoverVariable - 1))); + side, + aTileEntity.getInternalInputRedstoneSignal(ForgeDirection.getOrientation((aCoverVariable - 1)))); } return aCoverVariable; } @Override - public int onCoverScrewdriverclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, + public int onCoverScrewdriverclick(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) { aCoverVariable = (aCoverVariable + (aPlayer.isSneaking() ? -1 : 1)) % 7; if (aCoverVariable < 0) { @@ -54,43 +55,47 @@ public int onCoverScrewdriverclick(byte aSide, int aCoverID, int aCoverVariable, } @Override - public boolean letsEnergyIn(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public boolean letsEnergyIn(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return true; } @Override - public boolean letsEnergyOut(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public boolean letsEnergyOut(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return true; } @Override - public boolean letsFluidIn(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { + public boolean letsFluidIn(ForgeDirection side, int aCoverID, int aCoverVariable, Fluid aFluid, + ICoverable aTileEntity) { return true; } @Override - public boolean letsFluidOut(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { + public boolean letsFluidOut(ForgeDirection side, int aCoverID, int aCoverVariable, Fluid aFluid, + ICoverable aTileEntity) { return true; } @Override - public boolean letsItemsIn(byte aSide, int aCoverID, int aCoverVariable, int aSlot, ICoverable aTileEntity) { + public boolean letsItemsIn(ForgeDirection side, int aCoverID, int aCoverVariable, int aSlot, + ICoverable aTileEntity) { return true; } @Override - public boolean letsItemsOut(byte aSide, int aCoverID, int aCoverVariable, int aSlot, ICoverable aTileEntity) { + public boolean letsItemsOut(ForgeDirection side, int aCoverID, int aCoverVariable, int aSlot, + ICoverable aTileEntity) { return true; } @Override - public boolean manipulatesSidedRedstoneOutput(byte aSide, int aCoverID, int aCoverVariable, + public boolean manipulatesSidedRedstoneOutput(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return true; } @Override - public int getTickRate(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public int getTickRate(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return 1; } } diff --git a/src/main/java/gregtech/common/covers/GT_Cover_RedstoneReceiverExternal.java b/src/main/java/gregtech/common/covers/GT_Cover_RedstoneReceiverExternal.java index 00890541bcb..963ef4cbbfe 100644 --- a/src/main/java/gregtech/common/covers/GT_Cover_RedstoneReceiverExternal.java +++ b/src/main/java/gregtech/common/covers/GT_Cover_RedstoneReceiverExternal.java @@ -1,5 +1,7 @@ package gregtech.common.covers; +import net.minecraftforge.common.util.ForgeDirection; + import gregtech.api.GregTech_API; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.ICoverable; @@ -19,29 +21,29 @@ public GT_Cover_RedstoneReceiverExternal(ITexture coverTexture) { } @Override - public boolean isRedstoneSensitive(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, + public boolean isRedstoneSensitive(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) { return false; } @Override - public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity, - long aTimer) { + public int doCoverThings(ForgeDirection side, byte aInputRedstone, int aCoverID, int aCoverVariable, + ICoverable aTileEntity, long aTimer) { aTileEntity.setOutputRedstoneSignal( - aSide, + side, GregTech_API.sWirelessRedstone.get(aCoverVariable) == null ? 0 : GregTech_API.sWirelessRedstone.get(aCoverVariable)); return aCoverVariable; } @Override - public boolean manipulatesSidedRedstoneOutput(byte aSide, int aCoverID, int aCoverVariable, + public boolean manipulatesSidedRedstoneOutput(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return true; } @Override - public int getTickRate(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public int getTickRate(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return 1; } } diff --git a/src/main/java/gregtech/common/covers/GT_Cover_RedstoneReceiverInternal.java b/src/main/java/gregtech/common/covers/GT_Cover_RedstoneReceiverInternal.java index 899db734afb..8b948617309 100644 --- a/src/main/java/gregtech/common/covers/GT_Cover_RedstoneReceiverInternal.java +++ b/src/main/java/gregtech/common/covers/GT_Cover_RedstoneReceiverInternal.java @@ -1,5 +1,7 @@ package gregtech.common.covers; +import net.minecraftforge.common.util.ForgeDirection; + import gregtech.api.GregTech_API; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.ICoverable; @@ -21,10 +23,10 @@ public GT_Cover_RedstoneReceiverInternal(ITexture coverTexture) { } @Override - public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity, - long aTimer) { + public int doCoverThings(ForgeDirection side, byte aInputRedstone, int aCoverID, int aCoverVariable, + ICoverable aTileEntity, long aTimer) { if (aTileEntity instanceof IMachineProgress) { - if (getRedstoneInput(aSide, aInputRedstone, aCoverID, aCoverVariable, aTileEntity) > 0) + if (getRedstoneInput(side, aInputRedstone, aCoverID, aCoverVariable, aTileEntity) > 0) ((IMachineProgress) aTileEntity).enableWorking(); else((IMachineProgress) aTileEntity).disableWorking(); ((IMachineProgress) aTileEntity).setWorkDataValue(aInputRedstone); @@ -33,20 +35,20 @@ public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCov } @Override - protected boolean isRedstoneSensitiveImpl(byte aSide, int aCoverID, + protected boolean isRedstoneSensitiveImpl(ForgeDirection side, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity, long aTimer) { return true; } @Override - public byte getRedstoneInput(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, + public byte getRedstoneInput(ForgeDirection side, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return GregTech_API.sWirelessRedstone.get(aCoverVariable) == null ? 0 : GregTech_API.sWirelessRedstone.get(aCoverVariable); } @Override - public int getTickRate(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public int getTickRate(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return 1; } } diff --git a/src/main/java/gregtech/common/covers/GT_Cover_RedstoneSignalizer.java b/src/main/java/gregtech/common/covers/GT_Cover_RedstoneSignalizer.java index d8ace5b4d2c..4eead134c8a 100644 --- a/src/main/java/gregtech/common/covers/GT_Cover_RedstoneSignalizer.java +++ b/src/main/java/gregtech/common/covers/GT_Cover_RedstoneSignalizer.java @@ -1,6 +1,7 @@ package gregtech.common.covers; import net.minecraft.entity.player.EntityPlayer; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.Fluid; import gregtech.api.interfaces.ITexture; @@ -17,13 +18,13 @@ public class GT_Cover_RedstoneSignalizer extends GT_CoverBehavior { } @Override - public boolean isRedstoneSensitive(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, + public boolean isRedstoneSensitive(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) { return false; } @Override - public int onCoverScrewdriverclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, + public int onCoverScrewdriverclick(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) { aCoverVariable = (aCoverVariable + 1) % 48; switch (aCoverVariable / 16) { @@ -39,42 +40,46 @@ public int onCoverScrewdriverclick(byte aSide, int aCoverID, int aCoverVariable, } @Override - public boolean letsRedstoneGoIn(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public boolean letsRedstoneGoIn(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return true; } @Override - public boolean letsEnergyIn(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public boolean letsEnergyIn(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return true; } @Override - public boolean letsEnergyOut(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public boolean letsEnergyOut(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return true; } @Override - public boolean letsFluidIn(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { + public boolean letsFluidIn(ForgeDirection side, int aCoverID, int aCoverVariable, Fluid aFluid, + ICoverable aTileEntity) { return true; } @Override - public boolean letsFluidOut(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { + public boolean letsFluidOut(ForgeDirection side, int aCoverID, int aCoverVariable, Fluid aFluid, + ICoverable aTileEntity) { return true; } @Override - public boolean letsItemsIn(byte aSide, int aCoverID, int aCoverVariable, int aSlot, ICoverable aTileEntity) { + public boolean letsItemsIn(ForgeDirection side, int aCoverID, int aCoverVariable, int aSlot, + ICoverable aTileEntity) { return true; } @Override - public boolean letsItemsOut(byte aSide, int aCoverID, int aCoverVariable, int aSlot, ICoverable aTileEntity) { + public boolean letsItemsOut(ForgeDirection side, int aCoverID, int aCoverVariable, int aSlot, + ICoverable aTileEntity) { return true; } @Override - public byte getRedstoneInput(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, + public byte getRedstoneInput(ForgeDirection side, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { if (aCoverVariable < 16) { return (byte) (aCoverVariable & 0xF); diff --git a/src/main/java/gregtech/common/covers/GT_Cover_RedstoneTransmitterExternal.java b/src/main/java/gregtech/common/covers/GT_Cover_RedstoneTransmitterExternal.java index 05374fb096c..e2efbc3d873 100644 --- a/src/main/java/gregtech/common/covers/GT_Cover_RedstoneTransmitterExternal.java +++ b/src/main/java/gregtech/common/covers/GT_Cover_RedstoneTransmitterExternal.java @@ -1,8 +1,7 @@ package gregtech.common.covers; -import static gregtech.api.enums.GT_Values.ALL_VALID_SIDES; - import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; import gregtech.api.GregTech_API; import gregtech.api.interfaces.ITexture; @@ -25,34 +24,34 @@ public GT_Cover_RedstoneTransmitterExternal(ITexture coverTexture) { } @Override - public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity, - long aTimer) { + public int doCoverThings(ForgeDirection side, byte aInputRedstone, int aCoverID, int aCoverVariable, + ICoverable aTileEntity, long aTimer) { // TODO remove next line after 2.3.0 - if (!IControlsWorkCover.makeSureOnlyOne(aSide, aTileEntity)) return aCoverVariable; + if (!IControlsWorkCover.makeSureOnlyOne(side, aTileEntity)) return aCoverVariable; GregTech_API.sWirelessRedstone.put(aCoverVariable, aInputRedstone); return aCoverVariable; } @Override - protected boolean isRedstoneSensitiveImpl(byte aSide, int aCoverID, + protected boolean isRedstoneSensitiveImpl(ForgeDirection side, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity, long aTimer) { return true; } @Override - public boolean letsRedstoneGoIn(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public boolean letsRedstoneGoIn(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return true; } @Override - public int getTickRate(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public int getTickRate(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return 1; } @Override - public boolean isCoverPlaceable(byte aSide, ItemStack aStack, ICoverable aTileEntity) { - if (!super.isCoverPlaceable(aSide, aStack, aTileEntity)) return false; - for (byte tSide : ALL_VALID_SIDES) { + public boolean isCoverPlaceable(ForgeDirection side, ItemStack aStack, ICoverable aTileEntity) { + if (!super.isCoverPlaceable(side, aStack, aTileEntity)) return false; + for (final ForgeDirection tSide : ForgeDirection.VALID_DIRECTIONS) { if (aTileEntity.getCoverBehaviorAtSideNew(tSide) instanceof IControlsWorkCover) { return false; } diff --git a/src/main/java/gregtech/common/covers/GT_Cover_RedstoneTransmitterInternal.java b/src/main/java/gregtech/common/covers/GT_Cover_RedstoneTransmitterInternal.java index 43dbfea1de5..a7f39fccf0d 100644 --- a/src/main/java/gregtech/common/covers/GT_Cover_RedstoneTransmitterInternal.java +++ b/src/main/java/gregtech/common/covers/GT_Cover_RedstoneTransmitterInternal.java @@ -1,5 +1,7 @@ package gregtech.common.covers; +import net.minecraftforge.common.util.ForgeDirection; + import gregtech.api.GregTech_API; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.ICoverable; @@ -19,30 +21,30 @@ public GT_Cover_RedstoneTransmitterInternal(ITexture coverTexture) { } @Override - public boolean isRedstoneSensitive(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, + public boolean isRedstoneSensitive(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) { return false; } @Override - public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity, - long aTimer) { - GregTech_API.sWirelessRedstone.put(aCoverVariable, aTileEntity.getOutputRedstoneSignal(aSide)); + public int doCoverThings(ForgeDirection side, byte aInputRedstone, int aCoverID, int aCoverVariable, + ICoverable aTileEntity, long aTimer) { + GregTech_API.sWirelessRedstone.put(aCoverVariable, aTileEntity.getOutputRedstoneSignal(side)); return aCoverVariable; } @Override - public boolean letsRedstoneGoOut(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public boolean letsRedstoneGoOut(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return true; } @Override - public int getTickRate(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public int getTickRate(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return 1; } @Override - public boolean manipulatesSidedRedstoneOutput(byte aSide, int aCoverID, int aCoverVariable, + public boolean manipulatesSidedRedstoneOutput(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return true; } 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 f41250ad154..19bb3b7ef27 100644 --- a/src/main/java/gregtech/common/covers/GT_Cover_RedstoneWirelessBase.java +++ b/src/main/java/gregtech/common/covers/GT_Cover_RedstoneWirelessBase.java @@ -1,6 +1,7 @@ package gregtech.common.covers; import net.minecraft.entity.player.EntityPlayer; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.Fluid; import com.gtnewhorizons.modularui.api.math.MathExpression; @@ -38,17 +39,17 @@ public GT_Cover_RedstoneWirelessBase(ITexture coverTexture) { } @Override - public boolean onCoverRemoval(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, + public boolean onCoverRemoval(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity, boolean aForced) { GregTech_API.sWirelessRedstone.put(aCoverVariable, (byte) 0); return true; } @Override - protected boolean onCoverRightClickImpl(byte aSide, int aCoverID, + protected boolean onCoverRightClickImpl(ForgeDirection side, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) { - if (((aX > 0.375D) && (aX < 0.625D)) || ((aSide > 3) && ((aY > 0.375D) && (aY < 0.625D)))) { + if (((aX > 0.375D) && (aX < 0.625D)) || ((side.offsetX != 0) && ((aY > 0.375D) && (aY < 0.625D)))) { GregTech_API.sWirelessRedstone.put(aCoverVariable.get(), (byte) 0); aCoverVariable.set( (aCoverVariable.get() & (PRIVATE_MASK | CHECKBOX_MASK)) @@ -61,9 +62,9 @@ protected boolean onCoverRightClickImpl(byte aSide, int aCoverID, @Override @SuppressWarnings("deprecation") - public boolean onCoverRightclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, + public boolean onCoverRightclick(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) { - if (((aX > 0.375D) && (aX < 0.625D)) || ((aSide > 3) && ((aY > 0.375D) && (aY < 0.625D)))) { + if (((aX > 0.375D) && (aX < 0.625D)) || ((side.offsetX != 0) && ((aY > 0.375D) && (aY < 0.625D)))) { GregTech_API.sWirelessRedstone.put(aCoverVariable, (byte) 0); int val = GT_Utility.stackToInt(aPlayer.inventory.getCurrentItem()) @@ -72,7 +73,7 @@ public boolean onCoverRightclick(byte aSide, int aCoverID, int aCoverVariable, I aCoverVariable = (aCoverVariable & (PRIVATE_MASK | CHECKBOX_MASK)) | (val & PUBLIC_MASK); - aTileEntity.setCoverDataAtSide(aSide, aCoverVariable); + aTileEntity.setCoverDataAtSide(side, aCoverVariable); GT_Utility .sendChatToPlayer(aPlayer, GT_Utility.trans("081", "Frequency: ") + (aCoverVariable & PUBLIC_MASK)); return true; @@ -81,14 +82,14 @@ public boolean onCoverRightclick(byte aSide, int aCoverID, int aCoverVariable, I } @Override - public int onCoverScrewdriverclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, + public int onCoverScrewdriverclick(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) { if (((aX > 0.375D) && (aX < 0.625D)) - || ((aSide <= 3) || (((aY > 0.375D) && (aY < 0.625D)) || ((((aZ <= 0.375D) || (aZ >= 0.625D))))))) { + || ((side.offsetX == 0) || (((aY > 0.375D) && (aY < 0.625D)) || ((((aZ <= 0.375D) || (aZ >= 0.625D))))))) { GregTech_API.sWirelessRedstone.put(aCoverVariable, (byte) 0); - float[] tCoords = GT_Utility.getClickedFacingCoords(aSide, aX, aY, aZ); + final float[] tCoords = GT_Utility.getClickedFacingCoords(side, aX, aY, aZ); - short tAdjustVal = switch ((byte) ((byte) (int) (tCoords[0] * 2.0F) + final short tAdjustVal = switch ((byte) ((byte) (int) (tCoords[0] * 2.0F) + 2 * (byte) (int) (tCoords[1] * 2.0F))) { case 0 -> -32; case 1 -> 32; @@ -97,7 +98,7 @@ public int onCoverScrewdriverclick(byte aSide, int aCoverID, int aCoverVariable, default -> 0; }; - int tPublicChannel = (aCoverVariable & PUBLIC_MASK) + tAdjustVal; + final int tPublicChannel = (aCoverVariable & PUBLIC_MASK) + tAdjustVal; if (tPublicChannel < 0) { aCoverVariable = aCoverVariable & ~PUBLIC_MASK; @@ -112,42 +113,46 @@ public int onCoverScrewdriverclick(byte aSide, int aCoverID, int aCoverVariable, } @Override - public boolean letsEnergyIn(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public boolean letsEnergyIn(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return true; } @Override - public boolean letsEnergyOut(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public boolean letsEnergyOut(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return true; } @Override - public boolean letsFluidIn(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { + public boolean letsFluidIn(ForgeDirection side, int aCoverID, int aCoverVariable, Fluid aFluid, + ICoverable aTileEntity) { return true; } @Override - public boolean letsFluidOut(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { + public boolean letsFluidOut(ForgeDirection side, int aCoverID, int aCoverVariable, Fluid aFluid, + ICoverable aTileEntity) { return true; } @Override - public boolean letsItemsIn(byte aSide, int aCoverID, int aCoverVariable, int aSlot, ICoverable aTileEntity) { + public boolean letsItemsIn(ForgeDirection side, int aCoverID, int aCoverVariable, int aSlot, + ICoverable aTileEntity) { return true; } @Override - public boolean letsItemsOut(byte aSide, int aCoverID, int aCoverVariable, int aSlot, ICoverable aTileEntity) { + public boolean letsItemsOut(ForgeDirection side, int aCoverID, int aCoverVariable, int aSlot, + ICoverable aTileEntity) { return true; } @Override - public String getDescription(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public String getDescription(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return GT_Utility.trans("081", "Frequency: ") + aCoverVariable; } @Override - public int getTickRate(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public int getTickRate(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return 1; } diff --git a/src/main/java/gregtech/common/covers/GT_Cover_Screen.java b/src/main/java/gregtech/common/covers/GT_Cover_Screen.java index 77d75aa6b9e..fcf33093c52 100644 --- a/src/main/java/gregtech/common/covers/GT_Cover_Screen.java +++ b/src/main/java/gregtech/common/covers/GT_Cover_Screen.java @@ -1,6 +1,7 @@ package gregtech.common.covers; import net.minecraft.entity.player.EntityPlayer; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.Fluid; import gregtech.api.interfaces.ITexture; @@ -22,82 +23,86 @@ public GT_Cover_Screen(ITexture coverTexture) { } @Override - public boolean isRedstoneSensitive(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, + public boolean isRedstoneSensitive(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) { return false; } @Override - public float getBlastProofLevel(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public float getBlastProofLevel(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return 20.0F; } @Override - public boolean letsRedstoneGoIn(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public boolean letsRedstoneGoIn(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return false; } @Override - public boolean letsRedstoneGoOut(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public boolean letsRedstoneGoOut(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return false; } @Override - public boolean letsEnergyIn(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public boolean letsEnergyIn(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return false; } @Override - public boolean letsEnergyOut(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public boolean letsEnergyOut(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return false; } @Override - public boolean letsFluidIn(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { + public boolean letsFluidIn(ForgeDirection side, int aCoverID, int aCoverVariable, Fluid aFluid, + ICoverable aTileEntity) { return false; } @Override - public boolean letsFluidOut(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { + public boolean letsFluidOut(ForgeDirection side, int aCoverID, int aCoverVariable, Fluid aFluid, + ICoverable aTileEntity) { return false; } @Override - public boolean letsItemsIn(byte aSide, int aCoverID, int aCoverVariable, int aSlot, ICoverable aTileEntity) { + public boolean letsItemsIn(ForgeDirection side, int aCoverID, int aCoverVariable, int aSlot, + ICoverable aTileEntity) { return false; } @Override - public boolean letsItemsOut(byte aSide, int aCoverID, int aCoverVariable, int aSlot, ICoverable aTileEntity) { + public boolean letsItemsOut(ForgeDirection side, int aCoverID, int aCoverVariable, int aSlot, + ICoverable aTileEntity) { return false; } @Override - public boolean isGUIClickable(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public boolean isGUIClickable(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return true; } @Override - public boolean manipulatesSidedRedstoneOutput(byte aSide, int aCoverID, int aCoverVariable, + public boolean manipulatesSidedRedstoneOutput(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return false; } @Override - public boolean onCoverRightclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, + public boolean onCoverRightclick(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) { return false; } @Override - public boolean onCoverRemoval(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, + public boolean onCoverRemoval(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity, boolean aForced) { return true; } @Override - public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity, - long aTimer) { + public int doCoverThings(ForgeDirection side, byte aInputRedstone, int aCoverID, int aCoverVariable, + ICoverable aTileEntity, long aTimer) { return 0; } } 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 b846fd3b72b..90904cba656 100644 --- a/src/main/java/gregtech/common/covers/GT_Cover_Shutter.java +++ b/src/main/java/gregtech/common/covers/GT_Cover_Shutter.java @@ -1,6 +1,7 @@ package gregtech.common.covers; import net.minecraft.entity.player.EntityPlayer; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.Fluid; import com.gtnewhorizons.modularui.api.screen.ModularWindow; @@ -32,19 +33,19 @@ public GT_Cover_Shutter(ITexture coverTexture) { } @Override - public boolean isRedstoneSensitive(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, + public boolean isRedstoneSensitive(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) { return false; } @Override - public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity, - long aTimer) { + public int doCoverThings(ForgeDirection side, byte aInputRedstone, int aCoverID, int aCoverVariable, + ICoverable aTileEntity, long aTimer) { return aCoverVariable; } @Override - public int onCoverScrewdriverclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, + public int onCoverScrewdriverclick(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) { aCoverVariable = (aCoverVariable + (aPlayer.isSneaking() ? -1 : 1)) % 4; if (aCoverVariable < 0) { @@ -63,68 +64,72 @@ public int onCoverScrewdriverclick(byte aSide, int aCoverID, int aCoverVariable, } @Override - public boolean letsRedstoneGoIn(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public boolean letsRedstoneGoIn(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return aCoverVariable >= 2 ? aCoverVariable == 3 : !(aTileEntity instanceof IMachineProgress) || (((IMachineProgress) aTileEntity).isAllowedToWork() == (aCoverVariable % 2 == 0)); } @Override - public boolean letsRedstoneGoOut(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public boolean letsRedstoneGoOut(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return aCoverVariable >= 2 ? aCoverVariable == 2 : !(aTileEntity instanceof IMachineProgress) || (((IMachineProgress) aTileEntity).isAllowedToWork() == (aCoverVariable % 2 == 0)); } @Override - public boolean letsEnergyIn(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public boolean letsEnergyIn(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return aCoverVariable >= 2 ? aCoverVariable == 3 : !(aTileEntity instanceof IMachineProgress) || (((IMachineProgress) aTileEntity).isAllowedToWork() == (aCoverVariable % 2 == 0)); } @Override - public boolean letsEnergyOut(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public boolean letsEnergyOut(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return aCoverVariable >= 2 ? aCoverVariable == 2 : !(aTileEntity instanceof IMachineProgress) || ((IMachineProgress) aTileEntity).isAllowedToWork() == (aCoverVariable % 2 == 0); } @Override - public boolean letsFluidIn(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { + public boolean letsFluidIn(ForgeDirection side, int aCoverID, int aCoverVariable, Fluid aFluid, + ICoverable aTileEntity) { return aCoverVariable >= 2 ? aCoverVariable == 3 : !(aTileEntity instanceof IMachineProgress) || ((IMachineProgress) aTileEntity).isAllowedToWork() == (aCoverVariable % 2 == 0); } @Override - public boolean letsFluidOut(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { + public boolean letsFluidOut(ForgeDirection side, int aCoverID, int aCoverVariable, Fluid aFluid, + ICoverable aTileEntity) { return aCoverVariable >= 2 ? aCoverVariable == 2 : !(aTileEntity instanceof IMachineProgress) || ((IMachineProgress) aTileEntity).isAllowedToWork() == (aCoverVariable % 2 == 0); } @Override - public boolean letsItemsIn(byte aSide, int aCoverID, int aCoverVariable, int aSlot, ICoverable aTileEntity) { + public boolean letsItemsIn(ForgeDirection side, int aCoverID, int aCoverVariable, int aSlot, + ICoverable aTileEntity) { return aCoverVariable >= 2 ? aCoverVariable == 3 : !(aTileEntity instanceof IMachineProgress) || ((IMachineProgress) aTileEntity).isAllowedToWork() == (aCoverVariable % 2 == 0); } @Override - public boolean letsItemsOut(byte aSide, int aCoverID, int aCoverVariable, int aSlot, ICoverable aTileEntity) { + public boolean letsItemsOut(ForgeDirection side, int aCoverID, int aCoverVariable, int aSlot, + ICoverable aTileEntity) { return aCoverVariable >= 2 ? aCoverVariable == 2 : !(aTileEntity instanceof IMachineProgress) || ((IMachineProgress) aTileEntity).isAllowedToWork() == (aCoverVariable % 2 == 0); } @Override - public boolean alwaysLookConnected(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public boolean alwaysLookConnected(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return true; } @Override - public int getTickRate(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public int getTickRate(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return 0; } diff --git a/src/main/java/gregtech/common/covers/GT_Cover_SolarPanel.java b/src/main/java/gregtech/common/covers/GT_Cover_SolarPanel.java index 702291db780..20ce5101f4a 100644 --- a/src/main/java/gregtech/common/covers/GT_Cover_SolarPanel.java +++ b/src/main/java/gregtech/common/covers/GT_Cover_SolarPanel.java @@ -5,6 +5,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; import gregtech.api.interfaces.tileentity.ICoverable; import gregtech.api.util.GT_CoverBehavior; @@ -20,27 +21,27 @@ public GT_Cover_SolarPanel(int aVoltage) { } @Override - public boolean isRedstoneSensitive(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, + public boolean isRedstoneSensitive(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) { return false; } @Override - public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity, - long aTimer) { - if (aSide != 1) return 0; + public int doCoverThings(ForgeDirection side, byte aInputRedstone, int aCoverID, int aCoverVariable, + ICoverable aTileEntity, long aTimer) { + if (side != ForgeDirection.UP) return 0; int coverState = aCoverVariable & 0x3; int coverNum = aCoverVariable >> 2; if (aTimer % 100L == 0L) { if (aTileEntity.getWorld() .isThundering()) { - return aTileEntity.getBiome().rainfall > 0.0F && aTileEntity.getSkyAtSide(aSide) + return aTileEntity.getBiome().rainfall > 0.0F && aTileEntity.getSkyAtSide(side) ? Math.min(20, coverNum) << 2 : coverNum << 2; } else { if (aTileEntity.getWorld() .isRaining() && aTileEntity.getBiome().rainfall > 0.0F) { // really rains - if (aTileEntity.getSkyAtSide(aSide)) coverNum = Math.min(30, coverNum); + if (aTileEntity.getSkyAtSide(side)) coverNum = Math.min(30, coverNum); if (aTileEntity.getWorld().skylightSubtracted >= 4) { if (aTileEntity.getWorld() .isDaytime()) { @@ -60,14 +61,17 @@ public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCov } } if (coverState == 1) { - aTileEntity.injectEnergyUnits((byte) 6, ((100L - (long) coverNum) * ((long) this.mVoltage)) / 100L, 1L); + aTileEntity.injectEnergyUnits( + ForgeDirection.UNKNOWN, + ((100L - (long) coverNum) * ((long) this.mVoltage)) / 100L, + 1L); } if (aTimer % 28800L == 0L && coverNum < 100 && (coverNum > 10 || XSTR_INSTANCE.nextInt(3) == 2)) coverNum++; return coverState + (coverNum << 2); } @Override - protected boolean onCoverRightClickImpl(byte aSide, int aCoverID, + protected boolean onCoverRightClickImpl(ForgeDirection side, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) { if (aPlayer.capabilities.isCreativeMode) { @@ -94,11 +98,11 @@ protected boolean onCoverRightClickImpl(byte aSide, int aCoverID, @Override @SuppressWarnings("deprecation") - public boolean onCoverRightclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, + public boolean onCoverRightclick(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) { if (aPlayer.capabilities.isCreativeMode) { GT_Utility.sendChatToPlayer(aPlayer, "Cleaned solar panel from " + (aCoverVariable >> 2) + "% dirt"); - aTileEntity.setCoverDataAtSide(aSide, (aCoverVariable & 0x3)); + aTileEntity.setCoverDataAtSide(side, (aCoverVariable & 0x3)); return true; } for (int i = 0; i < aPlayer.inventory.mainInventory.length; i++) { @@ -109,7 +113,7 @@ public boolean onCoverRightclick(byte aSide, int aCoverID, int aCoverVariable, I aPlayer.inventory.mainInventory[i] = new ItemStack(Items.bucket); if (aPlayer.inventoryContainer != null) aPlayer.inventoryContainer.detectAndSendChanges(); GT_Utility.sendChatToPlayer(aPlayer, "Cleaned solar panel from " + (aCoverVariable >> 2) + "% dirt"); - aTileEntity.setCoverDataAtSide(aSide, (aCoverVariable & 0x3)); + aTileEntity.setCoverDataAtSide(side, (aCoverVariable & 0x3)); return true; } } @@ -118,12 +122,12 @@ public boolean onCoverRightclick(byte aSide, int aCoverID, int aCoverVariable, I } @Override - public boolean alwaysLookConnected(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public boolean alwaysLookConnected(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return true; } @Override - public int getTickRate(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public int getTickRate(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return 1; } } diff --git a/src/main/java/gregtech/common/covers/GT_Cover_SteamValve.java b/src/main/java/gregtech/common/covers/GT_Cover_SteamValve.java index 21c2fa6f636..ea463acf45c 100644 --- a/src/main/java/gregtech/common/covers/GT_Cover_SteamValve.java +++ b/src/main/java/gregtech/common/covers/GT_Cover_SteamValve.java @@ -1,5 +1,6 @@ package gregtech.common.covers; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; import gregtech.api.interfaces.ITexture; @@ -21,7 +22,7 @@ public GT_Cover_SteamValve(int aTransferRate, ITexture coverTexture) { } @Override - public boolean isRedstoneSensitive(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, + public boolean isRedstoneSensitive(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) { return false; } diff --git a/src/main/java/gregtech/common/covers/GT_Cover_Vent.java b/src/main/java/gregtech/common/covers/GT_Cover_Vent.java index c179f5843bc..e2be64b4752 100644 --- a/src/main/java/gregtech/common/covers/GT_Cover_Vent.java +++ b/src/main/java/gregtech/common/covers/GT_Cover_Vent.java @@ -1,6 +1,5 @@ package gregtech.common.covers; -import static gregtech.api.enums.GT_Values.SIDE_UNKNOWN; import static gregtech.api.objects.XSTR.XSTR_INSTANCE; import net.minecraft.block.Block; @@ -28,39 +27,40 @@ public GT_Cover_Vent(int aEfficiency) { } @Override - public boolean isRedstoneSensitive(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, + public boolean isRedstoneSensitive(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) { return false; } @Override - public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity, - long aTimer) { - if (aSide == SIDE_UNKNOWN) return 0; + public int doCoverThings(ForgeDirection side, byte aInputRedstone, int aCoverID, int aCoverVariable, + ICoverable aTileEntity, long aTimer) { + if (side == ForgeDirection.UNKNOWN) return 0; int ret = 0; if (aTileEntity instanceof IFluidHandler) { - ret = doCoolFluid(aSide, aTileEntity); + ret = doCoolFluid(side, aTileEntity); } if ((aTileEntity instanceof IMachineProgress)) { - ret = doProgressEfficiency(aSide, (IMachineProgress) aTileEntity, aCoverID); + ret = doProgressEfficiency(side, (IMachineProgress) aTileEntity, aCoverID); } return ret; } @Override - public boolean alwaysLookConnected(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public boolean alwaysLookConnected(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return true; } @Override - public int getTickRate(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public int getTickRate(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return 100; } - protected int doProgressEfficiency(final byte aSide, final IMachineProgress aTileEntity, final int aCoverVariable) { - final int offsetX = aTileEntity.getOffsetX(aSide, 1); - final int offsetY = aTileEntity.getOffsetY(aSide, 1); - final int offsetZ = aTileEntity.getOffsetZ(aSide, 1); + protected int doProgressEfficiency(final ForgeDirection side, final IMachineProgress aTileEntity, + final int aCoverVariable) { + final int offsetX = aTileEntity.getOffsetX(side, 1); + final int offsetY = aTileEntity.getOffsetY(side, 1); + final int offsetZ = aTileEntity.getOffsetZ(side, 1); final World world = aTileEntity.getWorld(); if (aTileEntity.hasThingsToDo() && aCoverVariable != aTileEntity.getProgress() && !GT_Utility.hasBlockHitBox(world, offsetX, offsetY, offsetZ)) { @@ -69,17 +69,17 @@ protected int doProgressEfficiency(final byte aSide, final IMachineProgress aTil return aTileEntity.getProgress(); } - protected int doCoolFluid(final byte aSide, final ICoverable aTileEntity) { - final int offsetX = aTileEntity.getOffsetX(aSide, 1); - final int offsetY = aTileEntity.getOffsetY(aSide, 1); - final int offsetZ = aTileEntity.getOffsetZ(aSide, 1); + protected int doCoolFluid(final ForgeDirection side, final ICoverable aTileEntity) { + final int offsetX = aTileEntity.getOffsetX(side, 1); + final int offsetY = aTileEntity.getOffsetY(side, 1); + final int offsetZ = aTileEntity.getOffsetZ(side, 1); final World world = aTileEntity.getWorld(); final IFluidHandler fluidHandler = (IFluidHandler) aTileEntity; if (!fluidHandler.canDrain(ForgeDirection.UNKNOWN, IC2_HOT_COOLANT)) { return 0; } final int chances; // 10000 = 100% - final Block blockAtSide = aTileEntity.getBlockAtSide(aSide); + final Block blockAtSide = aTileEntity.getBlockAtSide(side); if (blockAtSide == null) { return 0; } diff --git a/src/main/java/gregtech/common/covers/redstone/GT_Cover_AdvancedRedstoneReceiverExternal.java b/src/main/java/gregtech/common/covers/redstone/GT_Cover_AdvancedRedstoneReceiverExternal.java index 1e1c992bb10..a8a30de9b1c 100644 --- a/src/main/java/gregtech/common/covers/redstone/GT_Cover_AdvancedRedstoneReceiverExternal.java +++ b/src/main/java/gregtech/common/covers/redstone/GT_Cover_AdvancedRedstoneReceiverExternal.java @@ -1,5 +1,7 @@ package gregtech.common.covers.redstone; +import net.minecraftforge.common.util.ForgeDirection; + import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.ICoverable; @@ -10,23 +12,23 @@ public GT_Cover_AdvancedRedstoneReceiverExternal(ITexture coverTexture) { } @Override - public ReceiverData doCoverThingsImpl(byte aSide, byte aInputRedstone, int aCoverID, ReceiverData aCoverVariable, - ICoverable aTileEntity, long aTimer) { + public ReceiverData doCoverThingsImpl(ForgeDirection side, byte aInputRedstone, int aCoverID, + ReceiverData aCoverVariable, ICoverable aTileEntity, long aTimer) { aTileEntity.setOutputRedstoneSignal( - aSide, + side, getSignalAt(aCoverVariable.getUuid(), aCoverVariable.getFrequency(), aCoverVariable.getGateMode())); return aCoverVariable; } @Override - protected boolean isRedstoneSensitiveImpl(byte aSide, int aCoverID, ReceiverData aCoverVariable, + protected boolean isRedstoneSensitiveImpl(ForgeDirection side, int aCoverID, ReceiverData aCoverVariable, ICoverable aTileEntity, long aTimer) { return false; } @Override - protected boolean manipulatesSidedRedstoneOutputImpl(byte aSide, int aCoverID, ReceiverData aCoverVariable, + protected boolean manipulatesSidedRedstoneOutputImpl(ForgeDirection side, int aCoverID, ReceiverData aCoverVariable, ICoverable aTileEntity) { return true; } diff --git a/src/main/java/gregtech/common/covers/redstone/GT_Cover_AdvancedRedstoneReceiverInternal.java b/src/main/java/gregtech/common/covers/redstone/GT_Cover_AdvancedRedstoneReceiverInternal.java index 899a97dca7d..5553cb7c9c1 100644 --- a/src/main/java/gregtech/common/covers/redstone/GT_Cover_AdvancedRedstoneReceiverInternal.java +++ b/src/main/java/gregtech/common/covers/redstone/GT_Cover_AdvancedRedstoneReceiverInternal.java @@ -1,5 +1,7 @@ package gregtech.common.covers.redstone; +import net.minecraftforge.common.util.ForgeDirection; + import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.ICoverable; import gregtech.api.interfaces.tileentity.IMachineProgress; @@ -11,10 +13,10 @@ public GT_Cover_AdvancedRedstoneReceiverInternal(ITexture coverTexture) { } @Override - public ReceiverData doCoverThingsImpl(byte aSide, byte aInputRedstone, int aCoverID, ReceiverData aCoverVariable, - ICoverable aTileEntity, long aTimer) { + public ReceiverData doCoverThingsImpl(ForgeDirection side, byte aInputRedstone, int aCoverID, + ReceiverData aCoverVariable, ICoverable aTileEntity, long aTimer) { if (aTileEntity instanceof IMachineProgress machine) { - if (getRedstoneInput(aSide, aInputRedstone, aCoverID, aCoverVariable, aTileEntity) > 0) { + if (getRedstoneInput(side, aInputRedstone, aCoverID, aCoverVariable, aTileEntity) > 0) { machine.enableWorking(); } else { machine.disableWorking(); @@ -27,13 +29,13 @@ public ReceiverData doCoverThingsImpl(byte aSide, byte aInputRedstone, int aCove } @Override - protected byte getRedstoneInputImpl(byte aSide, byte aInputRedstone, int aCoverID, ReceiverData aCoverVariable, - ICoverable aTileEntity) { + protected byte getRedstoneInputImpl(ForgeDirection side, byte aInputRedstone, int aCoverID, + ReceiverData aCoverVariable, ICoverable aTileEntity) { return getSignalAt(aCoverVariable.getUuid(), aCoverVariable.getFrequency(), aCoverVariable.getGateMode()); } @Override - protected boolean isRedstoneSensitiveImpl(byte aSide, int aCoverID, ReceiverData aCoverVariable, + protected boolean isRedstoneSensitiveImpl(ForgeDirection side, int aCoverID, ReceiverData aCoverVariable, ICoverable aTileEntity, long aTimer) { return true; } diff --git a/src/main/java/gregtech/common/covers/redstone/GT_Cover_AdvancedRedstoneTransmitterBase.java b/src/main/java/gregtech/common/covers/redstone/GT_Cover_AdvancedRedstoneTransmitterBase.java index 237635eb7f2..3417542beca 100644 --- a/src/main/java/gregtech/common/covers/redstone/GT_Cover_AdvancedRedstoneTransmitterBase.java +++ b/src/main/java/gregtech/common/covers/redstone/GT_Cover_AdvancedRedstoneTransmitterBase.java @@ -9,6 +9,7 @@ import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.ForgeDirection; import com.google.common.io.ByteArrayDataInput; import com.gtnewhorizons.modularui.api.screen.ModularWindow; @@ -30,26 +31,26 @@ public GT_Cover_AdvancedRedstoneTransmitterBase(Class typeToken, ITexture cov super(typeToken, coverTexture); } - private static void unregisterSignal(byte aSide, TransmitterData aCoverVariable, ICoverable aTileEntity) { - long hash = hashCoverCoords(aTileEntity, aSide); + private static void unregisterSignal(ForgeDirection side, TransmitterData aCoverVariable, ICoverable aTileEntity) { + final long hash = hashCoverCoords(aTileEntity, side); removeSignalAt(aCoverVariable.uuid, aCoverVariable.frequency, hash); } @Override - public boolean onCoverRemovalImpl(byte aSide, int aCoverID, TransmitterData aCoverVariable, ICoverable aTileEntity, - boolean aForced) { - unregisterSignal(aSide, aCoverVariable, aTileEntity); + public boolean onCoverRemovalImpl(ForgeDirection side, int aCoverID, TransmitterData aCoverVariable, + ICoverable aTileEntity, boolean aForced) { + unregisterSignal(side, aCoverVariable, aTileEntity); return true; } @Override - protected void onBaseTEDestroyedImpl(byte aSide, int aCoverID, TransmitterData aCoverVariable, + protected void onBaseTEDestroyedImpl(ForgeDirection side, int aCoverID, TransmitterData aCoverVariable, ICoverable aTileEntity) { - unregisterSignal(aSide, aCoverVariable, aTileEntity); + unregisterSignal(side, aCoverVariable, aTileEntity); } @Override - protected T onCoverScrewdriverClickImpl(byte aSide, int aCoverID, T aCoverVariable, ICoverable aTileEntity, + protected T onCoverScrewdriverClickImpl(ForgeDirection side, int aCoverID, T aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) { aCoverVariable.invert = !aCoverVariable.invert; GT_Utility.sendChatToPlayer( @@ -60,11 +61,11 @@ protected T onCoverScrewdriverClickImpl(byte aSide, int aCoverID, T aCoverVariab } @Override - protected void preDataChangedImpl(byte aSide, int aCoverID, int aNewCoverId, T aCoverVariable, T aNewCoverVariable, - ICoverable aTileEntity) { + protected void preDataChangedImpl(ForgeDirection side, int aCoverID, int aNewCoverId, T aCoverVariable, + T aNewCoverVariable, ICoverable aTileEntity) { if (aCoverVariable.frequency != aNewCoverVariable.frequency || !Objects.equals(aCoverVariable.uuid, aNewCoverVariable.uuid)) { - unregisterSignal(aSide, aCoverVariable, aTileEntity); + unregisterSignal(side, aCoverVariable, aTileEntity); } } diff --git a/src/main/java/gregtech/common/covers/redstone/GT_Cover_AdvancedRedstoneTransmitterExternal.java b/src/main/java/gregtech/common/covers/redstone/GT_Cover_AdvancedRedstoneTransmitterExternal.java index c6936103181..139ec648434 100644 --- a/src/main/java/gregtech/common/covers/redstone/GT_Cover_AdvancedRedstoneTransmitterExternal.java +++ b/src/main/java/gregtech/common/covers/redstone/GT_Cover_AdvancedRedstoneTransmitterExternal.java @@ -1,5 +1,7 @@ package gregtech.common.covers.redstone; +import net.minecraftforge.common.util.ForgeDirection; + import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.ICoverable; @@ -21,7 +23,7 @@ public TransmitterData createDataObject(int aLegacyData) { } @Override - public TransmitterData doCoverThingsImpl(byte aSide, byte aInputRedstone, int aCoverID, + public TransmitterData doCoverThingsImpl(ForgeDirection side, byte aInputRedstone, int aCoverID, TransmitterData aCoverVariable, ICoverable aTileEntity, long aTimer) { byte outputRedstone = aInputRedstone; if (aCoverVariable.isInvert()) { @@ -29,20 +31,20 @@ public TransmitterData doCoverThingsImpl(byte aSide, byte aInputRedstone, int aC else outputRedstone = 15; } - long hash = hashCoverCoords(aTileEntity, aSide); + final long hash = hashCoverCoords(aTileEntity, side); setSignalAt(aCoverVariable.getUuid(), aCoverVariable.getFrequency(), hash, outputRedstone); return aCoverVariable; } @Override - protected boolean isRedstoneSensitiveImpl(byte aSide, int aCoverID, TransmitterData aCoverVariable, + protected boolean isRedstoneSensitiveImpl(ForgeDirection side, int aCoverID, TransmitterData aCoverVariable, ICoverable aTileEntity, long aTimer) { return true; } @Override - public boolean letsRedstoneGoInImpl(byte aSide, int aCoverID, TransmitterData aCoverVariable, + public boolean letsRedstoneGoInImpl(ForgeDirection side, int aCoverID, TransmitterData aCoverVariable, ICoverable aTileEntity) { return true; } diff --git a/src/main/java/gregtech/common/covers/redstone/GT_Cover_AdvancedRedstoneTransmitterInternal.java b/src/main/java/gregtech/common/covers/redstone/GT_Cover_AdvancedRedstoneTransmitterInternal.java index 353a5796808..01a46fcc86c 100644 --- a/src/main/java/gregtech/common/covers/redstone/GT_Cover_AdvancedRedstoneTransmitterInternal.java +++ b/src/main/java/gregtech/common/covers/redstone/GT_Cover_AdvancedRedstoneTransmitterInternal.java @@ -1,5 +1,7 @@ package gregtech.common.covers.redstone; +import net.minecraftforge.common.util.ForgeDirection; + import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.ICoverable; @@ -21,28 +23,28 @@ public TransmitterData createDataObject(int aLegacyData) { } @Override - public TransmitterData doCoverThingsImpl(byte aSide, byte aInputRedstone, int aCoverID, + public TransmitterData doCoverThingsImpl(ForgeDirection side, byte aInputRedstone, int aCoverID, TransmitterData aCoverVariable, ICoverable aTileEntity, long aTimer) { - byte outputRedstone = aTileEntity.getOutputRedstoneSignal(aSide); + byte outputRedstone = aTileEntity.getOutputRedstoneSignal(side); if (aCoverVariable.isInvert()) { if (outputRedstone > 0) outputRedstone = 0; else outputRedstone = 15; } - long hash = hashCoverCoords(aTileEntity, aSide); + final long hash = hashCoverCoords(aTileEntity, side); setSignalAt(aCoverVariable.getUuid(), aCoverVariable.getFrequency(), hash, outputRedstone); return aCoverVariable; } @Override - public boolean letsRedstoneGoOutImpl(byte aSide, int aCoverID, TransmitterData aCoverVariable, + public boolean letsRedstoneGoOutImpl(ForgeDirection side, int aCoverID, TransmitterData aCoverVariable, ICoverable aTileEntity) { return true; } @Override - protected boolean manipulatesSidedRedstoneOutputImpl(byte aSide, int aCoverID, TransmitterData aCoverVariable, - ICoverable aTileEntity) { + protected boolean manipulatesSidedRedstoneOutputImpl(ForgeDirection side, int aCoverID, + TransmitterData aCoverVariable, ICoverable aTileEntity) { return true; } } diff --git a/src/main/java/gregtech/common/covers/redstone/GT_Cover_AdvancedWirelessRedstoneBase.java b/src/main/java/gregtech/common/covers/redstone/GT_Cover_AdvancedWirelessRedstoneBase.java index 843c7ab5e22..e04a6664ac0 100644 --- a/src/main/java/gregtech/common/covers/redstone/GT_Cover_AdvancedWirelessRedstoneBase.java +++ b/src/main/java/gregtech/common/covers/redstone/GT_Cover_AdvancedWirelessRedstoneBase.java @@ -9,6 +9,7 @@ import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.Fluid; import com.google.common.io.ByteArrayDataInput; @@ -102,50 +103,54 @@ public static void setSignalAt(UUID uuid, int frequency, long hash, byte value) * x hashed into first 20 bytes y hashed into second 20 bytes z hashed into fifth 10 bytes dim hashed into sixth 10 * bytes side hashed into last 4 bytes */ - public static long hashCoverCoords(ICoverable tile, byte side) { + public static long hashCoverCoords(ICoverable tile, ForgeDirection side) { return (((((long) tile.getXCoord() << 20) + tile.getZCoord() << 10) + tile.getYCoord() << 10) - + tile.getWorld().provider.dimensionId << 4) + side; + + tile.getWorld().provider.dimensionId << 4) + side.ordinal(); } @Override - public boolean letsEnergyInImpl(byte aSide, int aCoverID, T aCoverVariable, ICoverable aTileEntity) { + public boolean letsEnergyInImpl(ForgeDirection side, int aCoverID, T aCoverVariable, ICoverable aTileEntity) { return true; } @Override - public boolean letsEnergyOutImpl(byte aSide, int aCoverID, T aCoverVariable, ICoverable aTileEntity) { + public boolean letsEnergyOutImpl(ForgeDirection side, int aCoverID, T aCoverVariable, ICoverable aTileEntity) { return true; } @Override - public boolean letsFluidInImpl(byte aSide, int aCoverID, T aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { + public boolean letsFluidInImpl(ForgeDirection side, int aCoverID, T aCoverVariable, Fluid aFluid, + ICoverable aTileEntity) { return true; } @Override - public boolean letsFluidOutImpl(byte aSide, int aCoverID, T aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { + public boolean letsFluidOutImpl(ForgeDirection side, int aCoverID, T aCoverVariable, Fluid aFluid, + ICoverable aTileEntity) { return true; } @Override - public boolean letsItemsInImpl(byte aSide, int aCoverID, T aCoverVariable, int aSlot, ICoverable aTileEntity) { + public boolean letsItemsInImpl(ForgeDirection side, int aCoverID, T aCoverVariable, int aSlot, + ICoverable aTileEntity) { return true; } @Override - public boolean letsItemsOutImpl(byte aSide, int aCoverID, T aCoverVariable, int aSlot, ICoverable aTileEntity) { + public boolean letsItemsOutImpl(ForgeDirection side, int aCoverID, T aCoverVariable, int aSlot, + ICoverable aTileEntity) { return true; } @Override - public String getDescriptionImpl(byte aSide, int aCoverID, T aCoverVariable, ICoverable aTileEntity) { + public String getDescriptionImpl(ForgeDirection side, int aCoverID, T aCoverVariable, ICoverable aTileEntity) { return GT_Utility.trans("081", "Frequency: ") + aCoverVariable.frequency + ", Transmission: " + (aCoverVariable.uuid == null ? "Public" : "Private"); } @Override - public int getTickRateImpl(byte aSide, int aCoverID, T aCoverVariable, ICoverable aTileEntity) { + public int getTickRateImpl(ForgeDirection side, int aCoverID, T aCoverVariable, ICoverable aTileEntity) { return 5; } diff --git a/src/main/java/gregtech/common/covers/redstone/GT_Cover_WirelessFluidDetector.java b/src/main/java/gregtech/common/covers/redstone/GT_Cover_WirelessFluidDetector.java index f580877dea1..ab5d26356fc 100644 --- a/src/main/java/gregtech/common/covers/redstone/GT_Cover_WirelessFluidDetector.java +++ b/src/main/java/gregtech/common/covers/redstone/GT_Cover_WirelessFluidDetector.java @@ -7,6 +7,7 @@ import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.ForgeDirection; import com.google.common.io.ByteArrayDataInput; import com.gtnewhorizons.modularui.api.math.MathExpression; @@ -41,25 +42,25 @@ public FluidTransmitterData createDataObject(int aLegacyData) { } @Override - public FluidTransmitterData doCoverThingsImpl(byte aSide, byte aInputRedstone, int aCoverID, + public FluidTransmitterData doCoverThingsImpl(ForgeDirection side, byte aInputRedstone, int aCoverID, FluidTransmitterData aCoverVariable, ICoverable aTileEntity, long aTimer) { - byte signal = GT_Cover_LiquidMeter + final byte signal = GT_Cover_LiquidMeter .computeSignalBasedOnFluid(aTileEntity, aCoverVariable.invert, aCoverVariable.threshold); - long hash = hashCoverCoords(aTileEntity, aSide); + final long hash = hashCoverCoords(aTileEntity, side); setSignalAt(aCoverVariable.getUuid(), aCoverVariable.getFrequency(), hash, signal); return aCoverVariable; } @Override - public boolean letsRedstoneGoOutImpl(byte aSide, int aCoverID, FluidTransmitterData aCoverVariable, + public boolean letsRedstoneGoOutImpl(ForgeDirection side, int aCoverID, FluidTransmitterData aCoverVariable, ICoverable aTileEntity) { return true; } @Override - protected boolean manipulatesSidedRedstoneOutputImpl(byte aSide, int aCoverID, FluidTransmitterData aCoverVariable, - ICoverable aTileEntity) { + protected boolean manipulatesSidedRedstoneOutputImpl(ForgeDirection side, int aCoverID, + FluidTransmitterData aCoverVariable, ICoverable aTileEntity) { return true; } diff --git a/src/main/java/gregtech/common/covers/redstone/GT_Cover_WirelessItemDetector.java b/src/main/java/gregtech/common/covers/redstone/GT_Cover_WirelessItemDetector.java index 8b8d047214c..9f5200b6fc7 100644 --- a/src/main/java/gregtech/common/covers/redstone/GT_Cover_WirelessItemDetector.java +++ b/src/main/java/gregtech/common/covers/redstone/GT_Cover_WirelessItemDetector.java @@ -9,6 +9,7 @@ import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.util.ForgeDirection; import com.google.common.io.ByteArrayDataInput; import com.gtnewhorizons.modularui.api.math.MathExpression; @@ -47,29 +48,29 @@ public ItemTransmitterData createDataObject(int aLegacyData) { } @Override - public ItemTransmitterData doCoverThingsImpl(byte aSide, byte aInputRedstone, int aCoverID, + public ItemTransmitterData doCoverThingsImpl(ForgeDirection side, byte aInputRedstone, int aCoverID, ItemTransmitterData aCoverVariable, ICoverable aTileEntity, long aTimer) { byte signal = GT_Cover_ItemMeter.computeSignalBasedOnItems( aTileEntity, aCoverVariable.invert, aCoverVariable.threshold, aCoverVariable.slot, - aSide); - long hash = hashCoverCoords(aTileEntity, aSide); + side.ordinal()); + final long hash = hashCoverCoords(aTileEntity, side); setSignalAt(aCoverVariable.getUuid(), aCoverVariable.getFrequency(), hash, signal); return aCoverVariable; } @Override - public boolean letsRedstoneGoOutImpl(byte aSide, int aCoverID, ItemTransmitterData aCoverVariable, + public boolean letsRedstoneGoOutImpl(ForgeDirection side, int aCoverID, ItemTransmitterData aCoverVariable, ICoverable aTileEntity) { return true; } @Override - protected boolean manipulatesSidedRedstoneOutputImpl(byte aSide, int aCoverID, ItemTransmitterData aCoverVariable, - ICoverable aTileEntity) { + protected boolean manipulatesSidedRedstoneOutputImpl(ForgeDirection side, int aCoverID, + ItemTransmitterData aCoverVariable, ICoverable aTileEntity) { return true; } diff --git a/src/main/java/gregtech/common/covers/redstone/GT_Cover_WirelessMaintenanceDetector.java b/src/main/java/gregtech/common/covers/redstone/GT_Cover_WirelessMaintenanceDetector.java index 6179b8084cf..d9cc765ef8b 100644 --- a/src/main/java/gregtech/common/covers/redstone/GT_Cover_WirelessMaintenanceDetector.java +++ b/src/main/java/gregtech/common/covers/redstone/GT_Cover_WirelessMaintenanceDetector.java @@ -8,6 +8,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.ForgeDirection; import com.google.common.io.ByteArrayDataInput; import com.gtnewhorizons.modularui.api.screen.ModularWindow; @@ -89,29 +90,29 @@ private static byte computeSignalBasedOnMaintenance(MaintenanceTransmitterData c } @Override - public MaintenanceTransmitterData doCoverThingsImpl(byte aSide, byte aInputRedstone, int aCoverID, + public MaintenanceTransmitterData doCoverThingsImpl(ForgeDirection side, byte aInputRedstone, int aCoverID, MaintenanceTransmitterData aCoverVariable, ICoverable aTileEntity, long aTimer) { - byte signal = computeSignalBasedOnMaintenance(aCoverVariable, aTileEntity); - long hash = hashCoverCoords(aTileEntity, aSide); + final byte signal = computeSignalBasedOnMaintenance(aCoverVariable, aTileEntity); + final long hash = hashCoverCoords(aTileEntity, side); setSignalAt(aCoverVariable.getUuid(), aCoverVariable.getFrequency(), hash, signal); return aCoverVariable; } @Override - public boolean letsRedstoneGoOutImpl(byte aSide, int aCoverID, MaintenanceTransmitterData aCoverVariable, + public boolean letsRedstoneGoOutImpl(ForgeDirection side, int aCoverID, MaintenanceTransmitterData aCoverVariable, ICoverable aTileEntity) { return true; } @Override - protected boolean manipulatesSidedRedstoneOutputImpl(byte aSide, int aCoverID, + protected boolean manipulatesSidedRedstoneOutputImpl(ForgeDirection side, int aCoverID, MaintenanceTransmitterData aCoverVariable, ICoverable aTileEntity) { return true; } @Override - public int getTickRateImpl(byte aSide, int aCoverID, MaintenanceTransmitterData aCoverVariable, + public int getTickRateImpl(ForgeDirection side, int aCoverID, MaintenanceTransmitterData aCoverVariable, ICoverable aTileEntity) { return 60; } diff --git a/src/main/java/gregtech/common/items/GT_VolumetricFlask.java b/src/main/java/gregtech/common/items/GT_VolumetricFlask.java index 7776af8d694..fc19daff83c 100644 --- a/src/main/java/gregtech/common/items/GT_VolumetricFlask.java +++ b/src/main/java/gregtech/common/items/GT_VolumetricFlask.java @@ -76,13 +76,13 @@ public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer pla } @Override - public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, + public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int ordinalSide, float xOffset, float yOffset, float zOffset) { if (player instanceof FakePlayer) { return false; } if (world.isRemote) return false; - if (interactWithTank(stack, player, world, x, y, z, side)) { + if (interactWithTank(stack, player, world, x, y, z, ordinalSide)) { return true; } MovingObjectPosition mop = getMovingObjectPositionFromPlayer(world, player, true); @@ -239,7 +239,8 @@ public void getSubItems(Item item, CreativeTabs creativeTabs, List it } } - private boolean interactWithTank(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side) { + private boolean interactWithTank(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, + int ordinalSide) { if (world.isRemote) { return false; } @@ -247,7 +248,7 @@ private boolean interactWithTank(ItemStack stack, EntityPlayer player, World wor if (!(te instanceof IFluidHandler handler)) { return false; } - ForgeDirection dir = ForgeDirection.getOrientation(side); + ForgeDirection dir = ForgeDirection.getOrientation(ordinalSide); FluidStack fs = this.getFluid(stack); int capacity = getCapacity(stack); if (fs != null && (!player.isSneaking() || fs.amount >= capacity)) { diff --git a/src/main/java/gregtech/common/items/behaviors/Behaviour_Cover_Tool.java b/src/main/java/gregtech/common/items/behaviors/Behaviour_Cover_Tool.java index d0f55825499..305993c0d0b 100644 --- a/src/main/java/gregtech/common/items/behaviors/Behaviour_Cover_Tool.java +++ b/src/main/java/gregtech/common/items/behaviors/Behaviour_Cover_Tool.java @@ -31,23 +31,23 @@ public class Behaviour_Cover_Tool extends Behaviour_None { @Override public boolean onItemUseFirst(GT_MetaBase_Item aItem, ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, - int aY, int aZ, int aSide, float hitX, float hitY, float hitZ) { + int aY, int aZ, ForgeDirection side, float hitX, float hitY, float hitZ) { if (aWorld.isRemote) { return false; } - NBTTagCompound tNBT = aStack.getTagCompound(); - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - boolean isCopyMode = aPlayer.isSneaking(); + final NBTTagCompound tNBT = aStack.getTagCompound(); + final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + final boolean isCopyMode = aPlayer.isSneaking(); initDataFromNBT(tNBT); if (((aPlayer instanceof EntityPlayerMP)) && (aItem.canUse(aStack, 100.0D))) { if (isCopyMode) { ArrayList tList = new ArrayList<>(); - doCopy(tTileEntity, aWorld, aX, aY, aZ, aSide, hitX, hitY, hitZ, tList); + doCopy(tTileEntity, aWorld, aX, aY, aZ, side, hitX, hitY, hitZ, tList); aItem.discharge(aStack, 100.0D, Integer.MAX_VALUE, true, false, false); writeListToNBT(tList, tNBT, aPlayer); saveDataToNBT(tNBT); } else { - doPaste(tTileEntity, aSide, hitX, hitY, hitZ, aPlayer); + doPaste(tTileEntity, side, hitX, hitY, hitZ, aPlayer); aItem.discharge(aStack, 25.0D, Integer.MAX_VALUE, true, false, false); } } @@ -84,8 +84,8 @@ private void writeListToNBT(List aList, NBTTagCompound aNBT, EntityPlayer aPlaye } @SuppressWarnings({ "unchecked", "rawtypes" }) - private void doCopy(TileEntity aTileEntity, World aWorld, int aX, int aY, int aZ, int aSide, float hitX, float hitY, - float hitZ, List aList) { + private void doCopy(TileEntity aTileEntity, World aWorld, int aX, int aY, int aZ, ForgeDirection side, float hitX, + float hitY, float hitZ, List aList) { aList.add( "----- X: " + EnumChatFormatting.AQUA + GT_Utility.formatNumbers(aX) @@ -104,20 +104,17 @@ private void doCopy(TileEntity aTileEntity, World aWorld, int aX, int aY, int aZ + EnumChatFormatting.RESET + " -----"); if (aTileEntity instanceof ICoverable tCoverable) { - int tSide = tCoverable.getCoverItemAtSide((byte) aSide) != null ? aSide - : tCoverable.getCoverItemAtSide(GT_Utility.determineWrenchingSide((byte) aSide, hitX, hitY, hitZ)) - != null ? GT_Utility.determineWrenchingSide((byte) aSide, hitX, hitY, hitZ) : -1; - if (tSide != -1) { - mStoredData = tCoverable.getComplexCoverDataAtSide((byte) tSide); - mCoverType = tCoverable.getCoverIDAtSide((byte) tSide); - aList.add( - "Block Side: " + EnumChatFormatting.AQUA - + ForgeDirection.getOrientation(tSide) - .name() - + EnumChatFormatting.RESET); + final ForgeDirection tSide = tCoverable.getCoverItemAtSide(side) != null ? side + : tCoverable.getCoverItemAtSide(GT_Utility.determineWrenchingSide(side, hitX, hitY, hitZ)) != null + ? GT_Utility.determineWrenchingSide(side, hitX, hitY, hitZ) + : ForgeDirection.UNKNOWN; + if (tSide != ForgeDirection.UNKNOWN) { + mStoredData = tCoverable.getComplexCoverDataAtSide(tSide); + mCoverType = tCoverable.getCoverIDAtSide(tSide); + aList.add("Block Side: " + EnumChatFormatting.AQUA + tSide.name() + EnumChatFormatting.RESET); aList.add( "Cover Type: " + EnumChatFormatting.GREEN - + tCoverable.getCoverItemAtSide((byte) tSide) + + tCoverable.getCoverItemAtSide(tSide) .getDisplayName() + EnumChatFormatting.RESET); } else { @@ -132,19 +129,21 @@ private void doCopy(TileEntity aTileEntity, World aWorld, int aX, int aY, int aZ } } - private void doPaste(TileEntity aTileEntity, int aSide, float hitX, float hitY, float hitZ, EntityPlayer aPlayer) { + private void doPaste(TileEntity aTileEntity, ForgeDirection side, float hitX, float hitY, float hitZ, + EntityPlayer aPlayer) { if (aTileEntity instanceof ICoverable tCoverable) { if (mCoverType == 0 || mStoredData == null) { GT_Utility.sendChatToPlayer(aPlayer, "Please Copy a Valid Cover First."); return; } - int tSide = tCoverable.getCoverItemAtSide((byte) aSide) != null ? aSide - : tCoverable.getCoverItemAtSide(GT_Utility.determineWrenchingSide((byte) aSide, hitX, hitY, hitZ)) - != null ? GT_Utility.determineWrenchingSide((byte) aSide, hitX, hitY, hitZ) : -1; - if (tSide != -1) { - int tCoverID = tCoverable.getCoverIDAtSide((byte) tSide); + final ForgeDirection tSide = tCoverable.getCoverItemAtSide(side) != null ? side + : tCoverable.getCoverItemAtSide(GT_Utility.determineWrenchingSide(side, hitX, hitY, hitZ)) != null + ? GT_Utility.determineWrenchingSide(side, hitX, hitY, hitZ) + : ForgeDirection.UNKNOWN; + if (tSide != ForgeDirection.UNKNOWN) { + int tCoverID = tCoverable.getCoverIDAtSide(tSide); if (tCoverID == mCoverType) { - tCoverable.setCoverDataAtSide((byte) tSide, mStoredData); + tCoverable.setCoverDataAtSide(tSide, mStoredData); GT_Utility.sendChatToPlayer(aPlayer, "Cover Data Pasted."); } else { GT_Utility.sendChatToPlayer(aPlayer, "Not Matched Cover."); @@ -158,8 +157,8 @@ private void doPaste(TileEntity aTileEntity, int aSide, float hitX, float hitY, @Override public List getAdditionalToolTips(GT_MetaBase_Item aItem, List aList, ItemStack aStack) { try { - NBTTagCompound tNBT = aStack.getTagCompound(); - int tSize = tNBT.getInteger("dataLinesCount"); + final NBTTagCompound tNBT = aStack.getTagCompound(); + final int tSize = tNBT.getInteger("dataLinesCount"); if (tSize < 1) throw new Exception(); aList.add(EnumChatFormatting.BLUE + "Stored Cover Data:"); for (int i = 0; i < tSize; i++) { diff --git a/src/main/java/gregtech/common/items/behaviors/Behaviour_Crowbar.java b/src/main/java/gregtech/common/items/behaviors/Behaviour_Crowbar.java index 76bc0615c18..97d3da4ca3f 100644 --- a/src/main/java/gregtech/common/items/behaviors/Behaviour_Crowbar.java +++ b/src/main/java/gregtech/common/items/behaviors/Behaviour_Crowbar.java @@ -7,6 +7,7 @@ import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; import gregtech.api.enums.SoundResource; import gregtech.api.items.GT_MetaBase_Item; @@ -25,7 +26,7 @@ public Behaviour_Crowbar(int aVanillaCosts, int aEUCosts) { @Override public boolean onItemUseFirst(GT_MetaBase_Item aItem, ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, - int aY, int aZ, int aSide, float hitX, float hitY, float hitZ) { + int aY, int aZ, ForgeDirection side, float hitX, float hitY, float hitZ) { if (aWorld.isRemote) { return false; } diff --git a/src/main/java/gregtech/common/items/behaviors/Behaviour_Hoe.java b/src/main/java/gregtech/common/items/behaviors/Behaviour_Hoe.java index 0d8e26ac661..167eccdf497 100644 --- a/src/main/java/gregtech/common/items/behaviors/Behaviour_Hoe.java +++ b/src/main/java/gregtech/common/items/behaviors/Behaviour_Hoe.java @@ -28,8 +28,8 @@ public Behaviour_Hoe(int aCosts) { @Override public boolean onItemUse(GT_MetaBase_Item aItem, ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, - int aY, int aZ, int aSide, float hitX, float hitY, float hitZ) { - if (!aPlayer.canPlayerEdit(aX, aY, aZ, aSide, aStack)) { + int aY, int aZ, int ordinalSide, float hitX, float hitY, float hitZ) { + if (!aPlayer.canPlayerEdit(aX, aY, aZ, ordinalSide, aStack)) { return false; } UseHoeEvent event = new UseHoeEvent(aPlayer, aStack, aWorld, aX, aY, aZ); @@ -43,7 +43,7 @@ public boolean onItemUse(GT_MetaBase_Item aItem, ItemStack aStack, EntityPlayer return true; } Block aBlock = aWorld.getBlock(aX, aY, aZ); - if ((aSide != 0) && (GT_Utility.isBlockAir(aWorld, aX, aY + 1, aZ)) + if ((ordinalSide != 0) && (GT_Utility.isBlockAir(aWorld, aX, aY + 1, aZ)) && ((aBlock == Blocks.grass) || (aBlock == Blocks.dirt))) { new WorldSpawnedEventBuilder.SoundEventBuilder() .setVolume((Blocks.farmland.stepSound.getVolume() + 1.0F) / 2.0F) diff --git a/src/main/java/gregtech/common/items/behaviors/Behaviour_Lighter.java b/src/main/java/gregtech/common/items/behaviors/Behaviour_Lighter.java index d348f3eed48..a4c26e2254d 100644 --- a/src/main/java/gregtech/common/items/behaviors/Behaviour_Lighter.java +++ b/src/main/java/gregtech/common/items/behaviors/Behaviour_Lighter.java @@ -73,23 +73,23 @@ public boolean onLeftClickEntity(GT_MetaBase_Item aItem, ItemStack aStack, Entit @Override public boolean onItemUse(GT_MetaBase_Item aItem, ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, - int aY, int aZ, int aSide, float hitX, float hitY, float hitZ) { + int aY, int aZ, int ordinalSide, float hitX, float hitY, float hitZ) { return false; } @Override public boolean onItemUseFirst(GT_MetaBase_Item aItem, ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, - int aY, int aZ, int aSide, float hitX, float hitY, float hitZ) { + int aY, int aZ, ForgeDirection side, float hitX, float hitY, float hitZ) { if ((aWorld.isRemote) || (aStack.stackSize != 1)) { return false; } boolean rOutput = false; - ForgeDirection tDirection = ForgeDirection.getOrientation(aSide); - aX += tDirection.offsetX; - aY += tDirection.offsetY; - aZ += tDirection.offsetZ; - if ((!GT_Utility.isBlockAir(aWorld, aX, aY, aZ)) || (!aPlayer.canPlayerEdit(aX, aY, aZ, aSide, aStack))) { + aX += side.offsetX; + aY += side.offsetY; + aZ += side.offsetZ; + if ((!GT_Utility.isBlockAir(aWorld, aX, aY, aZ)) + || (!aPlayer.canPlayerEdit(aX, aY, aZ, side.ordinal(), aStack))) { return false; } prepare(aStack); diff --git a/src/main/java/gregtech/common/items/behaviors/Behaviour_None.java b/src/main/java/gregtech/common/items/behaviors/Behaviour_None.java index 6928222af16..4ce7f60da0b 100644 --- a/src/main/java/gregtech/common/items/behaviors/Behaviour_None.java +++ b/src/main/java/gregtech/common/items/behaviors/Behaviour_None.java @@ -13,6 +13,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.EnumFacing; import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; import gregtech.api.enums.SubTag; import gregtech.api.interfaces.IItemBehaviour; @@ -28,13 +29,13 @@ public boolean onLeftClickEntity(GT_MetaBase_Item aItem, ItemStack aStack, Entit @Override public boolean onItemUse(GT_MetaBase_Item aItem, ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, - int aY, int aZ, int aSide, float hitX, float hitY, float hitZ) { + int aY, int aZ, int ordinalSide, float hitX, float hitY, float hitZ) { return false; } @Override public boolean onItemUseFirst(GT_MetaBase_Item aItem, ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, - int aY, int aZ, int aSide, float hitX, float hitY, float hitZ) { + int aY, int aZ, ForgeDirection side, float hitX, float hitY, float hitZ) { return false; } diff --git a/src/main/java/gregtech/common/items/behaviors/Behaviour_Plunger_Essentia.java b/src/main/java/gregtech/common/items/behaviors/Behaviour_Plunger_Essentia.java index 16c1f1dec19..a3c46ea9913 100644 --- a/src/main/java/gregtech/common/items/behaviors/Behaviour_Plunger_Essentia.java +++ b/src/main/java/gregtech/common/items/behaviors/Behaviour_Plunger_Essentia.java @@ -27,7 +27,7 @@ public Behaviour_Plunger_Essentia(int aCosts) { @Override public boolean onItemUseFirst(GT_MetaBase_Item aItem, ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, - int aY, int aZ, int aSide, float hitX, float hitY, float hitZ) { + int aY, int aZ, ForgeDirection side, float hitX, float hitY, float hitZ) { if (aWorld.isRemote) { return false; } diff --git a/src/main/java/gregtech/common/items/behaviors/Behaviour_Plunger_Fluid.java b/src/main/java/gregtech/common/items/behaviors/Behaviour_Plunger_Fluid.java index 95e895ba91d..c62cb5c4e5c 100644 --- a/src/main/java/gregtech/common/items/behaviors/Behaviour_Plunger_Fluid.java +++ b/src/main/java/gregtech/common/items/behaviors/Behaviour_Plunger_Fluid.java @@ -30,7 +30,7 @@ public Behaviour_Plunger_Fluid(int aCosts) { @Override public boolean onItemUseFirst(GT_MetaBase_Item aItem, ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, - int aY, int aZ, int aSide, float hitX, float hitY, float hitZ) { + int aY, int aZ, ForgeDirection side, float hitX, float hitY, float hitZ) { if (aWorld.isRemote) { return false; } diff --git a/src/main/java/gregtech/common/items/behaviors/Behaviour_Plunger_Item.java b/src/main/java/gregtech/common/items/behaviors/Behaviour_Plunger_Item.java index 41df9d6e95e..a5fa868a00f 100644 --- a/src/main/java/gregtech/common/items/behaviors/Behaviour_Plunger_Item.java +++ b/src/main/java/gregtech/common/items/behaviors/Behaviour_Plunger_Item.java @@ -8,6 +8,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; import gregtech.api.enums.SoundResource; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; @@ -30,13 +31,13 @@ public Behaviour_Plunger_Item(int aCosts) { @Override public boolean onItemUseFirst(GT_MetaBase_Item aItem, ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, - int aY, int aZ, int aSide, float hitX, float hitY, float hitZ) { + int aY, int aZ, ForgeDirection side, float hitX, float hitY, float hitZ) { if (aWorld.isRemote) { return false; } TileEntity aTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if ((aTileEntity instanceof IGregTechTileEntity)) { - IMetaTileEntity tMetaTileEntity = ((IGregTechTileEntity) aTileEntity).getMetaTileEntity(); + if (aTileEntity instanceof IGregTechTileEntity gtTE) { + IMetaTileEntity tMetaTileEntity = gtTE.getMetaTileEntity(); if ((tMetaTileEntity instanceof IMetaTileEntityItemPipe)) { for (IMetaTileEntityItemPipe tTileEntity : GT_Utility .sortMapByValuesAcending( @@ -48,13 +49,13 @@ public boolean onItemUseFirst(GT_MetaBase_Item aItem, ItemStack aStack, EntityPl if (tTileEntity.isValidSlot(i)) { if ((tTileEntity.getStackInSlot(i) != null) && ((aPlayer.capabilities.isCreativeMode) || (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts)))) { - ItemStack tStack = tTileEntity.decrStackSize(i, 64); + final ItemStack tStack = tTileEntity.decrStackSize(i, 64); if (tStack != null) { - EntityItem tEntity = new EntityItem( + final EntityItem tEntity = new EntityItem( aWorld, - ((IGregTechTileEntity) aTileEntity).getOffsetX((byte) aSide, 1) + 0.5D, - ((IGregTechTileEntity) aTileEntity).getOffsetY((byte) aSide, 1) + 0.5D, - ((IGregTechTileEntity) aTileEntity).getOffsetZ((byte) aSide, 1) + 0.5D, + gtTE.getOffsetX(side, 1) + 0.5D, + gtTE.getOffsetY(side, 1) + 0.5D, + gtTE.getOffsetZ(side, 1) + 0.5D, tStack); tEntity.motionX = 0.0D; tEntity.motionY = 0.0D; diff --git a/src/main/java/gregtech/common/items/behaviors/Behaviour_Prospecting.java b/src/main/java/gregtech/common/items/behaviors/Behaviour_Prospecting.java index 43a35cff059..e64722fb87a 100644 --- a/src/main/java/gregtech/common/items/behaviors/Behaviour_Prospecting.java +++ b/src/main/java/gregtech/common/items/behaviors/Behaviour_Prospecting.java @@ -41,7 +41,7 @@ public Behaviour_Prospecting(int aVanillaCosts, int aEUCosts) { @Override public boolean onItemUseFirst(GT_MetaBase_Item aItem, ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, - int aY, int aZ, int aSide, float hitX, float hitY, float hitZ) { + int aY, int aZ, ForgeDirection side, float hitX, float hitY, float hitZ) { if (aWorld.isRemote) { return false; } @@ -80,9 +80,9 @@ public boolean onItemUseFirst(GT_MetaBase_Item aItem, ItemStack aStack, EntityPl int tX = aX, tY = aY, tZ = aZ; Block tBlock; for (int i = 0, j = 6 + tQuality; i < j; i++) { - tX -= ForgeDirection.getOrientation(aSide).offsetX; - tY -= ForgeDirection.getOrientation(aSide).offsetY; - tZ -= ForgeDirection.getOrientation(aSide).offsetZ; + tX -= side.offsetX; + tY -= side.offsetY; + tZ -= side.offsetZ; tBlock = aWorld.getBlock(tX, tY, tZ); if (tBlock == Blocks.lava || tBlock == Blocks.flowing_lava) { @@ -109,16 +109,16 @@ public boolean onItemUseFirst(GT_MetaBase_Item aItem, ItemStack aStack, EntityPl } } - Random tRandom = new XSTR(aX ^ aY ^ aZ ^ aSide); + final Random tRandom = new XSTR(aX ^ aY ^ aZ ^ side.ordinal()); for (int i = 0, j = 9 + 2 * tQuality; i < j; i++) { tX = aX - 4 - tQuality + tRandom.nextInt(j); tY = aY - 4 - tQuality + tRandom.nextInt(j); tZ = aZ - 4 - tQuality + tRandom.nextInt(j); tBlock = aWorld.getBlock(tX, tY, tZ); if (tBlock instanceof GT_Block_Ores_Abstract) { - TileEntity tTileEntity = aWorld.getTileEntity(tX, tY, tZ); + final TileEntity tTileEntity = aWorld.getTileEntity(tX, tY, tZ); if (tTileEntity instanceof GT_TileEntity_Ores) { - Materials tMaterial = GregTech_API.sGeneratedMaterials[((GT_TileEntity_Ores) tTileEntity).mMetaData + final Materials tMaterial = GregTech_API.sGeneratedMaterials[((GT_TileEntity_Ores) tTileEntity).mMetaData % 1000]; if (tMaterial != null && tMaterial != Materials._NULL) { GT_Utility.sendChatToPlayer( diff --git a/src/main/java/gregtech/common/items/behaviors/Behaviour_Scanner.java b/src/main/java/gregtech/common/items/behaviors/Behaviour_Scanner.java index c041e02881b..22b708e3846 100644 --- a/src/main/java/gregtech/common/items/behaviors/Behaviour_Scanner.java +++ b/src/main/java/gregtech/common/items/behaviors/Behaviour_Scanner.java @@ -9,6 +9,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; import gregtech.api.enums.SoundResource; import gregtech.api.interfaces.IItemBehaviour; @@ -24,15 +25,15 @@ public class Behaviour_Scanner extends Behaviour_None { @Override public boolean onItemUseFirst(GT_MetaBase_Item aItem, ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, - int aY, int aZ, int aSide, float hitX, float hitY, float hitZ) { - NBTTagCompound tNBT = aStack.getTagCompound(); + int aY, int aZ, ForgeDirection side, float hitX, float hitY, float hitZ) { + final NBTTagCompound tNBT = aStack.getTagCompound(); if (((aPlayer instanceof EntityPlayerMP)) && (aItem.canUse(aStack, 20000.0D))) { - ArrayList tList = new ArrayList<>(); + final ArrayList tList = new ArrayList<>(); if (aItem.use( aStack, - GT_Utility.getCoordinateScan(tList, aPlayer, aWorld, 1, aX, aY, aZ, aSide, hitX, hitY, hitZ), + GT_Utility.getCoordinateScan(tList, aPlayer, aWorld, 1, aX, aY, aZ, side, hitX, hitY, hitZ), aPlayer)) { - int tList_sS = tList.size(); + final int tList_sS = tList.size(); tNBT.setInteger("dataLinesCount", tList_sS); for (int i = 0; i < tList_sS; i++) { tNBT.setString("dataLines" + i, tList.get(i)); diff --git a/src/main/java/gregtech/common/items/behaviors/Behaviour_Screwdriver.java b/src/main/java/gregtech/common/items/behaviors/Behaviour_Screwdriver.java index 3e15849e3fa..d940226b849 100644 --- a/src/main/java/gregtech/common/items/behaviors/Behaviour_Screwdriver.java +++ b/src/main/java/gregtech/common/items/behaviors/Behaviour_Screwdriver.java @@ -5,6 +5,7 @@ import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; import gregtech.api.enums.SoundResource; import gregtech.api.items.GT_MetaBase_Item; @@ -23,7 +24,7 @@ public Behaviour_Screwdriver(int aVanillaCosts, int aEUCosts) { @Override public boolean onItemUseFirst(GT_MetaBase_Item aItem, ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, - int aY, int aZ, int aSide, float hitX, float hitY, float hitZ) { + int aY, int aZ, ForgeDirection side, float hitX, float hitY, float hitZ) { if (aWorld.isRemote) { return false; } diff --git a/src/main/java/gregtech/common/items/behaviors/Behaviour_Sense.java b/src/main/java/gregtech/common/items/behaviors/Behaviour_Sense.java index 8adcc8a59da..b2ab0031ad2 100644 --- a/src/main/java/gregtech/common/items/behaviors/Behaviour_Sense.java +++ b/src/main/java/gregtech/common/items/behaviors/Behaviour_Sense.java @@ -6,6 +6,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; import gregtech.api.items.GT_MetaBase_Item; import gregtech.api.items.GT_MetaGenerated_Tool; @@ -24,7 +25,7 @@ public Behaviour_Sense(int aCosts) { @Override public boolean onItemUseFirst(GT_MetaBase_Item aItem, ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, - int aY, int aZ, int aSide, float hitX, float hitY, float hitZ) { + int aY, int aZ, ForgeDirection side, float hitX, float hitY, float hitZ) { if (aWorld.isRemote) { return false; } diff --git a/src/main/java/gregtech/common/items/behaviors/Behaviour_SensorKit.java b/src/main/java/gregtech/common/items/behaviors/Behaviour_SensorKit.java index 7362621df93..b12159d0581 100644 --- a/src/main/java/gregtech/common/items/behaviors/Behaviour_SensorKit.java +++ b/src/main/java/gregtech/common/items/behaviors/Behaviour_SensorKit.java @@ -9,6 +9,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; import gregtech.api.enums.ItemList; import gregtech.api.interfaces.tileentity.IGregTechDeviceInformation; @@ -24,7 +25,7 @@ public class Behaviour_SensorKit extends Behaviour_None { @Override public boolean onItemUseFirst(GT_MetaBase_Item aItem, ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, - int aY, int aZ, int aSide, float hitX, float hitY, float hitZ) { + int aY, int aZ, ForgeDirection side, float hitX, float hitY, float hitZ) { if ((aPlayer instanceof EntityPlayerMP)) { TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); if (((tTileEntity instanceof IInventory)) && (!((IInventory) tTileEntity).isUseableByPlayer(aPlayer))) { diff --git a/src/main/java/gregtech/common/items/behaviors/Behaviour_SoftHammer.java b/src/main/java/gregtech/common/items/behaviors/Behaviour_SoftHammer.java index 7f529282dd9..159a0c4b271 100644 --- a/src/main/java/gregtech/common/items/behaviors/Behaviour_SoftHammer.java +++ b/src/main/java/gregtech/common/items/behaviors/Behaviour_SoftHammer.java @@ -7,6 +7,7 @@ import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; import gregtech.api.enums.SoundResource; import gregtech.api.items.GT_MetaBase_Item; @@ -26,7 +27,7 @@ public Behaviour_SoftHammer(int aCosts) { @Override public boolean onItemUseFirst(GT_MetaBase_Item aItem, ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, - int aY, int aZ, int aSide, float hitX, float hitY, float hitZ) { + int aY, int aZ, ForgeDirection side, float hitX, float hitY, float hitZ) { if (aWorld.isRemote) { return false; } diff --git a/src/main/java/gregtech/common/items/behaviors/Behaviour_Sonictron.java b/src/main/java/gregtech/common/items/behaviors/Behaviour_Sonictron.java index 02413bf1435..dbab7645077 100644 --- a/src/main/java/gregtech/common/items/behaviors/Behaviour_Sonictron.java +++ b/src/main/java/gregtech/common/items/behaviors/Behaviour_Sonictron.java @@ -6,6 +6,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; import gregtech.api.enums.GT_Values; import gregtech.api.interfaces.IItemBehaviour; @@ -99,7 +100,7 @@ public static void copyInventory(ItemStack[] aInventory, ItemStack[] aNewContent @Override public boolean onItemUseFirst(GT_MetaBase_Item aItem, ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, - int aY, int aZ, int aSide, float hitX, float hitY, float hitZ) { + int aY, int aZ, ForgeDirection side, float hitX, float hitY, float hitZ) { setCurrentIndex(aStack, -1); return false; } diff --git a/src/main/java/gregtech/common/items/behaviors/Behaviour_Spray_Color.java b/src/main/java/gregtech/common/items/behaviors/Behaviour_Spray_Color.java index f9621a8da46..cab8e9a7a0f 100644 --- a/src/main/java/gregtech/common/items/behaviors/Behaviour_Spray_Color.java +++ b/src/main/java/gregtech/common/items/behaviors/Behaviour_Spray_Color.java @@ -65,12 +65,12 @@ public Behaviour_Spray_Color(ItemStack aEmpty, ItemStack aUsed, ItemStack aFull, @Override public boolean onItemUseFirst(GT_MetaBase_Item aItem, ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, - int aY, int aZ, int aSide, float hitX, float hitY, float hitZ) { + int aY, int aZ, ForgeDirection side, float hitX, float hitY, float hitZ) { if ((aWorld.isRemote) || (aStack.stackSize != 1)) { return false; } boolean rOutput = false; - if (!aPlayer.canPlayerEdit(aX, aY, aZ, aSide, aStack)) { + if (!aPlayer.canPlayerEdit(aX, aY, aZ, side.ordinal(), aStack)) { return false; } NBTTagCompound tNBT = aStack.getTagCompound(); @@ -97,7 +97,7 @@ public boolean onItemUseFirst(GT_MetaBase_Item aItem, ItemStack aStack, EntityPl } else { lookSide = look.zCoord > 0 ? ForgeDirection.SOUTH : ForgeDirection.NORTH; } - while ((GT_Utility.areStacksEqual(aStack, this.mUsed, true)) && (colorize(aWorld, aX, aY, aZ, aSide))) { + while ((GT_Utility.areStacksEqual(aStack, this.mUsed, true)) && (colorize(aWorld, aX, aY, aZ, side))) { GT_Utility.sendSoundToPlayers(aWorld, SoundResource.IC2_TOOLS_PAINTER, 1.0F, 1.0F, aX, aY, aZ); if (!aPlayer.capabilities.isCreativeMode) { tUses -= 1L; @@ -136,8 +136,8 @@ public boolean onItemUseFirst(GT_MetaBase_Item aItem, ItemStack aStack, EntityPl return rOutput; } - private boolean colorize(World aWorld, int aX, int aY, int aZ, int aSide) { - Block aBlock = aWorld.getBlock(aX, aY, aZ); + private boolean colorize(World aWorld, int aX, int aY, int aZ, ForgeDirection side) { + final Block aBlock = aWorld.getBlock(aX, aY, aZ); if ((aBlock != Blocks.air) && ((this.mAllowedVanillaBlocks.contains(aBlock)) || ((aBlock instanceof BlockColored)))) { if (aBlock == Blocks.hardened_clay) { @@ -158,7 +158,7 @@ private boolean colorize(World aWorld, int aX, int aY, int aZ, int aSide) { aWorld.setBlockMetadataWithNotify(aX, aY, aZ, (~this.mColor) & 0xF, 3); return true; } - return aBlock.recolourBlock(aWorld, aX, aY, aZ, ForgeDirection.getOrientation(aSide), (~this.mColor) & 0xF); + return aBlock.recolourBlock(aWorld, aX, aY, aZ, side, (~this.mColor) & 0xF); } @Override diff --git a/src/main/java/gregtech/common/items/behaviors/Behaviour_Switch_Metadata.java b/src/main/java/gregtech/common/items/behaviors/Behaviour_Switch_Metadata.java index 20bc59a1712..03cf29b9ddd 100644 --- a/src/main/java/gregtech/common/items/behaviors/Behaviour_Switch_Metadata.java +++ b/src/main/java/gregtech/common/items/behaviors/Behaviour_Switch_Metadata.java @@ -8,6 +8,7 @@ import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; import gregtech.api.items.GT_Generic_Block; import gregtech.api.items.GT_MetaBase_Item; @@ -41,7 +42,7 @@ public List getAdditionalToolTips(GT_MetaBase_Item aItem, List a @Override public boolean onItemUseFirst(GT_MetaBase_Item aItem, ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, - int aY, int aZ, int aSide, float aHitX, float aHitY, float aHitZ) { + int aY, int aZ, ForgeDirection side, float aHitX, float aHitY, float aHitZ) { if (aStack != null && (aPlayer == null || aPlayer.isSneaking()) && !aWorld.isRemote) { if (mCheckTarget) { Block aBlock = aWorld.blockExists(aX, aY, aZ) ? aWorld.getBlock(aX, aY, aZ) : Blocks.air; diff --git a/src/main/java/gregtech/common/items/behaviors/Behaviour_Wrench.java b/src/main/java/gregtech/common/items/behaviors/Behaviour_Wrench.java index 2e4d682dcfb..4eb1009ebcf 100644 --- a/src/main/java/gregtech/common/items/behaviors/Behaviour_Wrench.java +++ b/src/main/java/gregtech/common/items/behaviors/Behaviour_Wrench.java @@ -32,33 +32,34 @@ public Behaviour_Wrench(int aCosts) { @Override public boolean onItemUseFirst(GT_MetaBase_Item aItem, ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, - int aY, int aZ, int aSide, float hitX, float hitY, float hitZ) { + int aY, int aZ, ForgeDirection side, float hitX, float hitY, float hitZ) { if (aWorld.isRemote) { return false; } - Block aBlock = aWorld.getBlock(aX, aY, aZ); + final Block aBlock = aWorld.getBlock(aX, aY, aZ); if (aBlock == null) { return false; } - byte aMeta = (byte) aWorld.getBlockMetadata(aX, aY, aZ); - byte aTargetSide = GT_Utility.determineWrenchingSide((byte) aSide, hitX, hitY, hitZ); - TileEntity aTileEntity = aWorld.getTileEntity(aX, aY, aZ); + final byte aMeta = (byte) aWorld.getBlockMetadata(aX, aY, aZ); + final short targetSideOrdinal = (short) GT_Utility.determineWrenchingSide(side, hitX, hitY, hitZ) + .ordinal(); + final TileEntity aTileEntity = aWorld.getTileEntity(aX, aY, aZ); try { - if (((aTileEntity instanceof IWrenchable))) { - if (((IWrenchable) aTileEntity).wrenchCanSetFacing(aPlayer, aTargetSide)) { + if (aTileEntity instanceof IWrenchable wrenchable) { + if (wrenchable.wrenchCanSetFacing(aPlayer, targetSideOrdinal)) { if ((aPlayer.capabilities.isCreativeMode) || (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts))) { - ((IWrenchable) aTileEntity).setFacing(aTargetSide); + wrenchable.setFacing(targetSideOrdinal); GT_Utility.sendSoundToPlayers(aWorld, SoundResource.IC2_TOOLS_WRENCH, 1.0F, -1.0F, aX, aY, aZ); } return true; } - if (((IWrenchable) aTileEntity).wrenchCanRemove(aPlayer)) { - int tDamage = ((IWrenchable) aTileEntity).getWrenchDropRate() < 1.0F ? 10 : 3; + if (wrenchable.wrenchCanRemove(aPlayer)) { + final int tDamage = wrenchable.getWrenchDropRate() < 1.0F ? 10 : 3; if ((aPlayer.capabilities.isCreativeMode) || (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, (long) tDamage * this.mCosts))) { - ItemStack tOutput = ((IWrenchable) aTileEntity).getWrenchDrop(aPlayer); - for (ItemStack tStack : aBlock.getDrops(aWorld, aX, aY, aZ, aMeta, 0)) { + ItemStack tOutput = wrenchable.getWrenchDrop(aPlayer); + for (final ItemStack tStack : aBlock.getDrops(aWorld, aX, aY, aZ, aMeta, 0)) { if (tOutput == null) { aWorld.spawnEntityInWorld( new EntityItem(aWorld, aX + 0.5D, aY + 0.5D, aZ + 0.5D, tStack)); @@ -110,7 +111,7 @@ public boolean onItemUseFirst(GT_MetaBase_Item aItem, ItemStack aStack, EntityPl } return true; } - if (aMeta == aTargetSide) { + if (aMeta == targetSideOrdinal) { if ((aBlock == Blocks.pumpkin) || (aBlock == Blocks.lit_pumpkin) || (aBlock == Blocks.piston) || (aBlock == Blocks.sticky_piston) @@ -137,7 +138,7 @@ public boolean onItemUseFirst(GT_MetaBase_Item aItem, ItemStack aStack, EntityPl || (aBlock == Blocks.dropper)) { if ((aMeta < 6) && ((aPlayer.capabilities.isCreativeMode) || (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts)))) { - aWorld.setBlockMetadataWithNotify(aX, aY, aZ, aTargetSide, 3); + aWorld.setBlockMetadataWithNotify(aX, aY, aZ, targetSideOrdinal, 3); GT_Utility.sendSoundToPlayers(aWorld, SoundResource.IC2_TOOLS_WRENCH, 1.0F, -1.0F, aX, aY, aZ); } return true; @@ -148,27 +149,27 @@ public boolean onItemUseFirst(GT_MetaBase_Item aItem, ItemStack aStack, EntityPl || (aBlock == Blocks.chest) || (aBlock == Blocks.ender_chest) || (aBlock == Blocks.trapped_chest)) { - if ((aTargetSide > 1) && ((aPlayer.capabilities.isCreativeMode) + if ((targetSideOrdinal > 1) && ((aPlayer.capabilities.isCreativeMode) || (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts)))) { - aWorld.setBlockMetadataWithNotify(aX, aY, aZ, aTargetSide, 3); + aWorld.setBlockMetadataWithNotify(aX, aY, aZ, targetSideOrdinal, 3); GT_Utility.sendSoundToPlayers(aWorld, SoundResource.IC2_TOOLS_WRENCH, 1.0F, -1.0F, aX, aY, aZ); } return true; } if (aBlock == Blocks.hopper) { - if ((aTargetSide != 1) && ((aPlayer.capabilities.isCreativeMode) + if ((targetSideOrdinal != 1) && ((aPlayer.capabilities.isCreativeMode) || (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts)))) { - aWorld.setBlockMetadataWithNotify(aX, aY, aZ, aTargetSide, 3); + aWorld.setBlockMetadataWithNotify(aX, aY, aZ, targetSideOrdinal, 3); GT_Utility.sendSoundToPlayers(aWorld, SoundResource.IC2_TOOLS_WRENCH, 1.0F, -1.0F, aX, aY, aZ); } return true; } } if ((Arrays.asList(aBlock.getValidRotations(aWorld, aX, aY, aZ)) - .contains(ForgeDirection.getOrientation(aTargetSide))) + .contains(ForgeDirection.getOrientation(targetSideOrdinal))) && ((aPlayer.capabilities.isCreativeMode) || (!GT_ModHandler.isElectricItem(aStack)) || (GT_ModHandler.canUseElectricItem(aStack, this.mCosts))) - && (aBlock.rotateBlock(aWorld, aX, aY, aZ, ForgeDirection.getOrientation(aTargetSide)))) { + && (aBlock.rotateBlock(aWorld, aX, aY, aZ, ForgeDirection.getOrientation(targetSideOrdinal)))) { if (!aPlayer.capabilities.isCreativeMode) { ((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts); } diff --git a/src/main/java/gregtech/common/items/behaviors/Behaviour_WrittenBook.java b/src/main/java/gregtech/common/items/behaviors/Behaviour_WrittenBook.java index c62cfedf2a4..0f645a93a97 100644 --- a/src/main/java/gregtech/common/items/behaviors/Behaviour_WrittenBook.java +++ b/src/main/java/gregtech/common/items/behaviors/Behaviour_WrittenBook.java @@ -19,7 +19,7 @@ public class Behaviour_WrittenBook extends Behaviour_None { @Override @SideOnly(Side.CLIENT) public boolean onItemUse(GT_MetaBase_Item aItem, ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, - int aY, int aZ, int aSide, float hitX, float hitY, float hitZ) { + int aY, int aZ, int ordinalSide, float hitX, float hitY, float hitZ) { if ((GT_Utility.isStringValid(GT_Utility.ItemNBT.getBookTitle(aStack))) && ((aPlayer instanceof EntityPlayerSP))) { Minecraft.getMinecraft() diff --git a/src/main/java/gregtech/common/render/GT_CopiedBlockTexture.java b/src/main/java/gregtech/common/render/GT_CopiedBlockTexture.java index 421d2f648b7..937c1a994f5 100644 --- a/src/main/java/gregtech/common/render/GT_CopiedBlockTexture.java +++ b/src/main/java/gregtech/common/render/GT_CopiedBlockTexture.java @@ -14,10 +14,10 @@ public class GT_CopiedBlockTexture extends GT_TextureBase implements ITexture, I private final Block mBlock; private final byte mSide, mMeta; - protected GT_CopiedBlockTexture(Block aBlock, int aSide, int aMeta, short[] aRGBa, boolean allowAlpha) { + protected GT_CopiedBlockTexture(Block aBlock, int ordinalSide, int aMeta, short[] aRGBa, boolean allowAlpha) { if (aRGBa.length != 4) throw new IllegalArgumentException("RGBa doesn't have 4 Values @ GT_CopiedBlockTexture"); mBlock = aBlock; - mSide = (byte) aSide; + mSide = (byte) ordinalSide; mMeta = (byte) aMeta; } @@ -26,8 +26,8 @@ public boolean isOldTexture() { return false; } - private IIcon getIcon(int aSide) { - if (mSide == 6) return mBlock.getIcon(aSide, mMeta); + private IIcon getIcon(int ordinalSide) { + if (mSide == 6) return mBlock.getIcon(ordinalSide, mMeta); return mBlock.getIcon(mSide, mMeta); } @@ -37,7 +37,7 @@ public void renderXPos(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aRenderer.field_152631_f = true; startDrawingQuads(aRenderer, 1.0f, 0.0f, 0.0f); new LightingHelper(aRenderer).setupLightingXPos(aBlock, aX, aY, aZ) - .setupColor(ForgeDirection.EAST.ordinal(), 0xffffff); + .setupColor(ForgeDirection.EAST, 0xffffff); aRenderer.renderFaceXPos(aBlock, aX, aY, aZ, aIcon); draw(aRenderer); aRenderer.field_152631_f = false; @@ -48,7 +48,7 @@ public void renderXNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int startDrawingQuads(aRenderer, -1.0f, 0.0f, 0.0f); final IIcon aIcon = getIcon(ForgeDirection.WEST.ordinal()); new LightingHelper(aRenderer).setupLightingXNeg(aBlock, aX, aY, aZ) - .setupColor(ForgeDirection.WEST.ordinal(), 0xffffff); + .setupColor(ForgeDirection.WEST, 0xffffff); aRenderer.renderFaceXNeg(aBlock, aX, aY, aZ, aIcon); draw(aRenderer); } @@ -58,7 +58,7 @@ public void renderYPos(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int startDrawingQuads(aRenderer, 0.0f, 1.0f, 0.0f); final IIcon aIcon = getIcon(ForgeDirection.UP.ordinal()); new LightingHelper(aRenderer).setupLightingYPos(aBlock, aX, aY, aZ) - .setupColor(ForgeDirection.UP.ordinal(), 0xffffff); + .setupColor(ForgeDirection.UP, 0xffffff); aRenderer.renderFaceYPos(aBlock, aX, aY, aZ, aIcon); draw(aRenderer); } @@ -68,7 +68,7 @@ public void renderYNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int startDrawingQuads(aRenderer, 0.0f, -1.0f, 0.0f); final IIcon aIcon = getIcon(ForgeDirection.DOWN.ordinal()); new LightingHelper(aRenderer).setupLightingYNeg(aBlock, aX, aY, aZ) - .setupColor(ForgeDirection.DOWN.ordinal(), 0xffffff); + .setupColor(ForgeDirection.DOWN, 0xffffff); aRenderer.renderFaceYNeg(aBlock, aX, aY, aZ, aIcon); draw(aRenderer); } @@ -78,7 +78,7 @@ public void renderZPos(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int startDrawingQuads(aRenderer, 0.0f, 0.0f, 1.0f); final IIcon aIcon = getIcon(ForgeDirection.SOUTH.ordinal()); new LightingHelper(aRenderer).setupLightingZPos(aBlock, aX, aY, aZ) - .setupColor(ForgeDirection.SOUTH.ordinal(), 0xffffff); + .setupColor(ForgeDirection.SOUTH, 0xffffff); aRenderer.renderFaceZPos(aBlock, aX, aY, aZ, aIcon); draw(aRenderer); } @@ -89,7 +89,7 @@ public void renderZNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int final IIcon aIcon = getIcon(ForgeDirection.NORTH.ordinal()); aRenderer.field_152631_f = true; new LightingHelper(aRenderer).setupLightingZNeg(aBlock, aX, aY, aZ) - .setupColor(ForgeDirection.NORTH.ordinal(), 0xffffff); + .setupColor(ForgeDirection.NORTH, 0xffffff); aRenderer.renderFaceZNeg(aBlock, aX, aY, aZ, aIcon); draw(aRenderer); aRenderer.field_152631_f = false; diff --git a/src/main/java/gregtech/common/render/GT_CopiedCTMBlockTexture.java b/src/main/java/gregtech/common/render/GT_CopiedCTMBlockTexture.java index e4304af15d5..17fa9ac8ff6 100644 --- a/src/main/java/gregtech/common/render/GT_CopiedCTMBlockTexture.java +++ b/src/main/java/gregtech/common/render/GT_CopiedCTMBlockTexture.java @@ -15,11 +15,11 @@ class GT_CopiedCTMBlockTexture extends GT_TextureBase implements ITexture, IBloc private final Block mBlock; private final byte mSide, mMeta; - GT_CopiedCTMBlockTexture(Block aBlock, int aSide, int aMeta, short[] aRGBa, boolean allowAlpha) { + GT_CopiedCTMBlockTexture(Block aBlock, int ordinalSide, int aMeta, short[] aRGBa, boolean allowAlpha) { if (aRGBa.length != 4) throw new IllegalArgumentException("RGBa doesn't have 4 Values @ GT_CopiedCTMBlockTexture"); mBlock = aBlock; - mSide = (byte) aSide; + mSide = (byte) ordinalSide; mMeta = (byte) aMeta; } @@ -28,8 +28,8 @@ public boolean isOldTexture() { return false; } - private IIcon getIcon(int aSide, int aX, int aY, int aZ, RenderBlocks aRenderer) { - final int tSide = mSide == 6 ? aSide : mSide; + private IIcon getIcon(int ordinalSide, int aX, int aY, int aZ, RenderBlocks aRenderer) { + final int tSide = mSide == 6 ? ordinalSide : mSide; return mBlock.getIcon(getBlockAccess(aRenderer), aX, aY, aZ, tSide); } @@ -43,7 +43,7 @@ public void renderXPos(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aRenderer.field_152631_f = true; startDrawingQuads(aRenderer, 1.0f, 0.0f, 0.0f); new LightingHelper(aRenderer).setupLightingXPos(aBlock, aX, aY, aZ) - .setupColor(ForgeDirection.EAST.ordinal(), mBlock.colorMultiplier(getBlockAccess(aRenderer), aX, aY, aZ)); + .setupColor(ForgeDirection.EAST, mBlock.colorMultiplier(getBlockAccess(aRenderer), aX, aY, aZ)); aRenderer.renderFaceXPos(aBlock, aX, aY, aZ, aIcon); draw(aRenderer); aRenderer.field_152631_f = false; @@ -54,7 +54,7 @@ public void renderXNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int startDrawingQuads(aRenderer, -1.0f, 0.0f, 0.0f); final IIcon aIcon = getIcon(ForgeDirection.WEST.ordinal(), aX, aY, aZ, aRenderer); new LightingHelper(aRenderer).setupLightingXNeg(aBlock, aX, aY, aZ) - .setupColor(ForgeDirection.WEST.ordinal(), mBlock.colorMultiplier(getBlockAccess(aRenderer), aX, aY, aZ)); + .setupColor(ForgeDirection.WEST, mBlock.colorMultiplier(getBlockAccess(aRenderer), aX, aY, aZ)); aRenderer.renderFaceXNeg(aBlock, aX, aY, aZ, aIcon); draw(aRenderer); } @@ -64,7 +64,7 @@ public void renderYPos(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int startDrawingQuads(aRenderer, 0.0f, 1.0f, 0.0f); final IIcon aIcon = getIcon(ForgeDirection.UP.ordinal(), aX, aY, aZ, aRenderer); new LightingHelper(aRenderer).setupLightingYPos(aBlock, aX, aY, aZ) - .setupColor(ForgeDirection.UP.ordinal(), mBlock.colorMultiplier(getBlockAccess(aRenderer), aX, aY, aZ)); + .setupColor(ForgeDirection.UP, mBlock.colorMultiplier(getBlockAccess(aRenderer), aX, aY, aZ)); aRenderer.renderFaceYPos(aBlock, aX, aY, aZ, aIcon); draw(aRenderer); } @@ -74,7 +74,7 @@ public void renderYNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int startDrawingQuads(aRenderer, 0.0f, -1.0f, 0.0f); final IIcon aIcon = getIcon(ForgeDirection.DOWN.ordinal(), aX, aY, aZ, aRenderer); new LightingHelper(aRenderer).setupLightingYNeg(aBlock, aX, aY, aZ) - .setupColor(ForgeDirection.DOWN.ordinal(), mBlock.colorMultiplier(getBlockAccess(aRenderer), aX, aY, aZ)); + .setupColor(ForgeDirection.DOWN, mBlock.colorMultiplier(getBlockAccess(aRenderer), aX, aY, aZ)); aRenderer.renderFaceYNeg(aBlock, aX, aY, aZ, aIcon); draw(aRenderer); } @@ -84,7 +84,7 @@ public void renderZPos(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int startDrawingQuads(aRenderer, 0.0f, 0.0f, 1.0f); final IIcon aIcon = getIcon(ForgeDirection.SOUTH.ordinal(), aX, aY, aZ, aRenderer); new LightingHelper(aRenderer).setupLightingZPos(aBlock, aX, aY, aZ) - .setupColor(ForgeDirection.SOUTH.ordinal(), mBlock.colorMultiplier(getBlockAccess(aRenderer), aX, aY, aZ)); + .setupColor(ForgeDirection.SOUTH, mBlock.colorMultiplier(getBlockAccess(aRenderer), aX, aY, aZ)); aRenderer.renderFaceZPos(aBlock, aX, aY, aZ, aIcon); draw(aRenderer); } @@ -95,7 +95,7 @@ public void renderZNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int final IIcon aIcon = getIcon(ForgeDirection.NORTH.ordinal(), aX, aY, aZ, aRenderer); aRenderer.field_152631_f = true; new LightingHelper(aRenderer).setupLightingZNeg(aBlock, aX, aY, aZ) - .setupColor(ForgeDirection.NORTH.ordinal(), mBlock.colorMultiplier(getBlockAccess(aRenderer), aX, aY, aZ)); + .setupColor(ForgeDirection.NORTH, mBlock.colorMultiplier(getBlockAccess(aRenderer), aX, aY, aZ)); aRenderer.renderFaceZNeg(aBlock, aX, aY, aZ, aIcon); draw(aRenderer); aRenderer.field_152631_f = false; diff --git a/src/main/java/gregtech/common/render/GT_RenderUtil.java b/src/main/java/gregtech/common/render/GT_RenderUtil.java index 6cba823a669..e98f573b94c 100644 --- a/src/main/java/gregtech/common/render/GT_RenderUtil.java +++ b/src/main/java/gregtech/common/render/GT_RenderUtil.java @@ -5,6 +5,7 @@ import net.minecraft.client.renderer.Tessellator; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; +import net.minecraftforge.common.util.ForgeDirection; import org.lwjgl.opengl.GL11; @@ -23,31 +24,25 @@ public static void colorGTItem(ItemStack aStack) { } public static void renderBlockIcon(RenderBlocks aRenderer, Block aBlock, double aX, double aY, double aZ, - IIcon aIcon, byte aSide) { - switch (aSide) { - case 0 -> { + IIcon aIcon, ForgeDirection side) { + switch (side) { + case DOWN -> { aRenderer.renderFaceYNeg(aBlock, aX, aY, aZ, aIcon); - return; } - case 1 -> { + case UP -> { aRenderer.renderFaceYPos(aBlock, aX, aY, aZ, aIcon); - return; } - case 2 -> { + case NORTH -> { aRenderer.renderFaceZNeg(aBlock, aX, aY, aZ, aIcon); - return; } - case 3 -> { + case SOUTH -> { aRenderer.renderFaceZPos(aBlock, aX, aY, aZ, aIcon); - return; } - case 4 -> { + case WEST -> { aRenderer.renderFaceXNeg(aBlock, aX, aY, aZ, aIcon); - return; } - case 5 -> { + case EAST -> { aRenderer.renderFaceXPos(aBlock, aX, aY, aZ, aIcon); - return; } } } diff --git a/src/main/java/gregtech/common/render/GT_RenderedTexture.java b/src/main/java/gregtech/common/render/GT_RenderedTexture.java index 34b8c879aea..afaf3b290c1 100644 --- a/src/main/java/gregtech/common/render/GT_RenderedTexture.java +++ b/src/main/java/gregtech/common/render/GT_RenderedTexture.java @@ -64,11 +64,11 @@ public void renderXPos(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int if (enableAO) lighting.setBrightnessOverride(MAX_BRIGHTNESS); } lighting.setupLightingXPos(aBlock, aX, aY, aZ) - .setupColor(ForgeDirection.EAST.ordinal(), mRGBa); + .setupColor(ForgeDirection.EAST, mRGBa); final ExtendedFacing rotation = getExtendedFacing(aX, aY, aZ); renderFaceXPos(aRenderer, aX, aY, aZ, mIconContainer.getIcon(), rotation); if (mIconContainer.getOverlayIcon() != null) { - lighting.setupColor(ForgeDirection.EAST.ordinal(), 0xffffff); + lighting.setupColor(ForgeDirection.EAST, 0xffffff); renderFaceXPos(aRenderer, aX, aY, aZ, mIconContainer.getOverlayIcon(), rotation); } aRenderer.enableAO = enableAO; @@ -90,11 +90,11 @@ public void renderXNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int lighting.setBrightnessOverride(MAX_BRIGHTNESS); } lighting.setupLightingXNeg(aBlock, aX, aY, aZ) - .setupColor(ForgeDirection.WEST.ordinal(), mRGBa); + .setupColor(ForgeDirection.WEST, mRGBa); final ExtendedFacing rotation = getExtendedFacing(aX, aY, aZ); renderFaceXNeg(aRenderer, aX, aY, aZ, mIconContainer.getIcon(), rotation); if (mIconContainer.getOverlayIcon() != null) { - lighting.setupColor(ForgeDirection.WEST.ordinal(), 0xffffff); + lighting.setupColor(ForgeDirection.WEST, 0xffffff); renderFaceXNeg(aRenderer, aX, aY, aZ, mIconContainer.getOverlayIcon(), rotation); } aRenderer.enableAO = enableAO; @@ -116,11 +116,11 @@ public void renderYPos(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int lighting.setBrightnessOverride(MAX_BRIGHTNESS); } lighting.setupLightingYPos(aBlock, aX, aY, aZ) - .setupColor(ForgeDirection.UP.ordinal(), mRGBa); + .setupColor(ForgeDirection.UP, mRGBa); final ExtendedFacing rotation = getExtendedFacing(aX, aY, aZ); renderFaceYPos(aRenderer, aX, aY, aZ, mIconContainer.getIcon(), rotation); if (mIconContainer.getOverlayIcon() != null) { - lighting.setupColor(ForgeDirection.UP.ordinal(), 0xffffff); + lighting.setupColor(ForgeDirection.UP, 0xffffff); renderFaceYPos(aRenderer, aX, aY, aZ, mIconContainer.getOverlayIcon(), rotation); } aRenderer.enableAO = enableAO; @@ -142,7 +142,7 @@ public void renderYNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int lighting.setBrightnessOverride(MAX_BRIGHTNESS); } lighting.setupLightingYNeg(aBlock, aX, aY, aZ) - .setupColor(ForgeDirection.DOWN.ordinal(), mRGBa); + .setupColor(ForgeDirection.DOWN, mRGBa); final ExtendedFacing rotation = getExtendedFacing(aX, aY, aZ); renderFaceYNeg(aRenderer, aX, aY, aZ, mIconContainer.getIcon(), rotation); if (mIconContainer.getOverlayIcon() != null) { @@ -168,11 +168,11 @@ public void renderZPos(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int lighting.setBrightnessOverride(MAX_BRIGHTNESS); } lighting.setupLightingZPos(aBlock, aX, aY, aZ) - .setupColor(ForgeDirection.SOUTH.ordinal(), mRGBa); + .setupColor(ForgeDirection.SOUTH, mRGBa); final ExtendedFacing rotation = getExtendedFacing(aX, aY, aZ); renderFaceZPos(aRenderer, aX, aY, aZ, mIconContainer.getIcon(), rotation); if (mIconContainer.getOverlayIcon() != null) { - lighting.setupColor(ForgeDirection.SOUTH.ordinal(), 0xffffff); + lighting.setupColor(ForgeDirection.SOUTH, 0xffffff); renderFaceZPos(aRenderer, aX, aY, aZ, mIconContainer.getOverlayIcon(), rotation); } aRenderer.enableAO = enableAO; @@ -194,11 +194,11 @@ public void renderZNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int lighting.setBrightnessOverride(MAX_BRIGHTNESS); } lighting.setupLightingZNeg(aBlock, aX, aY, aZ) - .setupColor(ForgeDirection.NORTH.ordinal(), mRGBa); + .setupColor(ForgeDirection.NORTH, mRGBa); final ExtendedFacing rotation = getExtendedFacing(aX, aY, aZ); renderFaceZNeg(aRenderer, aX, aY, aZ, mIconContainer.getIcon(), rotation); if (mIconContainer.getOverlayIcon() != null) { - lighting.setupColor(ForgeDirection.NORTH.ordinal(), 0xffffff); + lighting.setupColor(ForgeDirection.NORTH, 0xffffff); renderFaceZNeg(aRenderer, aX, aY, aZ, mIconContainer.getOverlayIcon(), rotation); } aRenderer.enableAO = enableAO; @@ -383,9 +383,8 @@ private ExtendedFacing getExtendedFacing(int x, int y, int z) { alignment = ((IAlignmentProvider) meta).getAlignment(); } else if (meta != null) { return ExtendedFacing.of( - ForgeDirection.getOrientation( - meta.getBaseMetaTileEntity() - .getFrontFacing())); + meta.getBaseMetaTileEntity() + .getFrontFacing()); } } else if (te instanceof IAlignmentProvider) { alignment = ((IAlignmentProvider) te).getAlignment(); 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 012115efa3a..7ed875aa00c 100644 --- a/src/main/java/gregtech/common/render/GT_Renderer_Block.java +++ b/src/main/java/gregtech/common/render/GT_Renderer_Block.java @@ -1,5 +1,11 @@ package gregtech.common.render; +import static gregtech.api.enums.GT_Values.SIDE_DOWN; +import static gregtech.api.enums.GT_Values.SIDE_EAST; +import static gregtech.api.enums.GT_Values.SIDE_NORTH; +import static gregtech.api.enums.GT_Values.SIDE_SOUTH; +import static gregtech.api.enums.GT_Values.SIDE_UP; +import static gregtech.api.enums.GT_Values.SIDE_WEST; import static gregtech.api.interfaces.metatileentity.IConnectable.CONNECTED_DOWN; import static gregtech.api.interfaces.metatileentity.IConnectable.CONNECTED_EAST; import static gregtech.api.interfaces.metatileentity.IConnectable.CONNECTED_NORTH; @@ -26,6 +32,7 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; import org.lwjgl.opengl.GL11; @@ -40,6 +47,7 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.interfaces.tileentity.IPipeRenderedTileEntity; import gregtech.api.interfaces.tileentity.ITexturedTileEntity; +import gregtech.api.metatileentity.MetaPipeEntity; import gregtech.api.objects.XSTR; import gregtech.common.blocks.GT_Block_Machines; import gregtech.common.blocks.GT_Block_Ores_Abstract; @@ -72,12 +80,12 @@ public static boolean renderStandardBlock(IBlockAccess aWorld, int aX, int aY, i aZ, aBlock, aRenderer, - new ITexture[][] { ((IPipeRenderedTileEntity) tTileEntity).getTextureCovered((byte) DOWN.ordinal()), - ((IPipeRenderedTileEntity) tTileEntity).getTextureCovered((byte) UP.ordinal()), - ((IPipeRenderedTileEntity) tTileEntity).getTextureCovered((byte) NORTH.ordinal()), - ((IPipeRenderedTileEntity) tTileEntity).getTextureCovered((byte) SOUTH.ordinal()), - ((IPipeRenderedTileEntity) tTileEntity).getTextureCovered((byte) WEST.ordinal()), - ((IPipeRenderedTileEntity) tTileEntity).getTextureCovered((byte) EAST.ordinal()) }); + new ITexture[][] { ((IPipeRenderedTileEntity) tTileEntity).getTextureCovered(DOWN), + ((IPipeRenderedTileEntity) tTileEntity).getTextureCovered(UP), + ((IPipeRenderedTileEntity) tTileEntity).getTextureCovered(NORTH), + ((IPipeRenderedTileEntity) tTileEntity).getTextureCovered(SOUTH), + ((IPipeRenderedTileEntity) tTileEntity).getTextureCovered(WEST), + ((IPipeRenderedTileEntity) tTileEntity).getTextureCovered(EAST) }); } if ((tTileEntity instanceof ITexturedTileEntity)) { return renderStandardBlock( @@ -87,12 +95,12 @@ public static boolean renderStandardBlock(IBlockAccess aWorld, int aX, int aY, i aZ, aBlock, aRenderer, - new ITexture[][] { ((ITexturedTileEntity) tTileEntity).getTexture(aBlock, (byte) DOWN.ordinal()), - ((ITexturedTileEntity) tTileEntity).getTexture(aBlock, (byte) UP.ordinal()), - ((ITexturedTileEntity) tTileEntity).getTexture(aBlock, (byte) NORTH.ordinal()), - ((ITexturedTileEntity) tTileEntity).getTexture(aBlock, (byte) SOUTH.ordinal()), - ((ITexturedTileEntity) tTileEntity).getTexture(aBlock, (byte) WEST.ordinal()), - ((ITexturedTileEntity) tTileEntity).getTexture(aBlock, (byte) EAST.ordinal()) }); + new ITexture[][] { ((ITexturedTileEntity) tTileEntity).getTexture(aBlock, DOWN), + ((ITexturedTileEntity) tTileEntity).getTexture(aBlock, UP), + ((ITexturedTileEntity) tTileEntity).getTexture(aBlock, NORTH), + ((ITexturedTileEntity) tTileEntity).getTexture(aBlock, SOUTH), + ((ITexturedTileEntity) tTileEntity).getTexture(aBlock, WEST), + ((ITexturedTileEntity) tTileEntity).getTexture(aBlock, EAST) }); } return false; } @@ -102,12 +110,12 @@ public static boolean renderStandardBlock(IBlockAccess aWorld, int aX, int aY, i aBlock.setBlockBounds(blockMin, blockMin, blockMin, blockMax, blockMax, blockMax); aRenderer.setRenderBoundsFromBlock(aBlock); - renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[DOWN.ordinal()], true); - renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[UP.ordinal()], true); - renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[NORTH.ordinal()], true); - renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[SOUTH.ordinal()], true); - renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[WEST.ordinal()], true); - renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[EAST.ordinal()], true); + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[SIDE_DOWN], true); + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[SIDE_UP], true); + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[SIDE_NORTH], true); + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[SIDE_SOUTH], true); + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[SIDE_WEST], true); + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[SIDE_EAST], true); return true; } @@ -126,65 +134,66 @@ public static boolean renderPipeBlock(IBlockAccess aWorld, int aX, int aY, int a final float pipeMax = blockMax - pipeMin; final boolean[] tIsCovered = new boolean[VALID_DIRECTIONS.length]; for (int i = 0; i < VALID_DIRECTIONS.length; i++) { - tIsCovered[i] = (aTileEntity.getCoverIDAtSide((byte) i) != 0); + tIsCovered[i] = (aTileEntity.getCoverIDAtSide(ForgeDirection.getOrientation(i)) != 0); } final ITexture[][] tIcons = new ITexture[VALID_DIRECTIONS.length][]; final ITexture[][] tCovers = new ITexture[VALID_DIRECTIONS.length][]; - for (int i = 0; i < VALID_DIRECTIONS.length; i++) { - tCovers[i] = aTileEntity.getTexture(aBlock, (byte) i); - tIcons[i] = aTileEntity.getTextureUncovered((byte) i); + for (final ForgeDirection iSide : ForgeDirection.VALID_DIRECTIONS) { + final int iOrdinalSide = iSide.ordinal(); + tCovers[iOrdinalSide] = aTileEntity.getTexture(aBlock, iSide); + tIcons[iOrdinalSide] = aTileEntity.getTextureUncovered(iSide); } switch (aConnections) { case NO_CONNECTION -> { aBlock.setBlockBounds(pipeMin, pipeMin, pipeMin, pipeMax, pipeMax, pipeMax); aRenderer.setRenderBoundsFromBlock(aBlock); - renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[DOWN.ordinal()], false); - renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[UP.ordinal()], false); - renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[NORTH.ordinal()], false); - renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[SOUTH.ordinal()], false); - renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[WEST.ordinal()], false); - renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[EAST.ordinal()], false); + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[SIDE_DOWN], false); + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[SIDE_UP], false); + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[SIDE_NORTH], false); + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[SIDE_SOUTH], false); + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[SIDE_WEST], false); + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[SIDE_EAST], false); } case CONNECTED_EAST | CONNECTED_WEST -> { // EAST - WEST Pipe Sides aBlock.setBlockBounds(blockMin, pipeMin, pipeMin, blockMax, pipeMax, pipeMax); aRenderer.setRenderBoundsFromBlock(aBlock); - renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[DOWN.ordinal()], false); - renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[UP.ordinal()], false); - renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[NORTH.ordinal()], false); - renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[SOUTH.ordinal()], false); + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[SIDE_DOWN], false); + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[SIDE_UP], false); + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[SIDE_NORTH], false); + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[SIDE_SOUTH], false); // EAST - WEST Pipe Ends - renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[WEST.ordinal()], false); - renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[EAST.ordinal()], false); + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[SIDE_WEST], false); + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[SIDE_EAST], false); } case CONNECTED_DOWN | CONNECTED_UP -> { // UP - DOWN Pipe Sides aBlock.setBlockBounds(pipeMin, blockMin, pipeMin, pipeMax, blockMax, pipeMax); aRenderer.setRenderBoundsFromBlock(aBlock); - renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[NORTH.ordinal()], false); - renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[SOUTH.ordinal()], false); - renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[WEST.ordinal()], false); - renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[EAST.ordinal()], false); + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[SIDE_NORTH], false); + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[SIDE_SOUTH], false); + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[SIDE_WEST], false); + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[SIDE_EAST], false); // UP - DOWN Pipe Ends - renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[DOWN.ordinal()], false); - renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[UP.ordinal()], false); + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[SIDE_DOWN], false); + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[SIDE_UP], false); } case CONNECTED_NORTH | CONNECTED_SOUTH -> { // NORTH - SOUTH Pipe Sides aBlock.setBlockBounds(pipeMin, pipeMin, blockMin, pipeMax, pipeMax, blockMax); aRenderer.setRenderBoundsFromBlock(aBlock); - renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[DOWN.ordinal()], false); - renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[UP.ordinal()], false); - renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[WEST.ordinal()], false); - renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[EAST.ordinal()], false); + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[SIDE_DOWN], false); + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[SIDE_UP], false); + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[SIDE_WEST], false); + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[SIDE_EAST], false); // NORTH - SOUTH Pipe Ends - renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[NORTH.ordinal()], false); - renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[SOUTH.ordinal()], false); + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[SIDE_NORTH], false); + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[SIDE_SOUTH], false); } default -> { if ((aConnections & CONNECTED_WEST) == 0) { @@ -193,273 +202,273 @@ public static boolean renderPipeBlock(IBlockAccess aWorld, int aX, int aY, int a } else { aBlock.setBlockBounds(blockMin, pipeMin, pipeMin, pipeMin, pipeMax, pipeMax); aRenderer.setRenderBoundsFromBlock(aBlock); - renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[DOWN.ordinal()], false); - renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[UP.ordinal()], false); - renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[NORTH.ordinal()], false); - renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[SOUTH.ordinal()], false); + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[SIDE_DOWN], false); + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[SIDE_UP], false); + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[SIDE_NORTH], false); + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[SIDE_SOUTH], false); } - renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[WEST.ordinal()], false); + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[SIDE_WEST], false); if ((aConnections & CONNECTED_EAST) == 0) { aBlock.setBlockBounds(pipeMin, pipeMin, pipeMin, pipeMax, pipeMax, pipeMax); aRenderer.setRenderBoundsFromBlock(aBlock); } else { aBlock.setBlockBounds(pipeMax, pipeMin, pipeMin, blockMax, pipeMax, pipeMax); aRenderer.setRenderBoundsFromBlock(aBlock); - renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[DOWN.ordinal()], false); - renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[UP.ordinal()], false); - renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[NORTH.ordinal()], false); - renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[SOUTH.ordinal()], false); + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[SIDE_DOWN], false); + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[SIDE_UP], false); + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[SIDE_NORTH], false); + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[SIDE_SOUTH], false); } - renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[EAST.ordinal()], false); + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[SIDE_EAST], false); if ((aConnections & CONNECTED_DOWN) == 0) { aBlock.setBlockBounds(pipeMin, pipeMin, pipeMin, pipeMax, pipeMax, pipeMax); aRenderer.setRenderBoundsFromBlock(aBlock); } else { aBlock.setBlockBounds(pipeMin, blockMin, pipeMin, pipeMax, pipeMin, pipeMax); aRenderer.setRenderBoundsFromBlock(aBlock); - renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[NORTH.ordinal()], false); - renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[SOUTH.ordinal()], false); - renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[WEST.ordinal()], false); - renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[EAST.ordinal()], false); + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[SIDE_NORTH], false); + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[SIDE_SOUTH], false); + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[SIDE_WEST], false); + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[SIDE_EAST], false); } - renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[DOWN.ordinal()], false); + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[SIDE_DOWN], false); if ((aConnections & CONNECTED_UP) == 0) { aBlock.setBlockBounds(pipeMin, pipeMin, pipeMin, pipeMax, pipeMax, pipeMax); aRenderer.setRenderBoundsFromBlock(aBlock); } else { aBlock.setBlockBounds(pipeMin, pipeMax, pipeMin, pipeMax, blockMax, pipeMax); aRenderer.setRenderBoundsFromBlock(aBlock); - renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[NORTH.ordinal()], false); - renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[SOUTH.ordinal()], false); - renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[WEST.ordinal()], false); - renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[EAST.ordinal()], false); + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[SIDE_NORTH], false); + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[SIDE_SOUTH], false); + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[SIDE_WEST], false); + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[SIDE_EAST], false); } - renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[UP.ordinal()], false); + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[SIDE_UP], false); if ((aConnections & CONNECTED_NORTH) == 0) { aBlock.setBlockBounds(pipeMin, pipeMin, pipeMin, pipeMax, pipeMax, pipeMax); aRenderer.setRenderBoundsFromBlock(aBlock); } else { aBlock.setBlockBounds(pipeMin, pipeMin, blockMin, pipeMax, pipeMax, pipeMin); aRenderer.setRenderBoundsFromBlock(aBlock); - renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[DOWN.ordinal()], false); - renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[UP.ordinal()], false); - renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[WEST.ordinal()], false); - renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[EAST.ordinal()], false); + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[SIDE_DOWN], false); + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[SIDE_UP], false); + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[SIDE_WEST], false); + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[SIDE_EAST], false); } - renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[NORTH.ordinal()], false); + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[SIDE_NORTH], false); if ((aConnections & CONNECTED_SOUTH) == 0) { aBlock.setBlockBounds(pipeMin, pipeMin, pipeMin, pipeMax, pipeMax, pipeMax); aRenderer.setRenderBoundsFromBlock(aBlock); } else { aBlock.setBlockBounds(pipeMin, pipeMin, pipeMax, pipeMax, pipeMax, blockMax); aRenderer.setRenderBoundsFromBlock(aBlock); - renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[DOWN.ordinal()], false); - renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[UP.ordinal()], false); - renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[WEST.ordinal()], false); - renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[EAST.ordinal()], false); + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[SIDE_DOWN], false); + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[SIDE_UP], false); + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[SIDE_WEST], false); + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[SIDE_EAST], false); } - renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[SOUTH.ordinal()], false); + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[SIDE_SOUTH], false); } } // Render covers on pipes - if (tIsCovered[DOWN.ordinal()]) { + if (tIsCovered[SIDE_DOWN]) { aBlock.setBlockBounds(blockMin, blockMin, blockMin, blockMax, coverInnerMin, blockMax); aRenderer.setRenderBoundsFromBlock(aBlock); - if (!tIsCovered[NORTH.ordinal()]) { - renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[DOWN.ordinal()], false); + if (!tIsCovered[SIDE_NORTH]) { + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[SIDE_DOWN], false); } - if (!tIsCovered[SOUTH.ordinal()]) { - renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[DOWN.ordinal()], false); + if (!tIsCovered[SIDE_SOUTH]) { + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[SIDE_DOWN], false); } - if (!tIsCovered[WEST.ordinal()]) { - renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[DOWN.ordinal()], false); + if (!tIsCovered[SIDE_WEST]) { + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[SIDE_DOWN], false); } - if (!tIsCovered[EAST.ordinal()]) { - renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[DOWN.ordinal()], false); + if (!tIsCovered[SIDE_EAST]) { + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[SIDE_DOWN], false); } - renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[DOWN.ordinal()], false); + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[SIDE_DOWN], false); if ((aConnections & CONNECTED_DOWN) != 0) { // Split outer face to leave hole for pipe // Lower panel aRenderer.setRenderBounds(blockMin, blockMin, blockMin, blockMax, blockMin, pipeMin); - renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[DOWN.ordinal()], false); + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[SIDE_DOWN], false); // Upper panel aRenderer.setRenderBounds(blockMin, blockMin, pipeMax, blockMax, blockMin, blockMax); - renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[DOWN.ordinal()], false); + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[SIDE_DOWN], false); // Middle left panel aRenderer.setRenderBounds(blockMin, blockMin, pipeMin, pipeMin, blockMin, pipeMax); - renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[DOWN.ordinal()], false); + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[SIDE_DOWN], false); // Middle right panel aRenderer.setRenderBounds(pipeMax, blockMin, pipeMin, blockMax, blockMin, pipeMax); } - renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[DOWN.ordinal()], false); + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[SIDE_DOWN], false); } - if (tIsCovered[UP.ordinal()]) { + if (tIsCovered[SIDE_UP]) { aBlock.setBlockBounds(blockMin, coverInnerMax, blockMin, blockMax, blockMax, blockMax); aRenderer.setRenderBoundsFromBlock(aBlock); - if (!tIsCovered[NORTH.ordinal()]) { - renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[UP.ordinal()], false); + if (!tIsCovered[SIDE_NORTH]) { + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[SIDE_UP], false); } - if (!tIsCovered[SOUTH.ordinal()]) { - renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[UP.ordinal()], false); + if (!tIsCovered[SIDE_SOUTH]) { + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[SIDE_UP], false); } - if (!tIsCovered[WEST.ordinal()]) { - renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[UP.ordinal()], false); + if (!tIsCovered[SIDE_WEST]) { + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[SIDE_UP], false); } - if (!tIsCovered[EAST.ordinal()]) { - renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[UP.ordinal()], false); + if (!tIsCovered[SIDE_EAST]) { + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[SIDE_UP], false); } - renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[UP.ordinal()], false); + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[SIDE_UP], false); if ((aConnections & CONNECTED_UP) != 0) { // Split outer face to leave hole for pipe // Lower panel aRenderer.setRenderBounds(blockMin, blockMax, blockMin, blockMax, blockMax, pipeMin); - renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[UP.ordinal()], false); + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[SIDE_UP], false); // Upper panel aRenderer.setRenderBounds(blockMin, blockMax, pipeMax, blockMax, blockMax, blockMax); - renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[UP.ordinal()], false); + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[SIDE_UP], false); // Middle left panel aRenderer.setRenderBounds(blockMin, blockMax, pipeMin, pipeMin, blockMax, pipeMax); - renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[UP.ordinal()], false); + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[SIDE_UP], false); // Middle right panel aRenderer.setRenderBounds(pipeMax, blockMax, pipeMin, blockMax, blockMax, pipeMax); } - renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[UP.ordinal()], false); + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[SIDE_UP], false); } - if (tIsCovered[NORTH.ordinal()]) { + if (tIsCovered[SIDE_NORTH]) { aBlock.setBlockBounds(blockMin, blockMin, blockMin, blockMax, blockMax, coverInnerMin); aRenderer.setRenderBoundsFromBlock(aBlock); - if (!tIsCovered[DOWN.ordinal()]) { - renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[NORTH.ordinal()], false); + if (!tIsCovered[SIDE_DOWN]) { + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[SIDE_NORTH], false); } - if (!tIsCovered[UP.ordinal()]) { - renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[NORTH.ordinal()], false); + if (!tIsCovered[SIDE_UP]) { + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[SIDE_NORTH], false); } - if (!tIsCovered[WEST.ordinal()]) { - renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[NORTH.ordinal()], false); + if (!tIsCovered[SIDE_WEST]) { + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[SIDE_NORTH], false); } - if (!tIsCovered[EAST.ordinal()]) { - renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[NORTH.ordinal()], false); + if (!tIsCovered[SIDE_EAST]) { + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[SIDE_NORTH], false); } - renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[NORTH.ordinal()], false); + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[SIDE_NORTH], false); if ((aConnections & CONNECTED_NORTH) != 0) { // Split outer face to leave hole for pipe // Lower panel aRenderer.setRenderBounds(blockMin, blockMin, blockMin, blockMax, pipeMin, blockMin); - renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[NORTH.ordinal()], false); + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[SIDE_NORTH], false); // Upper panel aRenderer.setRenderBounds(blockMin, pipeMax, blockMin, blockMax, blockMax, blockMin); - renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[NORTH.ordinal()], false); + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[SIDE_NORTH], false); // Middle left panel aRenderer.setRenderBounds(blockMin, pipeMin, blockMin, pipeMin, pipeMax, blockMin); - renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[NORTH.ordinal()], false); + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[SIDE_NORTH], false); // Middle right panel aRenderer.setRenderBounds(pipeMax, pipeMin, blockMin, blockMax, pipeMax, blockMin); } - renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[NORTH.ordinal()], false); + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[SIDE_NORTH], false); } - if (tIsCovered[SOUTH.ordinal()]) { + if (tIsCovered[SIDE_SOUTH]) { aBlock.setBlockBounds(blockMin, blockMin, coverInnerMax, blockMax, blockMax, blockMax); aRenderer.setRenderBoundsFromBlock(aBlock); - if (!tIsCovered[DOWN.ordinal()]) { - renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[SOUTH.ordinal()], false); + if (!tIsCovered[SIDE_DOWN]) { + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[SIDE_SOUTH], false); } - if (!tIsCovered[UP.ordinal()]) { - renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[SOUTH.ordinal()], false); + if (!tIsCovered[SIDE_UP]) { + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[SIDE_SOUTH], false); } - if (!tIsCovered[WEST.ordinal()]) { - renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[SOUTH.ordinal()], false); + if (!tIsCovered[SIDE_WEST]) { + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[SIDE_SOUTH], false); } - if (!tIsCovered[EAST.ordinal()]) { - renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[SOUTH.ordinal()], false); + if (!tIsCovered[SIDE_EAST]) { + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[SIDE_SOUTH], false); } - renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[SOUTH.ordinal()], false); + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[SIDE_SOUTH], false); if ((aConnections & CONNECTED_SOUTH) != 0) { // Split outer face to leave hole for pipe // Lower panel aRenderer.setRenderBounds(blockMin, blockMin, blockMax, blockMax, pipeMin, blockMax); - renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[SOUTH.ordinal()], false); + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[SIDE_SOUTH], false); // Upper panel aRenderer.setRenderBounds(blockMin, pipeMax, blockMax, blockMax, blockMax, blockMax); - renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[SOUTH.ordinal()], false); + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[SIDE_SOUTH], false); // Middle left panel aRenderer.setRenderBounds(blockMin, pipeMin, blockMax, pipeMin, pipeMax, blockMax); - renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[SOUTH.ordinal()], false); + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[SIDE_SOUTH], false); // Middle right panel aRenderer.setRenderBounds(pipeMax, pipeMin, blockMax, blockMax, pipeMax, blockMax); } - renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[SOUTH.ordinal()], false); + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[SIDE_SOUTH], false); } - if (tIsCovered[WEST.ordinal()]) { + if (tIsCovered[SIDE_WEST]) { aBlock.setBlockBounds(blockMin, blockMin, blockMin, coverInnerMin, blockMax, blockMax); aRenderer.setRenderBoundsFromBlock(aBlock); - if (!tIsCovered[DOWN.ordinal()]) { - renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[WEST.ordinal()], false); + if (!tIsCovered[SIDE_DOWN]) { + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[SIDE_WEST], false); } - if (!tIsCovered[UP.ordinal()]) { - renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[WEST.ordinal()], false); + if (!tIsCovered[SIDE_UP]) { + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[SIDE_WEST], false); } - if (!tIsCovered[NORTH.ordinal()]) { - renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[WEST.ordinal()], false); + if (!tIsCovered[SIDE_NORTH]) { + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[SIDE_WEST], false); } - if (!tIsCovered[SOUTH.ordinal()]) { - renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[WEST.ordinal()], false); + if (!tIsCovered[SIDE_SOUTH]) { + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[SIDE_WEST], false); } - renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[WEST.ordinal()], false); + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[SIDE_WEST], false); if ((aConnections & CONNECTED_WEST) != 0) { // Split outer face to leave hole for pipe // Lower panel aRenderer.setRenderBounds(blockMin, blockMin, blockMin, blockMin, pipeMin, blockMax); - renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[WEST.ordinal()], false); + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[SIDE_WEST], false); // Upper panel aRenderer.setRenderBounds(blockMin, pipeMax, blockMin, blockMin, blockMax, blockMax); - renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[WEST.ordinal()], false); + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[SIDE_WEST], false); // Middle left panel aRenderer.setRenderBounds(blockMin, pipeMin, blockMin, blockMin, pipeMax, pipeMin); - renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[WEST.ordinal()], false); + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[SIDE_WEST], false); // Middle right panel aRenderer.setRenderBounds(blockMin, pipeMin, pipeMax, blockMin, pipeMax, blockMax); } - renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[WEST.ordinal()], false); + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[SIDE_WEST], false); } - if (tIsCovered[EAST.ordinal()]) { + if (tIsCovered[SIDE_EAST]) { aBlock.setBlockBounds(coverInnerMax, blockMin, blockMin, blockMax, blockMax, blockMax); aRenderer.setRenderBoundsFromBlock(aBlock); - if (!tIsCovered[DOWN.ordinal()]) { - renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[EAST.ordinal()], false); + if (!tIsCovered[SIDE_DOWN]) { + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[SIDE_EAST], false); } - if (!tIsCovered[UP.ordinal()]) { - renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[EAST.ordinal()], false); + if (!tIsCovered[SIDE_UP]) { + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[SIDE_EAST], false); } - if (!tIsCovered[NORTH.ordinal()]) { - renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[EAST.ordinal()], false); + if (!tIsCovered[SIDE_NORTH]) { + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[SIDE_EAST], false); } - if (!tIsCovered[SOUTH.ordinal()]) { - renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[EAST.ordinal()], false); + if (!tIsCovered[SIDE_SOUTH]) { + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[SIDE_EAST], false); } - renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[EAST.ordinal()], false); + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[SIDE_EAST], false); if ((aConnections & CONNECTED_EAST) != 0) { // Split outer face to leave hole for pipe // Lower panel aRenderer.setRenderBounds(blockMax, blockMin, blockMin, blockMax, pipeMin, blockMax); - renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[EAST.ordinal()], false); + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[SIDE_EAST], false); // Upper panel aRenderer.setRenderBounds(blockMax, pipeMax, blockMin, blockMax, blockMax, blockMax); - renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[EAST.ordinal()], false); + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[SIDE_EAST], false); // Middle left panel aRenderer.setRenderBounds(blockMax, pipeMin, blockMin, blockMax, pipeMax, pipeMin); - renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[EAST.ordinal()], false); + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[SIDE_EAST], false); // Middle right panel aRenderer.setRenderBounds(blockMax, pipeMin, pipeMax, blockMax, pipeMax, blockMax); } - renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[EAST.ordinal()], false); + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[SIDE_EAST], false); } aBlock.setBlockBounds(blockMin, blockMin, blockMin, blockMax, blockMax, blockMax); aRenderer.setRenderBoundsFromBlock(aBlock); @@ -469,28 +478,37 @@ public static boolean renderPipeBlock(IBlockAccess aWorld, int aX, int aY, int a @SideOnly(Side.CLIENT) public static void addHitEffects(EffectRenderer effectRenderer, Block block, World world, int x, int y, int z, - int side) { + int ordinalSide) { double rX = x + XSTR.XSTR_INSTANCE.nextDouble() * 0.8 + 0.1; double rY = y + XSTR.XSTR_INSTANCE.nextDouble() * 0.8 + 0.1; double rZ = z + XSTR.XSTR_INSTANCE.nextDouble() * 0.8 + 0.1; - if (side == 0) { + if (ordinalSide == 0) { rY = y - 0.1; - } else if (side == 1) { + } else if (ordinalSide == 1) { rY = y + 1.1; - } else if (side == 2) { + } else if (ordinalSide == 2) { rZ = z - 0.1; - } else if (side == 3) { + } else if (ordinalSide == 3) { rZ = z + 1.1; - } else if (side == 4) { + } else if (ordinalSide == 4) { rX = x - 0.1; - } else if (side == 5) { + } else if (ordinalSide == 5) { rX = x + 1.1; } effectRenderer.addEffect( - (new EntityDiggingFX(world, rX, rY, rZ, 0.0, 0.0, 0.0, block, block.getDamageValue(world, x, y, z), side)) - .applyColourMultiplier(x, y, z) - .multiplyVelocity(0.2F) - .multipleParticleScaleBy(0.6F)); + (new EntityDiggingFX( + world, + rX, + rY, + rZ, + 0.0, + 0.0, + 0.0, + block, + block.getDamageValue(world, x, y, z), + ordinalSide)).applyColourMultiplier(x, y, z) + .multiplyVelocity(0.2F) + .multipleParticleScaleBy(0.6F)); } @SideOnly(Side.CLIENT) @@ -537,7 +555,7 @@ public void renderInventoryBlock(Block aBlock, int aMeta, int aModelID, RenderBl 0, 0, 0, - tTileEntity.getTexture(aBlock, (byte) DOWN.ordinal()), + tTileEntity.getTexture(aBlock, ForgeDirection.DOWN), true); renderPositiveYFacing( null, @@ -546,7 +564,7 @@ public void renderInventoryBlock(Block aBlock, int aMeta, int aModelID, RenderBl 0, 0, 0, - tTileEntity.getTexture(aBlock, (byte) UP.ordinal()), + tTileEntity.getTexture(aBlock, ForgeDirection.UP), true); renderNegativeZFacing( null, @@ -555,7 +573,7 @@ public void renderInventoryBlock(Block aBlock, int aMeta, int aModelID, RenderBl 0, 0, 0, - tTileEntity.getTexture(aBlock, (byte) NORTH.ordinal()), + tTileEntity.getTexture(aBlock, ForgeDirection.NORTH), true); renderPositiveZFacing( null, @@ -564,7 +582,7 @@ public void renderInventoryBlock(Block aBlock, int aMeta, int aModelID, RenderBl 0, 0, 0, - tTileEntity.getTexture(aBlock, (byte) SOUTH.ordinal()), + tTileEntity.getTexture(aBlock, ForgeDirection.SOUTH), true); renderNegativeXFacing( null, @@ -573,7 +591,7 @@ public void renderInventoryBlock(Block aBlock, int aMeta, int aModelID, RenderBl 0, 0, 0, - tTileEntity.getTexture(aBlock, (byte) WEST.ordinal()), + tTileEntity.getTexture(aBlock, ForgeDirection.WEST), true); renderPositiveXFacing( null, @@ -582,7 +600,7 @@ public void renderInventoryBlock(Block aBlock, int aMeta, int aModelID, RenderBl 0, 0, 0, - tTileEntity.getTexture(aBlock, (byte) EAST.ordinal()), + tTileEntity.getTexture(aBlock, ForgeDirection.EAST), true); } else if (aMeta > 0 && (aMeta < GregTech_API.METATILEENTITIES.length) && aBlock instanceof GT_Block_Machines @@ -611,8 +629,9 @@ private static void renderNormalInventoryMetaTileEntity(Block aBlock, int aMeta, final IGregTechTileEntity iGregTechTileEntity = tMetaTileEntity.getBaseMetaTileEntity(); - if ((iGregTechTileEntity instanceof IPipeRenderedTileEntity)) { - final float tThickness = ((IPipeRenderedTileEntity) iGregTechTileEntity).getThickNess(); + if ((iGregTechTileEntity instanceof IPipeRenderedTileEntity renderedPipe) + && (tMetaTileEntity instanceof MetaPipeEntity pipeEntity)) { + final float tThickness = renderedPipe.getThickNess(); final float pipeMin = (blockMax - tThickness) / 2.0F; final float pipeMax = blockMax - pipeMin; @@ -625,13 +644,7 @@ private static void renderNormalInventoryMetaTileEntity(Block aBlock, int aMeta, 0, 0, 0, - tMetaTileEntity.getTexture( - iGregTechTileEntity, - (byte) DOWN.ordinal(), - (byte) (CONNECTED_WEST | CONNECTED_EAST), - (byte) -1, - false, - false), + pipeEntity.getTexture(iGregTechTileEntity, DOWN, (CONNECTED_WEST | CONNECTED_EAST), -1, false, false), true); renderPositiveYFacing( null, @@ -640,13 +653,7 @@ private static void renderNormalInventoryMetaTileEntity(Block aBlock, int aMeta, 0, 0, 0, - tMetaTileEntity.getTexture( - iGregTechTileEntity, - (byte) UP.ordinal(), - (byte) (CONNECTED_WEST | CONNECTED_EAST), - (byte) -1, - false, - false), + pipeEntity.getTexture(iGregTechTileEntity, UP, (CONNECTED_WEST | CONNECTED_EAST), -1, false, false), true); renderNegativeZFacing( null, @@ -655,13 +662,7 @@ private static void renderNormalInventoryMetaTileEntity(Block aBlock, int aMeta, 0, 0, 0, - tMetaTileEntity.getTexture( - iGregTechTileEntity, - (byte) NORTH.ordinal(), - (byte) (CONNECTED_WEST | CONNECTED_EAST), - (byte) -1, - false, - false), + pipeEntity.getTexture(iGregTechTileEntity, NORTH, (CONNECTED_WEST | CONNECTED_EAST), -1, false, false), true); renderPositiveZFacing( null, @@ -670,13 +671,7 @@ private static void renderNormalInventoryMetaTileEntity(Block aBlock, int aMeta, 0, 0, 0, - tMetaTileEntity.getTexture( - iGregTechTileEntity, - (byte) SOUTH.ordinal(), - (byte) (CONNECTED_WEST | CONNECTED_EAST), - (byte) -1, - false, - false), + pipeEntity.getTexture(iGregTechTileEntity, SOUTH, (CONNECTED_WEST | CONNECTED_EAST), -1, false, false), true); renderNegativeXFacing( null, @@ -685,13 +680,7 @@ private static void renderNormalInventoryMetaTileEntity(Block aBlock, int aMeta, 0, 0, 0, - tMetaTileEntity.getTexture( - iGregTechTileEntity, - (byte) WEST.ordinal(), - (byte) (CONNECTED_WEST | CONNECTED_EAST), - (byte) -1, - true, - false), + pipeEntity.getTexture(iGregTechTileEntity, WEST, (CONNECTED_WEST | CONNECTED_EAST), -1, true, false), true); renderPositiveXFacing( null, @@ -700,13 +689,7 @@ private static void renderNormalInventoryMetaTileEntity(Block aBlock, int aMeta, 0, 0, 0, - tMetaTileEntity.getTexture( - iGregTechTileEntity, - (byte) EAST.ordinal(), - (byte) (CONNECTED_WEST | CONNECTED_EAST), - (byte) -1, - true, - false), + pipeEntity.getTexture(iGregTechTileEntity, EAST, (CONNECTED_WEST | CONNECTED_EAST), -1, true, false), true); } else { renderNegativeYFacing( @@ -716,13 +699,7 @@ private static void renderNormalInventoryMetaTileEntity(Block aBlock, int aMeta, 0, 0, 0, - tMetaTileEntity.getTexture( - iGregTechTileEntity, - (byte) DOWN.ordinal(), - (byte) WEST.ordinal(), - (byte) -1, - true, - false), + tMetaTileEntity.getTexture(iGregTechTileEntity, DOWN, WEST, -1, true, false), true); renderPositiveYFacing( null, @@ -731,13 +708,7 @@ private static void renderNormalInventoryMetaTileEntity(Block aBlock, int aMeta, 0, 0, 0, - tMetaTileEntity.getTexture( - iGregTechTileEntity, - (byte) UP.ordinal(), - (byte) WEST.ordinal(), - (byte) -1, - true, - false), + tMetaTileEntity.getTexture(iGregTechTileEntity, UP, WEST, -1, true, false), true); renderNegativeZFacing( null, @@ -746,13 +717,7 @@ private static void renderNormalInventoryMetaTileEntity(Block aBlock, int aMeta, 0, 0, 0, - tMetaTileEntity.getTexture( - iGregTechTileEntity, - (byte) NORTH.ordinal(), - (byte) WEST.ordinal(), - (byte) -1, - true, - false), + tMetaTileEntity.getTexture(iGregTechTileEntity, NORTH, WEST, -1, true, false), true); renderPositiveZFacing( null, @@ -761,13 +726,7 @@ private static void renderNormalInventoryMetaTileEntity(Block aBlock, int aMeta, 0, 0, 0, - tMetaTileEntity.getTexture( - iGregTechTileEntity, - (byte) SOUTH.ordinal(), - (byte) WEST.ordinal(), - (byte) -1, - true, - false), + tMetaTileEntity.getTexture(iGregTechTileEntity, SOUTH, WEST, -1, true, false), true); renderNegativeXFacing( null, @@ -776,13 +735,7 @@ private static void renderNormalInventoryMetaTileEntity(Block aBlock, int aMeta, 0, 0, 0, - tMetaTileEntity.getTexture( - iGregTechTileEntity, - (byte) WEST.ordinal(), - (byte) WEST.ordinal(), - (byte) -1, - true, - false), + tMetaTileEntity.getTexture(iGregTechTileEntity, WEST, WEST, -1, true, false), true); renderPositiveXFacing( null, @@ -791,13 +744,7 @@ private static void renderNormalInventoryMetaTileEntity(Block aBlock, int aMeta, 0, 0, 0, - tMetaTileEntity.getTexture( - iGregTechTileEntity, - (byte) EAST.ordinal(), - (byte) WEST.ordinal(), - (byte) -1, - true, - false), + tMetaTileEntity.getTexture(iGregTechTileEntity, EAST, WEST, -1, true, false), true); } } @@ -810,7 +757,7 @@ public static void renderNegativeYFacing(IBlockAccess aWorld, RenderBlocks aRend .setBrightness(aBlock.getMixedBrightnessForBlock(aWorld, aX, aFullBlock ? aY - 1 : aY, aZ)); } if (aIcon == null) return; - for (ITexture iTexture : aIcon) { + for (final ITexture iTexture : aIcon) { if (iTexture != null) { iTexture.renderYNeg(aRenderer, aBlock, aX, aY, aZ); } @@ -825,7 +772,7 @@ public static void renderPositiveYFacing(IBlockAccess aWorld, RenderBlocks aRend .setBrightness(aBlock.getMixedBrightnessForBlock(aWorld, aX, aFullBlock ? aY + 1 : aY, aZ)); } if (aIcon == null) return; - for (ITexture iTexture : aIcon) { + for (final ITexture iTexture : aIcon) { if (iTexture != null) { iTexture.renderYPos(aRenderer, aBlock, aX, aY, aZ); } @@ -840,7 +787,7 @@ public static void renderNegativeZFacing(IBlockAccess aWorld, RenderBlocks aRend .setBrightness(aBlock.getMixedBrightnessForBlock(aWorld, aX, aY, aFullBlock ? aZ - 1 : aZ)); } if (aIcon == null) return; - for (ITexture iTexture : aIcon) { + for (final ITexture iTexture : aIcon) { if (iTexture != null) { iTexture.renderZNeg(aRenderer, aBlock, aX, aY, aZ); } @@ -855,7 +802,7 @@ public static void renderPositiveZFacing(IBlockAccess aWorld, RenderBlocks aRend .setBrightness(aBlock.getMixedBrightnessForBlock(aWorld, aX, aY, aFullBlock ? aZ + 1 : aZ)); } if (aIcon == null) return; - for (ITexture iTexture : aIcon) { + for (final ITexture iTexture : aIcon) { if (iTexture != null) { iTexture.renderZPos(aRenderer, aBlock, aX, aY, aZ); } @@ -870,7 +817,7 @@ public static void renderNegativeXFacing(IBlockAccess aWorld, RenderBlocks aRend .setBrightness(aBlock.getMixedBrightnessForBlock(aWorld, aFullBlock ? aX - 1 : aX, aY, aZ)); } if (aIcon == null) return; - for (ITexture iTexture : aIcon) { + for (final ITexture iTexture : aIcon) { if (iTexture != null) { iTexture.renderXNeg(aRenderer, aBlock, aX, aY, aZ); } @@ -885,7 +832,7 @@ public static void renderPositiveXFacing(IBlockAccess aWorld, RenderBlocks aRend .setBrightness(aBlock.getMixedBrightnessForBlock(aWorld, aFullBlock ? aX + 1 : aX, aY, aZ)); } if (aIcon == null) return; - for (ITexture iTexture : aIcon) { + for (final ITexture iTexture : aIcon) { if (iTexture != null) { iTexture.renderXPos(aRenderer, aBlock, aX, aY, aZ); } diff --git a/src/main/java/gregtech/common/render/IRenderedBlock.java b/src/main/java/gregtech/common/render/IRenderedBlock.java index 0f3a472e53e..16268de750e 100644 --- a/src/main/java/gregtech/common/render/IRenderedBlock.java +++ b/src/main/java/gregtech/common/render/IRenderedBlock.java @@ -4,6 +4,7 @@ import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.item.ItemStack; import net.minecraft.world.IBlockAccess; +import net.minecraftforge.common.util.ForgeDirection; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -14,10 +15,10 @@ public interface IRenderedBlock { /** @return the Textures to be rendered */ @SideOnly(Side.CLIENT) - ITexture[] getTexture(Block aBlock, byte aSide, int aRenderPass, boolean[] aShouldSideBeRendered); + ITexture[] getTexture(Block aBlock, ForgeDirection side, int aRenderPass, boolean[] aShouldSideBeRendered); @SideOnly(Side.CLIENT) - ITexture[] getTexture(Block aBlock, byte aSide, boolean isActive, int aRenderPass); + ITexture[] getTexture(Block aBlock, ForgeDirection side, boolean isActive, int aRenderPass); /** gets the Amount of Render Passes for this TileEntity or similar Handler. Only gets called once per Rendering. */ @SideOnly(Side.CLIENT) @@ -57,12 +58,13 @@ class ErrorRenderer implements IRenderedBlockSideCheck, IRenderedBlock { public ITexture[] mErrorTexture = Textures.BlockIcons.ERROR_RENDERING; @Override - public ITexture[] getTexture(Block aBlock, byte aSide, int aRenderPass, boolean[] aShouldSideBeRendered) { + public ITexture[] getTexture(Block aBlock, ForgeDirection side, int aRenderPass, + boolean[] aShouldSideBeRendered) { return mErrorTexture; } @Override - public ITexture[] getTexture(Block aBlock, byte aSide, boolean isActive, int aRenderPass) { + public ITexture[] getTexture(Block aBlock, ForgeDirection side, boolean isActive, int aRenderPass) { return mErrorTexture; } @@ -83,7 +85,7 @@ public boolean setBlockBounds(Block aBlock, int aRenderPass) { } @Override - public boolean renderFullBlockSide(Block aBlock, RenderBlocks aRenderer, byte aSide) { + public boolean renderFullBlockSide(Block aBlock, RenderBlocks aRenderer, ForgeDirection side) { return true; } diff --git a/src/main/java/gregtech/common/render/IRenderedBlockSideCheck.java b/src/main/java/gregtech/common/render/IRenderedBlockSideCheck.java index 1d109216de9..8feb69b2f5f 100644 --- a/src/main/java/gregtech/common/render/IRenderedBlockSideCheck.java +++ b/src/main/java/gregtech/common/render/IRenderedBlockSideCheck.java @@ -2,6 +2,7 @@ import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; +import net.minecraftforge.common.util.ForgeDirection; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -10,5 +11,5 @@ public interface IRenderedBlockSideCheck { /** returning false stops all the other Rendering from happening on that Side. */ @SideOnly(Side.CLIENT) - boolean renderFullBlockSide(Block aBlock, RenderBlocks aRenderer, byte aSide); + boolean renderFullBlockSide(Block aBlock, RenderBlocks aRenderer, ForgeDirection side); } diff --git a/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_Filter.java b/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_Filter.java index c6c73cb02fd..a5b495d73dd 100644 --- a/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_Filter.java +++ b/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_Filter.java @@ -5,6 +5,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.ForgeDirection; import com.gtnewhorizons.modularui.api.screen.ModularWindow; import com.gtnewhorizons.modularui.api.screen.UIBuildContext; @@ -87,8 +88,9 @@ public void loadNBTData(NBTTagCompound aNBT) { } @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - if (!super.allowPutStack(aBaseMetaTileEntity, aIndex, aSide, aStack)) { + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + if (!super.allowPutStack(aBaseMetaTileEntity, aIndex, side, aStack)) { return false; } if (this.bInvertFilter) { @@ -110,8 +112,14 @@ protected void handleRedstoneOutput(IGregTechTileEntity aBaseMetaTileEntity) { if (mInventory[i] == null) ++emptySlots; } if (!bInvert) emptySlots = 9 - emptySlots; - for (byte b = 0; b < 6; b++) aBaseMetaTileEntity.setInternalOutputRedstoneSignal(b, (byte) emptySlots); - } else for (byte b = 0; b < 6; b++) aBaseMetaTileEntity.setInternalOutputRedstoneSignal(b, (byte) 0); + for (final ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + aBaseMetaTileEntity.setInternalOutputRedstoneSignal(side, (byte) emptySlots); + } + } else { + for (final ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + aBaseMetaTileEntity.setInternalOutputRedstoneSignal(side, (byte) 0); + } + } } @Override diff --git a/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_ItemDistributor.java b/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_ItemDistributor.java index 7b2978d7011..1f4117acc92 100644 --- a/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_ItemDistributor.java +++ b/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_ItemDistributor.java @@ -7,6 +7,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.util.ForgeDirection; import com.gtnewhorizons.modularui.api.screen.ModularWindow; import com.gtnewhorizons.modularui.api.screen.UIBuildContext; @@ -25,7 +26,8 @@ public class GT_MetaTileEntity_ItemDistributor extends GT_MetaTileEntity_Buffer implements IAddUIWidgets { private byte[] itemsPerSide = new byte[6]; - private byte currentSide = 0, currentSideItemCount = 0; + private ForgeDirection currentSide = ForgeDirection.DOWN; + private byte currentSideItemCount = 0; public GT_MetaTileEntity_ItemDistributor(int aID, String aName, String aNameRegional, int aTier) { super( @@ -74,17 +76,18 @@ public ITexture getOverlayIcon() { } @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return aSide == aBaseMetaTileEntity.getFrontFacing(); + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return side == aBaseMetaTileEntity.getFrontFacing(); } @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, - boolean aActive, boolean aRedstone) { - if (aSide == aFacing) { - return mTextures[0][aColorIndex + 1]; + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection aFacing, + int colorIndex, boolean aActive, boolean redstoneLevel) { + if (side == aFacing) { + return mTextures[0][colorIndex + 1]; } else { - return mTextures[1][aColorIndex + 1]; + return mTextures[1][colorIndex + 1]; } } @@ -100,13 +103,13 @@ public ITexture[][][] getTextureSet(ITexture[] aTextures) { } @Override - public boolean isInputFacing(byte aSide) { - return getBaseMetaTileEntity().getFrontFacing() == aSide || itemsPerSide[aSide] == 0; + public boolean isInputFacing(ForgeDirection side) { + return getBaseMetaTileEntity().getFrontFacing() == side || itemsPerSide[side.ordinal()] == 0; } @Override - public boolean isOutputFacing(byte aSide) { - return getBaseMetaTileEntity().getFrontFacing() != aSide && itemsPerSide[aSide] > 0; + public boolean isOutputFacing(ForgeDirection side) { + return getBaseMetaTileEntity().getFrontFacing() != side && itemsPerSide[side.ordinal()] > 0; } @Override @@ -121,18 +124,20 @@ public void loadNBTData(NBTTagCompound aNBT) { if (itemsPerSide.length != 6) { itemsPerSide = new byte[6]; } - currentSide = aNBT.getByte("mCurrentSide"); + currentSide = ForgeDirection.getOrientation(aNBT.getByte("mCurrentSide")); currentSideItemCount = aNBT.getByte("mCurrentSideItemCount"); } @Override protected void moveItems(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { + int currentSideOrdinal = currentSide.ordinal(); fillStacksIntoFirstSlots(); int movedItems; TileEntity adjacentTileEntity = aBaseMetaTileEntity.getTileEntityAtSide(currentSide); int inspectedSides = 0; - while (itemsPerSide[currentSide] == 0) { - currentSide = (byte) ((currentSide + 1) % 6); + while (itemsPerSide[currentSideOrdinal] == 0) { + currentSideOrdinal = ((currentSideOrdinal + 1) % 6); + currentSide = ForgeDirection.getOrientation(currentSideOrdinal); currentSideItemCount = 0; adjacentTileEntity = aBaseMetaTileEntity.getTileEntityAtSide(currentSide); inspectedSides += 1; @@ -144,16 +149,17 @@ protected void moveItems(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { aBaseMetaTileEntity, adjacentTileEntity, currentSide, - GT_Utility.getOppositeSide(currentSide), + currentSide.getOpposite(), null, false, (byte) 64, (byte) 1, - (byte) (itemsPerSide[currentSide] - currentSideItemCount), + (byte) (itemsPerSide[currentSideOrdinal] - currentSideItemCount), (byte) 1); currentSideItemCount += movedItems; - if (currentSideItemCount >= itemsPerSide[currentSide]) { - currentSide = (byte) ((currentSide + 1) % 6); + if (currentSideItemCount >= itemsPerSide[currentSideOrdinal]) { + currentSideOrdinal = ((currentSideOrdinal + 1) % 6); + currentSide = ForgeDirection.getOrientation(currentSideOrdinal); currentSideItemCount = 0; } if (movedItems > 0 || aBaseMetaTileEntity.hasInventoryBeenModified()) { @@ -163,18 +169,19 @@ protected void moveItems(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { } @Override - public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + public void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { + final int ordinalSide = side.ordinal(); // Adjust items per side by 1 or -1, constrained to the cyclic interval [0, 127] - itemsPerSide[aSide] += aPlayer.isSneaking() ? -1 : 1; - itemsPerSide[aSide] = (byte) ((itemsPerSide[aSide] + 128) % 128); - GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("211", "Items per side: ") + itemsPerSide[aSide]); + itemsPerSide[ordinalSide] += aPlayer.isSneaking() ? -1 : 1; + itemsPerSide[ordinalSide] = (byte) ((itemsPerSide[ordinalSide] + 128) % 128); + GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("211", "Items per side: ") + itemsPerSide[ordinalSide]); } @Override public void saveNBTData(NBTTagCompound aNBT) { super.saveNBTData(aNBT); aNBT.setByteArray("mItemsPerSide", itemsPerSide); - aNBT.setByte("mCurrentSide", currentSide); + aNBT.setByte("mCurrentSide", (byte) currentSide.ordinal()); aNBT.setByte("mCurrentSideItemCount", currentSideItemCount); } diff --git a/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_Regulator.java b/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_Regulator.java index 9b0824aed1d..3fa296f9a2d 100644 --- a/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_Regulator.java +++ b/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_Regulator.java @@ -8,6 +8,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.ForgeDirection; import com.gtnewhorizons.modularui.api.screen.ModularWindow; import com.gtnewhorizons.modularui.api.screen.UIBuildContext; @@ -106,7 +107,7 @@ public void loadNBTData(NBTTagCompound aNBT) { } @Override - public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + public void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { // Regulation per Screwdriver is overridden by GUI regulation. } @@ -134,8 +135,9 @@ public void moveItems(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { } @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return super.allowPutStack(aBaseMetaTileEntity, aIndex, aSide, aStack) && aIndex >= 0 + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return super.allowPutStack(aBaseMetaTileEntity, aIndex, side, aStack) && aIndex >= 0 && aIndex <= 8 && GT_Utility.areStacksEqual(aStack, this.mInventory[(aIndex + 9)]); } diff --git a/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler.java b/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler.java index fbcc8f62ce2..325728ba984 100644 --- a/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler.java +++ b/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler.java @@ -70,11 +70,16 @@ public GT_MetaTileEntity_Boiler(String aName, int aTier, String[] aDescription, } @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, - boolean aActive, boolean aRedstone) { - ITexture[] tmp = mTextures[aSide >= 2 ? aSide != aFacing ? 2 : ((byte) (aActive ? 4 : 3)) : aSide][aColorIndex - + 1]; - if (aSide != aFacing && tmp.length == 2) { + public ITexture[] getTexture(IGregTechTileEntity baseMetaTileEntity, ForgeDirection sideDirection, + ForgeDirection facingDirection, int colorIndex, boolean active, boolean redstoneLevel) { + ITexture[] tmp; + if (sideDirection.offsetY == 0) { + if (sideDirection != facingDirection) tmp = mTextures[2][colorIndex + 1]; + else tmp = mTextures[(byte) (active ? 4 : 3)][colorIndex + 1]; + } else { + tmp = mTextures[sideDirection.ordinal()][colorIndex + 1]; + } + if (sideDirection != facingDirection && tmp.length == 2) { tmp = new ITexture[] { tmp[0] }; } return tmp; @@ -86,23 +91,8 @@ public boolean isElectric() { } @Override - public boolean isPneumatic() { - return false; - } - - @Override - public boolean isSteampowered() { - return false; - } - - @Override - public boolean isSimpleMachine() { - return false; - } - - @Override - public boolean isFacingValid(byte aFacing) { - return aFacing > 1; + public boolean isFacingValid(ForgeDirection facingDirection) { + return facingDirection.offsetY == 0; } @Override @@ -197,7 +187,7 @@ public boolean isDrainableStackSeparate() { } @Override - public boolean allowCoverOnSide(byte aSide, GT_ItemStack aCover) { + public boolean allowCoverOnSide(ForgeDirection side, GT_ItemStack aCover) { return GregTech_API.getCoverBehaviorNew(aCover.toStack()) .isSimpleCover(); } @@ -324,26 +314,17 @@ protected void onDangerousWaterLack(IGregTechTileEntity tile, long ignoredTicks) * Pushes Steam to a Side of this Boiler * * @param aBaseMetaTileEntity The tile-entity instance of this Boiler - * @param aSide The ordinal direction of the side to push Steam to + * @param side The direction of the side to push Steam to */ - protected final void pushSteamToSide(IGregTechTileEntity aBaseMetaTileEntity, int aSide) { + protected final void pushSteamToSide(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side) { if (mSteam == null || mSteam.amount == 0) return; - IFluidHandler tTileEntity = aBaseMetaTileEntity.getITankContainerAtSide((byte) aSide); + final IFluidHandler tTileEntity = aBaseMetaTileEntity.getITankContainerAtSide(side); if (tTileEntity == null) return; - FluidStack tDrained = aBaseMetaTileEntity - .drain(ForgeDirection.getOrientation(aSide), Math.max(1, this.mSteam.amount / 2), false); + final FluidStack tDrained = aBaseMetaTileEntity.drain(side, Math.max(1, this.mSteam.amount / 2), false); if (tDrained == null) return; - int tFilledAmount = tTileEntity.fill( - ForgeDirection.getOrientation(aSide) - .getOpposite(), - tDrained, - false); + final int tFilledAmount = tTileEntity.fill(side.getOpposite(), tDrained, false); if (tFilledAmount <= 0) return; - tTileEntity.fill( - ForgeDirection.getOrientation(aSide) - .getOpposite(), - aBaseMetaTileEntity.drain(ForgeDirection.getOrientation(aSide), tFilledAmount, true), - true); + tTileEntity.fill(side.getOpposite(), aBaseMetaTileEntity.drain(side, tFilledAmount, true), true); } /** @@ -353,9 +334,10 @@ protected final void pushSteamToSide(IGregTechTileEntity aBaseMetaTileEntity, in */ protected void pushSteamToInventories(IGregTechTileEntity aBaseMetaTileEntity) { if (mSteam == null || mSteam.amount == 0) return; - for (int i = 1; (this.mSteam != null) && (i < 6); i++) { - if (i == aBaseMetaTileEntity.getFrontFacing()) continue; - pushSteamToSide(aBaseMetaTileEntity, i); + for (final ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) { + if (direction == aBaseMetaTileEntity.getFrontFacing()) continue; + if (this.mSteam == null) break; + pushSteamToSide(aBaseMetaTileEntity, direction); } } @@ -371,12 +353,14 @@ private void calculateCooldown() { } @Override - public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { return GT_Mod.gregtechproxy.mAllowSmallBoilerAutomation; } @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { return GT_Mod.gregtechproxy.mAllowSmallBoilerAutomation; } diff --git a/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Bronze.java b/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Bronze.java index d375d285d21..c9a67f5d424 100644 --- a/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Bronze.java +++ b/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Bronze.java @@ -100,9 +100,9 @@ public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { public void onRandomDisplayTick(IGregTechTileEntity aBaseMetaTileEntity) { if (aBaseMetaTileEntity.isActive()) { - final byte frontFacing = aBaseMetaTileEntity.getFrontFacing(); + final ForgeDirection frontFacing = aBaseMetaTileEntity.getFrontFacing(); - if (frontFacing > 1 && aBaseMetaTileEntity.getCoverIDAtSide(frontFacing) == 0 + if (frontFacing.offsetY == 0 && aBaseMetaTileEntity.getCoverIDAtSide(frontFacing) == 0 && !aBaseMetaTileEntity.getOpacityAtSide(frontFacing)) { final double oX = aBaseMetaTileEntity.getOffsetX(frontFacing, 1) + 8D / 16D; @@ -115,16 +115,16 @@ public void onRandomDisplayTick(IGregTechTileEntity aBaseMetaTileEntity) { y = oY + XSTR_INSTANCE.nextFloat() * 6D / 16D; - if (frontFacing == ForgeDirection.WEST.ordinal()) { + if (frontFacing == ForgeDirection.WEST) { x = oX - offset; z = oZ + horizontal; - } else if (frontFacing == ForgeDirection.EAST.ordinal()) { + } else if (frontFacing == ForgeDirection.EAST) { x = oX + offset; z = oZ + horizontal; - } else if (frontFacing == ForgeDirection.NORTH.ordinal()) { + } else if (frontFacing == ForgeDirection.NORTH) { x = oX + horizontal; z = oZ - offset; - } else // if (frontFacing == ForgeDirection.SOUTH.ordinal()) + } else // if (frontFacing == ForgeDirection.SOUTH) { x = oX + horizontal; z = oZ + offset; diff --git a/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Lava.java b/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Lava.java index 6ffcd37f286..3a8b94463b7 100644 --- a/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Lava.java +++ b/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Lava.java @@ -86,23 +86,21 @@ public GT_MetaTileEntity_Boiler_Lava(String aName, int aTier, String[] aDescript } @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, - boolean aActive, boolean aRedstone) { - final ForgeDirection sideDirection = ForgeDirection.getOrientation(aSide); - final ForgeDirection facingDirection = ForgeDirection.getOrientation(aFacing); + public ITexture[] getTexture(IGregTechTileEntity baseMetaTileEntity, ForgeDirection sideDirection, + ForgeDirection facingDirection, int colorIndex, boolean active, boolean redstoneLevel) { final ForgeDirection rearDirection = facingDirection.getOpposite(); final ITexture[] tmp; - if (aSide >= 2) { + if (sideDirection.offsetY == 0) { if (sideDirection == facingDirection) { - if (aActive) tmp = mTextures[4][aColorIndex + 1]; - else tmp = mTextures[3][aColorIndex + 1]; + if (active) tmp = mTextures[4][colorIndex + 1]; + else tmp = mTextures[3][colorIndex + 1]; } else if (sideDirection == rearDirection) { - tmp = mTextures[5][aColorIndex + 1]; + tmp = mTextures[5][colorIndex + 1]; } else { - tmp = mTextures[2][aColorIndex + 1]; + tmp = mTextures[2][colorIndex + 1]; } - } else tmp = mTextures[aSide][aColorIndex + 1]; - if (aSide != aFacing && tmp.length == 2) { + } else tmp = mTextures[sideDirection.ordinal()][colorIndex + 1]; + if (sideDirection != facingDirection && tmp.length == 2) { return new ITexture[] { tmp[0] }; } return tmp; @@ -267,9 +265,8 @@ protected void pushSteamToInventories(IGregTechTileEntity aBaseMetaTileEntity) { if (mSteam == null || mSteam.amount == 0) return; pushSteamToSide( aBaseMetaTileEntity, - ForgeDirection.getOrientation(aBaseMetaTileEntity.getFrontFacing()) - .getOpposite() - .ordinal()); + aBaseMetaTileEntity.getFrontFacing() + .getOpposite()); } /** @@ -278,7 +275,7 @@ protected void pushSteamToInventories(IGregTechTileEntity aBaseMetaTileEntity) { * @param aBaseMetaTileEntity The tile-entity instance of this Lava Boiler */ protected void drainLava(IGregTechTileEntity aBaseMetaTileEntity) { - final IFluidHandler upTank = aBaseMetaTileEntity.getITankContainerAtSide((byte) ForgeDirection.UP.ordinal()); + final IFluidHandler upTank = aBaseMetaTileEntity.getITankContainerAtSide(ForgeDirection.UP); if (upTank == null) return; // Simulates drain of maximum lava amount up to 1000L that can fit the internal tank final FluidStack drainableLavaStack = upTank.drain( @@ -321,10 +318,9 @@ private boolean lavaToObsidian() { public void onRandomDisplayTick(IGregTechTileEntity aBaseMetaTileEntity) { if (aBaseMetaTileEntity.isActive()) { - final byte frontFacing = aBaseMetaTileEntity.getFrontFacing(); - final ForgeDirection frontDirection = ForgeDirection.getOrientation(frontFacing); + final ForgeDirection frontFacing = aBaseMetaTileEntity.getFrontFacing(); - if (frontFacing > 1 && aBaseMetaTileEntity.getCoverIDAtSide(frontFacing) == 0 + if (frontFacing.offsetY == 0 && aBaseMetaTileEntity.getCoverIDAtSide(frontFacing) == 0 && !aBaseMetaTileEntity.getOpacityAtSide(frontFacing)) { final double oX = aBaseMetaTileEntity.getOffsetX(frontFacing, 1) + 8D / 16D; @@ -337,7 +333,7 @@ public void onRandomDisplayTick(IGregTechTileEntity aBaseMetaTileEntity) { y = oY + XSTR_INSTANCE.nextFloat() * 6D / 16D; - switch (frontDirection) { + switch (frontFacing) { case WEST -> { x = oX - offset; z = oZ + horizontal; @@ -395,12 +391,14 @@ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { } @Override - public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { return true; } @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { return true; } @@ -408,7 +406,7 @@ public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex public void doSound(byte aIndex, double aX, double aY, double aZ) { if (aIndex != GT_MetaTileEntity_Boiler.SOUND_EVENT_LET_OFF_EXCESS_STEAM) return; - final ForgeDirection rearDirection = ForgeDirection.getOrientation(getBaseMetaTileEntity().getFrontFacing()) + final ForgeDirection rearDirection = getBaseMetaTileEntity().getFrontFacing() .getOpposite(); GT_Utility.doSoundAtClient( SoundResource.RANDOM_FIZZ, @@ -459,8 +457,8 @@ public FluidStack getDisplayedFluid() { } @Override - public FluidTankInfo[] getTankInfo(ForgeDirection aSide) { - return new FluidTankInfo[] { super.getTankInfo(aSide)[0], + public FluidTankInfo[] getTankInfo(ForgeDirection side) { + return new FluidTankInfo[] { super.getTankInfo(side)[0], new FluidTankInfo(this.lavaTank.getFluid(), this.lavaTank.getCapacity()), new FluidTankInfo(getDrainableStack(), getCapacity()) }; } diff --git a/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Solar.java b/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Solar.java index 38c0d6e9e26..3deaf12b6f8 100644 --- a/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Solar.java +++ b/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Solar.java @@ -128,14 +128,14 @@ public ITexture[][][] getTextureSet(ITexture[] aTextures) { } @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, - boolean aActive, boolean aRedstone) { - int i = aColorIndex + 1; - if (aSide >= 2) { - if (aSide != aFacing) return mTextures[2][i]; + public ITexture[] getTexture(IGregTechTileEntity baseMetaTileEntity, ForgeDirection sideDirection, + ForgeDirection facingDirection, int colorIndex, boolean active, boolean redstoneLevel) { + final int i = colorIndex + 1; + if (sideDirection.offsetY == 0) { + if (sideDirection != facingDirection) return mTextures[2][i]; return mTextures[3][i]; } - return mTextures[aSide][i]; + return mTextures[sideDirection.ordinal()][i]; } @Override @@ -224,7 +224,7 @@ protected void updateFuel(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { if ((aTick % 240L != 0L) || (world.isThundering())) { return; } - if (!aBaseMetaTileEntity.getSkyAtSide((byte) ForgeDirection.UP.ordinal())) { + if (!aBaseMetaTileEntity.getSkyAtSide(ForgeDirection.UP)) { return; } boolean weatherClear = !world.isRaining() || aBaseMetaTileEntity.getBiome().rainfall == 0.0F; diff --git a/src/main/java/gregtech/common/tileentities/casings/upgrade/Inventory.java b/src/main/java/gregtech/common/tileentities/casings/upgrade/Inventory.java index c153e6c1c5a..cc62de308cd 100644 --- a/src/main/java/gregtech/common/tileentities/casings/upgrade/Inventory.java +++ b/src/main/java/gregtech/common/tileentities/casings/upgrade/Inventory.java @@ -3,6 +3,7 @@ import java.util.UUID; import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.ForgeDirection; import com.gtnewhorizons.modularui.api.screen.ModularWindow.Builder; import com.gtnewhorizons.modularui.api.screen.UIBuildContext; @@ -79,7 +80,7 @@ private void unregisterInventories() { } @Override - public boolean hasGui(byte aSide) { + public boolean hasGui(ForgeDirection side) { return true; } diff --git a/src/main/java/gregtech/common/tileentities/debug/GT_MetaTileEntity_AdvDebugStructureWriter.java b/src/main/java/gregtech/common/tileentities/debug/GT_MetaTileEntity_AdvDebugStructureWriter.java index deb71f93cfa..f143ec556e1 100644 --- a/src/main/java/gregtech/common/tileentities/debug/GT_MetaTileEntity_AdvDebugStructureWriter.java +++ b/src/main/java/gregtech/common/tileentities/debug/GT_MetaTileEntity_AdvDebugStructureWriter.java @@ -70,19 +70,20 @@ public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { } @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, - boolean aActive, boolean aRedstone) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex + 1], aSide != aFacing - ? TextureFactory.of( - TextureFactory.builder() - .addIcon(Textures.BlockIcons.OVERLAY_TELEPORTER_ACTIVE) - .glow() - .build()) - : TextureFactory.of( - TextureFactory.builder() - .addIcon(Textures.BlockIcons.STRUCTURE_MARK) - .glow() - .build()) }; + public ITexture[] getTexture(IGregTechTileEntity baseMetaTileEntity, ForgeDirection sideDirection, + ForgeDirection facingDirection, int colorIndex, boolean active, boolean redstoneLevel) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[mTier][colorIndex + 1], sideDirection != facingDirection + ? TextureFactory.of( + TextureFactory.builder() + .addIcon(Textures.BlockIcons.OVERLAY_TELEPORTER_ACTIVE) + .glow() + .build()) + : TextureFactory.of( + TextureFactory.builder() + .addIcon(Textures.BlockIcons.STRUCTURE_MARK) + .glow() + .build()) }; } @Override @@ -91,12 +92,14 @@ public ITexture[][][] getTextureSet(ITexture[] aTextures) { } @Override - public boolean allowPutStack(IGregTechTileEntity iGregTechTileEntity, int i, byte b, ItemStack itemStack) { + public boolean allowPutStack(IGregTechTileEntity iGregTechTileEntity, int i, ForgeDirection b, + ItemStack itemStack) { return false; } @Override - public boolean allowPullStack(IGregTechTileEntity iGregTechTileEntity, int i, byte b, ItemStack itemStack) { + public boolean allowPullStack(IGregTechTileEntity iGregTechTileEntity, int i, ForgeDirection b, + ItemStack itemStack) { return false; } @@ -132,8 +135,7 @@ public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) { @Override public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { if (aBaseMetaTileEntity.isServerSide()) { - ExtendedFacing writerFacing = ExtendedFacing - .of(ForgeDirection.getOrientation(aBaseMetaTileEntity.getFrontFacing())); + ExtendedFacing writerFacing = ExtendedFacing.of(aBaseMetaTileEntity.getFrontFacing()); double[] abc = new double[3]; double[] xyz = new double[3]; boundingBox.dim = aBaseMetaTileEntity.getWorld().provider.dimensionId; @@ -163,7 +165,7 @@ public void onRemoval() { } @Override - public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + public void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { IGregTechTileEntity aBaseMetaTileEntity = getBaseMetaTileEntity(); printStructure(aPlayer); aBaseMetaTileEntity.disableWorking(); @@ -173,7 +175,7 @@ public void printStructure(EntityPlayer aPlayer) { IGregTechTileEntity aBaseMetaTileEntity = getBaseMetaTileEntity(); String pseudoJavaCode = StructureUtility.getPseudoJavaCode( aBaseMetaTileEntity.getWorld(), - ExtendedFacing.of(ForgeDirection.getOrientation(aBaseMetaTileEntity.getFrontFacing())), + ExtendedFacing.of(aBaseMetaTileEntity.getFrontFacing()), aBaseMetaTileEntity.getXCoord(), aBaseMetaTileEntity.getYCoord(), aBaseMetaTileEntity.getZCoord(), @@ -199,7 +201,7 @@ public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlaye } @Override - public boolean isFacingValid(byte aFacing) { + public boolean isFacingValid(ForgeDirection facing) { return true; } diff --git a/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_DieselGenerator.java b/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_DieselGenerator.java index e2aea182fb1..df7028c232a 100644 --- a/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_DieselGenerator.java +++ b/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_DieselGenerator.java @@ -54,8 +54,8 @@ public GT_MetaTileEntity_DieselGenerator(String aName, int aTier, String[] aDesc } @Override - public boolean isOutputFacing(byte aSide) { - return aSide == getBaseMetaTileEntity().getFrontFacing(); + public boolean isOutputFacing(ForgeDirection side) { + return side == getBaseMetaTileEntity().getFrontFacing(); } @Override @@ -124,15 +124,13 @@ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { public void onRandomDisplayTick(IGregTechTileEntity aBaseMetaTileEntity) { if (aBaseMetaTileEntity.isActive()) { - final byte topFacing = (byte) ForgeDirection.UP.ordinal(); + if (aBaseMetaTileEntity.getCoverIDAtSide(ForgeDirection.UP) == 0 + && !aBaseMetaTileEntity.getOpacityAtSide(ForgeDirection.UP)) { - if (aBaseMetaTileEntity.getCoverIDAtSide(topFacing) == 0 - && !aBaseMetaTileEntity.getOpacityAtSide(topFacing)) { - - final double x = aBaseMetaTileEntity.getOffsetX(topFacing, 1) + 2D / 16D + final double x = aBaseMetaTileEntity.getOffsetX(ForgeDirection.UP, 1) + 2D / 16D + XSTR_INSTANCE.nextFloat() * 14D / 16D; - final double y = aBaseMetaTileEntity.getOffsetY(topFacing, 1) + 1D / 32D; - final double z = aBaseMetaTileEntity.getOffsetZ(topFacing, 1) + 2D / 16D + final double y = aBaseMetaTileEntity.getOffsetY(ForgeDirection.UP, 1) + 1D / 32D; + final double z = aBaseMetaTileEntity.getOffsetZ(ForgeDirection.UP, 1) + 2D / 16D + XSTR_INSTANCE.nextFloat() * 14D / 16D; new ParticleEventBuilder().setMotion(0D, 0D, 0D) diff --git a/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_GasTurbine.java b/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_GasTurbine.java index 1c8aeebb407..f1f366052cc 100644 --- a/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_GasTurbine.java +++ b/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_GasTurbine.java @@ -2,6 +2,8 @@ import static gregtech.api.enums.Textures.BlockIcons.*; +import net.minecraftforge.common.util.ForgeDirection; + import gregtech.GT_Mod; import gregtech.api.GregTech_API; import gregtech.api.enums.ConfigCategories; @@ -69,8 +71,8 @@ public GT_MetaTileEntity_GasTurbine(String aName, int aTier, String[] aDescripti } @Override - public boolean isOutputFacing(byte aSide) { - return aSide == getBaseMetaTileEntity().getFrontFacing(); + public boolean isOutputFacing(ForgeDirection side) { + return side == getBaseMetaTileEntity().getFrontFacing(); } @Override diff --git a/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_LightningRod.java b/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_LightningRod.java index e72f944ebb0..9809dba278a 100644 --- a/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_LightningRod.java +++ b/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_LightningRod.java @@ -34,15 +34,15 @@ public GT_MetaTileEntity_LightningRod(String aName, int aTier, int aInvSlotCount } @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, - boolean aActive, boolean aRedstone) { - if (aSide != ForgeDirection.UP.ordinal()) { - return new ITexture[] { BlockIcons.MACHINE_CASINGS[mTier][aColorIndex + 1], + public ITexture[] getTexture(IGregTechTileEntity baseMetaTileEntity, ForgeDirection sideDirection, + ForgeDirection facingDirection, int colorIndex, boolean active, boolean redstoneLevel) { + if (sideDirection != ForgeDirection.UP) { + return new ITexture[] { BlockIcons.MACHINE_CASINGS[mTier][colorIndex + 1], BlockIcons.OVERLAYS_ENERGY_OUT_POWER[mTier] }; } - if (!aActive) return new ITexture[] { BlockIcons.MACHINE_CASINGS[mTier][aColorIndex + 1], + if (!active) return new ITexture[] { BlockIcons.MACHINE_CASINGS[mTier][colorIndex + 1], TextureFactory.of(BlockIcons.MACHINE_CASING_FUSION_GLASS) }; - return new ITexture[] { BlockIcons.MACHINE_CASINGS[mTier][aColorIndex + 1], + return new ITexture[] { BlockIcons.MACHINE_CASINGS[mTier][colorIndex + 1], TextureFactory.of(BlockIcons.MACHINE_CASING_FUSION_GLASS_YELLOW), TextureFactory.builder() .addIcon(BlockIcons.MACHINE_CASING_FUSION_GLASS_YELLOW_GLOW) .glow() @@ -110,12 +110,14 @@ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { } @Override - public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { return false; } @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { return false; } @@ -125,12 +127,12 @@ public boolean isSimpleMachine() { } @Override - public boolean isFacingValid(byte aFacing) { - return aFacing == 1; + public boolean isFacingValid(ForgeDirection facing) { + return facing == ForgeDirection.UP; } @Override - public boolean isOutputFacing(byte aSide) { + public boolean isOutputFacing(ForgeDirection side) { return true; } diff --git a/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_MagicEnergyConverter.java b/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_MagicEnergyConverter.java index 17089403c36..07990213be6 100644 --- a/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_MagicEnergyConverter.java +++ b/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_MagicEnergyConverter.java @@ -10,6 +10,8 @@ import static gregtech.api.enums.Textures.BlockIcons.MACHINE_CASING_MAGIC_GLOW; import static gregtech.api.enums.Textures.BlockIcons.OVERLAYS_ENERGY_OUT; +import net.minecraftforge.common.util.ForgeDirection; + import gregtech.api.GregTech_API; import gregtech.api.enums.ConfigCategories; import gregtech.api.interfaces.ITexture; @@ -41,8 +43,8 @@ public GT_MetaTileEntity_MagicEnergyConverter(String aName, int aTier, String[] } @Override - public boolean isOutputFacing(byte aSide) { - return aSide == getBaseMetaTileEntity().getFrontFacing(); + public boolean isOutputFacing(ForgeDirection side) { + return side == getBaseMetaTileEntity().getFrontFacing(); } @Override diff --git a/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_MagicalEnergyAbsorber.java b/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_MagicalEnergyAbsorber.java index b95f79c0f5a..ff3353256d7 100644 --- a/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_MagicalEnergyAbsorber.java +++ b/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_MagicalEnergyAbsorber.java @@ -144,7 +144,7 @@ public void onConfigLoad(GT_Config aConfig) { } @Override - public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + public void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { if (aPlayer.isSneaking()) mMagicalEnergyBB.decreaseTier(); else mMagicalEnergyBB.increaseTier(); GT_Utility.sendChatToPlayer( @@ -338,8 +338,8 @@ public ITexture[] getSidesActive(byte aColor) { } @Override - public boolean isOutputFacing(byte aSide) { - return aSide == getBaseMetaTileEntity().getFrontFacing(); + public boolean isOutputFacing(ForgeDirection side) { + return side == getBaseMetaTileEntity().getFrontFacing(); } @Override @@ -393,9 +393,7 @@ public void onRandomDisplayTick(IGregTechTileEntity aBaseMetaTileEntity) { if (aBaseMetaTileEntity.isActive()) { - final byte topFacing = (byte) ForgeDirection.UP.ordinal(); - - if (isEgg(aBaseMetaTileEntity.getBlockAtSide(topFacing))) { + if (isEgg(aBaseMetaTileEntity.getBlockAtSide(ForgeDirection.UP))) { final double oX = aBaseMetaTileEntity.getXCoord() + 8D / 16D; final double oY = aBaseMetaTileEntity.getYCoord() + 17D / 32D; @@ -443,7 +441,8 @@ public int getEfficiency() { } @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { // Restrict input to disenchantable items or enchanted books return (isDisenchantableItem(aStack) || isEnchantedBook(aStack)); } diff --git a/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_NaquadahReactor.java b/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_NaquadahReactor.java index 7e9fff95aad..c7e41063997 100644 --- a/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_NaquadahReactor.java +++ b/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_NaquadahReactor.java @@ -2,6 +2,8 @@ import static gregtech.api.enums.Textures.BlockIcons.*; +import net.minecraftforge.common.util.ForgeDirection; + import gregtech.api.GregTech_API; import gregtech.api.enums.ConfigCategories; import gregtech.api.interfaces.ITexture; @@ -33,9 +35,9 @@ public GT_MetaTileEntity_NaquadahReactor(String aName, int aTier, String[] aDesc } @Override - public boolean isOutputFacing(byte aSide) { - return (aSide > 1) && (aSide != getBaseMetaTileEntity().getFrontFacing()) - && (aSide != getBaseMetaTileEntity().getBackFacing()); + public boolean isOutputFacing(ForgeDirection side) { + return (side.offsetY == 0) && (side != getBaseMetaTileEntity().getFrontFacing()) + && (side != getBaseMetaTileEntity().getBackFacing()); } @Override diff --git a/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_PlasmaGenerator.java b/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_PlasmaGenerator.java index c1370cce639..00c7f931285 100644 --- a/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_PlasmaGenerator.java +++ b/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_PlasmaGenerator.java @@ -5,6 +5,8 @@ import static gregtech.api.enums.Textures.BlockIcons.MACHINE_CASING_FUSION_GLASS_YELLOW_GLOW; import static gregtech.api.enums.Textures.BlockIcons.OVERLAYS_ENERGY_OUT; +import net.minecraftforge.common.util.ForgeDirection; + import gregtech.api.GregTech_API; import gregtech.api.enums.ConfigCategories; import gregtech.api.interfaces.ITexture; @@ -106,8 +108,8 @@ public ITexture[] getSidesActive(byte aColor) { } @Override - public boolean isOutputFacing(byte aSide) { - return aSide == getBaseMetaTileEntity().getFrontFacing(); + public boolean isOutputFacing(ForgeDirection side) { + return side == getBaseMetaTileEntity().getFrontFacing(); } @Override diff --git a/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_SteamTurbine.java b/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_SteamTurbine.java index a875fd521c2..28962b69a0c 100644 --- a/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_SteamTurbine.java +++ b/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_SteamTurbine.java @@ -2,6 +2,7 @@ import static gregtech.api.enums.Textures.BlockIcons.*; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; import gregtech.api.GregTech_API; @@ -39,8 +40,8 @@ public GT_MetaTileEntity_SteamTurbine(String aName, int aTier, String[] aDescrip } @Override - public boolean isOutputFacing(byte aSide) { - return aSide == getBaseMetaTileEntity().getFrontFacing(); + public boolean isOutputFacing(ForgeDirection side) { + return side == getBaseMetaTileEntity().getFrontFacing(); } @Override diff --git a/src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_InputBus_ME.java b/src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_InputBus_ME.java index 2b78fd5c554..4aa56ae4f40 100644 --- a/src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_InputBus_ME.java +++ b/src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_InputBus_ME.java @@ -127,7 +127,7 @@ public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) { @Override public AECableType getCableConnectionType(ForgeDirection forgeDirection) { - return isOutputFacing((byte) forgeDirection.ordinal()) ? AECableType.SMART : AECableType.NONE; + return isOutputFacing(forgeDirection) ? AECableType.SMART : AECableType.NONE; } @Override @@ -223,17 +223,19 @@ public String[] getInfoData() { } @Override - public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { return false; } @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { return false; } @Override - public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + public void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { setAutoPullItemList(!autoPullItemList); GT_Utility.sendChatToPlayer(aPlayer, "Automatic Item Pull " + autoPullItemList); } @@ -242,13 +244,13 @@ public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, public void updateSlots() {} @Override - public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, byte aSide, float aX, - float aY, float aZ) { + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, ForgeDirection side, + float aX, float aY, float aZ) { if (!(aPlayer instanceof EntityPlayerMP)) - return super.onRightclick(aBaseMetaTileEntity, aPlayer, aSide, aX, aY, aZ); + return super.onRightclick(aBaseMetaTileEntity, aPlayer, side, aX, aY, aZ); ItemStack dataStick = aPlayer.inventory.getCurrentItem(); if (!ItemList.Tool_DataStick.isStackEqual(dataStick, true, true)) - return super.onRightclick(aBaseMetaTileEntity, aPlayer, aSide, aX, aY, aZ); + return super.onRightclick(aBaseMetaTileEntity, aPlayer, side, aX, aY, aZ); if (!dataStick.hasTagCompound() || !"stockingBus".equals(dataStick.stackTagCompound.getString("type"))) return false; diff --git a/src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_OutputBus_ME.java b/src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_OutputBus_ME.java index 22afe4b9fed..0a58dbf1b67 100644 --- a/src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_OutputBus_ME.java +++ b/src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_OutputBus_ME.java @@ -120,7 +120,7 @@ private BaseActionSource getRequest() { @Override public AECableType getCableConnectionType(ForgeDirection forgeDirection) { - return isOutputFacing((byte) forgeDirection.ordinal()) ? AECableType.SMART : AECableType.NONE; + return isOutputFacing(forgeDirection) ? AECableType.SMART : AECableType.NONE; } @Override @@ -129,8 +129,8 @@ public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlaye } @Override - public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { - if (!getBaseMetaTileEntity().getCoverInfoAtSide(aSide) + public void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (!getBaseMetaTileEntity().getCoverInfoAtSide(side) .isGUIClickable()) return; infiniteCache = !infiniteCache; GT_Utility diff --git a/src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_Output_ME.java b/src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_Output_ME.java index 0c65d1bc2e0..241412b423a 100644 --- a/src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_Output_ME.java +++ b/src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_Output_ME.java @@ -126,8 +126,8 @@ private BaseActionSource getRequest() { } @Override - public AECableType getCableConnectionType(ForgeDirection forgeDirection) { - return isOutputFacing((byte) forgeDirection.ordinal()) ? AECableType.SMART : AECableType.NONE; + public AECableType getCableConnectionType(ForgeDirection side) { + return isOutputFacing(side) ? AECableType.SMART : AECableType.NONE; } @Override @@ -149,9 +149,9 @@ public boolean doesFillContainers() { public void updateFluidDisplayItem() {} @Override - public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + public void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { // Don't allow to lock fluid in me fluid hatch - if (!getBaseMetaTileEntity().getCoverInfoAtSide(aSide) + if (!getBaseMetaTileEntity().getCoverInfoAtSide(side) .isGUIClickable()) return; infiniteCache = !infiniteCache; GT_Utility.sendChatToPlayer( diff --git a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Boxinator.java b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Boxinator.java index 02c1897522e..fdadb44a23c 100644 --- a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Boxinator.java +++ b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Boxinator.java @@ -3,6 +3,7 @@ import static gregtech.api.enums.Textures.BlockIcons.*; import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; import gregtech.api.enums.ItemList; import gregtech.api.interfaces.ITexture; @@ -194,9 +195,9 @@ public int checkRecipe() { } @Override - protected boolean allowPutStackValidated(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, + protected boolean allowPutStackValidated(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, ItemStack aStack) { - if (!super.allowPutStackValidated(aBaseMetaTileEntity, aIndex, aSide, aStack)) { + if (!super.allowPutStackValidated(aBaseMetaTileEntity, aIndex, side, aStack)) { return false; } ItemStack tInput1 = getInputAt(1); diff --git a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_CuringOven.java b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_CuringOven.java index 01832d0d963..5408beca32a 100644 --- a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_CuringOven.java +++ b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_CuringOven.java @@ -2,6 +2,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; import com.gtnewhorizons.modularui.api.screen.ModularWindow; @@ -63,9 +64,9 @@ public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { } @Override - protected boolean allowPutStackValidated(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, + protected boolean allowPutStackValidated(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, ItemStack aStack) { - return (super.allowPutStackValidated(aBaseMetaTileEntity, aIndex, aSide, aStack)) + return (super.allowPutStackValidated(aBaseMetaTileEntity, aIndex, side, aStack)) && ItemList.Cell_Empty.isStackEqual(aStack); } diff --git a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_IndustrialApiary.java b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_IndustrialApiary.java index a0e55615592..974036625b9 100644 --- a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_IndustrialApiary.java +++ b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_IndustrialApiary.java @@ -1,6 +1,5 @@ package gregtech.common.tileentities.machines.basic; -import static gregtech.api.enums.GT_Values.ALL_VALID_SIDES; import static gregtech.api.enums.GT_Values.AuthorKuba; import static gregtech.api.enums.GT_Values.V; import static gregtech.api.enums.Textures.BlockIcons.*; @@ -28,6 +27,7 @@ import net.minecraft.util.Vec3; import net.minecraft.world.World; import net.minecraft.world.biome.BiomeGenBase; +import net.minecraftforge.common.util.ForgeDirection; import com.google.common.collect.ImmutableSet; import com.gtnewhorizons.modularui.api.drawable.IDrawable; @@ -183,8 +183,8 @@ public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlaye openGUI(aBaseMetaTileEntity, aPlayer); return true; } - for (byte tSide : ALL_VALID_SIDES) { - if (aBaseMetaTileEntity.getAirAtSide(tSide)) { + for (final ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + if (aBaseMetaTileEntity.getAirAtSide(side)) { openGUI(aBaseMetaTileEntity, aPlayer); return true; } @@ -723,13 +723,13 @@ public IBeekeepingLogic getBeekeepingLogic() { @Override public int getBlockLightValue() { return this.getBaseMetaTileEntity() - .getLightLevelAtSide((byte) 1); + .getLightLevelAtSide(ForgeDirection.UP); } @Override public boolean canBlockSeeTheSky() { return this.getBaseMetaTileEntity() - .getSkyAtSide((byte) 1); + .getSkyAtSide(ForgeDirection.UP); } @Override diff --git a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_MicrowaveEnergyTransmitter.java b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_MicrowaveEnergyTransmitter.java index 3db90597f60..d7ddd84d211 100644 --- a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_MicrowaveEnergyTransmitter.java +++ b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_MicrowaveEnergyTransmitter.java @@ -15,6 +15,7 @@ import net.minecraft.util.EnumChatFormatting; import net.minecraft.world.World; import net.minecraftforge.common.DimensionManager; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; import com.gtnewhorizons.modularui.api.drawable.IDrawable; @@ -116,15 +117,15 @@ public String[] getInfoData() { } @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, - boolean aActive, boolean aRedstone) { - if (aSide == 0) return new ITexture[] { MACHINE_CASINGS[mTier][aColorIndex + 1] }; - if (aActive) return new ITexture[] { MACHINE_CASINGS[mTier][aColorIndex + 1], + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection aFacing, + int colorIndex, boolean aActive, boolean redstoneLevel) { + if (side == ForgeDirection.DOWN) return new ITexture[] { MACHINE_CASINGS[mTier][colorIndex + 1] }; + if (aActive) return new ITexture[] { MACHINE_CASINGS[mTier][colorIndex + 1], TextureFactory.of(OVERLAY_TELEPORTER_ACTIVE), TextureFactory.builder() .addIcon(OVERLAY_TELEPORTER_ACTIVE_GLOW) .glow() .build() }; - return new ITexture[] { MACHINE_CASINGS[mTier][aColorIndex + 1], TextureFactory.of(OVERLAY_TELEPORTER), + return new ITexture[] { MACHINE_CASINGS[mTier][colorIndex + 1], TextureFactory.of(OVERLAY_TELEPORTER), TextureFactory.builder() .addIcon(OVERLAY_TELEPORTER_GLOW) .glow() @@ -251,7 +252,8 @@ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { } energyUse = packetSize + ((V[mTier] * energyUse) / 100); if (getBaseMetaTileEntity().isUniversalEnergyStored(energyUse)) { - if (((IEnergyConnected) tTile).injectEnergyUnits((byte) 6, packetSize, 1) > 0) { + if (((IEnergyConnected) tTile).injectEnergyUnits(ForgeDirection.UNKNOWN, packetSize, 1) + > 0) { getBaseMetaTileEntity().decreaseStoredEnergyUnits(energyUse, false); } } @@ -296,7 +298,7 @@ public boolean isElectric() { } @Override - public boolean isFacingValid(byte aFacing) { + public boolean isFacingValid(ForgeDirection facing) { return true; } @@ -306,12 +308,12 @@ public boolean isEnetInput() { } @Override - public boolean isInputFacing(byte aSide) { + public boolean isInputFacing(ForgeDirection side) { return true; } @Override - public boolean isOutputFacing(byte aSide) { + public boolean isOutputFacing(ForgeDirection side) { 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 8186d716df2..314ffd8d1da 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 @@ -16,6 +16,7 @@ import net.minecraft.util.StatCollector; import net.minecraft.world.ChunkPosition; import net.minecraftforge.common.util.FakePlayer; +import net.minecraftforge.common.util.ForgeDirection; import com.gtnewhorizons.modularui.api.drawable.FallbackableUITexture; import com.gtnewhorizons.modularui.api.drawable.UITexture; @@ -152,9 +153,9 @@ public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) { } @Override - protected boolean allowPutStackValidated(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, + protected boolean allowPutStackValidated(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, ItemStack aStack) { - return super.allowPutStackValidated(aBaseMetaTileEntity, aIndex, aSide, aStack) // + return super.allowPutStackValidated(aBaseMetaTileEntity, aIndex, side, aStack) // && aStack.getItem() == GT_DrillingLogicDelegate.MINING_PIPE_STACK.getItem(); } @@ -169,9 +170,9 @@ public boolean hasFreeSpace() { } @Override - public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { - super.onScrewdriverRightClick(aSide, aPlayer, aX, aY, aZ); - if (aSide != getBaseMetaTileEntity().getFrontFacing() && aSide != mMainFacing) { + public void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { + super.onScrewdriverRightClick(side, aPlayer, aX, aY, aZ); + if (side != getBaseMetaTileEntity().getFrontFacing() && side != mMainFacing) { if (aPlayer.isSneaking()) { if (radiusConfig >= 0) { radiusConfig--; diff --git a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_MonsterRepellent.java b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_MonsterRepellent.java index 7306e89986b..fde78cfa2ea 100644 --- a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_MonsterRepellent.java +++ b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_MonsterRepellent.java @@ -60,15 +60,15 @@ public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { } @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, - boolean aActive, boolean aRedstone) { - if (aSide != ForgeDirection.UP.ordinal()) return new ITexture[] { MACHINE_CASINGS[mTier][aColorIndex + 1] }; - if (aActive) return new ITexture[] { MACHINE_CASINGS[mTier][aColorIndex + 1], + public ITexture[] getTexture(IGregTechTileEntity baseMetaTileEntity, ForgeDirection sideDirection, + ForgeDirection facingDirection, int colorIndex, boolean active, boolean redstoneLevel) { + if (sideDirection != ForgeDirection.UP) return new ITexture[] { MACHINE_CASINGS[mTier][colorIndex + 1] }; + if (active) return new ITexture[] { MACHINE_CASINGS[mTier][colorIndex + 1], TextureFactory.of(OVERLAY_TELEPORTER_ACTIVE), TextureFactory.builder() .addIcon(OVERLAY_TELEPORTER_ACTIVE_GLOW) .glow() .build() }; - return new ITexture[] { MACHINE_CASINGS[mTier][aColorIndex + 1], TextureFactory.of(OVERLAY_TELEPORTER), + return new ITexture[] { MACHINE_CASINGS[mTier][colorIndex + 1], TextureFactory.of(OVERLAY_TELEPORTER), TextureFactory.builder() .addIcon(OVERLAY_TELEPORTER_GLOW) .glow() @@ -118,7 +118,7 @@ public boolean isSimpleMachine() { } @Override - public boolean isFacingValid(byte aFacing) { + public boolean isFacingValid(ForgeDirection facing) { return true; } @@ -128,7 +128,7 @@ public boolean isEnetInput() { } @Override - public boolean isInputFacing(byte aSide) { + public boolean isInputFacing(ForgeDirection side) { return true; } @@ -158,12 +158,14 @@ public long maxAmperesIn() { } @Override - public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { return false; } @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { return false; } diff --git a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_PotionBrewer.java b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_PotionBrewer.java index ad73047507e..2b1399b8f42 100644 --- a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_PotionBrewer.java +++ b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_PotionBrewer.java @@ -4,6 +4,7 @@ import net.minecraft.init.Items; import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; @@ -211,9 +212,9 @@ private int setOutput(String aFluidName) { } @Override - public boolean allowPutStackValidated(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, + public boolean allowPutStackValidated(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, ItemStack aStack) { - return super.allowPutStackValidated(aBaseMetaTileEntity, aIndex, aSide, aStack) + return super.allowPutStackValidated(aBaseMetaTileEntity, aIndex, side, aStack) && getRecipeList().containsInput(aStack); } diff --git a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Pump.java b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Pump.java index db0a8892058..ea67dc2dc39 100644 --- a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Pump.java +++ b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Pump.java @@ -150,8 +150,8 @@ public void setItemNBT(NBTTagCompound aNBT) { } @Override - public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { - super.onScrewdriverRightClick(aSide, aPlayer, aX, aY, aZ); + public void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { + super.onScrewdriverRightClick(side, aPlayer, aX, aY, aZ); int max = getMaxPumpableDistance(); if (aPlayer.isSneaking()) { if (radiusConfig >= 0) { @@ -175,12 +175,12 @@ public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, } @Override - public boolean onSolderingToolRightClick(byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, - float aZ) { - if (super.onSolderingToolRightClick(aSide, aWrenchingSide, aPlayer, aX, aY, aZ)) return true; + public boolean onSolderingToolRightClick(ForgeDirection side, ForgeDirection wrenchingSide, + EntityPlayer entityPlayer, float aX, float aY, float aZ) { + if (super.onSolderingToolRightClick(side, wrenchingSide, entityPlayer, aX, aY, aZ)) return true; mDisallowRetract = !mDisallowRetract; GT_Utility.sendChatToPlayer( - aPlayer, + entityPlayer, StatCollector.translateToLocal( mDisallowRetract ? "GT5U.machines.autoretract.disabled" : "GT5U.machines.autoretract.enabled")); return true; @@ -234,8 +234,8 @@ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { IGregTechTileEntity tTileEntity; for (int i = 1; (i < 21) - && ((tTileEntity = getBaseMetaTileEntity().getIGregTechTileEntityAtSideAndDistance((byte) 0, i)) - != null) + && ((tTileEntity = getBaseMetaTileEntity() + .getIGregTechTileEntityAtSideAndDistance(ForgeDirection.DOWN, i)) != null) && ((tTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_Pump)); i++) { // Apparently someone might stack 21 pumps on top of each other, so let's check for that getBaseMetaTileEntity().setActive(tTileEntity.isActive()); @@ -400,7 +400,7 @@ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { if (this.mFluid != null && (aTick % 20 == 0)) { // auto outputs on top every second or so - IFluidHandler tTank = aBaseMetaTileEntity.getITankContainerAtSide((byte) 1); // 1 is up. + IFluidHandler tTank = aBaseMetaTileEntity.getITankContainerAtSide(ForgeDirection.UP); // 1 is up. if (tTank != null) { FluidStack tDrained = drain(1000, false); if (tDrained != null) { @@ -732,7 +732,7 @@ public boolean isElectric() { } @Override - public boolean isFacingValid(byte aFacing) { + public boolean isFacingValid(ForgeDirection facing) { return true; } @@ -742,12 +742,12 @@ public boolean isEnetInput() { } @Override - public boolean isInputFacing(byte aSide) { + public boolean isInputFacing(ForgeDirection side) { return true; } @Override - public boolean isOutputFacing(byte aSide) { + public boolean isOutputFacing(ForgeDirection side) { return false; } @@ -802,10 +802,10 @@ public int getTankPressure() { } @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, - boolean aActive, boolean aRedstone) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex + 1], - (aSide == 0 || aSide == 1) ? TextureFactory.of(Textures.BlockIcons.OVERLAY_PIPE_OUT) + public ITexture[] getTexture(IGregTechTileEntity baseMetaTileEntity, ForgeDirection sideDirection, + ForgeDirection facingDirection, int colorIndex, boolean active, boolean redstoneLevel) { + return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][colorIndex + 1], + (sideDirection.offsetY != 0) ? TextureFactory.of(Textures.BlockIcons.OVERLAY_PIPE_OUT) : TextureFactory.of(Textures.BlockIcons.OVERLAY_ADV_PUMP) }; } diff --git a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Replicator.java b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Replicator.java index 45abd16d9fd..1d9b6f61e13 100644 --- a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Replicator.java +++ b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Replicator.java @@ -6,6 +6,7 @@ import java.util.NoSuchElementException; import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; import gregtech.api.GregTech_API; @@ -179,9 +180,9 @@ public GT_Recipe.GT_Recipe_Map getRecipeList() { } @Override - protected boolean allowPutStackValidated(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, + protected boolean allowPutStackValidated(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, ItemStack aStack) { - return super.allowPutStackValidated(aBaseMetaTileEntity, aIndex, aSide, aStack) + return super.allowPutStackValidated(aBaseMetaTileEntity, aIndex, side, aStack) && ItemList.Cell_Empty.isStackEqual(aStack); } diff --git a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_RockBreaker.java b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_RockBreaker.java index 2c16cbad2a8..751ab7f57da 100644 --- a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_RockBreaker.java +++ b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_RockBreaker.java @@ -4,6 +4,7 @@ import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; import gregtech.api.enums.Materials; import gregtech.api.enums.OrePrefixes; @@ -107,9 +108,9 @@ public GT_Recipe.GT_Recipe_Map getRecipeList() { } @Override - protected boolean allowPutStackValidated(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, + protected boolean allowPutStackValidated(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, ItemStack aStack) { - return super.allowPutStackValidated(aBaseMetaTileEntity, aIndex, aSide, aStack) + return super.allowPutStackValidated(aBaseMetaTileEntity, aIndex, side, aStack) && getRecipeList().containsInput(aStack); } diff --git a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Scanner.java b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Scanner.java index ef4dc2ec3b4..508b9b07b4d 100644 --- a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Scanner.java +++ b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Scanner.java @@ -12,6 +12,7 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.ForgeDirection; import forestry.api.genetics.AlleleManager; import forestry.api.genetics.IIndividual; @@ -400,9 +401,9 @@ public int getCapacity() { } @Override - protected boolean allowPutStackValidated(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, + protected boolean allowPutStackValidated(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, ItemStack aStack) { - return super.allowPutStackValidated(aBaseMetaTileEntity, aIndex, aSide, aStack) + return super.allowPutStackValidated(aBaseMetaTileEntity, aIndex, side, aStack) && getRecipeList().containsInput(aStack); } diff --git a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Teleporter.java b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Teleporter.java index ffff8801a57..a0d56a683a2 100644 --- a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Teleporter.java +++ b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Teleporter.java @@ -39,6 +39,7 @@ import net.minecraft.util.EnumChatFormatting; import net.minecraft.world.World; import net.minecraftforge.common.DimensionManager; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; import com.gtnewhorizons.modularui.api.drawable.IDrawable; @@ -210,21 +211,21 @@ public String[] getInfoData() { } @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, - boolean aActive, boolean aRedstone) { - if (aSide != this.getBaseMetaTileEntity() + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection aFacing, + int colorIndex, boolean aActive, boolean redstoneLevel) { + if (side != this.getBaseMetaTileEntity() .getFrontFacing()) - return new ITexture[] { MACHINE_CASINGS[mTier][aColorIndex + 1], - TextureFactory.of(OVERLAY_TELEPORTER_SIDES), TextureFactory.builder() + return new ITexture[] { MACHINE_CASINGS[mTier][colorIndex + 1], TextureFactory.of(OVERLAY_TELEPORTER_SIDES), + TextureFactory.builder() .addIcon(OVERLAY_TELEPORTER_SIDES_GLOW) .glow() .build() }; - if (aActive) return new ITexture[] { MACHINE_CASINGS[mTier][aColorIndex + 1], + if (aActive) return new ITexture[] { MACHINE_CASINGS[mTier][colorIndex + 1], TextureFactory.of(OVERLAY_TELEPORTER_ACTIVE), TextureFactory.builder() .addIcon(OVERLAY_TELEPORTER_ACTIVE_GLOW) .glow() .build() }; - return new ITexture[] { MACHINE_CASINGS[mTier][aColorIndex + 1], TextureFactory.of(OVERLAY_TELEPORTER), + return new ITexture[] { MACHINE_CASINGS[mTier][colorIndex + 1], TextureFactory.of(OVERLAY_TELEPORTER), TextureFactory.builder() .addIcon(OVERLAY_TELEPORTER_GLOW) .glow() @@ -314,19 +315,8 @@ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { } super.onPostTick(aBaseMetaTileEntity, aTick); if (getBaseMetaTileEntity().isServerSide()) { - // if (getBaseMetaTileEntity().getTimer() % 100L == 50L) { - // this.hasEgg = checkForEgg(); - // } if ((getBaseMetaTileEntity().isAllowedToWork()) && (getBaseMetaTileEntity().getRedstone())) { if (getBaseMetaTileEntity().decreaseStoredEnergyUnits(sPassiveEnergyDrain, false)) { - // if (hasDimensionalTeleportCapability() && this.mTargetD != - // getBaseMetaTileEntity().getWorld().provider.dimensionId && (hasEgg || - // mFluid.isFluidEqual(Materials.Nitrogen.getPlasma(1)))&& new XSTR().nextInt(10)==0) { - // mFluid.amount--; - // if (mFluid.amount < 1) { - // mFluid = null; - // } - // } int tDistance = distanceCalculation(); if (mInventory[0] != null) { TileEntity tTile = null; @@ -343,8 +333,8 @@ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { GT_Utility.moveOneItemStack( this, tTile, - (byte) 0, - (byte) 0, + ForgeDirection.DOWN, + ForgeDirection.DOWN, null, false, (byte) 64, @@ -377,15 +367,7 @@ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { if (getBaseMetaTileEntity().decreaseStoredEnergyUnits( (long) (Math.pow(tDistance, 1.5) * weightCalculation(tEntity) * sFPowerMultiplyer), false)) { - // if (hasDimensionalTeleportCapability() && this.mTargetD != - // getBaseMetaTileEntity().getWorld().provider.dimensionId && (hasEgg || - // mFluid.isFluidEqual(Materials.Nitrogen.getPlasma(1)))) { - // mFluid.amount = mFluid.amount - ((int) Math.min(10, (Math.pow(tDistance, 1.5) * - // weightCalculation(tEntity) / 8192))); - // if (mFluid.amount < 1) { - // mFluid = null; - // } - // } + if (tEntity.ridingEntity != null) { tEntity.mountEntity(null); } @@ -455,7 +437,7 @@ public boolean isElectric() { } @Override - public boolean isFacingValid(byte aFacing) { + public boolean isFacingValid(ForgeDirection facing) { return true; } @@ -465,12 +447,12 @@ public boolean isEnetInput() { } @Override - public boolean isInputFacing(byte aSide) { + public boolean isInputFacing(ForgeDirection side) { return true; } @Override - public boolean isOutputFacing(byte aSide) { + public boolean isOutputFacing(ForgeDirection side) { return false; } diff --git a/src/main/java/gregtech/common/tileentities/machines/long_distance/GT_MetaTileEntity_LongDistancePipelineBase.java b/src/main/java/gregtech/common/tileentities/machines/long_distance/GT_MetaTileEntity_LongDistancePipelineBase.java index b868d151f2a..70270996f3d 100644 --- a/src/main/java/gregtech/common/tileentities/machines/long_distance/GT_MetaTileEntity_LongDistancePipelineBase.java +++ b/src/main/java/gregtech/common/tileentities/machines/long_distance/GT_MetaTileEntity_LongDistancePipelineBase.java @@ -279,11 +279,11 @@ protected int getDistanceToSelf(ChunkCoordinates aCoords) { + Math.abs(getBaseMetaTileEntity().getZCoord() - aCoords.posZ); } - public ChunkCoordinates getFacingOffset(IGregTechTileEntity gt_tile, byte aSide) { + public ChunkCoordinates getFacingOffset(IGregTechTileEntity gt_tile, ForgeDirection side) { return new ChunkCoordinates( - gt_tile.getOffsetX(aSide, 1), - gt_tile.getOffsetY(aSide, 1), - gt_tile.getOffsetZ(aSide, 1)); + gt_tile.getOffsetX(side, 1), + gt_tile.getOffsetY(side, 1), + gt_tile.getOffsetZ(side, 1)); } public ChunkCoordinates getCoords() { @@ -312,12 +312,11 @@ public boolean shouldTriggerBlockUpdate() { public void getWailaBody(ItemStack itemStack, List currentTip, IWailaDataAccessor accessor, IWailaConfigHandler config) { final NBTTagCompound tag = accessor.getNBTData(); - final int facing = getBaseMetaTileEntity().getFrontFacing(); - final int side = (byte) accessor.getSide() - .ordinal(); + final ForgeDirection facing = getBaseMetaTileEntity().getFrontFacing(); + final ForgeDirection side = accessor.getSide(); if (side == facing) currentTip.add(GOLD + "Pipeline Input" + RESET); - else if (side == ForgeDirection.OPPOSITES[facing]) currentTip.add(BLUE + "Pipeline Output" + RESET); + else if (side == facing.getOpposite()) currentTip.add(BLUE + "Pipeline Output" + RESET); else currentTip.add("Pipeline Side"); if (tag.getBoolean("hasSender")) currentTip.add("Other End of Input: " + GREEN + "distance" + RESET); diff --git a/src/main/java/gregtech/common/tileentities/machines/long_distance/GT_MetaTileEntity_LongDistancePipelineFluid.java b/src/main/java/gregtech/common/tileentities/machines/long_distance/GT_MetaTileEntity_LongDistancePipelineFluid.java index 6b95d20d5c8..11e2680e313 100644 --- a/src/main/java/gregtech/common/tileentities/machines/long_distance/GT_MetaTileEntity_LongDistancePipelineFluid.java +++ b/src/main/java/gregtech/common/tileentities/machines/long_distance/GT_MetaTileEntity_LongDistancePipelineFluid.java @@ -35,7 +35,6 @@ import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.render.TextureFactory; -import gregtech.api.util.GT_Utility; public class GT_MetaTileEntity_LongDistancePipelineFluid extends GT_MetaTileEntity_LongDistancePipelineBase { @@ -68,33 +67,32 @@ public IFluidHandler getTank() { } @Override - public FluidTankInfo[] getTankInfo(ForgeDirection aSide) { + public FluidTankInfo[] getTankInfo(ForgeDirection side) { if (checkTarget()) { final IFluidHandler tankTile = getTank(); - if (tankTile != null) return tankTile.getTankInfo(aSide); + if (tankTile != null) return tankTile.getTankInfo(side); } return emptyTank; } @Override - public int fill(ForgeDirection aSide, FluidStack aFluid, boolean aDoFill) { + public int fill(ForgeDirection side, FluidStack aFluid, boolean aDoFill) { if (checkTarget()) { final IGregTechTileEntity tTile = mTarget.getBaseMetaTileEntity(); final IFluidHandler tankTile = getTank(); - if (tankTile != null) - return tankTile.fill(ForgeDirection.getOrientation(tTile.getFrontFacing()), aFluid, aDoFill); + if (tankTile != null) return tankTile.fill(tTile.getFrontFacing(), aFluid, aDoFill); } return 0; } @Override - public FluidStack drain(ForgeDirection aSide, FluidStack aFluid, boolean aDoDrain) { + public FluidStack drain(ForgeDirection side, FluidStack aFluid, boolean aDoDrain) { return null; } @Override - public FluidStack drain(ForgeDirection aSide, int aMaxDrain, boolean aDoDrain) { + public FluidStack drain(ForgeDirection side, int aMaxDrain, boolean aDoDrain) { return null; } @@ -109,13 +107,13 @@ public ITexture[][][] getTextureSet(ITexture[] aTextures) { } @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, - boolean aActive, boolean aRedstone) { - if (aSide == aFacing) return new ITexture[] { MACHINE_CASINGS[mTier][aColorIndex + 1], + public ITexture[] getTexture(IGregTechTileEntity baseMetaTileEntity, ForgeDirection sideDirection, + ForgeDirection facingDirection, int colorIndex, boolean active, boolean redstoneLevel) { + if (sideDirection == facingDirection) return new ITexture[] { MACHINE_CASINGS[mTier][colorIndex + 1], TextureFactory.of(OVERLAY_PIPELINE_FLUID_FRONT) }; - else if (aSide == GT_Utility.getOppositeSide(aFacing)) return new ITexture[] { - MACHINE_CASINGS[mTier][aColorIndex + 1], TextureFactory.of(OVERLAY_PIPELINE_FLUID_BACK) }; - else return new ITexture[] { MACHINE_CASINGS[mTier][aColorIndex + 1], + else if (sideDirection == facingDirection.getOpposite()) return new ITexture[] { + MACHINE_CASINGS[mTier][colorIndex + 1], TextureFactory.of(OVERLAY_PIPELINE_FLUID_BACK) }; + else return new ITexture[] { MACHINE_CASINGS[mTier][colorIndex + 1], TextureFactory.of(OVERLAY_PIPELINE_FLUID_SIDE), TextureFactory.builder() .addIcon(OVERLAY_PIPELINE_FLUID_SIDE_GLOW) .glow() diff --git a/src/main/java/gregtech/common/tileentities/machines/long_distance/GT_MetaTileEntity_LongDistancePipelineItem.java b/src/main/java/gregtech/common/tileentities/machines/long_distance/GT_MetaTileEntity_LongDistancePipelineItem.java index dc3956d2a6c..13cd231183d 100644 --- a/src/main/java/gregtech/common/tileentities/machines/long_distance/GT_MetaTileEntity_LongDistancePipelineItem.java +++ b/src/main/java/gregtech/common/tileentities/machines/long_distance/GT_MetaTileEntity_LongDistancePipelineItem.java @@ -29,13 +29,13 @@ import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.util.ForgeDirection; import gregtech.api.enums.GT_Values; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.render.TextureFactory; -import gregtech.api.util.GT_Utility; public class GT_MetaTileEntity_LongDistancePipelineItem extends GT_MetaTileEntity_LongDistancePipelineBase { @@ -149,12 +149,13 @@ public boolean isItemValidForSlot(int aSlot, ItemStack aStack) { // @Override - public int[] getAccessibleSlotsFromSide(int aSide) { + public int[] getAccessibleSlotsFromSide(int ordinalSide) { if (checkTarget()) { final IGregTechTileEntity tTile = mTarget.getBaseMetaTileEntity(); final IInventory iInventory = getInventory(); - if (iInventory instanceof ISidedInventory) - return ((ISidedInventory) iInventory).getAccessibleSlotsFromSide(tTile.getFrontFacing()); + if (iInventory instanceof ISidedInventory inv) return inv.getAccessibleSlotsFromSide( + tTile.getFrontFacing() + .ordinal()); if (iInventory != null) { final int[] tReturn = new int[iInventory.getSizeInventory()]; for (int i = 0; i < tReturn.length; i++) tReturn[i] = i; @@ -166,19 +167,22 @@ public int[] getAccessibleSlotsFromSide(int aSide) { } @Override - public boolean canInsertItem(int aSlot, ItemStack aStack, int aSide) { + public boolean canInsertItem(int aSlot, ItemStack aStack, int ordinalSide) { if (checkTarget()) { final IGregTechTileEntity tTile = mTarget.getBaseMetaTileEntity(); IInventory iInventory = getInventory(); - if (iInventory instanceof ISidedInventory) - return ((ISidedInventory) iInventory).canInsertItem(aSlot, aStack, tTile.getFrontFacing()); + if (iInventory instanceof ISidedInventory iSidedInventory) return iSidedInventory.canInsertItem( + aSlot, + aStack, + tTile.getFrontFacing() + .ordinal()); return iInventory != null; } return false; } @Override - public boolean canExtractItem(int aSlot, ItemStack aStack, int aSide) { + public boolean canExtractItem(int aSlot, ItemStack aStack, int ordinalSide) { return false; } @@ -188,13 +192,13 @@ public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { } @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, - boolean aActive, boolean aRedstone) { - if (aSide == aFacing) return new ITexture[] { MACHINE_CASINGS[mTier][aColorIndex + 1], + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, + ForgeDirection facingDirection, int colorIndex, boolean aActive, boolean redstoneLevel) { + if (side == facingDirection) return new ITexture[] { MACHINE_CASINGS[mTier][colorIndex + 1], TextureFactory.of(OVERLAY_PIPELINE_ITEM_FRONT) }; - else if (aSide == GT_Utility.getOppositeSide(aFacing)) return new ITexture[] { - MACHINE_CASINGS[mTier][aColorIndex + 1], TextureFactory.of(OVERLAY_PIPELINE_ITEM_BACK) }; - else return new ITexture[] { MACHINE_CASINGS[mTier][aColorIndex + 1], + else if (side == facingDirection.getOpposite()) return new ITexture[] { MACHINE_CASINGS[mTier][colorIndex + 1], + TextureFactory.of(OVERLAY_PIPELINE_ITEM_BACK) }; + else return new ITexture[] { MACHINE_CASINGS[mTier][colorIndex + 1], TextureFactory.of(OVERLAY_PIPELINE_ITEM_SIDE), TextureFactory.builder() .addIcon(OVERLAY_PIPELINE_ITEM_SIDE_GLOW) .glow() 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 ccffb3cd3af..c92a33e5d5e 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 @@ -170,10 +170,10 @@ protected GT_Multiblock_Tooltip_Builder createTooltip() { } @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, - boolean aActive, boolean aRedstone) { - if (aSide == aFacing) { - if (aActive) return new ITexture[] { BlockIcons.casingTexturePages[0][16], TextureFactory.builder() + public ITexture[] getTexture(IGregTechTileEntity baseMetaTileEntity, ForgeDirection sideDirection, + ForgeDirection facingDirection, int colorIndex, boolean active, boolean redstoneLevel) { + if (sideDirection == facingDirection) { + if (active) return new ITexture[] { BlockIcons.casingTexturePages[0][16], TextureFactory.builder() .addIcon(OVERLAY_FRONT_ASSEMBLY_LINE_ACTIVE) .extFacing() .build(), 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 b650619966c..3fe0ab51499 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 @@ -2,6 +2,7 @@ import net.minecraft.block.Block; import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; import org.lwjgl.input.Keyboard; @@ -77,9 +78,9 @@ protected GT_Multiblock_Tooltip_Builder getTooltip() { } @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, - boolean aActive, boolean aRedstone) { - if (aSide == aFacing) { + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection aFacing, + int colorIndex, boolean aActive, boolean redstoneLevel) { + if (side == aFacing) { return aActive ? FACING_ACTIVE : FACING_FRONT; } return FACING_SIDE; 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 2341f6a0467..83e8cc1817f 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 @@ -7,6 +7,7 @@ import net.minecraft.block.Block; import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; import gregtech.api.GregTech_API; import gregtech.api.enums.SteamVariant; @@ -39,9 +40,9 @@ public String[] getDescription() { } @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, - boolean aActive, boolean aRedstone) { - if (aSide == aFacing) { + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection aFacing, + int colorIndex, boolean aActive, boolean redstoneLevel) { + if (side == aFacing) { return aActive ? FACING_ACTIVE : FACING_FRONT; } return FACING_SIDE; 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 9e1912ca515..3a454967725 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 @@ -15,6 +15,7 @@ import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.world.ChunkPosition; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.oredict.OreDictionary; import gregtech.GT_Mod; @@ -46,8 +47,8 @@ public GT_MetaTileEntity_Charcoal_Pit(String aName) { } @Override - public boolean isFacingValid(byte aFacing) { - return aFacing > 1; + public boolean isFacingValid(ForgeDirection facing) { + return facing.offsetY == 0; } @Override @@ -267,9 +268,9 @@ protected GT_Multiblock_Tooltip_Builder createTooltip() { } @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, - boolean aActive, boolean aRedstone) { - if (aSide == 1) { + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection aFacing, + int colorIndex, boolean aActive, boolean redstoneLevel) { + if (side == ForgeDirection.UP) { if (aActive) return new ITexture[] { casingTexturePages[0][10], TextureFactory.of(OVERLAY_FRONT_ROCK_BREAKER_ACTIVE), TextureFactory.builder() .addIcon(OVERLAY_FRONT_ROCK_BREAKER_ACTIVE_GLOW) @@ -299,9 +300,9 @@ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { new WorldSpawnedEventBuilder.ParticleEventBuilder().setMotion(0D, 0.3D, 0D) .setIdentifier(ParticleFX.LARGE_SMOKE) .setPosition( - aBaseMetaTileEntity.getOffsetX((byte) 1, 1) + XSTR_INSTANCE.nextFloat(), - aBaseMetaTileEntity.getOffsetY((byte) 1, 1), - aBaseMetaTileEntity.getOffsetZ((byte) 1, 1) + XSTR_INSTANCE.nextFloat()) + aBaseMetaTileEntity.getOffsetX(ForgeDirection.UP, 1) + XSTR_INSTANCE.nextFloat(), + aBaseMetaTileEntity.getOffsetY(ForgeDirection.UP, 1), + aBaseMetaTileEntity.getOffsetZ(ForgeDirection.UP, 1) + XSTR_INSTANCE.nextFloat()) .setWorld(getBaseMetaTileEntity().getWorld()) .run(); } 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 5a25507524c..a3326c4a073 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 @@ -1,6 +1,5 @@ package gregtech.common.tileentities.machines.multi; -import static gregtech.api.enums.GT_Values.ALL_VALID_SIDES; import static gregtech.api.enums.GT_Values.debugCleanroom; import static gregtech.api.enums.Textures.BlockIcons.*; @@ -101,8 +100,8 @@ public boolean checkRecipe(ItemStack aStack) { } @Override - public boolean isFacingValid(byte aFacing) { - return aFacing > 1; + public boolean isFacingValid(ForgeDirection facing) { + return facing.offsetY == 0; } @Override @@ -275,7 +274,7 @@ else if (Math.abs(dX) < x) // on side parallel to x axis if (doorState) { this.mEfficiency = Math.max(0, this.mEfficiency - 200); } - for (byte tSide : ALL_VALID_SIDES) { + for (final ForgeDirection tSide : ForgeDirection.VALID_DIRECTIONS) { final byte t = (byte) Math.max(1, (byte) (15 / (10000f / this.mEfficiency))); aBaseMetaTileEntity.setInternalOutputRedstoneSignal(tSide, t); } @@ -323,10 +322,10 @@ public boolean allowGeneralRedstoneOutput() { } @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, - boolean aActive, boolean aRedstone) { - if (aSide == ForgeDirection.DOWN.ordinal() || aSide == ForgeDirection.UP.ordinal()) { - return new ITexture[] { TextureFactory.of(BLOCK_PLASCRETE), aActive + public ITexture[] getTexture(IGregTechTileEntity baseMetaTileEntity, ForgeDirection sideDirection, + ForgeDirection facingDirection, int colorIndex, boolean active, boolean redstoneLevel) { + if (sideDirection.offsetY != 0) { + return new ITexture[] { TextureFactory.of(BLOCK_PLASCRETE), active ? TextureFactory.of( TextureFactory.of(OVERLAY_TOP_CLEANROOM_ACTIVE), TextureFactory.builder() 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 4fdc2e7f035..bf5d12482f6 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 @@ -21,6 +21,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; @@ -113,9 +114,9 @@ protected GT_Multiblock_Tooltip_Builder createTooltip() { } @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, - boolean aActive, boolean aRedstone) { - if (aSide == aFacing) { + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection aFacing, + int colorIndex, boolean aActive, boolean redstoneLevel) { + if (side == aFacing) { if (aActive) return new ITexture[] { casingTexturePages[0][50], TextureFactory.builder() .addIcon(OVERLAY_FRONT_DIESEL_ENGINE_ACTIVE) .extFacing() 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 17b043ead2a..73b65269036 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 @@ -149,14 +149,13 @@ protected GT_Multiblock_Tooltip_Builder createTooltip() { } @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, - boolean aActive, boolean aRedstone) { - if (aSide == aFacing) { - if (aActive) return new ITexture[] { BlockIcons.getCasingTextureForId(CASING_INDEX), - TextureFactory.builder() - .addIcon(OVERLAY_FRONT_DISTILLATION_TOWER_ACTIVE) - .extFacing() - .build(), + public ITexture[] getTexture(IGregTechTileEntity baseMetaTileEntity, ForgeDirection sideDirection, + ForgeDirection facingDirection, int colorIndex, boolean active, boolean redstoneLevel) { + if (sideDirection == facingDirection) { + if (active) return new ITexture[] { BlockIcons.getCasingTextureForId(CASING_INDEX), TextureFactory.builder() + .addIcon(OVERLAY_FRONT_DISTILLATION_TOWER_ACTIVE) + .extFacing() + .build(), TextureFactory.builder() .addIcon(OVERLAY_FRONT_DISTILLATION_TOWER_ACTIVE_GLOW) .extFacing() diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java index e7879cbe0d0..d65dd0ad606 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java @@ -144,10 +144,10 @@ private void initFields() { } @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, - boolean aActive, boolean aRedstone) { - if (aSide == aFacing) { - if (aActive) return new ITexture[] { getCasingTextureForId(casingTextureIndex), TextureFactory.builder() + public ITexture[] getTexture(IGregTechTileEntity baseMetaTileEntity, ForgeDirection sideDirection, + ForgeDirection facingDirection, int colorIndex, boolean active, boolean redstoneLevel) { + if (sideDirection == facingDirection) { + if (active) return new ITexture[] { getCasingTextureForId(casingTextureIndex), TextureFactory.builder() .addIcon(OVERLAY_FRONT_ORE_DRILL_ACTIVE) .extFacing() .build(), @@ -196,17 +196,17 @@ public void loadNBTData(NBTTagCompound aNBT) { } @Override - public boolean onSolderingToolRightClick(byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, - float aZ) { - if (aSide == getBaseMetaTileEntity().getFrontFacing()) { + public boolean onSolderingToolRightClick(ForgeDirection side, ForgeDirection wrenchingSide, + EntityPlayer entityPlayer, float aX, float aY, float aZ) { + if (side == getBaseMetaTileEntity().getFrontFacing()) { mChunkLoadingEnabled = !mChunkLoadingEnabled; GT_Utility.sendChatToPlayer( - aPlayer, + entityPlayer, mChunkLoadingEnabled ? GT_Utility.trans("502", "Mining chunk loading enabled") : GT_Utility.trans("503", "Mining chunk loading disabled")); return true; } - return super.onSolderingToolRightClick(aSide, aWrenchingSide, aPlayer, aX, aY, aZ); + return super.onSolderingToolRightClick(side, wrenchingSide, entityPlayer, aX, aY, aZ); } @Override @@ -444,7 +444,7 @@ private void updateCoordinates() { xDrill = getBaseMetaTileEntity().getXCoord(); yDrill = getBaseMetaTileEntity().getYCoord(); zDrill = getBaseMetaTileEntity().getZCoord(); - back = ForgeDirection.getOrientation(getBaseMetaTileEntity().getBackFacing()); + back = getBaseMetaTileEntity().getBackFacing(); xPipe = xDrill + back.offsetX; zPipe = zDrill + back.offsetZ; } 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 acd87c1687c..c0334bfcec1 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 @@ -15,6 +15,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; @@ -120,9 +121,9 @@ protected GT_Multiblock_Tooltip_Builder createTooltip() { } @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, - boolean aActive, boolean aRedstone) { - if (aSide == aFacing) { + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection aFacing, + int colorIndex, boolean aActive, boolean redstoneLevel) { + if (side == aFacing) { if (aActive) return new ITexture[] { casingTexturePages[0][CASING_INDEX], TextureFactory.builder() .addIcon(OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE_ACTIVE) .extFacing() @@ -422,7 +423,7 @@ public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBu } @Override - public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + public void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { inputSeparation = !inputSeparation; GT_Utility.sendChatToPlayer( aPlayer, 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 f156d4ffbdd..ee08617950f 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 @@ -10,6 +10,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; +import net.minecraftforge.common.util.ForgeDirection; import gregtech.GT_Mod; import gregtech.api.GregTech_API; @@ -68,9 +69,9 @@ protected GT_Recipe.GT_Recipe_Map_Fuel getFuelMap() { } @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, - boolean aActive, boolean aRedstone) { - if (aSide == aFacing) { + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection aFacing, + int colorIndex, boolean aActive, boolean redstoneLevel) { + if (side == aFacing) { if (aActive) return new ITexture[] { casingTexturePages[0][60], TextureFactory.builder() .addIcon(OVERLAY_FRONT_EXTREME_DIESEL_ENGINE_ACTIVE) .extFacing() diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer.java index a67b050abbf..4f353b24f98 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer.java @@ -19,6 +19,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; import com.google.common.collect.ImmutableMap; @@ -156,9 +157,9 @@ public Power getPower() { public abstract MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity); @Override - public boolean allowCoverOnSide(byte aSide, GT_ItemStack aStack) { + public boolean allowCoverOnSide(ForgeDirection side, GT_ItemStack aStack) { - return aSide != getBaseMetaTileEntity().getFrontFacing(); + return side != getBaseMetaTileEntity().getFrontFacing(); } @Override @@ -243,9 +244,9 @@ private boolean addExtractor(IGregTechTileEntity aBaseMetaTileEntity, int aBaseC public abstract int getFusionCoilMeta(); @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, - boolean aActive, boolean aRedstone) { - if (aSide == aFacing) return new ITexture[] { TextureFactory.builder() + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection aFacing, + int colorIndex, boolean aActive, boolean redstoneLevel) { + if (side == aFacing) return new ITexture[] { TextureFactory.builder() .addIcon(MACHINE_CASING_FUSION_GLASS) .extFacing() .build(), getTextureOverlay() }; 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 bdaf5209ce0..95529c503f4 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 @@ -11,6 +11,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; @@ -131,9 +132,9 @@ public void saveNBTData(NBTTagCompound aNBT) { } @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, - boolean aActive, boolean aRedstone) { - if (aSide == aFacing) { + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection aFacing, + int colorIndex, boolean aActive, boolean redstoneLevel) { + if (side == aFacing) { if (aActive) return new ITexture[] { casingTexturePages[0][CASING_INDEX], TextureFactory.builder() .addIcon(OVERLAY_FRONT_HEAT_EXCHANGER_ACTIVE) .extFacing() 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 0ba884ab8c6..a5cce300ed6 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 @@ -7,6 +7,7 @@ import java.util.ArrayList; import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; import com.gtnewhorizon.structurelib.structure.IStructureElement; @@ -68,9 +69,9 @@ public boolean addToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasing } @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, - boolean aActive, boolean aRedstone) { - if (aSide == aFacing) { + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection aFacing, + int colorIndex, boolean aActive, boolean redstoneLevel) { + if (side == aFacing) { if (aActive) return new ITexture[] { BlockIcons.casingTexturePages[0][16], TextureFactory.builder() .addIcon(OVERLAY_FRONT_IMPLOSION_COMPRESSOR_ACTIVE) .extFacing() diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_IntegratedOreFactory.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_IntegratedOreFactory.java index 5b3db72c984..3747bf85239 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_IntegratedOreFactory.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_IntegratedOreFactory.java @@ -23,6 +23,7 @@ import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.oredict.OreDictionary; @@ -371,7 +372,7 @@ private final boolean checkTypes(int aID, HashSet... aTables) { } @Override - public final void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + public final void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { if (aPlayer.isSneaking()) { sVoidStone = !sVoidStone; GT_Utility.sendChatToPlayer( @@ -662,9 +663,9 @@ public String[] getInfoData() { } @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, - boolean aActive, boolean aRedstone) { - if (aSide == aFacing) { + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection aFacing, + int colorIndex, boolean aActive, boolean redstoneLevel) { + if (side == aFacing) { if (aActive) return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(CASING_INDEX2), TextureFactory.builder() .addIcon(OVERLAY_FRONT_PROCESSING_ARRAY_ACTIVE) 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 a2086307f10..2e68b123750 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 @@ -19,6 +19,7 @@ import net.minecraft.block.Block; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; @@ -187,9 +188,9 @@ public int getPollutionPerSecond(ItemStack aStack) { } @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, - boolean aActive, boolean aRedstone) { - if (aSide == aFacing) { + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection aFacing, + int colorIndex, boolean aActive, boolean redstoneLevel) { + if (side == aFacing) { if (aActive) return new ITexture[] { BlockIcons.getCasingTextureForId(getCasingTextureIndex()), TextureFactory.builder() .addIcon(OVERLAY_FRONT_LARGE_BOILER_ACTIVE) 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 6fb7c6430a4..d3d425fc7ff 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 @@ -17,6 +17,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.IChatComponent; import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; import com.gtnewhorizon.structurelib.StructureLibAPI; @@ -112,9 +113,9 @@ public GT_Multiblock_Tooltip_Builder createTooltip() { } @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, - boolean aActive, boolean aRedstone) { - if (aSide == aFacing) { + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection aFacing, + int colorIndex, boolean aActive, boolean redstoneLevel) { + if (side == aFacing) { if (aActive) return new ITexture[] { casingTexturePages[1][48], TextureFactory.builder() .addIcon(OVERLAY_FRONT_LARGE_CHEMICAL_REACTOR_ACTIVE) .extFacing() diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine.java index 8ffd4016462..102ffab30e8 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine.java @@ -137,14 +137,14 @@ public boolean renderInWorld(IBlockAccess aWorld, int aX, int aY, int aZ, Block if (!isNewStyleRendering() || !mFormed) return false; int[] tABCCoord = new int[] { -1, -1, 0 }; int[] tXYZOffset = new int[3]; - byte tFacing = getBaseMetaTileEntity().getFrontFacing(); - ExtendedFacing tExtendedFacing = getExtendedFacing(); - ForgeDirection tDirection = tExtendedFacing.getDirection(); - LightingHelper tLighting = new LightingHelper(aRenderer); + final ForgeDirection tFacing = getBaseMetaTileEntity().getFrontFacing(); + final ExtendedFacing tExtendedFacing = getExtendedFacing(); + final ForgeDirection tDirection = tExtendedFacing.getDirection(); + final LightingHelper tLighting = new LightingHelper(aRenderer); // for some reason +x and -z need this field set to true, but not any other sides - if (tFacing == 2 || tFacing == 5) aRenderer.field_152631_f = true; - Block tBlock = getCasingBlock(); + if (tFacing == ForgeDirection.NORTH || tFacing == ForgeDirection.EAST) aRenderer.field_152631_f = true; + final Block tBlock = getCasingBlock(); IIconContainer[] tTextures; if (getBaseMetaTileEntity().isActive()) tTextures = getTurbineTextureActive(); 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 d48f27a7a4d..1984d48a51a 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 @@ -6,6 +6,7 @@ import net.minecraft.block.Block; import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; import gregtech.GT_Mod; @@ -30,10 +31,10 @@ public GT_MetaTileEntity_LargeTurbine_Gas(String aName) { } @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, - boolean aActive, boolean aRedstone) { - return new ITexture[] { MACHINE_CASINGS[1][aColorIndex + 1], - aFacing == aSide ? (aActive ? TextureFactory.builder() + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection aFacing, + int colorIndex, boolean aActive, boolean redstoneLevel) { + return new ITexture[] { MACHINE_CASINGS[1][colorIndex + 1], + aFacing == side ? (aActive ? TextureFactory.builder() .addIcon(LARGETURBINE_NEW_ACTIVE5) .build() : hasTurbine() ? TextureFactory.builder() diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_GasAdvanced.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_GasAdvanced.java index 81bd201b381..568925b371e 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_GasAdvanced.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_GasAdvanced.java @@ -6,6 +6,7 @@ import net.minecraft.block.Block; import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; import gregtech.GT_Mod; @@ -30,10 +31,10 @@ public GT_MetaTileEntity_LargeTurbine_GasAdvanced(String aName) { } @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, - boolean aActive, boolean aRedstone) { - return new ITexture[] { MACHINE_CASINGS[1][aColorIndex + 1], - aFacing == aSide ? (aActive ? TextureFactory.builder() + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection aFacing, + int colorIndex, boolean aActive, boolean redstoneLevel) { + return new ITexture[] { MACHINE_CASINGS[1][colorIndex + 1], + aFacing == side ? (aActive ? TextureFactory.builder() .addIcon(LARGETURBINE_NEW_ACTIVE5) .build() : hasTurbine() ? TextureFactory.builder() 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 fc1e7fe3ce0..03d9de99be5 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 @@ -10,6 +10,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; import gregtech.GT_Mod; @@ -36,10 +37,10 @@ public GT_MetaTileEntity_LargeTurbine_HPSteam(String aName) { } @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, - boolean aActive, boolean aRedstone) { - return new ITexture[] { MACHINE_CASINGS[1][aColorIndex + 1], - aFacing == aSide ? (aActive ? TextureFactory.builder() + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection aFacing, + int colorIndex, boolean aActive, boolean redstoneLevel) { + return new ITexture[] { MACHINE_CASINGS[1][colorIndex + 1], + aFacing == side ? (aActive ? TextureFactory.builder() .addIcon(LARGETURBINE_NEW_ACTIVE5) .build() : hasTurbine() ? TextureFactory.builder() @@ -192,8 +193,8 @@ float getOverflowEfficiency(int totalFlow, int actualOptimalFlow, int overflowMu } @Override - public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { - if (aSide == getBaseMetaTileEntity().getFrontFacing()) { + public void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (side == getBaseMetaTileEntity().getFrontFacing()) { looseFit ^= true; GT_Utility.sendChatToPlayer( aPlayer, 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 cfc565558be..df4e7e6d91b 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 @@ -8,6 +8,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; @@ -36,10 +37,10 @@ public GT_MetaTileEntity_LargeTurbine_Plasma(String aName) { } @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, - boolean aActive, boolean aRedstone) { - return new ITexture[] { MACHINE_CASINGS[1][aColorIndex + 1], - aFacing == aSide ? (aActive ? TextureFactory.builder() + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection aFacing, + int colorIndex, boolean aActive, boolean redstoneLevel) { + return new ITexture[] { MACHINE_CASINGS[1][colorIndex + 1], + aFacing == side ? (aActive ? TextureFactory.builder() .addIcon(LARGETURBINE_NEW_ACTIVE5) .build() : hasTurbine() ? TextureFactory.builder() 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 1a6a6f678ab..17fe1d2af3b 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 @@ -10,6 +10,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; import gregtech.GT_Mod; @@ -37,10 +38,10 @@ public GT_MetaTileEntity_LargeTurbine_Steam(String aName) { } @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, - boolean aActive, boolean aRedstone) { - return new ITexture[] { MACHINE_CASINGS[1][aColorIndex + 1], - aFacing == aSide ? (aActive ? TextureFactory.builder() + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection aFacing, + int colorIndex, boolean aActive, boolean redstoneLevel) { + return new ITexture[] { MACHINE_CASINGS[1][colorIndex + 1], + aFacing == side ? (aActive ? TextureFactory.builder() .addIcon(LARGETURBINE_NEW_ACTIVE5) .build() : hasTurbine() ? TextureFactory.builder() @@ -233,8 +234,8 @@ public static float[] calculateLooseFlow(float aOptFlow, float aBaseEff) { } @Override - public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { - if (aSide == getBaseMetaTileEntity().getFrontFacing()) { + public void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (side == getBaseMetaTileEntity().getFrontFacing()) { looseFit ^= true; GT_Utility.sendChatToPlayer( aPlayer, 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 58d82f29010..3bc884f8afa 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 @@ -104,10 +104,10 @@ protected GT_Multiblock_Tooltip_Builder createTooltip() { } @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, - boolean aActive, boolean aRedstone) { - if (aSide != aFacing) return new ITexture[] { casingTexturePages[0][CASING_INDEX] }; - if (aActive) return new ITexture[] { casingTexturePages[0][CASING_INDEX], TextureFactory.builder() + public ITexture[] getTexture(IGregTechTileEntity baseMetaTileEntity, ForgeDirection sideDirection, + ForgeDirection facingDirection, int colorIndex, boolean active, boolean redstoneLevel) { + if (sideDirection != facingDirection) return new ITexture[] { casingTexturePages[0][CASING_INDEX] }; + if (active) return new ITexture[] { casingTexturePages[0][CASING_INDEX], TextureFactory.builder() .addIcon(OVERLAY_FRONT_MULTI_SMELTER_ACTIVE) .extFacing() .build(), @@ -219,11 +219,11 @@ public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack a } private void replaceDeprecatedCoils(IGregTechTileEntity aBaseMetaTileEntity) { - int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; - int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; - int tX = aBaseMetaTileEntity.getXCoord() + xDir; - int tY = aBaseMetaTileEntity.getYCoord(); - int tZ = aBaseMetaTileEntity.getZCoord() + zDir; + final int xDir = aBaseMetaTileEntity.getBackFacing().offsetX; + final int zDir = aBaseMetaTileEntity.getBackFacing().offsetZ; + final int tX = aBaseMetaTileEntity.getXCoord() + xDir; + final int tY = aBaseMetaTileEntity.getYCoord(); + final int tZ = aBaseMetaTileEntity.getZCoord() + zDir; int tUsedMeta; for (int xPos = tX - 1; xPos <= tX + 1; xPos++) for (int zPos = tZ - 1; zPos <= tZ + 1; zPos++) { if ((xPos == tX) && (zPos == tZ)) continue; @@ -238,12 +238,12 @@ private void replaceDeprecatedCoils(IGregTechTileEntity aBaseMetaTileEntity) { @Override public String[] getInfoData() { int mPollutionReduction = 0; - for (GT_MetaTileEntity_Hatch_Muffler tHatch : mMufflerHatches) if (isValidMetaTileEntity(tHatch)) + for (final GT_MetaTileEntity_Hatch_Muffler tHatch : mMufflerHatches) if (isValidMetaTileEntity(tHatch)) mPollutionReduction = Math.max(tHatch.calculatePollutionReduction(100), mPollutionReduction); long storedEnergy = 0; long maxEnergy = 0; - for (GT_MetaTileEntity_Hatch_Energy tHatch : mEnergyHatches) if (isValidMetaTileEntity(tHatch)) { + for (final GT_MetaTileEntity_Hatch_Energy tHatch : mEnergyHatches) if (isValidMetaTileEntity(tHatch)) { storedEnergy += tHatch.getBaseMetaTileEntity() .getStoredEU(); maxEnergy += tHatch.getBaseMetaTileEntity() diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_NanoForge.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_NanoForge.java index 61ce017d5ab..1468dab84be 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_NanoForge.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_NanoForge.java @@ -185,10 +185,10 @@ public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { } @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, - boolean aActive, boolean aRedstone) { - if (aSide == aFacing) { - if (aActive) return new ITexture[] { + public ITexture[] getTexture(IGregTechTileEntity baseMetaTileEntity, ForgeDirection sideDirection, + ForgeDirection facingDirection, int colorIndex, boolean active, boolean redstoneLevel) { + if (sideDirection == facingDirection) { + if (active) return new ITexture[] { BlockIcons.getCasingTextureForId(GT_Utility.getCasingTextureIndex(GregTech_API.sBlockCasings8, 10)), TextureFactory.builder() .addIcon(OVERLAY_FRONT_ASSEMBLY_LINE_ACTIVE) @@ -487,7 +487,7 @@ protected GT_Multiblock_Tooltip_Builder createTooltip() { } @Override - public final void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + public final void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { inputSeparation = !inputSeparation; GT_Utility.sendChatToPlayer( aPlayer, 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 384013459cc..478aa7f7cd8 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 @@ -136,10 +136,10 @@ protected GT_Multiblock_Tooltip_Builder createTooltip() { } @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, - boolean aActive, boolean aRedstone) { - if (aSide == aFacing) { - if (aActive) return new ITexture[] { casingTexturePages[0][CASING_INDEX], TextureFactory.builder() + public ITexture[] getTexture(IGregTechTileEntity baseMetaTileEntity, ForgeDirection sideDirection, + ForgeDirection facingDirection, int colorIndex, boolean active, boolean redstoneLevel) { + if (sideDirection == facingDirection) { + if (active) return new ITexture[] { casingTexturePages[0][CASING_INDEX], TextureFactory.builder() .addIcon(OVERLAY_FRONT_OIL_CRACKER_ACTIVE) .extFacing() .build(), @@ -322,16 +322,16 @@ public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { } private void replaceDeprecatedCoils(IGregTechTileEntity aBaseMetaTileEntity) { - int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; - int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; - int tX = aBaseMetaTileEntity.getXCoord() + xDir; - int tY = aBaseMetaTileEntity.getYCoord(); - int tZ = aBaseMetaTileEntity.getZCoord() + zDir; + final int xDir = aBaseMetaTileEntity.getBackFacing().offsetX; + final int zDir = aBaseMetaTileEntity.getBackFacing().offsetZ; + final int tX = aBaseMetaTileEntity.getXCoord() + xDir; + final int tY = aBaseMetaTileEntity.getYCoord(); + final int tZ = aBaseMetaTileEntity.getZCoord() + zDir; for (int xPos = tX - 1; xPos <= tX + 1; xPos += (xDir != 0 ? 1 : 2)) for (int yPos = tY - 1; yPos <= tY + 1; yPos++) for (int zPos = tZ - 1; zPos <= tZ + 1; zPos += (xDir != 0 ? 2 : 1)) { if ((yPos == tY) && (xPos == tX || zPos == tZ)) continue; - byte tUsedMeta = aBaseMetaTileEntity.getMetaID(xPos, yPos, zPos); + final byte tUsedMeta = aBaseMetaTileEntity.getMetaID(xPos, yPos, zPos); if (tUsedMeta < 12) continue; if (tUsedMeta > 14) continue; if (aBaseMetaTileEntity.getBlock(xPos, yPos, zPos) != GregTech_API.sBlockCasings1) continue; @@ -343,12 +343,12 @@ private void replaceDeprecatedCoils(IGregTechTileEntity aBaseMetaTileEntity) { @Override public ArrayList getStoredFluids() { - ArrayList rList = new ArrayList<>(); - for (GT_MetaTileEntity_Hatch_Input tHatch : mInputHatches) { + final ArrayList rList = new ArrayList<>(); + for (final GT_MetaTileEntity_Hatch_Input tHatch : mInputHatches) { tHatch.mRecipeMap = getRecipeMap(); if (tHatch instanceof GT_MetaTileEntity_Hatch_MultiInput) { if (isValidMetaTileEntity(tHatch)) { - for (FluidStack tFluid : ((GT_MetaTileEntity_Hatch_MultiInput) tHatch).getStoredFluid()) { + for (final FluidStack tFluid : ((GT_MetaTileEntity_Hatch_MultiInput) tHatch).getStoredFluid()) { if (tFluid != null && !GT_Recipe.GT_Recipe_Map.sCrackingRecipes.isValidCatalystFluid(tFluid)) { rList.add(tFluid); } @@ -361,11 +361,11 @@ public ArrayList getStoredFluids() { } } } - for (GT_MetaTileEntity_Hatch_Input tHatch : mMiddleInputHatches) { + for (final GT_MetaTileEntity_Hatch_Input tHatch : mMiddleInputHatches) { tHatch.mRecipeMap = getRecipeMap(); if (tHatch instanceof GT_MetaTileEntity_Hatch_MultiInput) { if (isValidMetaTileEntity(tHatch)) { - for (FluidStack tFluid : ((GT_MetaTileEntity_Hatch_MultiInput) tHatch).getStoredFluid()) { + for (final FluidStack tFluid : ((GT_MetaTileEntity_Hatch_MultiInput) tHatch).getStoredFluid()) { if (tFluid != null && GT_Recipe.GT_Recipe_Map.sCrackingRecipes.isValidCatalystFluid(tFluid)) { rList.add(tFluid); } @@ -373,7 +373,7 @@ public ArrayList getStoredFluids() { } } else { if (isValidMetaTileEntity(tHatch) && tHatch.getFillableStack() != null) { - FluidStack tStack = tHatch.getFillableStack(); + final FluidStack tStack = tHatch.getFillableStack(); if (GT_Recipe.GT_Recipe_Map.sCrackingRecipes.isValidCatalystFluid(tStack)) { rList.add(tStack); } 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 c945e8c8616..1e7f683bc53 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 @@ -22,6 +22,7 @@ import net.minecraft.util.StatCollector; import net.minecraft.world.ChunkCoordIntPair; import net.minecraft.world.chunk.Chunk; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; @@ -54,9 +55,9 @@ public GT_MetaTileEntity_OilDrillBase(String aName) { } @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, - boolean aActive, boolean aRedstone) { - if (aSide == aFacing) { + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection aFacing, + int colorIndex, boolean aActive, boolean redstoneLevel) { + if (side == aFacing) { if (aActive) return new ITexture[] { getCasingTextureForId(casingTextureIndex), TextureFactory.builder() .addIcon(OVERLAY_FRONT_OIL_DRILL_ACTIVE) .extFacing() @@ -122,8 +123,8 @@ protected GT_Multiblock_Tooltip_Builder createTooltip(String tierSuffix) { protected abstract int getRangeInChunks(); @Override - public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { - super.onScrewdriverRightClick(aSide, aPlayer, aX, aY, aZ); + public void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { + super.onScrewdriverRightClick(side, aPlayer, aX, aY, aZ); int oldChunkRange = chunkRangeConfig; if (aPlayer.isSneaking()) { if (chunkRangeConfig > 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 de6b5c51446..8e8f16d1119 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 @@ -20,6 +20,7 @@ import net.minecraft.util.StatCollector; import net.minecraft.world.ChunkCoordIntPair; import net.minecraft.world.ChunkPosition; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; import com.google.common.collect.ImmutableList; @@ -72,8 +73,8 @@ public void loadNBTData(NBTTagCompound aNBT) { } @Override - public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { - super.onScrewdriverRightClick(aSide, aPlayer, aX, aY, aZ); + public void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { + super.onScrewdriverRightClick(side, aPlayer, aX, aY, aZ); if (aPlayer.isSneaking()) { if (chunkRadiusConfig > 0) { chunkRadiusConfig--; @@ -94,8 +95,8 @@ public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, } @Override - public boolean onWireCutterRightClick(byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, - float aZ) { + public boolean onWireCutterRightClick(ForgeDirection side, ForgeDirection wrenchingSide, EntityPlayer aPlayer, + float aX, float aY, float aZ) { replaceWithCobblestone = !replaceWithCobblestone; GT_Utility.sendChatToPlayer(aPlayer, "Replace with cobblestone " + replaceWithCobblestone); return true; diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PCBFactory.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PCBFactory.java index 0938da2b65b..719cbc0f636 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PCBFactory.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PCBFactory.java @@ -385,10 +385,10 @@ public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { } @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, - boolean aActive, boolean aRedstone) { - if (aSide == aFacing) { - if (aActive) + public ITexture[] getTexture(IGregTechTileEntity baseMetaTileEntity, ForgeDirection sideDirection, + ForgeDirection facingDirection, int colorIndex, boolean active, boolean redstoneLevel) { + if (sideDirection == facingDirection) { + if (active) return new ITexture[] { BlockIcons.getCasingTextureForId( getTier() < 3 ? GT_Utility.getCasingTextureIndex(GregTech_API.sBlockCasings8, 11) @@ -854,7 +854,7 @@ protected long getActualEnergyUsage() { } @Override - public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + public void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { inputSeparation = !inputSeparation; GT_Utility.sendChatToPlayer( aPlayer, diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PlasmaForge.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PlasmaForge.java index 30368a12f0b..621a6aaf166 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PlasmaForge.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PlasmaForge.java @@ -18,6 +18,7 @@ import net.minecraft.util.ResourceLocation; import net.minecraft.util.StatCollector; import net.minecraft.world.ChunkCoordIntPair; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; @@ -607,9 +608,9 @@ public boolean addToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasing } @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, - boolean aActive, boolean aRedstone) { - if (aSide == aFacing) { + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection aFacing, + int colorIndex, boolean aActive, boolean redstoneLevel) { + if (side == aFacing) { if (aActive) return new ITexture[] { casingTexturePages[0][DIM_BRIDGE_CASING], TextureFactory.builder() .addIcon(OVERLAY_DTPF_ON) .extFacing() diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PrimitiveBlastFurnace.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PrimitiveBlastFurnace.java index ccd536d341e..88ca267e514 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PrimitiveBlastFurnace.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PrimitiveBlastFurnace.java @@ -113,12 +113,12 @@ public boolean isEnetOutput() { } @Override - public boolean isInputFacing(byte aSide) { + public boolean isInputFacing(ForgeDirection side) { return false; } @Override - public boolean isOutputFacing(byte aSide) { + public boolean isOutputFacing(ForgeDirection side) { return false; } @@ -128,8 +128,8 @@ public boolean isTeleporterCompatible() { } @Override - public boolean isFacingValid(byte aFacing) { - return aFacing > 1; + public boolean isFacingValid(ForgeDirection facing) { + return facing.offsetY == 0; } @Override @@ -154,9 +154,9 @@ public int increaseProgress(int aProgress) { } @Override - public boolean allowCoverOnSide(byte aSide, GT_ItemStack aCoverID) { + public boolean allowCoverOnSide(ForgeDirection side, GT_ItemStack aCoverID) { return (GregTech_API.getCoverBehaviorNew(aCoverID.toStack()) - .isSimpleCover()) && (super.allowCoverOnSide(aSide, aCoverID)); + .isSimpleCover()) && (super.allowCoverOnSide(side, aCoverID)); } @Override @@ -196,14 +196,12 @@ public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlaye @Override public ExtendedFacing getExtendedFacing() { - return ExtendedFacing.of(ForgeDirection.getOrientation(getBaseMetaTileEntity().getFrontFacing())); + return ExtendedFacing.of(getBaseMetaTileEntity().getFrontFacing()); } @Override public void setExtendedFacing(ExtendedFacing alignment) { - getBaseMetaTileEntity().setFrontFacing( - (byte) alignment.getDirection() - .ordinal()); + getBaseMetaTileEntity().setFrontFacing(alignment.getDirection()); } @Override @@ -329,7 +327,7 @@ public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) { public void onRandomDisplayTick(IGregTechTileEntity aBaseMetaTileEntity) { if (aBaseMetaTileEntity.isActive()) { - final byte frontFacing = aBaseMetaTileEntity.getFrontFacing(); + final ForgeDirection frontFacing = aBaseMetaTileEntity.getFrontFacing(); final double oX = aBaseMetaTileEntity.getOffsetX(frontFacing, 1) + 0.5D; final double oY = aBaseMetaTileEntity.getOffsetY(frontFacing, 1); @@ -341,13 +339,13 @@ public void onRandomDisplayTick(IGregTechTileEntity aBaseMetaTileEntity) { y = oY + XSTR_INSTANCE.nextFloat() * 10D / 16D + 5D / 16D; - if (frontFacing == ForgeDirection.WEST.ordinal()) { + if (frontFacing == ForgeDirection.WEST) { x = oX - offset; z = oZ + horizontal; - } else if (frontFacing == ForgeDirection.EAST.ordinal()) { + } else if (frontFacing == ForgeDirection.EAST) { x = oX + offset; z = oZ + horizontal; - } else if (frontFacing == ForgeDirection.NORTH.ordinal()) { + } else if (frontFacing == ForgeDirection.NORTH) { x = oX + horizontal; z = oZ - offset; } else // if (frontFacing == ForgeDirection.SOUTH.ordinal()) @@ -441,12 +439,14 @@ public boolean isGivingInformation() { } @Override - public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { return aIndex > INPUT_SLOTS; } @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { return !GT_Utility.areStacksEqual(aStack, this.mInventory[0]); } 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 6e60396af4f..ff8178ad783 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 @@ -24,6 +24,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; import com.google.common.collect.ImmutableList; @@ -115,9 +116,9 @@ public boolean addToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasing } @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, - boolean aActive, boolean aRedstone) { - if (aSide == aFacing) { + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection aFacing, + int colorIndex, boolean aActive, boolean redstoneLevel) { + if (side == aFacing) { if (aActive) return new ITexture[] { BlockIcons.casingTexturePages[0][48], TextureFactory.builder() .addIcon(OVERLAY_FRONT_PROCESSING_ARRAY_ACTIVE) .extFacing() @@ -453,10 +454,10 @@ protected GT_Single_Recipe_Check loadSingleRecipeChecker(NBTTagCompound aNBT) { } @Override - public final void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + public final void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { if (aPlayer.isSneaking()) { // Lock to single recipe - super.onScrewdriverRightClick(aSide, aPlayer, aX, aY, aZ); + super.onScrewdriverRightClick(side, aPlayer, aX, aY, aZ); } else { inputSeparation = !inputSeparation; GT_Utility.sendChatToPlayer( @@ -466,8 +467,8 @@ public final void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, floa } @Override - public boolean onWireCutterRightClick(byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, - float aZ) { + public boolean onWireCutterRightClick(ForgeDirection side, ForgeDirection wrenchingSide, EntityPlayer aPlayer, + float aX, float aY, float aZ) { if (aPlayer.isSneaking()) { batchMode = !batchMode; if (batchMode) { 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 90bfa181381..d9b9d3c9435 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 @@ -118,10 +118,10 @@ protected GT_Multiblock_Tooltip_Builder createTooltip() { } @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, - boolean aActive, boolean aRedstone) { - if (aSide == aFacing) { - if (aActive) return new ITexture[] { BlockIcons.casingTexturePages[8][66], TextureFactory.builder() + public ITexture[] getTexture(IGregTechTileEntity baseMetaTileEntity, ForgeDirection sideDirection, + ForgeDirection facingDirection, int colorIndex, boolean active, boolean redstoneLevel) { + if (sideDirection == facingDirection) { + if (active) return new ITexture[] { BlockIcons.casingTexturePages[8][66], TextureFactory.builder() .addIcon(OVERLAY_FRONT_PYROLYSE_OVEN_ACTIVE) .extFacing() .build(), @@ -263,11 +263,11 @@ public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { } private void replaceDeprecatedCoils(IGregTechTileEntity aBaseMetaTileEntity) { - int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; - int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; - int tX = aBaseMetaTileEntity.getXCoord() + xDir * 2; - int tY = aBaseMetaTileEntity.getYCoord(); - int tZ = aBaseMetaTileEntity.getZCoord() + zDir * 2; + final int xDir = aBaseMetaTileEntity.getBackFacing().offsetX; + final int zDir = aBaseMetaTileEntity.getBackFacing().offsetZ; + final int tX = aBaseMetaTileEntity.getXCoord() + xDir * 2; + final int tY = aBaseMetaTileEntity.getYCoord(); + final int tZ = aBaseMetaTileEntity.getZCoord() + zDir * 2; for (int xPos = tX - 1; xPos <= tX + 1; xPos++) { for (int zPos = tZ - 1; zPos <= tZ + 1; zPos++) { if (aBaseMetaTileEntity.getBlock(xPos, tY, zPos) == GregTech_API.sBlockCasings1 diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_TranscendentPlasmaMixer.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_TranscendentPlasmaMixer.java index b8d9b008e22..2c1b7dae571 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_TranscendentPlasmaMixer.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_TranscendentPlasmaMixer.java @@ -13,6 +13,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; @@ -98,9 +99,9 @@ public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { } @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, - boolean aActive, boolean aRedstone) { - if (aSide == aFacing) { + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection aFacing, + int colorIndex, boolean aActive, boolean redstoneLevel) { + if (side == aFacing) { if (aActive) return new ITexture[] { casingTexturePages[0][DIM_TRANS_CASING], TextureFactory.builder() .addIcon(OVERLAY_DTPF_ON) .extFacing() 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 19bd46df5d0..1d86dfecce4 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 @@ -7,6 +7,7 @@ import static gregtech.api.enums.Textures.BlockIcons.casingTexturePages; import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; import com.gtnewhorizon.structurelib.structure.IStructureElement; @@ -59,10 +60,10 @@ protected GT_Multiblock_Tooltip_Builder createTooltip() { } @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, - boolean aActive, boolean aRedstone) { + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection aFacing, + int colorIndex, boolean aActive, boolean redstoneLevel) { ITexture[] rTexture; - if (aSide == aFacing) { + if (side == aFacing) { if (aActive) { rTexture = new ITexture[] { casingTexturePages[0][17], TextureFactory.builder() .addIcon(OVERLAY_FRONT_VACUUM_FREEZER_ACTIVE) diff --git a/src/main/java/gregtech/common/tileentities/machines/steam/GT_MetaTileEntity_ForgeHammer_Bronze.java b/src/main/java/gregtech/common/tileentities/machines/steam/GT_MetaTileEntity_ForgeHammer_Bronze.java index 64ae331f99a..8fce81c676b 100644 --- a/src/main/java/gregtech/common/tileentities/machines/steam/GT_MetaTileEntity_ForgeHammer_Bronze.java +++ b/src/main/java/gregtech/common/tileentities/machines/steam/GT_MetaTileEntity_ForgeHammer_Bronze.java @@ -140,9 +140,9 @@ public void onRandomDisplayTick(IGregTechTileEntity aBaseMetaTileEntity) { // Random Sparkles at main face if (aBaseMetaTileEntity.isActive() && XSTR_INSTANCE.nextInt(3) == 0) { - final byte mainFacing = (byte) this.mMainFacing; + final ForgeDirection mainFacing = this.mMainFacing; - if (mainFacing > 1 && aBaseMetaTileEntity.getCoverIDAtSide(mainFacing) == 0 + if (mainFacing.ordinal() > 1 && aBaseMetaTileEntity.getCoverIDAtSide(mainFacing) == 0 && !aBaseMetaTileEntity.getOpacityAtSide(mainFacing)) { final double oX = aBaseMetaTileEntity.getXCoord(); @@ -155,17 +155,17 @@ public void onRandomDisplayTick(IGregTechTileEntity aBaseMetaTileEntity) { y = oY + XSTR_INSTANCE.nextFloat() * 10D / 16D + 5D / 16D; - if (mainFacing == ForgeDirection.WEST.ordinal()) { + if (mainFacing == ForgeDirection.WEST) { x = oX - offset; mX = -.05D; z = oZ + horizontal; mZ = 0D; - } else if (mainFacing == ForgeDirection.EAST.ordinal()) { + } else if (mainFacing == ForgeDirection.EAST) { x = oX + offset; mX = .05D; z = oZ + horizontal; mZ = 0D; - } else if (mainFacing == ForgeDirection.NORTH.ordinal()) { + } else if (mainFacing == ForgeDirection.NORTH) { x = oX + horizontal; mX = 0D; z = oZ - offset; diff --git a/src/main/java/gregtech/common/tileentities/machines/steam/GT_MetaTileEntity_ForgeHammer_Steel.java b/src/main/java/gregtech/common/tileentities/machines/steam/GT_MetaTileEntity_ForgeHammer_Steel.java index 75aaf480780..3fc2d45e38c 100644 --- a/src/main/java/gregtech/common/tileentities/machines/steam/GT_MetaTileEntity_ForgeHammer_Steel.java +++ b/src/main/java/gregtech/common/tileentities/machines/steam/GT_MetaTileEntity_ForgeHammer_Steel.java @@ -140,9 +140,9 @@ public void onRandomDisplayTick(IGregTechTileEntity aBaseMetaTileEntity) { // Random Sparkles at main face if (aBaseMetaTileEntity.isActive() && XSTR_INSTANCE.nextInt(3) == 0) { - final byte mainFacing = (byte) this.mMainFacing; + final ForgeDirection mainFacing = this.mMainFacing; - if (mainFacing > 1 && aBaseMetaTileEntity.getCoverIDAtSide(mainFacing) == 0 + if (mainFacing.ordinal() > 1 && aBaseMetaTileEntity.getCoverIDAtSide(mainFacing) == 0 && !aBaseMetaTileEntity.getOpacityAtSide(mainFacing)) { final double oX = aBaseMetaTileEntity.getXCoord(); @@ -155,17 +155,17 @@ public void onRandomDisplayTick(IGregTechTileEntity aBaseMetaTileEntity) { y = oY + XSTR_INSTANCE.nextFloat() * 10D / 16D + 5D / 16D; - if (mainFacing == ForgeDirection.WEST.ordinal()) { + if (mainFacing == ForgeDirection.WEST) { x = oX - offset; mX = -.05D; z = oZ + horizontal; mZ = 0D; - } else if (mainFacing == ForgeDirection.EAST.ordinal()) { + } else if (mainFacing == ForgeDirection.EAST) { x = oX + offset; mX = .05D; z = oZ + horizontal; mZ = 0D; - } else if (mainFacing == ForgeDirection.NORTH.ordinal()) { + } else if (mainFacing == ForgeDirection.NORTH) { x = oX + horizontal; mX = 0D; z = oZ - offset; diff --git a/src/main/java/gregtech/common/tileentities/machines/steam/GT_MetaTileEntity_Furnace_Bronze.java b/src/main/java/gregtech/common/tileentities/machines/steam/GT_MetaTileEntity_Furnace_Bronze.java index 088292548ae..1f224553111 100644 --- a/src/main/java/gregtech/common/tileentities/machines/steam/GT_MetaTileEntity_Furnace_Bronze.java +++ b/src/main/java/gregtech/common/tileentities/machines/steam/GT_MetaTileEntity_Furnace_Bronze.java @@ -3,6 +3,7 @@ import static gregtech.api.enums.Textures.BlockIcons.*; import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; import gregtech.api.enums.SoundResource; import gregtech.api.interfaces.ITexture; @@ -54,9 +55,9 @@ public int checkRecipe() { } @Override - protected boolean allowPutStackValidated(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, + protected boolean allowPutStackValidated(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, ItemStack aStack) { - return super.allowPutStackValidated(aBaseMetaTileEntity, aIndex, aSide, aStack) + return super.allowPutStackValidated(aBaseMetaTileEntity, aIndex, side, aStack) && GT_ModHandler.getSmeltingOutput(GT_Utility.copyAmount(64L, aStack), false, null) != null; } diff --git a/src/main/java/gregtech/common/tileentities/machines/steam/GT_MetaTileEntity_Furnace_Steel.java b/src/main/java/gregtech/common/tileentities/machines/steam/GT_MetaTileEntity_Furnace_Steel.java index 49663fd852a..4c2d039a8ed 100644 --- a/src/main/java/gregtech/common/tileentities/machines/steam/GT_MetaTileEntity_Furnace_Steel.java +++ b/src/main/java/gregtech/common/tileentities/machines/steam/GT_MetaTileEntity_Furnace_Steel.java @@ -3,6 +3,7 @@ import static gregtech.api.enums.Textures.BlockIcons.*; import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; import gregtech.api.enums.SoundResource; import gregtech.api.interfaces.ITexture; @@ -54,9 +55,9 @@ public int checkRecipe() { } @Override - protected boolean allowPutStackValidated(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, + protected boolean allowPutStackValidated(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, ItemStack aStack) { - return super.allowPutStackValidated(aBaseMetaTileEntity, aIndex, aSide, aStack) + return super.allowPutStackValidated(aBaseMetaTileEntity, aIndex, side, aStack) && GT_ModHandler.getSmeltingOutput(GT_Utility.copyAmount(64L, aStack), false, null) != null; } diff --git a/src/main/java/gregtech/common/tileentities/machines/steam/GT_MetaTileEntity_Macerator_Bronze.java b/src/main/java/gregtech/common/tileentities/machines/steam/GT_MetaTileEntity_Macerator_Bronze.java index 7481b8716aa..7097d68525d 100644 --- a/src/main/java/gregtech/common/tileentities/machines/steam/GT_MetaTileEntity_Macerator_Bronze.java +++ b/src/main/java/gregtech/common/tileentities/machines/steam/GT_MetaTileEntity_Macerator_Bronze.java @@ -44,11 +44,9 @@ public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { super.onPreTick(aBaseMetaTileEntity, aTick); if (aBaseMetaTileEntity.isClientSide() && aBaseMetaTileEntity.isActive()) { - final byte topFacing = (byte) ForgeDirection.UP.ordinal(); - - if (aBaseMetaTileEntity.getFrontFacing() != topFacing - && aBaseMetaTileEntity.getCoverIDAtSide(topFacing) == 0 - && !aBaseMetaTileEntity.getOpacityAtSide(topFacing)) { + if (aBaseMetaTileEntity.getFrontFacing() != ForgeDirection.UP + && aBaseMetaTileEntity.getCoverIDAtSide(ForgeDirection.UP) == 0 + && !aBaseMetaTileEntity.getOpacityAtSide(ForgeDirection.UP)) { new ParticleEventBuilder().setMotion(0.0D, 0.0D, 0.0D) .setIdentifier(ParticleFX.SMOKE) @@ -86,9 +84,9 @@ public int checkRecipe() { } @Override - protected boolean allowPutStackValidated(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, + protected boolean allowPutStackValidated(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, ItemStack aStack) { - return super.allowPutStackValidated(aBaseMetaTileEntity, aIndex, aSide, aStack) + return super.allowPutStackValidated(aBaseMetaTileEntity, aIndex, side, aStack) && GT_Recipe_Map.sMaceratorRecipes.containsInput(GT_Utility.copyAmount(64L, aStack)); } diff --git a/src/main/java/gregtech/common/tileentities/machines/steam/GT_MetaTileEntity_Macerator_Steel.java b/src/main/java/gregtech/common/tileentities/machines/steam/GT_MetaTileEntity_Macerator_Steel.java index fb270fc95f1..2c221a273ac 100644 --- a/src/main/java/gregtech/common/tileentities/machines/steam/GT_MetaTileEntity_Macerator_Steel.java +++ b/src/main/java/gregtech/common/tileentities/machines/steam/GT_MetaTileEntity_Macerator_Steel.java @@ -43,12 +43,9 @@ public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { super.onPreTick(aBaseMetaTileEntity, aTick); if (aBaseMetaTileEntity.isClientSide() && aBaseMetaTileEntity.isActive()) { - - final byte topFacing = (byte) ForgeDirection.UP.ordinal(); - - if (aBaseMetaTileEntity.getFrontFacing() != topFacing - && aBaseMetaTileEntity.getCoverIDAtSide(topFacing) == 0 - && !aBaseMetaTileEntity.getOpacityAtSide(topFacing)) { + if (aBaseMetaTileEntity.getFrontFacing() != ForgeDirection.UP + && aBaseMetaTileEntity.getCoverIDAtSide(ForgeDirection.UP) == 0 + && !aBaseMetaTileEntity.getOpacityAtSide(ForgeDirection.UP)) { new WorldSpawnedEventBuilder.ParticleEventBuilder().setMotion(0.0D, 0.0D, 0.0D) .setIdentifier(ParticleFX.SMOKE) @@ -86,9 +83,9 @@ public int checkRecipe() { } @Override - public boolean allowPutStackValidated(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, + public boolean allowPutStackValidated(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, ItemStack aStack) { - return super.allowPutStackValidated(aBaseMetaTileEntity, aIndex, aSide, aStack) + return super.allowPutStackValidated(aBaseMetaTileEntity, aIndex, side, aStack) && GT_Recipe_Map.sMaceratorRecipes.containsInput(GT_Utility.copyAmount(64L, aStack)); } diff --git a/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_DigitalChestBase.java b/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_DigitalChestBase.java index aeced754fec..ec8eade5da9 100644 --- a/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_DigitalChestBase.java +++ b/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_DigitalChestBase.java @@ -20,6 +20,7 @@ import net.minecraft.util.StatCollector; import net.minecraft.world.World; import net.minecraftforge.common.util.Constants; +import net.minecraftforge.common.util.ForgeDirection; import appeng.api.storage.IMEMonitor; import appeng.api.storage.IMEMonitorHandlerReceiver; @@ -274,7 +275,7 @@ public StorageChannel getChannel() { } @Override - public final void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + public final void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { mVoidOverflow = !mVoidOverflow; GT_Utility.sendChatToPlayer( aPlayer, @@ -284,9 +285,9 @@ public final void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, floa } @Override - public boolean onSolderingToolRightClick(byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, - float aZ) { - if (super.onSolderingToolRightClick(aSide, aWrenchingSide, aPlayer, aX, aY, aZ)) return true; + public boolean onSolderingToolRightClick(ForgeDirection side, ForgeDirection wrenchingSide, EntityPlayer aPlayer, + float aX, float aY, float aZ) { + if (super.onSolderingToolRightClick(side, wrenchingSide, aPlayer, aX, aY, aZ)) return true; mDisableFilter = !mDisableFilter; GT_Utility.sendChatToPlayer( aPlayer, @@ -355,7 +356,7 @@ public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlaye } @Override - public boolean isFacingValid(byte aFacing) { + public boolean isFacingValid(ForgeDirection facing) { return true; } @@ -467,13 +468,15 @@ public void loadNBTData(NBTTagCompound aNBT) { } @Override - public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { if (GregTech_API.mAE2 && GT_Values.disableDigitalChestsExternalAccess && hasActiveMEConnection()) return false; return aIndex == 1; } @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { if (GregTech_API.mAE2 && GT_Values.disableDigitalChestsExternalAccess && hasActiveMEConnection()) return false; if (aIndex != 0) return false; if ((mInventory[0] != null && !GT_Utility.areStacksEqual(mInventory[0], aStack))) return false; @@ -483,10 +486,10 @@ public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex } @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, - boolean aActive, boolean aRedstone) { - if (aSide != aFacing) return new ITexture[] { MACHINE_CASINGS[mTier][aColorIndex + 1] }; - return new ITexture[] { MACHINE_CASINGS[mTier][aColorIndex + 1], TextureFactory.of(OVERLAY_SCHEST), + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection aFacing, + int colorIndex, boolean aActive, boolean redstoneLevel) { + if (side != aFacing) return new ITexture[] { MACHINE_CASINGS[mTier][colorIndex + 1] }; + return new ITexture[] { MACHINE_CASINGS[mTier][colorIndex + 1], TextureFactory.of(OVERLAY_SCHEST), TextureFactory.builder() .addIcon(OVERLAY_SCHEST_GLOW) .glow() @@ -497,7 +500,7 @@ public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide public void getWailaBody(ItemStack itemStack, List currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) { super.getWailaBody(itemStack, currenttip, accessor, config); - NBTTagCompound tag = accessor.getNBTData(); + final NBTTagCompound tag = accessor.getNBTData(); if (tag.hasKey("itemType", Constants.NBT.TAG_COMPOUND)) { currenttip.add("Item Count: " + GT_Utility.parseNumberToString(tag.getInteger("itemCount"))); currenttip.add( diff --git a/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_DigitalTankBase.java b/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_DigitalTankBase.java index 14f15015277..822b4e0f6f3 100644 --- a/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_DigitalTankBase.java +++ b/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_DigitalTankBase.java @@ -268,14 +268,14 @@ public boolean allowChangingLockedFluid(String name) { } @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, - boolean aActive, boolean aRedstone) { - if (aSide != ForgeDirection.UP.ordinal()) { - if (aSide == aBaseMetaTileEntity.getFrontFacing()) { - return new ITexture[] { MACHINE_CASINGS[mTier][aColorIndex + 1], TextureFactory.of(OVERLAY_PIPE) }; - } else return new ITexture[] { MACHINE_CASINGS[mTier][aColorIndex + 1] }; + public ITexture[] getTexture(IGregTechTileEntity baseMetaTileEntity, ForgeDirection sideDirection, + ForgeDirection facingDirection, int colorIndex, boolean active, boolean redstoneLevel) { + if (sideDirection != ForgeDirection.UP) { + if (sideDirection == baseMetaTileEntity.getFrontFacing()) { + return new ITexture[] { MACHINE_CASINGS[mTier][colorIndex + 1], TextureFactory.of(OVERLAY_PIPE) }; + } else return new ITexture[] { MACHINE_CASINGS[mTier][colorIndex + 1] }; } - return new ITexture[] { MACHINE_CASINGS[mTier][aColorIndex + 1], TextureFactory.of(OVERLAY_QTANK), + return new ITexture[] { MACHINE_CASINGS[mTier][colorIndex + 1], TextureFactory.of(OVERLAY_QTANK), TextureFactory.builder() .addIcon(OVERLAY_QTANK_GLOW) .glow() @@ -289,8 +289,8 @@ public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlaye } @Override - public final void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { - if (aSide == getBaseMetaTileEntity().getFrontFacing()) { + public final void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (side == getBaseMetaTileEntity().getFrontFacing()) { mAllowInputFromOutputSide = !mAllowInputFromOutputSide; GT_Utility.sendChatToPlayer( aPlayer, @@ -411,12 +411,9 @@ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { if (tTank != null) { FluidStack tDrained = drain(20 * (1 << (3 + 2 * tierPump(mTier))), false); if (tDrained != null) { - int tFilledAmount = tTank - .fill(ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()), tDrained, false); - if (tFilledAmount > 0) tTank.fill( - ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()), - drain(tFilledAmount, true), - true); + int tFilledAmount = tTank.fill(aBaseMetaTileEntity.getBackFacing(), tDrained, false); + if (tFilledAmount > 0) + tTank.fill(aBaseMetaTileEntity.getBackFacing(), drain(tFilledAmount, true), true); } } } @@ -424,27 +421,27 @@ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { } @Override - public boolean isFacingValid(byte aFacing) { + public boolean isFacingValid(ForgeDirection side) { return true; } @Override - public boolean isInputFacing(byte aSide) { + public boolean isInputFacing(ForgeDirection side) { return true; } @Override - public boolean isOutputFacing(byte aSide) { + public boolean isOutputFacing(ForgeDirection side) { return false; } @Override - public boolean isLiquidInput(byte aSide) { - return mAllowInputFromOutputSide || aSide != getBaseMetaTileEntity().getFrontFacing(); + public boolean isLiquidInput(ForgeDirection side) { + return mAllowInputFromOutputSide || side != getBaseMetaTileEntity().getFrontFacing(); } @Override - public boolean isLiquidOutput(byte aSide) { + public boolean isLiquidOutput(ForgeDirection side) { return true; } @@ -478,7 +475,7 @@ public FluidTankInfo getInfo() { } @Override - public FluidTankInfo[] getTankInfo(ForgeDirection aSide) { + public FluidTankInfo[] getTankInfo(ForgeDirection side) { return new FluidTankInfo[] { getInfo() }; } diff --git a/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_Locker.java b/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_Locker.java index 32d1694cc82..9779d696eaa 100644 --- a/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_Locker.java +++ b/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_Locker.java @@ -8,6 +8,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.ForgeDirection; import gregtech.api.enums.SoundResource; import gregtech.api.interfaces.ITexture; @@ -57,13 +58,13 @@ public ITexture[][][] getTextureSet(ITexture[] aTextures) { } @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, - boolean aActive, boolean aRedstone) { - if (aSide == aFacing) { - return new ITexture[] { this.mTextures[2][(aColorIndex + 1)][0], this.mTextures[2][(aColorIndex + 1)][1], + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection aFacing, + int colorIndex, boolean aActive, boolean redstoneLevel) { + if (side == aFacing) { + return new ITexture[] { this.mTextures[2][(colorIndex + 1)][0], this.mTextures[2][(colorIndex + 1)][1], LOCKERS[Math.abs(this.mType % LOCKERS.length)] }; } - return this.mTextures[0][(aColorIndex + 1)]; + return this.mTextures[0][(colorIndex + 1)]; } @Override @@ -87,8 +88,8 @@ public boolean isValidSlot(int aIndex) { } @Override - public boolean isFacingValid(byte aFacing) { - return aFacing > 1; + public boolean isFacingValid(ForgeDirection facing) { + return facing.offsetY == 0; } @Override @@ -97,8 +98,8 @@ public boolean isEnetInput() { } @Override - public boolean isInputFacing(byte aSide) { - return aSide == getBaseMetaTileEntity().getBackFacing(); + public boolean isInputFacing(ForgeDirection side) { + return side == getBaseMetaTileEntity().getBackFacing(); } @Override @@ -164,21 +165,21 @@ public void doSound(byte aIndex, double aX, double aY, double aZ) { } @Override - public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { - if (aSide == getBaseMetaTileEntity().getFrontFacing()) { + public void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (side == getBaseMetaTileEntity().getFrontFacing()) { this.mType = ((byte) (this.mType + 1)); } } @Override - public boolean allowCoverOnSide(byte aSide, GT_ItemStack aStack) { - return aSide != getBaseMetaTileEntity().getFrontFacing(); + public boolean allowCoverOnSide(ForgeDirection side, GT_ItemStack aStack) { + return side != getBaseMetaTileEntity().getFrontFacing(); } @Override - public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, byte aSide, float aX, - float aY, float aZ) { - if ((aBaseMetaTileEntity.isServerSide()) && (aSide == aBaseMetaTileEntity.getFrontFacing())) { + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, ForgeDirection side, + float aX, float aY, float aZ) { + if ((aBaseMetaTileEntity.isServerSide()) && (side == aBaseMetaTileEntity.getFrontFacing())) { for (int i = 0; i < 4; i++) { ItemStack tSwapStack = this.mInventory[i]; this.mInventory[i] = aPlayer.inventory.armorInventory[i]; @@ -191,12 +192,14 @@ public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlaye } @Override - public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { return false; } @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { return false; } } diff --git a/src/main/java/gregtech/loaders/postload/PartP2PGTPower.java b/src/main/java/gregtech/loaders/postload/PartP2PGTPower.java index 080ae1b00bf..53f73872e17 100644 --- a/src/main/java/gregtech/loaders/postload/PartP2PGTPower.java +++ b/src/main/java/gregtech/loaders/postload/PartP2PGTPower.java @@ -15,7 +15,6 @@ import appeng.parts.p2p.PartP2PIC2Power; import gregtech.api.interfaces.tileentity.IEnergyConnected; import gregtech.api.util.GT_Log; -import gregtech.api.util.GT_Utility; public class PartP2PGTPower extends PartP2PIC2Power implements IGridTickable { @@ -39,24 +38,26 @@ public final int getZCoord() { return getTile().zCoord; } - public final int getOffsetX(byte aSide, int aMultiplier) { - return getXCoord() + ForgeDirection.getOrientation(aSide).offsetX * aMultiplier; + public final int getOffsetX(ForgeDirection side, int aMultiplier) { + return getXCoord() + side.offsetX * aMultiplier; } - public final short getOffsetY(byte aSide, int aMultiplier) { - return (short) (getYCoord() + ForgeDirection.getOrientation(aSide).offsetY * aMultiplier); + public final short getOffsetY(ForgeDirection side, int aMultiplier) { + return (short) (getYCoord() + side.offsetY * aMultiplier); } - public final int getOffsetZ(byte aSide, int aMultiplier) { - return getZCoord() + ForgeDirection.getOrientation(aSide).offsetZ * aMultiplier; + public final int getOffsetZ(ForgeDirection side, int aMultiplier) { + return getZCoord() + side.offsetZ * aMultiplier; } public final TileEntity getTileEntity(int aX, int aY, int aZ) { return getWorld().getTileEntity(aX, aY, aZ); } - public final TileEntity getTileEntityAtSide(byte aSide) { - int tX = getOffsetX(aSide, 1), tY = getOffsetY(aSide, 1), tZ = getOffsetZ(aSide, 1); + public final TileEntity getTileEntityAtSide(ForgeDirection side) { + final int tX = getOffsetX(side, 1); + final int tY = getOffsetY(side, 1); + final int tZ = getOffsetZ(side, 1); return getWorld().getTileEntity(tX, tY, tZ); } @@ -64,14 +65,13 @@ public boolean outputEnergy() { if (getOfferedEnergy() == 0) { return false; } - TileEntity t = getTileEntityAtSide((byte) getSide().ordinal()); - if (t instanceof IEnergyConnected) { + final TileEntity te = getTileEntityAtSide(getSide()); + if (te instanceof IEnergyConnected energyConnected) { long voltage = 8 << (getSourceTier() * 2); if (voltage > getOfferedEnergy()) { voltage = (long) getOfferedEnergy(); } - if (((IEnergyConnected) t).injectEnergyUnits(GT_Utility.getOppositeSide(getSide().ordinal()), voltage, 1) - > 0) { + if (energyConnected.injectEnergyUnits(getSide().getOpposite(), voltage, 1) > 0) { drawEnergy(voltage); return true; }