-
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.
Fixed tint strategy and added shear command
- Loading branch information
Michael Zangl
committed
Aug 9, 2014
1 parent
04b4103
commit 4073f4c
Showing
9 changed files
with
160 additions
and
15 deletions.
There are no files selected for viewing
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
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
29 changes: 29 additions & 0 deletions
29
Minebot/src/net/famzangl/minecraft/minebot/ai/commands/CommandShear.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,29 @@ | ||
package net.famzangl.minecraft.minebot.ai.commands; | ||
|
||
import net.famzangl.minecraft.minebot.ai.AIHelper; | ||
import net.famzangl.minecraft.minebot.ai.AIStrategy; | ||
import net.famzangl.minecraft.minebot.ai.command.AICommand; | ||
import net.famzangl.minecraft.minebot.ai.command.AICommandInvocation; | ||
import net.famzangl.minecraft.minebot.ai.command.AICommandParameter; | ||
import net.famzangl.minecraft.minebot.ai.command.ParameterType; | ||
import net.famzangl.minecraft.minebot.ai.strategy.ShearStrategy; | ||
|
||
@AICommand(helpText="Shear sheep.", name="minebot") | ||
public class CommandShear { | ||
|
||
@AICommandInvocation() | ||
public static AIStrategy run( | ||
AIHelper helper, | ||
@AICommandParameter(type = ParameterType.FIXED, fixedName = "shear", description = "") String nameArg) { | ||
return run(helper, nameArg, -1); | ||
} | ||
|
||
@AICommandInvocation() | ||
public static AIStrategy run( | ||
AIHelper helper, | ||
@AICommandParameter(type = ParameterType.FIXED, fixedName = "shear", description = "") String nameArg, | ||
@AICommandParameter(type = ParameterType.COLOR, description = "The color to get") int color) { | ||
return new ShearStrategy(color); | ||
} | ||
|
||
} |
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
13 changes: 13 additions & 0 deletions
13
Minebot/src/net/famzangl/minecraft/minebot/ai/selectors/ItemSelector.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,13 @@ | ||
package net.famzangl.minecraft.minebot.ai.selectors; | ||
|
||
import net.minecraft.command.IEntitySelector; | ||
import net.minecraft.entity.Entity; | ||
import net.minecraft.entity.item.EntityItem; | ||
|
||
public final class ItemSelector implements | ||
IEntitySelector { | ||
@Override | ||
public boolean isEntityApplicable(Entity e) { | ||
return e instanceof EntityItem; | ||
} | ||
} |
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
77 changes: 77 additions & 0 deletions
77
Minebot/src/net/famzangl/minecraft/minebot/ai/strategy/ShearStrategy.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,77 @@ | ||
package net.famzangl.minecraft.minebot.ai.strategy; | ||
|
||
import net.famzangl.minecraft.minebot.ai.AIHelper; | ||
import net.famzangl.minecraft.minebot.ai.AIStrategy; | ||
import net.famzangl.minecraft.minebot.ai.ItemFilter; | ||
import net.famzangl.minecraft.minebot.ai.selectors.AndSelector; | ||
import net.famzangl.minecraft.minebot.ai.selectors.ColorSelector; | ||
import net.famzangl.minecraft.minebot.ai.selectors.ItemSelector; | ||
import net.famzangl.minecraft.minebot.ai.selectors.OrSelector; | ||
import net.famzangl.minecraft.minebot.ai.task.AITask; | ||
import net.famzangl.minecraft.minebot.ai.task.FaceAndInteractTask; | ||
import net.minecraft.command.IEntitySelector; | ||
import net.minecraft.entity.Entity; | ||
import net.minecraft.entity.passive.EntitySheep; | ||
import net.minecraft.item.ItemShears; | ||
import net.minecraft.item.ItemStack; | ||
|
||
public class ShearStrategy implements AIStrategy { | ||
private static final int DISTANCE = 20; | ||
private final int color; | ||
|
||
public ShearStrategy(int color) { | ||
this.color = color; | ||
} | ||
|
||
private final class ShearsFilter implements ItemFilter { | ||
@Override | ||
public boolean matches(ItemStack itemStack) { | ||
return itemStack != null && itemStack.getItem() instanceof ItemShears; | ||
} | ||
} | ||
|
||
private final class SheepSelector implements IEntitySelector { | ||
@Override | ||
public boolean isEntityApplicable(Entity var1) { | ||
return var1 instanceof EntitySheep | ||
&& ((EntitySheep) var1).isShearable(null, null, 0, 0, 0); | ||
} | ||
} | ||
|
||
public static enum TintType { | ||
WOLF, | ||
SHEEP, | ||
ANY; | ||
} | ||
|
||
@Override | ||
public void searchTasks(AIHelper helper) { | ||
if (!helper.selectCurrentItem(new ShearsFilter())) { | ||
return; | ||
} | ||
|
||
IEntitySelector selector = new SheepSelector(); | ||
|
||
if (color >= 0) { | ||
selector = new AndSelector(selector, new ColorSelector(color)); | ||
} | ||
|
||
final Entity found = helper.getClosestEntity(DISTANCE, new OrSelector( | ||
selector, new ItemSelector())); | ||
|
||
if (found != null) { | ||
helper.addTask(new FaceAndInteractTask(found, selector)); | ||
} | ||
} | ||
|
||
@Override | ||
public String getDescription() { | ||
return "Tinting..."; | ||
} | ||
|
||
@Override | ||
public AITask getOverrideTask(AIHelper helper) { | ||
return null; | ||
} | ||
|
||
} |
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
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