From 8296a8dc32c80021fcf1a4412d6580458ed359b4 Mon Sep 17 00:00:00 2001 From: Rseifert Date: Sat, 3 Nov 2012 00:34:54 -0400 Subject: [PATCH] added a Quick api Need a way to detect belt for my Mining Machin mod so i added an iterface to find each instance of a belt. As well what items are above this belt, what direction its facing, and quick add entities to it ignore list. --- src/common/assemblyline/api/IBelt.java | 28 +++++++++++++++++++ src/common/assemblyline/api/IBotArm.java | 5 ++++ .../belts/TileEntityConveyorBelt.java | 27 ++++++++++-------- 3 files changed, 49 insertions(+), 11 deletions(-) create mode 100644 src/common/assemblyline/api/IBelt.java create mode 100644 src/common/assemblyline/api/IBotArm.java diff --git a/src/common/assemblyline/api/IBelt.java b/src/common/assemblyline/api/IBelt.java new file mode 100644 index 000000000..ce06fbddb --- /dev/null +++ b/src/common/assemblyline/api/IBelt.java @@ -0,0 +1,28 @@ +package assemblyline.api; + +import java.util.List; + +import net.minecraft.src.Entity; +import net.minecraftforge.common.ForgeDirection; + +public interface IBelt { + /** + * Gets the facing direction of the belt, used but other machines to know + * which direction to start an item at + * + * @return + */ + public ForgeDirection getFacing(); + /** + * Causes the belt to ignore the entity for a few updates + * help in cases where another machine need to effect this entity + * without the belt doing so as well. + * @param entity - entity being ignored + */ + public void ignoreEntity(Entity entity); + /** + * Used to get a list of entities above this belt + * @return list of entities + */ + public List getEntityAbove(); +} diff --git a/src/common/assemblyline/api/IBotArm.java b/src/common/assemblyline/api/IBotArm.java new file mode 100644 index 000000000..53c3eaf7b --- /dev/null +++ b/src/common/assemblyline/api/IBotArm.java @@ -0,0 +1,5 @@ +package assemblyline.api; + +public interface IBotArm { +//TODO will add methods here to change the arms task, target, location,etc as need by other mods +} diff --git a/src/common/assemblyline/belts/TileEntityConveyorBelt.java b/src/common/assemblyline/belts/TileEntityConveyorBelt.java index 50a299139..30b14e8e8 100644 --- a/src/common/assemblyline/belts/TileEntityConveyorBelt.java +++ b/src/common/assemblyline/belts/TileEntityConveyorBelt.java @@ -19,10 +19,11 @@ import universalelectricity.prefab.TileEntityElectricityReceiver; import universalelectricity.prefab.network.IPacketReceiver; import universalelectricity.prefab.network.PacketManager; import assemblyline.AssemblyLine; +import assemblyline.api.IBelt; import com.google.common.io.ByteArrayDataInput; -public class TileEntityConveyorBelt extends TileEntityElectricityReceiver implements IPacketReceiver +public class TileEntityConveyorBelt extends TileEntityElectricityReceiver implements IPacketReceiver, IBelt { /** * Joules required to run this thing. @@ -124,10 +125,10 @@ public class TileEntityConveyorBelt extends TileEntityElectricityReceiver implem if (this.running) { - AxisAlignedBB bounds = AxisAlignedBB.getBoundingBox(this.xCoord, this.yCoord, this.zCoord, this.xCoord + 1, this.yCoord + 1, this.zCoord + 1); + try { - List entityOnTop = worldObj.getEntitiesWithinAABB(Entity.class, bounds); + List entityOnTop = this.getEntityAbove(); for (Entity entity : entityOnTop) { @@ -297,14 +298,6 @@ public class TileEntityConveyorBelt extends TileEntityElectricityReceiver implem } - /** - * Used to tell the belt not to apply velocity - * to some Entity in case they are being - * handled by another block. For example - * Rejector - * - * @param entity - */ public void ignoreEntity(Entity entity) { if (!this.entityIgnoreList.contains(entity)) @@ -313,4 +306,16 @@ public class TileEntityConveyorBelt extends TileEntityElectricityReceiver implem } } + + @Override + public ForgeDirection getFacing() { + + return ForgeDirection.getOrientation(this.getBeltDirection()); + } + + public List getEntityAbove() + { + AxisAlignedBB bounds = AxisAlignedBB.getBoundingBox(this.xCoord, this.yCoord, this.zCoord, this.xCoord + 1, this.yCoord + 1, this.zCoord + 1); + return worldObj.getEntitiesWithinAABB(Entity.class, bounds); + } }