Search in sources :

Example 81 with ChatComponentTranslation

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;
}
Also used : WrongUsageException(net.minecraft.command.WrongUsageException) ICommand(net.minecraft.command.ICommand) ChatComponentTranslation(net.minecraft.util.ChatComponentTranslation) CommandException(net.minecraft.command.CommandException) CommandNotFoundException(net.minecraft.command.CommandNotFoundException)

Example 82 with ChatComponentTranslation

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;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) ChatComponentTranslation(net.minecraft.util.ChatComponentTranslation) EntityLivingBase(net.minecraft.entity.EntityLivingBase)

Example 83 with ChatComponentTranslation

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;
}
Also used : IPressurizable(pneumaticCraft.api.item.IPressurizable) ChatComponentTranslation(net.minecraft.util.ChatComponentTranslation)

Example 84 with ChatComponentTranslation

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);
}
Also used : ChatComponentTranslation(net.minecraft.util.ChatComponentTranslation)

Example 85 with ChatComponentTranslation

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;
}
Also used : ChatComponentTranslation(net.minecraft.util.ChatComponentTranslation) ItemStack(net.minecraft.item.ItemStack) IFluidHandler(net.minecraftforge.fluids.IFluidHandler)

Aggregations

ChatComponentTranslation (net.minecraft.util.ChatComponentTranslation)89 ItemStack (net.minecraft.item.ItemStack)21 TileEntity (net.minecraft.tileentity.TileEntity)15 EntityPlayer (net.minecraft.entity.player.EntityPlayer)14 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)11 ChatComponentText (net.minecraft.util.ChatComponentText)6 ArrayList (java.util.ArrayList)5 Block (net.minecraft.block.Block)4 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)4 World (net.minecraft.world.World)4 Item1N4148 (club.nsdn.nyasamarailway.item.tool.Item1N4148)3 ItemNTP32Bit (club.nsdn.nyasamarailway.item.tool.ItemNTP32Bit)3 ItemNTP8Bit (club.nsdn.nyasamarailway.item.tool.ItemNTP8Bit)3 TileEntityActuator (club.nsdn.nyasamatelecom.api.tileentity.TileEntityActuator)3 BufferedImage (java.awt.image.BufferedImage)3 IChatComponent (net.minecraft.util.IChatComponent)3 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)3 Int3 (WayofTime.alchemicalWizardry.api.Int3)2 TEReagentConduit (WayofTime.alchemicalWizardry.common.tileEntity.TEReagentConduit)2 TrainPacket (club.nsdn.nyasamarailway.network.TrainPacket)2