mirror of
https://github.com/Sollace/Unicopia.git
synced 2025-02-17 10:24:23 +01:00
Fixed edibles not returning their container item correctly
This commit is contained in:
parent
8478c0a0da
commit
61cb1ac78b
1 changed files with 16 additions and 6 deletions
|
@ -66,8 +66,10 @@ public class ItemEdible extends ItemFood implements IEdible {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityLivingBase entityLiving) {
|
public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityLivingBase entityLiving) {
|
||||||
if (entityLiving instanceof EntityPlayer) {
|
|
||||||
EntityPlayer entityplayer = (EntityPlayer)entityLiving;
|
EntityPlayer entityplayer = entityLiving instanceof EntityPlayer ? (EntityPlayer)entityLiving : null;
|
||||||
|
|
||||||
|
if (entityplayer != null) {
|
||||||
entityplayer.getFoodStats().addStats(this, stack);
|
entityplayer.getFoodStats().addStats(this, stack);
|
||||||
|
|
||||||
worldIn.playSound(null, entityplayer.posX, entityplayer.posY, entityplayer.posZ, SoundEvents.ENTITY_PLAYER_BURP, SoundCategory.PLAYERS, 0.5F, worldIn.rand.nextFloat() * 0.1F + 0.9F);
|
worldIn.playSound(null, entityplayer.posX, entityplayer.posY, entityplayer.posZ, SoundEvents.ENTITY_PLAYER_BURP, SoundCategory.PLAYERS, 0.5F, worldIn.rand.nextFloat() * 0.1F + 0.9F);
|
||||||
|
@ -80,15 +82,23 @@ public class ItemEdible extends ItemFood implements IEdible {
|
||||||
if (entityplayer instanceof EntityPlayerMP) {
|
if (entityplayer instanceof EntityPlayerMP) {
|
||||||
CriteriaTriggers.CONSUME_ITEM.trigger((EntityPlayerMP)entityplayer, stack);
|
CriteriaTriggers.CONSUME_ITEM.trigger((EntityPlayerMP)entityplayer, stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (entityplayer == null || !entityplayer.capabilities.isCreativeMode) {
|
||||||
|
stack.shrink(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemStack container = getContainerItem(stack);
|
ItemStack container = getContainerItem(stack);
|
||||||
|
|
||||||
if (!container.isEmpty()) {
|
if (!container.isEmpty() && entityplayer != null && !entityplayer.capabilities.isCreativeMode) {
|
||||||
return container;
|
if (stack.isEmpty()) {
|
||||||
}
|
return getContainerItem(stack);
|
||||||
|
}
|
||||||
|
|
||||||
stack.shrink(1);
|
entityplayer.inventory.addItemStackToInventory(getContainerItem(stack));
|
||||||
|
}
|
||||||
|
|
||||||
return stack;
|
return stack;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue