Search in sources :

Example 21 with ChatComponentText

use of net.minecraft.util.ChatComponentText in project BetterRain by OreCruncher.

the class CommandRain method processCommand.

@Override
public void processCommand(final ICommandSender sender, final String[] parms) {
    try {
        final EntityPlayerMP player = getCommandSenderAsPlayer(sender);
        final World world = player.worldObj;
        final DimensionEffectData data = DimensionEffectData.get(world);
        if (parms.length == 1) {
            if ("status".compareToIgnoreCase(parms[0]) == 0) {
                // Dump out some diagnostics for the currentAurora dimension
                player.addChatMessage(new ChatComponentText(statusOutput(world, data)));
            } else if ("reset".compareToIgnoreCase(parms[0]) == 0) {
                world.provider.resetRainAndThunder();
                player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("msg.RainReset")));
            } else if ("reload".compareToIgnoreCase(parms[0]) == 0) {
                BiomeRegistry.initialize();
                BlockRegistry.initialize();
                player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("msg.BiomeReload")));
            } else {
                final double d = parseDouble(parms[0], 0.0D, 100.0D) / 100.0D;
                data.setRainIntensity((float) d);
                player.addChatMessage(new ChatComponentText(StatCollector.translateToLocalFormatted("msg.RainIntensitySet", FORMATTER.format(data.getRainIntensity() * 100))));
            }
        } else if (parms.length == 2) {
            if ("setmin".compareToIgnoreCase(parms[0]) == 0) {
                final double d = parseDouble(parms[1], 0.0D, 100.0D) / 100.0D;
                data.setMinRainIntensity((float) d);
                player.addChatMessage(new ChatComponentText(StatCollector.translateToLocalFormatted("msg.MinRainIntensitySet", FORMATTER.format(data.getMinRainIntensity() * 100))));
            } else if ("setmax".compareToIgnoreCase(parms[0]) == 0) {
                final double d = parseDouble(parms[1], 0.0D, 100.0D) / 100.0D;
                data.setMaxRainIntensity((float) d);
                player.addChatMessage(new ChatComponentText(StatCollector.translateToLocalFormatted("msg.MaxRainIntensitySet", FORMATTER.format(data.getMaxRainIntensity() * 100))));
            } else {
                throw new CommandException(getCommandUsage(sender));
            }
        } else {
            player.addChatMessage(new ChatComponentText(getCommandUsage(sender)));
        }
    } catch (final Exception ex) {
        ex.printStackTrace();
    }
}
Also used : DimensionEffectData(org.blockartistry.mod.DynSurround.data.DimensionEffectData) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) CommandException(net.minecraft.command.CommandException) World(net.minecraft.world.World) ChatComponentText(net.minecraft.util.ChatComponentText) CommandException(net.minecraft.command.CommandException)

Example 22 with ChatComponentText

use of net.minecraft.util.ChatComponentText in project Galacticraft by micdoodle8.

the class TileEntityCryogenicChamber method onActivated.

@Override
public boolean onActivated(EntityPlayer entityPlayer) {
    if (this.worldObj.isRemote) {
        return false;
    }
    EnumStatus enumstatus = this.sleepInBedAt(entityPlayer, this.getPos().getX(), this.getPos().getY(), this.getPos().getZ());
    switch(enumstatus) {
        case OK:
            ((EntityPlayerMP) entityPlayer).playerNetServerHandler.setPlayerLocation(entityPlayer.posX, entityPlayer.posY, entityPlayer.posZ, entityPlayer.rotationYaw, entityPlayer.rotationPitch);
            GalacticraftCore.packetPipeline.sendTo(new PacketSimpleMars(EnumSimplePacketMars.C_BEGIN_CRYOGENIC_SLEEP, GCCoreUtil.getDimensionID(entityPlayer.worldObj), new Object[] { this.getPos() }), (EntityPlayerMP) entityPlayer);
            return true;
        case NOT_POSSIBLE_NOW:
            GCPlayerStats stats = GCPlayerStats.get(entityPlayer);
            entityPlayer.addChatMessage(new ChatComponentText(GCCoreUtil.translateWithFormat("gui.cryogenic.chat.cant_use", stats.getCryogenicChamberCooldown() / 20)));
            return false;
        default:
            return false;
    }
}
Also used : EnumStatus(net.minecraft.entity.player.EntityPlayer.EnumStatus) GCPlayerStats(micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats) PacketSimpleMars(micdoodle8.mods.galacticraft.planets.mars.network.PacketSimpleMars) ChatComponentText(net.minecraft.util.ChatComponentText)

Example 23 with ChatComponentText

use of net.minecraft.util.ChatComponentText in project Galacticraft by micdoodle8.

the class BlockTelemetry method onMachineActivated.

@Override
public boolean onMachineActivated(World world, BlockPos pos, IBlockState state, EntityPlayer entityPlayer, EnumFacing side, float hitX, float hitY, float hitZ) {
    if (!world.isRemote) {
        TileEntity tile = world.getTileEntity(pos);
        if (tile instanceof TileEntityTelemetry) {
            ItemStack held = entityPlayer.inventory.getCurrentItem();
            // Look for Frequency Module
            if (held != null && held.getItem() == GCItems.basicItem && held.getItemDamage() == 19) {
                NBTTagCompound fmData = held.getTagCompound();
                if (fmData != null && fmData.hasKey("linkedUUIDMost") && fmData.hasKey("linkedUUIDLeast")) {
                    UUID uuid = new UUID(fmData.getLong("linkedUUIDMost"), fmData.getLong("linkedUUIDLeast"));
                    ((TileEntityTelemetry) tile).addTrackedEntity(uuid);
                    entityPlayer.addChatMessage(new ChatComponentText(GCCoreUtil.translate("gui.telemetry_succeed.message")));
                } else {
                    entityPlayer.addChatMessage(new ChatComponentText(GCCoreUtil.translate("gui.telemetry_fail.message")));
                    if (fmData == null) {
                        fmData = new NBTTagCompound();
                        held.setTagCompound(fmData);
                    }
                }
                fmData.setInteger("teCoordX", pos.getX());
                fmData.setInteger("teCoordY", pos.getY());
                fmData.setInteger("teCoordZ", pos.getZ());
                fmData.setInteger("teDim", GCCoreUtil.getDimensionID(world));
                return true;
            }
            ItemStack wearing = GCPlayerStats.get(entityPlayer).getFrequencyModuleInSlot();
            if (wearing != null) {
                if (wearing.hasTagCompound() && wearing.getTagCompound().hasKey("teDim")) {
                    return false;
                }
                entityPlayer.addChatMessage(new ChatComponentText(GCCoreUtil.translate("gui.telemetry_fail_wearing_it.message")));
            } else {
                entityPlayer.addChatMessage(new ChatComponentText(GCCoreUtil.translate("gui.telemetry_fail_no_frequency_module.message")));
            }
        }
    }
    return false;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityTelemetry(micdoodle8.mods.galacticraft.core.tile.TileEntityTelemetry) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemStack(net.minecraft.item.ItemStack) UUID(java.util.UUID) ChatComponentText(net.minecraft.util.ChatComponentText)

Example 24 with ChatComponentText

use of net.minecraft.util.ChatComponentText in project Galacticraft by micdoodle8.

the class SpaceRaceManager method onPlayerRemoval.

public static void onPlayerRemoval(MinecraftServer server, String player, SpaceRace race) {
    for (String member : race.getPlayerNames()) {
        EntityPlayerMP memberObj = PlayerUtil.getPlayerForUsernameVanilla(server, member);
        if (memberObj != null) {
            memberObj.addChatMessage(new ChatComponentText(EnumColor.DARK_AQUA + GCCoreUtil.translateWithFormat("gui.space_race.chat.remove_success", EnumColor.RED + player + EnumColor.DARK_AQUA)).setChatStyle(new ChatStyle().setColor(EnumChatFormatting.DARK_AQUA)));
        }
    }
    List<String> playerList = new ArrayList<String>();
    playerList.add(player);
    SpaceRace newRace = SpaceRaceManager.addSpaceRace(new SpaceRace(playerList, SpaceRace.DEFAULT_NAME, new FlagData(48, 32), new Vector3(1, 1, 1)));
    EntityPlayerMP playerToRemove = PlayerUtil.getPlayerBaseServerFromPlayerUsername(server, player, true);
    if (playerToRemove != null) {
        SpaceRaceManager.sendSpaceRaceData(server, playerToRemove, newRace);
        SpaceRaceManager.sendSpaceRaceData(server, playerToRemove, race);
    }
}
Also used : ChatStyle(net.minecraft.util.ChatStyle) FlagData(micdoodle8.mods.galacticraft.core.wrappers.FlagData) ArrayList(java.util.ArrayList) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) Vector3(micdoodle8.mods.galacticraft.api.vector.Vector3) ChatComponentText(net.minecraft.util.ChatComponentText)

Example 25 with ChatComponentText

use of net.minecraft.util.ChatComponentText in project Galacticraft by micdoodle8.

the class CommandSpaceStationAddOwner method processCommand.

@Override
public void processCommand(ICommandSender sender, String[] args) throws CommandException {
    String var3 = null;
    EntityPlayerMP playerBase = null;
    if (args.length > 0) {
        var3 = args[0];
        try {
            playerBase = PlayerUtil.getPlayerBaseServerFromPlayerUsername(sender.getName(), true);
            if (playerBase != null) {
                GCPlayerStats stats = GCPlayerStats.get(playerBase);
                if (stats.getSpaceStationDimensionData().isEmpty()) {
                    throw new WrongUsageException(GCCoreUtil.translate("commands.ssinvite.not_found"), new Object[0]);
                } else {
                    for (Map.Entry<Integer, Integer> ownedStations : stats.getSpaceStationDimensionData().entrySet()) {
                        final SpaceStationWorldData data = SpaceStationWorldData.getStationData(playerBase.worldObj, ownedStations.getValue(), playerBase);
                        if (var3.equalsIgnoreCase("+all")) {
                            data.setAllowedAll(true);
                            playerBase.addChatMessage(new ChatComponentText(GCCoreUtil.translateWithFormat("gui.spacestation.allow_all_true")));
                            return;
                        }
                        if (var3.equalsIgnoreCase("-all")) {
                            data.setAllowedAll(false);
                            playerBase.addChatMessage(new ChatComponentText(GCCoreUtil.translateWithFormat("gui.spacestation.allow_all_false", var3)));
                            return;
                        }
                        if (!data.getAllowedPlayers().contains(var3)) {
                            data.getAllowedPlayers().add(var3);
                            data.markDirty();
                        }
                    }
                }
                final EntityPlayerMP playerToAdd = PlayerUtil.getPlayerBaseServerFromPlayerUsername(var3, true);
                if (playerToAdd != null) {
                    playerToAdd.addChatMessage(new ChatComponentText(GCCoreUtil.translateWithFormat("gui.spacestation.added", PlayerUtil.getName(playerBase))));
                }
            }
        } catch (final Exception var6) {
            throw new CommandException(var6.getMessage(), new Object[0]);
        }
    } else {
        throw new WrongUsageException(GCCoreUtil.translateWithFormat("commands.ssinvite.wrong_usage", this.getCommandUsage(sender)), new Object[0]);
    }
    if (playerBase != null) {
        playerBase.addChatMessage(new ChatComponentText(GCCoreUtil.translateWithFormat("gui.spacestation.addsuccess", var3)));
    }
}
Also used : SpaceStationWorldData(micdoodle8.mods.galacticraft.core.dimension.SpaceStationWorldData) WrongUsageException(net.minecraft.command.WrongUsageException) GCPlayerStats(micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) CommandException(net.minecraft.command.CommandException) Map(java.util.Map) ChatComponentText(net.minecraft.util.ChatComponentText) CommandException(net.minecraft.command.CommandException) WrongUsageException(net.minecraft.command.WrongUsageException)

Aggregations

ChatComponentText (net.minecraft.util.ChatComponentText)164 ItemStack (net.minecraft.item.ItemStack)27 EntityPlayer (net.minecraft.entity.player.EntityPlayer)24 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)16 TileEntity (net.minecraft.tileentity.TileEntity)13 Entity (net.minecraft.entity.Entity)12 ClickEvent (net.minecraft.event.ClickEvent)10 IChatComponent (net.minecraft.util.IChatComponent)10 ArrayList (java.util.ArrayList)9 ChatStyle (net.minecraft.util.ChatStyle)9 GCPlayerStats (micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats)8 Block (net.minecraft.block.Block)8 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)8 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)7 File (java.io.File)7 RfToolsDimensionManager (mcjty.rftoolsdim.dimensions.RfToolsDimensionManager)7 WrongUsageException (net.minecraft.command.WrongUsageException)7 World (net.minecraft.world.World)6 AccessGroup (com.builtbroken.mc.lib.access.AccessGroup)5 DimensionInformation (mcjty.rftoolsdim.dimensions.DimensionInformation)5