diff --git a/src/main/java/forestry/core/entities/EntitySelector.java b/src/main/java/forestry/core/entities/EntitySelector.java deleted file mode 100644 index c0ce87257..000000000 --- a/src/main/java/forestry/core/entities/EntitySelector.java +++ /dev/null @@ -1,38 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011-2014 SirSengir. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser Public License v3 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl-3.0.txt - * - * Various Contributors including, but not limited to: - * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges - ******************************************************************************/ -package forestry.core.entities; - -import com.google.common.base.Predicate; - -import net.minecraft.entity.Entity; - -public abstract class EntitySelector implements Predicate { - private final Class entityClass; - - protected EntitySelector(Class entityClass) { - this.entityClass = entityClass; - } - - public Class getEntityClass() { - return entityClass; - } - - @Override - public boolean apply(Entity entity) { - if (entity == null) { - return false; - } - T castEntity = entityClass.cast(entity); - return isEntityApplicableTyped(castEntity); - } - - protected abstract boolean isEntityApplicableTyped(T entity); -} diff --git a/src/main/java/forestry/farming/logic/FarmLogic.java b/src/main/java/forestry/farming/logic/FarmLogic.java index 3241a0822..2cd81f799 100755 --- a/src/main/java/forestry/farming/logic/FarmLogic.java +++ b/src/main/java/forestry/farming/logic/FarmLogic.java @@ -14,6 +14,11 @@ import javax.annotation.Nonnull; import java.util.ArrayList; import java.util.List; +import com.google.common.base.Predicate; +import forestry.api.farming.FarmDirection; +import forestry.api.farming.IFarmHousing; +import forestry.api.farming.IFarmLogic; +import forestry.core.utils.VectUtil; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.client.renderer.texture.TextureMap; @@ -25,16 +30,9 @@ import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3i; import net.minecraft.world.World; - import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import forestry.api.farming.FarmDirection; -import forestry.api.farming.IFarmHousing; -import forestry.api.farming.IFarmLogic; -import forestry.core.entities.EntitySelector; -import forestry.core.utils.VectUtil; - public abstract class FarmLogic implements IFarmLogic { private final EntitySelectorFarm entitySelectorFarm = new EntitySelectorFarm(this); protected boolean isManual; @@ -90,7 +88,7 @@ public abstract class FarmLogic implements IFarmLogic { protected List collectEntityItems(World world, IFarmHousing farmHousing, boolean toWorldHeight) { AxisAlignedBB harvestBox = getHarvestBox(world, farmHousing, toWorldHeight); - List entityItems = world.getEntitiesWithinAABB(entitySelectorFarm.getEntityClass(), harvestBox, entitySelectorFarm); + List entityItems = world.getEntitiesWithinAABB(EntityItem.class, harvestBox, entitySelectorFarm); List stacks = new ArrayList<>(); for (EntityItem entity : entityItems) { ItemStack contained = entity.getEntityItem(); @@ -100,20 +98,23 @@ public abstract class FarmLogic implements IFarmLogic { return stacks; } - private static class EntitySelectorFarm extends EntitySelector { + private static class EntitySelectorFarm implements Predicate { private final FarmLogic farmLogic; public EntitySelectorFarm(FarmLogic farmLogic) { - super(EntityItem.class); this.farmLogic = farmLogic; } @Override - protected boolean isEntityApplicableTyped(EntityItem entity) { + public boolean apply(EntityItem entity) { if (entity.isDead) { return false; } + if (entity.getEntityData().getBoolean("PreventRemoteMovement")) { + return false; + } + ItemStack contained = entity.getEntityItem(); return farmLogic.isAcceptedGermling(contained) || farmLogic.isAcceptedWindfall(contained); }