-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Michael Zangl
committed
Aug 17, 2014
1 parent
6e88ead
commit 1bb8b59
Showing
2 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
Minebot/src/net/famzangl/minecraft/minebot/ai/strategy/CloseEntityActionStrategy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} |
18 changes: 18 additions & 0 deletions
18
Minebot/src/net/famzangl/minecraft/minebot/ai/strategy/CreeperComesActionStrategy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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_"; | ||
} | ||
} |