Java Code Examples for net.minecraft.command.ICommandSender#addChatMessage()

The following examples show how to use net.minecraft.command.ICommandSender#addChatMessage() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CommandRMax.java    From burlapcraft with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void processCommand(ICommandSender sender, String[] args) {
	World world = sender.getEntityWorld();
	if (!world.isRemote) {
		if (args.length > 0) {
			sender.addChatMessage(new ChatComponentText("This command takes no arguments"));
			return;
		}
		
		Dungeon dungeon = BurlapCraft.currentDungeon;
		
		if (dungeon == null) {
			sender.addChatMessage(new ChatComponentText("You are not inside a dungeon"));
			return;
		}


		Thread btread = new Thread(new Runnable() {
			@Override
			public void run() {
				MinecraftSolver.learn();
			}
		});
		btread.start();

	}
}
 
Example 2
Source File: CommandDisassembleShip.java    From archimedes-ships with MIT License 5 votes vote down vote up
@Override
public void processCommand(ICommandSender icommandsender, String[] astring)
{
	if (icommandsender instanceof Entity)
	{
		Entity player = (Entity) icommandsender;
		if (player.ridingEntity instanceof EntityShip)
		{
			EntityShip ship = (EntityShip) player.ridingEntity;
			int mode = 0;
			if (astring != null && astring.length > 2)
			{
				if (astring[0].equals("overwrite") || astring[0].equals("override"))
				{
					icommandsender.addChatMessage(new ChatComponentText("Overwriting existing blocks with ship blocks"));
					mode = 1;
				} else if (astring[1].equals("drop"))
				{
					icommandsender.addChatMessage(new ChatComponentText("Dropping to items if rejoining ship with the world fails"));
					mode = 2;
				}
			} else
			{
				icommandsender.addChatMessage(new ChatComponentText("Trying to add ship blocks to world"));
			}
			
			if (!ship.disassemble(mode == 1))
			{
				if (mode == 2)
				{
					ship.dropAsItems();
				}
			}
			player.mountEntity(null);
			return;
		}
	}
	icommandsender.addChatMessage(new ChatComponentText("Not steering a ship"));
}
 
Example 3
Source File: CommandSetGlobalVariable.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void processCommand(ICommandSender sender, String[] args){
    if(args.length != 4) throw new WrongUsageException("command.deliverAmazon.args");
    String varName = args[0].startsWith("#") ? args[0].substring(1) : args[0];
    ChunkPosition newPos = new ChunkPosition(parseInt(sender, args[1]), parseInt(sender, args[2]), parseInt(sender, args[3]));
    GlobalVariableManager.getInstance().set(varName, newPos);
    sender.addChatMessage(new ChatComponentTranslation("command.setGlobalVariable.output", varName, newPos.chunkPosX, newPos.chunkPosY, newPos.chunkPosZ));
}
 
Example 4
Source File: CommandVI.java    From burlapcraft with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void processCommand(ICommandSender sender, String[] args) {
	World world = sender.getEntityWorld();
	if (!world.isRemote) {
		if (args.length > 1) {
			sender.addChatMessage(new ChatComponentText("This command takes only 1 optional argument: the gamma factor"));
			return;
		}
		
		Dungeon dungeon = BurlapCraft.currentDungeon;

		
		if (dungeon == null) {
			sender.addChatMessage(new ChatComponentText("You are not inside a dungeon"));
			return;
		}

		
		
		double gamma = 0.99;
		if(args.length == 1){
			gamma = new Double(args[0]);
		}
		
		final double fgamma = gamma;

		Thread bthread = new Thread(new Runnable() {
			@Override
			public void run() {
				MinecraftSolver.stocasticPlan(fgamma);
			}
		});

		bthread.start();

	}
}
 
Example 5
Source File: CommandEnabled.java    From TickDynamic with MIT License 5 votes vote down vote up
@Override
public void processCommand(ICommandSender sender, String[] args) {
	if(args.length == 1)
	{
		if(mod.enabled)
			sender.addChatMessage(new ChatComponentText("Tick Dynamic is currently " + EnumChatFormatting.GREEN + " Enabled!"));
		else
			sender.addChatMessage(new ChatComponentText("Tick Dynamic is currently " + EnumChatFormatting.RED + " Disabled!"));
		sender.addChatMessage(new ChatComponentText("Usage: " + getCommandUsage(sender)));
		return;
	}
	
	if(args[1].equals("yes") || args[1].equals("y"))
	{
		if(mod.enabled)
		{
			sender.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + "Tick Dynamic is already enabled!"));
			return;
		}
		mod.enabled = true;
		sender.addChatMessage(new ChatComponentText("Tick Dynamic is now " + EnumChatFormatting.GREEN + "Enabled!"));
		return;
	}
	else if(args[1].equals("no") || args[1].equals("n"))
	{
		if(!mod.enabled)
		{
			sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Tick Dynamic is already disabled!"));
			return;
		}
		mod.enabled = false;
		sender.addChatMessage(new ChatComponentText("Tick Dynamic is now " + EnumChatFormatting.RED + "Disabled!"));
		return;
	}
	
	sender.addChatMessage(new ChatComponentText("Unrecognized argument: " + args[1]));
}
 
Example 6
Source File: CommandShipInfo.java    From archimedes-ships with MIT License 5 votes vote down vote up
@Override
public void processCommand(ICommandSender icommandsender, String[] astring)
{
	EntityShip ship = null;
	if (icommandsender instanceof Entity)
	{
		Entity player = (Entity) icommandsender;
		if (player.ridingEntity instanceof EntityShip)
		{
			ship = (EntityShip) player.ridingEntity;
		} else if (player.ridingEntity instanceof EntitySeat)
		{
			ship = ((EntitySeat) player.ridingEntity).getParentShip();
		}
	}
	if (ship != null)
	{
		icommandsender.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN.toString() + EnumChatFormatting.BOLD.toString() + "Ship information"));
		icommandsender.addChatMessage(new ChatComponentText(String.format(Locale.ENGLISH, "Airship: %b", ship.getCapabilities().canFly())));
		icommandsender.addChatMessage(new ChatComponentText(String.format(Locale.ENGLISH, "Position: %.2f, %.2f, %.2f", ship.posX, ship.posY, ship.posZ)));
		icommandsender.addChatMessage(new ChatComponentText(String.format(Locale.ENGLISH, "Speed: %.2f km/h", ship.getHorizontalVelocity() * 20 * 3.6F)));
		float f = 100F * ship.getCapabilities().getBalloonCount() / ship.getCapabilities().getBlockCount();
		icommandsender.addChatMessage(new ChatComponentText(String.format(Locale.ENGLISH, "Block count: %d", ship.getCapabilities().getBlockCount())));
		icommandsender.addChatMessage(new ChatComponentText(String.format(Locale.ENGLISH, "Balloon count: %d", ship.getCapabilities().getBalloonCount())));
		icommandsender.addChatMessage(new ChatComponentText(String.format(Locale.ENGLISH, "Balloon percentage: %.0f%%", f)));
		icommandsender.addChatMessage(new ChatComponentText(""));
		return;
	}
	icommandsender.addChatMessage(new ChatComponentText("Not steering a ship"));
}
 
Example 7
Source File: CommandReloadGroups.java    From TickDynamic with MIT License 5 votes vote down vote up
@Override
public void processCommand(ICommandSender sender, String[] args) {
	sender.addChatMessage(new ChatComponentText("Reloading Groups configuration..."));
	sender.addChatMessage(new ChatComponentText("Note: Moving of (tile)entities to new groups might cause lag!!!"));
	mod.loadConfig(true);
	sender.addChatMessage(new ChatComponentText("Reload and moving complete!"));
}
 
Example 8
Source File: CommandHandler.java    From TickDynamic with MIT License 5 votes vote down vote up
@Override
public void processCommand(ICommandSender sender, String[] args) {
	if(args.length == 0)
	{
		sender.addChatMessage(new ChatComponentText("Usage: " + getCommandUsage(sender)));
		return;
	}
	
	if(args[0].equals("tps"))
	{
		
		sender.addChatMessage(new ChatComponentText("Average TPS: " + getTPSFormatted(mod) + " TPS"));
		return;
	} else if(args[0].equals("identify")) {
		sender.addChatMessage(new ChatComponentText("Command not yet implemented! This will allow you to check what group a Tile or Entity belongs to by right clicking it.(And other info, like TPS)"));
		return;
	} else if(args[0].equals("help")) {
		sender.addChatMessage(new ChatComponentText("You can find the documentation over at http://mods.stjerncraft.com/tickdynamic"));
		return;
	}
	
	//Send it over to subCommand handler
	ICommand subHandler = subCommandHandlers.get(args[0]);
	if(subHandler == null)
	{
		sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "No handler for the command " + EnumChatFormatting.ITALIC + args[0]));
		return;
	}
	subHandler.processCommand(sender, args);
}
 
Example 9
Source File: CommandWorld.java    From TickDynamic with MIT License 4 votes vote down vote up
public void splitAndSend(ICommandSender sender, StringBuilder outputBuilder) {
	//Split newline and send
	String[] chatLines = outputBuilder.toString().split("\n");
	for(String chatLine : chatLines)
		sender.addChatMessage(new ChatComponentText(chatLine));
}
 
Example 10
Source File: QCraftCommand.java    From qcraft-mod with Apache License 2.0 4 votes vote down vote up
private void sendChat( ICommandSender icommandsender, String text )
{
    icommandsender.addChatMessage( new ChatComponentText( text ) );
}
 
Example 11
Source File: RunGC.java    From bartworks with MIT License 4 votes vote down vote up
@Override
public void processCommand(ICommandSender p_71515_1_, String[] p_71515_2_) {
    Runtime.getRuntime().gc();
    p_71515_1_.addChatMessage(new ChatComponentText("Ran GC!"));
}
 
Example 12
Source File: CommandDisassembleNear.java    From archimedes-ships with MIT License 4 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public void processCommand(ICommandSender icommandsender, String[] astring)
{
	if (icommandsender instanceof Entity)
	{
		double range = 16D;
		if (astring != null && astring.length > 0)
		{
			try
			{
				range = Integer.parseInt(astring[0]);
			} catch (NumberFormatException e)
			{
				throw new NumberInvalidException();
			}
		}
		double rangesqrd = range * range;
		
		Entity player = (Entity) icommandsender;
		EntityShip ne = null;
		if (player.ridingEntity instanceof EntityShip)
		{
			ne = (EntityShip) player.ridingEntity;
		} else
		{
			double nd = 0D;
			double d;
			for (Entity entity : (List<Entity>) player.worldObj.getLoadedEntityList())
			{
				if (entity instanceof EntityShip)
				{
					d = player.getDistanceSqToEntity(entity);
					if (d < rangesqrd && (ne == null || d < nd))
					{
						ne = (EntityShip) entity;
						nd = d;
					}
				}
			}
		}
		
		if (ne == null)
		{
			icommandsender.addChatMessage(new ChatComponentText("No ship in a " + ((int) range) + " blocks' range"));
			return;
		}
		if (!ne.disassemble(false))
		{
			icommandsender.addChatMessage(new ChatComponentText("Failed to disassemble ship; dropping to items"));
			ne.dropAsItems();
		}
		ne.setDead();
	}
}
 
Example 13
Source File: CommandAmazonDelivery.java    From PneumaticCraft with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void processCommand(ICommandSender sender, String[] args){
    if(args.length < 2) throw new WrongUsageException("command.deliverAmazon.args");
    int x, y, z;
    int curArg;
    String regex = "-?\\d+";
    if(args[0].matches(regex)) {
        if(args.length < 4) throw new WrongUsageException("command.deliverAmazon.args");
        if(!args[1].matches(regex) || !args[2].matches(regex)) throw new WrongUsageException("command.deliverAmazon.coords");
        x = Integer.parseInt(args[0]);
        y = Integer.parseInt(args[1]);
        z = Integer.parseInt(args[2]);
        curArg = 3;
    } else {
        EntityPlayerMP player = MinecraftServer.getServer().getConfigurationManager().func_152612_a(args[0]);
        if(player != null) {
            x = (int)Math.floor(player.posX);
            y = (int)Math.floor(player.posY) + 1;
            z = (int)Math.floor(player.posZ);
            curArg = 1;
        } else {
            throw new WrongUsageException("command.deliverAmazon.playerName");
        }
    }

    if(args.length < curArg + 3) throw new WrongUsageException("command.deliverAmazon.args");
    if(!args[curArg].matches(regex) || !args[curArg + 1].matches(regex) || !args[curArg + 2].matches(regex)) throw new WrongUsageException("command.deliverAmazon.coords");
    TileEntity te = sender.getEntityWorld().getTileEntity(Integer.parseInt(args[curArg]), Integer.parseInt(args[curArg + 1]), Integer.parseInt(args[curArg + 2]));
    IInventory inv = IOHelper.getInventoryForTE(te);
    if(inv != null) {
        List<ItemStack> deliveredStacks = new ArrayList<ItemStack>();
        for(int i = 0; i < inv.getSizeInventory() && deliveredStacks.size() < 65; i++) {
            if(inv.getStackInSlot(i) != null) deliveredStacks.add(inv.getStackInSlot(i));
        }
        if(deliveredStacks.size() > 0) {
            PneumaticRegistry.getInstance().deliverItemsAmazonStyle(sender.getEntityWorld(), x, y, z, deliveredStacks.toArray(new ItemStack[deliveredStacks.size()]));
            sender.addChatMessage(new ChatComponentTranslation("command.deliverAmazon.success"));
        } else {
            sender.addChatMessage(new ChatComponentTranslation("command.deliverAmazon.noItems"));
        }
    } else {
        throw new WrongUsageException("command.deliverAmazon.noInventory");
    }

}
 
Example 14
Source File: UpdateChecker.java    From PneumaticCraft with GNU General Public License v3.0 4 votes vote down vote up
private static void sendMessage(ICommandSender player, String message){
    player.addChatMessage(new ChatComponentTranslation(message));
}
 
Example 15
Source File: CommandBFS.java    From burlapcraft with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void processCommand(ICommandSender sender, String[] args) {
	World world = sender.getEntityWorld();
	if (!world.isRemote) {
		if (args.length > 2) {
			sender.addChatMessage(new ChatComponentText("This command takes only 2 optional arguments: closed or open as the first, and all or noplace as the second."));
			return;
		}
		
		Dungeon dungeon = BurlapCraft.currentDungeon;
		
		if (dungeon == null) {
			sender.addChatMessage(new ChatComponentText("You are not inside a dungeon"));
			return;
		}


		boolean closed = true;
		boolean place = true;
		if(args.length == 1){
			if(args[0].equals("open")){
				closed = false;
			}
		}
		
		if(args.length == 2){
			if(args[0].equals("open")){
				closed = false;
			}
			if(args[1].equals("noplace")){
				place = false;
			}
		}

		final boolean fclosed = closed;
		final boolean fplace = place;

		Thread bthread = new Thread(new Runnable() {
			@Override
			public void run() {
				MinecraftSolver.plan(0, fclosed, fplace);
			}
		});

		bthread.start();


	}
}
 
Example 16
Source File: CommandListWorlds.java    From TickDynamic with MIT License 4 votes vote down vote up
public void splitAndSend(ICommandSender sender, StringBuilder outputBuilder) {
	//Split newline and send
	String[] chatLines = outputBuilder.toString().split("\n");
	for(String chatLine : chatLines)
		sender.addChatMessage(new ChatComponentText(chatLine));
}
 
Example 17
Source File: CommandTeleport.java    From burlapcraft with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void processCommand(ICommandSender sender, String[] args) {
	
	if (!HandlerDungeonGeneration.dungeonsCreated) {
		sender.addChatMessage(new ChatComponentText("Dungeons aren't yet created."));
		return;
	}
	World world = sender.getEntityWorld();
	if (!world.isRemote) {
		if (args.length == 0) {
			sender.addChatMessage(new ChatComponentText("Invalid argument"));
			return;
		}
		
		if (args.length != 1 && args.length != 3) {
			sender.addChatMessage(new ChatComponentText("This command takes just one argument, or 3 integers for pose"));
			return;
		}
		EntityPlayer player = HandlerEvents.player;
		if (args.length == 3) {
			int x = Integer.valueOf(args[0]);
			int y = Integer.valueOf(args[1])	;
			int z = Integer.valueOf(args[2]);	
			Pose newp= Pose.fromXyz(x, y, z);
			HelperActions.setPlayerPosition(player, newp);
			
		}
		
		String dungeonName = args[0];

		
		if (dungeonName.equals("out")) {
			Pose spawnPoint = Pose.fromXyz(HandlerDungeonGeneration.playerSpawnPose.getX(), HandlerDungeonGeneration.playerSpawnPose.getY(), HandlerDungeonGeneration.playerSpawnPose.getZ());
			HelperActions.setPlayerPosition(player, spawnPoint);
			return;
		} 
		
		Dungeon d = BurlapCraft.dungeonMap.get(dungeonName);
		if (d == null) {
			ArrayList dungeonNames = new ArrayList(BurlapCraft.dungeonMap.keySet());
			Collections.sort(dungeonNames);
			sender.addChatMessage(new ChatComponentText("No dungeon '" + dungeonName + "'.  Dungeons are: "  + dungeonNames));
			return;
		}

		MinecraftStateGeneratorHelper.blockNameMap.clear();
		MinecraftStateGeneratorHelper.invBlockNameMap.clear();
		Pose offset = d.getPlayerStartOffset();
		Pose playerPose = d.getPose().add(offset);
		HelperActions.setPlayerPosition(player, playerPose);

		BurlapCraft.currentDungeon = d;
	}
	
}
 
Example 18
Source File: ClearCraftingCache.java    From bartworks with MIT License 4 votes vote down vote up
@Override
public void processCommand(ICommandSender p_71515_1_, String[] p_71515_2_) {
    BWCoreStaticReplacementMethodes.RECENTLYUSEDRECIPES.clear();
    p_71515_1_.addChatMessage(new ChatComponentText("Recipe Cache cleared? "+(BWCoreStaticReplacementMethodes.RECENTLYUSEDRECIPES.size() == 0)));
}
 
Example 19
Source File: GetWorkingDirectory.java    From bartworks with MIT License 4 votes vote down vote up
@Override
public void processCommand(ICommandSender p_71515_1_, String[] p_71515_2_) {
    p_71515_1_.addChatMessage(new ChatComponentText(Minecraft.getMinecraft().mcDataDir.getAbsolutePath()));
}
 
Example 20
Source File: CommandCurrentPath.java    From burlapcraft with GNU Lesser General Public License v3.0 3 votes vote down vote up
@Override
public void processCommand(ICommandSender sender, String[] args) {

	String workingDir = System.getProperty("user.dir");
	sender.addChatMessage(new ChatComponentText("Current working directory : " + workingDir));

}