Java Code Examples for net.minecraft.command.ICommandSender.getEntityWorld()

The following are Jave code examples for showing how to use getEntityWorld() of the net.minecraft.command.ICommandSender class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: Bewitchment   File: IncantationSnuff.java   Source Code and License Vote up 6 votes
@Override
public void cast(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
	World world = sender.getEntityWorld();
	BlockPos source = sender.getPosition();
	for (BlockPos pos : BlockPos.getAllInBox(source.add(5, 5, 5), source.add(-5, -5, -5))) {
		TileEntity tile = world.getTileEntity(pos);
		if (tile instanceof TileCandle && ((TileCandle) tile).isLit()) {
			for (int i = 0; i < 5; i++) {
				double x = pos.getX() + world.rand.nextFloat();
				double y = pos.getY() + world.rand.nextFloat();
				double z = pos.getZ() + world.rand.nextFloat();
				world.spawnParticle(EnumParticleTypes.FLAME, x, y, z, 0, 0, 0);
			}
			((TileCandle) tile).unLitCandle();
			PacketHandler.updateToNearbyPlayers(world, pos);
		}
	}
	EnergyHandler.addEnergy((EntityPlayer) sender, 800);
}
 
Example 2
Project: Bewitchment   File: IncantationCandlelight.java   Source Code and License Vote up 6 votes
@Override
public void cast(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
	World world = sender.getEntityWorld();
	BlockPos source = sender.getPosition();
	for (BlockPos pos : BlockPos.getAllInBox(source.add(5, 5, 5), source.add(-5, -5, -5))) {
		TileEntity tile = world.getTileEntity(pos);
		if (tile instanceof TileCandle && !((TileCandle) tile).isLit()) {
			for (int i = 0; i < 5; i++) {
				double x = pos.getX() + world.rand.nextFloat();
				double y = pos.getY() + world.rand.nextFloat();
				double z = pos.getZ() + world.rand.nextFloat();
				world.spawnParticle(EnumParticleTypes.FLAME, x, y, z, 0, 0, 0);
			}
			((TileCandle) tile).litCandle();
			PacketHandler.updateToNearbyPlayers(world, pos);
		}
	}
	EnergyHandler.addEnergy((EntityPlayer) sender, 800);
}
 
Example 3
Project: DecompiledMinecraft   File: CommandSetDefaultSpawnpoint.java   Source Code and License Vote up 6 votes
/**
 * Callback when the command is invoked
 */
public void processCommand(ICommandSender sender, String[] args) throws CommandException
{
    BlockPos blockpos;

    if (args.length == 0)
    {
        blockpos = getCommandSenderAsPlayer(sender).getPosition();
    }
    else
    {
        if (args.length != 3 || sender.getEntityWorld() == null)
        {
            throw new WrongUsageException("commands.setworldspawn.usage", new Object[0]);
        }

        blockpos = parseBlockPos(sender, args, 0, true);
    }

    sender.getEntityWorld().setSpawnPoint(blockpos);
    MinecraftServer.getServer().getConfigurationManager().sendPacketToAllPlayers(new S05PacketSpawnPosition(blockpos));
    notifyOperators(sender, this, "commands.setworldspawn.success", new Object[] {Integer.valueOf(blockpos.getX()), Integer.valueOf(blockpos.getY()), Integer.valueOf(blockpos.getZ())});
}
 
Example 4
Project: DecompiledMinecraft   File: CommandSetDefaultSpawnpoint.java   Source Code and License Vote up 6 votes
/**
 * Callback when the command is invoked
 */
public void processCommand(ICommandSender sender, String[] args) throws CommandException
{
    BlockPos blockpos;

    if (args.length == 0)
    {
        blockpos = getCommandSenderAsPlayer(sender).getPosition();
    }
    else
    {
        if (args.length != 3 || sender.getEntityWorld() == null)
        {
            throw new WrongUsageException("commands.setworldspawn.usage", new Object[0]);
        }

        blockpos = parseBlockPos(sender, args, 0, true);
    }

    sender.getEntityWorld().setSpawnPoint(blockpos);
    MinecraftServer.getServer().getConfigurationManager().sendPacketToAllPlayers(new S05PacketSpawnPosition(blockpos));
    notifyOperators(sender, this, "commands.setworldspawn.success", new Object[] {Integer.valueOf(blockpos.getX()), Integer.valueOf(blockpos.getY()), Integer.valueOf(blockpos.getZ())});
}
 
Example 5
Project: BaseClient   File: CommandSetDefaultSpawnpoint.java   Source Code and License Vote up 6 votes
/**
 * Callback when the command is invoked
 */
public void processCommand(ICommandSender sender, String[] args) throws CommandException
{
    BlockPos blockpos;

    if (args.length == 0)
    {
        blockpos = getCommandSenderAsPlayer(sender).getPosition();
    }
    else
    {
        if (args.length != 3 || sender.getEntityWorld() == null)
        {
            throw new WrongUsageException("commands.setworldspawn.usage", new Object[0]);
        }

        blockpos = parseBlockPos(sender, args, 0, true);
    }

    sender.getEntityWorld().setSpawnPoint(blockpos);
    MinecraftServer.getServer().getConfigurationManager().sendPacketToAllPlayers(new S05PacketSpawnPosition(blockpos));
    notifyOperators(sender, this, "commands.setworldspawn.success", new Object[] {Integer.valueOf(blockpos.getX()), Integer.valueOf(blockpos.getY()), Integer.valueOf(blockpos.getZ())});
}
 
Example 6
Project: BaseClient   File: CommandSetDefaultSpawnpoint.java   Source Code and License Vote up 6 votes
/**
 * Callback when the command is invoked
 */
public void processCommand(ICommandSender sender, String[] args) throws CommandException
{
    BlockPos blockpos;

    if (args.length == 0)
    {
        blockpos = getCommandSenderAsPlayer(sender).getPosition();
    }
    else
    {
        if (args.length != 3 || sender.getEntityWorld() == null)
        {
            throw new WrongUsageException("commands.setworldspawn.usage", new Object[0]);
        }

        blockpos = parseBlockPos(sender, args, 0, true);
    }

    sender.getEntityWorld().setSpawnPoint(blockpos);
    MinecraftServer.getServer().getConfigurationManager().sendPacketToAllPlayers(new S05PacketSpawnPosition(blockpos));
    notifyOperators(sender, this, "commands.setworldspawn.success", new Object[] {Integer.valueOf(blockpos.getX()), Integer.valueOf(blockpos.getY()), Integer.valueOf(blockpos.getZ())});
}
 
Example 7
Project: Halloween   File: CommandCurse.java   Source Code and License Vote up 6 votes
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
	World world = sender.getEntityWorld();
	if (!world.isRemote && args.length > 0)
	{
		EntityPlayer player = this.getCommandSenderAsPlayer(sender);
		EntityCurse curse = null;

		EnumCurseType curseType = EnumCurseType.byName(args[0]);
		switch(curseType)
		{
			case CREEPER: curse = new EntityCreeperCurse(world, player); break;
			case GHAST: curse = new EntityGhastCurse(world, player); break;
			case SKELETON: curse = new EntitySkeletonCurse(world, player); break;
			case SLIME: curse = new EntitySlimeCurse(world, player); break;
			case SPIDER: curse = new EntitySpiderCurse(world, player); break;
			case ZOMBIE: curse = new EntityZombieCurse(world, player); break;
		}
		world.spawnEntity(curse);
	}
}
 
Example 8
Project: CustomWorldGen   File: CommandSetDefaultSpawnpoint.java   Source Code and License Vote up 6 votes
/**
 * Callback for when the command is executed
 */
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
    BlockPos blockpos;

    if (args.length == 0)
    {
        blockpos = getCommandSenderAsPlayer(sender).getPosition();
    }
    else
    {
        if (args.length != 3 || sender.getEntityWorld() == null)
        {
            throw new WrongUsageException("commands.setworldspawn.usage", new Object[0]);
        }

        blockpos = parseBlockPos(sender, args, 0, true);
    }

    sender.getEntityWorld().setSpawnPoint(blockpos);
    server.getPlayerList().sendPacketToAllPlayers(new SPacketSpawnPosition(blockpos));
    notifyCommandListener(sender, this, "commands.setworldspawn.success", new Object[] {Integer.valueOf(blockpos.getX()), Integer.valueOf(blockpos.getY()), Integer.valueOf(blockpos.getZ())});
}
 
Example 9
Project: StructPro   File: Evaluator.java   Source Code and License Vote up 6 votes
/** Generate world region. Very high-weight for cpu-calculation resources command
 * @param vars Variables to parse arguments
 * @param sender Who sends the command
 */
static void execGen(Variables vars, ICommandSender sender) {
    int size = vars.get(new String[]{"size", "s", "length", "radius", "r"}, 16);
    int startX = vars.get(new String[]{"startx", "sx"}, 0);
    int startZ = vars.get(new String[]{"startz", "sz"}, 0);
    boolean stop = vars.get(new String[]{"stop", "end", "finish"}, false);
    boolean skip = vars.get(new String[]{"skip"}, false);
    int progress = vars.get(new String[]{"progress"}, 0);
    int step = Math.min(Math.max(1, vars.get(new String[]{"step", "delta"}, 32)), 4096);
    String worldName = vars.get(new String[]{"world"});
    UWorld world = worldName == null ? new UWorld(sender.getEntityWorld()) : UWorld.getWorld(worldName);
    if (world == null) {
        feedback(sender, "§4No matching world");
        return;
    }
    feedback(sender, Evaluator.cmdGen(world, startX, startZ, step, size, stop, skip, progress));
}
 
Example 10
Project: StructPro   File: Evaluator.java   Source Code and License Vote up 5 votes
/** Saves fragment from the world to schematic
 * @param vars Variables to parse arguments
 * @param sender Who sends the command
 */
static void execSave(Variables vars, ICommandSender sender) {
    String name = vars.get(new String[]{"name"}, "unnamed");
    UBlockPos where = new UBlockPos(0, 0, 0);
    if (sender instanceof EntityPlayerMP) {
        EntityPlayerMP player = (EntityPlayerMP) sender;
        where = new UBlockPos((int)player.posX, (int)player.posY, (int)player.posZ);
    }
    int posX = vars.get(new String[]{"posx", "px", "x"}, where.getX());
    int posY = vars.get(new String[]{"posy", "py", "y"}, where.getY());
    int posZ = vars.get(new String[]{"posz", "pz", "z"}, where.getZ());
    int width = vars.get(new String[]{"width", "w"}, 64);
    int height = vars.get(new String[]{"height", "h"}, 64);
    int length = vars.get(new String[]{"length", "l"}, 64);
    if (vars.get(new String[]{"wand"}, false) && sender instanceof EntityPlayer && wand.containsKey(sender)) {
        UBlockPos posK = wand.get(sender).getKey();
        UBlockPos posV = wand.get(sender).getValue();
        posX = Math.min(posK.getX(), posV.getX());
        posY = Math.min(posK.getY(), posV.getY());
        posZ = Math.min(posK.getZ(), posV.getZ());
        width = Math.max(posK.getX(), posV.getX()) - posX + 1;
        height = Math.max(posK.getY(), posV.getY()) - posY + 1;
        length = Math.max(posK.getZ(), posV.getZ()) - posZ + 1;
    }
    String worldName = vars.get(new String[]{"world"});
    UWorld world = worldName == null ? new UWorld(sender.getEntityWorld()) : UWorld.getWorld(worldName);
    if (world == null) {
        feedback(sender, "§4No matching world");
        return;
    }
    feedback(sender, Evaluator.cmdSave(world, name, posX, posY, posZ, width, height, length));
}
 
Example 11
Project: harshencastle   File: HarshenCastleCommands.java   Source Code and License Vote up 5 votes
@HarshenCommand
public static void reload(MinecraftServer server, ICommandSender sender, String[] args)
{
	BaseConfig.reloadAll();
	for(EntityPlayer player : sender.getEntityWorld().playerEntities)
		HandlerSyncConfig.syncConfigWithClient((EntityPlayerMP) player);
	message(sender, "success");
}
 
Example 12
Project: StructPro   File: Evaluator.java   Source Code and License Vote up 5 votes
/** Paste something to the world
 * @param vars Variables to parse arguments
 * @param sender Who sends the command
 */
static void execPaste(Variables vars, ICommandSender sender) {
    Random random = new Random();
    String name = vars.get(new String[]{"name"}, "");
    UBlockPos where = new UBlockPos(0, 0, 0);
    if (sender instanceof EntityPlayerMP) {
        EntityPlayerMP player = (EntityPlayerMP) sender;
        where = new UBlockPos((int)player.posX, (int)player.posY, (int)player.posZ);
    }
    int posX = vars.get(new String[]{"posx", "px", "x"}, where.getX());
    int posY = vars.get(new String[]{"posy", "py", "y"}, where.getY());
    int posZ = vars.get(new String[]{"posz", "pz", "z"}, where.getZ());
    int rotateX = vars.get(new String[]{"rotatex", "rotx", "rx"}, 0);
    int rotateY = vars.get(new String[]{"rotatey", "roty", "ry"}, random.nextInt() % 4);
    int rotateZ = vars.get(new String[]{"rotatez", "rotz", "rz"}, 0);
    boolean flipX = vars.get(new String[]{"flipx", "fx"},  random.nextBoolean());
    boolean flipY = vars.get(new String[]{"flipy", "fy"}, false);
    boolean flipZ = vars.get(new String[]{"flipz", "fz"}, random.nextBoolean());
    boolean isVillage = vars.get(new String[]{"village", "town", "city"}, false);
    boolean isInsecure = vars.get(new String[]{"insecure"}, false);
    posY = vars.get(new String[]{"auto"}, false) ? 0 : posY;
    if (vars.get(new String[]{"wand"}, false) && sender instanceof EntityPlayer && wand.containsKey(sender)) {
        UBlockPos pos = wand.get(sender).getValue();
        posX = pos.getX(); posY = pos.getY(); posZ = pos.getZ();
    }
    String worldName = vars.get(new String[]{"world"});
    UWorld world = worldName == null ? new UWorld(sender.getEntityWorld()) : UWorld.getWorld(worldName);
    if (world == null) {
        feedback(sender, "No matching world");
        return;
    }
    feedback(sender, Evaluator.cmdPaste(world, name, posX, posY, posZ, rotateX, rotateY, rotateZ, flipX, flipY, flipZ, isVillage, isInsecure));
}
 
Example 13
Project: StructPro   File: Evaluator.java   Source Code and License Vote up 5 votes
/** Saves fragment from the world to schematic
 * @param vars Variables to parse arguments
 * @param sender Who sends the command
 */
static void execSave(Variables vars, ICommandSender sender) {
    String name = vars.get(new String[]{"name"}, "unnamed");
    int posX = vars.get(new String[]{"posx", "px", "x"}, sender.getPosition().getX());
    int posY = vars.get(new String[]{"posy", "py", "y"}, sender.getPosition().getY());
    int posZ = vars.get(new String[]{"posz", "pz", "z"}, sender.getPosition().getZ());
    int width = vars.get(new String[]{"width", "w"}, 64);
    int height = vars.get(new String[]{"height", "h"}, 64);
    int length = vars.get(new String[]{"length", "l"}, 64);
    if (vars.get(new String[]{"wand"}, false) && sender instanceof EntityPlayer && wand.containsKey(sender)) {
        UBlockPos posK = wand.get(sender).getKey();
        UBlockPos posV = wand.get(sender).getValue();
        posX = Math.min(posK.getX(), posV.getX());
        posY = Math.min(posK.getY(), posV.getY());
        posZ = Math.min(posK.getZ(), posV.getZ());
        width = Math.max(posK.getX(), posV.getX()) - posX + 1;
        height = Math.max(posK.getY(), posV.getY()) - posY + 1;
        length = Math.max(posK.getZ(), posV.getZ()) - posZ + 1;
    }
    String worldName = vars.get(new String[]{"world"});
    UWorld world = worldName == null ? new UWorld(sender.getEntityWorld()) : UWorld.getWorld(worldName);
    if (world == null) {
        feedback(sender, "§4No matching world");
        return;
    }
    feedback(sender, Evaluator.cmdSave(world, name, posX, posY, posZ, width, height, length));
}
 
Example 14
Project: VillagerTrades   File: ModCommand.java   Source Code and License Vote up 5 votes
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
	World world = sender.getEntityWorld();
	if (!world.isRemote)
	{

		if (args.length == 0)
		{
			for (Map.Entry<Integer, String> kvp : VillagerRegistryHelper.getProfessionIdsAndNamesSortedById())
			{
				sender.sendMessage(new TextComponentString(kvp.getKey() + ": " + kvp.getValue()));
			}
			return;
		}

		if (args.length == 2 && args[0].equals("profession"))
		{
			VillagerProfession profession = VillagerRegistryHelper.getProfession(args[1]);
			if (profession != null)
			{
				for (VillagerCareer career : new VTTVillagerProfession(profession).getCareers())
				{
					VTTVillagerCareer vttCareer = new VTTVillagerCareer(career);
					sender.sendMessage(new TextComponentString(vttCareer.getId() + ": " + vttCareer.getName()));
					sender.sendMessage(new TextComponentString("   " + vttCareer.getCareerLevels() + " levels"));
				}
			}
		}

	}
}
 
Example 15
Project: StructPro   File: Evaluator.java   Source Code and License Vote up 5 votes
/** Paste something to the world
 * @param vars Variables to parse arguments
 * @param sender Who sends the command
 */
static void execPaste(Variables vars, ICommandSender sender) {
    Random random = new Random();
    String name = vars.get(new String[]{"name"}, "");
    int posX = vars.get(new String[]{"posx", "px", "x"}, sender.getPosition().getX());
    int posY = vars.get(new String[]{"posy", "py", "y"}, sender.getPosition().getY());
    int posZ = vars.get(new String[]{"posz", "pz", "z"}, sender.getPosition().getZ());
    int rotateX = vars.get(new String[]{"rotatex", "rotx", "rx"}, 0);
    int rotateY = vars.get(new String[]{"rotatey", "roty", "ry"}, random.nextInt() % 4);
    int rotateZ = vars.get(new String[]{"rotatez", "rotz", "rz"}, 0);
    boolean flipX = vars.get(new String[]{"flipx", "fx"},  random.nextBoolean());
    boolean flipY = vars.get(new String[]{"flipy", "fy"}, false);
    boolean flipZ = vars.get(new String[]{"flipz", "fz"}, random.nextBoolean());
    boolean isVillage = vars.get(new String[]{"village", "town", "city"}, false);
    boolean isInsecure = vars.get(new String[]{"insecure"}, false);
    posY = vars.get(new String[]{"auto"}, false) ? 0 : posY;
    if (vars.get(new String[]{"wand"}, false) && sender instanceof EntityPlayer && wand.containsKey(sender)) {
        UBlockPos pos = wand.get(sender).getValue();
        posX = pos.getX(); posY = pos.getY(); posZ = pos.getZ();
    }
    String worldName = vars.get(new String[]{"world"});
    UWorld world = worldName == null ? new UWorld(sender.getEntityWorld()) : UWorld.getWorld(worldName);
    if (world == null) {
        feedback(sender, "No matching world");
        return;
    }
    feedback(sender, Evaluator.cmdPaste(world, name, posX, posY, posZ, rotateX, rotateY, rotateZ, flipX, flipY, flipZ, isVillage, isInsecure));
}
 
Example 16
Project: StructPro   File: Evaluator.java   Source Code and License Vote up 5 votes
/** Paste something to the world
 * @param vars Variables to parse arguments
 * @param sender Who sends the command
 */
static void execPaste(Variables vars, ICommandSender sender) {
    Random random = new Random();
    String name = vars.get(new String[]{"name"}, "");
    int posX = vars.get(new String[]{"posx", "px", "x"}, sender.getPosition().getX());
    int posY = vars.get(new String[]{"posy", "py", "y"}, sender.getPosition().getY());
    int posZ = vars.get(new String[]{"posz", "pz", "z"}, sender.getPosition().getZ());
    int rotateX = vars.get(new String[]{"rotatex", "rotx", "rx"}, 0);
    int rotateY = vars.get(new String[]{"rotatey", "roty", "ry"}, random.nextInt() % 4);
    int rotateZ = vars.get(new String[]{"rotatez", "rotz", "rz"}, 0);
    boolean flipX = vars.get(new String[]{"flipx", "fx"},  random.nextBoolean());
    boolean flipY = vars.get(new String[]{"flipy", "fy"}, false);
    boolean flipZ = vars.get(new String[]{"flipz", "fz"}, random.nextBoolean());
    boolean isVillage = vars.get(new String[]{"village", "town", "city"}, false);
    boolean isInsecure = vars.get(new String[]{"insecure"}, false);
    posY = vars.get(new String[]{"auto"}, false) ? 0 : posY;
    if (vars.get(new String[]{"wand"}, false) && sender instanceof EntityPlayer && wand.containsKey(sender)) {
        UBlockPos pos = wand.get(sender).getValue();
        posX = pos.getX(); posY = pos.getY(); posZ = pos.getZ();
    }
    String worldName = vars.get(new String[]{"world"});
    UWorld world = worldName == null ? new UWorld(sender.getEntityWorld()) : UWorld.getWorld(worldName);
    if (world == null) {
        feedback(sender, "No matching world");
        return;
    }
    feedback(sender, Evaluator.cmdPaste(world, name, posX, posY, posZ, rotateX, rotateY, rotateZ, flipX, flipY, flipZ, isVillage, isInsecure));
}
 
Example 17
Project: StructPro   File: Evaluator.java   Source Code and License Vote up 5 votes
/** Saves fragment from the world to schematic
 * @param vars Variables to parse arguments
 * @param sender Who sends the command
 */
static void execSave(Variables vars, ICommandSender sender) {
    String name = vars.get(new String[]{"name"}, "unnamed");
    int posX = vars.get(new String[]{"posx", "px", "x"}, sender.getPosition().getX());
    int posY = vars.get(new String[]{"posy", "py", "y"}, sender.getPosition().getY());
    int posZ = vars.get(new String[]{"posz", "pz", "z"}, sender.getPosition().getZ());
    int width = vars.get(new String[]{"width", "w"}, 64);
    int height = vars.get(new String[]{"height", "h"}, 64);
    int length = vars.get(new String[]{"length", "l"}, 64);
    if (vars.get(new String[]{"wand"}, false) && sender instanceof EntityPlayer && wand.containsKey(sender)) {
        UBlockPos posK = wand.get(sender).getKey();
        UBlockPos posV = wand.get(sender).getValue();
        posX = Math.min(posK.getX(), posV.getX());
        posY = Math.min(posK.getY(), posV.getY());
        posZ = Math.min(posK.getZ(), posV.getZ());
        width = Math.max(posK.getX(), posV.getX()) - posX + 1;
        height = Math.max(posK.getY(), posV.getY()) - posY + 1;
        length = Math.max(posK.getZ(), posV.getZ()) - posZ + 1;
    }
    String worldName = vars.get(new String[]{"world"});
    UWorld world = worldName == null ? new UWorld(sender.getEntityWorld()) : UWorld.getWorld(worldName);
    if (world == null) {
        feedback(sender, "§4No matching world");
        return;
    }
    feedback(sender, Evaluator.cmdSave(world, name, posX, posY, posZ, width, height, length));
}
 
Example 18
Project: StructPro   File: Evaluator.java   Source Code and License Vote up 5 votes
/** Paste something to the world
 * @param vars Variables to parse arguments
 * @param sender Who sends the command
 */
static void execPaste(Variables vars, ICommandSender sender) {
    Random random = new Random();
    String name = vars.get(new String[]{"name"}, "");
    int posX = vars.get(new String[]{"posx", "px", "x"}, sender.getPosition().getX());
    int posY = vars.get(new String[]{"posy", "py", "y"}, sender.getPosition().getY());
    int posZ = vars.get(new String[]{"posz", "pz", "z"}, sender.getPosition().getZ());
    int rotateX = vars.get(new String[]{"rotatex", "rotx", "rx"}, 0);
    int rotateY = vars.get(new String[]{"rotatey", "roty", "ry"}, random.nextInt() % 4);
    int rotateZ = vars.get(new String[]{"rotatez", "rotz", "rz"}, 0);
    boolean flipX = vars.get(new String[]{"flipx", "fx"},  random.nextBoolean());
    boolean flipY = vars.get(new String[]{"flipy", "fy"}, false);
    boolean flipZ = vars.get(new String[]{"flipz", "fz"}, random.nextBoolean());
    boolean isVillage = vars.get(new String[]{"village", "town", "city"}, false);
    boolean isInsecure = vars.get(new String[]{"insecure"}, false);
    posY = vars.get(new String[]{"auto"}, false) ? 0 : posY;
    if (vars.get(new String[]{"wand"}, false) && sender instanceof EntityPlayer && wand.containsKey(sender)) {
        UBlockPos pos = wand.get(sender).getValue();
        posX = pos.getX(); posY = pos.getY(); posZ = pos.getZ();
    }
    String worldName = vars.get(new String[]{"world"});
    UWorld world = worldName == null ? new UWorld(sender.getEntityWorld()) : UWorld.getWorld(worldName);
    if (world == null) {
        feedback(sender, "No matching world");
        return;
    }
    feedback(sender, Evaluator.cmdPaste(world, name, posX, posY, posZ, rotateX, rotateY, rotateZ, flipX, flipY, flipZ, isVillage, isInsecure));
}
 
Example 19
Project: StructPro   File: Evaluator.java   Source Code and License Vote up 5 votes
/** Saves fragment from the world to schematic
 * @param vars Variables to parse arguments
 * @param sender Who sends the command
 */
static void execSave(Variables vars, ICommandSender sender) {
    String name = vars.get(new String[]{"name"}, "unnamed");
    int posX = vars.get(new String[]{"posx", "px", "x"}, sender.getPosition().getX());
    int posY = vars.get(new String[]{"posy", "py", "y"}, sender.getPosition().getY());
    int posZ = vars.get(new String[]{"posz", "pz", "z"}, sender.getPosition().getZ());
    int width = vars.get(new String[]{"width", "w"}, 64);
    int height = vars.get(new String[]{"height", "h"}, 64);
    int length = vars.get(new String[]{"length", "l"}, 64);
    if (vars.get(new String[]{"wand"}, false) && sender instanceof EntityPlayer && wand.containsKey(sender)) {
        UBlockPos posK = wand.get(sender).getKey();
        UBlockPos posV = wand.get(sender).getValue();
        posX = Math.min(posK.getX(), posV.getX());
        posY = Math.min(posK.getY(), posV.getY());
        posZ = Math.min(posK.getZ(), posV.getZ());
        width = Math.max(posK.getX(), posV.getX()) - posX + 1;
        height = Math.max(posK.getY(), posV.getY()) - posY + 1;
        length = Math.max(posK.getZ(), posV.getZ()) - posZ + 1;
    }
    String worldName = vars.get(new String[]{"world"});
    UWorld world = worldName == null ? new UWorld(sender.getEntityWorld()) : UWorld.getWorld(worldName);
    if (world == null) {
        feedback(sender, "§4No matching world");
        return;
    }
    feedback(sender, Evaluator.cmdSave(world, name, posX, posY, posZ, width, height, length));
}
 
Example 20
Project: youtube-chat-for-minecraft   File: YouTubeCommand.java   Source Code and License Vote up 4 votes
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args)
    throws CommandException {
  World world = sender.getEntityWorld();
  if (!world.isRemote) {
    if (args.length == 0) {
      showUsage(sender);
      return;
    }

    if (args[0].equalsIgnoreCase("start")) {
      YouTubeConfiguration configuration = YouTubeConfiguration.getInstance();
      String clientSecret = configuration.getClientSecret();
      if (clientSecret == null || clientSecret.isEmpty()) {
        showMessage("No client secret configurated", sender);
        return;
      }
      service.start(configuration.getVideoId(), clientSecret, sender);
    } else if (args[0].equalsIgnoreCase("stop")) {
      service.stop(sender);
    } else if (args[0].equalsIgnoreCase("logout")) {
      service.stop(sender);
      try {
        Auth.clearCredentials();
      } catch(IOException e) {
        showMessage(e.getMessage(), sender);
      }
    } else {
      if (args[0].equalsIgnoreCase("echoStart")) {
        if (!service.isInitialized()) {
          showMessage("Service is not initialized", sender);
          showUsage(sender);
        } else {
          service.subscribe(this);
        }
      } else if (args[0].equalsIgnoreCase("echoStop")) {
        service.unsubscribe(this);
      } else {
        showUsage(sender);
      }
    }
  }
}