@@ -60,6 +60,12 @@ public class EntityLootEntry {
6060 @ Getter (AccessLevel .PUBLIC )
6161 private @ UnknownNullability ItemStack item ;
6262
63+ // This NamespacedKey is used to match any attacker or damage type.
64+ private static final NamespacedKey ANY = new NamespacedKey ("minecraft" , "any" );
65+
66+ // This NamespacedKey is used to match unspecified / null attacker or damage type.
67+ private static final NamespacedKey UNSPECIFIED = new NamespacedKey ("minecraft" , "unspecified" );
68+
6369 @ Accessors (fluent = true )
6470 @ NoArgsConstructor (access = AccessLevel .PROTECTED )
6571 public static class Chance {
@@ -92,8 +98,8 @@ public static class Matcher {
9298
9399 public boolean matches (final @ Nullable String variant , final @ Nullable NamespacedKey attacker , final @ Nullable NamespacedKey damageType ) {
94100 final boolean isVariantMatch = (this .variant == null ) || Objects .equals (this .variant , variant );
95- final boolean isAttackerMatch = (attackers == null || attacker == null ) || attackers .contains (attacker );
96- final boolean isDamageMatch = (damageTypes == null || damageType == null ) || damageTypes .contains (damageType );
101+ final boolean isAttackerMatch = (this . attackers != null ) && (( this . attackers . contains ( ANY ) == true || this . attackers . contains ( attacker ) == true ) || ( this . attackers .contains (UNSPECIFIED ) == false && attacker == null ) );
102+ final boolean isDamageMatch = (this . damageTypes != null ) && (( this . damageTypes . contains ( ANY ) == true || this . damageTypes . contains ( damageType ) == true ) || ( this . damageTypes .contains (UNSPECIFIED ) == false && damageType == null ) );
97103 // Returning whether provided values match.
98104 return isVariantMatch && isAttackerMatch && isDamageMatch ;
99105 }
0 commit comments