fix tag ownership crash on dedicated servers

This commit is contained in:
Relentless 2023-04-19 21:33:33 +02:00
parent 84d5a94630
commit 949182f13e
No known key found for this signature in database
GPG key ID: 50C5FD225130D790
2 changed files with 10 additions and 2 deletions

View file

@ -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<UnifyConfig> getUnifyConfig() {
return Optional.ofNullable(config);
}
public TagOwnerships getTagOwnerships() {
Preconditions.checkNotNull(tagOwnerships, "TagOwnerships were not loaded correctly");
return tagOwnerships;
}
}

View file

@ -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<ResourceLocation> getRefItems(ReplacementMap repMap) {
Set<ResourceLocation> 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);