diff options
Diffstat (limited to 'src/main/java/gregtech/api/interfaces/metatileentity')
5 files changed, 76 insertions, 52 deletions
diff --git a/src/main/java/gregtech/api/interfaces/metatileentity/IConnectable.java b/src/main/java/gregtech/api/interfaces/metatileentity/IConnectable.java index 76d8d082ef..0ca519d40b 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 a24e05f1a2..c9377d10be 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.nbt.NBTTagCompound; 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 @@ public interface IMetaTileEntity extends ISidedInventory, IFluidTank, IFluidHand 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 @@ public interface IMetaTileEntity extends ISidedInventory, IFluidTank, IFluidHand /** * 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 @@ public interface IMetaTileEntity extends ISidedInventory, IFluidTank, IFluidHand /** * 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 @@ public interface IMetaTileEntity extends ISidedInventory, IFluidTank, IFluidHand 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 @@ public interface IMetaTileEntity extends ISidedInventory, IFluidTank, IFluidHand /** * 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 @@ public interface IMetaTileEntity extends ISidedInventory, IFluidTank, IFluidHand /** * 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 @@ public interface IMetaTileEntity extends ISidedInventory, IFluidTank, IFluidHand 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 3f7bc73383..a2d672e765 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.ArrayList; 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<TileEntity> aAlreadyPassedTileEntityList); - default long transferElectricity(byte aSide, long aVoltage, long aAmperage, HashSet<TileEntity> aAlreadyPassedSet) { - return transferElectricity(aSide, aVoltage, aAmperage, new ArrayList<>(aAlreadyPassedSet)); + default long transferElectricity(ForgeDirection side, long aVoltage, long aAmperage, + HashSet<TileEntity> 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 76d3f56e74..0c2c5ebf28 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 interface IMetaTileEntityItemPipe extends IMetaTileEntity { 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 0000000000..0ac29b2e45 --- /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); +} |