From 7ace8b152fd84492e1b9438cd66d6b5baf865850 Mon Sep 17 00:00:00 2001 From: Talia-12 Date: Tue, 6 Feb 2024 23:19:39 +1000 Subject: [PATCH] Fix #467, config-disabled patterns no longer spawned as loot (this is a "should fix it" not a "confirmed fixed it") --- .../common/loot/AddPerWorldPatternToScrollFunc.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Common/src/main/java/at/petrak/hexcasting/common/loot/AddPerWorldPatternToScrollFunc.java b/Common/src/main/java/at/petrak/hexcasting/common/loot/AddPerWorldPatternToScrollFunc.java index 30c9f97370..a64fef948d 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/loot/AddPerWorldPatternToScrollFunc.java +++ b/Common/src/main/java/at/petrak/hexcasting/common/loot/AddPerWorldPatternToScrollFunc.java @@ -1,6 +1,8 @@ package at.petrak.hexcasting.common.loot; +import at.petrak.hexcasting.api.HexAPI; import at.petrak.hexcasting.api.casting.ActionRegistryEntry; +import at.petrak.hexcasting.api.mod.HexConfig; import at.petrak.hexcasting.api.mod.HexTags; import at.petrak.hexcasting.api.utils.HexUtils; import at.petrak.hexcasting.common.casting.PatternRegistryManifest; @@ -40,7 +42,7 @@ public static ItemStack doStatic(ItemStack stack, LootContext ctx) { var perWorldKeys = new ArrayList>(); Registry regi = IXplatAbstractions.INSTANCE.getActionRegistry(); for (var key : regi.registryKeySet()) { - if (HexUtils.isOfTag(regi, key, HexTags.Actions.PER_WORLD_PATTERN)) { + if (HexUtils.isOfTag(regi, key, HexTags.Actions.PER_WORLD_PATTERN) && HexConfig.server().isActionAllowed(key.location())) { perWorldKeys.add(key); } } @@ -49,7 +51,11 @@ public static ItemStack doStatic(ItemStack stack, LootContext ctx) { var pat = PatternRegistryManifest.getCanonicalStrokesPerWorld(key, ctx.getLevel().getServer().overworld()); var tag = new CompoundTag(); tag.putString(ItemScroll.TAG_OP_ID, key.location().toString()); - tag.put(ItemScroll.TAG_PATTERN, pat.serializeToNBT()); + if (pat != null) { + tag.put(ItemScroll.TAG_PATTERN, pat.serializeToNBT()); + } else { + HexAPI.LOGGER.warn("Tried to generate great scroll for %s, doesn't have canonical per-world strokes.".formatted(key)); + } stack.getOrCreateTag().merge(tag);