From ffa0e186440249e1657268d036ec3036974b9fe9 Mon Sep 17 00:00:00 2001 From: SHsuperCM Date: Mon, 25 Apr 2022 17:48:42 +0300 Subject: Fixed hand condition parity Fixes #135 --- .../citresewn/defaults/cit/conditions/ConditionHand.java | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/defaults/src/main/java/shcm/shsupercm/fabric/citresewn/defaults/cit/conditions/ConditionHand.java b/defaults/src/main/java/shcm/shsupercm/fabric/citresewn/defaults/cit/conditions/ConditionHand.java index 0405cbc..d76c90f 100644 --- a/defaults/src/main/java/shcm/shsupercm/fabric/citresewn/defaults/cit/conditions/ConditionHand.java +++ b/defaults/src/main/java/shcm/shsupercm/fabric/citresewn/defaults/cit/conditions/ConditionHand.java @@ -1,6 +1,7 @@ package shcm.shsupercm.fabric.citresewn.defaults.cit.conditions; import io.shcm.shsupercm.fabric.fletchingtable.api.Entrypoint; +import net.minecraft.util.Hand; import shcm.shsupercm.fabric.citresewn.api.CITConditionContainer; import shcm.shsupercm.fabric.citresewn.cit.CITContext; import shcm.shsupercm.fabric.citresewn.cit.builtin.conditions.EnumCondition; @@ -16,18 +17,12 @@ public class ConditionHand extends EnumCondition { @Override protected Hand getValue(CITContext context) { - if (context.entity.getMainHandStack() == context.stack) - return Hand.MAINHAND; - if (context.entity.getOffHandStack() == context.stack) - return Hand.OFFHAND; - - return null; + return context.entity != null && context.entity.getOffHandStack() == context.stack ? Hand.OFFHAND : Hand.MAINHAND; } @Override public boolean test(CITContext context) { - Hand hand = getValue(context); - return this.value == hand || (this.value == Hand.ANY && hand != null); + return this.value == Hand.ANY || this.value == getValue(context); } protected enum Hand implements EnumCondition.Aliased { -- cgit