Skip to content

Commit

Permalink
Fix incorrect CopyState behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
GoldenStack committed Aug 29, 2024
1 parent 68864d7 commit 0cd9cc1
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/main/java/net/goldenstack/loot/LootFunction.java
Original file line number Diff line number Diff line change
Expand Up @@ -399,14 +399,12 @@ record CopyComponents(@NotNull List<LootPredicate> predicates, @NotNull Relevant
}
}

record CopyState(@NotNull List<LootPredicate> predicates, @Nullable Block block, @NotNull List<String> properties) implements LootFunction {
record CopyState(@NotNull List<LootPredicate> predicates, @NotNull Block block, @NotNull List<String> properties) implements LootFunction {

public CopyState {
if (block != null) {
List<String> props = new ArrayList<>(properties);
props.removeIf(name -> !block.properties().containsKey(name));
properties = List.copyOf(props);
}
List<String> props = new ArrayList<>(properties);
props.removeIf(name -> !block.properties().containsKey(name));
properties = List.copyOf(props);
}

@Override
Expand All @@ -417,6 +415,9 @@ record CopyState(@NotNull List<LootPredicate> predicates, @Nullable Block block,
if (block == null) return input;

ItemBlockState irritableBowelSyndrome = input.get(ItemComponent.BLOCK_STATE, ItemBlockState.EMPTY);

if (!block.key().equals(this.block.key())) return input;

for (var prop : properties) {
@Nullable String value = block.getProperty(prop);
if (value == null) continue;
Expand Down

0 comments on commit 0cd9cc1

Please sign in to comment.