From 1c5cc1b0000654d12025de30440511dfbd42ee71 Mon Sep 17 00:00:00 2001 From: NaulaN Date: Fri, 17 Jun 2022 11:50:09 +0200 Subject: [PATCH] Fix meat ne veux pas se supprimer --- .../java/fr/sae/terraria/modele/entities/items/Item.java | 4 +++- .../java/fr/sae/terraria/modele/entities/items/Meat.java | 7 ++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/java/fr/sae/terraria/modele/entities/items/Item.java b/src/main/java/fr/sae/terraria/modele/entities/items/Item.java index 3ef05a0..8ca86e9 100644 --- a/src/main/java/fr/sae/terraria/modele/entities/items/Item.java +++ b/src/main/java/fr/sae/terraria/modele/entities/items/Item.java @@ -11,7 +11,8 @@ public enum Item implements StowableObjectType SILEX, STONE, WOOD, - STICK; + STICK, + MEAT; public static boolean isCoal(StowableObjectType obj) { return obj == Item.COAL; } @@ -21,4 +22,5 @@ public enum Item implements StowableObjectType public static boolean isSilex(StowableObjectType obj) { return obj == Item.SILEX; } public static boolean isWood(StowableObjectType obj) { return obj == Item.WOOD; } public static boolean isStick(StowableObjectType obj) { return obj == Item.STICK; } + public static boolean isMeat(StowableObjectType obj) { return obj == Item.MEAT; } } diff --git a/src/main/java/fr/sae/terraria/modele/entities/items/Meat.java b/src/main/java/fr/sae/terraria/modele/entities/items/Meat.java index 37d8772..e632d8d 100644 --- a/src/main/java/fr/sae/terraria/modele/entities/items/Meat.java +++ b/src/main/java/fr/sae/terraria/modele/entities/items/Meat.java @@ -4,6 +4,8 @@ import fr.sae.terraria.modele.entities.entity.ConsumableObjectType; import fr.sae.terraria.modele.entities.entity.StowableObjectType; import fr.sae.terraria.modele.entities.player.Player; +import fr.sae.terraria.modele.entities.player.inventory.Inventory; +import fr.sae.terraria.modele.entities.player.inventory.Stack; public class Meat implements ConsumableObjectType, StowableObjectType @@ -21,8 +23,11 @@ public Meat(final Environment environment) { Environment.playSound("sound/eat.wav", false); - Player player = environment.getPlayer(); + Player player = this.environment.getPlayer(); if (player.getPv() < player.getPvMax()) player.setPv(player.getPv() + 1); + + Inventory inventory = player.getInventory(); + inventory.get().get(inventory.getPosCursor()).remove(); } }