diff --git a/build.gradle b/build.gradle index f11da66..bab3be9 100644 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,7 @@ //file:noinspection GroovyAssignabilityCheck //file:noinspection GroovyAccessibility plugins { - id "fabric-loom" version "1.6.+" + id "fabric-loom" version "1.7.+" id "io.freefair.lombok" version "8.10" id "maven-publish" } @@ -34,11 +34,12 @@ dependencies { modImplementation("net.fabricmc.fabric-api:fabric-api:${project.fabric_version}") modApi(include(fabricApi.module("fabric-data-generation-api-v1", project.fabric_version))) // include datagen api - modApi(include("io.github.fabricators_of_create.Porting-Lib:tags:${project.porting_lib_version}")) { exclude(group: "io.vram") } - modApi(include("io.github.fabricators_of_create.Porting-Lib:models:${project.porting_lib_version}")) { exclude(group: "io.vram") } - modApi(include("io.github.fabricators_of_create.Porting-Lib:data:${project.porting_lib_version}")) { exclude(group: "io.vram") } - compileOnly("org.projectlombok:lombok:1.18.34") + for (String module in porting_lib_modules.split(",")) { + modApi(include("io.github.fabricators_of_create.Porting-Lib:$module:$porting_lib_version")) { exclude(group: "io.vram") } + } + + compileOnly(annotationProcessor("org.projectlombok:lombok:1.18.34")) implementation(include("com.google.code.findbugs:jsr305:3.0.2")) implementation("javax.annotation:javax.annotation-api:1.3.2") diff --git a/gradle.properties b/gradle.properties index dee0996..a17578a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -8,7 +8,9 @@ mod_version = 1.3. minecraft_version = 1.21.1 loader_version = 0.16.5 fabric_version = 0.104.0+1.21.1 -porting_lib_version = 3.1.0-beta-beta.35+1.21 + +porting_lib_version = 3.1.0-beta.39+1.21.1 +porting_lib_modules = tags,models,data,lazy_registration # Mappings # https://parchmentmc.org/docs/getting-started diff --git a/src/main/java/com/tterrag/registrate/AbstractRegistrate.java b/src/main/java/com/tterrag/registrate/AbstractRegistrate.java index 6fde542..6412890 100644 --- a/src/main/java/com/tterrag/registrate/AbstractRegistrate.java +++ b/src/main/java/com/tterrag/registrate/AbstractRegistrate.java @@ -6,7 +6,6 @@ import com.tterrag.registrate.builders.MenuBuilder.ForgeMenuFactory; import com.tterrag.registrate.builders.MenuBuilder.MenuFactory; import com.tterrag.registrate.builders.MenuBuilder.ScreenFactory; -import com.tterrag.registrate.fabric.DeferredHolder; import com.tterrag.registrate.fabric.RegistryUtil; import com.tterrag.registrate.fabric.SimpleFlowableFluid; import com.tterrag.registrate.providers.ProviderType; @@ -33,6 +32,7 @@ import com.google.common.collect.Multimap; import com.google.common.collect.Table; import com.tterrag.registrate.providers.*; +import io.github.fabricators_of_create.porting_lib.util.DeferredHolder; import net.minecraft.Util; import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.gui.screens.inventory.MenuAccess; diff --git a/src/main/java/com/tterrag/registrate/builders/AbstractBuilder.java b/src/main/java/com/tterrag/registrate/builders/AbstractBuilder.java index b1813d6..c8cee84 100644 --- a/src/main/java/com/tterrag/registrate/builders/AbstractBuilder.java +++ b/src/main/java/com/tterrag/registrate/builders/AbstractBuilder.java @@ -3,7 +3,6 @@ import com.google.common.collect.HashMultimap; import com.google.common.collect.Multimap; import com.tterrag.registrate.AbstractRegistrate; -import com.tterrag.registrate.fabric.DeferredHolder; import com.tterrag.registrate.providers.ProviderType; import com.tterrag.registrate.providers.RegistrateLangProvider; import com.tterrag.registrate.providers.RegistrateTagsProvider; @@ -13,6 +12,7 @@ import com.tterrag.registrate.util.nullness.NonNullFunction; import com.tterrag.registrate.util.nullness.NonNullSupplier; import com.tterrag.registrate.util.nullness.NonnullType; +import io.github.fabricators_of_create.porting_lib.util.DeferredHolder; import lombok.AccessLevel; import lombok.Getter; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/com/tterrag/registrate/builders/BlockBuilder.java b/src/main/java/com/tterrag/registrate/builders/BlockBuilder.java index f2fdb69..6b820d4 100644 --- a/src/main/java/com/tterrag/registrate/builders/BlockBuilder.java +++ b/src/main/java/com/tterrag/registrate/builders/BlockBuilder.java @@ -3,7 +3,6 @@ import com.google.gson.JsonElement; import com.tterrag.registrate.AbstractRegistrate; import com.tterrag.registrate.builders.BlockEntityBuilder.BlockEntityFactory; -import com.tterrag.registrate.fabric.DeferredHolder; import com.tterrag.registrate.fabric.EnvExecutor; import com.tterrag.registrate.providers.*; import com.tterrag.registrate.providers.loot.RegistrateBlockLootTables; @@ -12,6 +11,7 @@ import com.tterrag.registrate.util.entry.RegistryEntry; import com.tterrag.registrate.util.nullness.*; import io.github.fabricators_of_create.porting_lib.models.generators.BlockStateProvider; +import io.github.fabricators_of_create.porting_lib.util.DeferredHolder; import net.fabricmc.api.EnvType; import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap; import net.fabricmc.fabric.api.client.rendering.v1.ColorProviderRegistry; diff --git a/src/main/java/com/tterrag/registrate/builders/BlockEntityBuilder.java b/src/main/java/com/tterrag/registrate/builders/BlockEntityBuilder.java index 759f824..850027b 100644 --- a/src/main/java/com/tterrag/registrate/builders/BlockEntityBuilder.java +++ b/src/main/java/com/tterrag/registrate/builders/BlockEntityBuilder.java @@ -6,13 +6,13 @@ import java.util.function.Function; import com.tterrag.registrate.AbstractRegistrate; -import com.tterrag.registrate.fabric.DeferredHolder; import com.tterrag.registrate.fabric.EnvExecutor; import com.tterrag.registrate.mixin.accessor.BlockEntityRenderersAccessor; import com.tterrag.registrate.util.entry.BlockEntityEntry; import com.tterrag.registrate.util.entry.RegistryEntry; import com.tterrag.registrate.util.nullness.NonNullFunction; import com.tterrag.registrate.util.nullness.NonNullSupplier; +import io.github.fabricators_of_create.porting_lib.util.DeferredHolder; import net.fabricmc.api.EnvType; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/com/tterrag/registrate/builders/Builder.java b/src/main/java/com/tterrag/registrate/builders/Builder.java index 9e53ba2..687264a 100644 --- a/src/main/java/com/tterrag/registrate/builders/Builder.java +++ b/src/main/java/com/tterrag/registrate/builders/Builder.java @@ -205,7 +205,7 @@ default > S2 transform } /** - * Register the entry and return the parent object. The {@link com.tterrag.registrate.fabric.DeferredHolder} will be created but not returned. It can be retrieved later with {@link AbstractRegistrate#get(ResourceKey)} or + * Register the entry and return the parent object. The {@link io.github.fabricators_of_create.porting_lib.util.DeferredHolder} will be created but not returned. It can be retrieved later with {@link AbstractRegistrate#get(ResourceKey)} or * {@link AbstractRegistrate#get(String, ResourceKey)}. * * @return the parent object diff --git a/src/main/java/com/tterrag/registrate/builders/BuilderCallback.java b/src/main/java/com/tterrag/registrate/builders/BuilderCallback.java index 5517fd2..cbba5e9 100644 --- a/src/main/java/com/tterrag/registrate/builders/BuilderCallback.java +++ b/src/main/java/com/tterrag/registrate/builders/BuilderCallback.java @@ -1,11 +1,11 @@ package com.tterrag.registrate.builders; import com.tterrag.registrate.AbstractRegistrate; -import com.tterrag.registrate.fabric.DeferredHolder; import com.tterrag.registrate.util.entry.RegistryEntry; import com.tterrag.registrate.util.nullness.NonNullFunction; import com.tterrag.registrate.util.nullness.NonNullSupplier; +import io.github.fabricators_of_create.porting_lib.util.DeferredHolder; import net.minecraft.core.Registry; import net.minecraft.resources.ResourceKey; diff --git a/src/main/java/com/tterrag/registrate/builders/EntityBuilder.java b/src/main/java/com/tterrag/registrate/builders/EntityBuilder.java index 178ee42..a57b2d6 100644 --- a/src/main/java/com/tterrag/registrate/builders/EntityBuilder.java +++ b/src/main/java/com/tterrag/registrate/builders/EntityBuilder.java @@ -3,7 +3,6 @@ import java.util.function.Supplier; import com.tterrag.registrate.AbstractRegistrate; -import com.tterrag.registrate.fabric.DeferredHolder; import com.tterrag.registrate.fabric.EnvExecutor; import com.tterrag.registrate.mixin.accessor.SpawnPlacementsAccessor; import com.tterrag.registrate.providers.DataGenContext; @@ -18,6 +17,7 @@ import com.tterrag.registrate.util.nullness.NonNullFunction; import com.tterrag.registrate.util.nullness.NonNullSupplier; +import io.github.fabricators_of_create.porting_lib.util.DeferredHolder; import net.minecraft.client.renderer.entity.EntityRenderer; import net.minecraft.client.renderer.entity.EntityRendererProvider; import net.minecraft.core.registries.Registries; diff --git a/src/main/java/com/tterrag/registrate/builders/FluidBuilder.java b/src/main/java/com/tterrag/registrate/builders/FluidBuilder.java index 5976316..8aa6453 100644 --- a/src/main/java/com/tterrag/registrate/builders/FluidBuilder.java +++ b/src/main/java/com/tterrag/registrate/builders/FluidBuilder.java @@ -10,7 +10,6 @@ import com.google.common.annotations.Beta; import com.google.common.base.Preconditions; import com.tterrag.registrate.AbstractRegistrate; -import com.tterrag.registrate.fabric.DeferredHolder; import com.tterrag.registrate.fabric.EnvExecutor; import com.tterrag.registrate.fabric.FluidHelper; import com.tterrag.registrate.fabric.SimpleFlowableFluid; @@ -24,6 +23,7 @@ import com.tterrag.registrate.util.nullness.NonNullFunction; import com.tterrag.registrate.util.nullness.NonNullSupplier; +import io.github.fabricators_of_create.porting_lib.util.DeferredHolder; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap; diff --git a/src/main/java/com/tterrag/registrate/builders/ItemBuilder.java b/src/main/java/com/tterrag/registrate/builders/ItemBuilder.java index 2a5d88c..1ecc41f 100644 --- a/src/main/java/com/tterrag/registrate/builders/ItemBuilder.java +++ b/src/main/java/com/tterrag/registrate/builders/ItemBuilder.java @@ -6,7 +6,6 @@ import com.google.common.collect.Maps; import com.tterrag.registrate.AbstractRegistrate; -import com.tterrag.registrate.fabric.DeferredHolder; import com.tterrag.registrate.fabric.EnvExecutor; import com.tterrag.registrate.providers.*; import com.tterrag.registrate.util.CreativeModeTabModifier; @@ -16,6 +15,7 @@ import com.tterrag.registrate.util.nullness.NonNullFunction; import com.tterrag.registrate.util.nullness.NonNullSupplier; import com.tterrag.registrate.util.nullness.NonNullUnaryOperator; +import io.github.fabricators_of_create.porting_lib.util.DeferredHolder; import net.fabricmc.api.EnvType; import net.fabricmc.fabric.api.client.rendering.v1.ColorProviderRegistry; import net.fabricmc.fabric.api.registry.CompostingChanceRegistry; diff --git a/src/main/java/com/tterrag/registrate/builders/MenuBuilder.java b/src/main/java/com/tterrag/registrate/builders/MenuBuilder.java index d8fe20c..7930b11 100644 --- a/src/main/java/com/tterrag/registrate/builders/MenuBuilder.java +++ b/src/main/java/com/tterrag/registrate/builders/MenuBuilder.java @@ -1,13 +1,13 @@ package com.tterrag.registrate.builders; import com.tterrag.registrate.AbstractRegistrate; -import com.tterrag.registrate.fabric.DeferredHolder; import com.tterrag.registrate.fabric.EnvExecutor; import com.tterrag.registrate.util.entry.MenuEntry; import com.tterrag.registrate.util.entry.RegistryEntry; import com.tterrag.registrate.util.nullness.NonNullSupplier; import com.tterrag.registrate.util.nullness.NonnullType; +import io.github.fabricators_of_create.porting_lib.util.DeferredHolder; import net.fabricmc.fabric.api.screenhandler.v1.ExtendedScreenHandlerType; import net.minecraft.client.gui.screens.MenuScreens; import net.minecraft.client.gui.screens.Screen; diff --git a/src/main/java/com/tterrag/registrate/fabric/DeferredHolder.java b/src/main/java/com/tterrag/registrate/fabric/DeferredHolder.java deleted file mode 100644 index 249e0d4..0000000 --- a/src/main/java/com/tterrag/registrate/fabric/DeferredHolder.java +++ /dev/null @@ -1,288 +0,0 @@ -/* - * Copyright (c) NeoForged and contributors - * SPDX-License-Identifier: LGPL-2.1-only - */ - -package com.tterrag.registrate.fabric; - -import com.mojang.datafixers.util.Either; -import java.util.Locale; -import java.util.Objects; -import java.util.Optional; -import java.util.function.Predicate; -import java.util.function.Supplier; -import java.util.stream.Stream; - -import lombok.Getter; -import net.minecraft.core.Holder; -import net.minecraft.core.HolderOwner; -import net.minecraft.core.Registry; -import net.minecraft.core.registries.BuiltInRegistries; -import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.tags.TagKey; -import org.jetbrains.annotations.Nullable; - -/** - * A Deferred Holder is a {@link Holder} that is constructed with only a ResourceKey. - * - *

It will be populated with the underlying Holder from the registry when available. - * - * @param The type of object being held by this DeferredHolder. - */ -public class DeferredHolder implements Holder, Supplier { - /** - * Creates a new DeferredHolder targeting the value with the specified name in the specified registry. - * - * @param The type of the target value. - * @param The registry type. - * @param registryKey The name of the registry the target value is a member of. - * @param valueName The name of the target value. - */ - public static DeferredHolder create(ResourceKey> registryKey, ResourceLocation valueName) { - return create(ResourceKey.create(registryKey, valueName)); - } - - /** - * Creates a new DeferredHolder targeting the value with the specified name in the specified registry. - * - * @param The registry type. - * @param registryName The name of the registry the target value is a member of. - * @param valueName The name of the target value. - */ - public static DeferredHolder create(ResourceLocation registryName, ResourceLocation valueName) { - return create(ResourceKey.createRegistryKey(registryName), valueName); - } - - /** - * Creates a new DeferredHolder targeting the specified value. - * - * @param The type of the target value. - * @param key The resource key of the target value. - */ - public static DeferredHolder create(ResourceKey key) { - return new DeferredHolder<>(key); - } - - /** - * The resource key of the target object. - * -- GETTER -- - * - * @return The ResourceKey of the object pointed to by this DeferredHolder. - - */ - @Getter - protected final ResourceKey key; - - /** - * The currently cached value. - */ - @Nullable - private Holder holder = null; - - /** - * Creates a new DeferredHolder with a ResourceKey. - * - *

Attempts to bind immediately if possible. - * - * @param key The resource key of the target object. - * @see #create(ResourceKey, ResourceLocation) - * @see #create(ResourceLocation, ResourceLocation) - * @see #create(ResourceKey) - */ - protected DeferredHolder(ResourceKey key) { - this.key = Objects.requireNonNull(key); - this.bind(false); - } - - /** - * Gets the object stored by this DeferredHolder, if this holder {@linkplain #isBound() is bound}. - * - * @throws IllegalStateException If the backing registry is unavailable. - * @throws NullPointerException If the underlying Holder has not been populated (the target object is not registered). - */ - @SuppressWarnings("unchecked") - @Override - public T value() { - bind(true); - if (this.holder == null) { - throw new NullPointerException("Trying to access unbound value: " + this.key); - } - - return (T) this.holder.value(); - } - - /** - * Gets the object stored by this DeferredHolder, if this holder {@linkplain #isBound() is bound}. - * - * @throws IllegalStateException If the backing registry is unavailable. - * @throws NullPointerException If the underlying Holder has not been populated (the target object is not registered). - */ - @Override - public T get() { - return this.value(); - } - - /** - * Returns an optional containing the target object, if {@link #isBound() bound}; otherwise {@linkplain Optional#empty() an empty optional}. - * - * @return an optional containing the target object, if {@link #isBound() bound}; otherwise {@linkplain Optional#empty() an empty optional} - */ - public Optional asOptional() { - return isBound() ? Optional.of(value()) : Optional.empty(); - } - - /** - * Returns the registry that this DeferredHolder is pointing at, or {@code null} if it doesn't exist. - * - * @return the registry that this DeferredHolder is pointing at, or {@code null} if it doesn't exist - */ - @Nullable - @SuppressWarnings("unchecked") - protected Registry getRegistry() { - return (Registry) BuiltInRegistries.REGISTRY.get(this.key.registry()); - } - - /** - * Binds this DeferredHolder to the underlying registry and target object. - * - *

Has no effect if already bound. - * - * @param throwOnMissingRegistry If true, an exception will be thrown if the registry is absent. - * @throws IllegalStateException If throwOnMissingRegistry is true and the backing registry is unavailable. - */ - protected final void bind(boolean throwOnMissingRegistry) { - if (this.holder != null) return; - - Registry registry = getRegistry(); - if (registry != null) { - this.holder = registry.getHolder(this.key).orElse(null); - } else if (throwOnMissingRegistry) { - throw new IllegalStateException("Registry not present for " + this + ": " + this.key.registry()); - } - } - - /** - * @return The ID of the object pointed to by this DeferredHolder. - */ - public ResourceLocation getId() { - return this.key.location(); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - return obj instanceof Holder h && h.kind() == Kind.REFERENCE && (h.unwrapKey().isPresent() && h.unwrapKey().get() == this.key); - } - - @Override - public int hashCode() { - return this.key.hashCode(); - } - - @Override - public String toString() { - return String.format(Locale.ENGLISH, "DeferredHolder{%s}", this.key); - } - - /** - * {@return true if the underlying object is available} - * - *

If {@code true}, the underlying object was added to the registry, - * and {@link #value()} or {@link #get()} can be called. - */ - @Override - public boolean isBound() { - bind(false); - return this.holder != null && this.holder.isBound(); - } - - /** - * {@return true if the passed ResourceLocation is the same as the ID of the target object} - */ - @Override - public boolean is(ResourceLocation id) { - return id.equals(this.key.location()); - } - - /** - * {@return true if the passed ResourceKey is the same as this holder's resource key} - */ - @Override - public boolean is(ResourceKey key) { - return key == this.key; - } - - /** - * Evaluates the passed predicate against this holder's resource key. - * - * @return {@code true} if the filter matches {@linkplain #getKey() this DH's resource key} - */ - @Override - public boolean is(Predicate> filter) { - return filter.test(this.key); - } - - /** - * {@return true if this holder is a member of the passed tag} - */ - @Override - public boolean is(TagKey tag) { - bind(false); - return this.holder != null && this.holder.is(tag); - } - - /** - * {@return {@code true} if the {@code holder} is the same as this holder} - */ - @Override - @Deprecated - public boolean is(Holder holder) { - bind(false); - return this.holder != null && this.holder.is(holder); - } - - /** - * {@return all tags present on the underlying object} - * - *

If the underlying object is not {@linkplain #isBound() bound} yet, and empty stream is returned. - */ - @Override - public Stream> tags() { - bind(false); - return this.holder != null ? this.holder.tags() : Stream.empty(); - } - - /** - * Returns an {@link Either#left()} containing {@linkplain #getKey() the resource key of this holder}. - * - * @apiNote This method is implemented for {@link Holder} compatibility, but {@link #getKey()} should be preferred. - */ - @Override - public Either, R> unwrap() { - // Holder.Reference always returns the key, do the same here. - return Either.left(this.key); - } - - /** - * Returns the resource key of this holder. - * - * @return a present optional containing {@linkplain #getKey() the resource key of this holder} - * @apiNote This method is implemented for {@link Holder} compatibility, but {@link #getKey()} should be preferred. - */ - @Override - public Optional> unwrapKey() { - return Optional.of(this.key); - } - - @Override - public Kind kind() { - return Kind.REFERENCE; - } - - @Override - public boolean canSerializeIn(HolderOwner owner) { - bind(false); - return this.holder != null && this.holder.canSerializeIn(owner); - } -} \ No newline at end of file diff --git a/src/main/java/com/tterrag/registrate/fabric/NonNullTriFunction.java b/src/main/java/com/tterrag/registrate/fabric/NonNullTriFunction.java deleted file mode 100644 index 53cb208..0000000 --- a/src/main/java/com/tterrag/registrate/fabric/NonNullTriFunction.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.tterrag.registrate.fabric; - -import com.tterrag.registrate.util.nullness.NonnullType; - -@FunctionalInterface -public interface NonNullTriFunction<@NonnullType T, @NonnullType U, @NonnullType P, @NonnullType R> extends TriFunction { - - @Override - R apply(T t, U u, P p); -} \ No newline at end of file diff --git a/src/main/java/com/tterrag/registrate/fabric/TriFunction.java b/src/main/java/com/tterrag/registrate/fabric/TriFunction.java deleted file mode 100644 index d33b2e5..0000000 --- a/src/main/java/com/tterrag/registrate/fabric/TriFunction.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.tterrag.registrate.fabric; - -import java.util.Objects; -import java.util.function.Function; - -@FunctionalInterface -public interface TriFunction { - - /** - * Applies this function to the given arguments. - * - * @param t the first function argument - * @param u the second function argument - * @return the function result - */ - R apply(T t, U u, P p); - - /** - * Returns a composed function that first applies this function to - * its input, and then applies the {@code after} function to the result. - * If evaluation of either function throws an exception, it is relayed to - * the caller of the composed function. - * - * @param the type of output of the {@code after} function, and of the - * composed function - * @param after the function to apply after this function is applied - * @return a composed function that first applies this function and then - * applies the {@code after} function - * @throws NullPointerException if after is null - */ - default TriFunction andThen(Function after) { - Objects.requireNonNull(after); - return (T t, U u, P p) -> after.apply(apply(t, u, p)); - } -} diff --git a/src/main/java/com/tterrag/registrate/mixin/LootTableProviderMixin.java b/src/main/java/com/tterrag/registrate/mixin/LootTableProviderMixin.java index e1135a9..3daaa19 100644 --- a/src/main/java/com/tterrag/registrate/mixin/LootTableProviderMixin.java +++ b/src/main/java/com/tterrag/registrate/mixin/LootTableProviderMixin.java @@ -2,12 +2,12 @@ import java.util.Collections; import java.util.Iterator; -import java.util.List; import java.util.Map; -import java.util.function.BiConsumer; +import java.util.function.Consumer; +import java.util.stream.Stream; import com.llamalad7.mixinextras.injector.ModifyExpressionValue; -import com.llamalad7.mixinextras.injector.WrapWithCondition; +import com.llamalad7.mixinextras.injector.v2.WrapWithCondition; import com.llamalad7.mixinextras.sugar.Local; import com.tterrag.registrate.fabric.CustomValidationLootProvider; import org.spongepowered.asm.mixin.Mixin; @@ -21,7 +21,7 @@ @Mixin(LootTableProvider.class) public class LootTableProviderMixin { @ModifyExpressionValue( - method = "run", + method = "run(Lnet/minecraft/data/CachedOutput;Lnet/minecraft/core/HolderLookup$Provider;)Ljava/util/concurrent/CompletableFuture;", at = @At( value = "INVOKE", target = "Ljava/util/Set;iterator()Ljava/util/Iterator;" // Sets.difference @@ -38,13 +38,13 @@ private Iterator runCustomValidation(Iterator tables, BiConsumer consumer) { + private boolean preventOtherValidation(Stream instance, Consumer consumer) { return !(this instanceof CustomValidationLootProvider); } } diff --git a/src/main/java/com/tterrag/registrate/providers/loot/RegistrateLootTableProvider.java b/src/main/java/com/tterrag/registrate/providers/loot/RegistrateLootTableProvider.java index fe4843e..797d991 100644 --- a/src/main/java/com/tterrag/registrate/providers/loot/RegistrateLootTableProvider.java +++ b/src/main/java/com/tterrag/registrate/providers/loot/RegistrateLootTableProvider.java @@ -2,34 +2,24 @@ import com.google.common.collect.*; import com.mojang.datafixers.util.Function4; -import com.mojang.datafixers.util.Function5; import com.tterrag.registrate.AbstractRegistrate; import com.tterrag.registrate.fabric.CustomValidationLootProvider; -import com.tterrag.registrate.fabric.NonNullTriFunction; -import com.tterrag.registrate.fabric.TriFunction; import com.tterrag.registrate.mixin.accessor.LootContextParamSetsAccessor; import com.tterrag.registrate.mixin.accessor.LootTableProviderAccessor; import com.tterrag.registrate.providers.ProviderType; import com.tterrag.registrate.providers.RegistrateProvider; import com.tterrag.registrate.util.nullness.NonNullConsumer; import net.fabricmc.api.EnvType; -import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator; import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; import net.minecraft.data.PackOutput; -import org.jetbrains.annotations.NotNull; -import lombok.Getter; import net.minecraft.core.Holder; import net.minecraft.core.HolderLookup; -import net.minecraft.core.WritableRegistry; -import net.minecraft.data.CachedOutput; -import net.minecraft.data.CachedOutput; import net.minecraft.data.loot.LootTableProvider; import net.minecraft.data.loot.LootTableSubProvider; import net.minecraft.data.loot.packs.VanillaLootTableProvider; import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; -import net.minecraft.util.ProblemReporter; import net.minecraft.world.level.storage.loot.LootTable; import net.minecraft.world.level.storage.loot.ValidationContext; import net.minecraft.world.level.storage.loot.parameters.LootContextParamSet; @@ -39,7 +29,6 @@ import java.util.concurrent.CompletableFuture; import java.util.function.BiConsumer; import java.util.function.Consumer; -import java.util.function.Supplier; public class RegistrateLootTableProvider extends LootTableProvider implements RegistrateProvider, CustomValidationLootProvider { diff --git a/src/main/java/com/tterrag/registrate/util/entry/BlockEntityEntry.java b/src/main/java/com/tterrag/registrate/util/entry/BlockEntityEntry.java index c5ff3db..78d92c6 100644 --- a/src/main/java/com/tterrag/registrate/util/entry/BlockEntityEntry.java +++ b/src/main/java/com/tterrag/registrate/util/entry/BlockEntityEntry.java @@ -4,7 +4,7 @@ import com.tterrag.registrate.AbstractRegistrate; -import com.tterrag.registrate.fabric.DeferredHolder; +import io.github.fabricators_of_create.porting_lib.util.DeferredHolder; import net.minecraft.core.BlockPos; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.block.entity.BlockEntity; diff --git a/src/main/java/com/tterrag/registrate/util/entry/BlockEntry.java b/src/main/java/com/tterrag/registrate/util/entry/BlockEntry.java index 6722439..71044c6 100644 --- a/src/main/java/com/tterrag/registrate/util/entry/BlockEntry.java +++ b/src/main/java/com/tterrag/registrate/util/entry/BlockEntry.java @@ -2,7 +2,7 @@ import com.tterrag.registrate.AbstractRegistrate; -import com.tterrag.registrate.fabric.DeferredHolder; +import io.github.fabricators_of_create.porting_lib.util.DeferredHolder; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.BlockState; diff --git a/src/main/java/com/tterrag/registrate/util/entry/EntityEntry.java b/src/main/java/com/tterrag/registrate/util/entry/EntityEntry.java index eaf3181..470134c 100644 --- a/src/main/java/com/tterrag/registrate/util/entry/EntityEntry.java +++ b/src/main/java/com/tterrag/registrate/util/entry/EntityEntry.java @@ -1,7 +1,7 @@ package com.tterrag.registrate.util.entry; import com.tterrag.registrate.AbstractRegistrate; -import com.tterrag.registrate.fabric.DeferredHolder; +import io.github.fabricators_of_create.porting_lib.util.DeferredHolder; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; import net.minecraft.world.level.Level; diff --git a/src/main/java/com/tterrag/registrate/util/entry/FluidEntry.java b/src/main/java/com/tterrag/registrate/util/entry/FluidEntry.java index da1270b..098d61b 100644 --- a/src/main/java/com/tterrag/registrate/util/entry/FluidEntry.java +++ b/src/main/java/com/tterrag/registrate/util/entry/FluidEntry.java @@ -4,7 +4,7 @@ import java.util.function.Predicate; import com.tterrag.registrate.AbstractRegistrate; -import com.tterrag.registrate.fabric.DeferredHolder; +import io.github.fabricators_of_create.porting_lib.util.DeferredHolder; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.world.item.Item; import net.minecraft.world.level.block.Block; diff --git a/src/main/java/com/tterrag/registrate/util/entry/ItemEntry.java b/src/main/java/com/tterrag/registrate/util/entry/ItemEntry.java index cc3a363..6b22f74 100644 --- a/src/main/java/com/tterrag/registrate/util/entry/ItemEntry.java +++ b/src/main/java/com/tterrag/registrate/util/entry/ItemEntry.java @@ -2,7 +2,7 @@ import com.tterrag.registrate.AbstractRegistrate; -import com.tterrag.registrate.fabric.DeferredHolder; +import io.github.fabricators_of_create.porting_lib.util.DeferredHolder; import net.minecraft.world.item.Item; public class ItemEntry extends ItemProviderEntry { diff --git a/src/main/java/com/tterrag/registrate/util/entry/ItemProviderEntry.java b/src/main/java/com/tterrag/registrate/util/entry/ItemProviderEntry.java index f52e36c..18cfe8c 100644 --- a/src/main/java/com/tterrag/registrate/util/entry/ItemProviderEntry.java +++ b/src/main/java/com/tterrag/registrate/util/entry/ItemProviderEntry.java @@ -1,8 +1,8 @@ package com.tterrag.registrate.util.entry; import com.tterrag.registrate.AbstractRegistrate; -import com.tterrag.registrate.fabric.DeferredHolder; +import io.github.fabricators_of_create.porting_lib.util.DeferredHolder; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.ItemLike; diff --git a/src/main/java/com/tterrag/registrate/util/entry/MenuEntry.java b/src/main/java/com/tterrag/registrate/util/entry/MenuEntry.java index db1bc70..822741e 100644 --- a/src/main/java/com/tterrag/registrate/util/entry/MenuEntry.java +++ b/src/main/java/com/tterrag/registrate/util/entry/MenuEntry.java @@ -4,9 +4,7 @@ import com.tterrag.registrate.AbstractRegistrate; -import com.tterrag.registrate.fabric.DeferredHolder; -import net.minecraft.network.FriendlyByteBuf; -import net.minecraft.network.RegistryFriendlyByteBuf; +import io.github.fabricators_of_create.porting_lib.util.DeferredHolder; import net.minecraft.network.chat.Component; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.SimpleMenuProvider; diff --git a/src/main/java/com/tterrag/registrate/util/entry/RegistryEntry.java b/src/main/java/com/tterrag/registrate/util/entry/RegistryEntry.java index 73e375a..906caf6 100644 --- a/src/main/java/com/tterrag/registrate/util/entry/RegistryEntry.java +++ b/src/main/java/com/tterrag/registrate/util/entry/RegistryEntry.java @@ -5,13 +5,11 @@ import java.util.function.Predicate; import com.tterrag.registrate.AbstractRegistrate; -import com.tterrag.registrate.fabric.DeferredHolder; import com.tterrag.registrate.util.nullness.NonNullSupplier; -import lombok.experimental.Delegate; +import io.github.fabricators_of_create.porting_lib.util.DeferredHolder; import net.minecraft.core.Registry; import net.minecraft.resources.ResourceKey; -import org.jetbrains.annotations.Nullable; /** * Wraps a {@link DeferredHolder}, providing a cleaner API with null-safe access, and registrate-specific extensions such as {@link #getSibling(ResourceKey)}.