From 949182f13ec92328f6d6c4d262369ef1909b5b00 Mon Sep 17 00:00:00 2001 From: Relentless Date: Wed, 19 Apr 2023 21:33:33 +0200 Subject: [PATCH] fix tag ownership crash on dedicated servers --- .../unified/AlmostUnifiedFallbackRuntime.java | 6 ++++++ .../java/com/almostreliable/unified/compat/HideHelper.java | 6 ++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Common/src/main/java/com/almostreliable/unified/AlmostUnifiedFallbackRuntime.java b/Common/src/main/java/com/almostreliable/unified/AlmostUnifiedFallbackRuntime.java index 6a05a5a..29ce49a 100644 --- a/Common/src/main/java/com/almostreliable/unified/AlmostUnifiedFallbackRuntime.java +++ b/Common/src/main/java/com/almostreliable/unified/AlmostUnifiedFallbackRuntime.java @@ -7,6 +7,7 @@ import com.almostreliable.unified.utils.ReplacementMap; import com.almostreliable.unified.utils.TagMap; import com.almostreliable.unified.utils.TagOwnerships; import com.almostreliable.unified.utils.UnifyTag; +import com.google.common.base.Preconditions; import com.google.gson.JsonElement; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.Item; @@ -84,4 +85,9 @@ public class AlmostUnifiedFallbackRuntime implements AlmostUnifiedRuntime { public Optional getUnifyConfig() { return Optional.ofNullable(config); } + + public TagOwnerships getTagOwnerships() { + Preconditions.checkNotNull(tagOwnerships, "TagOwnerships were not loaded correctly"); + return tagOwnerships; + } } diff --git a/Common/src/main/java/com/almostreliable/unified/compat/HideHelper.java b/Common/src/main/java/com/almostreliable/unified/compat/HideHelper.java index a1129a0..7ba8345 100644 --- a/Common/src/main/java/com/almostreliable/unified/compat/HideHelper.java +++ b/Common/src/main/java/com/almostreliable/unified/compat/HideHelper.java @@ -1,6 +1,7 @@ package com.almostreliable.unified.compat; import com.almostreliable.unified.AlmostUnified; +import com.almostreliable.unified.AlmostUnifiedFallbackRuntime; import com.almostreliable.unified.AlmostUnifiedRuntime; import com.almostreliable.unified.utils.ReplacementMap; import com.almostreliable.unified.utils.TagMap; @@ -91,8 +92,9 @@ public class HideHelper { private static Set getRefItems(ReplacementMap repMap) { Set hidingList = new HashSet<>(); - for (var ref : AlmostUnified.getTagOwnerships().getRefs()) { - var owner = AlmostUnified.getTagOwnerships().getOwnerByTag(ref); + var tagOwnerships = AlmostUnifiedFallbackRuntime.getInstance().getTagOwnerships(); + for (var ref : tagOwnerships.getRefs()) { + var owner = tagOwnerships.getOwnerByTag(ref); assert owner != null; var dominantItem = repMap.getPreferredItemForTag(owner, $ -> true);