Search in sources :

Example 6 with IBindable

use of WayofTime.alchemicalWizardry.api.items.interfaces.IBindable in project BloodMagic by WayofTime.

the class ItemDiabloKey method onItemRightClick.

public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
    World world = par3EntityPlayer.worldObj;
    if (!EnergyItems.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer) || par3EntityPlayer instanceof FakePlayer || par3EntityPlayer instanceof EntityPlayerMP) {
        return par1ItemStack;
    }
    if (world != null) {
        double posX = par3EntityPlayer.posX;
        double posY = par3EntityPlayer.posY;
        double posZ = par3EntityPlayer.posZ;
        world.playSoundEffect((double) ((float) posX + 0.5F), (double) ((float) posY + 0.5F), (double) ((float) posZ + 0.5F), "random.fizz", 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F);
        SpellHelper.sendIndexedParticleToAllAround(world, posX, posY, posZ, 20, world.provider.dimensionId, 4, posX, posY, posZ);
    }
    if (!par3EntityPlayer.worldObj.isRemote && !(par3EntityPlayer.getClass().equals(EntityPlayerMP.class))) {
        return par1ItemStack;
    }
    if (par3EntityPlayer.isSneaking()) {
        return par1ItemStack;
    }
    NBTTagCompound itemTag = par1ItemStack.getTagCompound();
    if (itemTag == null || itemTag.getString("ownerName").equals("")) {
        return par1ItemStack;
    }
    String ownerName = itemTag.getString("ownerName");
    ItemStack[] inv = par3EntityPlayer.inventory.mainInventory;
    for (ItemStack itemStack : inv) {
        if (itemStack == null) {
            continue;
        }
        Item item = itemStack.getItem();
        if (item instanceof ItemDiabloKey) {
            continue;
        }
        if (item instanceof IBindable) {
            EnergyItems.checkAndSetItemOwner(itemStack, ownerName);
        }
    }
    return par1ItemStack;
}
Also used : Item(net.minecraft.item.Item) IBindable(WayofTime.alchemicalWizardry.api.items.interfaces.IBindable) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) World(net.minecraft.world.World) ItemStack(net.minecraft.item.ItemStack) FakePlayer(net.minecraftforge.common.util.FakePlayer)

Aggregations

IBindable (WayofTime.alchemicalWizardry.api.items.interfaces.IBindable)6 ItemStack (net.minecraft.item.ItemStack)6 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)3 World (net.minecraft.world.World)3 CommandException (net.minecraft.command.CommandException)2 EntityPlayer (net.minecraft.entity.player.EntityPlayer)2 BoundArmour (WayofTime.alchemicalWizardry.common.items.armour.BoundArmour)1 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 List (java.util.List)1 EntityLivingBase (net.minecraft.entity.EntityLivingBase)1 EntityLightningBolt (net.minecraft.entity.effect.EntityLightningBolt)1 EntityItem (net.minecraft.entity.item.EntityItem)1 IInventory (net.minecraft.inventory.IInventory)1 Item (net.minecraft.item.Item)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1 TileEntity (net.minecraft.tileentity.TileEntity)1 AxisAlignedBB (net.minecraft.util.AxisAlignedBB)1 ChatComponentTranslation (net.minecraft.util.ChatComponentTranslation)1 FakePlayer (net.minecraftforge.common.util.FakePlayer)1