[Changes] Build for 1.19.3-pre3
This commit is contained in:
parent
0dcb7809b8
commit
7b726d958d
96 changed files with 1315 additions and 1198 deletions
|
@ -1 +1 @@
|
|||
Subproject commit 5707d247a5dd6103c8f2f9550e73b86ebf694e78
|
||||
Subproject commit 7bcd9178ccd4ea8b67d01ce1307d5a2bb3e7834e
|
|
@ -1,15 +1,16 @@
|
|||
# Done to increase the memory available to gradle.
|
||||
org.gradle.jvmargs=-Xmx8G
|
||||
#Modrinth
|
||||
modrinth_versions=["22w45a"]
|
||||
release_channel=release #`release`, `beta` or `alpha`
|
||||
modrinth_versions=["1.19.3-pre3"]
|
||||
#`release`, `beta` or `alpha`
|
||||
release_channel=release
|
||||
#Loom
|
||||
loom_version=1.0-SNAPSHOT
|
||||
# Fabric Properties
|
||||
# check these on https://fabricmc.net/versions.html
|
||||
minecraft_version=1.19.3-pre2
|
||||
minecraft_version=1.19.3-pre3
|
||||
loader_version=0.14.10
|
||||
fabric_version=0.67.3+1.19.3
|
||||
fabric_version=0.68.0+1.19.3
|
||||
# Mod Properties
|
||||
mod_version=2.1.3
|
||||
maven_group=org.betterx.bclib
|
||||
|
|
|
@ -6,10 +6,7 @@ import org.betterx.bclib.api.v2.generator.BCLibEndBiomeSource;
|
|||
import org.betterx.bclib.api.v2.generator.BCLibNetherBiomeSource;
|
||||
import org.betterx.bclib.api.v2.generator.GeneratorOptions;
|
||||
import org.betterx.bclib.api.v2.levelgen.LevelGenEvents;
|
||||
import org.betterx.bclib.api.v2.levelgen.biomes.BCLBiome;
|
||||
import org.betterx.bclib.api.v2.levelgen.biomes.BCLBiomeBuilder;
|
||||
import org.betterx.bclib.api.v2.levelgen.biomes.BCLBiomeRegistry;
|
||||
import org.betterx.bclib.api.v2.levelgen.biomes.BiomeAPI;
|
||||
import org.betterx.bclib.api.v2.levelgen.structures.TemplatePiece;
|
||||
import org.betterx.bclib.api.v2.levelgen.surface.rules.Conditions;
|
||||
import org.betterx.bclib.api.v2.poi.PoiManager;
|
||||
|
@ -28,8 +25,6 @@ import org.betterx.worlds.together.util.Logger;
|
|||
import org.betterx.worlds.together.world.WorldConfig;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
|
@ -45,84 +40,11 @@ public class BCLib implements ModInitializer {
|
|||
.getModContainer("nullscape")
|
||||
.isPresent();
|
||||
|
||||
private static void registerTestBiomes() {
|
||||
if (true && isDevEnvironment()) {
|
||||
BCLBiome theYellow = BCLBiomeBuilder
|
||||
.start(makeID("the_yellow"))
|
||||
.precipitation(Biome.Precipitation.NONE)
|
||||
.temperature(1.0f)
|
||||
.wetness(1.0f)
|
||||
.fogColor(0xFFFF00)
|
||||
.waterColor(0x777700)
|
||||
.waterFogColor(0xFFFF00)
|
||||
.skyColor(0xAAAA00)
|
||||
.addNetherClimateParamater(-1, 1)
|
||||
.surface(Blocks.YELLOW_CONCRETE)
|
||||
.build();
|
||||
BiomeAPI.registerEndLandBiome(theYellow);
|
||||
|
||||
BCLBiome theBlue = BCLBiomeBuilder
|
||||
.start(makeID("the_blue"))
|
||||
.precipitation(Biome.Precipitation.NONE)
|
||||
.temperature(1.0f)
|
||||
.wetness(1.0f)
|
||||
.fogColor(0x0000FF)
|
||||
.waterColor(0x000077)
|
||||
.waterFogColor(0x0000FF)
|
||||
.skyColor(0x0000AA)
|
||||
.addNetherClimateParamater(-1, 1)
|
||||
.surface(Blocks.LIGHT_BLUE_CONCRETE)
|
||||
.build();
|
||||
BiomeAPI.registerEndLandBiome(theBlue);
|
||||
|
||||
BCLBiome theGray = BCLBiomeBuilder
|
||||
.start(makeID("the_gray"))
|
||||
.precipitation(Biome.Precipitation.NONE)
|
||||
.temperature(1.0f)
|
||||
.wetness(1.0f)
|
||||
.fogColor(0xFFFFFF)
|
||||
.waterColor(0x777777)
|
||||
.waterFogColor(0xFFFFFF)
|
||||
.skyColor(0xAAAAAA)
|
||||
.addNetherClimateParamater(-1, 1)
|
||||
.surface(Blocks.GRAY_CONCRETE)
|
||||
.build();
|
||||
BiomeAPI.registerEndVoidBiome(theGray);
|
||||
|
||||
BCLBiome theOrange = BCLBiomeBuilder
|
||||
.start(makeID("the_orange"))
|
||||
.precipitation(Biome.Precipitation.NONE)
|
||||
.temperature(1.0f)
|
||||
.wetness(1.0f)
|
||||
.fogColor(0xFF7700)
|
||||
.waterColor(0x773300)
|
||||
.waterFogColor(0xFF7700)
|
||||
.skyColor(0xAA7700)
|
||||
.addNetherClimateParamater(-1, 1.1f)
|
||||
.surface(Blocks.ORANGE_CONCRETE)
|
||||
.build();
|
||||
BiomeAPI.registerNetherBiome(theOrange);
|
||||
|
||||
BCLBiome thePurple = BCLBiomeBuilder
|
||||
.start(makeID("the_purple"))
|
||||
.precipitation(Biome.Precipitation.NONE)
|
||||
.temperature(1.0f)
|
||||
.wetness(1.0f)
|
||||
.fogColor(0xFF00FF)
|
||||
.waterColor(0x770077)
|
||||
.waterFogColor(0xFF00FF)
|
||||
.skyColor(0xAA00AA)
|
||||
.addNetherClimateParamater(-1.1f, 1)
|
||||
.surface(Blocks.PURPLE_CONCRETE)
|
||||
.build();
|
||||
BiomeAPI.registerNetherBiome(thePurple);
|
||||
}
|
||||
}
|
||||
|
||||
private void onDatagen() {
|
||||
registerTestBiomes();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
WorldsTogether.onInitialize();
|
||||
|
|
|
@ -1,140 +0,0 @@
|
|||
package org.betterx.bclib;
|
||||
|
||||
import org.betterx.bclib.api.v2.levelgen.biomes.BCLBiomeRegistry;
|
||||
import org.betterx.bclib.api.v2.levelgen.biomes.BiomeData;
|
||||
import org.betterx.worlds.together.WorldsTogether;
|
||||
import org.betterx.worlds.together.surfaceRules.AssignedSurfaceRule;
|
||||
import org.betterx.worlds.together.surfaceRules.SurfaceRuleRegistry;
|
||||
|
||||
import com.mojang.serialization.DynamicOps;
|
||||
import com.mojang.serialization.Encoder;
|
||||
import com.mojang.serialization.JsonOps;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.data.CachedOutput;
|
||||
import net.minecraft.data.DataProvider;
|
||||
import net.minecraft.data.PackOutput;
|
||||
import net.minecraft.resources.RegistryDataLoader;
|
||||
import net.minecraft.resources.RegistryOps;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
|
||||
import net.fabricmc.fabric.api.datagen.v1.DataGeneratorEntrypoint;
|
||||
import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator;
|
||||
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
|
||||
import net.fabricmc.fabric.api.datagen.v1.provider.FabricBuiltinRegistriesProvider;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public class BCLibDatagen implements DataGeneratorEntrypoint {
|
||||
|
||||
@Override
|
||||
public void onInitializeDataGenerator(FabricDataGenerator dataGenerator) {
|
||||
final FabricDataGenerator.Pack pack = dataGenerator.createPack();
|
||||
pack.addProvider(FabricBuiltinRegistriesProvider.forCurrentMod());
|
||||
pack.addProvider(CustomRegistriesDataProvider::new);
|
||||
}
|
||||
|
||||
public static class CustomRegistriesDataProvider implements DataProvider {
|
||||
public static final List<RegistryDataLoader.RegistryData<?>> REGISTRIES = List.of(
|
||||
new RegistryDataLoader.RegistryData<>(BCLBiomeRegistry.BCL_BIOMES_REGISTRY, BiomeData.CODEC),
|
||||
new RegistryDataLoader.RegistryData<>(
|
||||
SurfaceRuleRegistry.SURFACE_RULES_REGISTRY,
|
||||
AssignedSurfaceRule.CODEC
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
private final PackOutput output;
|
||||
|
||||
public CustomRegistriesDataProvider(FabricDataOutput generator) {
|
||||
this.output = generator;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<?> run(CachedOutput cachedOutput) {
|
||||
RegistryAccess.Frozen registryAccess = BuiltInRegistries.createAccess();
|
||||
RegistryOps<JsonElement> dynamicOps = RegistryOps.create(JsonOps.INSTANCE, registryAccess);
|
||||
final List<CompletableFuture<?>> futures = new ArrayList<>();
|
||||
|
||||
for (RegistryDataLoader.RegistryData<?> registryData : REGISTRIES) {
|
||||
futures.add(this.dumpRegistryCapFuture(
|
||||
cachedOutput,
|
||||
registryAccess,
|
||||
dynamicOps,
|
||||
(RegistryDataLoader.RegistryData) registryData
|
||||
));
|
||||
}
|
||||
return CompletableFuture.allOf(futures.toArray(CompletableFuture[]::new));
|
||||
}
|
||||
|
||||
private <T> CompletableFuture dumpRegistryCapFuture(
|
||||
CachedOutput cachedOutput,
|
||||
RegistryAccess registryAccess,
|
||||
DynamicOps<JsonElement> dynamicOps,
|
||||
RegistryDataLoader.RegistryData<T> registryData
|
||||
) {
|
||||
return CompletableFuture.runAsync(() -> dumpRegistryCap(
|
||||
cachedOutput,
|
||||
registryAccess,
|
||||
dynamicOps,
|
||||
registryData
|
||||
));
|
||||
}
|
||||
|
||||
private <T> void dumpRegistryCap(
|
||||
CachedOutput cachedOutput,
|
||||
RegistryAccess registryAccess,
|
||||
DynamicOps<JsonElement> dynamicOps,
|
||||
RegistryDataLoader.RegistryData<T> registryData
|
||||
) {
|
||||
ResourceKey<? extends Registry<T>> resourceKey = registryData.key();
|
||||
Registry<T> registry = registryAccess.registryOrThrow(resourceKey);
|
||||
PackOutput.PathProvider pathProvider = this.output.createPathProvider(
|
||||
PackOutput.Target.DATA_PACK,
|
||||
resourceKey.location().getPath()
|
||||
);
|
||||
for (Map.Entry<ResourceKey<T>, T> entry : registry.entrySet()) {
|
||||
dumpValue(
|
||||
pathProvider.json(entry.getKey().location()),
|
||||
cachedOutput,
|
||||
dynamicOps,
|
||||
registryData.elementCodec(),
|
||||
entry.getValue()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private static <E> void dumpValue(
|
||||
Path path,
|
||||
CachedOutput cachedOutput,
|
||||
DynamicOps<JsonElement> dynamicOps,
|
||||
Encoder<E> encoder,
|
||||
E object
|
||||
) {
|
||||
|
||||
Optional<JsonElement> optional = encoder.encodeStart(dynamicOps, object)
|
||||
.resultOrPartial(string -> WorldsTogether.LOGGER.error(
|
||||
"Couldn't serialize element {}: {}",
|
||||
path,
|
||||
string
|
||||
));
|
||||
if (optional.isPresent()) {
|
||||
DataProvider.saveStable(cachedOutput, optional.get(), path);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "BCL Registries";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -7,7 +7,8 @@ import org.betterx.bclib.api.v2.generator.GeneratorOptions;
|
|||
import org.betterx.bclib.api.v2.levelgen.LevelGenUtil;
|
||||
import org.betterx.bclib.config.Configs;
|
||||
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.core.HolderLookup;
|
||||
import net.minecraft.data.registries.VanillaRegistries;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.NbtOps;
|
||||
import net.minecraft.nbt.Tag;
|
||||
|
@ -41,7 +42,7 @@ final class BiomeSourcePatch extends ForcedLevelPatch {
|
|||
|
||||
final CompoundTag worldGenSettings = root.getCompound("Data").getCompound("WorldGenSettings");
|
||||
final CompoundTag dimensions = worldGenSettings.getCompound("dimensions");
|
||||
final RegistryAccess registryAccess = BuiltinRegistries.createAccess();
|
||||
final HolderLookup.Provider registryAccess = VanillaRegistries.createLookup();
|
||||
final RegistryOps<Tag> registryOps = RegistryOps.create(NbtOps.INSTANCE, registryAccess);
|
||||
|
||||
|
||||
|
@ -82,7 +83,7 @@ final class BiomeSourcePatch extends ForcedLevelPatch {
|
|||
private boolean checkDimension(
|
||||
CompoundTag worldGenSettings,
|
||||
CompoundTag dimensions,
|
||||
RegistryAccess registryAccess,
|
||||
HolderLookup.Provider registryAccess,
|
||||
RegistryOps<Tag> registryOps,
|
||||
ResourceKey<LevelStem> dimensionKey
|
||||
) {
|
||||
|
|
|
@ -3,6 +3,7 @@ package org.betterx.bclib.api.v2;
|
|||
import org.betterx.bclib.api.v2.datafixer.DataFixerAPI;
|
||||
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
|
@ -106,7 +107,7 @@ public class LifeCycleAPI {
|
|||
));
|
||||
|
||||
final long seed = world.getSeed();
|
||||
final Registry<Biome> biomeRegistry = world.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY);
|
||||
final Registry<Biome> biomeRegistry = world.registryAccess().registryOrThrow(Registries.BIOME);
|
||||
onLoadLevelBiomes.forEach(c -> c.onLoad(world, seed, biomeRegistry));
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ import org.betterx.worlds.together.tag.v3.MineableTags;
|
|||
import org.betterx.worlds.together.tag.v3.TagManager;
|
||||
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.tags.TagKey;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
|
|
|
@ -7,6 +7,7 @@ import org.betterx.bclib.items.complex.EquipmentSet;
|
|||
|
||||
import net.minecraft.advancements.*;
|
||||
import net.minecraft.advancements.critereon.*;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.data.recipes.RecipeBuilder;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
|
|
|
@ -9,7 +9,7 @@ import org.betterx.worlds.together.world.BiomeSourceWithNoiseRelatedSettings;
|
|||
import org.betterx.worlds.together.world.BiomeSourceWithSeed;
|
||||
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.HolderGetter;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.biome.BiomeSource;
|
||||
|
@ -23,13 +23,13 @@ import java.util.Set;
|
|||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class BCLBiomeSource extends BiomeSource implements BiomeSourceWithSeed, MergeableBiomeSource<BCLBiomeSource>, BiomeSourceWithNoiseRelatedSettings, BiomeSourceFromRegistry<BCLBiomeSource> {
|
||||
protected final Registry<Biome> biomeRegistry;
|
||||
protected final HolderGetter<Biome> biomeRegistry;
|
||||
private int registryModificationCounter;
|
||||
protected long currentSeed;
|
||||
protected int maxHeight;
|
||||
|
||||
private static List<Holder<Biome>> preInit(
|
||||
Registry<Biome> biomeRegistry,
|
||||
HolderGetter<Biome> biomeRegistry,
|
||||
List<Holder<Biome>> biomes
|
||||
) {
|
||||
biomes = biomes.stream().sorted(Comparator.comparing(holder -> holder.unwrapKey()
|
||||
|
@ -41,7 +41,7 @@ public abstract class BCLBiomeSource extends BiomeSource implements BiomeSourceW
|
|||
}
|
||||
|
||||
protected BCLBiomeSource(
|
||||
Registry<Biome> biomeRegistry,
|
||||
HolderGetter<Biome> biomeRegistry,
|
||||
List<Holder<Biome>> list,
|
||||
long seed
|
||||
) {
|
||||
|
@ -103,15 +103,16 @@ public abstract class BCLBiomeSource extends BiomeSource implements BiomeSourceW
|
|||
}
|
||||
|
||||
protected static List<Holder<Biome>> getBiomes(
|
||||
Registry<Biome> biomeRegistry,
|
||||
HolderGetter<Biome> biomeRegistry,
|
||||
List<String> exclude,
|
||||
List<String> include,
|
||||
BCLibNetherBiomeSource.ValidBiomePredicate test
|
||||
) {
|
||||
return biomeRegistry.stream()
|
||||
//TODO: 1.19.3 restore this code
|
||||
return List.of();/*biomeRegistry.stream()
|
||||
.filter(biome -> biomeRegistry.getResourceKey(biome).isPresent())
|
||||
|
||||
.map(biome -> (Holder<Biome>) biomeRegistry.getOrCreateHolderOrThrow(
|
||||
.map(biome -> (Holder<Biome>) biomeRegistry.getHolderOrThrow(
|
||||
biomeRegistry.getResourceKey(biome).get())
|
||||
)
|
||||
.filter(biome -> {
|
||||
|
@ -122,7 +123,7 @@ public abstract class BCLBiomeSource extends BiomeSource implements BiomeSourceW
|
|||
|
||||
return test.isValid(biome, location);
|
||||
})
|
||||
.toList();
|
||||
.toList();*/
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -135,7 +136,8 @@ public abstract class BCLBiomeSource extends BiomeSource implements BiomeSourceW
|
|||
this.setMaxHeight(generator.noiseSettings().height());
|
||||
}
|
||||
|
||||
public Registry<Biome> getBiomeRegistry() {
|
||||
@Override
|
||||
public HolderGetter<Biome> getBiomeRegistry() {
|
||||
return biomeRegistry;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,13 +15,13 @@ import org.betterx.worlds.together.world.BiomeSourceWithNoiseRelatedSettings;
|
|||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.HolderGetter;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.data.BuiltinRegistries;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.data.worldgen.BootstapContext;
|
||||
import net.minecraft.data.worldgen.SurfaceRuleData;
|
||||
import net.minecraft.resources.RegistryOps;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.biome.BiomeGenerationSettings;
|
||||
import net.minecraft.world.level.biome.BiomeSource;
|
||||
|
@ -31,8 +31,6 @@ import net.minecraft.world.level.chunk.ChunkGenerator;
|
|||
import net.minecraft.world.level.dimension.DimensionType;
|
||||
import net.minecraft.world.level.dimension.LevelStem;
|
||||
import net.minecraft.world.level.levelgen.*;
|
||||
import net.minecraft.world.level.levelgen.structure.StructureSet;
|
||||
import net.minecraft.world.level.levelgen.synth.NormalNoise;
|
||||
|
||||
import com.google.common.base.Suppliers;
|
||||
|
||||
|
@ -43,11 +41,6 @@ public class BCLChunkGenerator extends NoiseBasedChunkGenerator implements Resto
|
|||
|
||||
public static final Codec<BCLChunkGenerator> CODEC = RecordCodecBuilder
|
||||
.create((RecordCodecBuilder.Instance<BCLChunkGenerator> builderInstance) -> {
|
||||
final RecordCodecBuilder<BCLChunkGenerator, Registry<NormalNoise.NoiseParameters>> noiseGetter = RegistryOps
|
||||
.retrieveRegistry(
|
||||
Registry.NOISE_REGISTRY)
|
||||
.forGetter(
|
||||
BCLChunkGenerator::getNoises);
|
||||
|
||||
RecordCodecBuilder<BCLChunkGenerator, BiomeSource> biomeSourceCodec = BiomeSource.CODEC
|
||||
.fieldOf("biome_source")
|
||||
|
@ -58,26 +51,22 @@ public class BCLChunkGenerator extends NoiseBasedChunkGenerator implements Resto
|
|||
.forGetter((BCLChunkGenerator generator) -> generator.generatorSettings());
|
||||
|
||||
|
||||
return NoiseBasedChunkGenerator
|
||||
.commonCodec(builderInstance)
|
||||
.and(builderInstance.group(noiseGetter, biomeSourceCodec, settingsCodec))
|
||||
.apply(builderInstance, builderInstance.stable(BCLChunkGenerator::new));
|
||||
return builderInstance.group(biomeSourceCodec, settingsCodec)
|
||||
.apply(builderInstance, builderInstance.stable(BCLChunkGenerator::new));
|
||||
});
|
||||
protected static final NoiseSettings NETHER_NOISE_SETTINGS_AMPLIFIED = NoiseSettings.create(0, 256, 1, 4);
|
||||
public static final ResourceKey<NoiseGeneratorSettings> AMPLIFIED_NETHER = ResourceKey.create(
|
||||
Registry.NOISE_GENERATOR_SETTINGS_REGISTRY,
|
||||
Registries.NOISE_SETTINGS,
|
||||
BCLib.makeID("amplified_nether")
|
||||
);
|
||||
|
||||
public final BiomeSource initialBiomeSource;
|
||||
|
||||
public BCLChunkGenerator(
|
||||
Registry<StructureSet> registry,
|
||||
Registry<NormalNoise.NoiseParameters> registry2,
|
||||
BiomeSource biomeSource,
|
||||
Holder<NoiseGeneratorSettings> holder
|
||||
) {
|
||||
super(registry, registry2, biomeSource, holder);
|
||||
super(biomeSource, holder);
|
||||
initialBiomeSource = biomeSource;
|
||||
if (biomeSource instanceof BiomeSourceWithNoiseRelatedSettings bcl) {
|
||||
bcl.onLoadGeneratorSettings(holder.value());
|
||||
|
@ -131,14 +120,6 @@ public class BCLChunkGenerator extends NoiseBasedChunkGenerator implements Resto
|
|||
return CODEC;
|
||||
}
|
||||
|
||||
|
||||
private Registry<NormalNoise.NoiseParameters> getNoises() {
|
||||
if (this instanceof NoiseGeneratorSettingsProvider p) {
|
||||
return p.bclib_getNoises();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "BCLib - Chunk Generator (" + Integer.toHexString(hashCode()) + ")";
|
||||
|
@ -150,18 +131,6 @@ public class BCLChunkGenerator extends NoiseBasedChunkGenerator implements Resto
|
|||
public void appendFeaturesPerStep() {
|
||||
}
|
||||
|
||||
public static RandomState createRandomState(ServerLevel level, ChunkGenerator generator) {
|
||||
if (generator instanceof NoiseBasedChunkGenerator noiseBasedChunkGenerator) {
|
||||
return RandomState.create(
|
||||
noiseBasedChunkGenerator.generatorSettings().value(),
|
||||
level.registryAccess().registryOrThrow(Registry.NOISE_REGISTRY),
|
||||
level.getSeed()
|
||||
);
|
||||
} else {
|
||||
return RandomState.create(level.registryAccess(), NoiseGeneratorSettings.OVERWORLD, level.getSeed());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Registry<LevelStem> enforceGeneratorInWorldGenSettings(
|
||||
RegistryAccess access,
|
||||
|
@ -184,8 +153,6 @@ public class BCLChunkGenerator extends NoiseBasedChunkGenerator implements Resto
|
|||
}
|
||||
|
||||
referenceGenerator = new BCLChunkGenerator(
|
||||
generator.bclib_getStructureSetsRegistry(),
|
||||
noiseProvider.bclib_getNoises(),
|
||||
bs,
|
||||
buildGeneratorSettings(
|
||||
referenceProvider.bclib_getNoiseGeneratorSettingHolders(),
|
||||
|
@ -234,14 +201,16 @@ public class BCLChunkGenerator extends NoiseBasedChunkGenerator implements Resto
|
|||
}
|
||||
|
||||
|
||||
public static NoiseGeneratorSettings amplifiedNether() {
|
||||
public static NoiseGeneratorSettings amplifiedNether(BootstapContext<NoiseGeneratorSettings> bootstapContext) {
|
||||
HolderGetter<DensityFunction> densityGetter = bootstapContext.lookup(Registries.DENSITY_FUNCTION);
|
||||
return new NoiseGeneratorSettings(
|
||||
NETHER_NOISE_SETTINGS_AMPLIFIED,
|
||||
Blocks.NETHERRACK.defaultBlockState(),
|
||||
Blocks.LAVA.defaultBlockState(),
|
||||
NoiseRouterData.noNewCaves(
|
||||
BuiltinRegistries.DENSITY_FUNCTION,
|
||||
NoiseRouterData.slideNetherLike(BuiltinRegistries.DENSITY_FUNCTION, 0, 256)
|
||||
densityGetter,
|
||||
bootstapContext.lookup(Registries.NOISE),
|
||||
NoiseRouterData.slideNetherLike(densityGetter, 0, 256)
|
||||
),
|
||||
SurfaceRuleData.nether(),
|
||||
List.of(),
|
||||
|
|
|
@ -13,10 +13,9 @@ import org.betterx.worlds.together.biomesource.ReloadableBiomeSource;
|
|||
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.QuartPos;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.SectionPos;
|
||||
import net.minecraft.core.*;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.resources.RegistryOps;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
@ -38,8 +37,7 @@ public class BCLibEndBiomeSource extends BCLBiomeSource implements BiomeSourceWi
|
|||
public static Codec<BCLibEndBiomeSource> CODEC
|
||||
= RecordCodecBuilder.create((instance) -> instance.group(
|
||||
RegistryOps
|
||||
.retrieveRegistry(Registry.BIOME_REGISTRY)
|
||||
.forGetter((theEndBiomeSource) -> theEndBiomeSource.biomeRegistry),
|
||||
.retrieveElement(Registries.BIOME),
|
||||
Codec
|
||||
.LONG
|
||||
.fieldOf("seed")
|
||||
|
@ -70,16 +68,24 @@ public class BCLibEndBiomeSource extends BCLBiomeSource implements BiomeSourceWi
|
|||
|
||||
private BCLEndBiomeSourceConfig config;
|
||||
|
||||
public BCLibEndBiomeSource(Registry<Biome> biomeRegistry, long seed, BCLEndBiomeSourceConfig config) {
|
||||
private BCLibEndBiomeSource(
|
||||
Holder.Reference<Registry<Biome>> registryReference,
|
||||
long seed,
|
||||
BCLEndBiomeSourceConfig bclEndBiomeSourceConfig
|
||||
) {
|
||||
this(registryReference.value().asLookup(), seed, bclEndBiomeSourceConfig);
|
||||
}
|
||||
|
||||
private BCLibEndBiomeSource(HolderGetter<Biome> biomeRegistry, long seed, BCLEndBiomeSourceConfig config) {
|
||||
this(biomeRegistry, seed, config, true);
|
||||
}
|
||||
|
||||
public BCLibEndBiomeSource(Registry<Biome> biomeRegistry, BCLEndBiomeSourceConfig config) {
|
||||
public BCLibEndBiomeSource(HolderGetter<Biome> biomeRegistry, BCLEndBiomeSourceConfig config) {
|
||||
this(biomeRegistry, 0, config, false);
|
||||
}
|
||||
|
||||
private BCLibEndBiomeSource(
|
||||
Registry<Biome> biomeRegistry,
|
||||
HolderGetter<Biome> biomeRegistry,
|
||||
long seed,
|
||||
BCLEndBiomeSourceConfig config,
|
||||
boolean initMaps
|
||||
|
@ -88,7 +94,7 @@ public class BCLibEndBiomeSource extends BCLBiomeSource implements BiomeSourceWi
|
|||
}
|
||||
|
||||
private BCLibEndBiomeSource(
|
||||
Registry<Biome> biomeRegistry,
|
||||
HolderGetter<Biome> biomeRegistry,
|
||||
List<Holder<Biome>> list,
|
||||
long seed,
|
||||
BCLEndBiomeSourceConfig config,
|
||||
|
@ -105,6 +111,7 @@ public class BCLibEndBiomeSource extends BCLBiomeSource implements BiomeSourceWi
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
@NotNull
|
||||
private void rebuildBiomePickers() {
|
||||
var includeMap = Configs.BIOMES_CONFIG.getBiomeIncludeMap();
|
||||
|
@ -243,8 +250,8 @@ public class BCLibEndBiomeSource extends BCLBiomeSource implements BiomeSourceWi
|
|||
return new BCLibEndBiomeSource(
|
||||
this.biomeRegistry,
|
||||
datapackBiomes.stream()
|
||||
.filter(b -> b.isValidInRegistry(biomeRegistry) && b.unwrapKey()
|
||||
.orElse(null) != BCLBiomeRegistry.EMPTY_BIOME.getBiomeKey())
|
||||
.filter(b -> b.unwrapKey()
|
||||
.orElse(null) != BCLBiomeRegistry.EMPTY_BIOME.getBiomeKey())
|
||||
.toList(),
|
||||
this.currentSeed,
|
||||
this.config,
|
||||
|
@ -252,7 +259,7 @@ public class BCLibEndBiomeSource extends BCLBiomeSource implements BiomeSourceWi
|
|||
);
|
||||
}
|
||||
|
||||
private static List<Holder<Biome>> getNonVanillaBiomes(Registry<Biome> biomeRegistry) {
|
||||
private static List<Holder<Biome>> getNonVanillaBiomes(HolderGetter<Biome> biomeRegistry) {
|
||||
return getBiomes(
|
||||
biomeRegistry,
|
||||
Configs.BIOMES_CONFIG.getExcludeMatching(BiomeAPI.BiomeType.END),
|
||||
|
@ -261,7 +268,7 @@ public class BCLibEndBiomeSource extends BCLBiomeSource implements BiomeSourceWi
|
|||
);
|
||||
}
|
||||
|
||||
private static List<Holder<Biome>> getBiomes(Registry<Biome> biomeRegistry) {
|
||||
private static List<Holder<Biome>> getBiomes(HolderGetter<Biome> biomeRegistry) {
|
||||
return getBiomes(
|
||||
biomeRegistry,
|
||||
Configs.BIOMES_CONFIG.getExcludeMatching(BiomeAPI.BiomeType.END),
|
||||
|
@ -293,7 +300,7 @@ public class BCLibEndBiomeSource extends BCLBiomeSource implements BiomeSourceWi
|
|||
}
|
||||
|
||||
public static void register() {
|
||||
Registry.register(Registry.BIOME_SOURCE, BCLib.makeID("end_biome_source"), CODEC);
|
||||
Registry.register(BuiltInRegistries.BIOME_SOURCE, BCLib.makeID("end_biome_source"), CODEC);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -16,7 +16,10 @@ import org.betterx.worlds.together.biomesource.ReloadableBiomeSource;
|
|||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.HolderGetter;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.resources.RegistryOps;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.tags.BiomeTags;
|
||||
|
@ -33,9 +36,7 @@ public class BCLibNetherBiomeSource extends BCLBiomeSource implements BiomeSourc
|
|||
public static final Codec<BCLibNetherBiomeSource> CODEC = RecordCodecBuilder
|
||||
.create(instance -> instance
|
||||
.group(
|
||||
RegistryOps
|
||||
.retrieveRegistry(Registry.BIOME_REGISTRY)
|
||||
.forGetter(source -> source.biomeRegistry),
|
||||
RegistryOps.retrieveElement(Registries.BIOME),
|
||||
Codec
|
||||
.LONG
|
||||
.fieldOf("seed")
|
||||
|
@ -55,16 +56,26 @@ public class BCLibNetherBiomeSource extends BCLBiomeSource implements BiomeSourc
|
|||
private BiomePicker biomePicker;
|
||||
private BCLNetherBiomeSourceConfig config;
|
||||
|
||||
public BCLibNetherBiomeSource(Registry<Biome> biomeRegistry, BCLNetherBiomeSourceConfig config) {
|
||||
|
||||
private BCLibNetherBiomeSource(
|
||||
Holder.Reference<Registry<Biome>> registryReference,
|
||||
long seed,
|
||||
BCLNetherBiomeSourceConfig bclNetherBiomeSourceConfig
|
||||
) {
|
||||
this(registryReference.value().asLookup(), seed, bclNetherBiomeSourceConfig);
|
||||
}
|
||||
|
||||
|
||||
public BCLibNetherBiomeSource(HolderGetter<Biome> biomeRegistry, BCLNetherBiomeSourceConfig config) {
|
||||
this(biomeRegistry, 0, config, false);
|
||||
}
|
||||
|
||||
public BCLibNetherBiomeSource(Registry<Biome> biomeRegistry, long seed, BCLNetherBiomeSourceConfig config) {
|
||||
private BCLibNetherBiomeSource(HolderGetter<Biome> biomeRegistry, long seed, BCLNetherBiomeSourceConfig config) {
|
||||
this(biomeRegistry, seed, config, true);
|
||||
}
|
||||
|
||||
private BCLibNetherBiomeSource(
|
||||
Registry<Biome> biomeRegistry,
|
||||
HolderGetter<Biome> biomeRegistry,
|
||||
long seed,
|
||||
BCLNetherBiomeSourceConfig config,
|
||||
boolean initMaps
|
||||
|
@ -73,7 +84,7 @@ public class BCLibNetherBiomeSource extends BCLBiomeSource implements BiomeSourc
|
|||
}
|
||||
|
||||
private BCLibNetherBiomeSource(
|
||||
Registry<Biome> biomeRegistry,
|
||||
HolderGetter<Biome> biomeRegistry,
|
||||
List<Holder<Biome>> list,
|
||||
long seed,
|
||||
BCLNetherBiomeSourceConfig config,
|
||||
|
@ -126,8 +137,8 @@ public class BCLibNetherBiomeSource extends BCLBiomeSource implements BiomeSourc
|
|||
return new BCLibNetherBiomeSource(
|
||||
this.biomeRegistry,
|
||||
datapackBiomes.stream()
|
||||
.filter(b -> b.isValidInRegistry(biomeRegistry) && b.unwrapKey()
|
||||
.orElse(null) != BCLBiomeRegistry.EMPTY_BIOME.getBiomeKey())
|
||||
.filter(b -> b.unwrapKey()
|
||||
.orElse(null) != BCLBiomeRegistry.EMPTY_BIOME.getBiomeKey())
|
||||
.toList(),
|
||||
this.currentSeed,
|
||||
config,
|
||||
|
@ -135,7 +146,7 @@ public class BCLibNetherBiomeSource extends BCLBiomeSource implements BiomeSourc
|
|||
);
|
||||
}
|
||||
|
||||
private static List<Holder<Biome>> getNonVanillaBiomes(Registry<Biome> biomeRegistry) {
|
||||
private static List<Holder<Biome>> getNonVanillaBiomes(HolderGetter<Biome> biomeRegistry) {
|
||||
List<String> include = Configs.BIOMES_CONFIG.getIncludeMatching(BiomeAPI.BiomeType.NETHER);
|
||||
List<String> exclude = Configs.BIOMES_CONFIG.getExcludeMatching(BiomeAPI.BiomeType.NETHER);
|
||||
|
||||
|
@ -143,7 +154,7 @@ public class BCLibNetherBiomeSource extends BCLBiomeSource implements BiomeSourc
|
|||
}
|
||||
|
||||
|
||||
private static List<Holder<Biome>> getBiomes(Registry<Biome> biomeRegistry) {
|
||||
private static List<Holder<Biome>> getBiomes(HolderGetter<Biome> biomeRegistry) {
|
||||
List<String> include = Configs.BIOMES_CONFIG.getIncludeMatching(BiomeAPI.BiomeType.NETHER);
|
||||
List<String> exclude = Configs.BIOMES_CONFIG.getExcludeMatching(BiomeAPI.BiomeType.NETHER);
|
||||
|
||||
|
@ -170,7 +181,7 @@ public class BCLibNetherBiomeSource extends BCLBiomeSource implements BiomeSourc
|
|||
}
|
||||
|
||||
public static void register() {
|
||||
Registry.register(Registry.BIOME_SOURCE, BCLib.makeID("nether_biome_source"), CODEC);
|
||||
Registry.register(BuiltInRegistries.BIOME_SOURCE, BCLib.makeID("nether_biome_source"), CODEC);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import org.betterx.bclib.api.v2.levelgen.biomes.BCLBiome;
|
|||
import org.betterx.bclib.api.v2.levelgen.biomes.BiomeAPI;
|
||||
import org.betterx.bclib.interfaces.BiomeMap;
|
||||
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.HolderGetter;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.biome.BiomeSource;
|
||||
|
@ -84,7 +84,7 @@ public abstract class BiomeDecider {
|
|||
* @param predicate A predicate that decides if a given Biome can be provided by this decider
|
||||
*/
|
||||
protected BiomeDecider(
|
||||
Registry<Biome> biomeRegistry, BiomePredicate predicate
|
||||
HolderGetter<Biome> biomeRegistry, BiomePredicate predicate
|
||||
) {
|
||||
this.predicate = predicate;
|
||||
this.map = null;
|
||||
|
|
|
@ -6,7 +6,8 @@ import org.betterx.bclib.util.WeighTree;
|
|||
import org.betterx.bclib.util.WeightedList;
|
||||
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.HolderGetter;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.levelgen.WorldgenRandom;
|
||||
|
@ -20,17 +21,17 @@ import java.util.Objects;
|
|||
|
||||
public class BiomePicker {
|
||||
private final Map<BCLBiome, ActualBiome> all = new HashMap<>();
|
||||
public final Registry<Biome> biomeRegistry;
|
||||
public final HolderGetter<Biome> biomeRegistry;
|
||||
private final List<ActualBiome> biomes = Lists.newArrayList();
|
||||
private final List<String> allowedBiomes;
|
||||
public final ActualBiome fallbackBiome;
|
||||
private WeighTree<ActualBiome> tree;
|
||||
|
||||
public BiomePicker(Registry<Biome> biomeRegistry) {
|
||||
public BiomePicker(HolderGetter<Biome> biomeRegistry) {
|
||||
this(biomeRegistry, null);
|
||||
}
|
||||
|
||||
public BiomePicker(Registry<Biome> biomeRegistry, List<Holder<Biome>> allowedBiomes) {
|
||||
public BiomePicker(HolderGetter<Biome> biomeRegistry, List<Holder<Biome>> allowedBiomes) {
|
||||
this.biomeRegistry = biomeRegistry;
|
||||
this.allowedBiomes = allowedBiomes != null ? allowedBiomes
|
||||
.stream()
|
||||
|
@ -104,9 +105,13 @@ public class BiomePicker {
|
|||
all.put(bclBiome, this);
|
||||
this.bclBiome = bclBiome;
|
||||
|
||||
this.key = biomeRegistry.getResourceKey(biomeRegistry.get(bclBiome.getID())).orElse(null);
|
||||
this.biome = key != null ? biomeRegistry.getOrCreateHolderOrThrow(key) : null;
|
||||
this.isValid = key != null && biome != null && biome.isBound();
|
||||
//TODO: 1.19.3 is it ok to build the key?
|
||||
this.key = ResourceKey.create(
|
||||
Registries.BIOME,
|
||||
bclBiome.getID()
|
||||
);//biomeRegistry.getResourceKey(biomeRegistry.get(bclBiome.getID())).orElse(null);
|
||||
this.biome = key != null ? biomeRegistry.getOrThrow(key) : null;
|
||||
this.isValid = key != null && biome != null && biome.isBound() && biomeRegistry.get(key).isPresent();
|
||||
bclBiome.forEachSubBiome((b, w) -> {
|
||||
if (isAllowed(b))
|
||||
subbiomes.add(create(b), w);
|
||||
|
|
|
@ -2,7 +2,7 @@ package org.betterx.bclib.api.v2.generator;
|
|||
|
||||
import org.betterx.bclib.api.v2.levelgen.biomes.BiomeAPI;
|
||||
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.HolderGetter;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
|
||||
public abstract class TypeBiomeDecider extends BiomeDecider {
|
||||
|
@ -12,7 +12,7 @@ public abstract class TypeBiomeDecider extends BiomeDecider {
|
|||
this(null, assignedType);
|
||||
}
|
||||
|
||||
protected TypeBiomeDecider(Registry<Biome> biomeRegistry, BiomeAPI.BiomeType assignedType) {
|
||||
protected TypeBiomeDecider(HolderGetter<Biome> biomeRegistry, BiomeAPI.BiomeType assignedType) {
|
||||
super(biomeRegistry, (biome) -> biome.getIntendedType().is(assignedType));
|
||||
this.assignedType = assignedType;
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ import net.minecraft.core.Holder;
|
|||
import net.minecraft.core.MappedRegistry;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.world.level.chunk.ChunkGenerator;
|
||||
|
@ -41,8 +42,6 @@ public class LevelGenUtil {
|
|||
return new LevelStem(
|
||||
context.dimension,
|
||||
new BCLChunkGenerator(
|
||||
context.structureSets,
|
||||
context.noiseParameters,
|
||||
netherSource,
|
||||
context.generatorSettings
|
||||
)
|
||||
|
@ -54,8 +53,6 @@ public class LevelGenUtil {
|
|||
return new LevelStem(
|
||||
context.dimension,
|
||||
new BCLChunkGenerator(
|
||||
context.structureSets,
|
||||
context.noiseParameters,
|
||||
endSource,
|
||||
context.generatorSettings
|
||||
)
|
||||
|
@ -70,7 +67,7 @@ public class LevelGenUtil {
|
|||
Registry<LevelStem> dimensionRegistry,
|
||||
ChunkGenerator generator
|
||||
) {
|
||||
Registry<DimensionType> dimensionTypeRegistry = registryAccess.registryOrThrow(Registry.DIMENSION_TYPE_REGISTRY);
|
||||
Registry<DimensionType> dimensionTypeRegistry = registryAccess.registryOrThrow(Registries.DIMENSION_TYPE);
|
||||
Registry<LevelStem> newDimensions = withDimension(
|
||||
dimensionKey,
|
||||
dimensionTypeKey,
|
||||
|
@ -91,7 +88,7 @@ public class LevelGenUtil {
|
|||
|
||||
LevelStem levelStem = inputDimensions.get(dimensionKey);
|
||||
Holder<DimensionType> dimensionType = levelStem == null
|
||||
? dimensionTypeRegistry.getOrCreateHolderOrThrow(dimensionTypeKey)
|
||||
? dimensionTypeRegistry.getHolderOrThrow(dimensionTypeKey)
|
||||
: levelStem.type();
|
||||
return withDimension(dimensionKey, inputDimensions, new LevelStem(dimensionType, generator));
|
||||
}
|
||||
|
@ -102,7 +99,7 @@ public class LevelGenUtil {
|
|||
LevelStem levelStem
|
||||
) {
|
||||
MappedRegistry<LevelStem> writableRegistry = new MappedRegistry<>(
|
||||
Registry.LEVEL_STEM_REGISTRY,
|
||||
Registries.LEVEL_STEM,
|
||||
Lifecycle.experimental()
|
||||
);
|
||||
writableRegistry.register(
|
||||
|
|
|
@ -8,6 +8,7 @@ import com.mojang.serialization.Codec;
|
|||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.KeyDispatchDataCodec;
|
||||
|
@ -175,7 +176,7 @@ public class BCLBiome extends BCLBiomeSettings implements BiomeData {
|
|||
super(terrainHeight, fogDensity, genChance, edgeSize, vertical, edge.map(BiomeAPI::getBiome).orElse(null));
|
||||
biomeToRegister = null;
|
||||
this.biomeID = biomeID;
|
||||
this.biomeKey = ResourceKey.create(Registry.BIOME_REGISTRY, biomeID);
|
||||
this.biomeKey = ResourceKey.create(Registries.BIOME, biomeID);
|
||||
this.biomeParent = biomeParent.orElse(null);
|
||||
if (parameterPoints.isPresent()) this.parameterPoints.addAll(parameterPoints.get());
|
||||
this.setIntendedType(intendedType.map(t -> BiomeAPI.BiomeType.create(t)).orElse(BiomeAPI.BiomeType.NONE));
|
||||
|
@ -196,7 +197,7 @@ public class BCLBiome extends BCLBiomeSettings implements BiomeData {
|
|||
* @param biomeID {@link ResourceLocation} biome ID.
|
||||
*/
|
||||
protected BCLBiome(ResourceLocation biomeID) {
|
||||
this(ResourceKey.create(Registry.BIOME_REGISTRY, biomeID), null);
|
||||
this(ResourceKey.create(Registries.BIOME, biomeID), null);
|
||||
}
|
||||
|
||||
|
||||
|
@ -232,7 +233,7 @@ public class BCLBiome extends BCLBiomeSettings implements BiomeData {
|
|||
* @param defaults The Settings for this Biome or null if you want to apply the defaults
|
||||
*/
|
||||
protected BCLBiome(ResourceLocation biomeID, Biome biomeToRegister, BCLBiomeSettings defaults) {
|
||||
this(ResourceKey.create(Registry.BIOME_REGISTRY, biomeID), biomeToRegister, defaults);
|
||||
this(ResourceKey.create(Registries.BIOME, biomeID), biomeToRegister, defaults);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -15,7 +15,9 @@ import org.betterx.worlds.together.tag.v3.TagManager;
|
|||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.HolderSet;
|
||||
import net.minecraft.core.particles.ParticleOptions;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.data.worldgen.BiomeDefaultFeatures;
|
||||
import net.minecraft.data.worldgen.BootstapContext;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.sounds.Music;
|
||||
|
@ -42,13 +44,96 @@ import net.fabricmc.fabric.api.biome.v1.BiomeModifications;
|
|||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class BCLBiomeBuilder {
|
||||
public record Context(BootstapContext<Biome> bootstrapContext) {
|
||||
public BCLBiomeBuilder start(ResourceLocation biomeID) {
|
||||
return BCLBiomeBuilder.start(this, biomeID);
|
||||
}
|
||||
}
|
||||
|
||||
public static final class PreparedBiome<T extends BCLBiome> {
|
||||
private final T biome;
|
||||
private final Context context;
|
||||
|
||||
private PreparedBiome(T biome, Context context) {
|
||||
this.biome = biome;
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
public T registerEndLandBiome() {
|
||||
BiomeAPI.registerEndLandBiome(context.bootstrapContext, biome);
|
||||
return this.biome;
|
||||
}
|
||||
|
||||
public T registerEndVoidBiome() {
|
||||
BiomeAPI.registerEndVoidBiome(context.bootstrapContext, biome);
|
||||
return this.biome;
|
||||
}
|
||||
|
||||
public T registerEndBarrensBiome(BCLBiome highlandBiome) {
|
||||
BiomeAPI.registerEndBarrensBiome(context.bootstrapContext, highlandBiome, biome);
|
||||
return this.biome;
|
||||
}
|
||||
|
||||
public T registerEndCenterBiome() {
|
||||
BiomeAPI.registerEndCenterBiome(context.bootstrapContext, biome);
|
||||
return this.biome;
|
||||
}
|
||||
|
||||
public T registerNetherBiome() {
|
||||
BiomeAPI.registerNetherBiome(context.bootstrapContext, biome);
|
||||
return this.biome;
|
||||
}
|
||||
|
||||
public T registerSubBiome(BCLBiome parent) {
|
||||
BiomeAPI.registerSubBiome(context.bootstrapContext, parent, biome);
|
||||
return this.biome;
|
||||
}
|
||||
|
||||
public T registerSubBiome(BCLBiome parent, BiomeAPI.BiomeType dim) {
|
||||
BiomeAPI.registerSubBiome(context.bootstrapContext, parent, biome, dim);
|
||||
return this.biome;
|
||||
}
|
||||
|
||||
public T register(BiomeAPI.BiomeType dim) {
|
||||
BiomeAPI.registerBuiltinBiomeAndOverrideIntendedDimension(context.bootstrapContext, biome, dim);
|
||||
return this.biome;
|
||||
}
|
||||
|
||||
public BCLBiome biome() {
|
||||
return biome;
|
||||
}
|
||||
|
||||
public Context context() {
|
||||
return context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this) return true;
|
||||
if (obj == null || obj.getClass() != this.getClass()) return false;
|
||||
PreparedBiome that = (PreparedBiome) obj;
|
||||
return Objects.equals(this.biome, that.biome) &&
|
||||
Objects.equals(this.context, that.context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(biome, context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Registry[" +
|
||||
"biome=" + biome + ", " +
|
||||
"context=" + context + ']';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
public interface BiomeSupplier<T> extends TriFunction<ResourceLocation, Biome, BCLBiomeSettings, T> {
|
||||
}
|
||||
|
@ -68,6 +153,7 @@ public class BCLBiomeBuilder {
|
|||
private SurfaceRules.RuleSource surfaceRule;
|
||||
private Precipitation precipitation;
|
||||
private ResourceLocation biomeID;
|
||||
private Context builderContext;
|
||||
|
||||
private final Set<TagKey<Biome>> tags = Sets.newHashSet();
|
||||
|
||||
|
@ -91,7 +177,10 @@ public class BCLBiomeBuilder {
|
|||
* @param biomeID {@link ResourceLocation} biome identifier.
|
||||
* @return prepared {@link BCLBiomeBuilder} instance.
|
||||
*/
|
||||
public static BCLBiomeBuilder start(ResourceLocation biomeID) {
|
||||
private static BCLBiomeBuilder start(
|
||||
Context ctx,
|
||||
ResourceLocation biomeID
|
||||
) {
|
||||
INSTANCE.biomeID = biomeID;
|
||||
INSTANCE.precipitation = Precipitation.NONE;
|
||||
INSTANCE.generationSettings = null;
|
||||
|
@ -109,6 +198,7 @@ public class BCLBiomeBuilder {
|
|||
INSTANCE.parameters.clear();
|
||||
INSTANCE.tags.clear();
|
||||
INSTANCE.biomeType = null;
|
||||
INSTANCE.builderContext = ctx;
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
|
@ -498,7 +588,7 @@ public class BCLBiomeBuilder {
|
|||
* @param music {@link SoundEvent} to use.
|
||||
* @return same {@link BCLBiomeBuilder} instance.
|
||||
*/
|
||||
public BCLBiomeBuilder music(SoundEvent music) {
|
||||
public BCLBiomeBuilder music(Holder<SoundEvent> music) {
|
||||
return music(new Music(music, 600, 2400, true));
|
||||
}
|
||||
|
||||
|
@ -508,7 +598,7 @@ public class BCLBiomeBuilder {
|
|||
* @param loopSound {@link SoundEvent} to use as a loop.
|
||||
* @return same {@link BCLBiomeBuilder} instance.
|
||||
*/
|
||||
public BCLBiomeBuilder loop(SoundEvent loopSound) {
|
||||
public BCLBiomeBuilder loop(Holder<SoundEvent> loopSound) {
|
||||
getEffects().ambientLoopSound(loopSound);
|
||||
return this;
|
||||
}
|
||||
|
@ -522,7 +612,7 @@ public class BCLBiomeBuilder {
|
|||
* @param soundPositionOffset offset in sound.
|
||||
* @return same {@link BCLBiomeBuilder} instance.
|
||||
*/
|
||||
public BCLBiomeBuilder mood(SoundEvent mood, int tickDelay, int blockSearchExtent, float soundPositionOffset) {
|
||||
public BCLBiomeBuilder mood(Holder<SoundEvent> mood, int tickDelay, int blockSearchExtent, float soundPositionOffset) {
|
||||
getEffects().ambientMoodSound(new AmbientMoodSettings(mood, tickDelay, blockSearchExtent, soundPositionOffset));
|
||||
return this;
|
||||
}
|
||||
|
@ -533,7 +623,7 @@ public class BCLBiomeBuilder {
|
|||
* @param mood {@link SoundEvent} to use as a mood.
|
||||
* @return same {@link BCLBiomeBuilder} instance.
|
||||
*/
|
||||
public BCLBiomeBuilder mood(SoundEvent mood) {
|
||||
public BCLBiomeBuilder mood(Holder<SoundEvent> mood) {
|
||||
return mood(mood, 6000, 8, 2.0F);
|
||||
}
|
||||
|
||||
|
@ -544,7 +634,7 @@ public class BCLBiomeBuilder {
|
|||
* @param intensity sound intensity. Default is 0.0111F.
|
||||
* @return same {@link BCLBiomeBuilder} instance.
|
||||
*/
|
||||
public BCLBiomeBuilder additions(SoundEvent additions, float intensity) {
|
||||
public BCLBiomeBuilder additions(Holder<SoundEvent> additions, float intensity) {
|
||||
getEffects().ambientAdditionsSound(new AmbientAdditionsSettings(additions, intensity));
|
||||
return this;
|
||||
}
|
||||
|
@ -555,7 +645,7 @@ public class BCLBiomeBuilder {
|
|||
* @param additions {@link SoundEvent} to use.
|
||||
* @return same {@link BCLBiomeBuilder} instance.
|
||||
*/
|
||||
public BCLBiomeBuilder additions(SoundEvent additions) {
|
||||
public BCLBiomeBuilder additions(Holder<SoundEvent> additions) {
|
||||
return additions(additions, 0.0111F);
|
||||
}
|
||||
|
||||
|
@ -838,8 +928,12 @@ public class BCLBiomeBuilder {
|
|||
* @return new or same {@link BiomeGenerationSettings.Builder} instance.
|
||||
*/
|
||||
private BiomeGenerationSettings.Builder getGeneration() {
|
||||
|
||||
if (generationSettings == null) {
|
||||
generationSettings = new BiomeGenerationSettings.Builder();
|
||||
generationSettings = new BiomeGenerationSettings.Builder(
|
||||
builderContext.bootstrapContext.lookup(Registries.PLACED_FEATURE),
|
||||
builderContext.bootstrapContext.lookup(Registries.CONFIGURED_CARVER)
|
||||
);
|
||||
}
|
||||
return generationSettings;
|
||||
}
|
||||
|
@ -849,8 +943,8 @@ public class BCLBiomeBuilder {
|
|||
*
|
||||
* @return created {@link BCLBiome} instance.
|
||||
*/
|
||||
public BCLBiome build() {
|
||||
return build((BiomeSupplier<BCLBiome>) BCLBiome::new);
|
||||
public PreparedBiome<BCLBiome> build() {
|
||||
return build(BCLBiome::new);
|
||||
}
|
||||
|
||||
|
||||
|
@ -860,7 +954,7 @@ public class BCLBiomeBuilder {
|
|||
* @param biomeConstructor {@link BiomeSupplier} biome constructor.
|
||||
* @return created {@link BCLBiome} instance.
|
||||
*/
|
||||
public <T extends BCLBiome> T build(BiomeSupplier<T> biomeConstructor) {
|
||||
public <T extends BCLBiome> PreparedBiome<T> build(BiomeSupplier<T> biomeConstructor) {
|
||||
BiomeBuilder builder = new BiomeBuilder()
|
||||
.precipitation(precipitation)
|
||||
.temperature(temperature)
|
||||
|
@ -893,6 +987,6 @@ public class BCLBiomeBuilder {
|
|||
|
||||
|
||||
//carvers.forEach(cfg -> BiomeAPI.addBiomeCarver(biome, cfg.second, cfg.first));
|
||||
return res;
|
||||
return new PreparedBiome<>(res, builderContext);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,10 +6,10 @@ import org.betterx.worlds.together.world.event.WorldBootstrap;
|
|||
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.Lifecycle;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.MappedRegistry;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.KeyDispatchDataCodec;
|
||||
|
@ -26,11 +26,11 @@ public class BCLBiomeRegistry {
|
|||
public static final ResourceKey<Registry<Codec<? extends BCLBiome>>> BCL_BIOME_CODEC_REGISTRY =
|
||||
createRegistryKey(WorldsTogether.makeID("worldgen/betterx/biome_codec"));
|
||||
|
||||
public static Registry<Codec<? extends BCLBiome>> BIOME_CODECS = Registry.registerSimple(
|
||||
public static Registry<Codec<? extends BCLBiome>> BIOME_CODECS = BuiltInRegistries.registerSimple(
|
||||
BCL_BIOME_CODEC_REGISTRY,
|
||||
BCLBiomeRegistry::bootstrapCodecs
|
||||
);
|
||||
public static Registry<BCLBiome> BUILTIN_BCL_BIOMES = new MappedRegistry<>(
|
||||
public static MappedRegistry<BCLBiome> BUILTIN_BCL_BIOMES = new MappedRegistry<>(
|
||||
BCL_BIOMES_REGISTRY,
|
||||
Lifecycle.stable()
|
||||
);
|
||||
|
@ -95,38 +95,38 @@ public class BCLBiomeRegistry {
|
|||
|
||||
|
||||
@ApiStatus.Internal
|
||||
public static Holder<BCLBiome> bootstrap(Registry<BCLBiome> registry) {
|
||||
BuiltinRegistries.register(registry, BiomeAPI.SMALL_END_ISLANDS.getBCLBiomeKey(), BiomeAPI.SMALL_END_ISLANDS);
|
||||
BuiltinRegistries.register(registry, BiomeAPI.END_BARRENS.getBCLBiomeKey(), BiomeAPI.END_BARRENS);
|
||||
BuiltinRegistries.register(registry, BiomeAPI.END_HIGHLANDS.getBCLBiomeKey(), BiomeAPI.END_HIGHLANDS);
|
||||
BuiltinRegistries.register(registry, BiomeAPI.END_MIDLANDS.getBCLBiomeKey(), BiomeAPI.END_MIDLANDS);
|
||||
BuiltinRegistries.register(registry, BiomeAPI.THE_END.getBCLBiomeKey(), BiomeAPI.THE_END);
|
||||
BuiltinRegistries.register(
|
||||
public static BCLBiome bootstrap(Registry<BCLBiome> registry) {
|
||||
Registry.register(registry, BiomeAPI.SMALL_END_ISLANDS.getBCLBiomeKey(), BiomeAPI.SMALL_END_ISLANDS);
|
||||
Registry.register(registry, BiomeAPI.END_BARRENS.getBCLBiomeKey(), BiomeAPI.END_BARRENS);
|
||||
Registry.register(registry, BiomeAPI.END_HIGHLANDS.getBCLBiomeKey(), BiomeAPI.END_HIGHLANDS);
|
||||
Registry.register(registry, BiomeAPI.END_MIDLANDS.getBCLBiomeKey(), BiomeAPI.END_MIDLANDS);
|
||||
Registry.register(registry, BiomeAPI.THE_END.getBCLBiomeKey(), BiomeAPI.THE_END);
|
||||
Registry.register(
|
||||
registry,
|
||||
BiomeAPI.BASALT_DELTAS_BIOME.getBCLBiomeKey(),
|
||||
BiomeAPI.BASALT_DELTAS_BIOME
|
||||
);
|
||||
BuiltinRegistries.register(
|
||||
Registry.register(
|
||||
registry,
|
||||
BiomeAPI.SOUL_SAND_VALLEY_BIOME.getBCLBiomeKey(),
|
||||
BiomeAPI.SOUL_SAND_VALLEY_BIOME
|
||||
);
|
||||
BuiltinRegistries.register(
|
||||
Registry.register(
|
||||
registry,
|
||||
BiomeAPI.WARPED_FOREST_BIOME.getBCLBiomeKey(),
|
||||
BiomeAPI.WARPED_FOREST_BIOME
|
||||
);
|
||||
BuiltinRegistries.register(
|
||||
Registry.register(
|
||||
registry,
|
||||
BiomeAPI.CRIMSON_FOREST_BIOME.getBCLBiomeKey(),
|
||||
BiomeAPI.CRIMSON_FOREST_BIOME
|
||||
);
|
||||
BuiltinRegistries.register(
|
||||
Registry.register(
|
||||
registry,
|
||||
BiomeAPI.NETHER_WASTES_BIOME.getBCLBiomeKey(),
|
||||
BiomeAPI.NETHER_WASTES_BIOME
|
||||
);
|
||||
return BuiltinRegistries.register(registry, EMPTY_BIOME.getBCLBiomeKey(), EMPTY_BIOME);
|
||||
return Registry.register(registry, EMPTY_BIOME.getBCLBiomeKey(), EMPTY_BIOME);
|
||||
}
|
||||
|
||||
public static BCLBiome get(ResourceLocation loc) {
|
||||
|
|
|
@ -14,10 +14,10 @@ import com.mojang.serialization.Codec;
|
|||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.HolderGetter;
|
||||
import net.minecraft.core.HolderSet;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.data.worldgen.BootstapContext;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.tags.BiomeTags;
|
||||
|
@ -56,6 +56,7 @@ import org.jetbrains.annotations.NotNull;
|
|||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class BiomeAPI {
|
||||
|
||||
/**
|
||||
* Register {@link BCLBiome} instance and its {@link Biome} if necessary.
|
||||
*
|
||||
|
@ -63,17 +64,14 @@ public class BiomeAPI {
|
|||
* @param dim The Dimension fo rthis Biome
|
||||
* @return {@link BCLBiome}
|
||||
*/
|
||||
public static BCLBiome registerBuiltinBiomeAndOverrideIntendedDimension(BCLBiome bclbiome, BiomeType dim) {
|
||||
return registerBiomeAndOverrideIntendedDimension(bclbiome, dim, Registries.BIOME);
|
||||
}
|
||||
|
||||
static BCLBiome registerBiomeAndOverrideIntendedDimension(
|
||||
static BCLBiome registerBuiltinBiomeAndOverrideIntendedDimension(
|
||||
BootstapContext<Biome> bootstrapContext,
|
||||
BCLBiome bclbiome,
|
||||
BiomeType dim,
|
||||
Registry<Biome> registryOrNull
|
||||
BiomeType dim
|
||||
) {
|
||||
|
||||
bclbiome._setIntendedType(dim);
|
||||
return registerBiome(bclbiome, registryOrNull);
|
||||
return registerBiome(bootstrapContext, bclbiome);
|
||||
}
|
||||
|
||||
public static class BiomeType {
|
||||
|
@ -290,16 +288,22 @@ public class BiomeAPI {
|
|||
* @param bclbiome {@link BCLBiome}
|
||||
* @return {@link BCLBiome}
|
||||
*/
|
||||
static BCLBiome registerBiome(BCLBiome bclbiome, Registry<Biome> registryOrNull) {
|
||||
BiomeType dim = bclbiome.getIntendedType();
|
||||
static BCLBiome registerBiome(BootstapContext<Biome> bootstrapContext, BCLBiome bclbiome) {
|
||||
HolderGetter<Biome> registryOrNull = bootstrapContext.lookup(Registries.BIOME);
|
||||
if (registryOrNull != null
|
||||
&& bclbiome.biomeToRegister != null
|
||||
&& registryOrNull.get(bclbiome.getID()) == null) {
|
||||
Registry.register(registryOrNull, bclbiome.getBiomeKey(), bclbiome.biomeToRegister);
|
||||
//TODO: 1.19.3 this was a ResourceLocation lookup, is this a valid test?
|
||||
&& registryOrNull.get(bclbiome.getBiomeKey()).map(v -> v.isBound()).orElse(false) == false) {
|
||||
bootstrapContext.register(bclbiome.getBiomeKey(), bclbiome.biomeToRegister);
|
||||
|
||||
BCLBiomeRegistry.register(null, bclbiome);
|
||||
}
|
||||
|
||||
return finishBiomeRegistration(bclbiome);
|
||||
}
|
||||
|
||||
static BCLBiome finishBiomeRegistration(BCLBiome bclbiome) {
|
||||
BiomeType dim = bclbiome.getIntendedType();
|
||||
if (dim != null && dim.is(BiomeType.NETHER)) {
|
||||
TagManager.BIOMES.add(BiomeTags.IS_NETHER, bclbiome.getBiomeKey());
|
||||
TagManager.BIOMES.add(CommonBiomeTags.IN_NETHER, bclbiome.getBiomeKey());
|
||||
|
@ -313,16 +317,27 @@ public class BiomeAPI {
|
|||
return bclbiome;
|
||||
}
|
||||
|
||||
public static BCLBiome registerSubBiome(BCLBiome parent, BCLBiome subBiome) {
|
||||
static BCLBiome registerSubBiome(
|
||||
BootstapContext<Biome> bootstrapContext,
|
||||
BCLBiome parent,
|
||||
BCLBiome subBiome
|
||||
) {
|
||||
return registerSubBiome(
|
||||
bootstrapContext,
|
||||
parent,
|
||||
subBiome,
|
||||
parent.getIntendedType()
|
||||
);
|
||||
}
|
||||
|
||||
public static BCLBiome registerSubBiome(BCLBiome parent, Biome subBiome, float genChance) {
|
||||
static BCLBiome registerSubBiome(
|
||||
BootstapContext<Biome> bootstrapContext,
|
||||
BCLBiome parent,
|
||||
Biome subBiome,
|
||||
float genChance
|
||||
) {
|
||||
return registerSubBiome(
|
||||
bootstrapContext,
|
||||
parent,
|
||||
subBiome,
|
||||
genChance,
|
||||
|
@ -330,16 +345,27 @@ public class BiomeAPI {
|
|||
);
|
||||
}
|
||||
|
||||
public static BCLBiome registerSubBiome(BCLBiome parent, BCLBiome subBiome, BiomeType dim) {
|
||||
registerBuiltinBiomeAndOverrideIntendedDimension(subBiome, dim);
|
||||
static BCLBiome registerSubBiome(
|
||||
BootstapContext<Biome> bootstrapContext,
|
||||
BCLBiome parent,
|
||||
BCLBiome subBiome,
|
||||
BiomeType dim
|
||||
) {
|
||||
registerBuiltinBiomeAndOverrideIntendedDimension(bootstrapContext, subBiome, dim);
|
||||
parent.addSubBiome(subBiome);
|
||||
|
||||
return subBiome;
|
||||
}
|
||||
|
||||
public static BCLBiome registerSubBiome(BCLBiome parent, Biome biome, float genChance, BiomeType dim) {
|
||||
static BCLBiome registerSubBiome(
|
||||
BootstapContext<Biome> bootstrapContext,
|
||||
BCLBiome parent,
|
||||
Biome biome,
|
||||
float genChance,
|
||||
BiomeType dim
|
||||
) {
|
||||
BCLBiome subBiome = new BCLBiome(biome, VanillaBiomeSettings.createVanilla().setGenChance(genChance).build());
|
||||
return registerSubBiome(parent, subBiome, dim);
|
||||
return registerSubBiome(bootstrapContext, parent, subBiome, dim);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -349,8 +375,8 @@ public class BiomeAPI {
|
|||
* @param biome {@link BCLBiome}
|
||||
* @return {@link BCLBiome}
|
||||
*/
|
||||
public static BCLBiome registerEndLandBiome(BCLBiome biome) {
|
||||
registerBuiltinBiomeAndOverrideIntendedDimension(biome, BiomeType.BCL_END_LAND);
|
||||
static BCLBiome registerEndLandBiome(BootstapContext<Biome> bootstrapContext, BCLBiome biome) {
|
||||
registerBuiltinBiomeAndOverrideIntendedDimension(bootstrapContext, biome, BiomeType.BCL_END_LAND);
|
||||
|
||||
float weight = biome.getGenChance();
|
||||
ResourceKey<Biome> key = biome.getBiomeKey();
|
||||
|
@ -373,8 +399,8 @@ public class BiomeAPI {
|
|||
* @param biome {@link BCLBiome}
|
||||
* @return {@link BCLBiome}
|
||||
*/
|
||||
public static BCLBiome registerEndVoidBiome(BCLBiome biome) {
|
||||
registerBuiltinBiomeAndOverrideIntendedDimension(biome, BiomeType.BCL_END_VOID);
|
||||
static BCLBiome registerEndVoidBiome(BootstapContext<Biome> bootstrapContext, BCLBiome biome) {
|
||||
registerBuiltinBiomeAndOverrideIntendedDimension(bootstrapContext, biome, BiomeType.BCL_END_VOID);
|
||||
|
||||
float weight = biome.getGenChance();
|
||||
ResourceKey<Biome> key = biome.getBiomeKey();
|
||||
|
@ -392,8 +418,8 @@ public class BiomeAPI {
|
|||
* @param biome {@link BCLBiome}
|
||||
* @return {@link BCLBiome}
|
||||
*/
|
||||
public static BCLBiome registerEndCenterBiome(BCLBiome biome) {
|
||||
registerBuiltinBiomeAndOverrideIntendedDimension(biome, BiomeType.BCL_END_CENTER);
|
||||
static BCLBiome registerEndCenterBiome(BootstapContext<Biome> bootstrapContext, BCLBiome biome) {
|
||||
registerBuiltinBiomeAndOverrideIntendedDimension(bootstrapContext, biome, BiomeType.BCL_END_CENTER);
|
||||
|
||||
float weight = biome.getGenChance();
|
||||
ResourceKey<Biome> key = biome.getBiomeKey();
|
||||
|
@ -411,8 +437,12 @@ public class BiomeAPI {
|
|||
* @param biome {@link BCLBiome}
|
||||
* @return {@link BCLBiome}
|
||||
*/
|
||||
public static BCLBiome registerEndBarrensBiome(BCLBiome highlandBiome, BCLBiome biome) {
|
||||
registerBuiltinBiomeAndOverrideIntendedDimension(biome, BiomeType.BCL_END_BARRENS);
|
||||
static BCLBiome registerEndBarrensBiome(
|
||||
BootstapContext<Biome> bootstrapContext,
|
||||
BCLBiome highlandBiome,
|
||||
BCLBiome biome
|
||||
) {
|
||||
registerBuiltinBiomeAndOverrideIntendedDimension(bootstrapContext, biome, BiomeType.BCL_END_BARRENS);
|
||||
|
||||
float weight = biome.getGenChance();
|
||||
ResourceKey<Biome> key = biome.getBiomeKey();
|
||||
|
@ -431,8 +461,8 @@ public class BiomeAPI {
|
|||
* @param bclBiome {@link BCLBiome}
|
||||
* @return {@link BCLBiome}
|
||||
*/
|
||||
public static BCLBiome registerNetherBiome(BCLBiome bclBiome) {
|
||||
registerBuiltinBiomeAndOverrideIntendedDimension(bclBiome, BiomeType.BCL_NETHER);
|
||||
static BCLBiome registerNetherBiome(BootstapContext<Biome> bootstrapContext, BCLBiome bclBiome) {
|
||||
registerBuiltinBiomeAndOverrideIntendedDimension(bootstrapContext, bclBiome, BiomeType.BCL_NETHER);
|
||||
|
||||
ResourceKey<Biome> key = bclBiome.getBiomeKey();
|
||||
if (!bclBiome.isEdgeBiome()) {
|
||||
|
@ -451,7 +481,7 @@ public class BiomeAPI {
|
|||
BCLBiome endBiome = InternalBiomeAPI.CLIENT.get(biome);
|
||||
if (endBiome == null) {
|
||||
ResourceLocation id = WorldBootstrap.getLastRegistryAccessOrElseBuiltin()
|
||||
.registryOrThrow(Registry.BIOME_REGISTRY)
|
||||
.registryOrThrow(Registries.BIOME)
|
||||
.getKey(biome);
|
||||
endBiome = id == null
|
||||
? BCLBiomeRegistry.EMPTY_BIOME
|
||||
|
@ -473,9 +503,8 @@ public class BiomeAPI {
|
|||
Optional<ResourceKey<Biome>> key = InternalBiomeAPI.biomeRegistry.getResourceKey(biome);
|
||||
if (key.isPresent()) return key.get();
|
||||
}
|
||||
return BuiltInRegistries.BIOME
|
||||
.getResourceKey(biome)
|
||||
.orElseGet(null);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -490,7 +519,9 @@ public class BiomeAPI {
|
|||
id = InternalBiomeAPI.biomeRegistry.getKey(biome);
|
||||
}
|
||||
if (id == null) {
|
||||
id = BuiltinRegistries.BIOME.getKey(biome);
|
||||
final ResourceKey key = getBiomeKey(biome);
|
||||
if (key != null)
|
||||
id = key.location();
|
||||
}
|
||||
|
||||
if (id == null) {
|
||||
|
@ -531,7 +562,8 @@ public class BiomeAPI {
|
|||
if (InternalBiomeAPI.biomeRegistry != null) {
|
||||
key = InternalBiomeAPI.biomeRegistry.getResourceKey(biome);
|
||||
} else {
|
||||
key = BuiltinRegistries.BIOME.getResourceKey(biome);
|
||||
ResourceKey<Biome> kkey = getBiomeKey(biome);
|
||||
key = kkey == null ? Optional.empty() : Optional.of(kkey);
|
||||
}
|
||||
|
||||
return getBiomeHolder(key.orElseThrow());
|
||||
|
@ -539,13 +571,13 @@ public class BiomeAPI {
|
|||
|
||||
public static Holder<Biome> getBiomeHolder(ResourceKey<Biome> biomeKey) {
|
||||
if (InternalBiomeAPI.biomeRegistry != null) {
|
||||
return InternalBiomeAPI.biomeRegistry.getOrCreateHolderOrThrow(biomeKey);
|
||||
return InternalBiomeAPI.biomeRegistry.getHolderOrThrow(biomeKey);
|
||||
}
|
||||
return BuiltinRegistries.BIOME.getOrCreateHolderOrThrow(biomeKey);
|
||||
return null;//InternalBiomeAPI.BUILTIN_BIOMES.get(biomeKey).orElse(null);
|
||||
}
|
||||
|
||||
public static Holder<Biome> getBiomeHolder(ResourceLocation biome) {
|
||||
return getBiomeHolder(ResourceKey.create(Registry.BIOME_REGISTRY, biome));
|
||||
return getBiomeHolder(ResourceKey.create(Registries.BIOME, biome));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -591,7 +623,7 @@ public class BiomeAPI {
|
|||
|
||||
public static Holder<Biome> getFromRegistry(ResourceLocation biomeID) {
|
||||
if (InternalBiomeAPI.biomeRegistry != null)
|
||||
return InternalBiomeAPI.biomeRegistry.getHolder(ResourceKey.create(Registry.BIOME_REGISTRY, biomeID))
|
||||
return InternalBiomeAPI.biomeRegistry.getHolder(ResourceKey.create(Registries.BIOME, biomeID))
|
||||
.orElseThrow();
|
||||
return getFromBuiltinRegistry(biomeID);
|
||||
}
|
||||
|
@ -605,12 +637,12 @@ public class BiomeAPI {
|
|||
|
||||
@Nullable
|
||||
public static Holder<Biome> getFromBuiltinRegistry(ResourceLocation biomeID) {
|
||||
return BuiltinRegistries.BIOME.getHolder(ResourceKey.create(Registry.BIOME_REGISTRY, biomeID)).orElse(null);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static Holder<Biome> getFromBuiltinRegistry(ResourceKey<Biome> key) {
|
||||
return BuiltinRegistries.BIOME.getHolder(key).orElse(null);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -2,11 +2,12 @@ package org.betterx.bclib.api.v2.levelgen.biomes;
|
|||
|
||||
import org.betterx.bclib.BCLib;
|
||||
import org.betterx.bclib.config.Configs;
|
||||
import org.betterx.bclib.mixin.common.BiomeGenerationSettingsAccessor;
|
||||
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.HolderGetter;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.Level;
|
||||
|
@ -56,34 +57,13 @@ public class InternalBiomeAPI {
|
|||
static final Map<Biome, BCLBiome> CLIENT = Maps.newHashMap();
|
||||
static final Map<Holder<PlacedFeature>, Integer> FEATURE_ORDER = Maps.newHashMap();
|
||||
|
||||
static final Map<Registry<Biome>, AtomicInteger> BIOME_ADDITIONS = Maps.newHashMap();
|
||||
static final Map<HolderGetter<Biome>, AtomicInteger> BIOME_ADDITIONS = Maps.newHashMap();
|
||||
static final MutableInt FEATURE_ORDER_ID = new MutableInt(0);
|
||||
static final Map<ResourceKey<LevelStem>, List<BiConsumer<ResourceLocation, Holder<Biome>>>> MODIFICATIONS = Maps.newHashMap();
|
||||
static final Map<ResourceKey, List<BiConsumer<ResourceLocation, Holder<Biome>>>> TAG_ADDERS = Maps.newHashMap();
|
||||
static Registry<Biome> biomeRegistry;
|
||||
static RegistryAccess registryAccess;
|
||||
|
||||
static void initFeatureOrder() {
|
||||
if (!FEATURE_ORDER.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
BuiltinRegistries.BIOME
|
||||
.entrySet()
|
||||
.stream()
|
||||
.filter(entry -> entry
|
||||
.getKey()
|
||||
.location()
|
||||
.getNamespace()
|
||||
.equals("minecraft"))
|
||||
.map(Map.Entry::getValue)
|
||||
.map(biome -> (BiomeGenerationSettingsAccessor) biome.getGenerationSettings())
|
||||
.map(BiomeGenerationSettingsAccessor::bclib_getFeatures)
|
||||
.forEach(stepFeatureSuppliers -> stepFeatureSuppliers.forEach(step -> step.forEach(feature -> {
|
||||
FEATURE_ORDER.computeIfAbsent(feature, f -> FEATURE_ORDER_ID.getAndIncrement());
|
||||
})));
|
||||
}
|
||||
|
||||
public static RegistryAccess worldRegistryAccess() {
|
||||
return registryAccess;
|
||||
}
|
||||
|
@ -96,7 +76,7 @@ public class InternalBiomeAPI {
|
|||
public static void initRegistry(RegistryAccess access) {
|
||||
if (access != registryAccess) {
|
||||
registryAccess = access;
|
||||
Registry<Biome> biomeRegistry = access.registry(Registry.BIOME_REGISTRY).orElse(null);
|
||||
Registry<Biome> biomeRegistry = access.registry(Registries.BIOME).orElse(null);
|
||||
|
||||
if (biomeRegistry != InternalBiomeAPI.biomeRegistry) {
|
||||
InternalBiomeAPI.biomeRegistry = biomeRegistry;
|
||||
|
@ -274,7 +254,8 @@ public class InternalBiomeAPI {
|
|||
|
||||
static {
|
||||
DynamicRegistrySetupCallback.EVENT.register(registryManager -> {
|
||||
Optional<? extends Registry<Biome>> oBiomeRegistry = registryManager.registry(Registry.BIOME_REGISTRY);
|
||||
Optional<? extends Registry<Biome>> oBiomeRegistry = registryManager.asDynamicRegistryManager()
|
||||
.registry(Registries.BIOME);
|
||||
if (oBiomeRegistry.isPresent()) {
|
||||
RegistryEntryAddedCallback
|
||||
.event(oBiomeRegistry.get())
|
||||
|
@ -304,21 +285,11 @@ public class InternalBiomeAPI {
|
|||
* @param registry The registry you want to check
|
||||
* @return The current number of additions since the world creation was started
|
||||
*/
|
||||
public static int getBiomeRegistryModificationCount(Registry<Biome> registry) {
|
||||
public static int getBiomeRegistryModificationCount(HolderGetter<Biome> registry) {
|
||||
if (registry == null) return 0;
|
||||
return BIOME_ADDITIONS.computeIfAbsent(registry, reg -> new AtomicInteger(0)).get();
|
||||
}
|
||||
|
||||
public static boolean registryContainsBound(ResourceKey<Biome> key) {
|
||||
Registry<Biome> reg = biomeRegistry;
|
||||
if (reg == null) reg = BuiltinRegistries.BIOME;
|
||||
|
||||
if (reg.containsKey(key)) {
|
||||
return reg.getOrCreateHolderOrThrow(key).isBound();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void registerBCLBiomeData(BCLBiome biome) {
|
||||
try {
|
||||
BCLBiomeRegistry.register(registryAccess, biome);
|
||||
|
@ -336,7 +307,7 @@ public class InternalBiomeAPI {
|
|||
*/
|
||||
|
||||
public static BCLBiome registerBuiltinBiome(BCLBiome bclbiome) {
|
||||
return BiomeAPI.registerBiome(bclbiome, BuiltinRegistries.BIOME);
|
||||
return BiomeAPI.finishBiomeRegistration(bclbiome);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
package org.betterx.bclib.api.v2.levelgen.structures;
|
||||
|
||||
import org.betterx.bclib.api.v2.levelgen.biomes.BCLBiomeBuilder;
|
||||
import org.betterx.bclib.mixin.common.StructuresAccessor;
|
||||
|
||||
import com.mojang.serialization.Codec;
|
||||
import net.minecraft.core.*;
|
||||
import net.minecraft.data.worldgen.StructureSets;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.HolderSet;
|
||||
import net.minecraft.core.QuartPos;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.data.worldgen.BootstapContext;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.tags.TagKey;
|
||||
|
@ -39,7 +42,8 @@ public class BCLStructure<S extends Structure> {
|
|||
|
||||
|
||||
private static HolderSet<Biome> biomes(TagKey<Biome> tagKey) {
|
||||
return BuiltinRegistries.BIOME.getOrCreateTag(tagKey);
|
||||
//TODO:1.19.3 Refactor
|
||||
return null; //BuiltInRegistries.BIOME.getOrCreateTag(tagKey);
|
||||
}
|
||||
|
||||
private static Structure.StructureSettings structure(
|
||||
|
@ -60,10 +64,12 @@ public class BCLStructure<S extends Structure> {
|
|||
}
|
||||
|
||||
private static <S extends Structure> StructureType<S> registerStructureType(
|
||||
BootstapContext<StructureType<?>> bootstrapContext,
|
||||
ResourceLocation id,
|
||||
Codec<S> codec
|
||||
) {
|
||||
return Registry.register(Registry.STRUCTURE_TYPES, id, () -> codec);
|
||||
final ResourceKey<StructureType<?>> key = ResourceKey.create(Registries.STRUCTURE_TYPE, id);
|
||||
return (StructureType<S>) bootstrapContext.register(key, () -> (Codec<Structure>) codec).value();
|
||||
}
|
||||
|
||||
protected BCLStructure(
|
||||
|
@ -79,15 +85,18 @@ public class BCLStructure<S extends Structure> {
|
|||
this.featureStep = step;
|
||||
this.STRUCTURE_CODEC = codec;
|
||||
this.spreadConfig = placement;
|
||||
this.structureKey = ResourceKey.create(Registry.STRUCTURE_REGISTRY, id);
|
||||
this.structureSetKey = ResourceKey.create(Registry.STRUCTURE_SET_REGISTRY, id);
|
||||
this.structureKey = ResourceKey.create(Registries.STRUCTURE, id);
|
||||
this.structureSetKey = ResourceKey.create(Registries.STRUCTURE_SET, id);
|
||||
|
||||
this.structureType = registerStructureType(id, STRUCTURE_CODEC);
|
||||
//TODO:1.19.3 Refactor
|
||||
this.structureType = null; //registerStructureType(id, STRUCTURE_CODEC);
|
||||
|
||||
this.biomeTag = biomeTag;
|
||||
this.baseStructure = structureBuilder.apply(structure(this.biomeTag, featureStep, terrainAdjustment));
|
||||
this.structure = StructuresAccessor.callRegister(structureKey, this.baseStructure);
|
||||
StructureSets.register(structureSetKey, this.structure, spreadConfig);
|
||||
//TODO:1.19.3 Refactor
|
||||
this.structure = null; //StructuresAccessor.callRegister(structureKey, this.baseStructure);
|
||||
//TODO:1.19.3 Refactor
|
||||
//StructureSets.register(structureSetKey, this.structure, spreadConfig);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -3,6 +3,7 @@ package org.betterx.bclib.api.v2.levelgen.structures;
|
|||
import org.betterx.worlds.together.tag.v3.TagManager;
|
||||
|
||||
import com.mojang.serialization.Codec;
|
||||
import net.minecraft.data.worldgen.BootstapContext;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.tags.TagKey;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
|
@ -16,6 +17,10 @@ import net.minecraft.world.level.levelgen.structure.placement.StructurePlacement
|
|||
import java.util.function.Function;
|
||||
|
||||
public class BCLStructureBuilder<S extends Structure> {
|
||||
public record Context(BootstapContext<Structure> bootstrapContext) {
|
||||
|
||||
}
|
||||
|
||||
private static final BCLStructureBuilder INSTANCE = new BCLStructureBuilder();
|
||||
|
||||
private ResourceLocation structureID;
|
||||
|
|
|
@ -4,9 +4,8 @@ import org.betterx.bclib.BCLib;
|
|||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.BlockPos.MutableBlockPos;
|
||||
import net.minecraft.core.HolderLookup;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.Vec3i;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.NbtIo;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
@ -104,7 +103,8 @@ public class StructureNBT {
|
|||
CompoundTag nbttagcompound = NbtIo.readCompressed(stream);
|
||||
|
||||
StructureTemplate template = new StructureTemplate();
|
||||
template.load(HolderLookup.forRegistry(Registry.BLOCK), nbttagcompound);
|
||||
|
||||
template.load(BuiltInRegistries.BLOCK.asLookup(), nbttagcompound);
|
||||
|
||||
return template;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package org.betterx.bclib.api.v2.levelgen.structures;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.HolderLookup;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
|
@ -120,7 +119,7 @@ public class StructureWorld {
|
|||
BlockState[] states = new BlockState[map2.size()];
|
||||
for (int i = 0; i < states.length; i++) {
|
||||
states[i] = NbtUtils.readBlockState(
|
||||
HolderLookup.forRegistry(BuiltInRegistries.BLOCK),
|
||||
BuiltInRegistries.BLOCK.asLookup(),
|
||||
(CompoundTag) map2.get(i)
|
||||
);
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import net.minecraft.core.BlockPos;
|
|||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.Vec3i;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.RandomSource;
|
||||
|
@ -40,7 +41,7 @@ public class TemplatePiece extends TemplateStructurePiece {
|
|||
|
||||
|
||||
private static StructurePieceType setFullContextPieceId(StructurePieceType structurePieceType, String id) {
|
||||
return Registry.register(Registry.STRUCTURE_PIECE, BCLib.makeID(id), structurePieceType);
|
||||
return Registry.register(BuiltInRegistries.STRUCTURE_PIECE, BCLib.makeID(id), structurePieceType);
|
||||
}
|
||||
|
||||
private static StructurePieceType setTemplatePieceId(
|
||||
|
|
|
@ -5,6 +5,7 @@ import org.betterx.bclib.interfaces.NumericProvider;
|
|||
|
||||
import com.mojang.serialization.Codec;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.valueproviders.UniformFloat;
|
||||
import net.minecraft.world.level.levelgen.SurfaceRules;
|
||||
|
@ -71,7 +72,7 @@ public class Conditions {
|
|||
public static final NumericProvider NETHER_NOISE = new NetherNoiseCondition();
|
||||
|
||||
public static void register(ResourceLocation location, Codec<? extends SurfaceRules.ConditionSource> codec) {
|
||||
Registry.register(Registry.CONDITION, location, codec);
|
||||
Registry.register(BuiltInRegistries.MATERIAL_CONDITION, location, codec);
|
||||
}
|
||||
|
||||
public static void registerNumeric(ResourceLocation location, Codec<? extends NumericProvider> codec) {
|
||||
|
@ -85,6 +86,6 @@ public class Conditions {
|
|||
register(BCLib.makeID("volume_threshold_condition"), VolumeThresholdCondition.CODEC);
|
||||
register(BCLib.makeID("rough_noise_condition"), RoughNoiseCondition.CODEC);
|
||||
|
||||
Registry.register(Registry.RULE, "bclib_switch_rule", SwitchRuleSource.CODEC);
|
||||
Registry.register(BuiltInRegistries.MATERIAL_RULE, "bclib_switch_rule", SwitchRuleSource.CODEC);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ import org.betterx.bclib.noise.Noises;
|
|||
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.util.KeyDispatchDataCodec;
|
||||
import net.minecraft.util.RandomSource;
|
||||
|
@ -18,7 +18,7 @@ import net.minecraft.world.level.levelgen.synth.NormalNoise;
|
|||
public class RoughNoiseCondition implements SurfaceRules.ConditionSource {
|
||||
public static final Codec<RoughNoiseCondition> CODEC = RecordCodecBuilder.create(instance -> instance
|
||||
.group(
|
||||
ResourceKey.codec(Registry.NOISE_REGISTRY).fieldOf("noise").forGetter(o -> o.noise),
|
||||
ResourceKey.codec(Registries.NOISE).fieldOf("noise").forGetter(o -> o.noise),
|
||||
Codec.DOUBLE.fieldOf("min_threshold").forGetter(o -> o.minThreshold),
|
||||
Codec.DOUBLE.fieldOf("max_threshold").forGetter(o -> o.maxThreshold),
|
||||
FloatProvider.CODEC.fieldOf("roughness").forGetter(o -> o.roughness)
|
||||
|
|
|
@ -4,7 +4,8 @@ import org.betterx.bclib.api.v2.levelgen.biomes.InternalBiomeAPI;
|
|||
import org.betterx.worlds.together.tag.v3.CommonPoiTags;
|
||||
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.tags.TagKey;
|
||||
|
@ -23,13 +24,19 @@ public class PoiManager {
|
|||
int maxTickets,
|
||||
int validRanges
|
||||
) {
|
||||
ResourceKey<PoiType> key = ResourceKey.create(Registry.POINT_OF_INTEREST_TYPE_REGISTRY, location);
|
||||
PoiType type = PoiTypes.register(Registry.POINT_OF_INTEREST_TYPE, key, matchingStates, maxTickets, validRanges);
|
||||
ResourceKey<PoiType> key = ResourceKey.create(Registries.POINT_OF_INTEREST_TYPE, location);
|
||||
PoiType type = PoiTypes.register(
|
||||
BuiltInRegistries.POINT_OF_INTEREST_TYPE,
|
||||
key,
|
||||
matchingStates,
|
||||
maxTickets,
|
||||
validRanges
|
||||
);
|
||||
return new BCLPoiType(key, type, matchingStates, maxTickets, validRanges);
|
||||
}
|
||||
|
||||
public static void setTag(ResourceKey<PoiType> type, TagKey<Block> tag) {
|
||||
var oHolder = Registry.POINT_OF_INTEREST_TYPE.getHolder(type);
|
||||
var oHolder = BuiltInRegistries.POINT_OF_INTEREST_TYPE.getHolder(type);
|
||||
if (oHolder.isPresent()) {
|
||||
setTag(oHolder.get().value(), tag);
|
||||
didAddTagFor(oHolder.get(), tag);
|
||||
|
|
|
@ -5,8 +5,8 @@ import org.betterx.bclib.api.v3.levelgen.features.BCLConfigureFeature;
|
|||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.LevelReader;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.BonemealableBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
@ -18,7 +18,7 @@ public interface BonemealNyliumLike extends BonemealableBlock {
|
|||
BCLConfigureFeature<? extends Feature<?>, ?> getCoverFeature();
|
||||
|
||||
default boolean isValidBonemealTarget(
|
||||
BlockGetter blockGetter,
|
||||
LevelReader blockGetter,
|
||||
BlockPos blockPos,
|
||||
BlockState blockState,
|
||||
boolean bl
|
||||
|
|
|
@ -3,7 +3,7 @@ package org.betterx.bclib.api.v3.bonemeal;
|
|||
import org.betterx.bclib.api.v3.levelgen.features.BCLConfigureFeature;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.LevelReader;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.levelgen.feature.Feature;
|
||||
|
@ -19,7 +19,7 @@ public class FeatureSpreader implements BonemealNyliumLike {
|
|||
|
||||
@Override
|
||||
public boolean isValidBonemealTarget(
|
||||
BlockGetter blockGetter,
|
||||
LevelReader blockGetter,
|
||||
BlockPos blockPos,
|
||||
BlockState blockState,
|
||||
boolean bl
|
||||
|
|
|
@ -38,12 +38,12 @@ public class BCLConfigureFeature<F extends Feature<FC>, FC extends FeatureConfig
|
|||
}
|
||||
|
||||
|
||||
public BCLPlacedFeatureBuilder<F, FC> place() {
|
||||
return place(this.id);
|
||||
public BCLPlacedFeatureBuilder<F, FC> place(BCLPlacedFeatureBuilder.Context ctx) {
|
||||
return place(ctx, this.id);
|
||||
}
|
||||
|
||||
public BCLPlacedFeatureBuilder<F, FC> place(ResourceLocation id) {
|
||||
return BCLPlacedFeatureBuilder.place(id, this);
|
||||
public BCLPlacedFeatureBuilder<F, FC> place(BCLPlacedFeatureBuilder.Context ctx, ResourceLocation id) {
|
||||
return BCLPlacedFeatureBuilder.place(ctx, id, this);
|
||||
}
|
||||
|
||||
static <F extends Feature<FC>, FC extends FeatureConfiguration> BCLConfigureFeature<F, FC> create(Holder<ConfiguredFeature<FC, F>> registeredFeature) {
|
||||
|
|
|
@ -6,6 +6,7 @@ import org.betterx.bclib.api.v3.levelgen.features.features.*;
|
|||
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.levelgen.GenerationStep;
|
||||
import net.minecraft.world.level.levelgen.feature.Feature;
|
||||
|
@ -99,6 +100,6 @@ public class BCLFeature<F extends Feature<FC>, FC extends FeatureConfiguration>
|
|||
ResourceLocation location,
|
||||
F feature
|
||||
) {
|
||||
return Registry.register(Registry.FEATURE, location, feature);
|
||||
return Registry.register(BuiltInRegistries.FEATURE, location, feature);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,9 @@ import org.betterx.bclib.util.Triple;
|
|||
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.data.worldgen.BootstapContext;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.random.SimpleWeightedRandomList;
|
||||
import net.minecraft.util.valueproviders.ConstantInt;
|
||||
|
@ -39,188 +41,198 @@ import java.util.Collection;
|
|||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.function.BiFunction;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public abstract class BCLFeatureBuilder<F extends Feature<FC>, FC extends FeatureConfiguration> {
|
||||
@FunctionalInterface
|
||||
public interface HolderBuilder<F extends Feature<FC>, FC extends FeatureConfiguration> {
|
||||
Holder<ConfiguredFeature<FC, F>> apply(
|
||||
Context ctx,
|
||||
ResourceLocation id,
|
||||
ConfiguredFeature<FC, F> feature
|
||||
);
|
||||
}
|
||||
|
||||
public record Context(BootstapContext<ConfiguredFeature<?, ?>> bootstrapContext) {
|
||||
/**
|
||||
* Starts a new {@link BCLFeature} builder.
|
||||
*
|
||||
* @param featureID {@link ResourceLocation} feature identifier.
|
||||
* @param feature {@link Feature} to construct.
|
||||
* @return {@link BCLFeatureBuilder} instance.
|
||||
*/
|
||||
public <F extends Feature<FC>, FC extends FeatureConfiguration> WithConfiguration<F, FC> start(
|
||||
ResourceLocation featureID,
|
||||
F feature
|
||||
) {
|
||||
return new WithConfiguration<>(this, featureID, feature);
|
||||
}
|
||||
|
||||
public ForSimpleBlock start(
|
||||
ResourceLocation featureID,
|
||||
Block block
|
||||
) {
|
||||
return start(featureID, BlockStateProvider.simple(block));
|
||||
}
|
||||
|
||||
public ForSimpleBlock start(
|
||||
ResourceLocation featureID,
|
||||
BlockState state
|
||||
) {
|
||||
return start(featureID, BlockStateProvider.simple(state));
|
||||
}
|
||||
|
||||
public ForSimpleBlock start(
|
||||
ResourceLocation featureID,
|
||||
BlockStateProvider provider
|
||||
) {
|
||||
return new ForSimpleBlock(
|
||||
this,
|
||||
featureID,
|
||||
(SimpleBlockFeature) Feature.SIMPLE_BLOCK,
|
||||
provider
|
||||
);
|
||||
}
|
||||
|
||||
public WeightedBlock startWeighted(ResourceLocation featureID) {
|
||||
return new WeightedBlock(
|
||||
this,
|
||||
featureID,
|
||||
(SimpleBlockFeature) Feature.SIMPLE_BLOCK
|
||||
);
|
||||
}
|
||||
|
||||
public WeightedBlockPatch startWeightedRandomPatch(ResourceLocation featureID) {
|
||||
return new WeightedBlockPatch(
|
||||
this,
|
||||
featureID,
|
||||
(RandomPatchFeature) Feature.RANDOM_PATCH
|
||||
);
|
||||
}
|
||||
|
||||
public WeightedBlockPatch startBonemealPatch(
|
||||
ResourceLocation featureID
|
||||
) {
|
||||
return startWeightedRandomPatch(featureID).likeDefaultBonemeal();
|
||||
}
|
||||
|
||||
public RandomPatch startRandomPatch(
|
||||
ResourceLocation featureID,
|
||||
Holder<PlacedFeature> featureToPlace
|
||||
) {
|
||||
return new RandomPatch(
|
||||
this,
|
||||
featureID,
|
||||
(RandomPatchFeature) Feature.RANDOM_PATCH,
|
||||
featureToPlace
|
||||
);
|
||||
}
|
||||
|
||||
public AsRandomSelect startRandomSelect(
|
||||
ResourceLocation featureID
|
||||
) {
|
||||
return new AsRandomSelect(
|
||||
this,
|
||||
featureID,
|
||||
(RandomSelectorFeature) Feature.RANDOM_SELECTOR
|
||||
);
|
||||
}
|
||||
|
||||
public AsMultiPlaceRandomSelect startRandomSelect(
|
||||
ResourceLocation featureID,
|
||||
AsMultiPlaceRandomSelect.Placer placementModFunction
|
||||
) {
|
||||
return new AsMultiPlaceRandomSelect(
|
||||
this,
|
||||
featureID,
|
||||
(RandomSelectorFeature) Feature.RANDOM_SELECTOR,
|
||||
placementModFunction
|
||||
);
|
||||
}
|
||||
|
||||
public NetherForrestVegetation startNetherVegetation(
|
||||
ResourceLocation featureID
|
||||
) {
|
||||
return new NetherForrestVegetation(
|
||||
this,
|
||||
featureID,
|
||||
(NetherForestVegetationFeature) Feature.NETHER_FOREST_VEGETATION
|
||||
);
|
||||
}
|
||||
|
||||
public NetherForrestVegetation startBonemealNetherVegetation(ResourceLocation featureID) {
|
||||
return new NetherForrestVegetation(
|
||||
this,
|
||||
featureID,
|
||||
(NetherForestVegetationFeature) Feature.NETHER_FOREST_VEGETATION
|
||||
).spreadHeight(1).spreadWidth(3);
|
||||
}
|
||||
|
||||
public WithTemplates startWithTemplates(ResourceLocation featureID) {
|
||||
return new WithTemplates(
|
||||
this,
|
||||
featureID,
|
||||
(TemplateFeature<TemplateFeatureConfig>) BCLFeature.TEMPLATE
|
||||
);
|
||||
}
|
||||
|
||||
public AsBlockColumn<BlockColumnFeature> startColumn(ResourceLocation featureID) {
|
||||
return new AsBlockColumn<>(
|
||||
this,
|
||||
featureID,
|
||||
(BlockColumnFeature) Feature.BLOCK_COLUMN
|
||||
);
|
||||
}
|
||||
|
||||
public AsPillar startPillar(
|
||||
ResourceLocation featureID,
|
||||
PillarFeatureConfig.KnownTransformers transformer
|
||||
) {
|
||||
return new AsPillar(
|
||||
this,
|
||||
featureID,
|
||||
(PillarFeature) BCLFeature.PILLAR,
|
||||
transformer
|
||||
);
|
||||
}
|
||||
|
||||
public AsSequence startSequence(ResourceLocation featureID) {
|
||||
return new AsSequence(
|
||||
this,
|
||||
featureID,
|
||||
(SequenceFeature) BCLFeature.SEQUENCE
|
||||
);
|
||||
}
|
||||
|
||||
public AsOre startOre(ResourceLocation featureID) {
|
||||
return new AsOre(
|
||||
this,
|
||||
featureID,
|
||||
(OreFeature) Feature.ORE
|
||||
);
|
||||
}
|
||||
|
||||
public FacingBlock startFacing(ResourceLocation featureID) {
|
||||
return new FacingBlock(
|
||||
this,
|
||||
featureID,
|
||||
(PlaceBlockFeature<PlaceFacingBlockConfig>) BCLFeature.PLACE_BLOCK
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
protected final ResourceLocation featureID;
|
||||
private final F feature;
|
||||
|
||||
private BCLFeatureBuilder(ResourceLocation featureID, F feature) {
|
||||
protected final Context ctx;
|
||||
|
||||
private BCLFeatureBuilder(Context ctx, ResourceLocation featureID, F feature) {
|
||||
this.featureID = featureID;
|
||||
this.feature = feature;
|
||||
this.ctx = ctx;
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts a new {@link BCLFeature} builder.
|
||||
*
|
||||
* @param featureID {@link ResourceLocation} feature identifier.
|
||||
* @param feature {@link Feature} to construct.
|
||||
* @return {@link BCLFeatureBuilder} instance.
|
||||
*/
|
||||
public static <F extends Feature<FC>, FC extends FeatureConfiguration> WithConfiguration<F, FC> start(
|
||||
ResourceLocation featureID,
|
||||
F feature
|
||||
) {
|
||||
return new WithConfiguration<>(featureID, feature);
|
||||
}
|
||||
|
||||
public static ForSimpleBlock start(
|
||||
ResourceLocation featureID,
|
||||
Block block
|
||||
) {
|
||||
return start(featureID, BlockStateProvider.simple(block));
|
||||
}
|
||||
|
||||
public static ForSimpleBlock start(
|
||||
ResourceLocation featureID,
|
||||
BlockState state
|
||||
) {
|
||||
return start(featureID, BlockStateProvider.simple(state));
|
||||
}
|
||||
|
||||
public static ForSimpleBlock start(
|
||||
ResourceLocation featureID,
|
||||
BlockStateProvider provider
|
||||
) {
|
||||
return new ForSimpleBlock(
|
||||
featureID,
|
||||
(SimpleBlockFeature) Feature.SIMPLE_BLOCK,
|
||||
provider
|
||||
);
|
||||
}
|
||||
|
||||
public static WeightedBlock startWeighted(
|
||||
ResourceLocation featureID
|
||||
) {
|
||||
return new WeightedBlock(
|
||||
featureID,
|
||||
(SimpleBlockFeature) Feature.SIMPLE_BLOCK
|
||||
);
|
||||
}
|
||||
|
||||
public static WeightedBlockPatch startWeightedRandomPatch(
|
||||
ResourceLocation featureID
|
||||
) {
|
||||
return new WeightedBlockPatch(
|
||||
featureID,
|
||||
(RandomPatchFeature) Feature.RANDOM_PATCH
|
||||
);
|
||||
}
|
||||
|
||||
public static WeightedBlockPatch startBonemealPatch(
|
||||
ResourceLocation featureID
|
||||
) {
|
||||
return startWeightedRandomPatch(featureID).likeDefaultBonemeal();
|
||||
}
|
||||
|
||||
|
||||
public static RandomPatch startRandomPatch(
|
||||
ResourceLocation featureID,
|
||||
Holder<PlacedFeature> featureToPlace
|
||||
) {
|
||||
return new RandomPatch(
|
||||
featureID,
|
||||
(RandomPatchFeature) Feature.RANDOM_PATCH,
|
||||
featureToPlace
|
||||
);
|
||||
}
|
||||
|
||||
public static AsRandomSelect startRandomSelect(
|
||||
ResourceLocation featureID
|
||||
) {
|
||||
return new AsRandomSelect(
|
||||
featureID,
|
||||
(RandomSelectorFeature) Feature.RANDOM_SELECTOR
|
||||
);
|
||||
}
|
||||
|
||||
public static AsMultiPlaceRandomSelect startRandomSelect(
|
||||
ResourceLocation featureID,
|
||||
AsMultiPlaceRandomSelect.Placer placementModFunction
|
||||
) {
|
||||
return new AsMultiPlaceRandomSelect(
|
||||
featureID,
|
||||
(RandomSelectorFeature) Feature.RANDOM_SELECTOR,
|
||||
placementModFunction
|
||||
);
|
||||
}
|
||||
|
||||
public static NetherForrestVegetation startNetherVegetation(
|
||||
ResourceLocation featureID
|
||||
) {
|
||||
return new NetherForrestVegetation(
|
||||
featureID,
|
||||
(NetherForestVegetationFeature) Feature.NETHER_FOREST_VEGETATION
|
||||
);
|
||||
}
|
||||
|
||||
public static NetherForrestVegetation startBonemealNetherVegetation(
|
||||
ResourceLocation featureID
|
||||
) {
|
||||
return new NetherForrestVegetation(
|
||||
featureID,
|
||||
(NetherForestVegetationFeature) Feature.NETHER_FOREST_VEGETATION
|
||||
).spreadHeight(1).spreadWidth(3);
|
||||
}
|
||||
|
||||
|
||||
public static WithTemplates startWithTemplates(
|
||||
ResourceLocation featureID
|
||||
) {
|
||||
return new WithTemplates(
|
||||
featureID,
|
||||
(TemplateFeature<TemplateFeatureConfig>) org.betterx.bclib.api.v3.levelgen.features.BCLFeature.TEMPLATE
|
||||
);
|
||||
}
|
||||
|
||||
public static AsBlockColumn<BlockColumnFeature> startColumn(
|
||||
ResourceLocation featureID
|
||||
) {
|
||||
return new AsBlockColumn<>(
|
||||
featureID,
|
||||
(BlockColumnFeature) Feature.BLOCK_COLUMN
|
||||
);
|
||||
}
|
||||
|
||||
public static AsPillar startPillar(
|
||||
ResourceLocation featureID,
|
||||
PillarFeatureConfig.KnownTransformers transformer
|
||||
) {
|
||||
return new AsPillar(
|
||||
featureID,
|
||||
(PillarFeature) BCLFeature.PILLAR,
|
||||
transformer
|
||||
);
|
||||
}
|
||||
|
||||
public static AsSequence startSequence(
|
||||
ResourceLocation featureID
|
||||
) {
|
||||
return new AsSequence(
|
||||
featureID,
|
||||
(SequenceFeature) BCLFeature.SEQUENCE
|
||||
);
|
||||
}
|
||||
|
||||
public static AsOre startOre(
|
||||
ResourceLocation featureID
|
||||
) {
|
||||
return new AsOre(
|
||||
featureID,
|
||||
(OreFeature) Feature.ORE
|
||||
);
|
||||
}
|
||||
|
||||
public static FacingBlock startFacing(
|
||||
ResourceLocation featureID
|
||||
) {
|
||||
return new FacingBlock(
|
||||
featureID,
|
||||
(PlaceBlockFeature<PlaceFacingBlockConfig>) BCLFeature.PLACE_BLOCK
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Internally used by the builder. Normally you should not have to call this method directly as it is
|
||||
|
@ -233,25 +245,23 @@ public abstract class BCLFeatureBuilder<F extends Feature<FC>, FC extends Featur
|
|||
* @return The Holder for the new Feature
|
||||
*/
|
||||
public static <F extends Feature<FC>, FC extends FeatureConfiguration> Holder<ConfiguredFeature<FC, F>> register(
|
||||
Context ctx,
|
||||
ResourceLocation id,
|
||||
ConfiguredFeature<FC, F> cFeature
|
||||
) {
|
||||
return (Holder<ConfiguredFeature<FC, F>>) (Object) BuiltInRegistries.register(
|
||||
BuiltInRegistries.CONFIGURED_FEATURE,
|
||||
id,
|
||||
cFeature
|
||||
);
|
||||
ResourceKey<ConfiguredFeature<?, ?>> key = ResourceKey.create(Registries.CONFIGURED_FEATURE, id);
|
||||
return (Holder<ConfiguredFeature<FC, F>>) (Object) ctx.bootstrapContext.register(key, cFeature);
|
||||
}
|
||||
|
||||
public abstract FC createConfiguration();
|
||||
|
||||
protected BCLConfigureFeature<F, FC> buildAndRegister(BiFunction<ResourceLocation, ConfiguredFeature<FC, F>, Holder<ConfiguredFeature<FC, F>>> holderBuilder) {
|
||||
protected BCLConfigureFeature<F, FC> buildAndRegister(HolderBuilder<F, FC> holderBuilder) {
|
||||
FC config = createConfiguration();
|
||||
if (config == null) {
|
||||
throw new IllegalStateException("Feature configuration for " + featureID + " can not be null!");
|
||||
}
|
||||
ConfiguredFeature<FC, F> cFeature = new ConfiguredFeature<>(feature, config);
|
||||
Holder<ConfiguredFeature<FC, F>> holder = holderBuilder.apply(featureID, cFeature);
|
||||
Holder<ConfiguredFeature<FC, F>> holder = holderBuilder.apply(this.ctx, featureID, cFeature);
|
||||
return new BCLConfigureFeature<>(featureID, holder, true);
|
||||
}
|
||||
|
||||
|
@ -260,12 +270,12 @@ public abstract class BCLFeatureBuilder<F extends Feature<FC>, FC extends Featur
|
|||
}
|
||||
|
||||
public BCLConfigureFeature<F, FC> build() {
|
||||
return buildAndRegister((id, cFeature) -> Holder.direct(cFeature));
|
||||
return buildAndRegister((ctx, id, cFeature) -> Holder.direct(cFeature));
|
||||
}
|
||||
|
||||
public BCLInlinePlacedBuilder<F, FC> inlinePlace() {
|
||||
BCLConfigureFeature<F, FC> f = build();
|
||||
return BCLInlinePlacedBuilder.place(f);
|
||||
return BCLInlinePlacedBuilder.place(ctx, f);
|
||||
}
|
||||
|
||||
public Holder<PlacedFeature> inlinePlace(BCLInlinePlacedBuilder<F, FC> placer) {
|
||||
|
@ -278,8 +288,8 @@ public abstract class BCLFeatureBuilder<F extends Feature<FC>, FC extends Featur
|
|||
private int size = 6;
|
||||
private float discardChanceOnAirExposure = 0;
|
||||
|
||||
private AsOre(ResourceLocation featureID, OreFeature feature) {
|
||||
super(featureID, feature);
|
||||
private AsOre(Context ctx, ResourceLocation featureID, OreFeature feature) {
|
||||
super(ctx, featureID, feature);
|
||||
}
|
||||
|
||||
public AsOre add(Block containedIn, Block ore) {
|
||||
|
@ -328,11 +338,12 @@ public abstract class BCLFeatureBuilder<F extends Feature<FC>, FC extends Featur
|
|||
private BlockPredicate allowedPlacement = BlockPredicate.ONLY_IN_AIR_PREDICATE;
|
||||
|
||||
private AsPillar(
|
||||
ResourceLocation featureID,
|
||||
PillarFeature feature,
|
||||
PillarFeatureConfig.KnownTransformers transformer
|
||||
@NotNull Context ctx,
|
||||
@NotNull ResourceLocation featureID,
|
||||
@NotNull PillarFeature feature,
|
||||
@NotNull PillarFeatureConfig.KnownTransformers transformer
|
||||
) {
|
||||
super(featureID, feature);
|
||||
super(ctx, featureID, feature);
|
||||
this.transformer = transformer;
|
||||
}
|
||||
|
||||
|
@ -403,8 +414,12 @@ public abstract class BCLFeatureBuilder<F extends Feature<FC>, FC extends Featur
|
|||
public static class AsSequence extends BCLFeatureBuilder<SequenceFeature, SequenceFeatureConfig> {
|
||||
private final List<Holder<PlacedFeature>> features = new LinkedList<>();
|
||||
|
||||
private AsSequence(ResourceLocation featureID, SequenceFeature feature) {
|
||||
super(featureID, feature);
|
||||
private AsSequence(
|
||||
@NotNull Context ctx,
|
||||
@NotNull ResourceLocation featureID,
|
||||
@NotNull SequenceFeature feature
|
||||
) {
|
||||
super(ctx, featureID, feature);
|
||||
}
|
||||
|
||||
|
||||
|
@ -429,8 +444,12 @@ public abstract class BCLFeatureBuilder<F extends Feature<FC>, FC extends Featur
|
|||
private BlockPredicate allowedPlacement = BlockPredicate.ONLY_IN_AIR_PREDICATE;
|
||||
private boolean prioritizeTip = false;
|
||||
|
||||
private AsBlockColumn(ResourceLocation featureID, FF feature) {
|
||||
super(featureID, feature);
|
||||
private AsBlockColumn(
|
||||
@NotNull Context ctx,
|
||||
@NotNull ResourceLocation featureID,
|
||||
@NotNull FF feature
|
||||
) {
|
||||
super(ctx, featureID, feature);
|
||||
}
|
||||
|
||||
public AsBlockColumn<FF> add(int height, Block block) {
|
||||
|
@ -541,8 +560,12 @@ public abstract class BCLFeatureBuilder<F extends Feature<FC>, FC extends Featur
|
|||
public static class WithTemplates extends BCLFeatureBuilder<TemplateFeature<TemplateFeatureConfig>, TemplateFeatureConfig> {
|
||||
private final List<StructureWorldNBT> templates = new LinkedList<>();
|
||||
|
||||
private WithTemplates(ResourceLocation featureID, TemplateFeature<TemplateFeatureConfig> feature) {
|
||||
super(featureID, feature);
|
||||
private WithTemplates(
|
||||
@NotNull Context ctx,
|
||||
@NotNull ResourceLocation featureID,
|
||||
@NotNull TemplateFeature<TemplateFeatureConfig> feature
|
||||
) {
|
||||
super(ctx, featureID, feature);
|
||||
}
|
||||
|
||||
public WithTemplates add(
|
||||
|
@ -567,8 +590,12 @@ public abstract class BCLFeatureBuilder<F extends Feature<FC>, FC extends Featur
|
|||
private int spreadWidth = 8;
|
||||
private int spreadHeight = 4;
|
||||
|
||||
private NetherForrestVegetation(ResourceLocation featureID, NetherForestVegetationFeature feature) {
|
||||
super(featureID, feature);
|
||||
private NetherForrestVegetation(
|
||||
@NotNull Context ctx,
|
||||
@NotNull ResourceLocation featureID,
|
||||
@NotNull NetherForestVegetationFeature feature
|
||||
) {
|
||||
super(ctx, featureID, feature);
|
||||
}
|
||||
|
||||
public NetherForrestVegetation spreadWidth(int v) {
|
||||
|
@ -634,11 +661,12 @@ public abstract class BCLFeatureBuilder<F extends Feature<FC>, FC extends Featur
|
|||
private int ySpread = 3;
|
||||
|
||||
private RandomPatch(
|
||||
@NotNull Context ctx,
|
||||
@NotNull ResourceLocation featureID,
|
||||
@NotNull RandomPatchFeature feature,
|
||||
@NotNull Holder<PlacedFeature> featureToPlace
|
||||
) {
|
||||
super(featureID, feature);
|
||||
super(ctx, featureID, feature);
|
||||
this.featureToPlace = featureToPlace;
|
||||
}
|
||||
|
||||
|
@ -678,8 +706,12 @@ public abstract class BCLFeatureBuilder<F extends Feature<FC>, FC extends Featur
|
|||
public static class WithConfiguration<F extends Feature<FC>, FC extends FeatureConfiguration> extends BCLFeatureBuilder<F, FC> {
|
||||
private FC configuration;
|
||||
|
||||
private WithConfiguration(@NotNull ResourceLocation featureID, @NotNull F feature) {
|
||||
super(featureID, feature);
|
||||
private WithConfiguration(
|
||||
@NotNull Context ctx,
|
||||
@NotNull ResourceLocation featureID,
|
||||
@NotNull F feature
|
||||
) {
|
||||
super(ctx, featureID, feature);
|
||||
}
|
||||
|
||||
public WithConfiguration<F, FC> configuration(FC config) {
|
||||
|
@ -709,8 +741,12 @@ public abstract class BCLFeatureBuilder<F extends Feature<FC>, FC extends Featur
|
|||
private int count = 0;
|
||||
private List<Direction> directions = PlaceFacingBlockConfig.HORIZONTAL;
|
||||
|
||||
private FacingBlock(ResourceLocation featureID, PlaceBlockFeature<PlaceFacingBlockConfig> feature) {
|
||||
super(featureID, feature);
|
||||
private FacingBlock(
|
||||
@NotNull Context ctx,
|
||||
@NotNull ResourceLocation featureID,
|
||||
@NotNull PlaceBlockFeature<PlaceFacingBlockConfig> feature
|
||||
) {
|
||||
super(ctx, featureID, feature);
|
||||
}
|
||||
|
||||
|
||||
|
@ -784,11 +820,12 @@ public abstract class BCLFeatureBuilder<F extends Feature<FC>, FC extends Featur
|
|||
private final BlockStateProvider provider;
|
||||
|
||||
private ForSimpleBlock(
|
||||
@NotNull Context ctx,
|
||||
@NotNull ResourceLocation featureID,
|
||||
@NotNull SimpleBlockFeature feature,
|
||||
@NotNull BlockStateProvider provider
|
||||
) {
|
||||
super(featureID, feature);
|
||||
super(ctx, featureID, feature);
|
||||
this.provider = provider;
|
||||
}
|
||||
|
||||
|
@ -806,8 +843,12 @@ public abstract class BCLFeatureBuilder<F extends Feature<FC>, FC extends Featur
|
|||
private int xzSpread = 7;
|
||||
private int ySpread = 3;
|
||||
|
||||
protected WeightedBlockPatch(@NotNull ResourceLocation featureID, @NotNull RandomPatchFeature feature) {
|
||||
super(featureID, feature);
|
||||
protected WeightedBlockPatch(
|
||||
@NotNull Context ctx,
|
||||
@NotNull ResourceLocation featureID,
|
||||
@NotNull RandomPatchFeature feature
|
||||
) {
|
||||
super(ctx, featureID, feature);
|
||||
}
|
||||
|
||||
public WeightedBlockPatch isEmpty() {
|
||||
|
@ -862,7 +903,7 @@ public abstract class BCLFeatureBuilder<F extends Feature<FC>, FC extends Featur
|
|||
|
||||
@Override
|
||||
public RandomPatchConfiguration createConfiguration() {
|
||||
BCLInlinePlacedBuilder<Feature<SimpleBlockConfiguration>, SimpleBlockConfiguration> blockFeature = BCLFeatureBuilder
|
||||
BCLInlinePlacedBuilder<Feature<SimpleBlockConfiguration>, SimpleBlockConfiguration> blockFeature = ctx
|
||||
.start(
|
||||
new ResourceLocation(featureID.getNamespace(), "tmp_" + featureID.getPath()),
|
||||
Feature.SIMPLE_BLOCK
|
||||
|
@ -879,10 +920,11 @@ public abstract class BCLFeatureBuilder<F extends Feature<FC>, FC extends Featur
|
|||
|
||||
public static class WeightedBlock extends WeightedBaseBlock<SimpleBlockFeature, SimpleBlockConfiguration, WeightedBlock> {
|
||||
private WeightedBlock(
|
||||
@NotNull Context ctx,
|
||||
@NotNull ResourceLocation featureID,
|
||||
@NotNull SimpleBlockFeature feature
|
||||
) {
|
||||
super(featureID, feature);
|
||||
super(ctx, featureID, feature);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -923,10 +965,11 @@ public abstract class BCLFeatureBuilder<F extends Feature<FC>, FC extends Featur
|
|||
SimpleWeightedRandomList.Builder<BlockState> stateBuilder = SimpleWeightedRandomList.builder();
|
||||
|
||||
protected WeightedBaseBlock(
|
||||
@NotNull Context ctx,
|
||||
@NotNull ResourceLocation featureID,
|
||||
@NotNull F feature
|
||||
) {
|
||||
super(featureID, feature);
|
||||
super(ctx, featureID, feature);
|
||||
}
|
||||
|
||||
public W add(Block block, int weight) {
|
||||
|
@ -955,8 +998,12 @@ public abstract class BCLFeatureBuilder<F extends Feature<FC>, FC extends Featur
|
|||
private final List<WeightedPlacedFeature> features = new LinkedList<>();
|
||||
private Holder<PlacedFeature> defaultFeature;
|
||||
|
||||
private AsRandomSelect(ResourceLocation featureID, RandomSelectorFeature feature) {
|
||||
super(featureID, feature);
|
||||
private AsRandomSelect(
|
||||
@NotNull Context ctx,
|
||||
@NotNull ResourceLocation featureID,
|
||||
@NotNull RandomSelectorFeature feature
|
||||
) {
|
||||
super(ctx, featureID, feature);
|
||||
}
|
||||
|
||||
|
||||
|
@ -989,11 +1036,12 @@ public abstract class BCLFeatureBuilder<F extends Feature<FC>, FC extends Featur
|
|||
private final Placer modFunction;
|
||||
|
||||
private AsMultiPlaceRandomSelect(
|
||||
ResourceLocation featureID,
|
||||
RandomSelectorFeature feature,
|
||||
Placer mod
|
||||
@NotNull Context ctx,
|
||||
@NotNull ResourceLocation featureID,
|
||||
@NotNull RandomSelectorFeature feature,
|
||||
@NotNull Placer mod
|
||||
) {
|
||||
super(featureID, feature);
|
||||
super(ctx, featureID, feature);
|
||||
this.modFunction = mod;
|
||||
}
|
||||
|
||||
|
@ -1067,7 +1115,7 @@ public abstract class BCLFeatureBuilder<F extends Feature<FC>, FC extends Featur
|
|||
}
|
||||
|
||||
private Holder<PlacedFeature> place(BlockStateProvider p, int id) {
|
||||
var builder = BCLFeatureBuilder
|
||||
var builder = ctx
|
||||
.start(BCLib.makeID("temp_select_feature" + (featureCounter++)), p)
|
||||
.inlinePlace();
|
||||
return modFunction.place(builder, id);
|
||||
|
|
|
@ -11,8 +11,10 @@ import net.minecraft.world.level.levelgen.placement.PlacementModifier;
|
|||
|
||||
public class BCLInlinePlacedBuilder<F extends Feature<FC>, FC extends FeatureConfiguration> extends CommonPlacedFeatureBuilder<F, FC, BCLInlinePlacedBuilder<F, FC>> {
|
||||
private final BCLConfigureFeature<F, FC> cFeature;
|
||||
protected final BCLFeatureBuilder.Context ctx;
|
||||
|
||||
private BCLInlinePlacedBuilder(BCLConfigureFeature<F, FC> cFeature) {
|
||||
private BCLInlinePlacedBuilder(BCLFeatureBuilder.Context ctx, BCLConfigureFeature<F, FC> cFeature) {
|
||||
this.ctx = ctx;
|
||||
this.cFeature = cFeature;
|
||||
}
|
||||
|
||||
|
@ -23,10 +25,11 @@ public class BCLInlinePlacedBuilder<F extends Feature<FC>, FC extends FeatureCon
|
|||
* @return {@link CommonPlacedFeatureBuilder} instance.
|
||||
*/
|
||||
public static <F extends Feature<FC>, FC extends FeatureConfiguration> BCLInlinePlacedBuilder<F, FC> place(
|
||||
BCLFeatureBuilder.Context ctx,
|
||||
ResourceLocation featureID,
|
||||
Holder<ConfiguredFeature<FC, F>> holder
|
||||
) {
|
||||
return place(BCLConfigureFeature.create(holder));
|
||||
return place(ctx, BCLConfigureFeature.create(holder));
|
||||
}
|
||||
|
||||
|
||||
|
@ -37,9 +40,10 @@ public class BCLInlinePlacedBuilder<F extends Feature<FC>, FC extends FeatureCon
|
|||
* @return {@link CommonPlacedFeatureBuilder} instance.
|
||||
*/
|
||||
static <F extends Feature<FC>, FC extends FeatureConfiguration> BCLInlinePlacedBuilder<F, FC> place(
|
||||
BCLFeatureBuilder.Context ctx,
|
||||
BCLConfigureFeature<F, FC> cFeature
|
||||
) {
|
||||
return new BCLInlinePlacedBuilder(cFeature);
|
||||
return new BCLInlinePlacedBuilder(ctx, cFeature);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -68,7 +72,7 @@ public class BCLInlinePlacedBuilder<F extends Feature<FC>, FC extends FeatureCon
|
|||
*/
|
||||
public Holder<PlacedFeature> build(Holder<ConfiguredFeature<FC, F>> feature) {
|
||||
PlacementModifier[] modifiers = modifications.toArray(new PlacementModifier[modifications.size()]);
|
||||
return PlacementUtils.inlinePlaced(feature, modifiers);
|
||||
return PlacementUtils.inlinePlaced((Holder<ConfiguredFeature<?, ?>>) (Object) feature, modifiers);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -82,4 +86,14 @@ public class BCLInlinePlacedBuilder<F extends Feature<FC>, FC extends FeatureCon
|
|||
}
|
||||
|
||||
|
||||
public BCLFeatureBuilder.RandomPatch inRandomPatch(ResourceLocation id) {
|
||||
return ctx.startRandomPatch(id, build());
|
||||
}
|
||||
|
||||
public BCLFeatureBuilder.RandomPatch randomBonemealDistribution(ResourceLocation id) {
|
||||
return inRandomPatch(id)
|
||||
.tries(9)
|
||||
.spreadXZ(3)
|
||||
.spreadY(1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
package org.betterx.bclib.api.v3.levelgen.features;
|
||||
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.data.worldgen.BootstapContext;
|
||||
import net.minecraft.data.worldgen.placement.PlacementUtils;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.levelgen.GenerationStep;
|
||||
import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
|
||||
|
@ -13,8 +16,14 @@ public class BCLPlacedFeatureBuilder<F extends Feature<FC>, FC extends FeatureCo
|
|||
private final ResourceLocation featureID;
|
||||
private GenerationStep.Decoration decoration = GenerationStep.Decoration.VEGETAL_DECORATION;
|
||||
private final BCLConfigureFeature<F, FC> cFeature;
|
||||
protected final BCLPlacedFeatureBuilder.Context ctx;
|
||||
|
||||
private BCLPlacedFeatureBuilder(ResourceLocation featureID, BCLConfigureFeature<F, FC> cFeature) {
|
||||
private BCLPlacedFeatureBuilder(
|
||||
Context ctx,
|
||||
ResourceLocation featureID,
|
||||
BCLConfigureFeature<F, FC> cFeature
|
||||
) {
|
||||
this.ctx = ctx;
|
||||
this.featureID = featureID;
|
||||
this.cFeature = cFeature;
|
||||
}
|
||||
|
@ -39,10 +48,11 @@ public class BCLPlacedFeatureBuilder<F extends Feature<FC>, FC extends FeatureCo
|
|||
* @return {@link CommonPlacedFeatureBuilder} instance.
|
||||
*/
|
||||
public static <F extends Feature<FC>, FC extends FeatureConfiguration> BCLPlacedFeatureBuilder<F, FC> place(
|
||||
Context ctx,
|
||||
ResourceLocation featureID,
|
||||
Holder<ConfiguredFeature<FC, F>> holder
|
||||
) {
|
||||
return place(featureID, BCLConfigureFeature.create(holder));
|
||||
return place(ctx, featureID, BCLConfigureFeature.create(holder));
|
||||
}
|
||||
|
||||
|
||||
|
@ -54,24 +64,43 @@ public class BCLPlacedFeatureBuilder<F extends Feature<FC>, FC extends FeatureCo
|
|||
* @return {@link CommonPlacedFeatureBuilder} instance.
|
||||
*/
|
||||
static <F extends Feature<FC>, FC extends FeatureConfiguration> BCLPlacedFeatureBuilder<F, FC> place(
|
||||
Context ctx,
|
||||
ResourceLocation featureID,
|
||||
BCLConfigureFeature<F, FC> cFeature
|
||||
) {
|
||||
return new BCLPlacedFeatureBuilder(featureID, cFeature);
|
||||
return new BCLPlacedFeatureBuilder(ctx, featureID, cFeature);
|
||||
}
|
||||
|
||||
public static <F extends Feature<FC>, FC extends FeatureConfiguration> BCLPlacedFeatureBuilder<F, FC> place(
|
||||
BCLPlacedFeatureBuilder.Context ctx,
|
||||
ResourceLocation configuredFeature
|
||||
) {
|
||||
ResourceKey<ConfiguredFeature<?, ?>> key = ResourceKey.create(
|
||||
Registries.CONFIGURED_FEATURE,
|
||||
configuredFeature
|
||||
);
|
||||
Holder<ConfiguredFeature<FC, F>> holder = (Holder<ConfiguredFeature<FC, F>>) (Object) ctx.bootstrapContext
|
||||
.lookup(Registries.CONFIGURED_FEATURE)
|
||||
.getOrThrow(key);
|
||||
var cFeature = new BCLConfigureFeature<F, FC>(configuredFeature, holder, false);
|
||||
return new BCLPlacedFeatureBuilder<F, FC>(ctx, configuredFeature, cFeature);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Builds a new {@link BCLFeature} instance.
|
||||
*
|
||||
* @return created {@link BCLFeature} instance.
|
||||
*/
|
||||
public Holder<PlacedFeature> build() {
|
||||
Holder<PlacedFeature> p = PlacementUtils.register(
|
||||
featureID.toString(),
|
||||
cFeature.configuredFeature,
|
||||
final ResourceKey<PlacedFeature> key = ResourceKey.create(Registries.PLACED_FEATURE, featureID);
|
||||
PlacementUtils.register(
|
||||
ctx.bootstrapContext,
|
||||
key,
|
||||
(Holder<ConfiguredFeature<?, ?>>) (Object) cFeature.configuredFeature,
|
||||
modifications
|
||||
);
|
||||
return p;
|
||||
return ctx.bootstrapContext.lookup(Registries.PLACED_FEATURE).get(key).orElseThrow();
|
||||
}
|
||||
|
||||
|
||||
|
@ -85,4 +114,7 @@ public class BCLPlacedFeatureBuilder<F extends Feature<FC>, FC extends FeatureCo
|
|||
Holder<PlacedFeature> p = build();
|
||||
return new BCLFeature(cFeature, p, decoration);
|
||||
}
|
||||
|
||||
public record Context(BootstapContext<PlacedFeature> bootstrapContext) {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,8 +24,8 @@ import java.util.List;
|
|||
import java.util.Optional;
|
||||
|
||||
abstract class CommonPlacedFeatureBuilder<F extends Feature<FC>, FC extends FeatureConfiguration, T extends CommonPlacedFeatureBuilder<F, FC, T>> {
|
||||
protected final List<PlacementModifier> modifications = new LinkedList<>();
|
||||
|
||||
protected final List<PlacementModifier> modifications = new LinkedList<>();
|
||||
|
||||
/**
|
||||
* Add feature placement modifier. Used as a condition for feature how to generate.
|
||||
|
@ -425,15 +425,4 @@ abstract class CommonPlacedFeatureBuilder<F extends Feature<FC>, FC extends Feat
|
|||
* @return created {@link PlacedFeature} instance.
|
||||
*/
|
||||
abstract Holder<PlacedFeature> build();
|
||||
|
||||
public BCLFeatureBuilder.RandomPatch inRandomPatch(ResourceLocation id) {
|
||||
return BCLFeatureBuilder.startRandomPatch(id, build());
|
||||
}
|
||||
|
||||
public BCLFeatureBuilder.RandomPatch randomBonemealDistribution(ResourceLocation id) {
|
||||
return inRandomPatch(id)
|
||||
.tries(9)
|
||||
.spreadXZ(3)
|
||||
.spreadY(1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import org.betterx.worlds.together.tag.v3.CommonBlockTags;
|
|||
|
||||
import com.mojang.serialization.Codec;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.tags.BlockTags;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
|
@ -39,7 +40,7 @@ public class BlockPredicates {
|
|||
);
|
||||
|
||||
public static <P extends BlockPredicate> BlockPredicateType<P> register(ResourceLocation location, Codec<P> codec) {
|
||||
return Registry.register(Registry.BLOCK_PREDICATE_TYPES, location, () -> codec);
|
||||
return Registry.register(BuiltInRegistries.BLOCK_PREDICATE_TYPE, location, () -> codec);
|
||||
}
|
||||
|
||||
public static void ensureStaticInitialization() {
|
||||
|
|
|
@ -5,7 +5,7 @@ import org.betterx.bclib.noise.Noises;
|
|||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.world.level.levelgen.placement.PlacementContext;
|
||||
|
@ -16,7 +16,7 @@ import net.minecraft.world.level.levelgen.synth.NormalNoise;
|
|||
public class NoiseFilter extends PlacementFilter {
|
||||
public static final Codec<NoiseFilter> CODEC = RecordCodecBuilder.create(instance -> instance
|
||||
.group(
|
||||
ResourceKey.codec(Registry.NOISE_REGISTRY).fieldOf("noise").forGetter(o -> o.noise),
|
||||
ResourceKey.codec(Registries.NOISE).fieldOf("noise").forGetter(o -> o.noise),
|
||||
Codec.DOUBLE.fieldOf("min_noise_level").forGetter(o -> o.minNoiseLevel),
|
||||
Codec.DOUBLE.fieldOf("max_noise_level").orElse(Double.MAX_VALUE).forGetter(o -> o.maxNoiseLevel),
|
||||
Codec.FLOAT.fieldOf("scale_xz").orElse(1f).forGetter(o -> o.scaleXZ),
|
||||
|
|
|
@ -4,6 +4,7 @@ import org.betterx.bclib.BCLib;
|
|||
|
||||
import com.mojang.serialization.Codec;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.levelgen.placement.PlacementModifier;
|
||||
import net.minecraft.world.level.levelgen.placement.PlacementModifierType;
|
||||
|
@ -85,7 +86,7 @@ public class PlacementModifiers {
|
|||
ResourceLocation location,
|
||||
Codec<P> codec
|
||||
) {
|
||||
return Registry.register(Registry.PLACEMENT_MODIFIERS, location, () -> codec);
|
||||
return Registry.register(BuiltInRegistries.PLACEMENT_MODIFIER_TYPE, location, () -> codec);
|
||||
}
|
||||
|
||||
public static void ensureStaticInitialization() {
|
||||
|
|
|
@ -13,6 +13,7 @@ import net.minecraft.world.item.enchantment.EnchantmentHelper;
|
|||
import net.minecraft.world.item.enchantment.Enchantments;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.LevelReader;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
@ -89,7 +90,7 @@ public class BaseCropBlock extends BasePlantBlock {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidBonemealTarget(BlockGetter world, BlockPos pos, BlockState state, boolean isClient) {
|
||||
public boolean isValidBonemealTarget(LevelReader world, BlockPos pos, BlockState state, boolean isClient) {
|
||||
return state.getValue(AGE) < 3;
|
||||
}
|
||||
|
||||
|
|
|
@ -131,7 +131,12 @@ public abstract class BaseDoublePlantBlock extends BaseBlockNotFull implements R
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidBonemealTarget(BlockGetter world, BlockPos pos, BlockState state, boolean isClient) {
|
||||
public boolean isValidBonemealTarget(
|
||||
LevelReader levelReader,
|
||||
BlockPos blockPos,
|
||||
BlockState blockState,
|
||||
boolean isClient
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -104,7 +104,7 @@ public abstract class BasePlantBlock extends BaseBlockNotFull implements RenderL
|
|||
this(
|
||||
propMod.amend(Properties
|
||||
.of(replaceable ? Material.REPLACEABLE_PLANT : Material.PLANT)
|
||||
.lightLevel((state)->light)
|
||||
.lightLevel((state) -> light)
|
||||
.sound(SoundType.GRASS)
|
||||
.noCollission()
|
||||
.offsetType(BlockBehaviour.OffsetType.XZ)
|
||||
|
@ -169,7 +169,7 @@ public abstract class BasePlantBlock extends BaseBlockNotFull implements RenderL
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidBonemealTarget(BlockGetter world, BlockPos pos, BlockState state, boolean isClient) {
|
||||
public boolean isValidBonemealTarget(LevelReader world, BlockPos pos, BlockState state, boolean isClient) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -135,7 +135,7 @@ public class BaseVineBlock extends BaseBlockNotFull implements RenderLayerProvid
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidBonemealTarget(BlockGetter world, BlockPos pos, BlockState state, boolean isClient) {
|
||||
public boolean isValidBonemealTarget(LevelReader world, BlockPos pos, BlockState state, boolean isClient) {
|
||||
while (world.getBlockState(pos).getBlock() == this) {
|
||||
pos = pos.below();
|
||||
}
|
||||
|
|
|
@ -151,7 +151,7 @@ public abstract class UnderwaterPlantBlock extends BaseBlockNotFull implements R
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidBonemealTarget(BlockGetter world, BlockPos pos, BlockState state, boolean isClient) {
|
||||
public boolean isValidBonemealTarget(LevelReader world, BlockPos pos, BlockState state, boolean isClient) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,15 +10,12 @@ import org.betterx.bclib.registry.PresetsRegistryClient;
|
|||
import org.betterx.worlds.together.WorldsTogether;
|
||||
import org.betterx.worlds.together.client.WorldsTogetherClient;
|
||||
|
||||
import net.minecraft.client.renderer.texture.SpriteLoader;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlas;
|
||||
import net.minecraft.client.resources.model.ModelResourceLocation;
|
||||
import net.minecraft.client.resources.model.UnbakedModel;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
import net.fabricmc.api.ClientModInitializer;
|
||||
import net.fabricmc.fabric.api.client.model.*;
|
||||
import net.fabricmc.fabric.api.event.client.ClientSpriteRegistryCallback;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
|
@ -39,13 +36,13 @@ public class BCLibClient implements ClientModInitializer, ModelResourceProvider,
|
|||
PresetsRegistryClient.onLoad();
|
||||
WorldsTogether.SURPRESS_EXPERIMENTAL_DIALOG = Configs.CLIENT_CONFIG.suppressExperimentalDialog();
|
||||
//dumpDatapack();
|
||||
|
||||
ClientSpriteRegistryCallback
|
||||
.event(TextureAtlas.LOCATION_BLOCKS)
|
||||
.register((resourceManager, sprites) -> {
|
||||
SpriteLoader.listSprites(resourceManager, "entity/chest", sprites::put);
|
||||
SpriteLoader.listSprites(resourceManager, "blocks", sprites::put);
|
||||
});
|
||||
//TODO: 1.19.3 Find out how to load sprites from custom folders
|
||||
// ClientSpriteRegistryCallback
|
||||
// .event(TextureAtlas.LOCATION_BLOCKS)
|
||||
// .register((resourceManager, sprites) -> {
|
||||
// SpriteLoader.listSprites(resourceManager, "entity/chest", sprites::put);
|
||||
// SpriteLoader.listSprites(resourceManager, "blocks", sprites::put);
|
||||
// });
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -9,6 +9,7 @@ import net.minecraft.client.renderer.block.model.BlockModel;
|
|||
import net.minecraft.client.renderer.block.model.multipart.MultiPart;
|
||||
import net.minecraft.client.resources.model.ModelResourceLocation;
|
||||
import net.minecraft.client.resources.model.UnbakedModel;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.packs.resources.ResourceManager;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
|
|
|
@ -13,6 +13,7 @@ import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
|
|||
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
|
||||
import net.minecraft.client.renderer.blockentity.BrightnessCombiner;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.*;
|
||||
|
|
|
@ -18,6 +18,7 @@ import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
|
|||
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
|
||||
import net.minecraft.client.renderer.blockentity.SignRenderer;
|
||||
import net.minecraft.client.resources.model.Material;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.FormattedCharSequence;
|
||||
import net.minecraft.util.Mth;
|
||||
|
|
|
@ -15,14 +15,13 @@ import com.mojang.serialization.JsonOps;
|
|||
import com.mojang.serialization.codecs.KeyDispatchCodec;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.Style;
|
||||
import net.minecraft.resources.RegistryOps;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.tags.TagEntry;
|
||||
import net.minecraft.tags.TagFile;
|
||||
import net.minecraft.util.KeyDispatchDataCodec;
|
||||
|
@ -141,22 +140,22 @@ public class DumpDatapack {
|
|||
) {
|
||||
BCLib.LOGGER.info("- Serializing: " + registry.key().toString());
|
||||
DUMPERS.clear();
|
||||
DUMPERS.put(Registry.BIOME_REGISTRY.location(), new Dumper<>((Biome v) -> Biome.DIRECT_CODEC));
|
||||
DUMPERS.put(Registries.BIOME.location(), new Dumper<>((Biome v) -> Biome.DIRECT_CODEC));
|
||||
DUMPERS.put(
|
||||
Registry.CONFIGURED_FEATURE_REGISTRY.location(),
|
||||
Registries.CONFIGURED_FEATURE.location(),
|
||||
new Dumper<>((ConfiguredFeature v) -> ConfiguredFeature.DIRECT_CODEC)
|
||||
);
|
||||
DUMPERS.put(
|
||||
Registry.WORLD_PRESET_REGISTRY.location(),
|
||||
Registries.WORLD_PRESET.location(),
|
||||
new Dumper<>((WorldPreset v) -> WorldPreset.DIRECT_CODEC)
|
||||
);
|
||||
DUMPERS.put(
|
||||
Registry.NOISE_GENERATOR_SETTINGS_REGISTRY.location(),
|
||||
Registries.NOISE_SETTINGS.location(),
|
||||
new Dumper<>((NoiseGeneratorSettings v) -> NoiseGeneratorSettings.DIRECT_CODEC)
|
||||
);
|
||||
DUMPERS.put(Registry.STRUCTURE_REGISTRY.location(), new Dumper<>((Structure v) -> Structure.DIRECT_CODEC));
|
||||
DUMPERS.put(Registries.STRUCTURE.location(), new Dumper<>((Structure v) -> Structure.DIRECT_CODEC));
|
||||
DUMPERS.put(
|
||||
Registry.DIMENSION_TYPE_REGISTRY.location(),
|
||||
Registries.DIMENSION_TYPE.location(),
|
||||
new Dumper<>((DimensionType v) -> DimensionType.DIRECT_CODEC)
|
||||
);
|
||||
DUMPERS.put(BCLBiomeRegistry.BCL_BIOMES_REGISTRY.location(), new Dumper<>((BCLBiome v) -> v.codec().codec()));
|
||||
|
@ -164,43 +163,37 @@ public class DumpDatapack {
|
|||
SurfaceRuleRegistry.SURFACE_RULES_REGISTRY.location(),
|
||||
new Dumper<>((AssignedSurfaceRule v) -> AssignedSurfaceRule.CODEC)
|
||||
);
|
||||
DUMPERS.put(Registry.SOUND_EVENT_REGISTRY.location(), new Dumper<>((SoundEvent v) -> SoundEvent.CODEC));
|
||||
DUMPERS.put(
|
||||
Registry.CONFIGURED_CARVER_REGISTRY.location(),
|
||||
Registries.CONFIGURED_CARVER.location(),
|
||||
new Dumper<>((ConfiguredWorldCarver v) -> ConfiguredWorldCarver.DIRECT_CODEC)
|
||||
);
|
||||
DUMPERS.put(
|
||||
Registry.PROCESSOR_LIST_REGISTRY.location(),
|
||||
Registries.PROCESSOR_LIST.location(),
|
||||
new Dumper<>((StructureProcessorList v) -> StructureProcessorType.DIRECT_CODEC)
|
||||
);
|
||||
DUMPERS.put(
|
||||
Registry.FLAT_LEVEL_GENERATOR_PRESET_REGISTRY.location(),
|
||||
Registries.FLAT_LEVEL_GENERATOR_PRESET.location(),
|
||||
new Dumper<>((FlatLevelGeneratorPreset v) -> FlatLevelGeneratorPreset.DIRECT_CODEC)
|
||||
);
|
||||
DUMPERS.put(
|
||||
Registry.DENSITY_FUNCTION_REGISTRY.location(),
|
||||
Registries.DENSITY_FUNCTION.location(),
|
||||
new Dumper<>((DensityFunction v) -> DensityFunction.DIRECT_CODEC)
|
||||
);
|
||||
DUMPERS.put(
|
||||
Registry.PLACED_FEATURE_REGISTRY.location(),
|
||||
Registries.PLACED_FEATURE.location(),
|
||||
new Dumper<>((PlacedFeature v) -> PlacedFeature.DIRECT_CODEC)
|
||||
);
|
||||
DUMPERS.put(
|
||||
Registry.NOISE_REGISTRY.location(),
|
||||
new Dumper<>((NormalNoise.NoiseParameters v) -> NormalNoise.NoiseParameters.DIRECT_CODEC)
|
||||
);
|
||||
DUMPERS.put(
|
||||
Registry.NOISE_REGISTRY.location(),
|
||||
Registries.NOISE.location(),
|
||||
new Dumper<>((NormalNoise.NoiseParameters v) -> NormalNoise.NoiseParameters.DIRECT_CODEC)
|
||||
);
|
||||
|
||||
|
||||
DUMPERS.put(
|
||||
Registry.TEMPLATE_POOL_REGISTRY.location(),
|
||||
Registries.TEMPLATE_POOL.location(),
|
||||
new Dumper<>((StructureTemplatePool v) -> StructureTemplatePool.DIRECT_CODEC)
|
||||
);
|
||||
DUMPERS.put(
|
||||
Registry.STRUCTURE_SET_REGISTRY.location(),
|
||||
Registries.STRUCTURE_SET.location(),
|
||||
new Dumper<>((StructureSet v) -> StructureSet.DIRECT_CODEC)
|
||||
);
|
||||
|
||||
|
|
33
src/main/java/org/betterx/bclib/datagen/BCLibDatagen.java
Normal file
33
src/main/java/org/betterx/bclib/datagen/BCLibDatagen.java
Normal file
|
@ -0,0 +1,33 @@
|
|||
package org.betterx.bclib.datagen;
|
||||
|
||||
import org.betterx.bclib.BCLib;
|
||||
|
||||
import net.minecraft.core.RegistrySetBuilder;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
|
||||
import net.fabricmc.fabric.api.datagen.v1.DataGeneratorEntrypoint;
|
||||
import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator;
|
||||
|
||||
public class BCLibDatagen implements DataGeneratorEntrypoint {
|
||||
static boolean ADD_TESTS = true;
|
||||
|
||||
@Override
|
||||
public void onInitializeDataGenerator(FabricDataGenerator dataGenerator) {
|
||||
BCLib.LOGGER.info("Bootstrap onInitializeDataGenerator");
|
||||
final FabricDataGenerator.Pack pack = dataGenerator.createPack();
|
||||
|
||||
pack.addProvider(WorldgenProvider::new);
|
||||
//pack.addProvider(BiomeProvider::new);
|
||||
//pack.addProvider(new BiomeProvider());
|
||||
// pack.addProvider(CustomRegistriesDataProvider::new);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildRegistry(RegistrySetBuilder registryBuilder) {
|
||||
BCLib.LOGGER.info("Datagen buildRegistry");
|
||||
registryBuilder.add(Registries.CONFIGURED_FEATURE, TestConfiguredFeatures::bootstrap);
|
||||
registryBuilder.add(Registries.PLACED_FEATURE, TestPlacedFeatures::bootstrap);
|
||||
registryBuilder.add(Registries.BIOME, TestBiomes::bootstrap);
|
||||
registryBuilder.add(Registries.NOISE_SETTINGS, NoiseDatagen::bootstrap);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,137 @@
|
|||
package org.betterx.bclib.datagen;
|
||||
|
||||
import org.betterx.bclib.api.v2.levelgen.biomes.BCLBiomeRegistry;
|
||||
import org.betterx.bclib.api.v2.levelgen.biomes.BiomeData;
|
||||
import org.betterx.worlds.together.WorldsTogether;
|
||||
import org.betterx.worlds.together.surfaceRules.AssignedSurfaceRule;
|
||||
import org.betterx.worlds.together.surfaceRules.SurfaceRuleRegistry;
|
||||
|
||||
import com.mojang.serialization.DynamicOps;
|
||||
import com.mojang.serialization.Encoder;
|
||||
import com.mojang.serialization.JsonOps;
|
||||
import net.minecraft.core.HolderLookup;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.data.CachedOutput;
|
||||
import net.minecraft.data.DataProvider;
|
||||
import net.minecraft.data.PackOutput;
|
||||
import net.minecraft.data.registries.VanillaRegistries;
|
||||
import net.minecraft.resources.RegistryDataLoader;
|
||||
import net.minecraft.resources.RegistryOps;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
|
||||
import net.minecraft.world.level.levelgen.placement.PlacedFeature;
|
||||
import net.minecraft.world.level.levelgen.structure.Structure;
|
||||
|
||||
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public class CustomRegistriesDataProvider implements DataProvider {
|
||||
public static final List<RegistryDataLoader.RegistryData<?>> REGISTRIES = List.of(
|
||||
new RegistryDataLoader.RegistryData<>(BCLBiomeRegistry.BCL_BIOMES_REGISTRY, BiomeData.CODEC),
|
||||
new RegistryDataLoader.RegistryData<>(
|
||||
SurfaceRuleRegistry.SURFACE_RULES_REGISTRY,
|
||||
AssignedSurfaceRule.CODEC
|
||||
),
|
||||
new RegistryDataLoader.RegistryData<>(Registries.BIOME, Biome.DIRECT_CODEC),
|
||||
new RegistryDataLoader.RegistryData<>(Registries.CONFIGURED_FEATURE, ConfiguredFeature.DIRECT_CODEC),
|
||||
new RegistryDataLoader.RegistryData<>(Registries.PLACED_FEATURE, PlacedFeature.DIRECT_CODEC),
|
||||
new RegistryDataLoader.RegistryData<>(Registries.STRUCTURE, Structure.DIRECT_CODEC)
|
||||
);
|
||||
|
||||
|
||||
private final PackOutput output;
|
||||
|
||||
public CustomRegistriesDataProvider(FabricDataOutput generator) {
|
||||
this.output = generator;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<?> run(CachedOutput cachedOutput) {
|
||||
HolderLookup.Provider registryAccess = VanillaRegistries.createLookup();
|
||||
RegistryOps<JsonElement> dynamicOps = RegistryOps.create(JsonOps.INSTANCE, registryAccess);
|
||||
final List<CompletableFuture<?>> futures = new ArrayList<>();
|
||||
|
||||
for (RegistryDataLoader.RegistryData<?> registryData : REGISTRIES) {
|
||||
futures.add(this.dumpRegistryCapFuture(
|
||||
cachedOutput,
|
||||
registryAccess,
|
||||
dynamicOps,
|
||||
(RegistryDataLoader.RegistryData) registryData
|
||||
));
|
||||
}
|
||||
return CompletableFuture.allOf(futures.toArray(CompletableFuture[]::new));
|
||||
}
|
||||
|
||||
private <T> CompletableFuture dumpRegistryCapFuture(
|
||||
CachedOutput cachedOutput,
|
||||
HolderLookup.Provider registryAccess,
|
||||
DynamicOps<JsonElement> dynamicOps,
|
||||
RegistryDataLoader.RegistryData<T> registryData
|
||||
) {
|
||||
return CompletableFuture.runAsync(() -> dumpRegistryCap(
|
||||
cachedOutput,
|
||||
registryAccess,
|
||||
dynamicOps,
|
||||
registryData
|
||||
));
|
||||
}
|
||||
|
||||
private <T> void dumpRegistryCap(
|
||||
CachedOutput cachedOutput,
|
||||
HolderLookup.Provider registryAccess,
|
||||
DynamicOps<JsonElement> dynamicOps,
|
||||
RegistryDataLoader.RegistryData<T> registryData
|
||||
) {
|
||||
ResourceKey<? extends Registry<T>> resourceKey = registryData.key();
|
||||
|
||||
HolderLookup.RegistryLookup<T> registry = registryAccess.lookupOrThrow(resourceKey);
|
||||
PackOutput.PathProvider pathProvider = this.output.createPathProvider(
|
||||
PackOutput.Target.DATA_PACK,
|
||||
resourceKey.location().getPath()
|
||||
);
|
||||
registry.listElementIds().forEach(entry ->
|
||||
dumpValue(
|
||||
pathProvider.json(entry.location()),
|
||||
cachedOutput,
|
||||
dynamicOps,
|
||||
registryData.elementCodec(),
|
||||
registry.get(entry).orElseThrow().value()
|
||||
)
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
private static <E> void dumpValue(
|
||||
Path path,
|
||||
CachedOutput cachedOutput,
|
||||
DynamicOps<JsonElement> dynamicOps,
|
||||
Encoder<E> encoder,
|
||||
E object
|
||||
) {
|
||||
|
||||
Optional<JsonElement> optional = encoder.encodeStart(dynamicOps, object)
|
||||
.resultOrPartial(string -> WorldsTogether.LOGGER.error(
|
||||
"Couldn't serialize element {}: {}",
|
||||
path,
|
||||
string
|
||||
));
|
||||
if (optional.isPresent()) {
|
||||
DataProvider.saveStable(cachedOutput, optional.get(), path);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "BCL Registries";
|
||||
}
|
||||
}
|
16
src/main/java/org/betterx/bclib/datagen/NoiseDatagen.java
Normal file
16
src/main/java/org/betterx/bclib/datagen/NoiseDatagen.java
Normal file
|
@ -0,0 +1,16 @@
|
|||
package org.betterx.bclib.datagen;
|
||||
|
||||
import org.betterx.bclib.api.v2.generator.BCLChunkGenerator;
|
||||
|
||||
import net.minecraft.data.worldgen.BootstapContext;
|
||||
import net.minecraft.world.level.levelgen.NoiseGeneratorSettings;
|
||||
|
||||
public class NoiseDatagen {
|
||||
public static void bootstrap(BootstapContext<NoiseGeneratorSettings> bootstrapContext) {
|
||||
bootstrapContext.register(
|
||||
BCLChunkGenerator.AMPLIFIED_NETHER,
|
||||
BCLChunkGenerator.amplifiedNether(bootstrapContext)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
102
src/main/java/org/betterx/bclib/datagen/TestBiomes.java
Normal file
102
src/main/java/org/betterx/bclib/datagen/TestBiomes.java
Normal file
|
@ -0,0 +1,102 @@
|
|||
package org.betterx.bclib.datagen;
|
||||
|
||||
import org.betterx.bclib.BCLib;
|
||||
import org.betterx.bclib.api.v2.levelgen.biomes.BCLBiome;
|
||||
import org.betterx.bclib.api.v2.levelgen.biomes.BCLBiomeBuilder;
|
||||
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.HolderGetter;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.data.worldgen.BootstapContext;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.levelgen.GenerationStep;
|
||||
import net.minecraft.world.level.levelgen.placement.PlacedFeature;
|
||||
|
||||
public class TestBiomes {
|
||||
|
||||
public static void bootstrap(BootstapContext<Biome> bootstrapContext) {
|
||||
BCLib.LOGGER.info("Bootstrap Biomes");
|
||||
if (BCLibDatagen.ADD_TESTS && BCLib.isDevEnvironment()) {
|
||||
HolderGetter<PlacedFeature> holderGetter = bootstrapContext.lookup(Registries.PLACED_FEATURE);
|
||||
Holder.Reference<PlacedFeature> reference = holderGetter.getOrThrow(ResourceKey.create(
|
||||
Registries.PLACED_FEATURE,
|
||||
BCLib.makeID("yellow_feature")
|
||||
));
|
||||
BCLib.LOGGER.info("REF Biome:" + reference);
|
||||
|
||||
BCLBiomeBuilder.Context biomeBuilder = new BCLBiomeBuilder.Context(bootstrapContext);
|
||||
BCLBiome theYellow = biomeBuilder
|
||||
.start(BCLib.makeID("the_yellow"))
|
||||
.precipitation(Biome.Precipitation.NONE)
|
||||
.temperature(1.0f)
|
||||
.wetness(1.0f)
|
||||
.fogColor(0xFFFF00)
|
||||
.waterColor(0x777700)
|
||||
.waterFogColor(0xFFFF00)
|
||||
.skyColor(0xAAAA00)
|
||||
.feature(GenerationStep.Decoration.VEGETAL_DECORATION, reference)
|
||||
.addNetherClimateParamater(-1, 1)
|
||||
.surface(Blocks.YELLOW_CONCRETE)
|
||||
.build()
|
||||
.registerEndLandBiome();
|
||||
|
||||
BCLBiome theBlue = biomeBuilder
|
||||
.start(BCLib.makeID("the_blue"))
|
||||
.precipitation(Biome.Precipitation.NONE)
|
||||
.temperature(1.0f)
|
||||
.wetness(1.0f)
|
||||
.fogColor(0x0000FF)
|
||||
.waterColor(0x000077)
|
||||
.waterFogColor(0x0000FF)
|
||||
.skyColor(0x0000AA)
|
||||
.addNetherClimateParamater(-1, 1)
|
||||
.surface(Blocks.LIGHT_BLUE_CONCRETE)
|
||||
.build()
|
||||
.registerEndLandBiome();
|
||||
|
||||
BCLBiome theGray = biomeBuilder
|
||||
.start(BCLib.makeID("the_gray"))
|
||||
.precipitation(Biome.Precipitation.NONE)
|
||||
.temperature(1.0f)
|
||||
.wetness(1.0f)
|
||||
.fogColor(0xFFFFFF)
|
||||
.waterColor(0x777777)
|
||||
.waterFogColor(0xFFFFFF)
|
||||
.skyColor(0xAAAAAA)
|
||||
.addNetherClimateParamater(-1, 1)
|
||||
.surface(Blocks.GRAY_CONCRETE)
|
||||
.build()
|
||||
.registerEndVoidBiome();
|
||||
|
||||
BCLBiome theOrange = biomeBuilder
|
||||
.start(BCLib.makeID("the_orange"))
|
||||
.precipitation(Biome.Precipitation.NONE)
|
||||
.temperature(1.0f)
|
||||
.wetness(1.0f)
|
||||
.fogColor(0xFF7700)
|
||||
.waterColor(0x773300)
|
||||
.waterFogColor(0xFF7700)
|
||||
.skyColor(0xAA7700)
|
||||
.addNetherClimateParamater(-1, 1.1f)
|
||||
.surface(Blocks.ORANGE_CONCRETE)
|
||||
.build()
|
||||
.registerNetherBiome();
|
||||
|
||||
BCLBiome thePurple = biomeBuilder
|
||||
.start(BCLib.makeID("the_purple"))
|
||||
.precipitation(Biome.Precipitation.NONE)
|
||||
.temperature(1.0f)
|
||||
.wetness(1.0f)
|
||||
.fogColor(0xFF00FF)
|
||||
.waterColor(0x770077)
|
||||
.waterFogColor(0xFF00FF)
|
||||
.skyColor(0xAA00AA)
|
||||
.addNetherClimateParamater(-1.1f, 1)
|
||||
.surface(Blocks.PURPLE_CONCRETE)
|
||||
.build()
|
||||
.registerNetherBiome();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package org.betterx.bclib.datagen;
|
||||
|
||||
import org.betterx.bclib.BCLib;
|
||||
import org.betterx.bclib.api.v3.levelgen.features.BCLConfigureFeature;
|
||||
import org.betterx.bclib.api.v3.levelgen.features.BCLFeatureBuilder;
|
||||
|
||||
import net.minecraft.data.worldgen.BootstapContext;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
|
||||
import net.minecraft.world.level.levelgen.feature.RandomPatchFeature;
|
||||
import net.minecraft.world.level.levelgen.feature.configurations.RandomPatchConfiguration;
|
||||
|
||||
public class TestConfiguredFeatures {
|
||||
static BCLConfigureFeature<RandomPatchFeature, RandomPatchConfiguration> YELLOW_FEATURE;
|
||||
|
||||
public static void bootstrap(BootstapContext<ConfiguredFeature<?, ?>> bootstrapContext) {
|
||||
BCLib.LOGGER.info("Bootstrap CONFIGUREDFeatures");
|
||||
if (BCLibDatagen.ADD_TESTS && BCLib.isDevEnvironment()) {
|
||||
BCLFeatureBuilder.Context builder = new BCLFeatureBuilder.Context(bootstrapContext);
|
||||
|
||||
YELLOW_FEATURE = builder
|
||||
.startBonemealPatch(BCLib.makeID("yellow_feature"))
|
||||
.add(Blocks.YELLOW_STAINED_GLASS, 30)
|
||||
.add(Blocks.YELLOW_CONCRETE_POWDER, 30)
|
||||
.add(Blocks.YELLOW_GLAZED_TERRACOTTA, 5)
|
||||
.buildAndRegister();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package org.betterx.bclib.datagen;
|
||||
|
||||
import org.betterx.bclib.BCLib;
|
||||
import org.betterx.bclib.api.v3.levelgen.features.BCLFeature;
|
||||
import org.betterx.bclib.api.v3.levelgen.features.BCLPlacedFeatureBuilder;
|
||||
|
||||
import net.minecraft.data.worldgen.BootstapContext;
|
||||
import net.minecraft.world.level.levelgen.GenerationStep;
|
||||
import net.minecraft.world.level.levelgen.feature.RandomPatchFeature;
|
||||
import net.minecraft.world.level.levelgen.feature.configurations.RandomPatchConfiguration;
|
||||
import net.minecraft.world.level.levelgen.placement.PlacedFeature;
|
||||
|
||||
public class TestPlacedFeatures {
|
||||
static BCLFeature<RandomPatchFeature, RandomPatchConfiguration> YELLOW_PLACED;
|
||||
|
||||
public static void bootstrap(BootstapContext<PlacedFeature> bootstrapContext) {
|
||||
BCLib.LOGGER.info("Bootstrap PLACEDFeatures");
|
||||
|
||||
if (BCLibDatagen.ADD_TESTS && BCLib.isDevEnvironment()) {
|
||||
final BCLPlacedFeatureBuilder.Context buildContext = new BCLPlacedFeatureBuilder.Context(bootstrapContext);
|
||||
YELLOW_PLACED = BCLPlacedFeatureBuilder.<RandomPatchFeature, RandomPatchConfiguration>place(
|
||||
buildContext,
|
||||
BCLib.makeID("yellow_feature")
|
||||
)
|
||||
.decoration(GenerationStep.Decoration.VEGETAL_DECORATION)
|
||||
.vanillaNetherGround(8)
|
||||
.isEmptyAndOnNetherGround()
|
||||
.buildAndRegister();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package org.betterx.bclib.datagen;
|
||||
|
||||
import net.minecraft.core.HolderLookup;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
|
||||
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
|
||||
import net.fabricmc.fabric.api.datagen.v1.provider.FabricDynamicRegistryProvider;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public class WorldgenProvider extends FabricDynamicRegistryProvider {
|
||||
public WorldgenProvider(
|
||||
FabricDataOutput output,
|
||||
CompletableFuture<HolderLookup.Provider> registriesFuture
|
||||
) {
|
||||
super(output, registriesFuture);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure(HolderLookup.Provider registries, Entries entries) {
|
||||
entries.addAll(registries.lookupOrThrow(Registries.CONFIGURED_FEATURE));
|
||||
entries.addAll(registries.lookupOrThrow(Registries.PLACED_FEATURE));
|
||||
entries.addAll(registries.lookupOrThrow(Registries.BIOME));
|
||||
entries.addAll(registries.lookupOrThrow(Registries.NOISE_SETTINGS));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "007 - BCLib Feature Provider";
|
||||
}
|
||||
}
|
|
@ -4,7 +4,6 @@ import org.betterx.bclib.BCLib;
|
|||
import org.betterx.worlds.together.tag.v3.TagManager;
|
||||
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
|
@ -55,7 +54,7 @@ public abstract class ModIntegration {
|
|||
}
|
||||
|
||||
public ResourceKey<Biome> getKey(String name) {
|
||||
return ResourceKey.create(Registry.BIOME_REGISTRY, getID(name));
|
||||
return ResourceKey.create(Registries.BIOME, getID(name));
|
||||
}
|
||||
|
||||
public boolean modIsInstalled() {
|
||||
|
@ -64,11 +63,13 @@ public abstract class ModIntegration {
|
|||
|
||||
|
||||
public ConfiguredFeature<?, ?> getConfiguredFeature(String name) {
|
||||
return BuiltInRegistries.CONFIGURED_FEATURE.get(getID(name));
|
||||
//TODO: 1.19.3 find how to change this without having features before a world gets loaded
|
||||
return null; //BuiltInRegistries.CONFIGURED_FEATURE.get(getID(name));
|
||||
}
|
||||
|
||||
public Holder<Biome> getBiome(String name) {
|
||||
return BuiltInRegistries.BIOME.getHolder(getKey(name)).orElseThrow();
|
||||
//TODO: 1.19.3 find how to change this without having features before a world gets loaded
|
||||
return null; //BuiltInRegistries.BIOME.getHolder(getKey(name)).orElseThrow();
|
||||
}
|
||||
|
||||
public Class<?> getClass(String path) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package org.betterx.bclib.interfaces;
|
||||
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
|
@ -9,7 +9,7 @@ import java.util.List;
|
|||
|
||||
public interface AlloyingRecipeWorkstation {
|
||||
static List<Block> getWorkstations() {
|
||||
return Registry.BLOCK
|
||||
return BuiltInRegistries.BLOCK
|
||||
.stream()
|
||||
.filter(b -> b instanceof AlloyingRecipeWorkstation)
|
||||
.toList();
|
||||
|
|
|
@ -1,13 +1,9 @@
|
|||
package org.betterx.bclib.interfaces;
|
||||
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.world.level.levelgen.NoiseGeneratorSettings;
|
||||
import net.minecraft.world.level.levelgen.synth.NormalNoise;
|
||||
|
||||
public interface NoiseGeneratorSettingsProvider {
|
||||
NoiseGeneratorSettings bclib_getNoiseGeneratorSettings();
|
||||
Holder<NoiseGeneratorSettings> bclib_getNoiseGeneratorSettingHolders();
|
||||
|
||||
Registry<NormalNoise.NoiseParameters> bclib_getNoises();
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package org.betterx.bclib.interfaces;
|
||||
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.tags.TagKey;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
|
|
|
@ -5,6 +5,7 @@ import org.betterx.bclib.interfaces.BlockModelProvider;
|
|||
import org.betterx.bclib.interfaces.ItemModelProvider;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
|
|
|
@ -8,6 +8,7 @@ import net.minecraft.client.color.block.BlockColors;
|
|||
import net.minecraft.client.color.item.ItemColors;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.client.main.GameConfig;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
|
|
@ -3,7 +3,6 @@ package org.betterx.bclib.mixin.common;
|
|||
import org.betterx.bclib.api.v2.levelgen.biomes.BCLBiomeRegistry;
|
||||
|
||||
import com.mojang.serialization.Lifecycle;
|
||||
import net.minecraft.core.MappedRegistry;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.WritableRegistry;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
|
@ -18,21 +17,21 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|||
@Mixin(BuiltInRegistries.class)
|
||||
public abstract class BuiltinRegistriesMixin {
|
||||
@Shadow
|
||||
protected static <T, R extends WritableRegistry<T>> R internalRegister(
|
||||
private static <T, R extends WritableRegistry<T>> R internalRegister(
|
||||
ResourceKey<? extends Registry<T>> resourceKey,
|
||||
R writableRegistry,
|
||||
BuiltInRegistries.RegistryBootstrap<T> registryBootstrap,
|
||||
Lifecycle lifecycle
|
||||
) {
|
||||
throw new RuntimeException("Shadowed Call");
|
||||
throw new RuntimeException("Shadowed");
|
||||
}
|
||||
|
||||
//this needs to be added BEFORE the WORLD_PRESET-Registry. Otherwise decoding will fail!
|
||||
@Inject(method = "<clinit>", at = @At(value = "INVOKE", target = "Lnet/minecraft/data/BuiltinRegistries;registerSimple(Lnet/minecraft/resources/ResourceKey;Lnet/minecraft/data/BuiltinRegistries$RegistryBootstrap;)Lnet/minecraft/core/Registry;", ordinal = 0))
|
||||
@Inject(method = "<clinit>", at = @At(value = "INVOKE", ordinal = 0, target = "Lnet/minecraft/core/registries/BuiltInRegistries;registerSimple(Lnet/minecraft/resources/ResourceKey;Lnet/minecraft/core/registries/BuiltInRegistries$RegistryBootstrap;)Lnet/minecraft/core/Registry;"))
|
||||
private static void bcl_registerBuiltin(CallbackInfo ci) {
|
||||
BCLBiomeRegistry.BUILTIN_BCL_BIOMES = internalRegister(
|
||||
BCLBiomeRegistry.BCL_BIOMES_REGISTRY,
|
||||
(MappedRegistry) BCLBiomeRegistry.BUILTIN_BCL_BIOMES,
|
||||
BCLBiomeRegistry.BUILTIN_BCL_BIOMES,
|
||||
BCLBiomeRegistry::bootstrap,
|
||||
Lifecycle.stable()
|
||||
);
|
||||
|
|
|
@ -9,9 +9,7 @@ import net.minecraft.world.level.chunk.ChunkAccess;
|
|||
import net.minecraft.world.level.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.level.levelgen.structure.StructureSet;
|
||||
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyArg;
|
||||
|
@ -19,9 +17,6 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|||
|
||||
@Mixin(ChunkGenerator.class)
|
||||
public class ChunkGeneratorMixin implements ChunkGeneratorAccessor {
|
||||
@Shadow
|
||||
@Final
|
||||
protected Registry<StructureSet> structureSets;
|
||||
private int bclib_featureIteratorSeed;
|
||||
|
||||
|
||||
|
@ -41,6 +36,6 @@ public class ChunkGeneratorMixin implements ChunkGeneratorAccessor {
|
|||
}
|
||||
|
||||
public Registry<StructureSet> bclib_getStructureSetsRegistry() {
|
||||
return structureSets;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,10 +4,8 @@ import org.betterx.bclib.interfaces.NoiseGeneratorSettingsProvider;
|
|||
import org.betterx.bclib.interfaces.SurfaceProvider;
|
||||
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator;
|
||||
import net.minecraft.world.level.levelgen.NoiseGeneratorSettings;
|
||||
import net.minecraft.world.level.levelgen.synth.NormalNoise;
|
||||
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
@ -19,9 +17,6 @@ public abstract class NoiseBasedChunkGeneratorMixin implements SurfaceProvider,
|
|||
@Shadow
|
||||
protected Holder<NoiseGeneratorSettings> settings;
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
private Registry<NormalNoise.NoiseParameters> noises;
|
||||
|
||||
@Override
|
||||
public NoiseGeneratorSettings bclib_getNoiseGeneratorSettings() {
|
||||
|
@ -32,9 +27,4 @@ public abstract class NoiseBasedChunkGeneratorMixin implements SurfaceProvider,
|
|||
public Holder<NoiseGeneratorSettings> bclib_getNoiseGeneratorSettingHolders() {
|
||||
return settings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Registry<NormalNoise.NoiseParameters> bclib_getNoises() {
|
||||
return noises;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,36 +1,22 @@
|
|||
package org.betterx.bclib.mixin.common;
|
||||
|
||||
import org.betterx.bclib.api.v2.generator.BCLChunkGenerator;
|
||||
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.world.level.levelgen.NoiseGeneratorSettings;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(NoiseGeneratorSettings.class)
|
||||
public abstract class NoiseGeneratorSettingsMixin {
|
||||
@Shadow
|
||||
static protected Holder<NoiseGeneratorSettings> register(
|
||||
Registry<NoiseGeneratorSettings> registry,
|
||||
ResourceKey<NoiseGeneratorSettings> resourceKey,
|
||||
NoiseGeneratorSettings noiseGeneratorSettings
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
;
|
||||
|
||||
@Inject(method = "bootstrap", at = @At("HEAD"))
|
||||
private static void bcl_addNoiseGenerators(
|
||||
Registry<NoiseGeneratorSettings> registry,
|
||||
CallbackInfoReturnable<Holder<NoiseGeneratorSettings>> cir
|
||||
) {
|
||||
register(registry, BCLChunkGenerator.AMPLIFIED_NETHER, BCLChunkGenerator.amplifiedNether());
|
||||
}
|
||||
//TODO:1.19.3 Replaced by Datagen pack file in NoiseDatagen
|
||||
// @Inject(method = "bootstrap", at = @At("HEAD"))
|
||||
// private static void bcl_addNoiseGenerators(
|
||||
// BootstapContext<NoiseGeneratorSettings> bootstapContext, CallbackInfo ci
|
||||
// ) {
|
||||
// bootstapContext.register(
|
||||
// BCLChunkGenerator.AMPLIFIED_NETHER,
|
||||
// BCLChunkGenerator.amplifiedNether(bootstapContext)
|
||||
// );
|
||||
// }
|
||||
}
|
||||
|
|
|
@ -1,17 +1,14 @@
|
|||
package org.betterx.bclib.mixin.common;
|
||||
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.data.worldgen.Structures;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.world.level.levelgen.structure.Structure;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||
|
||||
@Mixin(Structures.class)
|
||||
public interface StructuresAccessor {
|
||||
@Invoker
|
||||
static Holder<Structure> callRegister(ResourceKey<Structure> resourceKey, Structure structure) {
|
||||
throw new RuntimeException("Unexpected call");
|
||||
}
|
||||
//TODO: 1.19.3 Refactor
|
||||
// @Invoker
|
||||
// static Holder<Structure> callRegister(ResourceKey<Structure> resourceKey, Structure structure) {
|
||||
// throw new RuntimeException("Unexpected call");
|
||||
// }
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ public abstract class BoatMixin extends Entity implements CustomBoatTypeOverride
|
|||
return bcl_type;
|
||||
}
|
||||
|
||||
@Inject(method = "setType", at = @At("HEAD"), cancellable = true)
|
||||
@Inject(method = "setVariant", at = @At("HEAD"), cancellable = true)
|
||||
void bcl_setType(Boat.Type type, CallbackInfo ci) {
|
||||
if (bcl_type != null) {
|
||||
this.entityData.set(DATA_ID_TYPE, bcl_type.ordinal());
|
||||
|
@ -56,7 +56,7 @@ public abstract class BoatMixin extends Entity implements CustomBoatTypeOverride
|
|||
}
|
||||
}
|
||||
|
||||
@Inject(method = "getBoatType", at = @At("HEAD"), cancellable = true)
|
||||
@Inject(method = "getVariant", at = @At("HEAD"), cancellable = true)
|
||||
void bcl_getBoatType(CallbackInfoReturnable<Boat.Type> cir) {
|
||||
BoatTypeOverride type = BoatTypeOverride.byId(this.entityData.get(DATA_ID_TYPE));
|
||||
if (type != null) {
|
||||
|
|
|
@ -5,6 +5,7 @@ import org.betterx.bclib.BCLib;
|
|||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.RandomSource;
|
||||
|
@ -19,7 +20,7 @@ public class Noises {
|
|||
"roughness_noise"));
|
||||
|
||||
public static ResourceKey<NormalNoise.NoiseParameters> createKey(ResourceLocation loc) {
|
||||
return ResourceKey.create(Registry.NOISE_REGISTRY, loc);
|
||||
return ResourceKey.create(Registries.NOISE, loc);
|
||||
}
|
||||
|
||||
public static NormalNoise createNoise(
|
||||
|
@ -36,7 +37,7 @@ public class Noises {
|
|||
RandomSource randomSource,
|
||||
ResourceKey<NormalNoise.NoiseParameters> noise
|
||||
) {
|
||||
final Registry<NormalNoise.NoiseParameters> registry = registryAccess.registryOrThrow(Registry.NOISE_REGISTRY);
|
||||
final Registry<NormalNoise.NoiseParameters> registry = registryAccess.registryOrThrow(Registries.NOISE);
|
||||
return noiseIntances.computeIfAbsent(noise, (key) -> createNoise(registry, randomSource, noise));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import net.minecraft.core.Registry;
|
|||
import net.minecraft.core.particles.ParticleOptions;
|
||||
import net.minecraft.core.particles.ParticleType;
|
||||
import net.minecraft.core.particles.SimpleParticleType;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
import net.fabricmc.fabric.api.client.particle.v1.ParticleFactoryRegistry;
|
||||
|
@ -45,7 +46,11 @@ public class BCLParticleType {
|
|||
ParticleOptions.Deserializer<T> factory,
|
||||
Codec<T> codec
|
||||
) {
|
||||
return Registry.register(Registry.PARTICLE_TYPE, location, deserializer(overrideLimiter, factory, codec));
|
||||
return Registry.register(
|
||||
BuiltInRegistries.PARTICLE_TYPE,
|
||||
location,
|
||||
deserializer(overrideLimiter, factory, codec)
|
||||
);
|
||||
}
|
||||
|
||||
public static SimpleParticleType simple(boolean overrideLimiter) {
|
||||
|
@ -62,7 +67,7 @@ public class BCLParticleType {
|
|||
}
|
||||
|
||||
public static SimpleParticleType register(ResourceLocation location, boolean overrideLimiter) {
|
||||
return Registry.register(Registry.PARTICLE_TYPE, location, simple(overrideLimiter));
|
||||
return Registry.register(BuiltInRegistries.PARTICLE_TYPE, location, simple(overrideLimiter));
|
||||
}
|
||||
|
||||
public static SimpleParticleType register(
|
||||
|
@ -77,7 +82,7 @@ public class BCLParticleType {
|
|||
boolean overrideLimiter,
|
||||
ParticleFactoryRegistry.PendingParticleFactory<SimpleParticleType> provider
|
||||
) {
|
||||
SimpleParticleType type = Registry.register(Registry.PARTICLE_TYPE, location, simple(overrideLimiter));
|
||||
SimpleParticleType type = Registry.register(BuiltInRegistries.PARTICLE_TYPE, location, simple(overrideLimiter));
|
||||
ParticleFactoryRegistry.getInstance().register(type, provider);
|
||||
return type;
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package org.betterx.bclib.recipes;
|
|||
import org.betterx.bclib.api.v2.advancement.AdvancementManager;
|
||||
|
||||
import net.minecraft.advancements.RequirementsStrategy;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.tags.TagKey;
|
||||
import net.minecraft.world.item.ArmorItem;
|
||||
|
|
|
@ -12,6 +12,7 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
|||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.NonNullList;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.TagParser;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
|
|
|
@ -3,6 +3,7 @@ package org.betterx.bclib.recipes;
|
|||
import org.betterx.bclib.util.CollectionsUtil;
|
||||
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.Container;
|
||||
import net.minecraft.world.item.Items;
|
||||
|
@ -103,12 +104,12 @@ public class BCLRecipeManager {
|
|||
String id,
|
||||
S serializer
|
||||
) {
|
||||
return Registry.register(Registry.RECIPE_SERIALIZER, modID + ":" + id, serializer);
|
||||
return Registry.register(BuiltInRegistries.RECIPE_SERIALIZER, modID + ":" + id, serializer);
|
||||
}
|
||||
|
||||
public static <C extends Container, T extends Recipe<C>> RecipeType<T> registerType(String modID, String type) {
|
||||
ResourceLocation recipeTypeId = new ResourceLocation(modID, type);
|
||||
return Registry.register(Registry.RECIPE_TYPE, recipeTypeId, new RecipeType<T>() {
|
||||
return Registry.register(BuiltInRegistries.RECIPE_TYPE, recipeTypeId, new RecipeType<T>() {
|
||||
public String toString() {
|
||||
return type;
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ import org.betterx.bclib.blocks.BaseFurnaceBlock;
|
|||
import org.betterx.bclib.blocks.BaseSignBlock;
|
||||
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
|
@ -29,35 +30,35 @@ public class BaseBlockEntities {
|
|||
ResourceLocation typeId,
|
||||
BlockEntitySupplier<? extends T> supplier
|
||||
) {
|
||||
return Registry.register(Registry.BLOCK_ENTITY_TYPE, typeId, new DynamicBlockEntityType<>(supplier));
|
||||
return Registry.register(BuiltInRegistries.BLOCK_ENTITY_TYPE, typeId, new DynamicBlockEntityType<>(supplier));
|
||||
}
|
||||
|
||||
public static void register() {
|
||||
}
|
||||
|
||||
public static Block[] getChests() {
|
||||
return Registry.BLOCK
|
||||
return BuiltInRegistries.BLOCK
|
||||
.stream()
|
||||
.filter(block -> block instanceof BaseChestBlock)
|
||||
.toArray(Block[]::new);
|
||||
}
|
||||
|
||||
public static Block[] getBarrels() {
|
||||
return Registry.BLOCK
|
||||
return BuiltInRegistries.BLOCK
|
||||
.stream()
|
||||
.filter(block -> block instanceof BaseBarrelBlock)
|
||||
.toArray(Block[]::new);
|
||||
}
|
||||
|
||||
public static Block[] getSigns() {
|
||||
return Registry.BLOCK
|
||||
return BuiltInRegistries.BLOCK
|
||||
.stream()
|
||||
.filter(block -> block instanceof BaseSignBlock)
|
||||
.toArray(Block[]::new);
|
||||
}
|
||||
|
||||
public static Block[] getFurnaces() {
|
||||
return Registry.BLOCK
|
||||
return BuiltInRegistries.BLOCK
|
||||
.stream()
|
||||
.filter(block -> block instanceof BaseFurnaceBlock)
|
||||
.toArray(Block[]::new);
|
||||
|
|
|
@ -12,6 +12,7 @@ import org.betterx.worlds.together.tag.v3.MineableTags;
|
|||
import org.betterx.worlds.together.tag.v3.TagManager;
|
||||
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.tags.BlockTags;
|
||||
import net.minecraft.tags.ItemTags;
|
||||
|
@ -49,7 +50,7 @@ public class BlockRegistry extends BaseRegistry<Block> {
|
|||
FlammableBlockRegistry.getDefaultInstance().add(block, 5, 5);
|
||||
}
|
||||
|
||||
block = Registry.register(Registry.BLOCK, id, block);
|
||||
block = Registry.register(BuiltInRegistries.BLOCK, id, block);
|
||||
getModBlocks(id.getNamespace()).add(block);
|
||||
|
||||
if (block instanceof BaseLeavesBlock) {
|
||||
|
@ -80,7 +81,7 @@ public class BlockRegistry extends BaseRegistry<Block> {
|
|||
return block;
|
||||
}
|
||||
getModBlocks(id.getNamespace()).add(block);
|
||||
return Registry.register(Registry.BLOCK, id, block);
|
||||
return Registry.register(BuiltInRegistries.BLOCK, id, block);
|
||||
}
|
||||
|
||||
private Item registerBlockItem(ResourceLocation id, BlockItem item) {
|
||||
|
@ -91,7 +92,7 @@ public class BlockRegistry extends BaseRegistry<Block> {
|
|||
@Override
|
||||
public void registerItem(ResourceLocation id, Item item) {
|
||||
if (item != null && item != Items.AIR) {
|
||||
Registry.register(Registry.ITEM, id, item);
|
||||
Registry.register(BuiltInRegistries.ITEM, id, item);
|
||||
getModBlockItems(id.getNamespace()).add(item);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ import net.minecraft.core.Direction;
|
|||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.dispenser.DefaultDispenseItemBehavior;
|
||||
import net.minecraft.core.dispenser.ShearsDispenseItemBehavior;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.world.effect.MobEffectInstance;
|
||||
|
@ -138,7 +139,7 @@ public class ItemRegistry extends BaseRegistry<Item> {
|
|||
@Override
|
||||
public void registerItem(ResourceLocation id, Item item) {
|
||||
if (item != null && item != Items.AIR) {
|
||||
Registry.register(Registry.ITEM, id, item);
|
||||
Registry.register(BuiltInRegistries.ITEM, id, item);
|
||||
getModItems(id.getNamespace()).add(item);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ public class PresetsRegistry implements WorldPresetBootstrap {
|
|||
BCLib.makeID("large"),
|
||||
(overworldStem, netherContext, endContext, noiseSettings, noiseBasedOverworld) -> {
|
||||
Holder<NoiseGeneratorSettings> largeBiomeGenerator = noiseSettings
|
||||
.getOrCreateHolderOrThrow(NoiseGeneratorSettings.LARGE_BIOMES);
|
||||
.getOrThrow(NoiseGeneratorSettings.LARGE_BIOMES);
|
||||
return buildPreset(
|
||||
noiseBasedOverworld.make(
|
||||
overworldStem.generator().getBiomeSource(),
|
||||
|
@ -61,14 +61,13 @@ public class PresetsRegistry implements WorldPresetBootstrap {
|
|||
BCLib.makeID("amplified"),
|
||||
(overworldStem, netherContext, endContext, noiseSettings, noiseBasedOverworld) -> {
|
||||
Holder<NoiseGeneratorSettings> amplifiedBiomeGenerator = noiseSettings
|
||||
.getOrCreateHolderOrThrow(NoiseGeneratorSettings.AMPLIFIED);
|
||||
.getOrThrow(NoiseGeneratorSettings.AMPLIFIED);
|
||||
|
||||
WorldGenUtil.Context amplifiedNetherContext = new WorldGenUtil.Context(
|
||||
netherContext.biomes,
|
||||
netherContext.dimension,
|
||||
netherContext.structureSets,
|
||||
netherContext.noiseParameters,
|
||||
Holder.direct(BCLChunkGenerator.amplifiedNether())
|
||||
noiseSettings.getOrThrow(BCLChunkGenerator.AMPLIFIED_NETHER)
|
||||
);
|
||||
|
||||
return buildPreset(
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package org.betterx.bclib.util;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.HolderLookup;
|
||||
import net.minecraft.core.Vec3i;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
|
@ -69,7 +68,7 @@ public class StructureHelper {
|
|||
CompoundTag nbttagcompound = NbtIo.readCompressed(stream);
|
||||
|
||||
StructureTemplate template = new StructureTemplate();
|
||||
template.load(HolderLookup.forRegistry(BuiltInRegistries.BLOCK), nbttagcompound);
|
||||
template.load(BuiltInRegistries.BLOCK.asLookup(), nbttagcompound);
|
||||
|
||||
return template;
|
||||
}
|
||||
|
|
|
@ -1,124 +0,0 @@
|
|||
package org.betterx.bclib.util;
|
||||
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.Set;
|
||||
|
||||
public class TranslationHelper {
|
||||
/**
|
||||
* Print English translation file lines. Translation is "auto-beautified" text (example "strange_thing" -> "Strange Thing").
|
||||
*
|
||||
* @param modID {@link String} mod ID string.
|
||||
*/
|
||||
public static void printMissingEnNames(String modID) {
|
||||
printMissingNames(modID, "en_us");
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints translation file lines for specified language.
|
||||
*
|
||||
* @param modID {@link String} mod ID string;
|
||||
* @param languageCode {@link String} language code (example "en_us", "ru_ru").
|
||||
*/
|
||||
public static void printMissingNames(String modID, String languageCode) {
|
||||
Set<String> missingNames = Sets.newHashSet();
|
||||
|
||||
Gson gson = new Gson();
|
||||
InputStream inputStream = TranslationHelper.class.getResourceAsStream("/assets/" + modID + "/lang/" + languageCode + ".json");
|
||||
JsonObject translation = inputStream == null
|
||||
? new JsonObject()
|
||||
: gson.fromJson(new InputStreamReader(inputStream), JsonObject.class);
|
||||
|
||||
BuiltInRegistries.BLOCK.forEach(block -> {
|
||||
if (BuiltInRegistries.BLOCK.getKey(block).getNamespace().equals(modID)) {
|
||||
String name = block.getName().getString();
|
||||
if (!translation.has(name)) {
|
||||
missingNames.add(name);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
BuiltInRegistries.ITEM.forEach(item -> {
|
||||
if (BuiltInRegistries.ITEM.getKey(item).getNamespace().equals(modID)) {
|
||||
String name = item.getDescription().getString();
|
||||
if (!translation.has(name)) {
|
||||
missingNames.add(name);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
BuiltinRegistries.BIOME.forEach(biome -> {
|
||||
ResourceLocation id = BuiltinRegistries.BIOME.getKey(biome);
|
||||
if (id.getNamespace().equals(modID)) {
|
||||
String name = "biome." + modID + "." + id.getPath();
|
||||
if (!translation.has(name)) {
|
||||
missingNames.add(name);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Registry.ENTITY_TYPE.forEach((entity) -> {
|
||||
ResourceLocation id = Registry.ENTITY_TYPE.getKey(entity);
|
||||
if (id.getNamespace().equals(modID)) {
|
||||
String name = "entity." + modID + "." + id.getPath();
|
||||
if (!translation.has(name)) {
|
||||
missingNames.add(name);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (!missingNames.isEmpty()) {
|
||||
|
||||
System.out.println("========================================");
|
||||
System.out.println(" MISSING NAMES LIST");
|
||||
|
||||
if (!missingNames.isEmpty()) {
|
||||
if (languageCode.equals("en_us")) {
|
||||
System.out.println("========================================");
|
||||
System.out.println(" AUTO ENGLISH BEAUTIFICATION");
|
||||
System.out.println("========================================");
|
||||
missingNames.stream().sorted().forEach(name -> {
|
||||
System.out.println(" \"" + name + "\": \"" + fastTranslateEn(name) + "\",");
|
||||
});
|
||||
} else {
|
||||
System.out.println("========================================");
|
||||
System.out.println(" TEMPLATE: [" + languageCode + "]");
|
||||
System.out.println("========================================");
|
||||
missingNames.stream().sorted().forEach(name -> {
|
||||
System.out.println(" \"" + name + "\": \"\",");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println("========================================");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Simple fast text beautification (example "strange_thing" -> "Strange Thing").
|
||||
*
|
||||
* @param text {@link String} to process;
|
||||
* @return {@link String} result.
|
||||
*/
|
||||
public static String fastTranslateEn(String text) {
|
||||
String[] words = text.substring(text.lastIndexOf('.') + 1).split("_");
|
||||
StringBuilder builder = new StringBuilder();
|
||||
for (int i = 0; i < words.length; i++) {
|
||||
String word = words[i];
|
||||
builder.append(Character.toUpperCase(word.charAt(0)));
|
||||
builder.append(word, 1, word.length());
|
||||
if (i < words.length - 1) {
|
||||
builder.append(' ');
|
||||
}
|
||||
}
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
|
@ -1,108 +0,0 @@
|
|||
package org.betterx.bclib.world.structures;
|
||||
|
||||
import org.betterx.bclib.api.v2.levelgen.structures.BCLStructureBuilder;
|
||||
import org.betterx.worlds.together.tag.v3.TagManager;
|
||||
|
||||
import com.mojang.serialization.Codec;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.tags.TagKey;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.levelgen.GenerationStep;
|
||||
import net.minecraft.world.level.levelgen.structure.Structure;
|
||||
import net.minecraft.world.level.levelgen.structure.TerrainAdjustment;
|
||||
import net.minecraft.world.level.levelgen.structure.placement.RandomSpreadStructurePlacement;
|
||||
import net.minecraft.world.level.levelgen.structure.placement.RandomSpreadType;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
@Deprecated(forRemoval = true)
|
||||
/**
|
||||
* Please use the {@link org.betterx.bclib.api.v2.levelgen.structures.BCLStructure} and
|
||||
* {@link BCLStructureBuilder} instead.
|
||||
* @deprecated Use {@link org.betterx.bclib.api.v2.levelgen.structures.BCLStructure} instead
|
||||
*/
|
||||
public class BCLStructure<S extends Structure> extends org.betterx.bclib.api.v2.levelgen.structures.BCLStructure<S> {
|
||||
|
||||
@Deprecated(forRemoval = true)
|
||||
/**
|
||||
* Please use the {@link BCLStructureBuilder} instead:
|
||||
*
|
||||
* BCLStructureBuilder
|
||||
* .start(id, structureBuilder)
|
||||
* .step(step)
|
||||
* .randomPlacement(spacing, separation)
|
||||
* .build();
|
||||
*/
|
||||
public BCLStructure(
|
||||
ResourceLocation id,
|
||||
Function<Structure.StructureSettings, S> structureBuilder,
|
||||
GenerationStep.Decoration step,
|
||||
int spacing,
|
||||
int separation
|
||||
) {
|
||||
this(id, structureBuilder, step, spacing, separation, false);
|
||||
}
|
||||
|
||||
@Deprecated(forRemoval = true)
|
||||
/**
|
||||
* Please use the {@link BCLStructureBuilder} instead:
|
||||
*
|
||||
* BCLStructureBuilder
|
||||
* .start(id, structureBuilder)
|
||||
* .step(step)
|
||||
* .randomPlacement(spacing, separation)
|
||||
* .build();
|
||||
*/
|
||||
public BCLStructure(
|
||||
ResourceLocation id,
|
||||
Function<Structure.StructureSettings, S> structureBuilder,
|
||||
GenerationStep.Decoration step,
|
||||
int spacing,
|
||||
int separation,
|
||||
boolean adaptNoise
|
||||
) {
|
||||
this(
|
||||
id,
|
||||
structureBuilder,
|
||||
step,
|
||||
spacing,
|
||||
separation,
|
||||
adaptNoise,
|
||||
Structure.simpleCodec(structureBuilder),
|
||||
TagManager.BIOMES.makeStructureTag(id.getNamespace(), id.getPath())
|
||||
);
|
||||
}
|
||||
|
||||
@Deprecated(forRemoval = true)
|
||||
/**
|
||||
*
|
||||
* Please use the {@link BCLStructureBuilder} instead:
|
||||
*
|
||||
* BCLStructureBuilder
|
||||
* .start(id, structureBuilder)
|
||||
* .step(step)
|
||||
* .randomPlacement(spacing, separation)
|
||||
* .codec(codec)
|
||||
* .biomeTag(biomeTag)
|
||||
* .build();
|
||||
*
|
||||
*/
|
||||
public BCLStructure(
|
||||
ResourceLocation id,
|
||||
Function<Structure.StructureSettings, S> structureBuilder,
|
||||
GenerationStep.Decoration step,
|
||||
int spacing,
|
||||
int separation,
|
||||
boolean adaptNoise,
|
||||
Codec<S> codec,
|
||||
TagKey<Biome> biomeTag
|
||||
) {
|
||||
super(id, structureBuilder, step, new RandomSpreadStructurePlacement(
|
||||
spacing,
|
||||
separation,
|
||||
RandomSpreadType.LINEAR,
|
||||
id.toString().hashCode()
|
||||
), codec, biomeTag, TerrainAdjustment.NONE);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,11 +1,11 @@
|
|||
package org.betterx.worlds.together.biomesource;
|
||||
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.HolderGetter;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.biome.BiomeSource;
|
||||
|
||||
public interface BiomeSourceFromRegistry<T extends BiomeSource> {
|
||||
Registry<Biome> getBiomeRegistry();
|
||||
HolderGetter<Biome> getBiomeRegistry();
|
||||
boolean didBiomeRegistryChange();
|
||||
|
||||
default <R extends BiomeSource> boolean togetherBiomeSourceContentChanged(BiomeSourceFromRegistry<R> other) {
|
||||
|
|
|
@ -12,6 +12,7 @@ import org.betterx.worlds.together.worldPreset.TogetherWorldPreset;
|
|||
import org.betterx.worlds.together.worldPreset.WorldPresets;
|
||||
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.HolderGetter;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
|
@ -28,7 +29,6 @@ import net.minecraft.world.level.levelgen.NoiseGeneratorSettings;
|
|||
import net.minecraft.world.level.levelgen.WorldDimensions;
|
||||
import net.minecraft.world.level.levelgen.presets.WorldPreset;
|
||||
import net.minecraft.world.level.levelgen.structure.StructureSet;
|
||||
import net.minecraft.world.level.levelgen.synth.NormalNoise;
|
||||
|
||||
import java.util.Map;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
@ -99,35 +99,31 @@ public class WorldGenUtil {
|
|||
}
|
||||
|
||||
public static class Context extends StemContext {
|
||||
public final Registry<Biome> biomes;
|
||||
public final HolderGetter<Biome> biomes;
|
||||
|
||||
public Context(
|
||||
Registry<Biome> biomes,
|
||||
HolderGetter<Biome> biomes,
|
||||
Holder<DimensionType> dimension,
|
||||
Registry<StructureSet> structureSets,
|
||||
Registry<NormalNoise.NoiseParameters> noiseParameters,
|
||||
HolderGetter<StructureSet> structureSets,
|
||||
Holder<NoiseGeneratorSettings> generatorSettings
|
||||
) {
|
||||
super(dimension, structureSets, noiseParameters, generatorSettings);
|
||||
super(dimension, structureSets, generatorSettings);
|
||||
this.biomes = biomes;
|
||||
}
|
||||
}
|
||||
|
||||
public static class StemContext {
|
||||
public final Holder<DimensionType> dimension;
|
||||
public final Registry<StructureSet> structureSets;
|
||||
public final Registry<NormalNoise.NoiseParameters> noiseParameters;
|
||||
public final HolderGetter<StructureSet> structureSets;
|
||||
public final Holder<NoiseGeneratorSettings> generatorSettings;
|
||||
|
||||
public StemContext(
|
||||
Holder<DimensionType> dimension,
|
||||
Registry<StructureSet> structureSets,
|
||||
Registry<NormalNoise.NoiseParameters> noiseParameters,
|
||||
HolderGetter<StructureSet> structureSets,
|
||||
Holder<NoiseGeneratorSettings> generatorSettings
|
||||
) {
|
||||
this.dimension = dimension;
|
||||
this.structureSets = structureSets;
|
||||
this.noiseParameters = noiseParameters;
|
||||
this.generatorSettings = generatorSettings;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,32 +0,0 @@
|
|||
package org.betterx.worlds.together.mixin.common;
|
||||
|
||||
import org.betterx.worlds.together.surfaceRules.SurfaceRuleRegistry;
|
||||
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(BuiltInRegistries.class)
|
||||
public class BuiltinRegistriesMixin {
|
||||
|
||||
@Inject(method = "<clinit>", at = @At(value = "INVOKE", target = "Ljava/util/Map;forEach(Ljava/util/function/BiConsumer;)V"))
|
||||
private static void together_registerSurface(CallbackInfo ci) {
|
||||
SurfaceRuleRegistry.BUILTIN_SURFACE_RULES = registerSimple(
|
||||
SurfaceRuleRegistry.SURFACE_RULES_REGISTRY,
|
||||
SurfaceRuleRegistry::bootstrap
|
||||
);
|
||||
}
|
||||
|
||||
@Shadow
|
||||
static protected <T> Registry<T> registerSimple(
|
||||
ResourceKey<? extends Registry<T>> resourceKey, BuiltInRegistries.RegistryBootstrap<T> registryBootstrap
|
||||
) {
|
||||
throw new RuntimeException("Shadowed Call");
|
||||
}
|
||||
}
|
|
@ -1,6 +1,5 @@
|
|||
package org.betterx.worlds.together.mixin.common;
|
||||
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.resources.RegistryOps;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
@ -8,6 +7,6 @@ import org.spongepowered.asm.mixin.gen.Accessor;
|
|||
|
||||
@Mixin(RegistryOps.class)
|
||||
public interface RegistryOpsAccessor {
|
||||
@Accessor("registryAccess")
|
||||
RegistryAccess bcl_getRegistryAccess();
|
||||
@Accessor("lookupProvider")
|
||||
RegistryOps.RegistryInfoLookup bcl_getLookupProvider();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
package org.betterx.worlds.together.mixin.common;
|
||||
|
||||
import org.betterx.worlds.together.surfaceRules.SurfaceRuleRegistry;
|
||||
|
||||
import net.minecraft.core.RegistrySetBuilder;
|
||||
import net.minecraft.data.registries.VanillaRegistries;
|
||||
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(VanillaRegistries.class)
|
||||
public class VanillaRegistriesMixin {
|
||||
@Shadow
|
||||
@Final
|
||||
private static RegistrySetBuilder BUILDER;
|
||||
|
||||
@Inject(method = "<clinit>", at = @At(value = "TAIL"))
|
||||
private static void together_registerSurface(CallbackInfo ci) {
|
||||
BUILDER.add(
|
||||
SurfaceRuleRegistry.SURFACE_RULES_REGISTRY,
|
||||
SurfaceRuleRegistry::bootstrap
|
||||
);
|
||||
}
|
||||
}
|
|
@ -4,15 +4,16 @@ import org.betterx.worlds.together.levelgen.WorldGenUtil;
|
|||
import org.betterx.worlds.together.worldPreset.WorldPresets;
|
||||
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.HolderGetter;
|
||||
import net.minecraft.data.worldgen.BootstapContext;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.biome.BiomeSource;
|
||||
import net.minecraft.world.level.dimension.DimensionType;
|
||||
import net.minecraft.world.level.dimension.LevelStem;
|
||||
import net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator;
|
||||
import net.minecraft.world.level.levelgen.NoiseGeneratorSettings;
|
||||
import net.minecraft.world.level.levelgen.placement.PlacedFeature;
|
||||
import net.minecraft.world.level.levelgen.presets.WorldPreset;
|
||||
import net.minecraft.world.level.levelgen.structure.StructureSet;
|
||||
import net.minecraft.world.level.levelgen.synth.NormalNoise;
|
||||
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
@ -24,29 +25,23 @@ import org.spongepowered.asm.mixin.injection.ModifyArg;
|
|||
public abstract class WorldPresetsBootstrapMixin {
|
||||
@Shadow
|
||||
@Final
|
||||
private Registry<WorldPreset> presets;
|
||||
private HolderGetter<Biome> biomes;
|
||||
@Shadow
|
||||
@Final
|
||||
private Registry<Biome> biomes;
|
||||
@Shadow
|
||||
@Final
|
||||
private Registry<StructureSet> structureSets;
|
||||
@Shadow
|
||||
@Final
|
||||
private Registry<NormalNoise.NoiseParameters> noises;
|
||||
@Shadow
|
||||
@Final
|
||||
private Holder<DimensionType> netherDimensionType;
|
||||
@Shadow
|
||||
@Final
|
||||
private Holder<NoiseGeneratorSettings> netherNoiseSettings;
|
||||
@Shadow
|
||||
@Final
|
||||
private Holder<DimensionType> endDimensionType;
|
||||
@Shadow
|
||||
@Final
|
||||
private Holder<NoiseGeneratorSettings> endNoiseSettings;
|
||||
private HolderGetter<StructureSet> structureSets;
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
private BootstapContext<WorldPreset> context;
|
||||
@Shadow
|
||||
@Final
|
||||
private HolderGetter<PlacedFeature> placedFeatures;
|
||||
@Shadow
|
||||
@Final
|
||||
private LevelStem netherStem;
|
||||
@Shadow
|
||||
@Final
|
||||
private LevelStem endStem;
|
||||
//see WorldPresets.register
|
||||
|
||||
@Shadow
|
||||
|
@ -57,27 +52,38 @@ public abstract class WorldPresetsBootstrapMixin {
|
|||
|
||||
@Shadow
|
||||
@Final
|
||||
private Registry<NoiseGeneratorSettings> noiseSettings;
|
||||
private HolderGetter<NoiseGeneratorSettings> noiseSettings;
|
||||
|
||||
@ModifyArg(method = "run", at = @At(value = "INVOKE", ordinal = 0, target = "Lnet/minecraft/world/level/levelgen/presets/WorldPresets$Bootstrap;registerCustomOverworldPreset(Lnet/minecraft/resources/ResourceKey;Lnet/minecraft/world/level/dimension/LevelStem;)Lnet/minecraft/core/Holder;"))
|
||||
@ModifyArg(method = "run", at = @At(value = "INVOKE", ordinal = 0, target = "Lnet/minecraft/world/level/levelgen/presets/WorldPresets$Bootstrap;registerCustomOverworldPreset(Lnet/minecraft/resources/ResourceKey;Lnet/minecraft/world/level/dimension/LevelStem;)V"))
|
||||
private LevelStem bcl_getOverworldStem(LevelStem overworldStem) {
|
||||
Holder<NoiseGeneratorSettings> netherSettings, endSettings;
|
||||
if (this.netherStem.generator() instanceof NoiseBasedChunkGenerator nether) {
|
||||
netherSettings = nether.generatorSettings();
|
||||
} else {
|
||||
netherSettings = this.noiseSettings.getOrThrow(NoiseGeneratorSettings.NETHER);
|
||||
}
|
||||
|
||||
if (this.endStem.generator() instanceof NoiseBasedChunkGenerator nether) {
|
||||
endSettings = nether.generatorSettings();
|
||||
} else {
|
||||
endSettings = this.noiseSettings.getOrThrow(NoiseGeneratorSettings.END);
|
||||
}
|
||||
|
||||
WorldGenUtil.Context netherContext = new WorldGenUtil.Context(
|
||||
this.biomes,
|
||||
this.netherDimensionType,
|
||||
this.netherStem.type(),
|
||||
this.structureSets,
|
||||
this.noises,
|
||||
this.netherNoiseSettings
|
||||
netherSettings
|
||||
);
|
||||
WorldGenUtil.Context endContext = new WorldGenUtil.Context(
|
||||
this.biomes,
|
||||
this.endDimensionType,
|
||||
this.endStem.type(),
|
||||
this.structureSets,
|
||||
this.noises,
|
||||
this.endNoiseSettings
|
||||
endSettings
|
||||
);
|
||||
|
||||
WorldPresets.bootstrapPresets(
|
||||
presets,
|
||||
context,
|
||||
overworldStem,
|
||||
netherContext,
|
||||
endContext,
|
||||
|
|
|
@ -2,16 +2,16 @@ package org.betterx.worlds.together.surfaceRules;
|
|||
|
||||
import org.betterx.worlds.together.WorldsTogether;
|
||||
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.data.worldgen.BootstapContext;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.dimension.LevelStem;
|
||||
import net.minecraft.world.level.levelgen.SurfaceRules;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.Predicate;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
|
@ -21,40 +21,50 @@ public class SurfaceRuleRegistry {
|
|||
public static final Predicate<ResourceKey<LevelStem>> NON_MANAGED_DIMENSIONS = dim -> dim != LevelStem.NETHER && dim != LevelStem.END;
|
||||
public static final Predicate<ResourceKey<LevelStem>> ALL_DIMENSIONS = dim -> true;
|
||||
|
||||
public static Registry<AssignedSurfaceRule> BUILTIN_SURFACE_RULES;
|
||||
//public static Registry<AssignedSurfaceRule> BUILTIN_SURFACE_RULES;
|
||||
|
||||
private static <T> ResourceKey<Registry<T>> createRegistryKey(ResourceLocation location) {
|
||||
return ResourceKey.createRegistryKey(location);
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
public static Holder<AssignedSurfaceRule> bootstrap(Registry<AssignedSurfaceRule> registry) {
|
||||
return BuiltInRegistries.register(
|
||||
registry,
|
||||
WorldsTogether.makeID("dummy"),
|
||||
new AssignedSurfaceRule(
|
||||
SurfaceRules.state(Blocks.YELLOW_CONCRETE.defaultBlockState()),
|
||||
WorldsTogether.makeID("none")
|
||||
)
|
||||
);
|
||||
public static void bootstrap(BootstapContext<AssignedSurfaceRule> ctx) {
|
||||
// ctx.register(
|
||||
// ResourceKey.create(
|
||||
// SurfaceRuleRegistry.SURFACE_RULES_REGISTRY,
|
||||
// WorldsTogether.makeID("dummy")
|
||||
// ),
|
||||
// new AssignedSurfaceRule(
|
||||
// SurfaceRules.state(Blocks.YELLOW_CONCRETE.defaultBlockState()),
|
||||
// WorldsTogether.makeID("none")
|
||||
// )
|
||||
// );
|
||||
for (var entry : KNOWN.entrySet()) {
|
||||
ctx.register(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
private static Map<ResourceKey<AssignedSurfaceRule>, AssignedSurfaceRule> KNOWN = new HashMap<>();
|
||||
|
||||
public static ResourceKey<AssignedSurfaceRule> registerRule(
|
||||
ResourceLocation ruleID,
|
||||
SurfaceRules.RuleSource rules,
|
||||
ResourceLocation biomeID
|
||||
) {
|
||||
ResourceKey<AssignedSurfaceRule> key = ResourceKey.create(
|
||||
final ResourceKey<AssignedSurfaceRule> key = ResourceKey.create(
|
||||
SurfaceRuleRegistry.SURFACE_RULES_REGISTRY,
|
||||
ruleID
|
||||
);
|
||||
Registry.register(SurfaceRuleRegistry.BUILTIN_SURFACE_RULES, key, new AssignedSurfaceRule(
|
||||
KNOWN.put(
|
||||
key,
|
||||
new AssignedSurfaceRule(
|
||||
SurfaceRules.ifTrue(
|
||||
SurfaceRules.isBiome(ResourceKey.create(Registries.BIOME, biomeID)),
|
||||
rules
|
||||
), biomeID
|
||||
)
|
||||
);
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,10 +19,13 @@ import java.util.stream.Collectors;
|
|||
|
||||
public class SurfaceRuleUtil {
|
||||
private static List<SurfaceRules.RuleSource> getRulesForBiome(ResourceLocation biomeID) {
|
||||
Registry<AssignedSurfaceRule> registry = SurfaceRuleRegistry.BUILTIN_SURFACE_RULES;
|
||||
Registry<AssignedSurfaceRule> registry = null;
|
||||
if (WorldBootstrap.getLastRegistryAccess() != null)
|
||||
registry = WorldBootstrap.getLastRegistryAccess()
|
||||
.registryOrThrow(SurfaceRuleRegistry.SURFACE_RULES_REGISTRY);
|
||||
|
||||
if (registry == null) return List.of();
|
||||
|
||||
return registry.stream()
|
||||
.filter(a -> a != null && a.biomeID != null && a.biomeID.equals(
|
||||
biomeID))
|
||||
|
|
|
@ -111,7 +111,7 @@ public class WorldBootstrap {
|
|||
public static class DedicatedServer {
|
||||
public static void registryReady(RegistryOps<Tag> regOps) {
|
||||
if (regOps instanceof RegistryOpsAccessor acc) {
|
||||
Helpers.onRegistryReady(acc.bcl_getRegistryAccess());
|
||||
//Helpers.onRegistryReady(acc.bcl_getLookupProvider().);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,6 @@ import com.mojang.serialization.codecs.RecordCodecBuilder;
|
|||
import net.minecraft.core.MappedRegistry;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.NbtOps;
|
||||
|
@ -30,6 +29,7 @@ import java.util.HashMap;
|
|||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class TogetherWorldPreset extends WorldPreset {
|
||||
public final int sortOrder;
|
||||
|
@ -152,12 +152,13 @@ public class TogetherWorldPreset extends WorldPreset {
|
|||
}
|
||||
}
|
||||
|
||||
public static Registry<LevelStem> getDimensions(ResourceKey<WorldPreset> key) {
|
||||
public static @Nullable Registry<LevelStem> getDimensions(ResourceKey<WorldPreset> key) {
|
||||
RegistryAccess access = WorldBootstrap.getLastRegistryAccessOrElseBuiltin();
|
||||
var preset = (access == null
|
||||
? BuiltInRegistries.WORLD_PRESET
|
||||
: access.registryOrThrow(Registries.WORLD_PRESET))
|
||||
.getHolder(key);
|
||||
if (access == null) {
|
||||
WorldsTogether.LOGGER.error("No valid registry found!");
|
||||
return null;
|
||||
}
|
||||
var preset = access.registryOrThrow(Registries.WORLD_PRESET).getHolder(key);
|
||||
if (preset.isEmpty()) return null;
|
||||
return preset
|
||||
.get()
|
||||
|
|
|
@ -9,10 +9,10 @@ import org.betterx.worlds.together.tag.v3.TagRegistry;
|
|||
import org.betterx.worlds.together.worldPreset.client.WorldPresetsClient;
|
||||
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.HolderGetter;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.data.worldgen.BootstapContext;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.tags.WorldPresetTags;
|
||||
|
@ -32,8 +32,8 @@ public class WorldPresets {
|
|||
LevelStem make(BiomeSource biomeSource, Holder<NoiseGeneratorSettings> noiseGeneratorSettings);
|
||||
}
|
||||
|
||||
public static final TagRegistry.Simple<WorldPreset> WORLD_PRESETS =
|
||||
TagManager.registerType(BuiltInRegistries.WORLD_PRESET, "tags/worldgen/world_preset");
|
||||
public static final TagRegistry.UnTyped<WorldPreset> WORLD_PRESETS =
|
||||
TagManager.registerType(Registries.WORLD_PRESET, "tags/worldgen/world_preset");
|
||||
private static Map<ResourceKey<WorldPreset>, PresetBuilder> BUILDERS = Maps.newHashMap();
|
||||
private static ResourceKey<WorldPreset> DEFAULT = net.minecraft.world.level.levelgen.presets.WorldPresets.NORMAL;
|
||||
|
||||
|
@ -87,23 +87,24 @@ public class WorldPresets {
|
|||
|
||||
@ApiStatus.Internal
|
||||
public static void bootstrapPresets(
|
||||
Registry<WorldPreset> presets,
|
||||
BootstapContext<WorldPreset> bootstrapContext,
|
||||
LevelStem overworldStem,
|
||||
WorldGenUtil.Context netherContext,
|
||||
WorldGenUtil.Context endContext,
|
||||
Registry<NoiseGeneratorSettings> noiseSettings,
|
||||
HolderGetter<NoiseGeneratorSettings> noiseSettings,
|
||||
OverworldBuilder noiseBasedOverworld
|
||||
) {
|
||||
EntrypointUtil.getCommon(WorldPresetBootstrap.class)
|
||||
.forEach(e -> e.bootstrapWorldPresets());
|
||||
|
||||
for (Map.Entry<ResourceKey<WorldPreset>, PresetBuilder> e : BUILDERS.entrySet()) {
|
||||
TogetherWorldPreset preset = e.getValue()
|
||||
.create(
|
||||
overworldStem, netherContext, endContext,
|
||||
noiseSettings, noiseBasedOverworld
|
||||
);
|
||||
BuiltInRegistries.register(presets, e.getKey(), preset);
|
||||
//TODO:1.19.3 called out of sync
|
||||
// TogetherWorldPreset preset = e.getValue()
|
||||
// .create(
|
||||
// overworldStem, netherContext, endContext,
|
||||
// noiseSettings, noiseBasedOverworld
|
||||
// );
|
||||
// bootstrapContext.register(e.getKey(), preset);
|
||||
}
|
||||
BUILDERS = null;
|
||||
}
|
||||
|
@ -127,7 +128,7 @@ public class WorldPresets {
|
|||
LevelStem overworldStem,
|
||||
WorldGenUtil.Context netherContext,
|
||||
WorldGenUtil.Context endContext,
|
||||
Registry<NoiseGeneratorSettings> noiseSettings,
|
||||
HolderGetter<NoiseGeneratorSettings> noiseSettings,
|
||||
OverworldBuilder noiseBasedOverworld
|
||||
);
|
||||
}
|
||||
|
|
|
@ -7,13 +7,12 @@ import net.minecraft.world.level.levelgen.presets.WorldPreset;
|
|||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public class WorldPresetsClient {
|
||||
public static void registerCustomizeUI(ResourceKey<WorldPreset> key, PresetEditor setupScreen) {
|
||||
if (setupScreen != null) {
|
||||
PresetEditor.EDITORS.put(Optional.of(key), setupScreen);
|
||||
//TODO: 1.19.3 this is called out of order
|
||||
//PresetEditor.EDITORS.put(Optional.of(key), setupScreen);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,6 @@ accessible class net/minecraft/world/level/levelgen/SurfaceRules$SequenceRuleSou
|
|||
accessible class net/minecraft/world/level/levelgen/presets/WorldPresets$Bootstrap
|
||||
extendable class net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator
|
||||
accessible class net/minecraft/core/registries/BuiltInRegistries$RegistryBootstrap
|
||||
accessible class net/minecraft/core/Registry$RegistryBootstrap
|
||||
accessible class net/minecraft/world/level/levelgen/SurfaceRules$SequenceRuleSource
|
||||
accessible class net/minecraft/server/dedicated/DedicatedServerProperties$WorldDimensionData
|
||||
|
||||
|
@ -20,11 +19,11 @@ accessible method net/minecraft/client/gui/screens/worldselection/WorldGenSettin
|
|||
accessible method net/minecraft/world/level/storage/loot/LootPool <init> ([Lnet/minecraft/world/level/storage/loot/entries/LootPoolEntryContainer;[Lnet/minecraft/world/level/storage/loot/predicates/LootItemCondition;[Lnet/minecraft/world/level/storage/loot/functions/LootItemFunction;Lnet/minecraft/world/level/storage/loot/providers/number/NumberProvider;Lnet/minecraft/world/level/storage/loot/providers/number/NumberProvider;)V
|
||||
accessible method net/minecraft/world/entity/ai/village/poi/PoiTypes register (Lnet/minecraft/core/Registry;Lnet/minecraft/resources/ResourceKey;Ljava/util/Set;II)Lnet/minecraft/world/entity/ai/village/poi/PoiType;
|
||||
accessible method net/minecraft/world/level/levelgen/SurfaceRules$SequenceRuleSource <init> (Ljava/util/List;)V
|
||||
accessible method net/minecraft/core/Registry registerSimple (Lnet/minecraft/resources/ResourceKey;Lnet/minecraft/core/Registry$RegistryBootstrap;)Lnet/minecraft/core/Registry;
|
||||
accessible method net/minecraft/core/registries/BuiltInRegistries registerSimple (Lnet/minecraft/resources/ResourceKey;Lnet/minecraft/core/registries/BuiltInRegistries$RegistryBootstrap;)Lnet/minecraft/core/Registry;
|
||||
accessible method net/minecraft/world/entity/SpawnPlacements register (Lnet/minecraft/world/entity/EntityType;Lnet/minecraft/world/entity/SpawnPlacements$Type;Lnet/minecraft/world/level/levelgen/Heightmap$Types;Lnet/minecraft/world/entity/SpawnPlacements$SpawnPredicate;)V
|
||||
accessible method net/minecraft/world/level/block/state/properties/WoodType register (Lnet/minecraft/world/level/block/state/properties/WoodType;)Lnet/minecraft/world/level/block/state/properties/WoodType;
|
||||
accessible method net/minecraft/world/level/levelgen/NoiseRouterData nether (Lnet/minecraft/core/Registry;)Lnet/minecraft/world/level/levelgen/NoiseRouter;
|
||||
accessible method net/minecraft/world/level/levelgen/NoiseRouterData noNewCaves (Lnet/minecraft/core/Registry;Lnet/minecraft/world/level/levelgen/DensityFunction;)Lnet/minecraft/world/level/levelgen/NoiseRouter;
|
||||
accessible method net/minecraft/world/level/levelgen/NoiseRouterData slideNetherLike (Lnet/minecraft/core/Registry;II)Lnet/minecraft/world/level/levelgen/DensityFunction;
|
||||
accessible method net/minecraft/world/level/levelgen/NoiseRouterData nether (Lnet/minecraft/core/HolderGetter;Lnet/minecraft/core/HolderGetter;)Lnet/minecraft/world/level/levelgen/NoiseRouter;
|
||||
accessible method net/minecraft/world/level/levelgen/NoiseRouterData noNewCaves (Lnet/minecraft/core/HolderGetter;Lnet/minecraft/core/HolderGetter;Lnet/minecraft/world/level/levelgen/DensityFunction;)Lnet/minecraft/world/level/levelgen/NoiseRouter;
|
||||
accessible method net/minecraft/world/level/levelgen/NoiseRouterData slideNetherLike (Lnet/minecraft/core/HolderGetter;II)Lnet/minecraft/world/level/levelgen/DensityFunction;
|
||||
#Fields
|
||||
accessible field net/minecraft/world/entity/ai/village/poi/PoiTypes TYPE_BY_STATE Ljava/util/Map;
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"schemaVersion": 1,
|
||||
"id": "bclib",
|
||||
"version": "2.1.5",
|
||||
"version": "2.2.0",
|
||||
"name": "BCLib",
|
||||
"description": "A library for BetterX team mods",
|
||||
"authors": [
|
||||
|
@ -37,7 +37,7 @@
|
|||
"org.betterx.bclib.integration.emi.EMIPlugin"
|
||||
],
|
||||
"fabric-datagen": [
|
||||
"org.betterx.bclib.BCLibDatagen"
|
||||
"org.betterx.bclib.datagen.BCLibDatagen"
|
||||
]
|
||||
},
|
||||
"accessWidener": "bclib.accesswidener",
|
||||
|
@ -52,7 +52,7 @@
|
|||
"fabricloader": ">=0.14.10",
|
||||
"fabric": ">=0.65.0",
|
||||
"minecraft": [
|
||||
"1.19.3-alpha.22.43.a"
|
||||
"1.19.3-beta.3"
|
||||
]
|
||||
},
|
||||
"custom": {
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
"compatibilityLevel": "JAVA_17",
|
||||
"mixins": [
|
||||
"BiomeSourceMixin",
|
||||
"BuiltinRegistriesMixin",
|
||||
"DedicatedServerPropertiesMixin",
|
||||
"DiggerItemAccessor",
|
||||
"MainDataMixin",
|
||||
|
@ -17,6 +16,7 @@
|
|||
"RegistryDataLoaderMixin",
|
||||
"RegistryOpsAccessor",
|
||||
"TagLoaderMixin",
|
||||
"VanillaRegistriesMixin",
|
||||
"WorldGenPropertiesMixin",
|
||||
"WorldLoaderMixin",
|
||||
"WorldPresetAccessor",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue