From 4eaaae3e1751d94204d409262a4e986b197f45de Mon Sep 17 00:00:00 2001 From: AndyTechGuy Date: Wed, 8 Jul 2020 14:36:52 -0230 Subject: [PATCH] Rearrange logic in onActivate water well system event --- .../interaction/systems/WellWaterSystem.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/terasology/metalrenegades/interaction/systems/WellWaterSystem.java b/src/main/java/org/terasology/metalrenegades/interaction/systems/WellWaterSystem.java index 234130dc..7209a82d 100644 --- a/src/main/java/org/terasology/metalrenegades/interaction/systems/WellWaterSystem.java +++ b/src/main/java/org/terasology/metalrenegades/interaction/systems/WellWaterSystem.java @@ -88,15 +88,16 @@ public void onActivate(ActivateEvent event, EntityRef sourceBlock) { } WellSourceComponent wellSourceComp = wellEntity.getComponent(WellSourceComponent.class); - if (!useRefill(wellSourceComp)) { // if no refills remain, don't give water. - return; - } + boolean refillAvailable = useRefill(wellSourceComp); - EntityRef heldItem = gatheringCharacter.getComponent(CharacterHeldItemComponent.class).selectedItem; - if (heldItem.hasComponent(WaterCupComponent.class)) { - fillWaterCup(gatheringCharacter, heldItem, wellEntity); - } else { - directDrink(gatheringCharacter, wellEntity); + if (refillAvailable) { + EntityRef heldItem = gatheringCharacter.getComponent(CharacterHeldItemComponent.class).selectedItem; + + if (heldItem.hasComponent(WaterCupComponent.class)) { + fillWaterCup(gatheringCharacter, heldItem, wellEntity); + } else { + directDrink(gatheringCharacter, wellEntity); + } } wellEntity.saveComponent(wellSourceComp);