Search in sources :

Example 71 with ChatComponentText

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

the class ItemGrenade method onItemRightClick.

@Override
public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer entityPlayer) {
    if (itemStack != null) {
        Explosive zhaPin = Explosives.get(itemStack.getItemDamage()).handler;
        ExplosivePreDetonationEvent evt = new ExplosivePreDetonationEvent(world, entityPlayer, ExplosiveType.ITEM, zhaPin);
        MinecraftForge.EVENT_BUS.post(evt);
        if (!evt.isCanceled()) {
            entityPlayer.setItemInUse(itemStack, this.getMaxItemUseDuration(itemStack));
        } else {
            entityPlayer.addChatMessage(new ChatComponentText("Grenades are banned in this region."));
        }
    }
    return itemStack;
}
Also used : Explosive(icbm.classic.content.explosive.Explosive) ItemBlockExplosive(icbm.classic.content.explosive.tile.ItemBlockExplosive) ExplosivePreDetonationEvent(resonant.api.explosion.ExplosionEvent.ExplosivePreDetonationEvent) ChatComponentText(net.minecraft.util.ChatComponentText)

Example 72 with ChatComponentText

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

the class ItemRadarGun method read.

@Override
public void read(ByteBuf buf, EntityPlayer player, PacketType packet) {
    ItemStack stack = player.inventory.getCurrentItem();
    if (stack != null && stack.getItem() == this) {
        setLocation(stack, new Location(player.worldObj, buf.readInt(), buf.readInt(), buf.readInt()));
        player.addChatComponentMessage(new ChatComponentText("GPS data set"));
    }
}
Also used : ItemStack(net.minecraft.item.ItemStack) ChatComponentText(net.minecraft.util.ChatComponentText) Location(com.builtbroken.mc.imp.transform.vector.Location)

Example 73 with ChatComponentText

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

the class ItemRocketLauncher method onItemRightClick.

@Override
public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) {
    if (!world.isRemote) {
        long clickMs = System.currentTimeMillis();
        if (clickTimePlayer.containsKey(player.getCommandSenderName())) {
            if (clickMs - clickTimePlayer.get(player.getCommandSenderName()) < firingDelay) {
                //TODO play weapon empty click audio to note the gun is reloading
                return itemStack;
            }
        }
        if (this.getEnergy(itemStack) >= ENERGY || player.capabilities.isCreativeMode) {
            // Check the player's inventory and look for missiles.
            for (int slot = 0; slot < player.inventory.getSizeInventory(); slot++) {
                ItemStack inventoryStack = player.inventory.getStackInSlot(slot);
                if (inventoryStack != null) {
                    if (inventoryStack.getItem() instanceof ItemMissile) {
                        int meta = inventoryStack.getItemDamage();
                        Explosives ex = Explosives.get(meta);
                        ExplosivePreDetonationEvent evt = new ExplosivePreDetonationEvent(world, player.posX, player.posY, player.posZ, ExplosiveType.AIR, Explosives.get(meta).handler);
                        MinecraftForge.EVENT_BUS.post(evt);
                        if (((Explosion) ex.handler) != null && !evt.isCanceled()) {
                            // Limit the missile to tier two.
                            if ((((Explosion) ex.handler).getTier() <= Settings.MAX_ROCKET_LAUCNHER_TIER || Engine.runningAsDev) && ((Explosion) ex.handler).isCruise()) {
                                EntityMissile entityMissile = new EntityMissile(player);
                                entityMissile.missileType = EntityMissile.MissileType.LAUNCHER;
                                entityMissile.explosiveID = ex;
                                entityMissile.acceleration = 1;
                                entityMissile.launch(null);
                                world.spawnEntityInWorld(entityMissile);
                                if (player.isSneaking()) {
                                    player.mountEntity(entityMissile);
                                    player.setSneaking(false);
                                }
                                if (!player.capabilities.isCreativeMode) {
                                    player.inventory.setInventorySlotContents(slot, null);
                                    player.inventoryContainer.detectAndSendChanges();
                                    this.discharge(itemStack, ENERGY, true);
                                }
                                //Store last time player launched a rocket
                                clickTimePlayer.put(player.getCommandSenderName(), clickMs);
                                return itemStack;
                            }
                        } else {
                            player.addChatComponentMessage(new ChatComponentText(LanguageUtility.getLocal("message.launcher.protected")));
                        }
                    }
                }
            }
        }
    }
    return itemStack;
}
Also used : Explosion(icbm.classic.content.explosive.ex.Explosion) ExplosivePreDetonationEvent(resonant.api.explosion.ExplosionEvent.ExplosivePreDetonationEvent) Explosives(icbm.classic.content.explosive.Explosives) ItemStack(net.minecraft.item.ItemStack) ChatComponentText(net.minecraft.util.ChatComponentText) EntityMissile(icbm.classic.content.entity.EntityMissile)

Example 74 with ChatComponentText

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

the class MissileHoming method onInteract.

@Override
public boolean onInteract(EntityMissile missileObj, EntityPlayer entityPlayer) {
    if (!missileObj.worldObj.isRemote && missileObj.getTicksInAir() <= 0) {
        if (entityPlayer.getCurrentEquippedItem() != null) {
            if (entityPlayer.getCurrentEquippedItem().getItem() instanceof ItemTracker) {
                Entity trackingEntity = ((ItemTracker) entityPlayer.getCurrentEquippedItem().getItem()).getTrackingEntity(missileObj.worldObj, entityPlayer.getCurrentEquippedItem());
                if (trackingEntity != null) {
                    if (missileObj.trackingVar != trackingEntity.getEntityId()) {
                        missileObj.trackingVar = trackingEntity.getEntityId();
                        entityPlayer.addChatMessage(new ChatComponentText("Missile target locked to: " + trackingEntity.getCommandSenderName()));
                        if (missileObj.getLauncher() != null && missileObj.getLauncher().getController() != null) {
                            Pos newTarget = new Pos(trackingEntity.posX, 0, trackingEntity.posZ);
                            missileObj.getLauncher().getController().setTarget(newTarget);
                        }
                        return true;
                    }
                }
            }
        }
    }
    return false;
}
Also used : Entity(net.minecraft.entity.Entity) ItemTracker(icbm.classic.content.items.ItemTracker) Pos(com.builtbroken.mc.imp.transform.vector.Pos) ChatComponentText(net.minecraft.util.ChatComponentText)

Example 75 with ChatComponentText

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

the class TileCruiseLauncher 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 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)

Aggregations

ChatComponentText (net.minecraft.util.ChatComponentText)108 EntityPlayer (net.minecraft.entity.player.EntityPlayer)19 ItemStack (net.minecraft.item.ItemStack)16 TileEntity (net.minecraft.tileentity.TileEntity)9 Entity (net.minecraft.entity.Entity)8 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)7 ArrayList (java.util.ArrayList)7 Block (net.minecraft.block.Block)6 AMVector3 (am2.api.math.AMVector3)4 AccessGroup (com.builtbroken.mc.framework.access.AccessGroup)4 Pos (com.builtbroken.mc.imp.transform.vector.Pos)4 OpenChatGui (logisticspipes.network.packets.gui.OpenChatGui)4 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)4 ChatStyle (net.minecraft.util.ChatStyle)4 IPowerNode (am2.api.power.IPowerNode)3 IItemActivationListener (com.builtbroken.mc.api.items.listeners.IItemActivationListener)3 IItemEventListener (com.builtbroken.mc.api.items.listeners.IItemEventListener)3 AbstractCommand (com.builtbroken.mc.core.commands.prefab.AbstractCommand)3 ItemListenerIterator (com.builtbroken.mc.prefab.items.listeners.ItemListenerIterator)3 EntityLivingBase (net.minecraft.entity.EntityLivingBase)3