Skip to content

Commit

Permalink
Fix a crash & create in LootTableEvent
Browse files Browse the repository at this point in the history
  • Loading branch information
LLytho committed Jul 25, 2024
1 parent a71a076 commit 2b662d8
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ and this project adheres to [Semantic Versioning].

- /

## [3.0.4] - 2024-07-25

- Fix `.create` in loot tables event

## [3.0.3] - 2024-07-22

- Bump kubejs version
Expand Down
5 changes: 5 additions & 0 deletions example_scripts/create_loot_table.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
LootJS.lootTables(e => {
e.create("lootjs:blocks/test_table", "block").createPool((pool) => {
pool.addEntry(LootEntry.of("minecraft:stick").limitCount(10, 32));
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public ItemLootEntry(ItemStack itemStack) {
getFunctions().setCount(ConstantValue.exactly(itemStack.getCount()));
}

if (!itemStack.getComponents().isEmpty()) {
if (!itemStack.isComponentsPatchEmpty()) {
DataComponentPatch.Builder builder = DataComponentPatch.builder();
for (TypedDataComponent<?> component : itemStack.getComponents()) {
builder.set(Utils.cast(component.type()), component.value());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
@Mixin(value = ReloadableServerRegistries.class, priority = 1337)
public class ReloadableServerRegistriesMixin {

@Inject(method = "apply", at = @At("RETURN"))
@Inject(method = "apply", at = @At("HEAD"))
private static void lootjs$runLootTableEventJS(LayeredRegistryAccess<RegistryLayer> arg, List<WritableRegistry<?>> list, CallbackInfoReturnable<LayeredRegistryAccess<RegistryLayer>> cir) {
WritableRegistry<LootTable> registry = null;
try {
Expand Down

0 comments on commit 2b662d8

Please sign in to comment.