mirror of
https://github.com/FabricMC/fabric.git
synced 2024-11-23 16:18:29 -05:00
Fix some registry-related bugs (#3932)
* Fix tag path for custom registry * Strip knownPackInfo during Biome Modification
This commit is contained in:
parent
c111832abb
commit
5bd9f1bc81
4 changed files with 23 additions and 18 deletions
|
@ -21,6 +21,7 @@ import java.util.Comparator;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Predicate;
|
||||
|
@ -35,6 +36,8 @@ import net.minecraft.registry.DynamicRegistryManager;
|
|||
import net.minecraft.registry.Registry;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
import net.minecraft.registry.SimpleRegistry;
|
||||
import net.minecraft.registry.entry.RegistryEntryInfo;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.gen.feature.util.PlacedFeatureIndexer;
|
||||
|
@ -166,6 +169,12 @@ public class BiomeModificationImpl {
|
|||
);
|
||||
});
|
||||
}
|
||||
|
||||
if (biomes instanceof SimpleRegistry<Biome> registry) {
|
||||
RegistryEntryInfo info = registry.keyToEntryInfo.get(key);
|
||||
RegistryEntryInfo newInfo = new RegistryEntryInfo(Optional.empty(), info.lifecycle());
|
||||
registry.keyToEntryInfo.put(key, newInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -59,3 +59,6 @@ mutable field net/minecraft/world/biome/GenerationSettings allowedFeatures Ljava
|
|||
# ChunkGenerator
|
||||
accessible field net/minecraft/world/gen/chunk/ChunkGenerator indexedFeaturesListSupplier Ljava/util/function/Supplier;
|
||||
mutable field net/minecraft/world/gen/chunk/ChunkGenerator indexedFeaturesListSupplier Ljava/util/function/Supplier;
|
||||
|
||||
# Registry mutation sync
|
||||
accessible field net/minecraft/registry/SimpleRegistry keyToEntryInfo Ljava/util/Map;
|
||||
|
|
|
@ -16,28 +16,21 @@
|
|||
|
||||
package net.fabricmc.fabric.mixin.registry.sync;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
|
||||
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
|
||||
import com.llamalad7.mixinextras.sugar.Local;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
|
||||
import net.minecraft.registry.Registry;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.registry.tag.TagManagerLoader;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
// Adds namespaces to tag directories for registries added by mods.
|
||||
@Mixin(TagManagerLoader.class)
|
||||
abstract class TagManagerLoaderMixin {
|
||||
@WrapOperation(
|
||||
method = "buildRequiredGroup",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/registry/RegistryKeys;getTagPath(Lnet/minecraft/registry/RegistryKey;)Ljava/lang/String;"
|
||||
)
|
||||
)
|
||||
private String prependDirectoryWithNamespace(RegistryKey<? extends Registry<?>> registryKey, Operation<String> original) {
|
||||
Identifier id = registryKey.getValue();
|
||||
@Mixin(RegistryKeys.class)
|
||||
public class RegistryKeysMixin {
|
||||
@ModifyReturnValue(method = "getTagPath", at = @At("RETURN"))
|
||||
private static String prependDirectoryWithNamespace(String original, @Local(argsOnly = true) RegistryKey<? extends Registry<?>> registryRef) {
|
||||
Identifier id = registryRef.getValue();
|
||||
|
||||
// Vanilla doesn't mark namespaces in the directories of tags at all,
|
||||
// so we prepend the directories with the namespace if it's a modded registry id.
|
||||
|
@ -46,6 +39,6 @@ abstract class TagManagerLoaderMixin {
|
|||
return "tags/" + id.getNamespace() + "/" + id.getPath();
|
||||
}
|
||||
|
||||
return original.call(registryKey);
|
||||
return original;
|
||||
}
|
||||
}
|
|
@ -11,11 +11,11 @@
|
|||
"MainMixin",
|
||||
"RegistriesAccessor",
|
||||
"RegistriesMixin",
|
||||
"RegistryKeysMixin",
|
||||
"RegistryLoaderMixin",
|
||||
"SaveLoadingMixin",
|
||||
"SerializableRegistriesMixin",
|
||||
"SimpleRegistryMixin",
|
||||
"TagManagerLoaderMixin"
|
||||
"SimpleRegistryMixin"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
|
|
Loading…
Reference in a new issue