Allow stacks of essence berries to be consumed at once (#114)

* consume stacks at once

* address review
This commit is contained in:
GDCloud authored and GitHub committed 2024-04-02 00:19:36 +02:00
1 parent c40122661a
commit b486ea2744
1 file changed
+17 -8
@@ -52,14 +52,23 @@ public class OreBerries extends CraftingItem {
@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
if (stack.getItemDamage() == 5) {
EntityXPOrb entity = new EntityXPOrb(
world,
player.posX,
player.posY + 1,
player.posZ,
itemRand.nextInt(14) + 6);
spawnEntity(player.posX, player.posY + 1, player.posZ, entity, world, player);
if (!player.capabilities.isCreativeMode) stack.stackSize--;
if (!player.isSneaking()) {
EntityXPOrb entity = new EntityXPOrb(
world,
player.posX,
player.posY + 1,
player.posZ,
itemRand.nextInt(14) + 6);
spawnEntity(player.posX, player.posY + 1, player.posZ, entity, world, player);
if (!player.capabilities.isCreativeMode) stack.stackSize--;
} else {
int xpToAdd = 0;
for (int i = stack.stackSize; i > 0; i--) {
xpToAdd += itemRand.nextInt(14) + 6;
}
player.addExperience(xpToAdd);
if (!player.capabilities.isCreativeMode) stack.stackSize = 0;
}
}
return stack;
}