From b5e0bfbea1de184349f75354fc5c83d3d2cf2732 Mon Sep 17 00:00:00 2001 From: tterrag1098 Date: Sun, 4 May 2014 01:55:42 -0400 Subject: [PATCH] Fix Farm sucking in useless items --- .../enderio/machine/farm/TileFarmStation.java | 32 ++++++++++++------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/src/main/java/crazypants/enderio/machine/farm/TileFarmStation.java b/src/main/java/crazypants/enderio/machine/farm/TileFarmStation.java index fdfe251f..afc3287d 100644 --- a/src/main/java/crazypants/enderio/machine/farm/TileFarmStation.java +++ b/src/main/java/crazypants/enderio/machine/farm/TileFarmStation.java @@ -262,25 +262,35 @@ public class TileFarmStation extends AbstractPoweredTaskEntity implements IEntit BoundingBox bb = new BoundingBox(getLocation()); AxisAlignedBB aabb = AxisAlignedBB.getBoundingBox(bb.minX, bb.minY, bb.minZ, bb.maxX, bb.maxY, bb.maxZ); aabb = aabb.expand(farmSize + 3, farmSize + 3, farmSize + 3); - List interestingItems = worldObj.selectEntitiesWithinAABB(Entity.class, aabb, this); + List interestingItems = worldObj.selectEntitiesWithinAABB(EntityItem.class, aabb, this); - for (Entity entity : interestingItems) { + for (EntityItem entity : interestingItems) { double x = (xCoord + 0.5D - entity.posX); double y = (yCoord + 0.5D - entity.posY); double z = (zCoord + 0.5D - entity.posZ); - double distance = Math.sqrt(x * x + y * y + z * z); - if(distance < 1.25) { - hooverEntity(entity); - } else { - double speed = 0.035; - entity.motionX += x / distance * speed; - entity.motionY += y * speed; - entity.motionZ += z / distance * speed; + if (isInteresting(entity)) { + double distance = Math.sqrt(x * x + y * y + z * z); + if(distance < 1.25) { + hooverEntity(entity); + } else { + double speed = 0.035; + entity.motionX += x / distance * speed; + entity.motionY += y * speed; + entity.motionZ += z / distance * speed; + } } } } - + + private boolean isInteresting(EntityItem entity) { + for (int i = 0; i < inventory.length; i++) { + if (isMachineItemValidForSlot(i, entity.getEntityItem())) + return true; + } + return false; + } + private boolean isFull() { for (int i = minSupSlot; i <= maxSupSlot; i++) { ItemStack stack = inventory[i];