use of v1_8_9.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 v1_8_9.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)));
}
}
use of v1_8_9.net.minecraft.util.ChatComponentText in project Galacticraft by micdoodle8.
the class CommandSpaceStationRemoveOwner 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(), false);
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> e : stats.getSpaceStationDimensionData().entrySet()) {
final SpaceStationWorldData data = SpaceStationWorldData.getStationData(playerBase.worldObj, e.getValue(), playerBase);
String str = null;
for (String name : data.getAllowedPlayers()) {
if (name.equalsIgnoreCase(var3)) {
str = name;
break;
}
}
if (str != null) {
data.getAllowedPlayers().remove(str);
data.markDirty();
} else {
throw new CommandException(GCCoreUtil.translateWithFormat("commands.ssuninvite.no_player", "\"" + var3 + "\""), new Object[0]);
}
}
}
}
} 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.removesuccess", var3)));
}
}
use of v1_8_9.net.minecraft.util.ChatComponentText in project Galacticraft by micdoodle8.
the class EntityBuggy method interactFirst.
@Override
public boolean interactFirst(EntityPlayer var1) {
if (this.worldObj.isRemote) {
if (this.riddenByEntity == null) {
var1.addChatMessage(new ChatComponentText(GameSettings.getKeyDisplayString(KeyHandlerClient.leftKey.getKeyCode()) + " / " + GameSettings.getKeyDisplayString(KeyHandlerClient.rightKey.getKeyCode()) + " - " + GCCoreUtil.translate("gui.buggy.turn.name")));
var1.addChatMessage(new ChatComponentText(GameSettings.getKeyDisplayString(KeyHandlerClient.accelerateKey.getKeyCode()) + " - " + GCCoreUtil.translate("gui.buggy.accel.name")));
var1.addChatMessage(new ChatComponentText(GameSettings.getKeyDisplayString(KeyHandlerClient.decelerateKey.getKeyCode()) + " - " + GCCoreUtil.translate("gui.buggy.decel.name")));
var1.addChatMessage(new ChatComponentText(GameSettings.getKeyDisplayString(KeyHandlerClient.openFuelGui.getKeyCode()) + " - " + GCCoreUtil.translate("gui.buggy.inv.name")));
}
return true;
} else {
if (this.riddenByEntity != null) {
if (this.riddenByEntity == var1)
var1.mountEntity(null);
return true;
} else {
var1.mountEntity(this);
return true;
}
}
}
use of v1_8_9.net.minecraft.util.ChatComponentText in project Waystones by blay09.
the class BlockWaystone method onBlockActivated.
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
if (player.isSneaking() && (player.capabilities.isCreativeMode || !Waystones.getConfig().creativeModeOnly)) {
if (world.isRemote) {
TileWaystone tileWaystone = getTileWaystone(world, x, y, z);
if (tileWaystone == null) {
return true;
}
Waystones.proxy.openWaystoneNameEdit(tileWaystone);
}
return true;
}
if (!world.isRemote) {
TileWaystone tileWaystone = getTileWaystone(world, x, y, z);
if (tileWaystone == null) {
return true;
}
ChatComponentText nameComponent = new ChatComponentText(tileWaystone.getWaystoneName());
nameComponent.getChatStyle().setColor(EnumChatFormatting.WHITE);
ChatComponentTranslation chatComponent = new ChatComponentTranslation("waystones:activatedWaystone", nameComponent);
chatComponent.getChatStyle().setColor(EnumChatFormatting.YELLOW);
player.addChatComponentMessage(chatComponent);
WaystoneManager.activateWaystone(player, tileWaystone);
if (Waystones.getConfig().setSpawnPoint) {
ForgeDirection facing = ForgeDirection.getOrientation(world.getBlockMetadata(tileWaystone.xCoord, tileWaystone.yCoord, tileWaystone.zCoord));
player.setSpawnChunk(new ChunkCoordinates(tileWaystone.xCoord + facing.offsetX, tileWaystone.yCoord + facing.offsetY, tileWaystone.zCoord + facing.offsetZ), true);
}
} else {
Waystones.proxy.playSound("random.levelup", 1f);
for (int i = 0; i < 32; i++) {
world.spawnParticle("enchantmenttable", x + 0.5 + (world.rand.nextDouble() - 0.5) * 2, y + 3, z + 0.5 + (world.rand.nextDouble() - 0.5) * 2, 0, -5, 0);
world.spawnParticle("enchantmenttable", x + 0.5 + (world.rand.nextDouble() - 0.5) * 2, y + 4, z + 0.5 + (world.rand.nextDouble() - 0.5) * 2, 0, -5, 0);
}
}
return true;
}
Aggregations