mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2025-07-01 15:37:24 +00:00
1.21.2-pre1 builds
This commit is contained in:
parent
197cb12be2
commit
2ccf8a8805
@ -29,7 +29,7 @@ public class BiomeParticleConfigTemplate implements ObjectTemplate<BiomeParticle
|
||||
try {
|
||||
return new BiomeParticleConfig(
|
||||
ParticleEffectArgumentType.readParameters(new StringReader(particle),
|
||||
(RegistryWrapper.WrapperLookup) Registries.PARTICLE_TYPE.getReadOnlyWrapper()),
|
||||
(RegistryWrapper.WrapperLookup) Registries.PARTICLE_TYPE),
|
||||
probability);
|
||||
} catch(CommandSyntaxException e) {
|
||||
throw new RuntimeException(e);
|
||||
|
@ -15,6 +15,6 @@ public class EntityTypeTemplate implements ObjectTemplate<EntityType<?>> {
|
||||
|
||||
@Override
|
||||
public EntityType<?> get() {
|
||||
return Registries.ENTITY_TYPE.getEntry(id);
|
||||
return Registries.ENTITY_TYPE.getEntry(id).orElseThrow().value();
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,6 @@ public class VillagerTypeTemplate implements ObjectTemplate<VillagerType> {
|
||||
|
||||
@Override
|
||||
public VillagerType get() {
|
||||
return Registries.VILLAGER_TYPE.getEntry(id);
|
||||
return Registries.VILLAGER_TYPE.getEntry(id).orElseThrow().value();
|
||||
}
|
||||
}
|
||||
|
@ -35,7 +35,6 @@ import net.minecraft.world.StructureWorldAccess;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.biome.source.BiomeAccess;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraft.world.gen.GenerationStep.Carver;
|
||||
import net.minecraft.world.gen.StructureAccessor;
|
||||
import net.minecraft.world.gen.StructureWeightSampler;
|
||||
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());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void carve(ChunkRegion chunkRegion, long seed, NoiseConfig noiseConfig, BiomeAccess world, StructureAccessor structureAccessor,
|
||||
Chunk chunk, Carver carverStep) {
|
||||
// no op
|
||||
public void carve(ChunkRegion chunkRegion, long seed, NoiseConfig noiseConfig, BiomeAccess biomeAccess,
|
||||
StructureAccessor structureAccessor, Chunk chunk) {
|
||||
//no op
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -24,6 +24,7 @@ import net.minecraft.command.argument.ItemStackArgumentType;
|
||||
import net.minecraft.registry.Registry;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.registry.RegistryWrapper.Impl;
|
||||
import net.minecraft.resource.featuretoggle.FeatureSet;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import java.util.Optional;
|
||||
@ -43,6 +44,11 @@ public class MinecraftItemHandle implements ItemHandle {
|
||||
public Item createItem(String data) {
|
||||
try {
|
||||
return (Item) new ItemStackArgumentType(new CommandRegistryAccess() {
|
||||
@Override
|
||||
public FeatureSet getEnabledFeatures() {
|
||||
return FeatureSet.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<RegistryKey<? extends Registry<?>>> streamAllRegistryKeys() {
|
||||
return CommonPlatform.get().getServer().getRegistryManager().streamAllRegistryKeys();
|
||||
|
@ -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 " +
|
||||
"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();
|
||||
if(state == null) throw new IllegalArgumentException("Invalid data: " + data);
|
||||
return (BlockState) state;
|
||||
@ -76,6 +76,6 @@ public class MinecraftWorldHandle implements WorldHandle {
|
||||
if(!id.contains(":")) throw new IllegalArgumentException("Invalid entity identifier " + id);
|
||||
Identifier 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();
|
||||
}
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ public abstract class MobSpawnerBlockEntityMixin extends BlockEntity {
|
||||
|
||||
public EntityType terra$getSpawnedType() {
|
||||
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) {
|
||||
|
@ -18,6 +18,7 @@
|
||||
package com.dfsek.terra.mod.mixin.implementations.terra.world;
|
||||
|
||||
import net.minecraft.block.FluidBlock;
|
||||
import net.minecraft.entity.SpawnReason;
|
||||
import net.minecraft.fluid.Fluid;
|
||||
import net.minecraft.util.collection.BoundedRegionArray;
|
||||
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) {
|
||||
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);
|
||||
((ChunkRegion) (Object) this).spawnEntity(entity);
|
||||
return (Entity) entity;
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
package com.dfsek.terra.mod.mixin.implementations.terra.world;
|
||||
|
||||
import net.minecraft.entity.SpawnReason;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.WorldAccess;
|
||||
import org.spongepowered.asm.mixin.Implements;
|
||||
@ -42,7 +43,7 @@ import com.dfsek.terra.mod.util.MinecraftUtil;
|
||||
@Implements(@Interface(iface = ServerWorld.class, prefix = "terra$"))
|
||||
public abstract class ServerWorldMixin {
|
||||
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);
|
||||
((net.minecraft.server.world.ServerWorld) (Object) this).spawnEntity(entity);
|
||||
return (Entity) entity;
|
||||
|
@ -1,10 +1,16 @@
|
||||
package com.dfsek.terra.mod.mixin.lifecycle;
|
||||
|
||||
import net.minecraft.registry.CombinedDynamicRegistries;
|
||||
import net.minecraft.registry.DynamicRegistryManager;
|
||||
import net.minecraft.registry.Registry;
|
||||
import net.minecraft.registry.Registry.PendingTagLoad;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
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.command.CommandManager;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
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.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)
|
||||
public class DataPackContentsMixin {
|
||||
@ -26,9 +38,14 @@ public class DataPackContentsMixin {
|
||||
/*
|
||||
* #refresh populates all tags in the registries
|
||||
*/
|
||||
@Inject(method = "refresh()V", at = @At("RETURN"))
|
||||
private void injectReload(CallbackInfo ci) {
|
||||
DynamicRegistryManager.Immutable dynamicRegistryManager = this.reloadableRegistries.getRegistryManager();
|
||||
@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 static void injectReload(ResourceManager resourceManager,
|
||||
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));
|
||||
|
||||
Registry<Biome> biomeRegistry = dynamicRegistryManager.getOrThrow(RegistryKeys.BIOME);
|
||||
|
@ -47,8 +47,7 @@ public final class MinecraftUtil {
|
||||
|
||||
public static <T> Optional<RegistryEntry<T>> getEntry(Registry<T> registry, Identifier identifier) {
|
||||
return registry.getOptionalValue(identifier)
|
||||
.flatMap(registry::getKey)
|
||||
.flatMap(registry::getEntry);
|
||||
.flatMap(id -> Optional.ofNullable(registry.getEntry(id)));
|
||||
}
|
||||
|
||||
public static BlockEntity createState(WorldAccess worldAccess, BlockPos pos) {
|
||||
|
@ -40,9 +40,8 @@ public class PresetUtil {
|
||||
platform.multiNoiseBiomeSourceParameterListRegistry();
|
||||
|
||||
|
||||
RegistryEntry<DimensionType> overworldDimensionType = dimensionTypeRegistry.getEntry(DimensionTypes.OVERWORLD).orElseThrow();
|
||||
RegistryEntry<ChunkGeneratorSettings> overworld = chunkGeneratorSettingsRegistry.getEntry(ChunkGeneratorSettings.OVERWORLD)
|
||||
.orElseThrow();
|
||||
RegistryEntry<DimensionType> overworldDimensionType = dimensionTypeRegistry.getEntry(dimensionTypeRegistry.get(DimensionTypes.OVERWORLD));
|
||||
RegistryEntry<ChunkGeneratorSettings> overworld = chunkGeneratorSettingsRegistry.getEntry(chunkGeneratorSettingsRegistry.get(ChunkGeneratorSettings.OVERWORLD));
|
||||
|
||||
|
||||
Identifier generatorID = Identifier.tryParse(
|
||||
@ -51,15 +50,13 @@ public class PresetUtil {
|
||||
|
||||
PRESETS.add(generatorID);
|
||||
|
||||
RegistryEntry<DimensionType> registryEntry = dimensionTypeRegistry.getEntry(DimensionTypes.THE_NETHER).orElseThrow();
|
||||
RegistryEntry.Reference<MultiNoiseBiomeSourceParameterList> reference = multiNoiseBiomeSourceParameterLists.getEntry(
|
||||
MultiNoiseBiomeSourceParameterLists.NETHER).orElseThrow();
|
||||
RegistryEntry<ChunkGeneratorSettings> registryEntry2 = chunkGeneratorSettingsRegistry.getEntry(ChunkGeneratorSettings.NETHER)
|
||||
.orElseThrow();
|
||||
RegistryEntry<DimensionType> registryEntry = dimensionTypeRegistry.getEntry(dimensionTypeRegistry.get(DimensionTypes.THE_NETHER));
|
||||
RegistryEntry<MultiNoiseBiomeSourceParameterList> reference = multiNoiseBiomeSourceParameterLists.getEntry(
|
||||
multiNoiseBiomeSourceParameterLists.get(MultiNoiseBiomeSourceParameterLists.NETHER));
|
||||
RegistryEntry<ChunkGeneratorSettings> registryEntry2 = chunkGeneratorSettingsRegistry.getEntry(chunkGeneratorSettingsRegistry.get(ChunkGeneratorSettings.NETHER));
|
||||
|
||||
RegistryEntry<DimensionType> registryEntry3 = dimensionTypeRegistry.getEntry(DimensionTypes.THE_END).orElseThrow();
|
||||
RegistryEntry<ChunkGeneratorSettings> registryEntry4 = chunkGeneratorSettingsRegistry.getEntry(ChunkGeneratorSettings.END)
|
||||
.orElseThrow();
|
||||
RegistryEntry<DimensionType> registryEntry3 = dimensionTypeRegistry.getEntry(dimensionTypeRegistry.get(DimensionTypes.THE_END));
|
||||
RegistryEntry<ChunkGeneratorSettings> registryEntry4 = chunkGeneratorSettingsRegistry.getEntry(chunkGeneratorSettingsRegistry.get(ChunkGeneratorSettings.END));
|
||||
|
||||
TerraBiomeSource biomeSource = new TerraBiomeSource(pack);
|
||||
ChunkGenerator generator = new MinecraftChunkGeneratorWrapper(biomeSource, pack, overworld);
|
||||
@ -69,7 +66,7 @@ public class PresetUtil {
|
||||
new NoiseChunkGenerator(MultiNoiseBiomeSource.create(reference),
|
||||
registryEntry2));
|
||||
DimensionOptions endDimensionOptions = new DimensionOptions(registryEntry3, new NoiseChunkGenerator(
|
||||
TheEndBiomeSource.createVanilla(platform.biomeRegistry().getReadOnlyWrapper()), registryEntry4));
|
||||
TheEndBiomeSource.createVanilla(platform.biomeRegistry()), registryEntry4));
|
||||
|
||||
WorldPreset preset = createPreset(dimensionOptions, netherDimensionOptions, endDimensionOptions);
|
||||
LOGGER.info("Created world type \"{}\"", generatorID);
|
||||
|
@ -2,7 +2,9 @@ package com.dfsek.terra.mod.util;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import net.minecraft.registry.Registry;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.registry.entry.RegistryEntry;
|
||||
import net.minecraft.registry.tag.TagGroupLoader.RegistryTags;
|
||||
import net.minecraft.registry.tag.TagKey;
|
||||
import net.minecraft.registry.tag.WorldPresetTags;
|
||||
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) {
|
||||
return registry
|
||||
.streamTags()
|
||||
.collect(HashMap::new,
|
||||
(map, pair) ->
|
||||
map.put(pair.getFirst(), new ArrayList<>(pair.getSecond().stream().toList())),
|
||||
.streamTags().collect(HashMap::new,
|
||||
(map, tag) -> map.put(tag.getTag(), new ArrayList<>()),
|
||||
HashMap::putAll);
|
||||
}
|
||||
|
||||
@ -46,8 +46,7 @@ public final class TagUtil {
|
||||
.add(preset),
|
||||
() -> logger.error("Preset {} does not exist!", id)));
|
||||
|
||||
registry.clearTags();
|
||||
registry.populateTags(ImmutableMap.copyOf(collect));
|
||||
registry.startTagReload(new RegistryTags<>(registry.getKey(), collect)).apply();
|
||||
}
|
||||
|
||||
public static void registerBiomeTags(Registry<Biome> registry) {
|
||||
@ -90,8 +89,7 @@ public final class TagUtil {
|
||||
tb))),
|
||||
() -> logger.error("No vanilla biome: {}", vb)));
|
||||
|
||||
registry.clearTags();
|
||||
registry.populateTags(ImmutableMap.copyOf(collect));
|
||||
registry.startTagReload(new RegistryTags<>(registry.getKey(), collect)).apply();
|
||||
|
||||
if(logger.isDebugEnabled()) {
|
||||
registry.streamEntries()
|
||||
|
@ -51,7 +51,7 @@ public final class BiomeUtil {
|
||||
|
||||
|
||||
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 {
|
||||
VanillaBiomeProperties vanillaBiomeProperties = biome.getContext().get(VanillaBiomeProperties.class);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user