Search in sources :

Example 6 with ChatComponentText

use of net.minecraft.util.ChatComponentText in project ICBM-Classic by BuiltBrokenModding.

the class TileLauncherScreen method receiveRadioWave.

@Override
public void receiveRadioWave(float hz, IRadioWaveSender sender, String messageHeader, Object[] data) {
    //Floor frequency as we do not care about sub ranges
    int frequency = (int) Math.floor(hz);
    //Only tier 3 (2 for tier value) can be remotely fired
    if (getTier() == 2 && frequency == getFrequency() && laucherBase != null) {
        //Laser detonator signal
        if (messageHeader.equals("activateLauncherWithTarget")) {
            Pos pos = (Pos) data[0];
            if (toPos().distance(pos) < this.laucherBase.getRange()) {
                setTarget(pos);
                launch();
                ((FakeRadioSender) sender).player.addChatComponentMessage(new ChatComponentText("Firing missile at " + pos));
            }
        } else //Remote detonator signal
        if (messageHeader.equals("activateLauncher")) {
            ((FakeRadioSender) sender).player.addChatComponentMessage(new ChatComponentText("Firing missile at " + getTarget()));
            launch();
        }
    }
}
Also used : Pos(com.builtbroken.mc.imp.transform.vector.Pos) FakeRadioSender(com.builtbroken.mc.prefab.hz.FakeRadioSender) ChatComponentText(net.minecraft.util.ChatComponentText)

Example 7 with ChatComponentText

use of net.minecraft.util.ChatComponentText in project ICBM-Classic by BuiltBrokenModding.

the class TileLauncherScreen method onPlayerActivated.

@Override
public boolean onPlayerActivated(EntityPlayer player, int side, Pos hit) {
    if (isServer()) {
        boolean notNull = player.getHeldItem() != null;
        if (notNull && player.getHeldItem().getItem() == Items.redstone) {
            if (canLaunch()) {
                launch();
            } else {
                player.addChatComponentMessage(new ChatComponentText(LanguageUtility.getLocal("chat.launcher.failedToFire")));
                String translation = LanguageUtility.getLocal("chat.launcher.status");
                translation = translation.replace("%1", getStatus());
                player.addChatComponentMessage(new ChatComponentText(translation));
            }
        } else if (notNull && player.getHeldItem().getItem() instanceof ItemRemoteDetonator) {
            ((ItemRemoteDetonator) player.getHeldItem().getItem()).setBroadCastHz(player.getHeldItem(), getFrequency());
            player.addChatComponentMessage(new ChatComponentText(LanguageUtility.getLocal("chat.launcher.toolFrequencySet").replace("%1", "" + getFrequency())));
        } else if (notNull && player.getHeldItem().getItem() instanceof IWorldPosItem) {
            IWorldPosition location = ((IWorldPosItem) player.getHeldItem().getItem()).getLocation(player.getHeldItem());
            if (location != null) {
                if (location.world() == world()) {
                    setTarget(new Pos(location.x(), location.y(), location.z()));
                    player.addChatComponentMessage(new ChatComponentText(LanguageUtility.getLocal("chat.launcher.toolTargetSet")));
                } else {
                    player.addChatComponentMessage(new ChatComponentText(LanguageUtility.getLocal("chat.launcher.toolWorldNotMatch")));
                }
            } else {
                player.addChatComponentMessage(new ChatComponentText(LanguageUtility.getLocal("chat.launcher.noTargetInTool")));
            }
        } else {
            player.openGui(ICBMClassic.INSTANCE, 0, this.worldObj, this.xCoord, this.yCoord, this.zCoord);
        }
    }
    return true;
}
Also used : Pos(com.builtbroken.mc.imp.transform.vector.Pos) IWorldPosition(com.builtbroken.mc.api.IWorldPosition) IWorldPosItem(com.builtbroken.mc.api.items.tools.IWorldPosItem) ChatComponentText(net.minecraft.util.ChatComponentText) ItemRemoteDetonator(icbm.classic.content.items.ItemRemoteDetonator)

Example 8 with ChatComponentText

use of net.minecraft.util.ChatComponentText in project ICBM-Classic by BuiltBrokenModding.

the class CommandICBM method processCommand.

@Override
public void processCommand(ICommandSender sender, String[] args) {
    try {
        EntityPlayer entityPlayer = (EntityPlayer) sender;
        int dimension = entityPlayer.worldObj.provider.dimensionId;
        if (args == null || args.length == 0 || args[0].equalsIgnoreCase("help")) {
            ((EntityPlayer) sender).addChatComponentMessage(new ChatComponentText("/icbmc help"));
            ((EntityPlayer) sender).addChatComponentMessage(new ChatComponentText("/icbmc lag <radius>"));
            ((EntityPlayer) sender).addChatComponentMessage(new ChatComponentText("/icbmc remove <All/Missile/Explosion> <radius>"));
            ((EntityPlayer) sender).addChatComponentMessage(new ChatComponentText("/icbmc emp <radius>"));
            return;
        } else if (args.length >= 2 && args[0].equalsIgnoreCase("lag")) {
            int radius = parseInt(sender, args[1]);
            if (radius > 0) {
                AxisAlignedBB bounds = AxisAlignedBB.getBoundingBox(entityPlayer.posX - radius, entityPlayer.posY - radius, entityPlayer.posZ - radius, entityPlayer.posX + radius, entityPlayer.posY + radius, entityPlayer.posZ + radius);
                List<Entity> entitiesNearby = entityPlayer.worldObj.getEntitiesWithinAABB(Entity.class, bounds);
                for (Entity entity : entitiesNearby) {
                    if (entity instanceof EntityFlyingBlock) {
                        ((EntityFlyingBlock) entity).setBlock();
                    } else if (entity instanceof EntityMissile) {
                        entity.setDead();
                    } else if (entity instanceof EntityExplosion) {
                        entity.setDead();
                    }
                }
                ((EntityPlayer) sender).addChatComponentMessage(new ChatComponentText("Removed all ICBM lag sources within " + radius + " radius."));
                return;
            } else {
                throw new WrongUsageException("Radius needs to be higher than zero");
            }
        } else if (args.length >= 3 && args[0].equalsIgnoreCase("remove")) {
            int radius = parseInt(sender, args[2]);
            boolean all = args[1].equalsIgnoreCase("all");
            boolean missile = args[1].equalsIgnoreCase("missiles");
            boolean explosion = args[1].equalsIgnoreCase("explosion");
            String str = "entities";
            if (missile) {
                str = "missiles";
            }
            if (explosion) {
                str = "explosions";
            }
            if (radius > 0) {
                EntityPlayer player = (EntityPlayer) sender;
                AxisAlignedBB bounds = AxisAlignedBB.getBoundingBox(player.posX - radius, player.posY - radius, player.posZ - radius, player.posX + radius, player.posY + radius, player.posZ + radius);
                List<Entity> entitiesNearby = player.worldObj.getEntitiesWithinAABB(Entity.class, bounds);
                for (Entity entity : entitiesNearby) {
                    if ((all || explosion) && entity instanceof EntityFlyingBlock) {
                        ((EntityFlyingBlock) entity).setBlock();
                    } else if ((all || missile) && entity instanceof EntityMissile) {
                        entity.setDead();
                    } else if ((all || explosion) && entity instanceof EntityExplosion) {
                        entity.setDead();
                    }
                }
                ((EntityPlayer) sender).addChatComponentMessage(new ChatComponentText("Removed all ICBM " + str + " within " + radius + " radius."));
                return;
            } else {
                throw new WrongUsageException("Radius needs to be higher than zero");
            }
        } else if (args.length >= 2 && args[0].equalsIgnoreCase("emp")) {
            int radius = parseInt(sender, args[1]);
            if (radius > 0) {
                new BlastEMP(entityPlayer.worldObj, null, entityPlayer.posX, entityPlayer.posY, entityPlayer.posZ, radius).setEffectBlocks().setEffectEntities().doExplode();
                switch(entityPlayer.worldObj.rand.nextInt(20)) {
                    case 0:
                        ((EntityPlayer) sender).addChatComponentMessage(new ChatComponentText("Did you pay the power bill?"));
                        return;
                    case 1:
                        ((EntityPlayer) sender).addChatComponentMessage(new ChatComponentText("See them power their toys now!"));
                        return;
                    case 2:
                        ((EntityPlayer) sender).addChatComponentMessage(new ChatComponentText("Hey who turned the lights out."));
                        return;
                    case 3:
                        ((EntityPlayer) sender).addChatComponentMessage(new ChatComponentText("Ha! I run on steam power!"));
                        return;
                    case 4:
                        ((EntityPlayer) sender).addChatComponentMessage(new ChatComponentText("The power of lighting at my finger tips!"));
                        return;
                    default:
                        ((EntityPlayer) sender).addChatComponentMessage(new ChatComponentText("Zap!"));
                        return;
                }
            } else {
                throw new WrongUsageException("Radius needs to be higher than zero");
            }
        }
    } catch (Exception e) {
    }
    throw new WrongUsageException(this.getCommandUsage(sender));
}
Also used : AxisAlignedBB(net.minecraft.util.AxisAlignedBB) Entity(net.minecraft.entity.Entity) EntityExplosion(icbm.classic.content.entity.EntityExplosion) EntityMissile(icbm.classic.content.entity.EntityMissile) BlastEMP(icbm.classic.content.explosive.blast.BlastEMP) WrongUsageException(net.minecraft.command.WrongUsageException) WrongUsageException(net.minecraft.command.WrongUsageException) EntityFlyingBlock(icbm.classic.content.entity.EntityFlyingBlock) EntityPlayer(net.minecraft.entity.player.EntityPlayer) List(java.util.List) ChatComponentText(net.minecraft.util.ChatComponentText)

Example 9 with ChatComponentText

use of net.minecraft.util.ChatComponentText in project SecurityCraft by Geforce132.

the class SCEventHandler method onPlayerLoggedIn.

@SubscribeEvent
public void onPlayerLoggedIn(PlayerLoggedInEvent event) {
    String tipKey = getRandomTip();
    IChatComponent chatcomponenttext;
    if (tipsWithLink.containsKey(tipKey.split("\\.")[2]))
        chatcomponenttext = new ChatComponentText("[" + EnumChatFormatting.GOLD + "SecurityCraft" + EnumChatFormatting.WHITE + "] " + StatCollector.translateToLocal("messages.thanks").replace("#", SecurityCraft.getVersion()) + " " + StatCollector.translateToLocal("messages.tip") + " " + StatCollector.translateToLocal(tipKey) + " ").appendSibling(ForgeHooks.newChatWithLinks(tipsWithLink.get(tipKey.split("\\.")[2])));
    else
        chatcomponenttext = new ChatComponentText("[" + EnumChatFormatting.GOLD + "SecurityCraft" + EnumChatFormatting.WHITE + "] " + StatCollector.translateToLocal("messages.thanks").replace("#", SecurityCraft.getVersion()) + " " + StatCollector.translateToLocal("messages.tip") + " " + StatCollector.translateToLocal(tipKey));
    if (SecurityCraft.config.sayThanksMessage)
        event.player.addChatComponentMessage(chatcomponenttext);
}
Also used : IChatComponent(net.minecraft.util.IChatComponent) ChatComponentText(net.minecraft.util.ChatComponentText) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 10 with ChatComponentText

use of net.minecraft.util.ChatComponentText in project TecTech by Technus.

the class GiveEM method processCommand.

@Override
public void processCommand(ICommandSender sender, String[] args) {
    if (sender instanceof EntityPlayerMP && !sender.getEntityWorld().isRemote) {
        if (args.length < 3) {
            sender.addChatMessage(new ChatComponentText(getCommandUsage(sender)));
        } else {
            TecTech.Logger.info("Spawninig EM for " + ((EntityPlayerMP) sender).getDisplayName() + " - " + Arrays.toString(args));
            ArrayList<String> list = new ArrayList<>();
            list.addAll(Arrays.asList(args));
            String energy = list.remove(0);
            cElementalDefinitionStack def = getDefinitionStack(list);
            cElementalInstanceStack instanceStack = new cElementalInstanceStack(def, 1, 0, Long.parseLong(energy));
            sender.addChatMessage(new ChatComponentText(instanceStack.definition.getSymbol() + " - " + instanceStack.definition.getName()));
            cElementalInstanceStackMap instanceMap = new cElementalInstanceStackMap(instanceStack);
            ItemStack itemStack = new ItemStack(DebugElementalInstanceContainer_EM.INSTANCE);
            NBTTagCompound contents = new NBTTagCompound();
            contents.setTag("info", instanceMap.getInfoNBT());
            contents.setTag("content", instanceMap.toNBT());
            itemStack.setTagCompound(contents);
            ((EntityPlayerMP) sender).inventory.addItemStackToInventory(itemStack);
        }
    }
}
Also used : com.github.technus.tectech.elementalMatter.core.cElementalInstanceStackMap(com.github.technus.tectech.elementalMatter.core.cElementalInstanceStackMap) com.github.technus.tectech.elementalMatter.core.stacks.cElementalInstanceStack(com.github.technus.tectech.elementalMatter.core.stacks.cElementalInstanceStack) com.github.technus.tectech.elementalMatter.core.stacks.cElementalDefinitionStack(com.github.technus.tectech.elementalMatter.core.stacks.cElementalDefinitionStack) ArrayList(java.util.ArrayList) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) ItemStack(net.minecraft.item.ItemStack) ChatComponentText(net.minecraft.util.ChatComponentText)

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