diff options
author | Kiwi <42833050+Kiwi233@users.noreply.github.com> | 2020-05-24 08:28:19 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-24 08:28:19 +0800 |
commit | f0bce85d3faf040d87a22d83250ae2d9767c3642 (patch) | |
tree | ed60c1d975c8b06a27cae03d148714f7bb9e9805 /src/main/java/gregtech/api/interfaces/metatileentity | |
parent | ac7282a30ef161101cabc921e52db5c5d7e0096c (diff) | |
parent | d6c19a9b6434c8a4c59ea8452603f85cfd2ad208 (diff) | |
download | GT5-Unofficial-f0bce85d3faf040d87a22d83250ae2d9767c3642.tar.gz GT5-Unofficial-f0bce85d3faf040d87a22d83250ae2d9767c3642.tar.bz2 GT5-Unofficial-f0bce85d3faf040d87a22d83250ae2d9767c3642.zip |
Merge pull request #1 from GTNewHorizons/experimental
5/24
Diffstat (limited to 'src/main/java/gregtech/api/interfaces/metatileentity')
4 files changed, 152 insertions, 134 deletions
diff --git a/src/main/java/gregtech/api/interfaces/metatileentity/IConnectable.java b/src/main/java/gregtech/api/interfaces/metatileentity/IConnectable.java index 96c03bbd6d..bc822250fd 100644 --- a/src/main/java/gregtech/api/interfaces/metatileentity/IConnectable.java +++ b/src/main/java/gregtech/api/interfaces/metatileentity/IConnectable.java @@ -1,18 +1,19 @@ -package gregtech.api.interfaces.metatileentity;
-
-/**
- * For pipes, wires, and other MetaTiles which need to be decided whether they should connect to the block at each side.
- */
-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.
- */
- public int connect(byte aSide);
- /**
- * Try to disconnect to the Block at the specified side
- */
- public void disconnect(byte aSide);
-
- public boolean isConnectedAtSide(int aSide);
-}
+package gregtech.api.interfaces.metatileentity; + +/** + * For pipes, wires, and other MetaTiles which need to be decided whether they should connect to the block at each side. + */ +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); + + /** + * Try to disconnect to the Block at the specified side + */ + void disconnect(byte aSide); + + boolean isConnectedAtSide(int aSide); +} diff --git a/src/main/java/gregtech/api/interfaces/metatileentity/IMetaTileEntity.java b/src/main/java/gregtech/api/interfaces/metatileentity/IMetaTileEntity.java index 1ebeda2895..f0ca426616 100644 --- a/src/main/java/gregtech/api/interfaces/metatileentity/IMetaTileEntity.java +++ b/src/main/java/gregtech/api/interfaces/metatileentity/IMetaTileEntity.java @@ -5,6 +5,7 @@ import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGearEnergyTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.interfaces.tileentity.IMachineBlockUpdateable; import gregtech.api.objects.GT_ItemStack; import gregtech.api.util.GT_Config; import net.minecraft.block.Block; @@ -31,7 +32,7 @@ import java.util.List; * <p/> * Don't implement this yourself and expect it to work. Extend @MetaTileEntity itself. */ -public interface IMetaTileEntity extends ISidedInventory, IFluidTank, IFluidHandler, IGearEnergyTileEntity { +public interface IMetaTileEntity extends ISidedInventory, IFluidTank, IFluidHandler, IGearEnergyTileEntity, IMachineBlockUpdateable { /** * This determines the BaseMetaTileEntity belonging to this MetaTileEntity by using the Meta ID of the Block itself. * <p/> @@ -47,10 +48,10 @@ public interface IMetaTileEntity extends ISidedInventory, IFluidTank, IFluidHand * 9 = BaseMetaPipeEntity, Cutter lvl 1 to dismantle * 10 = BaseMetaPipeEntity, Cutter lvl 2 to dismantle * 11 = BaseMetaPipeEntity, Cutter lvl 3 to dismantle - * 12 = BaseMetaPipeEntity, Axe lvl 0 to dismantle - * 13 = BaseMetaPipeEntity, Axe lvl 1 to dismantle - * 14 = BaseMetaPipeEntity, Axe lvl 2 to dismantle - * 15 = BaseMetaPipeEntity, Axe lvl 3 to dismantle + * 12 = GT++ + * 13 = GT++ + * 14 = GT++ + * 15 = GT++ */ byte getTileEntityBaseType(); @@ -234,11 +235,6 @@ public interface IMetaTileEntity extends ISidedInventory, IFluidTank, IFluidHand boolean isAccessAllowed(EntityPlayer aPlayer); /** - * When a Machine Update occurs - */ - void onMachineBlockUpdate(); - - /** * a Player rightclicks the Machine * Sneaky rightclicks are not getting passed to this! * @@ -389,7 +385,7 @@ public interface IMetaTileEntity extends ISidedInventory, IFluidTank, IFluidHand void onColorChangeClient(byte aColor); int getLightOpacity(); - + boolean allowGeneralRedstoneOutput(); void addCollisionBoxesToList(World aWorld, int aX, int aY, int aZ, AxisAlignedBB inputAABB, List<AxisAlignedBB> outputAABB, Entity collider); @@ -402,8 +398,28 @@ public interface IMetaTileEntity extends ISidedInventory, IFluidTank, IFluidHand * The onCreated Function of the Item Class redirects here */ void onCreated(ItemStack aStack, World aWorld, EntityPlayer aPlayer); - + boolean hasAlternativeModeText(); - + String getAlternativeModeText(); -}
\ No newline at end of file + + boolean shouldJoinIc2Enet(); + + /** + * The Machine Update, which is called when the Machine needs an Update of its Parts. + * I suggest to wait 1-5 seconds before actually checking the Machine Parts. + * RP-Frames could for example cause Problems when you instacheck the Machine Parts. + * + * just do stuff since we are already in meta tile... + */ + @Override + void onMachineBlockUpdate(); + + /** + * just return in should recurse since we are already in meta tile... + */ + @Override + default boolean isMachineBlockUpdateRecursive(){ + return true; + } +} diff --git a/src/main/java/gregtech/api/interfaces/metatileentity/IMetaTileEntityCable.java b/src/main/java/gregtech/api/interfaces/metatileentity/IMetaTileEntityCable.java index ead9c8bf8f..a7c1209d24 100644 --- a/src/main/java/gregtech/api/interfaces/metatileentity/IMetaTileEntityCable.java +++ b/src/main/java/gregtech/api/interfaces/metatileentity/IMetaTileEntityCable.java @@ -7,9 +7,9 @@ import java.util.HashSet; public interface IMetaTileEntityCable extends IMetaTileEntity { @Deprecated - public long transferElectricity(byte aSide, long aVoltage, long aAmperage, ArrayList<TileEntity> aAlreadyPassedTileEntityList); + long transferElectricity(byte aSide, long aVoltage, long aAmperage, ArrayList<TileEntity> aAlreadyPassedTileEntityList); - default public long transferElectricity(byte aSide, long aVoltage, long aAmperage, HashSet<TileEntity> aAlreadyPassedSet) { + default long transferElectricity(byte aSide, long aVoltage, long aAmperage, HashSet<TileEntity> aAlreadyPassedSet) { return transferElectricity(aSide, aVoltage, aAmperage, new ArrayList<>(aAlreadyPassedSet)); } }
\ No newline at end of file diff --git a/src/main/java/gregtech/api/interfaces/metatileentity/IMetaTileEntityItemPipe.java b/src/main/java/gregtech/api/interfaces/metatileentity/IMetaTileEntityItemPipe.java index 7187ccb04b..f136f4f32b 100644 --- a/src/main/java/gregtech/api/interfaces/metatileentity/IMetaTileEntityItemPipe.java +++ b/src/main/java/gregtech/api/interfaces/metatileentity/IMetaTileEntityItemPipe.java @@ -1,100 +1,101 @@ -package gregtech.api.interfaces.metatileentity;
-
-import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
-import gregtech.api.metatileentity.BaseMetaPipeEntity;
-import gregtech.api.util.GT_Utility;
-
-import java.util.Map;
-
-public interface IMetaTileEntityItemPipe extends IMetaTileEntity {
- /**
- * @return if this Pipe can still be used.
- */
- public boolean pipeCapacityCheck();
-
- /**
- * @return if this Pipe can still be used.
- */
- public boolean incrementTransferCounter(int aIncrement);
-
- /**
- * Sends an ItemStack from aSender to the adjacent Blocks.
- *
- * @param aSender the BaseMetaTileEntity sending the Stack.
- * @return if it was able to send something
- */
- public boolean sendItemStack(Object aSender);
-
- /**
- * 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.
- * @return if this Side was allowed to Output into the Block.
- */
- public boolean insertItemStackIntoTileEntity(Object aSender, byte aSide);
-
- /**
- * Can be used to make flow control Pipes, like Redpowers Restriction Tubes.
- * Every normal Pipe returns a Value of 32768, so you can easily insert lower Numbers to set Routing priorities.
- * Negative Numbers to "suck" Items into a certain direction are also possible.
- */
- public int getStepSize();
-
- /**
- * Utility for the Item Network
- */
- public static class Util {
- /**
- * @return a List of connected Item Pipes
- */
- public static Map<IMetaTileEntityItemPipe, Long> scanPipes(IMetaTileEntityItemPipe aMetaTileEntity, Map<IMetaTileEntityItemPipe, Long> aMap, long aStep, boolean aSuckItems, boolean aIgnoreCapacity) {
- aStep += aMetaTileEntity.getStepSize();
- if (aIgnoreCapacity || aMetaTileEntity.pipeCapacityCheck())
- if (aMap.get(aMetaTileEntity) == null || aMap.get(aMetaTileEntity) > aStep) {
- IGregTechTileEntity aBaseMetaTileEntity = aMetaTileEntity.getBaseMetaTileEntity();
- aMap.put(aMetaTileEntity, aStep);
- for (byte i = 0, j = 0; i < 6; i++) {
- if (aMetaTileEntity instanceof IConnectable && !((IConnectable) aMetaTileEntity).isConnectedAtSide(i)) continue;
- j = GT_Utility.getOppositeSide(i);
- if (aSuckItems) {
- if (aBaseMetaTileEntity.getCoverBehaviorAtSide(i).letsItemsIn(i, aBaseMetaTileEntity.getCoverIDAtSide(i), aBaseMetaTileEntity.getCoverDataAtSide(i), -2, aBaseMetaTileEntity)) {
- IGregTechTileEntity tItemPipe = aBaseMetaTileEntity.getIGregTechTileEntityAtSide(i);
- if (aBaseMetaTileEntity.getColorization() >= 0) {
- byte tColor = tItemPipe.getColorization();
- if (tColor >= 0 && tColor != aBaseMetaTileEntity.getColorization()) {
- continue;
- }
- }
- if (tItemPipe instanceof BaseMetaPipeEntity) {
- IMetaTileEntity tMetaTileEntity = tItemPipe.getMetaTileEntity();
- if (tMetaTileEntity instanceof IMetaTileEntityItemPipe && tItemPipe.getCoverBehaviorAtSide(j).letsItemsOut(j, tItemPipe.getCoverIDAtSide(j), tItemPipe.getCoverDataAtSide(j), -2, tItemPipe)) {
- scanPipes((IMetaTileEntityItemPipe) tMetaTileEntity, aMap, aStep, aSuckItems, aIgnoreCapacity);
- }
- }
- }
- } else {
- if (aBaseMetaTileEntity.getCoverBehaviorAtSide(i).letsItemsOut(i, aBaseMetaTileEntity.getCoverIDAtSide(i), aBaseMetaTileEntity.getCoverDataAtSide(i), -2, aBaseMetaTileEntity)) {
- IGregTechTileEntity tItemPipe = aBaseMetaTileEntity.getIGregTechTileEntityAtSide(i);
- if (tItemPipe != null) {
- if (aBaseMetaTileEntity.getColorization() >= 0) {
- byte tColor = tItemPipe.getColorization();
- if (tColor >= 0 && tColor != aBaseMetaTileEntity.getColorization()) {
- continue;
- }
- }
- if (tItemPipe instanceof BaseMetaPipeEntity) {
- IMetaTileEntity tMetaTileEntity = tItemPipe.getMetaTileEntity();
- if (tMetaTileEntity instanceof IMetaTileEntityItemPipe && tItemPipe.getCoverBehaviorAtSide(j).letsItemsIn(j, tItemPipe.getCoverIDAtSide(j), tItemPipe.getCoverDataAtSide(j), -2, tItemPipe)) {
- scanPipes((IMetaTileEntityItemPipe) tMetaTileEntity, aMap, aStep, aSuckItems, aIgnoreCapacity);
- }
- }
- }
- }
- }
- }
- }
- return aMap;
- }
- }
-}
+package gregtech.api.interfaces.metatileentity; + +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.BaseMetaPipeEntity; +import gregtech.api.util.GT_Utility; + +import java.util.Map; + +public interface IMetaTileEntityItemPipe extends IMetaTileEntity { + /** + * @return if this Pipe can still be used. + */ + boolean pipeCapacityCheck(); + + /** + * @return if this Pipe can still be used. + */ + boolean incrementTransferCounter(int aIncrement); + + /** + * Sends an ItemStack from aSender to the adjacent Blocks. + * + * @param aSender the BaseMetaTileEntity sending the Stack. + * @return if it was able to send something + */ + boolean sendItemStack(Object aSender); + + /** + * 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. + * @return if this Side was allowed to Output into the Block. + */ + boolean insertItemStackIntoTileEntity(Object aSender, byte aSide); + + /** + * Can be used to make flow control Pipes, like Redpowers Restriction Tubes. + * Every normal Pipe returns a Value of 32768, so you can easily insert lower Numbers to set Routing priorities. + * Negative Numbers to "suck" Items into a certain direction are also possible. + */ + int getStepSize(); + + /** + * Utility for the Item Network + */ + class Util { + /** + * @return a List of connected Item Pipes + */ + public static Map<IMetaTileEntityItemPipe, Long> scanPipes(IMetaTileEntityItemPipe aMetaTileEntity, Map<IMetaTileEntityItemPipe, Long> aMap, long aStep, boolean aSuckItems, boolean aIgnoreCapacity) { + aStep += aMetaTileEntity.getStepSize(); + if (aIgnoreCapacity || aMetaTileEntity.pipeCapacityCheck()) + if (aMap.get(aMetaTileEntity) == null || aMap.get(aMetaTileEntity) > aStep) { + IGregTechTileEntity aBaseMetaTileEntity = aMetaTileEntity.getBaseMetaTileEntity(); + aMap.put(aMetaTileEntity, aStep); + for (byte i = 0, j = 0; i < 6; i++) { + if (aMetaTileEntity instanceof IConnectable && !((IConnectable) aMetaTileEntity).isConnectedAtSide(i)) + continue; + j = GT_Utility.getOppositeSide(i); + if (aSuckItems) { + if (aBaseMetaTileEntity.getCoverBehaviorAtSide(i).letsItemsIn(i, aBaseMetaTileEntity.getCoverIDAtSide(i), aBaseMetaTileEntity.getCoverDataAtSide(i), -2, aBaseMetaTileEntity)) { + IGregTechTileEntity tItemPipe = aBaseMetaTileEntity.getIGregTechTileEntityAtSide(i); + if (aBaseMetaTileEntity.getColorization() >= 0) { + byte tColor = tItemPipe.getColorization(); + if (tColor >= 0 && tColor != aBaseMetaTileEntity.getColorization()) { + continue; + } + } + if (tItemPipe instanceof BaseMetaPipeEntity) { + IMetaTileEntity tMetaTileEntity = tItemPipe.getMetaTileEntity(); + if (tMetaTileEntity instanceof IMetaTileEntityItemPipe && tItemPipe.getCoverBehaviorAtSide(j).letsItemsOut(j, tItemPipe.getCoverIDAtSide(j), tItemPipe.getCoverDataAtSide(j), -2, tItemPipe)) { + scanPipes((IMetaTileEntityItemPipe) tMetaTileEntity, aMap, aStep, aSuckItems, aIgnoreCapacity); + } + } + } + } else { + if (aBaseMetaTileEntity.getCoverBehaviorAtSide(i).letsItemsOut(i, aBaseMetaTileEntity.getCoverIDAtSide(i), aBaseMetaTileEntity.getCoverDataAtSide(i), -2, aBaseMetaTileEntity)) { + IGregTechTileEntity tItemPipe = aBaseMetaTileEntity.getIGregTechTileEntityAtSide(i); + if (tItemPipe != null) { + if (aBaseMetaTileEntity.getColorization() >= 0) { + byte tColor = tItemPipe.getColorization(); + if (tColor >= 0 && tColor != aBaseMetaTileEntity.getColorization()) { + continue; + } + } + if (tItemPipe instanceof BaseMetaPipeEntity) { + IMetaTileEntity tMetaTileEntity = tItemPipe.getMetaTileEntity(); + if (tMetaTileEntity instanceof IMetaTileEntityItemPipe && tItemPipe.getCoverBehaviorAtSide(j).letsItemsIn(j, tItemPipe.getCoverIDAtSide(j), tItemPipe.getCoverDataAtSide(j), -2, tItemPipe)) { + scanPipes((IMetaTileEntityItemPipe) tMetaTileEntity, aMap, aStep, aSuckItems, aIgnoreCapacity); + } + } + } + } + } + } + } + return aMap; + } + } +} |