Search in sources :

Example 81 with ChatComponentText

use of v1_8_9.net.minecraft.util.ChatComponentText in project BiomeTweaker by superckl.

the class CommandInfo method processCommand.

@Override
public void processCommand(final ICommandSender sender, final String[] p_71515_2_) {
    final ChunkCoordinates coord = sender.getPlayerCoordinates();
    final World world = sender.getEntityWorld();
    if ((coord != null) && (world != null)) {
        final JsonObject obj = BiomeHelper.fillJsonObject(world.getBiomeGenForCoords(coord.posX, coord.posZ), coord.posX, coord.posY, coord.posZ);
        sender.addChatMessage(new ChatComponentTranslation("biometweaker.msg.info.output.text").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.AQUA)));
        final ChatStyle gold = new ChatStyle().setColor(EnumChatFormatting.GOLD);
        final Gson gson = new GsonBuilder().setPrettyPrinting().create();
        for (final Entry<String, JsonElement> entry : obj.entrySet()) if (entry.getValue().isJsonArray())
            // It looks hideous in MC chat.
            sender.addChatMessage(new ChatComponentText(entry.getKey() + ": Check the output files.").setChatStyle(gold));
        else
            sender.addChatMessage(new ChatComponentText(entry.getKey() + ": " + gson.toJson(entry.getValue())).setChatStyle(gold));
    } else
        sender.addChatMessage(new ChatComponentTranslation("biometweaker.msg.info.invalsender.text").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.RED)));
}
Also used : ChatStyle(net.minecraft.util.ChatStyle) GsonBuilder(com.google.gson.GsonBuilder) ChatComponentTranslation(net.minecraft.util.ChatComponentTranslation) JsonElement(com.google.gson.JsonElement) ChunkCoordinates(net.minecraft.util.ChunkCoordinates) JsonObject(com.google.gson.JsonObject) Gson(com.google.gson.Gson) World(net.minecraft.world.World) ChatComponentText(net.minecraft.util.ChatComponentText)

Example 82 with ChatComponentText

use of v1_8_9.net.minecraft.util.ChatComponentText in project RFTools by McJty.

the class CmdDelEffect method execute.

@Override
public void execute(ICommandSender sender, String[] args) {
    if (args.length < 2) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Several parameters are missing!"));
        return;
    } else if (args.length > 2) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Too many parameters!"));
        return;
    }
    String effectName = fetchString(sender, args, 1, "");
    effectName = "EFFECT_" + effectName.toUpperCase();
    EffectType type = null;
    try {
        type = EffectType.valueOf(effectName);
    } catch (IllegalArgumentException e) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Bad effect name!"));
        return;
    }
    World world = sender.getEntityWorld();
    int dim = world.provider.dimensionId;
    RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(world);
    DimensionInformation information = dimensionManager.getDimensionInformation(dim);
    if (information == null) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Not an RFTools dimension!"));
        return;
    }
    if (!information.getEffectTypes().contains(type)) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "This effect is not active!"));
        return;
    }
    information.getEffectTypes().remove(type);
    dimensionManager.save(world);
}
Also used : EffectType(mcjty.rftools.dimension.world.types.EffectType) World(net.minecraft.world.World) ChatComponentText(net.minecraft.util.ChatComponentText) DimensionInformation(mcjty.rftools.dimension.DimensionInformation) RfToolsDimensionManager(mcjty.rftools.dimension.RfToolsDimensionManager)

Example 83 with ChatComponentText

use of v1_8_9.net.minecraft.util.ChatComponentText in project RFTools by McJty.

the class CmdLoadDim method execute.

@Override
public void execute(ICommandSender sender, String[] args) {
    if (args.length < 3) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "The dimension and filename parameters are missing!"));
        return;
    } else if (args.length > 3) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Too many parameters!"));
        return;
    }
    int dim = fetchInt(sender, args, 1, 0);
    String filename = fetchString(sender, args, 2, null);
    World world = sender.getEntityWorld();
    RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(world);
    if (dimensionManager.getDimensionDescriptor(dim) == null) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Not an RFTools dimension!"));
        return;
    }
    DimensionInformation information = dimensionManager.getDimensionInformation(dim);
    String error = information.loadFromJson(filename);
    if (error != null) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Error: " + error));
    } else {
        dimensionManager.save(world);
    }
}
Also used : World(net.minecraft.world.World) ChatComponentText(net.minecraft.util.ChatComponentText) DimensionInformation(mcjty.rftools.dimension.DimensionInformation) RfToolsDimensionManager(mcjty.rftools.dimension.RfToolsDimensionManager)

Example 84 with ChatComponentText

use of v1_8_9.net.minecraft.util.ChatComponentText in project RFTools by McJty.

the class CmdSetOwner method execute.

@Override
public void execute(ICommandSender sender, String[] args) {
    if (args.length < 3) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "The dimension and player parameters are missing!"));
        return;
    } else if (args.length > 3) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Too many parameters!"));
        return;
    }
    int dim = fetchInt(sender, args, 1, 0);
    String playerName = fetchString(sender, args, 2, null);
    World world = sender.getEntityWorld();
    RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(world);
    if (dimensionManager.getDimensionDescriptor(dim) == null) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Not an RFTools dimension!"));
        return;
    }
    for (Object o : MinecraftServer.getServer().getConfigurationManager().playerEntityList) {
        EntityPlayerMP entityPlayerMP = (EntityPlayerMP) o;
        if (playerName.equals(entityPlayerMP.getDisplayName())) {
            DimensionInformation information = dimensionManager.getDimensionInformation(dim);
            information.setOwner(playerName, entityPlayerMP.getGameProfile().getId());
            sender.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + "Owner of dimension changed!"));
            dimensionManager.save(world);
            return;
        }
    }
    sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Could not find player!"));
}
Also used : EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) World(net.minecraft.world.World) ChatComponentText(net.minecraft.util.ChatComponentText) DimensionInformation(mcjty.rftools.dimension.DimensionInformation) RfToolsDimensionManager(mcjty.rftools.dimension.RfToolsDimensionManager)

Example 85 with ChatComponentText

use of v1_8_9.net.minecraft.util.ChatComponentText in project RFTools by McJty.

the class CmdDelDimension method execute.

@Override
public void execute(ICommandSender sender, String[] args) {
    if (args.length < 2) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "The dimension parameters is missing!"));
        return;
    } else if (args.length > 2) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Too many parameters!"));
        return;
    }
    int dim = fetchInt(sender, args, 1, 0);
    World world = sender.getEntityWorld();
    RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(world);
    if (dimensionManager.getDimensionDescriptor(dim) == null) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Not an RFTools dimension!"));
        return;
    }
    dimensionManager.removeDimension(dim);
    dimensionManager.save(world);
    DimensionStorage dimensionStorage = DimensionStorage.getDimensionStorage(world);
    dimensionStorage.removeDimension(dim);
    dimensionStorage.save(world);
    sender.addChatMessage(new ChatComponentText("Dimension deleted."));
}
Also used : DimensionStorage(mcjty.rftools.dimension.DimensionStorage) World(net.minecraft.world.World) ChatComponentText(net.minecraft.util.ChatComponentText) RfToolsDimensionManager(mcjty.rftools.dimension.RfToolsDimensionManager)

Aggregations

ChatComponentText (net.minecraft.util.ChatComponentText)383 IChatComponent (net.minecraft.util.IChatComponent)55 EntityPlayer (net.minecraft.entity.player.EntityPlayer)43 ChatStyle (net.minecraft.util.ChatStyle)39 ItemStack (net.minecraft.item.ItemStack)36 ClickEvent (net.minecraft.event.ClickEvent)31 World (net.minecraft.world.World)28 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)26 TileEntity (net.minecraft.tileentity.TileEntity)25 ChatComponentTranslation (net.minecraft.util.ChatComponentTranslation)25 HoverEvent (net.minecraft.event.HoverEvent)23 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)21 ArrayList (java.util.ArrayList)17 RfToolsDimensionManager (mcjty.rftools.dimension.RfToolsDimensionManager)16 Block (net.minecraft.block.Block)15 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)15 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)14 Entity (net.minecraft.entity.Entity)14 DimensionInformation (mcjty.rftools.dimension.DimensionInformation)13 File (java.io.File)12