Re Added Ignore Entity to Belts

I ORIGINAL added this so that machine could take control of the Entity
without the belt trying to move the Entity. This should correct the
issue with the armbot trying to grab an Entity but it being ripped out
of its hands by the moving belt.
This commit is contained in:
Rseifert 2013-02-17 04:55:14 -05:00
parent a4ea8ed8b2
commit a69f2375a1
4 changed files with 53 additions and 18 deletions

View file

@ -18,4 +18,11 @@ public interface IBelt
* @return list of entities in the belts are of effect
*/
public List<Entity> getAffectedEntities();
/**
* Adds and entity to the ignore list so its not moved
* has to be done every 20 ticks
* @param entity
*/
public void IgnoreEntity(Entity entity);
}

View file

@ -67,14 +67,8 @@ public class BlockConveyorBelt extends BlockMachine
{
TileEntityConveyorBelt tileEntity = (TileEntityConveyorBelt) t;
if (tileEntity.getSlant() == SlantType.UP || tileEntity.getSlant() == SlantType.DOWN)
{
return AxisAlignedBB.getAABBPool().addOrModifyAABBInPool((double) x + this.minX, (double) y + this.minY, (double) z + this.minZ, (double) x + 1, (double) y + 1, (double) z + 1);
}
if (tileEntity.getSlant() == SlantType.TOP)
{
return AxisAlignedBB.getAABBPool().addOrModifyAABBInPool((double) x + this.minX, (double) y + 0.68f, (double) z + this.minZ, (double) x + this.maxX, (double) y + 0.98f, (double) z + this.maxZ);
}
if (tileEntity.getSlant() == SlantType.UP || tileEntity.getSlant() == SlantType.DOWN) { return AxisAlignedBB.getAABBPool().addOrModifyAABBInPool((double) x + this.minX, (double) y + this.minY, (double) z + this.minZ, (double) x + 1, (double) y + 1, (double) z + 1); }
if (tileEntity.getSlant() == SlantType.TOP) { return AxisAlignedBB.getAABBPool().addOrModifyAABBInPool((double) x + this.minX, (double) y + 0.68f, (double) z + this.minZ, (double) x + this.maxX, (double) y + 0.98f, (double) z + this.maxZ); }
}
return AxisAlignedBB.getAABBPool().addOrModifyAABBInPool((double) x + this.minX, (double) y + this.minY, (double) z + this.minZ, (double) x + this.maxX, (double) y + this.maxY, (double) z + this.maxZ);
@ -246,7 +240,7 @@ public class BlockConveyorBelt extends BlockMachine
{
TileEntityConveyorBelt tileEntity = (TileEntityConveyorBelt) world.getBlockTileEntity(x, y, z);
tileEntity.updatePowerTransferRange();
if (tileEntity.IgnoreList.contains(entity)) { return; }
if (tileEntity.isRunning() && !world.isBlockIndirectlyGettingPowered(x, y, z))
{
float acceleration = tileEntity.acceleration;

View file

@ -1,5 +1,6 @@
package assemblyline.common.machine.belt;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
@ -45,6 +46,8 @@ public class TileEntityConveyorBelt extends TileEntityAssemblyNetwork implements
private int animFrame = 0; // this is from 0 to 15
private SlantType slantType = SlantType.NONE;
public List<Entity> IgnoreList = new ArrayList<Entity>();// Entities that need to be ignored to prevent movement
public TileEntityConveyorBelt()
{
super();
@ -52,8 +55,7 @@ public class TileEntityConveyorBelt extends TileEntityAssemblyNetwork implements
}
/**
* This function is overriden to allow conveyor belts to power belts that are diagonally going
* up.
* This function is overriden to allow conveyor belts to power belts that are diagonally going up.
*/
@Override
public void updatePowerTransferRange()
@ -116,6 +118,15 @@ public class TileEntityConveyorBelt extends TileEntityAssemblyNetwork implements
{
PacketManager.sendPacketToClients(this.getDescriptionPacket());
}
/* PROCESSES IGNORE LIST AND REMOVES UNNEED ENTRIES */
for (Entity ent : IgnoreList)
{
if (!this.getAffectedEntities().contains(ent))
{
this.IgnoreList.remove(ent);
}
}
if (this.isRunning() && !this.worldObj.isBlockIndirectlyGettingPowered(this.xCoord, this.yCoord, this.zCoord))
{
@ -338,4 +349,14 @@ public class TileEntityConveyorBelt extends TileEntityAssemblyNetwork implements
nbt.setInteger("rotation", worldObj.getBlockMetadata(this.xCoord, this.yCoord, this.zCoord));
}
}
@Override
public void IgnoreEntity(Entity entity)
{
if (!this.IgnoreList.contains(entity))
{
this.IgnoreList.add(entity);
}
}
}

View file

@ -2,11 +2,14 @@ package assemblyline.common.machine.command;
import java.util.List;
import assemblyline.common.machine.belt.TileEntityConveyorBelt;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityAgeable;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import universalelectricity.core.vector.Vector3;
@ -20,10 +23,11 @@ public class CommandGrab extends Command
public static final float radius = 0.5f;
/**
* If the grab command is specific to one entity this tell whether or not to grab the child
* version of that entity.
* If the grab command is specific to one entity this tell whether or not to grab the child version of that entity.
*/
public boolean child = false;
private TileEntityConveyorBelt belt;
/**
* The item to be collected.
*/
@ -62,14 +66,23 @@ public class CommandGrab extends Command
{
super.doTask();
if (this.tileEntity.getGrabbedEntities().size() > 0)
{
return false;
}
if (this.tileEntity.getGrabbedEntities().size() > 0) { return false; }
Vector3 serachPosition = this.tileEntity.getHandPosition();
List<Entity> found = this.world.getEntitiesWithinAABB(this.entityToInclude, AxisAlignedBB.getBoundingBox(serachPosition.x - radius, serachPosition.y - radius, serachPosition.z - radius, serachPosition.x + radius, serachPosition.y + radius, serachPosition.z + radius));
TileEntity ent = serachPosition.getTileEntity(world);
Vector3 searchPostion2 = Vector3.add(serachPosition, new Vector3(0, -1, 0));
TileEntity ent2 = searchPostion2.getTileEntity(world);
if (ent instanceof TileEntityConveyorBelt)
{
this.belt = (TileEntityConveyorBelt) ent;
}
else if (ent2 instanceof TileEntityConveyorBelt)
{
this.belt = (TileEntityConveyorBelt) ent2;
}
if (found != null && found.size() > 0)
{
for (int i = 0; i < found.size(); i++)
@ -78,7 +91,7 @@ public class CommandGrab extends Command
{
this.tileEntity.grabEntity(found.get(i));
this.world.playSound(this.tileEntity.xCoord, this.tileEntity.yCoord, this.tileEntity.zCoord, "random.pop", 0.2F, ((this.tileEntity.worldObj.rand.nextFloat() - this.tileEntity.worldObj.rand.nextFloat()) * 0.7F + 1.0F) * 1.0F, true);
if(this.belt != null){belt.IgnoreEntity(found.get(i));}
return false;
}
}