rejector cleanup

This commit is contained in:
DarkGuardsman 2013-07-05 20:12:23 -04:00
parent 0621433663
commit 1fc0664683
2 changed files with 18 additions and 59 deletions

View file

@ -10,52 +10,33 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraftforge.common.ForgeDirection;
import universalelectricity.core.vector.Vector3;
import universalelectricity.prefab.network.PacketManager;
import assemblyline.api.IBelt;
import assemblyline.common.imprinter.prefab.TileEntityFilterable;
/**
*
* @author Darkguardsman
*
*/
/** @author Darkguardsman */
public class TileEntityRejector extends TileEntityFilterable
{
/**
* should the piston fire, or be extended
*/
/** should the piston fire, or be extended */
public boolean firePiston = false;
public TileEntityRejector()
{
super();
}
@Override
public void onUpdate()
{
/**
* Has to update a bit faster than a conveyer belt
*/
/** Has to update a bit faster than a conveyer belt */
if (this.ticks % 5 == 0 && !this.isDisabled())
{
int metadata = this.getBlockMetadata();
this.firePiston = false;
// area to search for items
this.firePiston = false;
Vector3 searchPosition = new Vector3(this);
searchPosition.modifyPositionFromSide(this.getDirection());
TileEntity tileEntity = searchPosition.getTileEntity(this.worldObj);
try
{
boolean flag = false;
if (this.isRunning())
{
/**
* Find all entities in the position in which this block is facing and attempt
* to push it out of the way.
*/
/** Find all entities in the position in which this block is facing and attempt
* to push it out of the way. */
AxisAlignedBB bounds = AxisAlignedBB.getBoundingBox(searchPosition.x, searchPosition.y, searchPosition.z, searchPosition.x + 1, searchPosition.y + 1, searchPosition.z + 1);
List<Entity> entitiesInFront = this.worldObj.getEntitiesWithinAABB(Entity.class, bounds);
@ -63,8 +44,7 @@ public class TileEntityRejector extends TileEntityFilterable
{
if (this.canEntityBeThrow(entity))
{
this.throwItem(this.getDirection(), entity);
flag = true;
this.throwItem(tileEntity, this.getDirection(), entity);
}
}
}
@ -76,23 +56,22 @@ public class TileEntityRejector extends TileEntityFilterable
}
}
/**
* Used to move after it has been rejected
*
* @param side - used to do the offset
* @param entity - Entity being thrown
*/
public void throwItem(ForgeDirection side, Entity entity)
/** Pushs an entity in the direction in which the rejector is facing */
public void throwItem(TileEntity tileEntity, ForgeDirection side, Entity entity)
{
this.firePiston = true;
//TODO add config to adjust the motion magnitude per rejector
entity.motionX = (double) side.offsetX * 0.1;
entity.motionY += 0.10000000298023224D;
entity.motionZ = (double) side.offsetZ * 0.1;
PacketManager.sendPacketToClients(getDescriptionPacket());
if (!this.worldObj.isRemote && tileEntity instanceof IBelt)
{
((IBelt) tileEntity).ignoreEntity(entity);
}
}
/** Checks to see if the rejector can push the entity in the facing direction */
public boolean canEntityBeThrow(Entity entity)
{
// TODO Add other things than items
@ -107,26 +86,6 @@ public class TileEntityRejector extends TileEntityFilterable
return false;
}
/**
* NBT Data
*/
@Override
public void readFromNBT(NBTTagCompound nbt)
{
super.readFromNBT(nbt);
this.firePiston = nbt.getBoolean("piston");
}
/**
* Writes a tile entity to NBT.
*/
@Override
public void writeToNBT(NBTTagCompound nbt)
{
super.writeToNBT(nbt);
nbt.setBoolean("piston", this.firePiston);
}
@Override
public boolean canConnect(ForgeDirection dir)
{

View file

@ -228,7 +228,7 @@ public class TileEntityConveyorBelt extends TileEntityAssembly implements IPacke
}
@Override
public void IgnoreEntity(Entity entity)
public void ignoreEntity(Entity entity)
{
if (!this.IgnoreList.contains(entity))
{