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.
This commit is contained in:
Rseifert 2012-11-03 00:34:54 -04:00
parent 57f8a12c6d
commit 8296a8dc32
3 changed files with 49 additions and 11 deletions

View file

@ -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<Entity> getEntityAbove();
}

View file

@ -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
}

View file

@ -19,10 +19,11 @@ import universalelectricity.prefab.TileEntityElectricityReceiver;
import universalelectricity.prefab.network.IPacketReceiver; import universalelectricity.prefab.network.IPacketReceiver;
import universalelectricity.prefab.network.PacketManager; import universalelectricity.prefab.network.PacketManager;
import assemblyline.AssemblyLine; import assemblyline.AssemblyLine;
import assemblyline.api.IBelt;
import com.google.common.io.ByteArrayDataInput; 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. * Joules required to run this thing.
@ -124,10 +125,10 @@ public class TileEntityConveyorBelt extends TileEntityElectricityReceiver implem
if (this.running) if (this.running)
{ {
AxisAlignedBB bounds = AxisAlignedBB.getBoundingBox(this.xCoord, this.yCoord, this.zCoord, this.xCoord + 1, this.yCoord + 1, this.zCoord + 1);
try try
{ {
List<Entity> entityOnTop = worldObj.getEntitiesWithinAABB(Entity.class, bounds); List<Entity> entityOnTop = this.getEntityAbove();
for (Entity entity : entityOnTop) 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) public void ignoreEntity(Entity entity)
{ {
if (!this.entityIgnoreList.contains(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<Entity> 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);
}
} }