Search in sources :

Example 86 with ChatComponentText

use of net.minecraft.util.ChatComponentText in project ArsMagica2 by Mithion.

the class BlockAstralBarrier method onBlockActivated.

@Override
public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9) {
    TileEntity te = par1World.getTileEntity(par2, par3, par4);
    TileEntityAstralBarrier abte = null;
    if (te != null && te instanceof TileEntityAstralBarrier) {
        abte = (TileEntityAstralBarrier) te;
    } else {
        return true;
    }
    if (HandleSpecialItems(par1World, par5EntityPlayer, par2, par3, par4)) {
        return true;
    }
    if (!par1World.isRemote)
        if (KeystoneUtilities.HandleKeystoneRecovery(par5EntityPlayer, ((IKeystoneLockable) par1World.getTileEntity(par2, par3, par4))))
            return true;
    if (KeystoneUtilities.instance.canPlayerAccess((IKeystoneLockable) par1World.getTileEntity(par2, par3, par4), par5EntityPlayer, KeystoneAccessType.USE)) {
        if (par5EntityPlayer.isSneaking()) {
            if (par1World.isRemote) {
                abte.ToggleAuraDisplay();
                par5EntityPlayer.addChatMessage(new ChatComponentText("Barrier Aura Toggled"));
            }
        } else {
            if (!par1World.isRemote) {
                super.onBlockActivated(par1World, par2, par3, par4, par5EntityPlayer, par6, par7, par8, par9);
                FMLNetworkHandler.openGui(par5EntityPlayer, AMCore.instance, ArsMagicaGuiIdList.GUI_ASTRAL_BARRIER, par1World, par2, par3, par4);
            }
        }
    }
    return true;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityAstralBarrier(am2.blocks.tileentities.TileEntityAstralBarrier) ChatComponentText(net.minecraft.util.ChatComponentText)

Example 87 with ChatComponentText

use of net.minecraft.util.ChatComponentText in project ArsMagica2 by Mithion.

the class SetAffinityCommand method processCommand.

@Override
public void processCommand(ICommandSender var1, String[] var2) {
    if (var2.length != 3 && var2.length != 2) {
        throw new WrongUsageException(this.getCommandUsage(var1), new Object[0]);
    }
    EntityPlayer player = null;
    String affinity = "";
    float depth = 0f;
    if (var2.length == 3) {
        player = getPlayer(var1, var2[0]);
        affinity = var2[1].toUpperCase();
        depth = tryParseInt(var2[2]);
    } else {
        player = getCommandSenderAsPlayer(var1);
        affinity = var2[0].toUpperCase();
        depth = tryParseInt(var2[1]);
    }
    if (player == null)
        return;
    Affinity enumAffinity;
    try {
        enumAffinity = Affinity.valueOf(affinity);
    } catch (Throwable t) {
        player.addChatMessage(new ChatComponentText("Unknown affinity name specified."));
        return;
    }
    AffinityData.For(player).setAffinityAndDepth(enumAffinity, depth);
    AffinityData.For(player).forceSync();
    func_152373_a(var1, this, "Setting " + player.getCommandSenderName() + "'s " + affinity + " affinity level to " + depth, new Object[0]);
}
Also used : WrongUsageException(net.minecraft.command.WrongUsageException) EntityPlayer(net.minecraft.entity.player.EntityPlayer) Affinity(am2.api.spell.enums.Affinity) ChatComponentText(net.minecraft.util.ChatComponentText)

Example 88 with ChatComponentText

use of net.minecraft.util.ChatComponentText in project ArsMagica2 by Mithion.

the class ShiftAffinityCommand method processCommand.

@Override
public void processCommand(ICommandSender var1, String[] var2) {
    if (var2.length != 3 && var2.length != 2) {
        throw new WrongUsageException(this.getCommandUsage(var1), new Object[0]);
    }
    EntityPlayer player = null;
    String affinity = "";
    float amt = 0f;
    if (var2.length == 3) {
        player = getPlayer(var1, var2[0]);
        affinity = var2[1].toUpperCase();
        amt = tryParseFloat(var2[2]);
    } else {
        player = getCommandSenderAsPlayer(var1);
        affinity = var2[0].toUpperCase();
        amt = tryParseFloat(var2[1]);
    }
    if (player == null)
        return;
    Affinity enumAffinity;
    try {
        enumAffinity = Affinity.valueOf(affinity);
    } catch (Throwable t) {
        player.addChatMessage(new ChatComponentText("Unknown affinity name specified."));
        return;
    }
    float affinityDepth = AffinityData.For(player).getAffinityDepth(enumAffinity) * AffinityData.MAX_DEPTH;
    affinityDepth += amt;
    AffinityData.For(player).setAffinityAndDepth(enumAffinity, affinityDepth);
    AffinityData.For(player).forceSync();
    func_152373_a(var1, this, "Shifting " + player.getCommandSenderName() + "'s " + affinity + " affinity level by " + amt, new Object[0]);
}
Also used : WrongUsageException(net.minecraft.command.WrongUsageException) EntityPlayer(net.minecraft.entity.player.EntityPlayer) Affinity(am2.api.spell.enums.Affinity) ChatComponentText(net.minecraft.util.ChatComponentText)

Example 89 with ChatComponentText

use of net.minecraft.util.ChatComponentText in project ArsMagica2 by Mithion.

the class Explosions method processCommand.

@Override
public void processCommand(ICommandSender icommandsender, String[] astring) {
    EntityPlayer player = getCommandSenderAsPlayer(icommandsender);
    if (player.getCommandSenderName().equals("Moridrex") || player.getCommandSenderName().equals("Mithion")) {
        if (player.worldObj.rand.nextInt(10) < 5 || !player.worldObj.canBlockSeeTheSky((int) player.posX, (int) player.posY, (int) player.posZ)) {
            Explosion explosion = player.worldObj.newExplosion(null, player.posX, player.posY, player.posZ, 10, true, true);
            player.attackEntityFrom(DamageSource.setExplosionSource(explosion), 5000);
        } else {
            if (!player.worldObj.isRemote) {
                for (int i = 0; i < 25; ++i) {
                    EntityCreeper creeper = new EntityCreeper(player.worldObj);
                    creeper.setPosition(player.posX + player.worldObj.rand.nextInt(4) - 2, player.posY + 20, player.posZ + player.worldObj.rand.nextInt(4) - 2);
                    player.worldObj.spawnEntityInWorld(creeper);
                }
            }
        }
    } else {
        player.addChatMessage(new ChatComponentText("You aren't Moridrex..."));
    }
}
Also used : Explosion(net.minecraft.world.Explosion) EntityCreeper(net.minecraft.entity.monster.EntityCreeper) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ChatComponentText(net.minecraft.util.ChatComponentText)

Example 90 with ChatComponentText

use of net.minecraft.util.ChatComponentText in project ArsMagica2 by Mithion.

the class ItemSpellStaff method onItemUseFirst.

@Override
public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
    if (isMagiTechStaff()) {
        if (!world.isRemote) {
            TileEntity te = world.getTileEntity(x, y, z);
            if (te != null && te instanceof IPowerNode) {
                if (player.isSneaking()) {
                    AMNetHandler.INSTANCE.syncPowerPaths((IPowerNode) te, (EntityPlayerMP) player);
                } else {
                    PowerTypes[] types = ((IPowerNode) te).getValidPowerTypes();
                    for (PowerTypes type : types) {
                        float power = PowerNodeRegistry.For(world).getPower((IPowerNode) te, type);
                        player.addChatMessage(new ChatComponentText(String.format(StatCollector.translateToLocal("am2.tooltip.det_eth"), type.chatColor(), type.name(), String.format("%.2f", power))));
                    }
                }
                return true;
            }
        }
    }
    return false;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) PowerTypes(am2.api.power.PowerTypes) ChatComponentText(net.minecraft.util.ChatComponentText) IPowerNode(am2.api.power.IPowerNode)

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