use of net.minecraft.item.ItemFood in project BloodMagic by WayofTime.
the class EntityBileDemon method interact.
/**
* Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig.
*/
@Override
public boolean interact(EntityPlayer par1EntityPlayer) {
ItemStack itemstack = par1EntityPlayer.inventory.getCurrentItem();
if (this.isTamed()) {
if (itemstack != null) {
if (itemstack.getItem() instanceof ItemFood) {
ItemFood itemfood = (ItemFood) itemstack.getItem();
if (itemfood.isWolfsFavoriteMeat() && this.dataWatcher.getWatchableObjectFloat(18) < maxTamedHealth) {
if (!par1EntityPlayer.capabilities.isCreativeMode) {
--itemstack.stackSize;
}
this.heal((float) itemfood.func_150905_g(itemstack));
if (itemstack.stackSize <= 0) {
par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, null);
}
return true;
}
}
}
if (this.getOwner() instanceof EntityPlayer && SpellHelper.getUsername(par1EntityPlayer).equalsIgnoreCase(SpellHelper.getUsername((EntityPlayer) this.getOwner())) && !this.isBreedingItem(itemstack)) {
if (!this.worldObj.isRemote) {
this.aiSit.setSitting(!this.isSitting());
this.isJumping = false;
this.setPathToEntity(null);
this.setTarget(null);
this.setAttackTarget(null);
}
this.sendSittingMessageToPlayer(par1EntityPlayer, !this.isSitting());
}
} else if (itemstack != null && itemstack.getItem().equals(ModItems.weakBloodOrb) && !this.isAngry()) {
if (!par1EntityPlayer.capabilities.isCreativeMode) {
--itemstack.stackSize;
}
if (itemstack.stackSize <= 0) {
par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, null);
}
if (!this.worldObj.isRemote) {
if (this.rand.nextInt(1) == 0) {
this.setTamed(true);
this.setPathToEntity(null);
this.setAttackTarget(null);
this.aiSit.setSitting(true);
this.setHealth(maxTamedHealth);
this.func_152115_b(par1EntityPlayer.getUniqueID().toString());
this.playTameEffect(true);
this.worldObj.setEntityState(this, (byte) 7);
} else {
this.playTameEffect(false);
this.worldObj.setEntityState(this, (byte) 6);
}
}
return true;
}
return super.interact(par1EntityPlayer);
}
use of net.minecraft.item.ItemFood in project BloodMagic by WayofTime.
the class EntityLowerGuardian method interact.
/**
* Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig.
*/
@Override
public boolean interact(EntityPlayer par1EntityPlayer) {
ItemStack itemstack = par1EntityPlayer.inventory.getCurrentItem();
if (this.isTamed()) {
if (itemstack != null) {
if (itemstack.getItem() instanceof ItemFood) {
ItemFood itemfood = (ItemFood) itemstack.getItem();
if (itemfood.isWolfsFavoriteMeat() && this.dataWatcher.getWatchableObjectFloat(18) < maxTamedHealth) {
if (!par1EntityPlayer.capabilities.isCreativeMode) {
--itemstack.stackSize;
}
this.heal((float) itemfood.func_150905_g(itemstack));
if (itemstack.stackSize <= 0) {
par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, null);
}
return true;
}
}
}
if (this.getOwner() instanceof EntityPlayer && SpellHelper.getUsername(par1EntityPlayer).equalsIgnoreCase(SpellHelper.getUsername((EntityPlayer) this.getOwner())) && !this.isBreedingItem(itemstack)) {
if (!this.worldObj.isRemote) {
this.aiSit.setSitting(!this.isSitting());
this.isJumping = false;
this.setPathToEntity(null);
this.setTarget(null);
this.setAttackTarget(null);
}
this.sendSittingMessageToPlayer(par1EntityPlayer, !this.isSitting());
}
} else if (itemstack != null && itemstack.getItem().equals(ModItems.weakBloodOrb) && !this.isAngry()) {
if (!par1EntityPlayer.capabilities.isCreativeMode) {
--itemstack.stackSize;
}
if (itemstack.stackSize <= 0) {
par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, null);
}
if (!this.worldObj.isRemote) {
if (this.rand.nextInt(1) == 0) {
this.setTamed(true);
this.setPathToEntity(null);
this.setAttackTarget(null);
this.aiSit.setSitting(true);
this.setHealth(maxTamedHealth);
this.func_152115_b(par1EntityPlayer.getUniqueID().toString());
this.playTameEffect(true);
this.worldObj.setEntityState(this, (byte) 7);
} else {
this.playTameEffect(false);
this.worldObj.setEntityState(this, (byte) 6);
}
}
return true;
}
return super.interact(par1EntityPlayer);
}
use of net.minecraft.item.ItemFood in project BloodMagic by WayofTime.
the class EntityWingedFireDemon method interact.
/**
* Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig.
*/
@Override
public boolean interact(EntityPlayer par1EntityPlayer) {
ItemStack itemstack = par1EntityPlayer.inventory.getCurrentItem();
if (this.isTamed()) {
if (itemstack != null) {
if (itemstack.getItem() instanceof ItemFood) {
ItemFood itemfood = (ItemFood) itemstack.getItem();
if (itemfood.isWolfsFavoriteMeat() && this.dataWatcher.getWatchableObjectFloat(18) < maxTamedHealth) {
if (!par1EntityPlayer.capabilities.isCreativeMode) {
--itemstack.stackSize;
}
this.heal((float) itemfood.func_150905_g(itemstack));
if (itemstack.stackSize <= 0) {
par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, null);
}
return true;
}
}
}
if (this.getOwner() instanceof EntityPlayer && SpellHelper.getUsername(par1EntityPlayer).equalsIgnoreCase(SpellHelper.getUsername((EntityPlayer) this.getOwner())) && !this.isBreedingItem(itemstack)) {
if (!this.worldObj.isRemote) {
this.aiSit.setSitting(!this.isSitting());
this.isJumping = false;
this.setPathToEntity(null);
this.setTarget(null);
this.setAttackTarget(null);
}
this.sendSittingMessageToPlayer(par1EntityPlayer, !this.isSitting());
}
} else if (itemstack != null && itemstack.getItem().equals(ModItems.weakBloodOrb) && !this.isAngry()) {
if (!par1EntityPlayer.capabilities.isCreativeMode) {
--itemstack.stackSize;
}
if (itemstack.stackSize <= 0) {
par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, null);
}
if (!this.worldObj.isRemote) {
if (this.rand.nextInt(1) == 0) {
this.setTamed(true);
this.setPathToEntity(null);
this.setAttackTarget(null);
this.aiSit.setSitting(true);
this.setHealth(maxTamedHealth);
this.func_152115_b(par1EntityPlayer.getUniqueID().toString());
this.playTameEffect(true);
this.worldObj.setEntityState(this, (byte) 7);
} else {
this.playTameEffect(false);
this.worldObj.setEntityState(this, (byte) 6);
}
}
return true;
}
return super.interact(par1EntityPlayer);
}
Aggregations