Posted 28 February 2015 - 09:13 PM
I've written a small mod, that adds a ShootyTurtle (a Turtle with a bow).
Nearly everything is working except that players didn't get any damage, but Mobs do.
Nearly everything is working except that players didn't get any damage, but Mobs do.
package de.agowa338.computercraft.turtle.turtle;
public class shootyTurtle extends anyToolTurtle {
@Override
public TurtleCommandResult useTool(ITurtleAccess turtle, TurtleSide side, TurtleVerb verb, int direction) {
if (verb == TurtleVerb.Attack) {
ItemStack currentItemStack = turtle.getInventory().getStackInSlot(turtle.getSelectedSlot());
if (currentItemStack == null || !currentItemStack.getItem().equals(net.minecraft.item.Item.getItemById(262))) {
return TurtleCommandResult.failure();
} else {
World world = turtle.getWorld();
ChunkCoordinates chunkCoordinates = turtle.getPosition();
TurtlePlayer turtlePlayer = TurtlePlaceCommand.createPlayer(world, chunkCoordinates, turtle, direction);
EntityArrow entityArrow = new EntityArrow(world, turtlePlayer, 5F);
//entityArrow.setDamage(2);
//entityArrow.setIsCritical(true);
//entityArrow.setKnockbackStrength(20);
world.spawnEntityInWorld(entityArrow);
//TODO: Player doesn't get any damage, Arrow is bouncing off players
this.itemBow.onPlayerStoppedUsing(this.getItemStack(), world, turtlePlayer, 71971);
return TurtleCommandResult.success();
}
} else {
return TurtleCommandResult.failure("This Turtle cannot dig.");
}
}
}
Full Code: https://github.com/a...omputerCraftMod