diff --git a/Minebot/src/net/famzangl/minecraft/minebot/ai/strategy/CloseEntityActionStrategy.java b/Minebot/src/net/famzangl/minecraft/minebot/ai/strategy/CloseEntityActionStrategy.java new file mode 100644 index 00000000..3866e28a --- /dev/null +++ b/Minebot/src/net/famzangl/minecraft/minebot/ai/strategy/CloseEntityActionStrategy.java @@ -0,0 +1,23 @@ +package net.famzangl.minecraft.minebot.ai.strategy; + +import net.famzangl.minecraft.minebot.ai.AIHelper; +import net.minecraft.command.IEntitySelector; +import net.minecraft.entity.Entity; + +public abstract class CloseEntityActionStrategy extends ValueActionStrategy { + @Override + protected double getValue(final AIHelper helper) { + final Entity closest = helper.getClosestEntity(50, + new IEntitySelector() { + @Override + public boolean isEntityApplicable(Entity player) { + return matches(helper, player); + } + + }); + return closest == null ? Double.MAX_VALUE : closest + .getDistanceToEntity(helper.getMinecraft().thePlayer); + } + + protected abstract boolean matches(AIHelper helper, Entity player); +} diff --git a/Minebot/src/net/famzangl/minecraft/minebot/ai/strategy/CreeperComesActionStrategy.java b/Minebot/src/net/famzangl/minecraft/minebot/ai/strategy/CreeperComesActionStrategy.java new file mode 100644 index 00000000..c367b449 --- /dev/null +++ b/Minebot/src/net/famzangl/minecraft/minebot/ai/strategy/CreeperComesActionStrategy.java @@ -0,0 +1,18 @@ +package net.famzangl.minecraft.minebot.ai.strategy; + +import net.famzangl.minecraft.minebot.ai.AIHelper; +import net.minecraft.entity.Entity; +import net.minecraft.entity.monster.EntityCreeper; + +public class CreeperComesActionStrategy extends CloseEntityActionStrategy { + + @Override + protected boolean matches(AIHelper helper, Entity player) { + return player instanceof EntityCreeper; + } + + @Override + protected String getSettingPrefix() { + return "on_creeper_comes_"; + } +}