Skip to content

Commit

Permalink
Merge pull request #882 from pietro-lopes/deferred-wrapper
Browse files Browse the repository at this point in the history
added deferred holder
  • Loading branch information
LatvianModder authored Aug 15, 2024
2 parents 99656c1 + 6dae927 commit 4c0bda3
Showing 1 changed file with 2 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.TagKey;
import net.neoforged.neoforge.registries.DeferredHolder;
import org.jetbrains.annotations.Nullable;

import java.util.List;
Expand Down Expand Up @@ -46,11 +47,7 @@ static Holder<?> wrap(KubeJSContext cx, Object from, TypeInfo param) {

var holder = registry.getHolder(id);

if (holder.isEmpty()) {
throw Context.reportRuntimeError("Can't interpret '" + from + "' as Holder: entry not found", cx);
}

return holder.get();
return holder.isEmpty() ? DeferredHolder.create(registry.key(), id) : holder.get();
}

static HolderSet<?> wrapSet(KubeJSContext cx, Object from, TypeInfo param) {
Expand Down

0 comments on commit 4c0bda3

Please sign in to comment.