Search in sources :

Example 36 with TextComponentTranslation

use of net.minecraft.util.text.TextComponentTranslation in project pnc-repressurized by TeamPneumatic.

the class PacketAmadronTradeAdd method handleServerSide.

@Override
public void handleServerSide(PacketAmadronTradeAdd message, EntityPlayer player) {
    AmadronOfferCustom offer = message.getOffer();
    offer.updatePlayerId();
    if (AmadronOfferManager.getInstance().hasOffer(offer.copy().invert())) {
        player.sendStatusMessage(new TextComponentTranslation("message.amadron.duplicateReversedOffer"), false);
    } else if (AmadronOfferManager.getInstance().addStaticOffer(offer)) {
        if (AmadronOfferSettings.notifyOfTradeAddition)
            NetworkHandler.sendToAll(message);
        try {
            AmadronOfferStaticConfig.INSTANCE.writeToFile();
        } catch (IOException e) {
            e.printStackTrace();
        }
    } else {
        player.sendStatusMessage(new TextComponentTranslation("message.amadron.duplicateOffer"), false);
    }
}
Also used : TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) IOException(java.io.IOException) AmadronOfferCustom(me.desht.pneumaticcraft.common.recipes.AmadronOfferCustom)

Example 37 with TextComponentTranslation

use of net.minecraft.util.text.TextComponentTranslation in project BuildCraft by BuildCraft.

the class CommandHelpers method sendLocalizedChatMessage.

public static void sendLocalizedChatMessage(ICommandSender sender, Style chatStyle, String locTag, Object... args) {
    TextComponentTranslation chat = new TextComponentTranslation(locTag, args);
    chat.setStyle(chatStyle);
    sender.addChatMessage(chat);
}
Also used : TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation)

Example 38 with TextComponentTranslation

use of net.minecraft.util.text.TextComponentTranslation in project BiomeTweaker by superckl.

the class CommandListBiomes method execute.

@Override
public void execute(final MinecraftServer server, final ICommandSender sender, final String[] args) throws CommandException {
    sender.sendMessage(new TextComponentTranslation("biometweaker.msg.listbiomes.output.text").setStyle(new Style().setColor(TextFormatting.AQUA)));
    final Iterator<Biome> it = Biome.REGISTRY.iterator();
    while (it.hasNext()) {
        final Biome gen = it.next();
        if (gen != null) {
            final String message = new StringBuilder().append(Biome.getIdForBiome(gen)).append(" - ").append(gen.getBiomeName()).toString();
            sender.sendMessage(new TextComponentString(message).setStyle(new Style().setColor(TextFormatting.GOLD)));
        }
    }
}
Also used : TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) Biome(net.minecraft.world.biome.Biome) Style(net.minecraft.util.text.Style) TextComponentString(net.minecraft.util.text.TextComponentString) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 39 with TextComponentTranslation

use of net.minecraft.util.text.TextComponentTranslation in project BiomeTweaker by superckl.

the class CommandSetBiome method execute.

@Override
public void execute(final MinecraftServer server, final ICommandSender sender, final String[] args) throws CommandException {
    final BlockPos coord = sender.getPosition();
    final World world = sender.getEntityWorld();
    if ((coord != null) && (world != null)) {
        if ((args.length < 2) || (args.length > 3)) {
            sender.sendMessage(new TextComponentTranslation("biometweaker.msg.setbiome.invalargs.text").setStyle(new Style().setColor(TextFormatting.RED)));
            return;
        }
        Biome gen = null;
        Integer i = Ints.tryParse(args[0]);
        if (i != null)
            gen = Biome.getBiome(i);
        else {
            final Iterator<Biome> it = Biome.REGISTRY.iterator();
            while (it.hasNext()) {
                final Biome biome = it.next();
                if ((biome != null) && biome.getBiomeName().equals(args[0])) {
                    gen = biome;
                    break;
                }
            }
        }
        if (gen == null) {
            sender.sendMessage(new TextComponentTranslation("biometweaker.msg.setbiome.invalargs.text").setStyle(new Style().setColor(TextFormatting.RED)));
            return;
        }
        final int id = Biome.getIdForBiome(gen);
        i = Ints.tryParse(args[1]);
        if (i == null) {
            sender.sendMessage(new TextComponentTranslation("biometweaker.msg.setbiome.invalargs.text").setStyle(new Style().setColor(TextFormatting.RED)));
            return;
        }
        boolean blocks = true;
        if (args.length == 3)
            if (args[2].equalsIgnoreCase("block"))
                blocks = true;
            else if (args[2].equalsIgnoreCase("chunk"))
                blocks = false;
            else {
                sender.sendMessage(new TextComponentTranslation("biometweaker.msg.setbiome.invalargs.text").setStyle(new Style().setColor(TextFormatting.RED)));
                return;
            }
        int count = 0;
        if (blocks) {
            for (int x = coord.getX() - i; x <= (coord.getX() + i); x++) for (int z = coord.getZ() - i; z <= (coord.getZ() + i); z++) {
                final int realX = x & 15;
                final int realZ = z & 15;
                /*if(x < 0)
							realX = 15-realX;
						if(z < 0)
							realZ = 15-realZ;*/
                final Chunk chunk = world.getChunkFromBlockCoords(new BlockPos(x, 0, z));
                chunk.getBiomeArray()[(realZ * 16) + realX] = (byte) id;
                chunk.markDirty();
                count++;
            }
            sender.sendMessage(new TextComponentTranslation("biometweaker.msg.setbiome.blocksuccess.text", count, gen.getBiomeName()).setStyle(new Style().setColor(TextFormatting.GOLD)));
        } else {
            final byte[] biomeArray = new byte[256];
            Arrays.fill(biomeArray, (byte) id);
            final int chunkX = coord.getX() >> 4;
            final int chunkZ = coord.getZ() >> 4;
            for (int x = chunkX - i; x <= (chunkX + i); x++) for (int z = chunkZ - i; z <= (chunkZ + i); z++) {
                final Chunk chunk = world.getChunkFromChunkCoords(x, z);
                chunk.setBiomeArray(Arrays.copyOf(biomeArray, biomeArray.length));
                chunk.markDirty();
                count++;
            }
            sender.sendMessage(new TextComponentTranslation("biometweaker.msg.setbiome.chunksuccess.text", count, gen.getBiomeName()).setStyle(new Style().setColor(TextFormatting.GOLD)));
        }
    } else
        sender.sendMessage(new TextComponentTranslation("biometweaker.msg.info.invalsender.text").setStyle(new Style().setColor(TextFormatting.RED)));
}
Also used : TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) Biome(net.minecraft.world.biome.Biome) Style(net.minecraft.util.text.Style) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World) Chunk(net.minecraft.world.chunk.Chunk)

Example 40 with TextComponentTranslation

use of net.minecraft.util.text.TextComponentTranslation in project BiomeTweaker by superckl.

the class CommandOutput method execute.

@Override
public void execute(final MinecraftServer server, final ICommandSender sender, final String[] args) throws CommandException {
    try {
        BiomeTweaker.getInstance().generateOutputFiles();
        sender.sendMessage(new TextComponentTranslation("biometweaker.msg.output.success.text").setStyle(new Style().setColor(TextFormatting.AQUA)));
    } catch (final IOException e) {
        sender.sendMessage(new TextComponentTranslation("biometweaker.msg.output.failure.text").setStyle(new Style().setColor(TextFormatting.RED)));
        LogHelper.error("Failed to regenerate output files!");
        e.printStackTrace();
    }
}
Also used : TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) Style(net.minecraft.util.text.Style) IOException(java.io.IOException)

Aggregations

TextComponentTranslation (net.minecraft.util.text.TextComponentTranslation)502 ItemStack (net.minecraft.item.ItemStack)134 ITextComponent (net.minecraft.util.text.ITextComponent)82 EntityPlayer (net.minecraft.entity.player.EntityPlayer)72 BlockPos (net.minecraft.util.math.BlockPos)70 TextComponentString (net.minecraft.util.text.TextComponentString)66 Style (net.minecraft.util.text.Style)60 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)58 TileEntity (net.minecraft.tileentity.TileEntity)45 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)36 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)33 ArrayList (java.util.ArrayList)32 World (net.minecraft.world.World)30 IBlockState (net.minecraft.block.state.IBlockState)28 EnumFacing (net.minecraft.util.EnumFacing)26 CommandException (net.minecraft.command.CommandException)25 Block (net.minecraft.block.Block)20 Nonnull (javax.annotation.Nonnull)19 WrongUsageException (net.minecraft.command.WrongUsageException)19 EnumActionResult (net.minecraft.util.EnumActionResult)19