Search in sources :

Example 11 with Style

use of net.minecraft.util.text.Style in project Random-Things by lumien231.

the class BlockEnderMailbox method onBlockActivated.

@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
    if (!worldIn.isRemote) {
        ItemStack heldItem = playerIn.getHeldItemMainhand();
        if (playerIn.isSneaking() && heldItem.getItem() == ModItems.enderLetter) {
            NBTTagCompound compound;
            if ((compound = heldItem.getTagCompound()) != null) {
                if (compound.hasKey("receiver") && !compound.getBoolean("received")) {
                    GameProfile playerProfile = worldIn.getMinecraftServer().getPlayerProfileCache().getGameProfileForUsername(compound.getString("receiver"));
                    if (playerProfile != null && playerProfile.getId() != null) {
                        EnderMailboxInventory mailboxInventory = EnderLetterHandler.get(worldIn).getOrCreateInventoryForPlayer(playerProfile.getId());
                        for (int slot = 0; slot < mailboxInventory.getSizeInventory(); slot++) {
                            if (mailboxInventory.getStackInSlot(slot).isEmpty()) {
                                ItemStack sendingLetter = heldItem.copy();
                                heldItem.shrink(1);
                                sendingLetter.getTagCompound().setBoolean("received", true);
                                sendingLetter.getTagCompound().setString("sender", playerIn.getGameProfile().getName());
                                mailboxInventory.setInventorySlotContents(slot, sendingLetter);
                                playerIn.world.playSound(null, pos, SoundEvents.ENTITY_ENDERMEN_TELEPORT, SoundCategory.BLOCKS, 1, 1);
                                return true;
                            }
                        }
                        playerIn.sendMessage(new TextComponentTranslation("item.enderLetter.noSpace").setStyle(new Style().setColor(TextFormatting.DARK_PURPLE)));
                    } else {
                        playerIn.sendMessage(new TextComponentTranslation("item.enderLetter.noPlayer", compound.getString("receiver")).setStyle(new Style().setColor(TextFormatting.DARK_PURPLE)));
                    }
                }
            }
            return true;
        }
        TileEntityEnderMailbox te = (TileEntityEnderMailbox) worldIn.getTileEntity(pos);
        if (te.getOwner() != null) {
            if (te.getOwner().equals(playerIn.getGameProfile().getId())) {
                playerIn.openGui(RandomThings.instance, GuiIds.ENDER_MAILBOX, worldIn, pos.getX(), pos.getY(), pos.getZ());
            } else {
                playerIn.sendMessage(new TextComponentTranslation("block.enderMailbox.owner").setStyle(new Style().setColor(TextFormatting.RED)));
            }
        }
    }
    return true;
}
Also used : TileEntityEnderMailbox(lumien.randomthings.tileentity.TileEntityEnderMailbox) EnderMailboxInventory(lumien.randomthings.handler.EnderLetterHandler.EnderMailboxInventory) TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) GameProfile(com.mojang.authlib.GameProfile) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) Style(net.minecraft.util.text.Style) ItemStack(net.minecraft.item.ItemStack)

Example 12 with Style

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

the class CommandHelpers method printHelp.

public static void printHelp(ICommandSender sender, IModCommand command) {
    Style header = new Style();
    header.setColor(TextFormatting.GRAY);
    header.setBold(true);
    sendLocalizedChatMessage(sender, header, "command.buildcraft." + command.getFullCommandString().replace(" ", ".") + ".format", command.getFullCommandString());
    Style body = new Style();
    body.setColor(TextFormatting.GRAY);
    if (command.getCommandAliases().size() > 0) {
        sendLocalizedChatMessage(sender, body, "command.buildcraft.aliases", command.getCommandAliases().toString().replace("[", "").replace("]", ""));
    }
    if (command.getMinimumPermissionLevel() > 0) {
        sendLocalizedChatMessage(sender, body, "command.buildcraft.permlevel", command.getMinimumPermissionLevel());
    }
    sendLocalizedChatMessage(sender, body, "command.buildcraft." + command.getFullCommandString().replace(" ", ".") + ".help");
    if (!command.getChildren().isEmpty()) {
        sendLocalizedChatMessage(sender, "command.buildcraft.list");
        for (SubCommand child : command.getChildren()) {
            sendLocalizedChatMessage(sender, "command.buildcraft." + child.getFullCommandString().replace(" ", ".") + ".desc", child.getCommandName());
        }
    }
}
Also used : Style(net.minecraft.util.text.Style)

Example 13 with Style

use of net.minecraft.util.text.Style 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 14 with Style

use of net.minecraft.util.text.Style 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 15 with Style

use of net.minecraft.util.text.Style 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

Style (net.minecraft.util.text.Style)51 TextComponentTranslation (net.minecraft.util.text.TextComponentTranslation)30 TextComponentString (net.minecraft.util.text.TextComponentString)21 ITextComponent (net.minecraft.util.text.ITextComponent)17 ClickEvent (net.minecraft.util.text.event.ClickEvent)10 BlockPos (net.minecraft.util.math.BlockPos)9 CommandException (net.minecraft.command.CommandException)7 EntityPlayer (net.minecraft.entity.player.EntityPlayer)4 ItemStack (net.minecraft.item.ItemStack)4 World (net.minecraft.world.World)4 Colony (com.minecolonies.coremod.colony.Colony)3 PlayerIdentifier (com.mraof.minestuck.util.IdentifierHandler.PlayerIdentifier)3 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)3 GameProfile (com.mojang.authlib.GameProfile)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)2 HoverEvent (net.minecraft.util.text.event.HoverEvent)2 Biome (net.minecraft.world.biome.Biome)2 FluidStack (net.minecraftforge.fluids.FluidStack)2