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;
}
Aggregations