Fix stackable consumable bug
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
package core.game.content.consumable;
|
package core.game.content.consumable;
|
||||||
|
|
||||||
|
import api.Container;
|
||||||
|
import api.ContentAPI;
|
||||||
import core.game.node.entity.player.Player;
|
import core.game.node.entity.player.Player;
|
||||||
import core.game.node.item.Item;
|
import core.game.node.item.Item;
|
||||||
import core.game.world.update.flag.context.Animation;
|
import core.game.world.update.flag.context.Animation;
|
||||||
@@ -46,10 +48,13 @@ public abstract class Consumable implements Plugin<Object> {
|
|||||||
public void consume(final Item item, final Player player) {
|
public void consume(final Item item, final Player player) {
|
||||||
executeConsumptionActions(player);
|
executeConsumptionActions(player);
|
||||||
final int nextItemId = getNextItemId(item.getId());
|
final int nextItemId = getNextItemId(item.getId());
|
||||||
|
|
||||||
|
if(item.getAmount() > 1){
|
||||||
|
ContentAPI.removeItem(player, item.getId(), Container.INVENTORY);
|
||||||
|
} else ContentAPI.removeItem(player, item, Container.INVENTORY);
|
||||||
|
|
||||||
if (nextItemId != -1) {
|
if (nextItemId != -1) {
|
||||||
player.getInventory().replace(new Item(nextItemId), item.getSlot());
|
ContentAPI.addItem(player, nextItemId, 1);
|
||||||
} else {
|
|
||||||
player.getInventory().remove(item);
|
|
||||||
}
|
}
|
||||||
final int initialLifePoints = player.getSkills().getLifepoints();
|
final int initialLifePoints = player.getSkills().getLifepoints();
|
||||||
Consumables.getConsumableById(item.getId()).effect.activate(player);
|
Consumables.getConsumableById(item.getId()).effect.activate(player);
|
||||||
|
|||||||
@@ -285,7 +285,7 @@ public enum Consumables {
|
|||||||
/** Miscellaneous */
|
/** Miscellaneous */
|
||||||
CHOCOLATE_BAR(new Food(new int[] {1973}, new HealingEffect(3))),
|
CHOCOLATE_BAR(new Food(new int[] {1973}, new HealingEffect(3))),
|
||||||
PURPLE_SWEETS(new Food(new int[] {4561}, new HealingEffect(0))),
|
PURPLE_SWEETS(new Food(new int[] {4561}, new HealingEffect(0))),
|
||||||
PURPLE_SWEETS_STACKABLE(new Food(new int[] {10476, 10476}, new MultiEffect(new EnergyEffect(10), new RandomHealthEffect(1, 3)), "The sugary goodness heals some energy.", "The sugary goodness is yummy.")),
|
PURPLE_SWEETS_STACKABLE(new Food(new int[] {10476}, new MultiEffect(new EnergyEffect(10), new RandomHealthEffect(1, 3)), "The sugary goodness heals some energy.", "The sugary goodness is yummy.")),
|
||||||
FIELD_RATION(new Food(new int[] {7934}, new HealingEffect(10))),
|
FIELD_RATION(new Food(new int[] {7934}, new HealingEffect(10))),
|
||||||
ROLL(new Food(new int[] {6963}, new HealingEffect(6))),
|
ROLL(new Food(new int[] {6963}, new HealingEffect(6))),
|
||||||
TCHIKI_MONKEY_NUTS(new Food(new int[] {7573}, new HealingEffect(5), "You eat the Tchiki monkey nuts. They taste nutty.")),
|
TCHIKI_MONKEY_NUTS(new Food(new int[] {7573}, new HealingEffect(5), "You eat the Tchiki monkey nuts. They taste nutty.")),
|
||||||
|
|||||||
Reference in New Issue
Block a user