/**
* @see com.sijobe.spc.wrapper.CommandBase#execute(com.sijobe.spc.wrapper.CommandSender, java.util.List)
*/
@Override
public void execute(CommandSender sender, List<?> params) throws CommandException {
Player player = getSenderAsPlayer(sender);
double radius = 128.0D;
String entityType = "item";
if(params.size() > 0) {
entityType = (String)params.get(0);
if(Entity.getEntityClass(entityType) == null) {
try {
radius = Double.parseDouble((String)params.get(0));
sender.sendMessageToPlayer("Setting radius to: " + radius);
entityType = "item";
} catch (NumberFormatException nfe) {
throw new CommandException("Unknown entity specified.");
}
}
if(params.size() > 1) {
radius = (Integer)params.get(1);
}
}
if(radius <=0 || radius > 256) {
throw new CommandException("Radius should be between 0 and 256.");
}
List<net.minecraft.src.Entity> foundEntities = Entity.findEntities(entityType, player.getPosition(), player.getWorld(), radius);
net.minecraft.src.Vec3 vec3d = player.getMinecraftPlayer().getLook(1.0F);
double d = 5.0D;
double offsetY = player.getMinecraftPlayer().posY + player.getMinecraftPlayer().getEyeHeight();
double d1 = player.getMinecraftPlayer().posX + vec3d.xCoord * d;
double d2 = offsetY + vec3d.yCoord * d;
double d3 = player.getMinecraftPlayer().posZ + vec3d.zCoord * d;
for(net.minecraft.src.Entity entity : foundEntities) {
if(entity == player.getMinecraftPlayer()) {
continue; // don't allow the player to bring themselves
}
entity.setPosition(d1, d2 + 0.5D, d3);
}
sender.sendMessageToPlayer(foundEntities.size() + " entities brought.");