use of net.minecraft.command.SyntaxErrorException in project ICBM-Classic by BuiltBrokenModding.
the class CommandBlastSpread method doCommand.
private void doCommand(@Nonnull ICommandSender sender, @Nonnull String[] args) throws CommandException {
final int count = CommandBase.parseInt(args[0], 1);
final int distance = CommandBase.parseInt(args[1], 1);
// Get explosive data from user
final IExplosiveData explosiveData = CommandBlastTrigger.getExplosive(args[2]);
// Get world position
final World world = CommandUtils.getWorld(sender, args[3], sender.getEntityWorld());
final double xInput = CommandUtils.getNumber(sender, args[4], sender.getPosition().getX() + 0.5);
final double yInput = CommandUtils.getNumber(sender, args[5], sender.getPosition().getY() + 0.5);
final double zInput = CommandUtils.getNumber(sender, args[6], sender.getPosition().getZ() + 0.5);
// Get scale from user
// TODO turn into helper method
final float scale = Float.parseFloat(args[7]);
if (scale <= 0) {
throw new SyntaxErrorException(CommandBlastTrigger.TRANSLATION_ERROR_SCALE_ZERO);
}
final int expectedSpawnCount = (int) Math.floor(Math.pow((count * 2) + 1, 2));
sender.sendMessage(new TextComponentTranslation(TRANSLATION_SPREAD_START, explosiveData.getRegistryName(), scale, world.provider.getDimension(), world.getWorldType().getName(), xInput, yInput, zInput, count, distance, expectedSpawnCount));
// Generate blasts in a grid
for (int xi = -count; xi <= count; xi++) {
for (int zi = -count; zi <= count; zi++) {
// calc position
final double x = xInput + xi * distance;
final double z = zInput + zi * distance;
// Trigger blast
final BlastState result = ExplosiveHandler.createExplosion(null, world, x, yInput, z, explosiveData.getRegistryID(), scale, null);
if (result != BlastState.TRIGGERED && result != BlastState.THREADING) {
// Send translated message to user
sender.sendMessage(new TextComponentTranslation(CommandBlastTrigger.getTranslationKey(result), explosiveData.getRegistryName(), scale, world.provider.getDimension(), world.getWorldType().getName(), x, yInput, z));
}
}
}
}
use of net.minecraft.command.SyntaxErrorException in project ICBM-Classic by BuiltBrokenModding.
the class CommandBlastTrigger method shortVersion.
private void shortVersion(ICommandSender sender, IExplosiveData explosiveData, String[] args) throws SyntaxErrorException {
final float scale = Float.parseFloat(args[1]);
if (scale <= 0) {
throw new SyntaxErrorException(TRANSLATION_ERROR_SCALE_ZERO);
}
// Get position data
final World world = sender.getEntityWorld();
final double x = sender.getPositionVector().x;
final double y = sender.getPositionVector().y;
final double z = sender.getPositionVector().z;
// Trigger blast
trigger(sender, world, x, y, z, explosiveData, scale);
}
use of net.minecraft.command.SyntaxErrorException in project ICBM-Classic by BuiltBrokenModding.
the class CommandBlastTrigger method longVersion.
private void longVersion(ICommandSender sender, IExplosiveData explosiveData, String[] args) throws SyntaxErrorException {
final float scale = Float.parseFloat(args[5]);
if (scale <= 0) {
throw new SyntaxErrorException(TRANSLATION_ERROR_SCALE_ZERO);
}
// Get position data
final World world = CommandUtils.getWorld(sender, args[1], sender.getEntityWorld());
final double x = CommandUtils.getNumber(sender, args[2], sender.getPositionVector().x);
final double y = CommandUtils.getNumber(sender, args[3], sender.getPositionVector().y);
final double z = CommandUtils.getNumber(sender, args[4], sender.getPositionVector().z);
// Trigger blast
trigger(sender, world, x, y, z, explosiveData, scale);
}
Aggregations