Search in sources :

Example 1 with ItemNameTag

use of net.minecraft.item.ItemNameTag in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class EventsCommon method onRightClickBlock.

@SubscribeEvent()
public void onRightClickBlock(RightClickBlock event) {
    if (!event.getWorld().isRemote) {
        ItemStack stack = event.getItemStack();
        if (stack != null && stack.getItem() instanceof ItemNameTag) {
            BlockPos posAt = event.getPos();
            EntityPlayer player = event.getEntityPlayer();
            World world = event.getWorld();
            PhysicsWrapperEntity wrapper = ValkyrienWarfareMod.physicsManager.getObjectManagingPos(world, posAt);
            if (wrapper != null) {
                wrapper.setCustomNameTag(stack.getDisplayName());
                --stack.stackSize;
                event.setCanceled(true);
            }
        }
    }
}
Also used : ItemNameTag(net.minecraft.item.ItemNameTag) PhysicsWrapperEntity(ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity) EntityPlayer(net.minecraft.entity.player.EntityPlayer) BlockPos(net.minecraft.util.math.BlockPos) ItemStack(net.minecraft.item.ItemStack) World(net.minecraft.world.World) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 2 with ItemNameTag

use of net.minecraft.item.ItemNameTag in project ArsMagica2 by Mithion.

the class EntityLightMage method interact.

@Override
protected boolean interact(EntityPlayer player) {
    if (worldObj.isRemote)
        return false;
    if (player.getHeldItem() != null && player.getHeldItem().getItem() instanceof ItemNameTag)
        return false;
    if (SkillData.For(player).isEntryKnown(SkillTreeManager.instance.getSkillTreeEntry(SkillManager.instance.getSkill("MageBandI")))) {
        if (EntityUtilities.isSummon(this)) {
            player.addChatMessage(new ChatComponentText(String.format("\247o%s", StatCollector.translateToLocal("am2.npc.partyleave"))));
            EntityUtilities.revertAI(this);
        } else {
            if (ExtendedProperties.For(player).getCanHaveMoreSummons()) {
                if (ExtendedProperties.For(player).getMagicLevel() - 5 >= ExtendedProperties.For(this).getMagicLevel()) {
                    player.addChatMessage(new ChatComponentText(String.format("\247o%s", StatCollector.translateToLocal("am2.npc.partyjoin"))));
                    EntityUtilities.setOwner(this, player);
                    EntityUtilities.makeSummon_PlayerFaction(this, player, true);
                    EntityUtilities.setSummonDuration(this, -1);
                } else {
                    player.addChatMessage(new ChatComponentText(String.format("\247o%s", StatCollector.translateToLocal("am2.npc.partyrefuse"))));
                }
            } else {
                player.addChatMessage(new ChatComponentText(String.format("\247o%s", StatCollector.translateToLocal("am2.npc.partyfull"))));
            }
        }
    } else {
        player.addChatMessage(new ChatComponentText(String.format("\247o%s", StatCollector.translateToLocal("am2.npc.nopartyskill"))));
    }
    return false;
}
Also used : ItemNameTag(net.minecraft.item.ItemNameTag) ChatComponentText(net.minecraft.util.ChatComponentText)

Aggregations

ItemNameTag (net.minecraft.item.ItemNameTag)2 PhysicsWrapperEntity (ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 ItemStack (net.minecraft.item.ItemStack)1 ChatComponentText (net.minecraft.util.ChatComponentText)1 BlockPos (net.minecraft.util.math.BlockPos)1 World (net.minecraft.world.World)1 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)1