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();
}
}
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;
}
}
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;
}
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);
}
}
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)));
}
}
Aggregations