Search in sources :

Example 71 with ChatComponentText

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;
}
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 72 with ChatComponentText

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

Example 73 with ChatComponentText

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)));
    }
}
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) ChatComponentText(net.minecraft.util.ChatComponentText) CommandException(net.minecraft.command.CommandException) WrongUsageException(net.minecraft.command.WrongUsageException)

Example 74 with ChatComponentText

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;
        }
    }
}
Also used : ChatComponentText(net.minecraft.util.ChatComponentText)

Example 75 with ChatComponentText

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;
}
Also used : ChatComponentTranslation(net.minecraft.util.ChatComponentTranslation) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) ChunkCoordinates(net.minecraft.util.ChunkCoordinates) ChatComponentText(net.minecraft.util.ChatComponentText)

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