mirror of
https://github.com/FabricMC/fabric.git
synced 2024-11-24 16:48:02 -05:00
Even more fixes
This commit is contained in:
parent
ca04f2463c
commit
4c89a6c135
20 changed files with 90 additions and 56 deletions
|
@ -19,6 +19,9 @@ package net.fabricmc.fabric.api.resource.conditions.v1;
|
|||
import java.util.List;
|
||||
|
||||
import com.mojang.serialization.Codec;
|
||||
|
||||
import net.minecraft.registry.RegistryOps;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import net.minecraft.registry.RegistryWrapper;
|
||||
|
@ -56,8 +59,8 @@ public interface ResourceCondition {
|
|||
* (such as recipes or advancements). However, it may be {@code null} in client-side
|
||||
* resources, or for non-vanilla resource types.
|
||||
*
|
||||
* @param registryLookup the registry lookup, or {@code null} in case registry is unavailable
|
||||
* @param registryInfo the registry lookup, or {@code null} in case registry is unavailable
|
||||
* @return whether the condition was successful
|
||||
*/
|
||||
boolean test(@Nullable RegistryWrapper.WrapperLookup registryLookup);
|
||||
boolean test(@Nullable RegistryOps.RegistryInfoGetter registryInfo);
|
||||
}
|
||||
|
|
|
@ -27,6 +27,11 @@ import java.util.stream.Collectors;
|
|||
import com.google.gson.JsonObject;
|
||||
import com.mojang.serialization.DataResult;
|
||||
import com.mojang.serialization.JsonOps;
|
||||
|
||||
import net.minecraft.registry.RegistryEntryLookup;
|
||||
import net.minecraft.registry.RegistryOps;
|
||||
import net.minecraft.registry.entry.RegistryEntryInfo;
|
||||
|
||||
import org.apache.commons.lang3.mutable.MutableBoolean;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -62,14 +67,14 @@ public final class ResourceConditionsImpl implements ModInitializer {
|
|||
ResourceConditions.register(DefaultResourceConditionTypes.REGISTRY_CONTAINS);
|
||||
}
|
||||
|
||||
public static boolean applyResourceConditions(JsonObject obj, String dataType, Identifier key, @Nullable RegistryWrapper.WrapperLookup registryLookup) {
|
||||
public static boolean applyResourceConditions(JsonObject obj, String dataType, Identifier key, @Nullable RegistryOps.RegistryInfoGetter registryInfo) {
|
||||
boolean debugLogEnabled = ResourceConditionsImpl.LOGGER.isDebugEnabled();
|
||||
|
||||
if (obj.has(ResourceConditions.CONDITIONS_KEY)) {
|
||||
DataResult<ResourceCondition> conditions = ResourceCondition.CONDITION_CODEC.parse(JsonOps.INSTANCE, obj.get(ResourceConditions.CONDITIONS_KEY));
|
||||
|
||||
if (conditions.isSuccess()) {
|
||||
boolean matched = conditions.getOrThrow().test(registryLookup);
|
||||
boolean matched = conditions.getOrThrow().test(registryInfo);
|
||||
|
||||
if (debugLogEnabled) {
|
||||
String verdict = matched ? "Allowed" : "Rejected";
|
||||
|
@ -87,9 +92,9 @@ public final class ResourceConditionsImpl implements ModInitializer {
|
|||
|
||||
// Condition implementations
|
||||
|
||||
public static boolean conditionsMet(List<ResourceCondition> conditions, @Nullable RegistryWrapper.WrapperLookup registryLookup, boolean and) {
|
||||
public static boolean conditionsMet(List<ResourceCondition> conditions, @Nullable RegistryOps.RegistryInfoGetter registryInfo, boolean and) {
|
||||
for (ResourceCondition condition : conditions) {
|
||||
if (condition.test(registryLookup) != and) {
|
||||
if (condition.test(registryInfo) != and) {
|
||||
return !and;
|
||||
}
|
||||
}
|
||||
|
@ -164,19 +169,19 @@ public final class ResourceConditionsImpl implements ModInitializer {
|
|||
return set.isSubsetOf(currentFeatures);
|
||||
}
|
||||
|
||||
public static boolean registryContains(@Nullable RegistryWrapper.WrapperLookup registryLookup, Identifier registryId, List<Identifier> entries) {
|
||||
public static boolean registryContains(@Nullable RegistryOps.RegistryInfoGetter registryInfo, Identifier registryId, List<Identifier> entries) {
|
||||
RegistryKey<? extends Registry<Object>> registryKey = RegistryKey.ofRegistry(registryId);
|
||||
|
||||
if (registryLookup == null) {
|
||||
if (registryInfo == null) {
|
||||
LOGGER.warn("Can't retrieve registry {}, failing registry_contains resource condition check", registryId);
|
||||
return false;
|
||||
}
|
||||
|
||||
Optional<RegistryWrapper.Impl<Object>> wrapper = registryLookup.getOptionalWrapper(registryKey);
|
||||
Optional<RegistryOps.RegistryInfo<Object>> wrapper = registryInfo.getRegistryInfo(registryKey);
|
||||
|
||||
if (wrapper.isPresent()) {
|
||||
for (Identifier id : entries) {
|
||||
if (wrapper.get().getOptional(RegistryKey.of(registryKey, id)).isEmpty()) {
|
||||
if (wrapper.get().entryLookup().getOptional(RegistryKey.of(registryKey, id)).isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,6 +21,9 @@ import java.util.List;
|
|||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.MapCodec;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
|
||||
import net.minecraft.registry.RegistryOps;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import net.minecraft.registry.RegistryWrapper;
|
||||
|
@ -41,7 +44,7 @@ public record AllModsLoadedResourceCondition(List<String> modIds) implements Res
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean test(@Nullable RegistryWrapper.WrapperLookup registryLookup) {
|
||||
public boolean test(@Nullable RegistryOps.RegistryInfoGetter registryInfo) {
|
||||
return ResourceConditionsImpl.modsLoaded(this.modIds(), true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,9 @@ import java.util.List;
|
|||
|
||||
import com.mojang.serialization.MapCodec;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
|
||||
import net.minecraft.registry.RegistryOps;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import net.minecraft.registry.RegistryWrapper;
|
||||
|
@ -40,7 +43,7 @@ public record AndResourceCondition(List<ResourceCondition> conditions) implement
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean test(@Nullable RegistryWrapper.WrapperLookup registryLookup) {
|
||||
return ResourceConditionsImpl.conditionsMet(this.conditions(), registryLookup, true);
|
||||
public boolean test(@Nullable RegistryOps.RegistryInfoGetter registryInfo) {
|
||||
return ResourceConditionsImpl.conditionsMet(this.conditions(), registryInfo, true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,6 +21,9 @@ import java.util.List;
|
|||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.MapCodec;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
|
||||
import net.minecraft.registry.RegistryOps;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import net.minecraft.registry.RegistryWrapper;
|
||||
|
@ -41,7 +44,7 @@ public record AnyModsLoadedResourceCondition(List<String> modIds) implements Res
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean test(@Nullable RegistryWrapper.WrapperLookup registryLookup) {
|
||||
public boolean test(@Nullable RegistryOps.RegistryInfoGetter registryInfo) {
|
||||
return ResourceConditionsImpl.modsLoaded(this.modIds(), false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,6 +21,9 @@ import java.util.List;
|
|||
|
||||
import com.mojang.serialization.MapCodec;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
|
||||
import net.minecraft.registry.RegistryOps;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import net.minecraft.registry.RegistryWrapper;
|
||||
|
@ -52,7 +55,7 @@ public record FeaturesEnabledResourceCondition(Collection<Identifier> features)
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean test(@Nullable RegistryWrapper.WrapperLookup registryLookup) {
|
||||
public boolean test(@Nullable RegistryOps.RegistryInfoGetter registryInfo) {
|
||||
return ResourceConditionsImpl.featuresEnabled(this.features());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,9 @@ package net.fabricmc.fabric.impl.resource.conditions.conditions;
|
|||
|
||||
import com.mojang.serialization.MapCodec;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
|
||||
import net.minecraft.registry.RegistryOps;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import net.minecraft.registry.RegistryWrapper;
|
||||
|
@ -37,7 +40,7 @@ public record NotResourceCondition(ResourceCondition condition) implements Resou
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean test(@Nullable RegistryWrapper.WrapperLookup registryLookup) {
|
||||
return !this.condition().test(registryLookup);
|
||||
public boolean test(@Nullable RegistryOps.RegistryInfoGetter registryInfo) {
|
||||
return !this.condition().test(registryInfo);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,9 @@ import java.util.List;
|
|||
|
||||
import com.mojang.serialization.MapCodec;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
|
||||
import net.minecraft.registry.RegistryOps;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import net.minecraft.registry.RegistryWrapper;
|
||||
|
@ -40,7 +43,7 @@ public record OrResourceCondition(List<ResourceCondition> conditions) implements
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean test(@Nullable RegistryWrapper.WrapperLookup registryLookup) {
|
||||
return ResourceConditionsImpl.conditionsMet(this.conditions(), registryLookup, false);
|
||||
public boolean test(@Nullable RegistryOps.RegistryInfoGetter registryInfo) {
|
||||
return ResourceConditionsImpl.conditionsMet(this.conditions(), registryInfo, false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,6 +21,9 @@ import java.util.List;
|
|||
|
||||
import com.mojang.serialization.MapCodec;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
|
||||
import net.minecraft.registry.RegistryOps;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
|
@ -56,7 +59,7 @@ public record RegistryContainsResourceCondition(Identifier registry, List<Identi
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean test(@Nullable RegistryWrapper.WrapperLookup registryLookup) {
|
||||
return ResourceConditionsImpl.registryContains(registryLookup, this.registry(), this.entries());
|
||||
public boolean test(@Nullable RegistryOps.RegistryInfoGetter registryInfo) {
|
||||
return ResourceConditionsImpl.registryContains(registryInfo, this.registry(), this.entries());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,6 +21,9 @@ import java.util.List;
|
|||
|
||||
import com.mojang.serialization.MapCodec;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
|
||||
import net.minecraft.registry.RegistryOps;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
|
@ -57,7 +60,7 @@ public record TagsPopulatedResourceCondition(Identifier registry, List<Identifie
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean test(@Nullable RegistryWrapper.WrapperLookup registryLookup) {
|
||||
public boolean test(@Nullable RegistryOps.RegistryInfoGetter registryInfo) {
|
||||
return ResourceConditionsImpl.tagsPopulated(this.registry(), this.tags());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,6 +17,9 @@
|
|||
package net.fabricmc.fabric.impl.resource.conditions.conditions;
|
||||
|
||||
import com.mojang.serialization.MapCodec;
|
||||
|
||||
import net.minecraft.registry.RegistryOps;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import net.minecraft.registry.RegistryWrapper;
|
||||
|
@ -34,7 +37,7 @@ public class TrueResourceCondition implements ResourceCondition {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean test(@Nullable RegistryWrapper.WrapperLookup registryLookup) {
|
||||
public boolean test(@Nullable RegistryOps.RegistryInfoGetter registryInfo) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,6 +21,9 @@ import java.util.Map;
|
|||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import net.minecraft.registry.RegistryOps;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
@ -45,7 +48,7 @@ public class JsonDataLoaderMixin extends SinglePreparationResourceReloaderMixin
|
|||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
protected void fabric_applyResourceConditions(ResourceManager resourceManager, Profiler profiler, Object object, @Nullable RegistryWrapper.WrapperLookup registryLookup) {
|
||||
protected void fabric_applyResourceConditions(ResourceManager resourceManager, Profiler profiler, Object object, @Nullable RegistryOps.RegistryInfoGetter registryInfo) {
|
||||
profiler.push("Fabric resource conditions: %s".formatted(dataType));
|
||||
|
||||
Iterator<Map.Entry<Identifier, JsonElement>> it = ((Map<Identifier, JsonElement>) object).entrySet().iterator();
|
||||
|
|
|
@ -22,6 +22,7 @@ import org.spongepowered.asm.mixin.Mixin;
|
|||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
import net.minecraft.recipe.RecipeManager;
|
||||
import net.minecraft.registry.RegistryOps;
|
||||
import net.minecraft.registry.RegistryWrapper;
|
||||
|
||||
@Mixin(RecipeManager.class)
|
||||
|
@ -31,7 +32,7 @@ public class RecipeManagerMixin extends SinglePreparationResourceReloaderMixin {
|
|||
private RegistryWrapper.WrapperLookup registryLookup;
|
||||
|
||||
@Override
|
||||
protected @Nullable RegistryWrapper.WrapperLookup fabric_getRegistryLookup() {
|
||||
return this.registryLookup;
|
||||
protected @Nullable RegistryOps.RegistryInfoGetter fabric_getRegistryLookup() {
|
||||
return new RegistryOps.CachedRegistryInfoGetter(registryLookup);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ package net.fabricmc.fabric.mixin.resource.conditions;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.llamalad7.mixinextras.sugar.Local;
|
||||
|
@ -28,14 +28,11 @@ import org.spongepowered.asm.mixin.Unique;
|
|||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import net.minecraft.registry.DynamicRegistryManager;
|
||||
import net.minecraft.registry.MutableRegistry;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.registry.RegistryLoader;
|
||||
import net.minecraft.registry.RegistryOps;
|
||||
import net.minecraft.registry.RegistryWrapper;
|
||||
import net.minecraft.registry.entry.RegistryEntryInfo;
|
||||
import net.minecraft.resource.Resource;
|
||||
import net.minecraft.resource.ResourceManager;
|
||||
|
@ -45,26 +42,20 @@ import net.fabricmc.fabric.impl.resource.conditions.ResourceConditionsImpl;
|
|||
@Mixin(RegistryLoader.class)
|
||||
public class RegistryLoaderMixin {
|
||||
@Unique
|
||||
private static final ThreadLocal<DynamicRegistryManager> REGISTRIES = new ThreadLocal<>();
|
||||
private static final ThreadLocal<RegistryOps.RegistryInfoGetter> REGISTRY_INFO = new ThreadLocal<>();
|
||||
|
||||
/**
|
||||
* Capture the current registries, so they can be passed to the resource conditions.
|
||||
*/
|
||||
@Inject(method = "loadFromResource(Lnet/minecraft/resource/ResourceManager;Ljava/util/List;Ljava/util/List;)Lnet/minecraft/registry/DynamicRegistryManager$Immutable;", at = @At("RETURN"))
|
||||
private static void captureRegistries(ResourceManager resourceManager, List<RegistryWrapper.Impl<?>> registries, List<RegistryLoader.Entry<?>> entries, CallbackInfoReturnable<DynamicRegistryManager.Immutable> cir) {
|
||||
REGISTRIES.set(cir.getReturnValue());
|
||||
@Inject(method = "loadFromResource(Lnet/minecraft/resource/ResourceManager;Lnet/minecraft/registry/RegistryOps$RegistryInfoGetter;Lnet/minecraft/registry/MutableRegistry;Lcom/mojang/serialization/Decoder;Ljava/util/Map;)V", at = @At("HEAD"))
|
||||
private static <E> void captureRegistries(ResourceManager resourceManager, RegistryOps.RegistryInfoGetter infoGetter, MutableRegistry<E> registry, Decoder<E> elementDecoder, Map<RegistryKey<?>, Exception> errors, CallbackInfo ci) {
|
||||
REGISTRY_INFO.set(infoGetter);
|
||||
}
|
||||
|
||||
// TODO 24w33a - Double Check if replacement above will work - it doesnt
|
||||
/*@WrapOperation(method = "loadFromResource(Lnet/minecraft/resource/ResourceManager;Lnet/minecraft/registry/DynamicRegistryManager;Ljava/util/List;)Lnet/minecraft/registry/DynamicRegistryManager$Immutable;", at = @At(value = "INVOKE", target = "Lnet/minecraft/registry/RegistryLoader;load(Lnet/minecraft/registry/RegistryLoader$RegistryLoadable;Lnet/minecraft/registry/DynamicRegistryManager;Ljava/util/List;)Lnet/minecraft/registry/DynamicRegistryManager$Immutable;"))
|
||||
private static DynamicRegistryManager.Immutable captureRegistries(@Coerce Object registryLoadable, DynamicRegistryManager baseRegistryManager, List<RegistryLoader.Entry<?>> entries, Operation<DynamicRegistryManager.Immutable> original) {
|
||||
try {
|
||||
REGISTRIES.set(baseRegistryManager);
|
||||
return original.call(registryLoadable, baseRegistryManager, entries);
|
||||
} finally {
|
||||
REGISTRIES.remove();
|
||||
@Inject(method = "loadFromResource(Lnet/minecraft/resource/ResourceManager;Lnet/minecraft/registry/RegistryOps$RegistryInfoGetter;Lnet/minecraft/registry/MutableRegistry;Lcom/mojang/serialization/Decoder;Ljava/util/Map;)V", at = @At("RETURN"))
|
||||
private static <E> void releaseRegistries(ResourceManager resourceManager, RegistryOps.RegistryInfoGetter infoGetter, MutableRegistry<E> registry, Decoder<E> elementDecoder, Map<RegistryKey<?>, Exception> errors, CallbackInfo ci) {
|
||||
REGISTRY_INFO.remove();
|
||||
}
|
||||
}*/
|
||||
|
||||
@Inject(
|
||||
method = "Lnet/minecraft/registry/RegistryLoader;parseAndAdd(Lnet/minecraft/registry/MutableRegistry;Lcom/mojang/serialization/Decoder;Lnet/minecraft/registry/RegistryOps;Lnet/minecraft/registry/RegistryKey;Lnet/minecraft/resource/Resource;Lnet/minecraft/registry/entry/RegistryEntryInfo;)V",
|
||||
|
@ -77,10 +68,10 @@ public class RegistryLoaderMixin {
|
|||
) throws IOException {
|
||||
// This method is called both on the server (when loading resources) and on the client (when syncing from the
|
||||
// server). We only want to apply resource conditions when loading via loadFromResource.
|
||||
DynamicRegistryManager registries = REGISTRIES.get();
|
||||
if (registries == null) return;
|
||||
RegistryOps.RegistryInfoGetter registryInfoGetter = REGISTRY_INFO.get();
|
||||
if (registryInfoGetter == null) return;
|
||||
|
||||
if (jsonElement.isJsonObject() && !ResourceConditionsImpl.applyResourceConditions(jsonElement.getAsJsonObject(), key.getRegistry().toString(), key.getValue(), registries)) {
|
||||
if (jsonElement.isJsonObject() && !ResourceConditionsImpl.applyResourceConditions(jsonElement.getAsJsonObject(), key.getRegistry().toString(), key.getValue(), registryInfoGetter)) {
|
||||
reader.close();
|
||||
ci.cancel();
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ public class ReloadableRegistriesMixin {
|
|||
|
||||
@Inject(method = "method_61239", at = @At("HEAD"), cancellable = true)
|
||||
private static void applyConditions(LootDataType lootDataType, RegistryOps ops, MutableRegistry mutableRegistry, Identifier id, JsonElement json, CallbackInfo ci) {
|
||||
if (json.isJsonObject() && !ResourceConditionsImpl.applyResourceConditions(json.getAsJsonObject(), lootDataType.registryKey().getValue().getPath(), id, REGISTRY_LOOKUPS.get(ops))) {
|
||||
if (json.isJsonObject() && !ResourceConditionsImpl.applyResourceConditions(json.getAsJsonObject(), lootDataType.registryKey().getValue().getPath(), id, new RegistryOps.CachedRegistryInfoGetter(REGISTRY_LOOKUPS.get(ops)))) {
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
|
||||
package net.fabricmc.fabric.mixin.resource.conditions;
|
||||
|
||||
import net.minecraft.registry.RegistryOps;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
@ -31,7 +33,7 @@ public class ServerAdvancementLoaderMixin extends SinglePreparationResourceReloa
|
|||
private RegistryWrapper.WrapperLookup registryLookup;
|
||||
|
||||
@Override
|
||||
protected @Nullable RegistryWrapper.WrapperLookup fabric_getRegistryLookup() {
|
||||
return this.registryLookup;
|
||||
protected @Nullable RegistryOps.RegistryInfoGetter fabric_getRegistryLookup() {
|
||||
return new RegistryOps.CachedRegistryInfoGetter(this.registryLookup);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
|
||||
package net.fabricmc.fabric.mixin.resource.conditions;
|
||||
|
||||
import net.minecraft.registry.RegistryOps;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
|
@ -39,11 +41,11 @@ public class SinglePreparationResourceReloaderMixin {
|
|||
fabric_applyResourceConditions(resourceManager, profiler, object, fabric_getRegistryLookup());
|
||||
}
|
||||
|
||||
protected void fabric_applyResourceConditions(ResourceManager resourceManager, Profiler profiler, Object object, @Nullable RegistryWrapper.WrapperLookup registryLookup) {
|
||||
protected void fabric_applyResourceConditions(ResourceManager resourceManager, Profiler profiler, Object object, @Nullable RegistryOps.RegistryInfoGetter registryLookup) {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected RegistryWrapper.WrapperLookup fabric_getRegistryLookup() {
|
||||
protected RegistryOps.RegistryInfoGetter fabric_getRegistryLookup() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
accessWidener v2 named
|
||||
|
||||
accessible class net/minecraft/registry/ReloadableRegistries$ReloadableWrapperLookup
|
||||
accessible class net/minecraft/registry/RegistryOps$CachedRegistryInfoGetter
|
||||
|
|
|
@ -27,6 +27,7 @@ import net.minecraft.registry.Registries;
|
|||
import net.minecraft.registry.Registry;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
import net.minecraft.registry.RegistryOps;
|
||||
import net.minecraft.registry.RegistryWrapper;
|
||||
import net.minecraft.registry.tag.BiomeTags;
|
||||
import net.minecraft.registry.tag.BlockTags;
|
||||
|
@ -52,7 +53,7 @@ public class DefaultResourceConditionsTest {
|
|||
|
||||
private void expectCondition(TestContext context, String name, ResourceCondition condition, boolean expected) {
|
||||
RegistryWrapper.WrapperLookup registryLookup = context.getWorld().getRegistryManager();
|
||||
boolean actual = condition.test(registryLookup);
|
||||
boolean actual = condition.test(new RegistryOps.CachedRegistryInfoGetter(registryLookup));
|
||||
|
||||
if (actual != expected) {
|
||||
throw new AssertionError("Test \"%s\" for condition %s failed; expected %s, got %s".formatted(name, condition.getType().id(), expected, actual));
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
{
|
||||
"type": "minecraft:crafting_shapeless",
|
||||
"ingredients": [
|
||||
{
|
||||
"item": "minecraft:blue_dye"
|
||||
}
|
||||
"minecraft:blue_dye"
|
||||
],
|
||||
"result": {
|
||||
"id": "minecraft:diamond"
|
||||
|
|
Loading…
Reference in a new issue