use of net.minecraft.util.ChatComponentTranslation in project watson by totemo.
the class ClientCommandManager method executeCommand.
// --------------------------------------------------------------------------
/**
* @see net.minecraft.src.ICommandManager#executeCommand(net.minecraft.src.ICommandSender,
* java.lang.String)
*
* The JavaDocs for the interface don't currently describe the exact
* meaning of the return value. Looking at the code for
* {@link net.minecraft.src.CommandHandler} it contains a loop that
* applies a command for all players who match a particular name pattern.
* The returned value is the number of times that the command was
* successfully executed by that loop. Therefore in the case of this
* class, it returns 1 on success and 0 on error.
*/
@Override
public int executeCommand(ICommandSender sender, String commandLine) {
try {
String[] tokens = getTokens(commandLine);
String verb = tokens[0];
ICommand command = getCommand(verb);
if (command == null) {
throw new CommandNotFoundException();
}
tokens = Arrays.copyOfRange(tokens, 1, tokens.length);
if (command.canCommandSenderUseCommand(sender)) {
command.processCommand(sender, tokens);
return 1;
} else {
sendError(sender, new ChatComponentTranslation("commands.generic.permission", new Object[0]));
}
} catch (WrongUsageException ex) {
sendError(sender, new ChatComponentTranslation("commands.generic.usage", new Object[] { new ChatComponentTranslation(ex.getMessage(), ex.getErrorObjects()) }));
} catch (CommandException ex) {
sendError(sender, new ChatComponentTranslation(ex.getMessage(), ex.getErrorObjects()));
} catch (Throwable throwable) {
sendError(sender, new ChatComponentTranslation("commands.generic.exception", new Object[0]));
Log.exception(Level.WARNING, "error processing command", throwable);
}
return 0;
}
use of net.minecraft.util.ChatComponentTranslation in project Engine by VoltzEngine-Project.
the class AbstractDamageSource method func_151519_b.
@Override
public IChatComponent func_151519_b(EntityLivingBase victum) {
// TODO JUnit test to see if this method outputs the correct data
EntityLivingBase attacker = victum.func_94060_bK();
String deathTranslation = "death.attack." + this.damageType;
String playerKillTranslation = deathTranslation + ".player";
String machineKillTranslation = deathTranslation + ".machine";
if (damageSource instanceof TileEntity) {
if (StatCollector.canTranslate(machineKillTranslation)) {
return new ChatComponentTranslation(machineKillTranslation, victum.func_145748_c_());
}
} else if (attacker != null) {
if (StatCollector.canTranslate(playerKillTranslation)) {
return new ChatComponentTranslation(playerKillTranslation, victum.func_145748_c_(), attacker.func_145748_c_());
}
} else if (StatCollector.canTranslate(deathTranslation)) {
return new ChatComponentTranslation(deathTranslation, victum.func_145748_c_());
}
return null;
}
use of net.minecraft.util.ChatComponentTranslation in project PneumaticCraft by MineMaarten.
the class ContainerAmadron method canInteractWith.
@Override
public boolean canInteractWith(EntityPlayer player) {
if (player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() == Itemss.amadronTablet) {
IPressurizable pressurizable = (IPressurizable) Itemss.amadronTablet;
pressurizable.addAir(player.getCurrentEquippedItem(), -1);
if (pressurizable.getPressure(player.getCurrentEquippedItem()) > 0)
return true;
else {
player.addChatMessage(new ChatComponentTranslation("gui.tab.problems.notEnoughPressure"));
}
}
return false;
}
use of net.minecraft.util.ChatComponentTranslation in project ForestryMC by ForestryMC.
the class CommandHelpers method sendLocalizedChatMessage.
public static void sendLocalizedChatMessage(ICommandSender sender, ChatStyle chatStyle, String locTag, Object... args) {
ChatComponentTranslation chat = new ChatComponentTranslation(locTag, args);
chat.setChatStyle(chatStyle);
sender.addChatMessage(chat);
}
use of net.minecraft.util.ChatComponentTranslation in project ForestryMC by ForestryMC.
the class BlockBase method onBlockActivated.
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float par7, float par8, float par9) {
if (getDefinition(world, x, y, z).onBlockActivated(world, x, y, z, player, side, par7, par8, par9)) {
return true;
}
if (player.isSneaking()) {
return false;
}
TileBase tile = (TileBase) world.getTileEntity(x, y, z);
if (!Utils.isUseableByPlayer(player, tile)) {
return false;
}
ItemStack current = player.getCurrentEquippedItem();
if (current != null && current.getItem() != Items.bucket && tile instanceof IFluidHandler && tile.allowsAlteration(player)) {
if (FluidHelper.handleRightClick((IFluidHandler) tile, ForgeDirection.getOrientation(side), player, true, tile.canDrainWithBucket())) {
return true;
}
}
if (!Proxies.common.isSimulating(world)) {
return true;
}
if (tile.allowsViewing(player)) {
tile.openGui(player, tile);
} else {
player.addChatMessage(new ChatComponentTranslation("for.chat.accesslocked", PlayerUtil.getOwnerName(tile)));
}
return true;
}
Aggregations