1.21.2-pre1 builds

This commit is contained in:
Zoe Gidiere 2024-10-09 16:18:47 -06:00
parent 197cb12be2
commit 2ccf8a8805
14 changed files with 57 additions and 38 deletions

View File

@ -29,7 +29,7 @@ public class BiomeParticleConfigTemplate implements ObjectTemplate<BiomeParticle
try { try {
return new BiomeParticleConfig( return new BiomeParticleConfig(
ParticleEffectArgumentType.readParameters(new StringReader(particle), ParticleEffectArgumentType.readParameters(new StringReader(particle),
(RegistryWrapper.WrapperLookup) Registries.PARTICLE_TYPE.getReadOnlyWrapper()), (RegistryWrapper.WrapperLookup) Registries.PARTICLE_TYPE),
probability); probability);
} catch(CommandSyntaxException e) { } catch(CommandSyntaxException e) {
throw new RuntimeException(e); throw new RuntimeException(e);

View File

@ -15,6 +15,6 @@ public class EntityTypeTemplate implements ObjectTemplate<EntityType<?>> {
@Override @Override
public EntityType<?> get() { public EntityType<?> get() {
return Registries.ENTITY_TYPE.getEntry(id); return Registries.ENTITY_TYPE.getEntry(id).orElseThrow().value();
} }
} }

View File

@ -15,6 +15,6 @@ public class VillagerTypeTemplate implements ObjectTemplate<VillagerType> {
@Override @Override
public VillagerType get() { public VillagerType get() {
return Registries.VILLAGER_TYPE.getEntry(id); return Registries.VILLAGER_TYPE.getEntry(id).orElseThrow().value();
} }
} }

View File

@ -35,7 +35,6 @@ import net.minecraft.world.StructureWorldAccess;
import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.source.BiomeAccess; import net.minecraft.world.biome.source.BiomeAccess;
import net.minecraft.world.chunk.Chunk; import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.gen.GenerationStep.Carver;
import net.minecraft.world.gen.StructureAccessor; import net.minecraft.world.gen.StructureAccessor;
import net.minecraft.world.gen.StructureWeightSampler; import net.minecraft.world.gen.StructureWeightSampler;
import net.minecraft.world.gen.chunk.Blender; import net.minecraft.world.gen.chunk.Blender;
@ -215,10 +214,11 @@ public class MinecraftChunkGeneratorWrapper extends net.minecraft.world.gen.chun
logger.debug("Loading world with config pack {}", pack.getID()); logger.debug("Loading world with config pack {}", pack.getID());
} }
@Override @Override
public void carve(ChunkRegion chunkRegion, long seed, NoiseConfig noiseConfig, BiomeAccess world, StructureAccessor structureAccessor, public void carve(ChunkRegion chunkRegion, long seed, NoiseConfig noiseConfig, BiomeAccess biomeAccess,
Chunk chunk, Carver carverStep) { StructureAccessor structureAccessor, Chunk chunk) {
// no op //no op
} }
@Override @Override

View File

@ -24,6 +24,7 @@ import net.minecraft.command.argument.ItemStackArgumentType;
import net.minecraft.registry.Registry; import net.minecraft.registry.Registry;
import net.minecraft.registry.RegistryKey; import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.RegistryWrapper.Impl; import net.minecraft.registry.RegistryWrapper.Impl;
import net.minecraft.resource.featuretoggle.FeatureSet;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import java.util.Optional; import java.util.Optional;
@ -43,6 +44,11 @@ public class MinecraftItemHandle implements ItemHandle {
public Item createItem(String data) { public Item createItem(String data) {
try { try {
return (Item) new ItemStackArgumentType(new CommandRegistryAccess() { return (Item) new ItemStackArgumentType(new CommandRegistryAccess() {
@Override
public FeatureSet getEnabledFeatures() {
return FeatureSet.empty();
}
@Override @Override
public Stream<RegistryKey<? extends Registry<?>>> streamAllRegistryKeys() { public Stream<RegistryKey<? extends Registry<?>>> streamAllRegistryKeys() {
return CommonPlatform.get().getServer().getRegistryManager().streamAllRegistryKeys(); return CommonPlatform.get().getServer().getRegistryManager().streamAllRegistryKeys();

View File

@ -48,7 +48,7 @@ public class MinecraftWorldHandle implements WorldHandle {
". You are advised to perform this rename in your config packs as this translation will be removed in the next major " + ". You are advised to perform this rename in your config packs as this translation will be removed in the next major " +
"version of Terra."); "version of Terra.");
} }
net.minecraft.block.BlockState state = BlockArgumentParser.block(Registries.BLOCK.getReadOnlyWrapper(), data, true) net.minecraft.block.BlockState state = BlockArgumentParser.block(Registries.BLOCK, data, true)
.blockState(); .blockState();
if(state == null) throw new IllegalArgumentException("Invalid data: " + data); if(state == null) throw new IllegalArgumentException("Invalid data: " + data);
return (BlockState) state; return (BlockState) state;
@ -76,6 +76,6 @@ public class MinecraftWorldHandle implements WorldHandle {
if(!id.contains(":")) throw new IllegalArgumentException("Invalid entity identifier " + id); if(!id.contains(":")) throw new IllegalArgumentException("Invalid entity identifier " + id);
Identifier identifier = Identifier.tryParse(id); Identifier identifier = Identifier.tryParse(id);
if(identifier == null) identifier = Identifier.tryParse(id); if(identifier == null) identifier = Identifier.tryParse(id);
return (EntityType) Registries.ENTITY_TYPE.getEntry(identifier); return (EntityType) Registries.ENTITY_TYPE.getEntry(identifier).orElseThrow();
} }
} }

View File

@ -55,7 +55,7 @@ public abstract class MobSpawnerBlockEntityMixin extends BlockEntity {
public EntityType terra$getSpawnedType() { public EntityType terra$getSpawnedType() {
return (EntityType) Registries.ENTITY_TYPE.getEntry( return (EntityType) Registries.ENTITY_TYPE.getEntry(
Identifier.tryParse(((MobSpawnerLogicAccessor) getLogic()).getSpawnEntry().getNbt().getString("id"))); Identifier.tryParse(((MobSpawnerLogicAccessor) getLogic()).getSpawnEntry().getNbt().getString("id"))).orElseThrow();
} }
public void terra$setSpawnedType(@NotNull EntityType creatureType) { public void terra$setSpawnedType(@NotNull EntityType creatureType) {

View File

@ -18,6 +18,7 @@
package com.dfsek.terra.mod.mixin.implementations.terra.world; package com.dfsek.terra.mod.mixin.implementations.terra.world;
import net.minecraft.block.FluidBlock; import net.minecraft.block.FluidBlock;
import net.minecraft.entity.SpawnReason;
import net.minecraft.fluid.Fluid; import net.minecraft.fluid.Fluid;
import net.minecraft.util.collection.BoundedRegionArray; import net.minecraft.util.collection.BoundedRegionArray;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
@ -125,7 +126,7 @@ public abstract class ChunkRegionMixin {
} }
public Entity terraWorld$spawnEntity(double x, double y, double z, EntityType entityType) { public Entity terraWorld$spawnEntity(double x, double y, double z, EntityType entityType) {
net.minecraft.entity.Entity entity = ((net.minecraft.entity.EntityType<?>) entityType).create(world); net.minecraft.entity.Entity entity = ((net.minecraft.entity.EntityType<?>) entityType).create(world, SpawnReason.CHUNK_GENERATION);
entity.setPos(x, y, z); entity.setPos(x, y, z);
((ChunkRegion) (Object) this).spawnEntity(entity); ((ChunkRegion) (Object) this).spawnEntity(entity);
return (Entity) entity; return (Entity) entity;

View File

@ -17,6 +17,7 @@
package com.dfsek.terra.mod.mixin.implementations.terra.world; package com.dfsek.terra.mod.mixin.implementations.terra.world;
import net.minecraft.entity.SpawnReason;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.WorldAccess; import net.minecraft.world.WorldAccess;
import org.spongepowered.asm.mixin.Implements; import org.spongepowered.asm.mixin.Implements;
@ -42,7 +43,7 @@ import com.dfsek.terra.mod.util.MinecraftUtil;
@Implements(@Interface(iface = ServerWorld.class, prefix = "terra$")) @Implements(@Interface(iface = ServerWorld.class, prefix = "terra$"))
public abstract class ServerWorldMixin { public abstract class ServerWorldMixin {
public Entity terra$spawnEntity(double x, double y, double z, EntityType entityType) { public Entity terra$spawnEntity(double x, double y, double z, EntityType entityType) {
net.minecraft.entity.Entity entity = ((net.minecraft.entity.EntityType<?>) entityType).create(null); net.minecraft.entity.Entity entity = ((net.minecraft.entity.EntityType<?>) entityType).create(null, SpawnReason.CHUNK_GENERATION);
entity.setPos(x, y, z); entity.setPos(x, y, z);
((net.minecraft.server.world.ServerWorld) (Object) this).spawnEntity(entity); ((net.minecraft.server.world.ServerWorld) (Object) this).spawnEntity(entity);
return (Entity) entity; return (Entity) entity;

View File

@ -1,10 +1,16 @@
package com.dfsek.terra.mod.mixin.lifecycle; package com.dfsek.terra.mod.mixin.lifecycle;
import net.minecraft.registry.CombinedDynamicRegistries;
import net.minecraft.registry.DynamicRegistryManager; import net.minecraft.registry.DynamicRegistryManager;
import net.minecraft.registry.Registry; import net.minecraft.registry.Registry;
import net.minecraft.registry.Registry.PendingTagLoad;
import net.minecraft.registry.RegistryKeys; import net.minecraft.registry.RegistryKeys;
import net.minecraft.registry.ReloadableRegistries; import net.minecraft.registry.ReloadableRegistries;
import net.minecraft.registry.ServerDynamicRegistryType;
import net.minecraft.resource.ResourceManager;
import net.minecraft.resource.featuretoggle.FeatureSet;
import net.minecraft.server.DataPackContents; import net.minecraft.server.DataPackContents;
import net.minecraft.server.command.CommandManager;
import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.Biome;
import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
@ -16,6 +22,12 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import com.dfsek.terra.mod.util.MinecraftUtil; import com.dfsek.terra.mod.util.MinecraftUtil;
import com.dfsek.terra.mod.util.TagUtil; import com.dfsek.terra.mod.util.TagUtil;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;
@Mixin(DataPackContents.class) @Mixin(DataPackContents.class)
public class DataPackContentsMixin { public class DataPackContentsMixin {
@ -26,9 +38,14 @@ public class DataPackContentsMixin {
/* /*
* #refresh populates all tags in the registries * #refresh populates all tags in the registries
*/ */
@Inject(method = "refresh()V", at = @At("RETURN")) @Inject(method = "reload(Lnet/minecraft/resource/ResourceManager;Lnet/minecraft/registry/CombinedDynamicRegistries;Ljava/util/List;Lnet/minecraft/resource/featuretoggle/FeatureSet;Lnet/minecraft/server/command/CommandManager$RegistrationEnvironment;ILjava/util/concurrent/Executor;Ljava/util/concurrent/Executor;)Ljava/util/concurrent/CompletableFuture;", at = @At("RETURN"))
private void injectReload(CallbackInfo ci) { private static void injectReload(ResourceManager resourceManager,
DynamicRegistryManager.Immutable dynamicRegistryManager = this.reloadableRegistries.getRegistryManager(); CombinedDynamicRegistries<ServerDynamicRegistryType> dynamicRegistries,
List<PendingTagLoad<?>> pendingTagLoads, FeatureSet enabledFeatures,
CommandManager.RegistrationEnvironment environment, int functionPermissionLevel,
Executor prepareExecutor,
Executor applyExecutor, CallbackInfoReturnable<CompletableFuture<DataPackContents>> cir) {
DynamicRegistryManager.Immutable dynamicRegistryManager = dynamicRegistries.getCombinedRegistryManager();
TagUtil.registerWorldPresetTags(dynamicRegistryManager.getOrThrow(RegistryKeys.WORLD_PRESET)); TagUtil.registerWorldPresetTags(dynamicRegistryManager.getOrThrow(RegistryKeys.WORLD_PRESET));
Registry<Biome> biomeRegistry = dynamicRegistryManager.getOrThrow(RegistryKeys.BIOME); Registry<Biome> biomeRegistry = dynamicRegistryManager.getOrThrow(RegistryKeys.BIOME);

View File

@ -47,8 +47,7 @@ public final class MinecraftUtil {
public static <T> Optional<RegistryEntry<T>> getEntry(Registry<T> registry, Identifier identifier) { public static <T> Optional<RegistryEntry<T>> getEntry(Registry<T> registry, Identifier identifier) {
return registry.getOptionalValue(identifier) return registry.getOptionalValue(identifier)
.flatMap(registry::getKey) .flatMap(id -> Optional.ofNullable(registry.getEntry(id)));
.flatMap(registry::getEntry);
} }
public static BlockEntity createState(WorldAccess worldAccess, BlockPos pos) { public static BlockEntity createState(WorldAccess worldAccess, BlockPos pos) {

View File

@ -40,9 +40,8 @@ public class PresetUtil {
platform.multiNoiseBiomeSourceParameterListRegistry(); platform.multiNoiseBiomeSourceParameterListRegistry();
RegistryEntry<DimensionType> overworldDimensionType = dimensionTypeRegistry.getEntry(DimensionTypes.OVERWORLD).orElseThrow(); RegistryEntry<DimensionType> overworldDimensionType = dimensionTypeRegistry.getEntry(dimensionTypeRegistry.get(DimensionTypes.OVERWORLD));
RegistryEntry<ChunkGeneratorSettings> overworld = chunkGeneratorSettingsRegistry.getEntry(ChunkGeneratorSettings.OVERWORLD) RegistryEntry<ChunkGeneratorSettings> overworld = chunkGeneratorSettingsRegistry.getEntry(chunkGeneratorSettingsRegistry.get(ChunkGeneratorSettings.OVERWORLD));
.orElseThrow();
Identifier generatorID = Identifier.tryParse( Identifier generatorID = Identifier.tryParse(
@ -51,15 +50,13 @@ public class PresetUtil {
PRESETS.add(generatorID); PRESETS.add(generatorID);
RegistryEntry<DimensionType> registryEntry = dimensionTypeRegistry.getEntry(DimensionTypes.THE_NETHER).orElseThrow(); RegistryEntry<DimensionType> registryEntry = dimensionTypeRegistry.getEntry(dimensionTypeRegistry.get(DimensionTypes.THE_NETHER));
RegistryEntry.Reference<MultiNoiseBiomeSourceParameterList> reference = multiNoiseBiomeSourceParameterLists.getEntry( RegistryEntry<MultiNoiseBiomeSourceParameterList> reference = multiNoiseBiomeSourceParameterLists.getEntry(
MultiNoiseBiomeSourceParameterLists.NETHER).orElseThrow(); multiNoiseBiomeSourceParameterLists.get(MultiNoiseBiomeSourceParameterLists.NETHER));
RegistryEntry<ChunkGeneratorSettings> registryEntry2 = chunkGeneratorSettingsRegistry.getEntry(ChunkGeneratorSettings.NETHER) RegistryEntry<ChunkGeneratorSettings> registryEntry2 = chunkGeneratorSettingsRegistry.getEntry(chunkGeneratorSettingsRegistry.get(ChunkGeneratorSettings.NETHER));
.orElseThrow();
RegistryEntry<DimensionType> registryEntry3 = dimensionTypeRegistry.getEntry(DimensionTypes.THE_END).orElseThrow(); RegistryEntry<DimensionType> registryEntry3 = dimensionTypeRegistry.getEntry(dimensionTypeRegistry.get(DimensionTypes.THE_END));
RegistryEntry<ChunkGeneratorSettings> registryEntry4 = chunkGeneratorSettingsRegistry.getEntry(ChunkGeneratorSettings.END) RegistryEntry<ChunkGeneratorSettings> registryEntry4 = chunkGeneratorSettingsRegistry.getEntry(chunkGeneratorSettingsRegistry.get(ChunkGeneratorSettings.END));
.orElseThrow();
TerraBiomeSource biomeSource = new TerraBiomeSource(pack); TerraBiomeSource biomeSource = new TerraBiomeSource(pack);
ChunkGenerator generator = new MinecraftChunkGeneratorWrapper(biomeSource, pack, overworld); ChunkGenerator generator = new MinecraftChunkGeneratorWrapper(biomeSource, pack, overworld);
@ -69,7 +66,7 @@ public class PresetUtil {
new NoiseChunkGenerator(MultiNoiseBiomeSource.create(reference), new NoiseChunkGenerator(MultiNoiseBiomeSource.create(reference),
registryEntry2)); registryEntry2));
DimensionOptions endDimensionOptions = new DimensionOptions(registryEntry3, new NoiseChunkGenerator( DimensionOptions endDimensionOptions = new DimensionOptions(registryEntry3, new NoiseChunkGenerator(
TheEndBiomeSource.createVanilla(platform.biomeRegistry().getReadOnlyWrapper()), registryEntry4)); TheEndBiomeSource.createVanilla(platform.biomeRegistry()), registryEntry4));
WorldPreset preset = createPreset(dimensionOptions, netherDimensionOptions, endDimensionOptions); WorldPreset preset = createPreset(dimensionOptions, netherDimensionOptions, endDimensionOptions);
LOGGER.info("Created world type \"{}\"", generatorID); LOGGER.info("Created world type \"{}\"", generatorID);

View File

@ -2,7 +2,9 @@ package com.dfsek.terra.mod.util;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import net.minecraft.registry.Registry; import net.minecraft.registry.Registry;
import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.entry.RegistryEntry; import net.minecraft.registry.entry.RegistryEntry;
import net.minecraft.registry.tag.TagGroupLoader.RegistryTags;
import net.minecraft.registry.tag.TagKey; import net.minecraft.registry.tag.TagKey;
import net.minecraft.registry.tag.WorldPresetTags; import net.minecraft.registry.tag.WorldPresetTags;
import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.Biome;
@ -25,10 +27,8 @@ public final class TagUtil {
private static <T> Map<TagKey<T>, List<RegistryEntry<T>>> tagsToMutableMap(Registry<T> registry) { private static <T> Map<TagKey<T>, List<RegistryEntry<T>>> tagsToMutableMap(Registry<T> registry) {
return registry return registry
.streamTags() .streamTags().collect(HashMap::new,
.collect(HashMap::new, (map, tag) -> map.put(tag.getTag(), new ArrayList<>()),
(map, pair) ->
map.put(pair.getFirst(), new ArrayList<>(pair.getSecond().stream().toList())),
HashMap::putAll); HashMap::putAll);
} }
@ -46,8 +46,7 @@ public final class TagUtil {
.add(preset), .add(preset),
() -> logger.error("Preset {} does not exist!", id))); () -> logger.error("Preset {} does not exist!", id)));
registry.clearTags(); registry.startTagReload(new RegistryTags<>(registry.getKey(), collect)).apply();
registry.populateTags(ImmutableMap.copyOf(collect));
} }
public static void registerBiomeTags(Registry<Biome> registry) { public static void registerBiomeTags(Registry<Biome> registry) {
@ -90,8 +89,7 @@ public final class TagUtil {
tb))), tb))),
() -> logger.error("No vanilla biome: {}", vb))); () -> logger.error("No vanilla biome: {}", vb)));
registry.clearTags(); registry.startTagReload(new RegistryTags<>(registry.getKey(), collect)).apply();
registry.populateTags(ImmutableMap.copyOf(collect));
if(logger.isDebugEnabled()) { if(logger.isDebugEnabled()) {
registry.streamEntries() registry.streamEntries()

View File

@ -51,7 +51,7 @@ public final class BiomeUtil {
if(pack.getContext().get(PreLoadCompatibilityOptions.class).useVanillaBiomes()) { if(pack.getContext().get(PreLoadCompatibilityOptions.class).useVanillaBiomes()) {
((ProtoPlatformBiome) biome.getPlatformBiome()).setDelegate(registry.getEntry(vanilla).orElseThrow()); ((ProtoPlatformBiome) biome.getPlatformBiome()).setDelegate(registry.getEntry(registry.get(vanilla)));
} else { } else {
VanillaBiomeProperties vanillaBiomeProperties = biome.getContext().get(VanillaBiomeProperties.class); VanillaBiomeProperties vanillaBiomeProperties = biome.getContext().get(VanillaBiomeProperties.class);