Compiling version (some features are currently disabled and need a rewrite)

This commit is contained in:
Frank 2022-10-25 17:19:22 +02:00
parent b1f4173ce4
commit f8bcba4d3a
48 changed files with 488 additions and 506 deletions

View file

@ -1,7 +1,7 @@
# Done to increase the memory available to gradle. # Done to increase the memory available to gradle.
org.gradle.jvmargs=-Xmx8G org.gradle.jvmargs=-Xmx8G
#Modrinth #Modrinth
modrinth_versions=["1.19", "1.19.1", "1.19.2"] modrinth_versions=["22w42a"]
release_channel=release #`release`, `beta` or `alpha` release_channel=release #`release`, `beta` or `alpha`
#Loom #Loom
loom_version=1.0-SNAPSHOT loom_version=1.0-SNAPSHOT
@ -9,7 +9,7 @@ loom_version=1.0-SNAPSHOT
# check these on https://fabricmc.net/versions.html # check these on https://fabricmc.net/versions.html
minecraft_version=22w42a minecraft_version=22w42a
loader_version=0.14.10 loader_version=0.14.10
fabric_version=0.60.0+1.19.2 fabric_version=0.65.0+1.19.3
# Mod Properties # Mod Properties
mod_version=2.1.3 mod_version=2.1.3
maven_group=org.betterx.bclib maven_group=org.betterx.bclib

View file

@ -8,6 +8,7 @@ import org.betterx.bclib.api.v2.levelgen.LevelGenUtil;
import org.betterx.bclib.config.Configs; import org.betterx.bclib.config.Configs;
import net.minecraft.core.RegistryAccess; import net.minecraft.core.RegistryAccess;
import net.minecraft.data.BuiltinRegistries;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtOps; import net.minecraft.nbt.NbtOps;
import net.minecraft.nbt.Tag; import net.minecraft.nbt.Tag;
@ -42,7 +43,7 @@ final class BiomeSourcePatch extends ForcedLevelPatch {
final CompoundTag worldGenSettings = root.getCompound("Data").getCompound("WorldGenSettings"); final CompoundTag worldGenSettings = root.getCompound("Data").getCompound("WorldGenSettings");
final CompoundTag dimensions = worldGenSettings.getCompound("dimensions"); final CompoundTag dimensions = worldGenSettings.getCompound("dimensions");
final RegistryAccess registryAccess = RegistryAccess.builtinCopy(); final RegistryAccess registryAccess = BuiltinRegistries.createAccess();
final RegistryOps<Tag> registryOps = RegistryOps.create(NbtOps.INSTANCE, registryAccess); final RegistryOps<Tag> registryOps = RegistryOps.create(NbtOps.INSTANCE, registryAccess);

View file

@ -28,7 +28,10 @@ public abstract class BCLBiomeSource extends BiomeSource implements BiomeSourceW
protected long currentSeed; protected long currentSeed;
protected int maxHeight; protected int maxHeight;
private static List<Holder<Biome>> preInit(Registry<Biome> biomeRegistry, List<Holder<Biome>> biomes) { private static List<Holder<Biome>> preInit(
Registry<Biome> biomeRegistry,
List<Holder<Biome>> biomes
) {
biomes = biomes.stream().sorted(Comparator.comparing(holder -> holder.unwrapKey() biomes = biomes.stream().sorted(Comparator.comparing(holder -> holder.unwrapKey()
.get() .get()
.location() .location()
@ -108,8 +111,9 @@ public abstract class BCLBiomeSource extends BiomeSource implements BiomeSourceW
return biomeRegistry.stream() return biomeRegistry.stream()
.filter(biome -> biomeRegistry.getResourceKey(biome).isPresent()) .filter(biome -> biomeRegistry.getResourceKey(biome).isPresent())
.map(biome -> biomeRegistry.getOrCreateHolderOrThrow(biomeRegistry.getResourceKey(biome) .map(biome -> (Holder<Biome>) biomeRegistry.getOrCreateHolderOrThrow(
.get())) biomeRegistry.getResourceKey(biome).get())
)
.filter(biome -> { .filter(biome -> {
ResourceLocation location = biome.unwrapKey().orElseThrow().location(); ResourceLocation location = biome.unwrapKey().orElseThrow().location();
final String strLocation = location.toString(); final String strLocation = location.toString();

View file

@ -30,7 +30,7 @@ import net.minecraft.world.level.dimension.LevelStem;
import net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator; import net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator;
import net.minecraft.world.level.levelgen.NoiseGeneratorSettings; import net.minecraft.world.level.levelgen.NoiseGeneratorSettings;
import net.minecraft.world.level.levelgen.RandomState; import net.minecraft.world.level.levelgen.RandomState;
import net.minecraft.world.level.levelgen.WorldGenSettings; import net.minecraft.world.level.levelgen.WorldDimensions;
import net.minecraft.world.level.levelgen.structure.StructureSet; import net.minecraft.world.level.levelgen.structure.StructureSet;
import net.minecraft.world.level.levelgen.synth.NormalNoise; import net.minecraft.world.level.levelgen.synth.NormalNoise;
@ -55,7 +55,7 @@ public class BCLChunkGenerator extends NoiseBasedChunkGenerator implements Resto
RecordCodecBuilder<BCLChunkGenerator, Holder<NoiseGeneratorSettings>> settingsCodec = NoiseGeneratorSettings.CODEC RecordCodecBuilder<BCLChunkGenerator, Holder<NoiseGeneratorSettings>> settingsCodec = NoiseGeneratorSettings.CODEC
.fieldOf("settings") .fieldOf("settings")
.forGetter((BCLChunkGenerator generator) -> generator.settings); .forGetter((BCLChunkGenerator generator) -> generator.generatorSettings());
return NoiseBasedChunkGenerator return NoiseBasedChunkGenerator
@ -157,12 +157,12 @@ public class BCLChunkGenerator extends NoiseBasedChunkGenerator implements Resto
} }
@Override @Override
public WorldGenSettings enforceGeneratorInWorldGenSettings( public WorldDimensions enforceGeneratorInWorldGenSettings(
RegistryAccess access, RegistryAccess access,
ResourceKey<LevelStem> dimensionKey, ResourceKey<LevelStem> dimensionKey,
ResourceKey<DimensionType> dimensionTypeKey, ResourceKey<DimensionType> dimensionTypeKey,
ChunkGenerator loadedChunkGenerator, ChunkGenerator loadedChunkGenerator,
WorldGenSettings settings WorldDimensions worldDims
) { ) {
BCLib.LOGGER.info("Enforcing Correct Generator for " + dimensionKey.location().toString() + "."); BCLib.LOGGER.info("Enforcing Correct Generator for " + dimensionKey.location().toString() + ".");
@ -195,7 +195,7 @@ public class BCLChunkGenerator extends NoiseBasedChunkGenerator implements Resto
dimensionKey, dimensionKey,
dimensionTypeKey, dimensionTypeKey,
access, access,
settings, worldDims,
referenceGenerator referenceGenerator
); );

View file

@ -21,6 +21,7 @@ import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.TagLoader; import net.minecraft.tags.TagLoader;
import net.minecraft.world.level.chunk.ChunkGenerator; import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.dimension.LevelStem; import net.minecraft.world.level.dimension.LevelStem;
import net.minecraft.world.level.levelgen.WorldDimensions;
import net.minecraft.world.level.levelgen.WorldGenSettings; import net.minecraft.world.level.levelgen.WorldGenSettings;
import net.minecraft.world.level.levelgen.presets.WorldPreset; import net.minecraft.world.level.levelgen.presets.WorldPreset;
import net.minecraft.world.level.storage.LevelStorageSource; import net.minecraft.world.level.storage.LevelStorageSource;
@ -71,9 +72,9 @@ public class LevelGenEvents {
private static Optional<Holder<WorldPreset>> adaptWorldPresetSettings( private static Optional<Holder<WorldPreset>> adaptWorldPresetSettings(
Optional<Holder<WorldPreset>> currentPreset, Optional<Holder<WorldPreset>> currentPreset,
WorldGenSettings worldGenSettings WorldDimensions worldDims
) { ) {
LevelStem endStem = worldGenSettings.dimensions().get(LevelStem.END); LevelStem endStem = worldDims.dimensions().get(LevelStem.END);
//We probably loaded a Datapack for the End //We probably loaded a Datapack for the End
if (!(endStem.generator().getBiomeSource() instanceof BCLibEndBiomeSource)) { if (!(endStem.generator().getBiomeSource() instanceof BCLibEndBiomeSource)) {

View file

@ -22,7 +22,7 @@ import net.minecraft.resources.ResourceKey;
import net.minecraft.world.level.chunk.ChunkGenerator; import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.dimension.DimensionType; import net.minecraft.world.level.dimension.DimensionType;
import net.minecraft.world.level.dimension.LevelStem; import net.minecraft.world.level.dimension.LevelStem;
import net.minecraft.world.level.levelgen.WorldGenSettings; import net.minecraft.world.level.levelgen.WorldDimensions;
import net.minecraft.world.level.levelgen.presets.WorldPreset; import net.minecraft.world.level.levelgen.presets.WorldPreset;
import net.minecraft.world.level.levelgen.presets.WorldPresets; import net.minecraft.world.level.levelgen.presets.WorldPresets;
@ -64,11 +64,11 @@ public class LevelGenUtil {
} }
public static WorldGenSettings replaceGenerator( public static WorldDimensions replaceGenerator(
ResourceKey<LevelStem> dimensionKey, ResourceKey<LevelStem> dimensionKey,
ResourceKey<DimensionType> dimensionTypeKey, ResourceKey<DimensionType> dimensionTypeKey,
RegistryAccess registryAccess, RegistryAccess registryAccess,
WorldGenSettings worldGenSettings, WorldDimensions worldDimensions,
ChunkGenerator generator ChunkGenerator generator
) { ) {
Registry<DimensionType> dimensionTypeRegistry = registryAccess.registryOrThrow(Registry.DIMENSION_TYPE_REGISTRY); Registry<DimensionType> dimensionTypeRegistry = registryAccess.registryOrThrow(Registry.DIMENSION_TYPE_REGISTRY);
@ -76,15 +76,10 @@ public class LevelGenUtil {
dimensionKey, dimensionKey,
dimensionTypeKey, dimensionTypeKey,
dimensionTypeRegistry, dimensionTypeRegistry,
worldGenSettings.dimensions(), worldDimensions.dimensions(),
generator generator
); );
return new WorldGenSettings( return new WorldDimensions(newDimensions);
worldGenSettings.seed(),
worldGenSettings.generateStructures(),
worldGenSettings.generateBonusChest(),
newDimensions
);
} }
public static Registry<LevelStem> withDimension( public static Registry<LevelStem> withDimension(
@ -98,7 +93,7 @@ public class LevelGenUtil {
LevelStem levelStem = inputDimensions.get(dimensionKey); LevelStem levelStem = inputDimensions.get(dimensionKey);
Holder<DimensionType> dimensionType = levelStem == null Holder<DimensionType> dimensionType = levelStem == null
? dimensionTypeRegistry.getOrCreateHolderOrThrow(dimensionTypeKey) ? dimensionTypeRegistry.getOrCreateHolderOrThrow(dimensionTypeKey)
: levelStem.typeHolder(); : levelStem.type();
return withDimension(dimensionKey, inputDimensions, new LevelStem(dimensionType, generator)); return withDimension(dimensionKey, inputDimensions, new LevelStem(dimensionType, generator));
} }
@ -109,8 +104,7 @@ public class LevelGenUtil {
) { ) {
MappedRegistry<LevelStem> writableRegistry = new MappedRegistry<>( MappedRegistry<LevelStem> writableRegistry = new MappedRegistry<>(
Registry.LEVEL_STEM_REGISTRY, Registry.LEVEL_STEM_REGISTRY,
Lifecycle.experimental(), Lifecycle.experimental()
null
); );
writableRegistry.register( writableRegistry.register(
dimensionKey, dimensionKey,

View file

@ -33,7 +33,7 @@ public class BCLBiomeRegistry {
); );
public static Registry<BCLBiome> BUILTIN_BCL_BIOMES = new MappedRegistry<>( public static Registry<BCLBiome> BUILTIN_BCL_BIOMES = new MappedRegistry<>(
BCL_BIOMES_REGISTRY, BCL_BIOMES_REGISTRY,
Lifecycle.stable(), null Lifecycle.stable()
); );
/** /**

View file

@ -4,6 +4,8 @@ import org.betterx.bclib.BCLib;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos; 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.Vec3i;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtIo; import net.minecraft.nbt.NbtIo;
@ -102,7 +104,7 @@ public class StructureNBT {
CompoundTag nbttagcompound = NbtIo.readCompressed(stream); CompoundTag nbttagcompound = NbtIo.readCompressed(stream);
StructureTemplate template = new StructureTemplate(); StructureTemplate template = new StructureTemplate();
template.load(nbttagcompound); template.load(HolderLookup.forRegistry(Registry.BLOCK), nbttagcompound);
return template; return template;
} }

View file

@ -1,6 +1,8 @@
package org.betterx.bclib.api.v2.levelgen.structures; package org.betterx.bclib.api.v2.levelgen.structures;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.HolderLookup;
import net.minecraft.core.Registry;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag; import net.minecraft.nbt.ListTag;
import net.minecraft.nbt.NbtUtils; import net.minecraft.nbt.NbtUtils;
@ -117,7 +119,11 @@ public class StructureWorld {
ListTag map2 = tag.getList("states", 10); ListTag map2 = tag.getList("states", 10);
BlockState[] states = new BlockState[map2.size()]; BlockState[] states = new BlockState[map2.size()];
for (int i = 0; i < states.length; i++) { for (int i = 0; i < states.length; i++) {
states[i] = NbtUtils.readBlockState((CompoundTag) map2.get(i)); states[i] = NbtUtils.readBlockState(
//TODO: 1.19.3 This appears to be used on a level registry, not the global one?
HolderLookup.forRegistry(Registry.BLOCK),
(CompoundTag) map2.get(i)
);
} }
map.forEach((element) -> { map.forEach((element) -> {

View file

@ -10,6 +10,7 @@ import net.minecraft.client.resources.model.BlockModelRotation;
import net.minecraft.client.resources.model.UnbakedModel; import net.minecraft.client.resources.model.UnbakedModel;
import net.minecraft.core.Registry; import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.ButtonBlock; import net.minecraft.world.level.block.ButtonBlock;
@ -30,7 +31,14 @@ public abstract class BaseButtonBlock extends ButtonBlock implements BlockModelP
private final Block parent; private final Block parent;
protected BaseButtonBlock(Block parent, Properties properties, boolean sensitive) { protected BaseButtonBlock(Block parent, Properties properties, boolean sensitive) {
super(sensitive, properties.noCollission()); this(parent, properties, 30, sensitive);
}
protected BaseButtonBlock(Block parent, Properties properties, int ticksToStayPressed, boolean sensitive) {
super(
properties.noCollission(), ticksToStayPressed, sensitive,
SoundEvents.STONE_BUTTON_CLICK_OFF, SoundEvents.STONE_BUTTON_CLICK_ON
);
this.parent = parent; this.parent = parent;
} }

View file

@ -13,6 +13,7 @@ import net.minecraft.client.resources.model.BlockModelRotation;
import net.minecraft.client.resources.model.UnbakedModel; import net.minecraft.client.resources.model.UnbakedModel;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.tags.BlockTags; import net.minecraft.tags.BlockTags;
import net.minecraft.tags.ItemTags; import net.minecraft.tags.ItemTags;
import net.minecraft.tags.TagKey; import net.minecraft.tags.TagKey;
@ -42,7 +43,7 @@ public class BaseDoorBlock extends DoorBlock implements RenderLayerProvider, Blo
} }
public BaseDoorBlock(BlockBehaviour.Properties properties) { public BaseDoorBlock(BlockBehaviour.Properties properties) {
super(properties); super(properties, SoundEvents.WOODEN_DOOR_CLOSE, SoundEvents.WOODEN_DOOR_OPEN);
} }
@Override @Override

View file

@ -9,6 +9,7 @@ import net.minecraft.client.renderer.block.model.BlockModel;
import net.minecraft.client.resources.model.UnbakedModel; import net.minecraft.client.resources.model.UnbakedModel;
import net.minecraft.core.Registry; import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.FenceGateBlock; import net.minecraft.world.level.block.FenceGateBlock;
@ -28,7 +29,7 @@ public class BaseGateBlock extends FenceGateBlock implements BlockModelProvider
private final Block parent; private final Block parent;
public BaseGateBlock(Block source) { public BaseGateBlock(Block source) {
super(Properties.copy(source).noOcclusion()); super(Properties.copy(source).noOcclusion(), SoundEvents.FENCE_GATE_CLOSE, SoundEvents.FENCE_GATE_OPEN);
this.parent = source; this.parent = source;
} }

View file

@ -9,6 +9,7 @@ import net.minecraft.client.renderer.block.model.BlockModel;
import net.minecraft.client.resources.model.UnbakedModel; import net.minecraft.client.resources.model.UnbakedModel;
import net.minecraft.core.Registry; import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.PressurePlateBlock; import net.minecraft.world.level.block.PressurePlateBlock;
@ -28,7 +29,10 @@ public class BasePressurePlateBlock extends PressurePlateBlock implements BlockM
private final Block parent; private final Block parent;
public BasePressurePlateBlock(Sensitivity rule, Block source) { public BasePressurePlateBlock(Sensitivity rule, Block source) {
super(rule, Properties.copy(source).noCollission().noOcclusion().strength(0.5F)); super(
rule, Properties.copy(source).noCollission().noOcclusion().strength(0.5F),
SoundEvents.WOODEN_PRESSURE_PLATE_CLICK_OFF, SoundEvents.WOODEN_PRESSURE_PLATE_CLICK_ON
);
this.parent = source; this.parent = source;
} }

View file

@ -11,6 +11,7 @@ import net.minecraft.client.renderer.block.model.BlockModel;
import net.minecraft.client.resources.model.BlockModelRotation; import net.minecraft.client.resources.model.BlockModelRotation;
import net.minecraft.client.resources.model.UnbakedModel; import net.minecraft.client.resources.model.UnbakedModel;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.TrapDoorBlock; import net.minecraft.world.level.block.TrapDoorBlock;
@ -31,7 +32,7 @@ public class BaseTrapdoorBlock extends TrapDoorBlock implements RenderLayerProvi
} }
public BaseTrapdoorBlock(BlockBehaviour.Properties properties) { public BaseTrapdoorBlock(BlockBehaviour.Properties properties) {
super(properties); super(properties, SoundEvents.WOODEN_TRAPDOOR_CLOSE, SoundEvents.WOODEN_TRAPDOOR_OPEN);
} }
@Override @Override

View file

@ -9,6 +9,7 @@ import net.minecraft.client.renderer.block.model.BlockModel;
import net.minecraft.client.resources.model.UnbakedModel; import net.minecraft.client.resources.model.UnbakedModel;
import net.minecraft.core.Registry; import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.WeightedPressurePlateBlock; import net.minecraft.world.level.block.WeightedPressurePlateBlock;
@ -31,10 +32,11 @@ public class BaseWeightedPlateBlock extends WeightedPressurePlateBlock implement
super( super(
15, 15,
Properties.copy(source) Properties.copy(source)
.noCollission() .noCollission()
.noOcclusion() .noOcclusion()
.requiresCorrectToolForDrops() .requiresCorrectToolForDrops()
.strength(0.5F) .strength(0.5F),
SoundEvents.METAL_PRESSURE_PLATE_CLICK_OFF, SoundEvents.METAL_PRESSURE_PLATE_CLICK_ON
); );
this.parent = source; this.parent = source;
} }

View file

@ -255,7 +255,7 @@ public class WorldSetupScreen extends LayoutScreen {
createWorldScreen createWorldScreen
.worldGenSettingsComponent .worldGenSettingsComponent
.settings() .settings()
.worldGenSettings() .selectedDimensions()
.dimensions() .dimensions()
) )
))); )));
@ -269,11 +269,11 @@ public class WorldSetupScreen extends LayoutScreen {
ChunkGenerator chunkGenerator ChunkGenerator chunkGenerator
) { ) {
createWorldScreen.worldGenSettingsComponent.updateSettings( createWorldScreen.worldGenSettingsComponent.updateSettings(
(registryAccess, worldGenSettings) -> LevelGenUtil.replaceGenerator( (registryAccess, worldDimensions) -> LevelGenUtil.replaceGenerator(
dimensionKey, dimensionKey,
dimensionTypeKey, dimensionTypeKey,
registryAccess, registryAccess,
worldGenSettings, worldDimensions,
chunkGenerator chunkGenerator
) )
); );

View file

@ -1,16 +1,12 @@
package org.betterx.bclib.client.models; package org.betterx.bclib.client.models;
import org.betterx.bclib.api.v2.ModIntegrationAPI;
import org.betterx.bclib.client.render.EmissiveTextureInfo;
import org.betterx.bclib.interfaces.BlockModelProvider; import org.betterx.bclib.interfaces.BlockModelProvider;
import org.betterx.bclib.interfaces.ItemModelProvider; import org.betterx.bclib.interfaces.ItemModelProvider;
import org.betterx.bclib.models.RecordItemModelProvider; import org.betterx.bclib.models.RecordItemModelProvider;
import com.mojang.datafixers.util.Pair;
import net.minecraft.client.renderer.block.BlockModelShaper; import net.minecraft.client.renderer.block.BlockModelShaper;
import net.minecraft.client.renderer.block.model.BlockModel; import net.minecraft.client.renderer.block.model.BlockModel;
import net.minecraft.client.renderer.block.model.multipart.MultiPart; import net.minecraft.client.renderer.block.model.multipart.MultiPart;
import net.minecraft.client.resources.model.Material;
import net.minecraft.client.resources.model.ModelResourceLocation; import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.client.resources.model.UnbakedModel; import net.minecraft.client.resources.model.UnbakedModel;
import net.minecraft.core.Registry; import net.minecraft.core.Registry;
@ -21,12 +17,8 @@ import net.minecraft.world.level.block.state.BlockState;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Set;
public class CustomModelBakery { public class CustomModelBakery {
private final Map<ResourceLocation, UnbakedModel> models = Maps.newConcurrentMap(); private final Map<ResourceLocation, UnbakedModel> models = Maps.newConcurrentMap();
@ -114,43 +106,44 @@ public class CustomModelBakery {
BlockModel model = provider.getItemModel(modelLocation); BlockModel model = provider.getItemModel(modelLocation);
models.put(modelLocation, model); models.put(modelLocation, model);
} }
public static void loadEmissiveModels(Map<ResourceLocation, UnbakedModel> unbakedCache) { //TODO: 1.19.3 Handled differently now
if (!ModIntegrationAPI.hasCanvas()) { // public static void loadEmissiveModels(Map<ResourceLocation, UnbakedModel> unbakedCache) {
return; // if (!ModIntegrationAPI.hasCanvas()) {
} // return;
// }
Map<ResourceLocation, UnbakedModel> cacheCopy = new HashMap<>(unbakedCache); //
Set<Pair<String, String>> strings = Sets.newConcurrentHashSet(); // Map<ResourceLocation, UnbakedModel> cacheCopy = new HashMap<>(unbakedCache);
Registry.BLOCK.keySet().forEach(blockID -> { // Set<Pair<String, String>> strings = Sets.newConcurrentHashSet();
Block block = Registry.BLOCK.get(blockID); // Registry.BLOCK.keySet().forEach(blockID -> {
ImmutableList<BlockState> states = block.getStateDefinition().getPossibleStates(); // Block block = Registry.BLOCK.get(blockID);
boolean addBlock = false; // ImmutableList<BlockState> states = block.getStateDefinition().getPossibleStates();
// boolean addBlock = false;
for (BlockState state : states) { //
ResourceLocation stateID = BlockModelShaper.stateToModelLocation(blockID, state); // for (BlockState state : states) {
UnbakedModel model = cacheCopy.get(stateID); // ResourceLocation stateID = BlockModelShaper.stateToModelLocation(blockID, state);
if (model == null) { // UnbakedModel model = cacheCopy.get(stateID);
continue; // if (model == null) {
} // continue;
Collection<Material> materials = model.getMaterials(cacheCopy::get, strings); // }
if (materials == null) { // Collection<Material> materials = model.getMaterials(cacheCopy::get, strings);
continue; // if (materials == null) {
} // continue;
for (Material material : materials) { // }
if (EmissiveTextureInfo.isEmissiveTexture(material.texture())) { // for (Material material : materials) {
addBlock = true; // if (EmissiveTextureInfo.isEmissiveTexture(material.texture())) {
break; // addBlock = true;
} // break;
} // }
if (addBlock) { // }
break; // if (addBlock) {
} // break;
} // }
// }
if (addBlock) { //
EmissiveTextureInfo.addBlock(blockID); // if (addBlock) {
} // EmissiveTextureInfo.addBlock(blockID);
}); // }
} // });
// }
} }

View file

@ -4,7 +4,6 @@ import org.betterx.bclib.BCLib;
import org.betterx.bclib.util.BlocksHelper; import org.betterx.bclib.util.BlocksHelper;
import org.betterx.bclib.util.MHelper; import org.betterx.bclib.util.MHelper;
import com.mojang.datafixers.util.Pair;
import com.mojang.math.Vector3f; import com.mojang.math.Vector3f;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.block.model.BakedQuad; import net.minecraft.client.renderer.block.model.BakedQuad;
@ -86,17 +85,13 @@ public class OBJBlockModel implements UnbakedModel, BakedModel {
} }
@Override @Override
public Collection<Material> getMaterials( public void resolveParents(Function<ResourceLocation, UnbakedModel> function) {
Function<ResourceLocation, UnbakedModel> function,
Set<Pair<String, String>> set
) {
return materials;
} }
@Nullable @Nullable
@Override @Override
public BakedModel bake( public BakedModel bake(
ModelBakery modelBakery, ModelBaker modelBakery,
Function<Material, TextureAtlasSprite> textureGetter, Function<Material, TextureAtlasSprite> textureGetter,
ModelState modelState, ModelState modelState,
ResourceLocation resourceLocation ResourceLocation resourceLocation

View file

@ -16,8 +16,7 @@ public interface NumericProvider {
BCLib.makeID("worldgen/numeric_provider")); BCLib.makeID("worldgen/numeric_provider"));
Registry<Codec<? extends NumericProvider>> NUMERIC_PROVIDER = new MappedRegistry<>( Registry<Codec<? extends NumericProvider>> NUMERIC_PROVIDER = new MappedRegistry<>(
NUMERIC_PROVIDER_REGISTRY, NUMERIC_PROVIDER_REGISTRY,
Lifecycle.experimental(), Lifecycle.experimental()
null
); );
Codec<NumericProvider> CODEC = NUMERIC_PROVIDER.byNameCodec() Codec<NumericProvider> CODEC = NUMERIC_PROVIDER.byNameCodec()
.dispatch(NumericProvider::pcodec, Function.identity()); .dispatch(NumericProvider::pcodec, Function.identity());

View file

@ -3,11 +3,11 @@ package org.betterx.bclib.items.boat;
import org.betterx.bclib.BCLib; import org.betterx.bclib.BCLib;
import net.minecraft.client.model.BoatModel; import net.minecraft.client.model.BoatModel;
import net.minecraft.client.model.ChestBoatModel;
import net.minecraft.client.model.geom.ModelLayerLocation; import net.minecraft.client.model.geom.ModelLayerLocation;
import net.minecraft.client.renderer.entity.EntityRendererProvider; import net.minecraft.client.renderer.entity.EntityRendererProvider;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.BoatItem; import net.minecraft.world.item.BoatItem;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.Item; import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Block;
@ -64,8 +64,8 @@ public final class BoatTypeOverride {
public void createBoatModels(EntityRendererProvider.Context context) { public void createBoatModels(EntityRendererProvider.Context context) {
if (boatModel == null) { if (boatModel == null) {
boatModel = new BoatModel(context.bakeLayer(boatModelName), false); boatModel = new BoatModel(context.bakeLayer(boatModelName));
chestBoatModel = new BoatModel(context.bakeLayer(chestBoatModelName), true); chestBoatModel = new ChestBoatModel(context.bakeLayer(chestBoatModelName));
} }
} }
@ -115,7 +115,7 @@ public final class BoatTypeOverride {
} }
public BoatItem createItem(boolean hasChest) { public BoatItem createItem(boolean hasChest) {
return createItem(hasChest, new Item.Properties().stacksTo(1).tab(CreativeModeTab.TAB_TRANSPORTATION)); return createItem(hasChest, new Item.Properties().stacksTo(1));
} }
public BoatItem createItem(boolean hasChest, Item.Properties itemSettings) { public BoatItem createItem(boolean hasChest, Item.Properties itemSettings) {

View file

@ -1,7 +1,6 @@
package org.betterx.bclib.mixin.client; package org.betterx.bclib.mixin.client;
import org.betterx.bclib.api.v2.ModIntegrationAPI; import org.betterx.bclib.api.v2.ModIntegrationAPI;
import org.betterx.bclib.client.models.CustomModelBakery;
import net.minecraft.client.color.block.BlockColors; import net.minecraft.client.color.block.BlockColors;
import net.minecraft.client.resources.model.ModelBakery; import net.minecraft.client.resources.model.ModelBakery;
@ -35,7 +34,8 @@ public abstract class ModelBakeryMixin {
) { ) {
//CustomModelBakery.setModelsLoaded(false); //CustomModelBakery.setModelsLoaded(false);
if (ModIntegrationAPI.hasCanvas()) { if (ModIntegrationAPI.hasCanvas()) {
CustomModelBakery.loadEmissiveModels(unbakedCache); //TODO:1.19.3 this needs to change
//CustomModelBakery.loadEmissiveModels(unbakedCache);
} }
} }
} }

View file

@ -1,114 +1,97 @@
package org.betterx.bclib.mixin.client; package org.betterx.bclib.mixin.client;
import org.betterx.bclib.BCLib;
import org.betterx.bclib.client.render.EmissiveTextureInfo;
import com.mojang.blaze3d.platform.NativeImage;
import net.minecraft.client.renderer.texture.TextureAtlas; import net.minecraft.client.renderer.texture.TextureAtlas;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.packs.resources.Resource;
import net.minecraft.server.packs.resources.ResourceManager;
import net.fabricmc.fabric.impl.client.texture.FabricSprite;
import net.fabricmc.loader.api.FabricLoader;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.io.IOException;
import java.util.Optional;
@Mixin(TextureAtlas.class) @Mixin(TextureAtlas.class)
public class TextureAtlasMixin { public class TextureAtlasMixin {
private static final int EMISSIVE_ALPHA = 254 << 24; private static final int EMISSIVE_ALPHA = 254 << 24;
private boolean bclib_modifyAtlas; private boolean bclib_modifyAtlas;
@Inject(method = "<init>*", at = @At("TAIL")) //TODO: 1.19.3 How were FabricSprites replaced?
private void bclib_onAtlasInit(ResourceLocation resourceLocation, CallbackInfo info) { // @Inject(method = "<init>*", at = @At("TAIL"))
boolean hasOptifine = FabricLoader.getInstance().isModLoaded("optifabric"); // private void bclib_onAtlasInit(ResourceLocation resourceLocation, CallbackInfo info) {
bclib_modifyAtlas = !hasOptifine && resourceLocation.toString().equals("minecraft:textures/atlas/blocks.png"); // boolean hasOptifine = FabricLoader.getInstance().isModLoaded("optifabric");
if (bclib_modifyAtlas) { // bclib_modifyAtlas = !hasOptifine && resourceLocation.toString().equals("minecraft:textures/atlas/blocks.png");
EmissiveTextureInfo.clear(); // if (bclib_modifyAtlas) {
} // EmissiveTextureInfo.clear();
} // }
// }
@Inject(method = "load(Lnet/minecraft/server/packs/resources/ResourceManager;Lnet/minecraft/client/renderer/texture/TextureAtlasSprite$Info;IIIII)Lnet/minecraft/client/renderer/texture/TextureAtlasSprite;", at = @At("HEAD"), cancellable = true) //
private void bclib_loadSprite( // @Inject(method = "load(Lnet/minecraft/server/packs/resources/ResourceManager;Lnet/minecraft/client/renderer/texture/TextureAtlasSprite$Info;IIIII)Lnet/minecraft/client/renderer/texture/TextureAtlasSprite;", at = @At("HEAD"), cancellable = true)
ResourceManager resourceManager, // private void bclib_loadSprite(
TextureAtlasSprite.Info spriteInfo, // ResourceManager resourceManager,
int atlasWidth, // TextureAtlasSprite.Info spriteInfo,
int atlasHeight, // int atlasWidth,
int maxLevel, // int atlasHeight,
int posX, // int maxLevel,
int posY, // int posX,
CallbackInfoReturnable<TextureAtlasSprite> info // int posY,
) { // CallbackInfoReturnable<TextureAtlasSprite> info
if (!bclib_modifyAtlas) { // ) {
return; // if (!bclib_modifyAtlas) {
} // return;
// }
ResourceLocation location = spriteInfo.name(); //
if (!location.getPath().startsWith("block")) { // ResourceLocation location = spriteInfo.name();
return; // if (!location.getPath().startsWith("block")) {
} // return;
// }
ResourceLocation emissiveLocation = new ResourceLocation( //
location.getNamespace(), // ResourceLocation emissiveLocation = new ResourceLocation(
"textures/" + location.getPath() + "_e.png" // location.getNamespace(),
); // "textures/" + location.getPath() + "_e.png"
Optional<Resource> emissiveRes = resourceManager.getResource(emissiveLocation); // );
if (emissiveRes.isPresent()) { // Optional<Resource> emissiveRes = resourceManager.getResource(emissiveLocation);
NativeImage sprite = null; // if (emissiveRes.isPresent()) {
NativeImage emission = null; // NativeImage sprite = null;
try { // NativeImage emission = null;
ResourceLocation spriteLocation = new ResourceLocation( // try {
location.getNamespace(), // ResourceLocation spriteLocation = new ResourceLocation(
"textures/" + location.getPath() + ".png" // location.getNamespace(),
); // "textures/" + location.getPath() + ".png"
Resource resource = resourceManager.getResource(spriteLocation).orElse(null); // );
sprite = NativeImage.read(resource.open()); // Resource resource = resourceManager.getResource(spriteLocation).orElse(null);
// sprite = NativeImage.read(resource.open());
resource = emissiveRes.get(); //
emission = NativeImage.read(resource.open()); // resource = emissiveRes.get();
} catch (IOException e) { // emission = NativeImage.read(resource.open());
BCLib.LOGGER.warning(e.getMessage()); // } catch (IOException e) {
} // BCLib.LOGGER.warning(e.getMessage());
if (sprite != null && emission != null) { // }
int width = Math.min(sprite.getWidth(), emission.getWidth()); // if (sprite != null && emission != null) {
int height = Math.min(sprite.getHeight(), emission.getHeight()); // int width = Math.min(sprite.getWidth(), emission.getWidth());
for (int x = 0; x < width; x++) { // int height = Math.min(sprite.getHeight(), emission.getHeight());
for (int y = 0; y < height; y++) { // for (int x = 0; x < width; x++) {
int argb = emission.getPixelRGBA(x, y); // for (int y = 0; y < height; y++) {
int alpha = (argb >> 24) & 255; // int argb = emission.getPixelRGBA(x, y);
if (alpha > 127) { // int alpha = (argb >> 24) & 255;
int r = (argb >> 16) & 255; // if (alpha > 127) {
int g = (argb >> 8) & 255; // int r = (argb >> 16) & 255;
int b = argb & 255; // int g = (argb >> 8) & 255;
if (r > 0 || g > 0 || b > 0) { // int b = argb & 255;
argb = (argb & 0x00FFFFFF) | EMISSIVE_ALPHA; // if (r > 0 || g > 0 || b > 0) {
sprite.setPixelRGBA(x, y, argb); // argb = (argb & 0x00FFFFFF) | EMISSIVE_ALPHA;
} // sprite.setPixelRGBA(x, y, argb);
} // }
} // }
} // }
TextureAtlas self = (TextureAtlas) (Object) this; // }
FabricSprite result = new FabricSprite( // TextureAtlas self = (TextureAtlas) (Object) this;
self, // FabricSprite result = new FabricSprite(
spriteInfo, // self,
maxLevel, // spriteInfo,
atlasWidth, // maxLevel,
atlasHeight, // atlasWidth,
posX, // atlasHeight,
posY, // posX,
sprite // posY,
); // sprite
EmissiveTextureInfo.addTexture(location); // );
info.setReturnValue(result); // EmissiveTextureInfo.addTexture(location);
} // info.setReturnValue(result);
} // }
} // }
// }
} }

View file

@ -1,48 +1,35 @@
package org.betterx.bclib.mixin.common; package org.betterx.bclib.mixin.common;
import org.betterx.bclib.api.v2.levelgen.biomes.BCLBiomeRegistry;
import org.betterx.bclib.api.v2.levelgen.biomes.BiomeData;
import com.mojang.serialization.Codec;
import net.minecraft.core.Registry;
import net.minecraft.core.RegistryAccess; import net.minecraft.core.RegistryAccess;
import net.minecraft.resources.ResourceKey;
import com.google.common.collect.ImmutableMap;
import org.spongepowered.asm.mixin.Mixin; 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.ModifyArg;
import java.util.Map;
import java.util.function.Supplier;
@Mixin(RegistryAccess.class) @Mixin(RegistryAccess.class)
public interface RegistryAccessMixin { public interface RegistryAccessMixin {
//TODO: 1.19.3 Will probably be a new custom data provider now
@ModifyArg(method = "<clinit>", at = @At(value = "INVOKE", target = "Lnet/minecraft/Util;make(Ljava/util/function/Supplier;)Ljava/lang/Object;")) // @ModifyArg(method = "<clinit>", at = @At(value = "INVOKE", target = "Lnet/minecraft/Util;make(Ljava/util/function/Supplier;)Ljava/lang/Object;"))
private static Supplier<ImmutableMap<ResourceKey<Registry<?>>, RegistryAccess.RegistryData<?>>> together_addRegistry( // private static Supplier<ImmutableMap<ResourceKey<Registry<?>>, RegistryAccess.RegistryData<?>>> together_addRegistry(
Supplier<ImmutableMap<ResourceKey<Registry<?>>, RegistryAccess.RegistryData<?>>> supplier // Supplier<ImmutableMap<ResourceKey<Registry<?>>, RegistryAccess.RegistryData<?>>> supplier
) { // ) {
return () -> { // return () -> {
ImmutableMap.Builder<ResourceKey<Registry<?>>, RegistryAccess.RegistryData<?>> builder = ImmutableMap.builder(); // ImmutableMap.Builder<ResourceKey<Registry<?>>, RegistryAccess.RegistryData<?>> builder = ImmutableMap.builder();
//Make sure this gets added before WORLD_PRESETS // //Make sure this gets added before WORLD_PRESETS
put(builder, BCLBiomeRegistry.BCL_BIOMES_REGISTRY, BiomeData.CODEC); // put(builder, BCLBiomeRegistry.BCL_BIOMES_REGISTRY, BiomeData.CODEC);
//
Map<ResourceKey<Registry<?>>, RegistryAccess.RegistryData<?>> res = supplier.get(); // Map<ResourceKey<Registry<?>>, RegistryAccess.RegistryData<?>> res = supplier.get();
builder.putAll(res); // builder.putAll(res);
//
return builder.build(); // return builder.build();
}; // };
} // }
//
@Shadow // @Shadow
static <E> void put( // static <E> void put(
ImmutableMap.Builder<ResourceKey<Registry<?>>, RegistryAccess.RegistryData<?>> builder, // ImmutableMap.Builder<ResourceKey<Registry<?>>, RegistryAccess.RegistryData<?>> builder,
ResourceKey<? extends Registry<E>> resourceKey, // ResourceKey<? extends Registry<E>> resourceKey,
Codec<E> codec // Codec<E> codec
) { // ) {
throw new RuntimeException("Shadowed Call"); // throw new RuntimeException("Shadowed Call");
} // }
} }

View file

@ -24,6 +24,14 @@ public class BlastFurnaceRecipe extends CookingRecipe<BlastFurnaceRecipe, Contai
@Override @Override
protected BlastingRecipe buildRecipe() { protected BlastingRecipe buildRecipe() {
return new BlastingRecipe(id, group, input, new ItemStack(output, count), experience, cookingTime); return new BlastingRecipe(
id,
group,
bookCategory,
input,
new ItemStack(output, count),
experience,
cookingTime
);
} }
} }

View file

@ -4,6 +4,7 @@ import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.TagKey; import net.minecraft.tags.TagKey;
import net.minecraft.world.Container; import net.minecraft.world.Container;
import net.minecraft.world.item.Item; import net.minecraft.world.item.Item;
import net.minecraft.world.item.crafting.CookingBookCategory;
import net.minecraft.world.item.crafting.Recipe; import net.minecraft.world.item.crafting.Recipe;
import net.minecraft.world.item.crafting.RecipeType; import net.minecraft.world.item.crafting.RecipeType;
import net.minecraft.world.level.ItemLike; import net.minecraft.world.level.ItemLike;
@ -11,6 +12,7 @@ import net.minecraft.world.level.ItemLike;
public abstract class CookingRecipe<T extends AbstractSimpleRecipe, C extends Container, R extends Recipe<C>> extends AbstractSimpleRecipe<T, C, R> { public abstract class CookingRecipe<T extends AbstractSimpleRecipe, C extends Container, R extends Recipe<C>> extends AbstractSimpleRecipe<T, C, R> {
protected float experience; protected float experience;
protected int cookingTime; protected int cookingTime;
protected CookingBookCategory bookCategory;
CookingRecipe(ResourceLocation id, RecipeType<R> type, ItemLike output) { CookingRecipe(ResourceLocation id, RecipeType<R> type, ItemLike output) {
this(id, type, type.toString(), output); this(id, type, type.toString(), output);
@ -20,6 +22,7 @@ public abstract class CookingRecipe<T extends AbstractSimpleRecipe, C extends Co
super(id, type, category, output); super(id, type, category, output);
cookingTime = 1000; cookingTime = 1000;
experience = 0; experience = 0;
this.bookCategory = CookingBookCategory.MISC;
} }
public T setInput(ItemLike in) { public T setInput(ItemLike in) {
@ -39,4 +42,9 @@ public abstract class CookingRecipe<T extends AbstractSimpleRecipe, C extends Co
cookingTime = time; cookingTime = time;
return (T) this; return (T) this;
} }
public T setCookingBookCategory(CookingBookCategory c) {
bookCategory = c;
return (T) this;
}
} }

View file

@ -20,6 +20,7 @@ public class FurnaceRecipe extends AbstractAdvancementRecipe {
private int count; private int count;
private int time; private int time;
private float xp; private float xp;
protected CookingBookCategory bookCategory;
private FurnaceRecipe() { private FurnaceRecipe() {
} }
@ -34,6 +35,7 @@ public class FurnaceRecipe extends AbstractAdvancementRecipe {
INSTANCE.xp = 0; INSTANCE.xp = 0;
INSTANCE.exist = BCLRecipeManager.exists(output); INSTANCE.exist = BCLRecipeManager.exists(output);
INSTANCE.createAdvancement(INSTANCE.id, false); INSTANCE.createAdvancement(INSTANCE.id, false);
INSTANCE.bookCategory = CookingBookCategory.MISC;
return INSTANCE; return INSTANCE;
} }
@ -76,6 +78,11 @@ public class FurnaceRecipe extends AbstractAdvancementRecipe {
return this; return this;
} }
public FurnaceRecipe setCookingBookCategory(CookingBookCategory c) {
bookCategory = c;
return this;
}
public void build() { public void build() {
build(false, false, false); build(false, false, false);
} }
@ -96,6 +103,7 @@ public class FurnaceRecipe extends AbstractAdvancementRecipe {
SmeltingRecipe recipe = new SmeltingRecipe( SmeltingRecipe recipe = new SmeltingRecipe(
new ResourceLocation(id + "_smelting"), new ResourceLocation(id + "_smelting"),
group, group,
bookCategory,
input, input,
new ItemStack(output, count), new ItemStack(output, count),
xp, xp,
@ -108,6 +116,7 @@ public class FurnaceRecipe extends AbstractAdvancementRecipe {
BlastingRecipe recipe2 = new BlastingRecipe( BlastingRecipe recipe2 = new BlastingRecipe(
new ResourceLocation(id + "_blasting"), new ResourceLocation(id + "_blasting"),
group, group,
bookCategory,
input, input,
new ItemStack(output, count), new ItemStack(output, count),
xp, xp,
@ -121,6 +130,7 @@ public class FurnaceRecipe extends AbstractAdvancementRecipe {
CampfireCookingRecipe recipe2 = new CampfireCookingRecipe( CampfireCookingRecipe recipe2 = new CampfireCookingRecipe(
new ResourceLocation(id + "_campfire"), new ResourceLocation(id + "_campfire"),
group, group,
bookCategory,
input, input,
new ItemStack(output, count), new ItemStack(output, count),
xp, xp,
@ -134,6 +144,7 @@ public class FurnaceRecipe extends AbstractAdvancementRecipe {
SmokingRecipe recipe2 = new SmokingRecipe( SmokingRecipe recipe2 = new SmokingRecipe(
new ResourceLocation(id + "_smoker"), new ResourceLocation(id + "_smoker"),
group, group,
bookCategory,
input, input,
new ItemStack(output, count), new ItemStack(output, count),
xp, xp,

View file

@ -31,6 +31,8 @@ public class GridRecipe extends AbstractAdvancementRecipe {
private int count; private int count;
private boolean exist; private boolean exist;
protected CraftingBookCategory bookCategory;
private GridRecipe() { private GridRecipe() {
} }
@ -51,6 +53,7 @@ public class GridRecipe extends AbstractAdvancementRecipe {
INSTANCE.shape = new String[]{"#"}; INSTANCE.shape = new String[]{"#"};
INSTANCE.materialKeys.clear(); INSTANCE.materialKeys.clear();
INSTANCE.count = 1; INSTANCE.count = 1;
INSTANCE.bookCategory = CraftingBookCategory.MISC;
INSTANCE.exist = output != null && BCLRecipeManager.exists(output); INSTANCE.exist = output != null && BCLRecipeManager.exists(output);
INSTANCE.createAdvancement(id, output); INSTANCE.createAdvancement(id, output);
@ -122,6 +125,11 @@ public class GridRecipe extends AbstractAdvancementRecipe {
return materials; return materials;
} }
public GridRecipe setCraftingBookCategory(CraftingBookCategory c) {
bookCategory = c;
return this;
}
public void build() { public void build() {
if (!exist) { if (!exist) {
@ -145,11 +153,12 @@ public class GridRecipe extends AbstractAdvancementRecipe {
CraftingRecipe recipe = shaped ? new ShapedRecipe( CraftingRecipe recipe = shaped ? new ShapedRecipe(
id, id,
group, group,
bookCategory,
width, width,
height, height,
materials, materials,
result result
) : new ShapelessRecipe(id, group, result, materials); ) : new ShapelessRecipe(id, group, bookCategory, result, materials);
BCLRecipeManager.addRecipe(type, recipe); BCLRecipeManager.addRecipe(type, recipe);
registerAdvancement(recipe); registerAdvancement(recipe);

View file

@ -34,7 +34,8 @@ public abstract class BaseRegistry<T> {
public Item.Properties makeItemSettings() { public Item.Properties makeItemSettings() {
Item.Properties properties = new Item.Properties(); Item.Properties properties = new Item.Properties();
return properties.tab(creativeTab); //TODO: 1.19.3 Creative mode tabs are handled differently now
return properties;//.tab(creativeTab);
} }
private void registerInternal() { private void registerInternal() {

View file

@ -1,6 +1,8 @@
package org.betterx.bclib.util; package org.betterx.bclib.util;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.HolderLookup;
import net.minecraft.core.Registry;
import net.minecraft.core.Vec3i; import net.minecraft.core.Vec3i;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtIo; import net.minecraft.nbt.NbtIo;
@ -67,7 +69,7 @@ public class StructureHelper {
CompoundTag nbttagcompound = NbtIo.readCompressed(stream); CompoundTag nbttagcompound = NbtIo.readCompressed(stream);
StructureTemplate template = new StructureTemplate(); StructureTemplate template = new StructureTemplate();
template.load(nbttagcompound); template.load(HolderLookup.forRegistry(Registry.BLOCK), nbttagcompound);
return template; return template;
} }

View file

@ -6,7 +6,7 @@ import net.minecraft.world.level.levelgen.WorldGenSettings;
public class ChunkGeneratorUtils { public class ChunkGeneratorUtils {
public static void restoreOriginalBiomeSourceInAllDimension(WorldGenSettings settings) { public static void restoreOriginalBiomeSourceInAllDimension(WorldGenSettings settings) {
for (var entry : settings.dimensions().entrySet()) { for (var entry : settings.dimensions().dimensions().entrySet()) {
ResourceKey<LevelStem> key = entry.getKey(); ResourceKey<LevelStem> key = entry.getKey();
LevelStem stem = entry.getValue(); LevelStem stem = entry.getValue();

View file

@ -10,15 +10,15 @@ import net.minecraft.world.level.biome.BiomeSource;
import net.minecraft.world.level.chunk.ChunkGenerator; import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.dimension.DimensionType; import net.minecraft.world.level.dimension.DimensionType;
import net.minecraft.world.level.dimension.LevelStem; import net.minecraft.world.level.dimension.LevelStem;
import net.minecraft.world.level.levelgen.WorldGenSettings; import net.minecraft.world.level.levelgen.WorldDimensions;
public interface EnforceableChunkGenerator<G extends ChunkGenerator> { public interface EnforceableChunkGenerator<G extends ChunkGenerator> {
WorldGenSettings enforceGeneratorInWorldGenSettings( WorldDimensions enforceGeneratorInWorldGenSettings(
RegistryAccess access, RegistryAccess access,
ResourceKey<LevelStem> dimensionKey, ResourceKey<LevelStem> dimensionKey,
ResourceKey<DimensionType> dimensionTypeKey, ResourceKey<DimensionType> dimensionTypeKey,
ChunkGenerator loadedChunkGenerator, ChunkGenerator loadedChunkGenerator,
WorldGenSettings settings WorldDimensions worldDims
); );
default boolean togetherShouldRepair(ChunkGenerator chunkGenerator) { default boolean togetherShouldRepair(ChunkGenerator chunkGenerator) {

View file

@ -12,17 +12,12 @@ import org.betterx.worlds.together.world.event.WorldBootstrap;
import org.betterx.worlds.together.worldPreset.TogetherWorldPreset; import org.betterx.worlds.together.worldPreset.TogetherWorldPreset;
import org.betterx.worlds.together.worldPreset.WorldPresets; import org.betterx.worlds.together.worldPreset.WorldPresets;
import com.mojang.datafixers.util.Pair;
import com.mojang.serialization.JsonOps;
import net.minecraft.Util;
import net.minecraft.core.Holder; import net.minecraft.core.Holder;
import net.minecraft.core.Registry; import net.minecraft.core.Registry;
import net.minecraft.core.RegistryAccess; import net.minecraft.core.RegistryAccess;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.resources.RegistryOps;
import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.packs.resources.ResourceManager;
import net.minecraft.util.RandomSource; import net.minecraft.util.RandomSource;
import net.minecraft.world.level.biome.Biome; import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.chunk.ChunkGenerator; import net.minecraft.world.level.chunk.ChunkGenerator;
@ -30,14 +25,11 @@ import net.minecraft.world.level.dimension.DimensionType;
import net.minecraft.world.level.dimension.LevelStem; import net.minecraft.world.level.dimension.LevelStem;
import net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator; import net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator;
import net.minecraft.world.level.levelgen.NoiseGeneratorSettings; import net.minecraft.world.level.levelgen.NoiseGeneratorSettings;
import net.minecraft.world.level.levelgen.WorldGenSettings; import net.minecraft.world.level.levelgen.WorldDimensions;
import net.minecraft.world.level.levelgen.presets.WorldPreset; import net.minecraft.world.level.levelgen.presets.WorldPreset;
import net.minecraft.world.level.levelgen.structure.StructureSet; import net.minecraft.world.level.levelgen.structure.StructureSet;
import net.minecraft.world.level.levelgen.synth.NormalNoise; import net.minecraft.world.level.levelgen.synth.NormalNoise;
import com.google.common.collect.ImmutableMap;
import com.google.gson.JsonElement;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.ApiStatus;
@ -46,18 +38,18 @@ public class WorldGenUtil {
public static final String TAG_PRESET = "preset"; public static final String TAG_PRESET = "preset";
public static final String TAG_GENERATOR = "generator"; public static final String TAG_GENERATOR = "generator";
public static WorldGenSettings createWorldFromPreset( public static WorldDimensions createWorldFromPreset(
ResourceKey<WorldPreset> preset, ResourceKey<WorldPreset> preset,
RegistryAccess registryAccess, RegistryAccess registryAccess,
long seed, long seed,
boolean generateStructures, boolean generateStructures,
boolean generateBonusChest boolean generateBonusChest
) { ) {
WorldGenSettings settings = registryAccess WorldDimensions settings = registryAccess
.registryOrThrow(Registry.WORLD_PRESET_REGISTRY) .registryOrThrow(Registry.WORLD_PRESET_REGISTRY)
.getHolderOrThrow(preset) .getHolderOrThrow(preset)
.value() .value()
.createWorldGenSettings(seed, generateStructures, generateBonusChest); .createWorldDimensions();
for (LevelStem stem : settings.dimensions()) { for (LevelStem stem : settings.dimensions()) {
if (stem.generator().getBiomeSource() instanceof BiomeSourceWithSeed bcl) { if (stem.generator().getBiomeSource() instanceof BiomeSourceWithSeed bcl) {
@ -73,7 +65,7 @@ public class WorldGenUtil {
return settings; return settings;
} }
public static WorldGenSettings createDefaultWorldFromPreset( public static WorldDimensions createDefaultWorldFromPreset(
RegistryAccess registryAccess, RegistryAccess registryAccess,
long seed, long seed,
boolean generateStructures, boolean generateStructures,
@ -89,28 +81,30 @@ public class WorldGenUtil {
} }
@ApiStatus.Internal @ApiStatus.Internal
public static Pair<WorldGenSettings, RegistryAccess.Frozen> defaultWorldDataSupplier( //TODO: 1.19.3 Disabled for now
RegistryOps<JsonElement> loaderOps, // public static Pair<WorldDimensions, RegistryAccess.Frozen> defaultWorldDataSupplier(
RegistryAccess.Frozen frozen // RegistryOps<JsonElement> loaderOps,
) { // RegistryAccess.Frozen frozen
WorldGenSettings defaultGen = createDefaultWorldFromPreset(frozen); // ) {
RegistryOps<JsonElement> registryOps = RegistryOps.create(JsonOps.INSTANCE, frozen); // WorldDimensions defaultGen = createDefaultWorldFromPreset(frozen);
WorldGenSettings worldGenSettings = WorldGenSettings.CODEC // RegistryOps<JsonElement> registryOps = RegistryOps.create(JsonOps.INSTANCE, frozen);
.encodeStart(registryOps, defaultGen) //
.flatMap(json -> WorldGenSettings.CODEC.parse( // WorldDimensions worldGenSettings = WorldDimensions.CODEC
loaderOps, // .codec().parse(registryOps, defaultGen)
json // .flatMap(json -> WorldDimensions.CODEC.codec().parse(
)) // loaderOps,
.getOrThrow( // json
false, // ))
Util.prefix( // .getOrThrow(
"Error parsing worldgen settings after loading data packs: ", // false,
WorldsTogether.LOGGER::error // Util.prefix(
) // "Error parsing worldgen settings after loading data packs: ",
); // WorldsTogether.LOGGER::error
// WorldGenSettings worldGenSettings = createDefaultWorldFromPreset(frozen); // )
return Pair.of(worldGenSettings, frozen); // );
} //// WorldGenSettings worldGenSettings = createDefaultWorldFromPreset(frozen);
// return Pair.of(worldGenSettings, frozen);
// }
private static final Map<ResourceKey<WorldPreset>, Map<ResourceKey<LevelStem>, LevelStem>> WORLD_PRESET_MAP = new HashMap<>(); private static final Map<ResourceKey<WorldPreset>, Map<ResourceKey<LevelStem>, LevelStem>> WORLD_PRESET_MAP = new HashMap<>();
@ -136,52 +130,52 @@ public class WorldGenUtil {
WORLD_PRESET_MAP.clear(); WORLD_PRESET_MAP.clear();
} }
public static void preloadWorldPresets(ResourceManager resourceManager, RegistryAccess.Writable writable) { // public static void preloadWorldPresets(ResourceManager resourceManager, RegistryAccess.Writable writable) {
clearPreloadedWorldPresets(); // clearPreloadedWorldPresets();
Registry<WorldPreset> registry = writable.registryOrThrow(Registry.WORLD_PRESET_REGISTRY); // Registry<WorldPreset> registry = writable.registryOrThrow(Registry.WORLD_PRESET_REGISTRY);
//for (ResourceKey<WorldPreset> key : registry.registryKeySet()) // //for (ResourceKey<WorldPreset> key : registry.registryKeySet())
ResourceKey<WorldPreset> key = net.minecraft.world.level.levelgen.presets.WorldPresets.NORMAL; // ResourceKey<WorldPreset> key = net.minecraft.world.level.levelgen.presets.WorldPresets.NORMAL;
{ // {
RegistryOps<JsonElement> loaderOps = RegistryOps.createAndLoad( // RegistryOps<JsonElement> loaderOps = RegistryOps.createAndLoad(
JsonOps.INSTANCE, writable, resourceManager // JsonOps.INSTANCE, writable, resourceManager
); // );
Holder<WorldPreset> in = registry.getHolderOrThrow(key); // Holder<WorldPreset> in = registry.getHolderOrThrow(key);
if (in.unwrapKey().isPresent()) { // if (in.unwrapKey().isPresent()) {
RegistryOps<JsonElement> registryOps = RegistryOps.create(JsonOps.INSTANCE, writable); // RegistryOps<JsonElement> registryOps = RegistryOps.create(JsonOps.INSTANCE, writable);
WorldGenSettings settings = WorldGenUtil.createWorldFromPreset( // WorldGenSettings settings = WorldGenUtil.createWorldFromPreset(
in.unwrapKey().orElseThrow(), // in.unwrapKey().orElseThrow(),
writable, // writable,
RandomSource.create().nextLong(), // RandomSource.create().nextLong(),
true, // true,
false // false
); // );
WorldGenSettings worldGenSettings = WorldGenSettings.CODEC // WorldGenSettings worldGenSettings = WorldGenSettings.CODEC
.encodeStart(registryOps, settings) // .encodeStart(registryOps, settings)
.flatMap(json -> WorldGenSettings.CODEC.parse( // .flatMap(json -> WorldGenSettings.CODEC.parse(
loaderOps, // loaderOps,
json // json
)) // ))
.getOrThrow( // .getOrThrow(
false, // false,
Util.prefix( // Util.prefix(
"Error parsing world preset settings after loading data packs: ", // "Error parsing world preset settings after loading data packs: ",
WorldsTogether.LOGGER::error // WorldsTogether.LOGGER::error
) // )
); // );
ImmutableMap.Builder<ResourceKey<LevelStem>, LevelStem> map = ImmutableMap.builder(); // ImmutableMap.Builder<ResourceKey<LevelStem>, LevelStem> map = ImmutableMap.builder();
for (Map.Entry<ResourceKey<LevelStem>, LevelStem> entry : worldGenSettings.dimensions().entrySet()) { // for (Map.Entry<ResourceKey<LevelStem>, LevelStem> entry : worldGenSettings.dimensions().entrySet()) {
map.put(entry.getKey(), entry.getValue()); // map.put(entry.getKey(), entry.getValue());
} // }
WORLD_PRESET_MAP.put(key, map.build()); // WORLD_PRESET_MAP.put(key, map.build());
} // }
} // }
} // }
public static WorldGenSettings createDefaultWorldFromPreset(RegistryAccess registryAccess, long seed) { public static WorldDimensions createDefaultWorldFromPreset(RegistryAccess registryAccess, long seed) {
return createDefaultWorldFromPreset(registryAccess, seed, true, false); return createDefaultWorldFromPreset(registryAccess, seed, true, false);
} }
public static WorldGenSettings createDefaultWorldFromPreset(RegistryAccess registryAccess) { public static WorldDimensions createDefaultWorldFromPreset(RegistryAccess registryAccess) {
return createDefaultWorldFromPreset(registryAccess, RandomSource.create().nextLong()); return createDefaultWorldFromPreset(registryAccess, RandomSource.create().nextLong());
} }
@ -233,9 +227,9 @@ public class WorldGenUtil {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@ApiStatus.Internal @ApiStatus.Internal
public static WorldGenSettings repairBiomeSourceInAllDimensions( public static WorldDimensions repairBiomeSourceInAllDimensions(
RegistryAccess registryAccess, RegistryAccess registryAccess,
WorldGenSettings settings WorldDimensions settings
) { ) {
var dimensions = TogetherWorldPreset.loadWorldDimensions(); var dimensions = TogetherWorldPreset.loadWorldDimensions();
for (var entry : settings.dimensions().entrySet()) { for (var entry : settings.dimensions().entrySet()) {
@ -271,7 +265,7 @@ public class WorldGenUtil {
settings = enforcer.enforceGeneratorInWorldGenSettings( settings = enforcer.enforceGeneratorInWorldGenSettings(
registryAccess, registryAccess,
key, key,
loadedStem.typeHolder().unwrapKey().orElseThrow(), loadedStem.type().unwrapKey().orElseThrow(),
loadedChunkGenerator, loadedChunkGenerator,
settings settings
); );

View file

@ -1,15 +1,11 @@
package org.betterx.worlds.together.mixin.client; package org.betterx.worlds.together.mixin.client;
import org.betterx.worlds.together.levelgen.WorldGenUtil;
import org.betterx.worlds.together.world.event.WorldBootstrap; import org.betterx.worlds.together.world.event.WorldBootstrap;
import org.betterx.worlds.together.worldPreset.WorldPresets; import org.betterx.worlds.together.worldPreset.WorldPresets;
import com.mojang.serialization.JsonOps;
import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.gui.screens.worldselection.CreateWorldScreen; import net.minecraft.client.gui.screens.worldselection.CreateWorldScreen;
import net.minecraft.client.gui.screens.worldselection.WorldGenSettingsComponent; import net.minecraft.client.gui.screens.worldselection.WorldGenSettingsComponent;
import net.minecraft.core.RegistryAccess;
import net.minecraft.resources.RegistryOps;
import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceKey;
import net.minecraft.server.WorldLoader; import net.minecraft.server.WorldLoader;
import net.minecraft.world.level.DataPackConfig; import net.minecraft.world.level.DataPackConfig;
@ -17,7 +13,6 @@ import net.minecraft.world.level.levelgen.WorldGenSettings;
import net.minecraft.world.level.levelgen.presets.WorldPreset; import net.minecraft.world.level.levelgen.presets.WorldPreset;
import net.minecraft.world.level.storage.LevelStorageSource; import net.minecraft.world.level.storage.LevelStorageSource;
import com.google.gson.JsonElement;
import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Shadow;
@ -65,23 +60,25 @@ public class CreateWorldScreenMixin {
//Make sure the WorldGenSettings used to populate the create screen match the default WorldPreset //Make sure the WorldGenSettings used to populate the create screen match the default WorldPreset
@ModifyArg(method = "openFresh", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/WorldLoader;load(Lnet/minecraft/server/WorldLoader$InitConfig;Lnet/minecraft/server/WorldLoader$WorldDataSupplier;Lnet/minecraft/server/WorldLoader$ResultFactory;Ljava/util/concurrent/Executor;Ljava/util/concurrent/Executor;)Ljava/util/concurrent/CompletableFuture;")) @ModifyArg(method = "openFresh", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/WorldLoader;load(Lnet/minecraft/server/WorldLoader$InitConfig;Lnet/minecraft/server/WorldLoader$WorldDataSupplier;Lnet/minecraft/server/WorldLoader$ResultFactory;Ljava/util/concurrent/Executor;Ljava/util/concurrent/Executor;)Ljava/util/concurrent/CompletableFuture;"))
private static WorldLoader.WorldDataSupplier<WorldGenSettings> wt_NewDefaultSettings(WorldLoader.WorldDataSupplier<WorldGenSettings> worldDataSupplier) { private static WorldLoader.WorldDataSupplier<WorldGenSettings> wt_NewDefaultSettings(WorldLoader.WorldDataSupplier<WorldGenSettings> worldDataSupplier) {
return (resourceManager, dataPackConfig) -> { return worldDataSupplier;
// Pair<WorldGenSettings, RegistryAccess.Frozen> res = worldDataSupplier.get(resourceManager, dataPackConfig); //TODO: 1.19.3 New DataProviders might handle this edge case automatically?
// WorldGenSettings defaultGen = net.minecraft.world.level.levelgen.presets.WorldPresets.createNormalWorldFromPreset(frozen); // return (resourceManager, dataPackConfig) -> {
// WorldBootstrap.InGUI.setDefaultCreateWorldSettings(defaultGen); //// Pair<WorldGenSettings, RegistryAccess.Frozen> res = worldDataSupplier.get(resourceManager, dataPackConfig);
RegistryAccess.Writable writable = RegistryAccess.builtinCopy(); //// WorldGenSettings defaultGen = net.minecraft.world.level.levelgen.presets.WorldPresets.createNormalWorldFromPreset(frozen);
//// WorldBootstrap.InGUI.setDefaultCreateWorldSettings(defaultGen);
// RegistryAccess.Writable writable = RegistryAccess.builtinCopy();
WorldGenUtil.preloadWorldPresets(resourceManager, writable); //
RegistryOps<JsonElement> registryOps = RegistryOps.createAndLoad( //
JsonOps.INSTANCE, writable, resourceManager // WorldGenUtil.preloadWorldPresets(resourceManager, writable);
); // RegistryOps<JsonElement> registryOps = RegistryOps.createAndLoad(
RegistryAccess.Frozen frozen = writable.freeze(); // JsonOps.INSTANCE, writable, resourceManager
WorldBootstrap.InGUI.registryReady(frozen); // );
// RegistryAccess.Frozen frozen = writable.freeze();
// WorldBootstrap.InGUI.registryReady(frozen);
return WorldGenUtil.defaultWorldDataSupplier(registryOps, frozen); //
}; //
// return WorldGenUtil.defaultWorldDataSupplier(registryOps, frozen);
// };
} }
//this is called when a new world is first created //this is called when a new world is first created

View file

@ -5,10 +5,13 @@ import org.betterx.worlds.together.world.event.WorldBootstrap;
import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.gui.screens.worldselection.WorldOpenFlows; import net.minecraft.client.gui.screens.worldselection.WorldOpenFlows;
import net.minecraft.core.LayeredRegistryAccess;
import net.minecraft.core.RegistryAccess; import net.minecraft.core.RegistryAccess;
import net.minecraft.server.RegistryLayer;
import net.minecraft.server.ReloadableServerResources; import net.minecraft.server.ReloadableServerResources;
import net.minecraft.world.level.LevelSettings; import net.minecraft.world.level.LevelSettings;
import net.minecraft.world.level.levelgen.WorldGenSettings; import net.minecraft.world.level.levelgen.WorldDimensions;
import net.minecraft.world.level.levelgen.WorldOptions;
import net.minecraft.world.level.storage.LevelStorageSource; import net.minecraft.world.level.storage.LevelStorageSource;
import net.minecraft.world.level.storage.WorldData; import net.minecraft.world.level.storage.WorldData;
@ -19,7 +22,7 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.util.Optional; import java.util.function.Function;
@Mixin(WorldOpenFlows.class) @Mixin(WorldOpenFlows.class)
public abstract class WorldOpenFlowsMixin { public abstract class WorldOpenFlowsMixin {
@ -56,18 +59,19 @@ public abstract class WorldOpenFlowsMixin {
public void wt_createFreshLevel( public void wt_createFreshLevel(
String levelID, String levelID,
LevelSettings levelSettings, LevelSettings levelSettings,
RegistryAccess registryAccess, WorldOptions worldOptions,
WorldGenSettings worldGenSettings, Function<RegistryAccess, WorldDimensions> function,
CallbackInfo ci CallbackInfo ci
) { ) {
WorldBootstrap.InFreshLevel.setupNewWorld(levelID, worldGenSettings, this.levelSource, Optional.empty()); //TODO: 1.19.3 no mor dimensions at this stage...
//WorldBootstrap.InFreshLevel.setupNewWorld(levelID, worldGenSettings, this.levelSource, Optional.empty());
} }
@Inject(method = "createLevelFromExistingSettings", at = @At("HEAD")) @Inject(method = "createLevelFromExistingSettings", at = @At("HEAD"))
public void wt_createLevelFromExistingSettings( public void wt_createLevelFromExistingSettings(
LevelStorageSource.LevelStorageAccess levelStorageAccess, LevelStorageSource.LevelStorageAccess levelStorageAccess,
ReloadableServerResources reloadableServerResources, ReloadableServerResources reloadableServerResources,
RegistryAccess.Frozen frozen, LayeredRegistryAccess<RegistryLayer> layeredRegistryAccess,
WorldData worldData, WorldData worldData,
CallbackInfo ci CallbackInfo ci
) { ) {

View file

@ -6,7 +6,6 @@ import com.mojang.serialization.DynamicOps;
import net.minecraft.nbt.Tag; import net.minecraft.nbt.Tag;
import net.minecraft.resources.RegistryOps; import net.minecraft.resources.RegistryOps;
import net.minecraft.server.Main; import net.minecraft.server.Main;
import net.minecraft.world.level.levelgen.WorldGenSettings;
import net.minecraft.world.level.storage.LevelStorageSource; import net.minecraft.world.level.storage.LevelStorageSource;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
@ -23,7 +22,7 @@ abstract public class MainMixin {
} }
@ModifyArg(method = "method_43613", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/storage/LevelStorageSource$LevelStorageAccess;getDataTag(Lcom/mojang/serialization/DynamicOps;Lnet/minecraft/world/level/DataPackConfig;Lcom/mojang/serialization/Lifecycle;)Lnet/minecraft/world/level/storage/WorldData;")) @ModifyArg(method = "method_43613", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/storage/LevelStorageSource$LevelStorageAccess;getDataTag(Lcom/mojang/serialization/DynamicOps;Lnet/minecraft/world/level/WorldDataConfiguration;Lnet/minecraft/core/Registry;Lcom/mojang/serialization/Lifecycle;)Lcom/mojang/datafixers/util/Pair;"))
private static DynamicOps<Tag> bcl_onCreate(DynamicOps<Tag> dynamicOps) { private static DynamicOps<Tag> bcl_onCreate(DynamicOps<Tag> dynamicOps) {
if (dynamicOps instanceof RegistryOps<Tag> regOps) { if (dynamicOps instanceof RegistryOps<Tag> regOps) {
WorldBootstrap.DedicatedServer.registryReady(regOps); WorldBootstrap.DedicatedServer.registryReady(regOps);
@ -31,9 +30,10 @@ abstract public class MainMixin {
return dynamicOps; return dynamicOps;
} }
@ModifyArg(method = "method_43613", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/storage/PrimaryLevelData;<init>(Lnet/minecraft/world/level/LevelSettings;Lnet/minecraft/world/level/levelgen/WorldGenSettings;Lcom/mojang/serialization/Lifecycle;)V")) //TODO: 1.19.3 this may be obsolete, as datapacks are handled differently now
private static WorldGenSettings bcl_onCreateLevelData(WorldGenSettings worldGenSettings) { // @ModifyArg(method = "method_43613", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/storage/PrimaryLevelData;<init>(Lnet/minecraft/world/level/LevelSettings;Lnet/minecraft/world/level/levelgen/WorldOptions;Lnet/minecraft/world/level/storage/PrimaryLevelData$SpecialWorldProperty;Lcom/mojang/serialization/Lifecycle;)V"))
WorldBootstrap.DedicatedServer.applyDatapackChangesOnNewWorld(worldGenSettings); // private static WorldGenSettings bcl_onCreateLevelData(WorldGenSettings worldGenSettings) {
return worldGenSettings; // WorldBootstrap.DedicatedServer.applyDatapackChangesOnNewWorld(worldGenSettings);
} // return worldGenSettings;
// }
} }

View file

@ -1,7 +1,5 @@
package org.betterx.worlds.together.mixin.common; package org.betterx.worlds.together.mixin.common;
import org.betterx.worlds.together.world.event.WorldBootstrap;
import net.minecraft.core.RegistryAccess; import net.minecraft.core.RegistryAccess;
import net.minecraft.server.MinecraftServer; import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.progress.ChunkProgressListener; import net.minecraft.server.level.progress.ChunkProgressListener;
@ -29,7 +27,8 @@ public class MinecraftServerMixin {
@Inject(method = "createLevels", at = @At(value = "HEAD")) @Inject(method = "createLevels", at = @At(value = "HEAD"))
private void together_addSurfaceRules(ChunkProgressListener worldGenerationProgressListener, CallbackInfo ci) { private void together_addSurfaceRules(ChunkProgressListener worldGenerationProgressListener, CallbackInfo ci) {
WorldBootstrap.finalizeWorldGenSettings(this.worldData.worldGenSettings()); //TODO: 1.19.3 Dimensions are handled differently now
//WorldBootstrap.finalizeWorldGenSettings(this.worldData.worldGenSettings());
} }
} }

View file

@ -1,7 +1,5 @@
package org.betterx.worlds.together.mixin.common; package org.betterx.worlds.together.mixin.common;
import org.betterx.worlds.together.chunkgenerator.ChunkGeneratorUtils;
import com.mojang.datafixers.DataFixer; import com.mojang.datafixers.DataFixer;
import net.minecraft.server.MinecraftServer; import net.minecraft.server.MinecraftServer;
import net.minecraft.server.Services; import net.minecraft.server.Services;
@ -31,6 +29,7 @@ public class MinecraftServerMixinLate {
ChunkProgressListenerFactory chunkProgressListenerFactory, ChunkProgressListenerFactory chunkProgressListenerFactory,
CallbackInfo ci CallbackInfo ci
) { ) {
ChunkGeneratorUtils.restoreOriginalBiomeSourceInAllDimension(worldStem.worldData().worldGenSettings()); //TODO: 1.19.3 Dimensions are handled differently now
//ChunkGeneratorUtils.restoreOriginalBiomeSourceInAllDimension(worldStem.worldData().worldGenSettings());
} }
} }

View file

@ -1,69 +1,50 @@
package org.betterx.worlds.together.mixin.common; package org.betterx.worlds.together.mixin.common;
import org.betterx.worlds.together.world.event.WorldBootstrap;
import com.mojang.datafixers.DataFixer;
import com.mojang.serialization.Dynamic;
import com.mojang.serialization.Lifecycle;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.Tag;
import net.minecraft.resources.RegistryOps;
import net.minecraft.world.level.LevelSettings;
import net.minecraft.world.level.levelgen.WorldGenSettings;
import net.minecraft.world.level.storage.LevelVersion;
import net.minecraft.world.level.storage.PrimaryLevelData; import net.minecraft.world.level.storage.PrimaryLevelData;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin; 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;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.util.Optional;
import org.jetbrains.annotations.Nullable;
@Mixin(PrimaryLevelData.class) @Mixin(PrimaryLevelData.class)
public class PrimaryLevelDataMixin { public class PrimaryLevelDataMixin {
@Shadow //TODO: 1.19.3 This was changed completley
@Final // @Shadow
private WorldGenSettings worldGenSettings; // @Final
private static final ThreadLocal<Optional<RegistryOps<Tag>>> bcl_lastRegistryAccess = ThreadLocal.withInitial( // private WorldGenSettings worldGenSettings;
() -> Optional.empty()); // private static final ThreadLocal<Optional<RegistryOps<Tag>>> bcl_lastRegistryAccess = ThreadLocal.withInitial(
// () -> Optional.empty());
//This is the way a created (new) world is initializing the PrimaryLevelData //
@ModifyArg(method = "<init>(Lnet/minecraft/world/level/LevelSettings;Lnet/minecraft/world/level/levelgen/WorldGenSettings;Lcom/mojang/serialization/Lifecycle;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/storage/PrimaryLevelData;<init>(Lcom/mojang/datafixers/DataFixer;ILnet/minecraft/nbt/CompoundTag;ZIIIFJJIIIZIZZZLnet/minecraft/world/level/border/WorldBorder$Settings;IILjava/util/UUID;Ljava/util/Set;Lnet/minecraft/world/level/timers/TimerQueue;Lnet/minecraft/nbt/CompoundTag;Lnet/minecraft/nbt/CompoundTag;Lnet/minecraft/world/level/LevelSettings;Lnet/minecraft/world/level/levelgen/WorldGenSettings;Lcom/mojang/serialization/Lifecycle;)V")) // //This is the way a created (new) world is initializing the PrimaryLevelData
private static WorldGenSettings bcl_fixOtherSettings(WorldGenSettings worldGenSettings) { // @ModifyArg(method = "<init>(Lnet/minecraft/world/level/LevelSettings;Lnet/minecraft/world/level/levelgen/WorldGenSettings;Lcom/mojang/serialization/Lifecycle;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/storage/PrimaryLevelData;<init>(Lcom/mojang/datafixers/DataFixer;ILnet/minecraft/nbt/CompoundTag;ZIIIFJJIIIZIZZZLnet/minecraft/world/level/border/WorldBorder$Settings;IILjava/util/UUID;Ljava/util/Set;Lnet/minecraft/world/level/timers/TimerQueue;Lnet/minecraft/nbt/CompoundTag;Lnet/minecraft/nbt/CompoundTag;Lnet/minecraft/world/level/LevelSettings;Lnet/minecraft/world/level/levelgen/WorldGenSettings;Lcom/mojang/serialization/Lifecycle;)V"))
return WorldBootstrap.enforceInNewWorld(worldGenSettings); // private static WorldGenSettings bcl_fixOtherSettings(WorldGenSettings worldGenSettings) {
} // return WorldBootstrap.enforceInNewWorld(worldGenSettings);
// }
@Inject(method = "parse", at = @At("HEAD")) //
private static void bcl_parse( // @Inject(method = "parse", at = @At("HEAD"))
Dynamic<Tag> dynamic, // private static void bcl_parse(
DataFixer dataFixer, // Dynamic<Tag> dynamic,
int i, // DataFixer dataFixer,
@Nullable CompoundTag compoundTag, // int i,
LevelSettings levelSettings, // @Nullable CompoundTag compoundTag,
LevelVersion levelVersion, // LevelSettings levelSettings,
WorldGenSettings worldGenSettings, // LevelVersion levelVersion,
Lifecycle lifecycle, // WorldGenSettings worldGenSettings,
CallbackInfoReturnable<PrimaryLevelData> cir // Lifecycle lifecycle,
) { // CallbackInfoReturnable<PrimaryLevelData> cir
if (dynamic.getOps() instanceof RegistryOps<Tag> regOps) { // ) {
bcl_lastRegistryAccess.set(Optional.of(regOps)); // if (dynamic.getOps() instanceof RegistryOps<Tag> regOps) {
} // bcl_lastRegistryAccess.set(Optional.of(regOps));
} // }
// }
//
//This is the way a loaded (existing) world is initializing the PrimaryLevelData //
@ModifyArg(method = "parse", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/storage/PrimaryLevelData;<init>(Lcom/mojang/datafixers/DataFixer;ILnet/minecraft/nbt/CompoundTag;ZIIIFJJIIIZIZZZLnet/minecraft/world/level/border/WorldBorder$Settings;IILjava/util/UUID;Ljava/util/Set;Lnet/minecraft/world/level/timers/TimerQueue;Lnet/minecraft/nbt/CompoundTag;Lnet/minecraft/nbt/CompoundTag;Lnet/minecraft/world/level/LevelSettings;Lnet/minecraft/world/level/levelgen/WorldGenSettings;Lcom/mojang/serialization/Lifecycle;)V")) // //This is the way a loaded (existing) world is initializing the PrimaryLevelData
private static WorldGenSettings bcl_fixSettings(WorldGenSettings settings) { // @ModifyArg(method = "parse", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/storage/PrimaryLevelData;<init>(Lcom/mojang/datafixers/DataFixer;ILnet/minecraft/nbt/CompoundTag;ZIIIFJJIIIZIZZZLnet/minecraft/world/level/border/WorldBorder$Settings;IILjava/util/UUID;Ljava/util/Set;Lnet/minecraft/world/level/timers/TimerQueue;Lnet/minecraft/nbt/CompoundTag;Lnet/minecraft/nbt/CompoundTag;Lnet/minecraft/world/level/LevelSettings;Lnet/minecraft/world/level/levelgen/WorldGenSettings;Lcom/mojang/serialization/Lifecycle;)V"))
Optional<RegistryOps<Tag>> registryOps = bcl_lastRegistryAccess.get(); // private static WorldGenSettings bcl_fixSettings(WorldGenSettings settings) {
WorldBootstrap.InGUI.registryReadyOnLoadedWorld(registryOps); // Optional<RegistryOps<Tag>> registryOps = bcl_lastRegistryAccess.get();
settings = WorldBootstrap.enforceInLoadedWorld(registryOps, settings); // WorldBootstrap.InGUI.registryReadyOnLoadedWorld(registryOps);
bcl_lastRegistryAccess.set(Optional.empty()); // settings = WorldBootstrap.enforceInLoadedWorld(registryOps, settings);
return settings; // bcl_lastRegistryAccess.set(Optional.empty());
} // return settings;
// }
} }

View file

@ -1,48 +1,35 @@
package org.betterx.worlds.together.mixin.common; package org.betterx.worlds.together.mixin.common;
import org.betterx.worlds.together.surfaceRules.AssignedSurfaceRule;
import org.betterx.worlds.together.surfaceRules.SurfaceRuleRegistry;
import com.mojang.serialization.Codec;
import net.minecraft.client.Minecraft;
import net.minecraft.core.Registry;
import net.minecraft.core.RegistryAccess; import net.minecraft.core.RegistryAccess;
import net.minecraft.resources.ResourceKey;
import com.google.common.collect.ImmutableMap;
import org.spongepowered.asm.mixin.Mixin; 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.ModifyArg;
import java.util.Map;
import java.util.function.Supplier;
@Mixin(RegistryAccess.class) @Mixin(RegistryAccess.class)
public interface RegistryAccessMixin { public interface RegistryAccessMixin {
@ModifyArg(method = "<clinit>", at = @At(value = "INVOKE", target = "Lnet/minecraft/Util;make(Ljava/util/function/Supplier;)Ljava/lang/Object;")) //TODO: 1.19.3 This will probably be a new kind of DataProvider.
private static Supplier<ImmutableMap<ResourceKey<Registry<?>>, RegistryAccess.RegistryData<?>>> together_addRegistry( // @ModifyArg(method = "<clinit>", at = @At(value = "INVOKE", target = "Lnet/minecraft/Util;make(Ljava/util/function/Supplier;)Ljava/lang/Object;"))
Supplier<ImmutableMap<ResourceKey<Registry<?>>, RegistryAccess.RegistryData<?>>> supplier // private static Supplier<ImmutableMap<ResourceKey<Registry<?>>, RegistryAccess.RegistryData<?>>> together_addRegistry(
) { // Supplier<ImmutableMap<ResourceKey<Registry<?>>, RegistryAccess.RegistryData<?>>> supplier
// ) {
return () -> { //
Map<ResourceKey<Registry<?>>, RegistryAccess.RegistryData<?>> res = supplier.get(); // return () -> {
ImmutableMap.Builder<ResourceKey<Registry<?>>, RegistryAccess.RegistryData<?>> builder = ImmutableMap.builder(); // Map<ResourceKey<Registry<?>>, RegistryAccess.RegistryData<?>> res = supplier.get();
// ImmutableMap.Builder<ResourceKey<Registry<?>>, RegistryAccess.RegistryData<?>> builder = ImmutableMap.builder();
builder.putAll(res); //
put(builder, SurfaceRuleRegistry.SURFACE_RULES_REGISTRY, AssignedSurfaceRule.CODEC); // builder.putAll(res);
return builder.build(); // put(builder, SurfaceRuleRegistry.SURFACE_RULES_REGISTRY, AssignedSurfaceRule.CODEC);
}; // return builder.build();
} // };
// }
@Shadow //
static <E> void put( // @Shadow
ImmutableMap.Builder<ResourceKey<Registry<?>>, RegistryAccess.RegistryData<?>> builder, // static <E> void put(
ResourceKey<? extends Registry<E>> resourceKey, // ImmutableMap.Builder<ResourceKey<Registry<?>>, RegistryAccess.RegistryData<?>> builder,
Codec<E> codec // ResourceKey<? extends Registry<E>> resourceKey,
) { // Codec<E> codec
throw new RuntimeException("Shadowed Call"); // ) {
} // throw new RuntimeException("Shadowed Call");
// }
} }

View file

@ -10,7 +10,7 @@ import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyArg; import org.spongepowered.asm.mixin.injection.ModifyArg;
@Mixin(DedicatedServerProperties.WorldGenProperties.class) @Mixin(DedicatedServerProperties.WorldDimensionData.class)
public class WorldGenPropertiesMixin { public class WorldGenPropertiesMixin {
// @ModifyArg(method = "create", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/levelgen/presets/WorldPreset;createWorldGenSettings(JZZ)Lnet/minecraft/world/level/levelgen/WorldGenSettings;")) // @ModifyArg(method = "create", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/levelgen/presets/WorldPreset;createWorldGenSettings(JZZ)Lnet/minecraft/world/level/levelgen/WorldGenSettings;"))
// public long wt_getSeed(long seed) { // public long wt_getSeed(long seed) {

View file

@ -84,7 +84,7 @@ public class SurfaceRuleUtil {
} }
public static void injectSurfaceRulesToAllDimensions(WorldGenSettings settings) { public static void injectSurfaceRulesToAllDimensions(WorldGenSettings settings) {
for (var entry : settings.dimensions().entrySet()) { for (var entry : settings.dimensions().dimensions().entrySet()) {
ResourceKey<LevelStem> key = entry.getKey(); ResourceKey<LevelStem> key = entry.getKey();
LevelStem stem = entry.getValue(); LevelStem stem = entry.getValue();

View file

@ -1,15 +1,15 @@
package org.betterx.worlds.together.world.event; package org.betterx.worlds.together.world.event;
import net.minecraft.core.Holder; import net.minecraft.core.Holder;
import net.minecraft.world.level.levelgen.WorldGenSettings; import net.minecraft.world.level.levelgen.WorldDimensions;
import net.minecraft.world.level.levelgen.presets.WorldPreset; import net.minecraft.world.level.levelgen.presets.WorldPreset;
import java.util.Optional; import java.util.Optional;
public class AdaptWorldPresetSettingEvent extends EventImpl<OnAdaptWorldPresetSettings> { public class AdaptWorldPresetSettingEvent extends EventImpl<OnAdaptWorldPresetSettings> {
public Optional<Holder<WorldPreset>> emit(Optional<Holder<WorldPreset>> start, WorldGenSettings settings) { public Optional<Holder<WorldPreset>> emit(Optional<Holder<WorldPreset>> start, WorldDimensions worldDims) {
for (OnAdaptWorldPresetSettings a : handlers) { for (OnAdaptWorldPresetSettings a : handlers) {
start = a.adapt(start, settings); start = a.adapt(start, worldDims);
} }
return start; return start;
} }

View file

@ -1,7 +1,7 @@
package org.betterx.worlds.together.world.event; package org.betterx.worlds.together.world.event;
import net.minecraft.core.Holder; import net.minecraft.core.Holder;
import net.minecraft.world.level.levelgen.WorldGenSettings; import net.minecraft.world.level.levelgen.WorldDimensions;
import net.minecraft.world.level.levelgen.presets.WorldPreset; import net.minecraft.world.level.levelgen.presets.WorldPreset;
import java.util.Optional; import java.util.Optional;
@ -10,6 +10,6 @@ import java.util.Optional;
public interface OnAdaptWorldPresetSettings { public interface OnAdaptWorldPresetSettings {
Optional<Holder<WorldPreset>> adapt( Optional<Holder<WorldPreset>> adapt(
Optional<Holder<WorldPreset>> currentPreset, Optional<Holder<WorldPreset>> currentPreset,
WorldGenSettings worldGenSettings WorldDimensions worldDims
); );
} }

View file

@ -22,6 +22,7 @@ import net.minecraft.resources.RegistryOps;
import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceKey;
import net.minecraft.world.level.chunk.ChunkGenerator; import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.dimension.LevelStem; import net.minecraft.world.level.dimension.LevelStem;
import net.minecraft.world.level.levelgen.WorldDimensions;
import net.minecraft.world.level.levelgen.WorldGenSettings; import net.minecraft.world.level.levelgen.WorldGenSettings;
import net.minecraft.world.level.levelgen.presets.WorldPreset; import net.minecraft.world.level.levelgen.presets.WorldPreset;
import net.minecraft.world.level.storage.LevelResource; import net.minecraft.world.level.storage.LevelResource;
@ -42,7 +43,8 @@ public class WorldBootstrap {
} }
public static RegistryAccess getLastRegistryAccessOrElseBuiltin() { public static RegistryAccess getLastRegistryAccessOrElseBuiltin() {
if (LAST_REGISTRY_ACCESS == null) return BuiltinRegistries.ACCESS; //TODO: 1.19.3 ther no longer is a general builtin ACCESS
if (LAST_REGISTRY_ACCESS == null) return BuiltinRegistries.createAccess();
return LAST_REGISTRY_ACCESS; return LAST_REGISTRY_ACCESS;
} }
@ -92,10 +94,10 @@ public class WorldBootstrap {
if (currentPreset.isPresent() && LAST_REGISTRY_ACCESS != null) { if (currentPreset.isPresent() && LAST_REGISTRY_ACCESS != null) {
var presetKey = currentPreset.get().unwrapKey(); var presetKey = currentPreset.get().unwrapKey();
if (presetKey.isPresent()) { if (presetKey.isPresent()) {
Optional<Holder<WorldPreset>> newPreset = LAST_REGISTRY_ACCESS Optional<Holder.Reference<WorldPreset>> newPreset = LAST_REGISTRY_ACCESS
.registryOrThrow(Registry.WORLD_PRESET_REGISTRY) .registryOrThrow(Registry.WORLD_PRESET_REGISTRY)
.getHolder(presetKey.get()); .getHolder(presetKey.get());
if (newPreset.isPresent()) currentPreset = newPreset; if (newPreset.isPresent()) currentPreset = (Optional<Holder<WorldPreset>>) (Optional<?>) newPreset;
} }
} }
return currentPreset; return currentPreset;
@ -131,15 +133,15 @@ public class WorldBootstrap {
} }
//Needs to get called after setupWorld //Needs to get called after setupWorld
public static void applyDatapackChangesOnNewWorld(WorldGenSettings worldGenSettings) { public static void applyDatapackChangesOnNewWorld(WorldDimensions worldDims) {
Optional<Holder<WorldPreset>> currentPreset = Optional.of(Helpers.defaultServerPreset()); Optional<Holder<WorldPreset>> currentPreset = Optional.of(Helpers.defaultServerPreset());
currentPreset = WorldEventsImpl.ADAPT_WORLD_PRESET.emit(currentPreset, worldGenSettings); currentPreset = WorldEventsImpl.ADAPT_WORLD_PRESET.emit(currentPreset, worldDims);
if (currentPreset.map(Holder::value).orElse(null) instanceof WorldPresetAccessor acc) { if (currentPreset.map(Holder::value).orElse(null) instanceof WorldPresetAccessor acc) {
TogetherWorldPreset.writeWorldPresetSettings(acc.bcl_getDimensions()); TogetherWorldPreset.writeWorldPresetSettings(acc.bcl_getDimensions());
} else { } else {
WorldsTogether.LOGGER.error("Failed writing together File"); WorldsTogether.LOGGER.error("Failed writing together File");
TogetherWorldPreset.writeWorldPresetSettings(worldGenSettings.dimensions()); TogetherWorldPreset.writeWorldPresetSettings(worldDims.dimensions());
} }
WorldEventsImpl.ON_WORLD_LOAD.emit(OnWorldLoad::onLoad); WorldEventsImpl.ON_WORLD_LOAD.emit(OnWorldLoad::onLoad);
} }
@ -171,7 +173,8 @@ public class WorldBootstrap {
Optional<Holder<WorldPreset>> newPreset = setupNewWorldCommon( Optional<Holder<WorldPreset>> newPreset = setupNewWorldCommon(
levelStorageAccess.get(), levelStorageAccess.get(),
currentPreset, currentPreset,
worldGenSettingsComponent.settings().worldGenSettings() //TODO: 1.19.13 see if this is the correct Dimensions list
worldGenSettingsComponent.settings().selectedDimensions()
); );
if (newPreset != currentPreset) { if (newPreset != currentPreset) {
acc.bcl_setPreset(newPreset); acc.bcl_setPreset(newPreset);
@ -188,7 +191,7 @@ public class WorldBootstrap {
static Optional<Holder<WorldPreset>> setupNewWorldCommon( static Optional<Holder<WorldPreset>> setupNewWorldCommon(
LevelStorageSource.LevelStorageAccess levelStorageAccess, LevelStorageSource.LevelStorageAccess levelStorageAccess,
Optional<Holder<WorldPreset>> currentPreset, Optional<Holder<WorldPreset>> currentPreset,
WorldGenSettings worldGenSettings WorldDimensions worldDims
) { ) {
Helpers.initializeWorldConfig(levelStorageAccess, true); Helpers.initializeWorldConfig(levelStorageAccess, true);
@ -208,13 +211,13 @@ public class WorldBootstrap {
true true
)); ));
currentPreset = WorldEventsImpl.ADAPT_WORLD_PRESET.emit(currentPreset, worldGenSettings); currentPreset = WorldEventsImpl.ADAPT_WORLD_PRESET.emit(currentPreset, worldDims);
if (currentPreset.map(Holder::value).orElse(null) instanceof WorldPresetAccessor acc) { if (currentPreset.map(Holder::value).orElse(null) instanceof WorldPresetAccessor acc) {
TogetherWorldPreset.writeWorldPresetSettings(acc.bcl_getDimensions()); TogetherWorldPreset.writeWorldPresetSettings(acc.bcl_getDimensions());
} else { } else {
WorldsTogether.LOGGER.error("Failed writing together File"); WorldsTogether.LOGGER.error("Failed writing together File");
TogetherWorldPreset.writeWorldPresetSettings(worldGenSettings.dimensions()); TogetherWorldPreset.writeWorldPresetSettings(worldDims.dimensions());
} }
//LifeCycleAPI._runBeforeLevelLoad(); //LifeCycleAPI._runBeforeLevelLoad();
@ -281,13 +284,13 @@ public class WorldBootstrap {
public static class InFreshLevel { public static class InFreshLevel {
public static void setupNewWorld( public static void setupNewWorld(
String levelID, String levelID,
WorldGenSettings worldGenSettings, WorldDimensions worldDims,
LevelStorageSource levelSource, LevelStorageSource levelSource,
Optional<Holder<WorldPreset>> worldPreset Optional<Holder<WorldPreset>> worldPreset
) { ) {
try { try {
var levelStorageAccess = levelSource.createAccess(levelID); var levelStorageAccess = levelSource.createAccess(levelID);
InGUI.setupNewWorldCommon(levelStorageAccess, worldPreset, worldGenSettings); InGUI.setupNewWorldCommon(levelStorageAccess, worldPreset, worldDims);
levelStorageAccess.close(); levelStorageAccess.close();
} catch (Exception e) { } catch (Exception e) {
WorldsTogether.LOGGER.error("Failed to initialize data in world", e); WorldsTogether.LOGGER.error("Failed to initialize data in world", e);
@ -297,7 +300,7 @@ public class WorldBootstrap {
public static void finalizeWorldGenSettings(WorldGenSettings worldGenSettings) { public static void finalizeWorldGenSettings(WorldGenSettings worldGenSettings) {
String output = "World Dimensions: "; String output = "World Dimensions: ";
for (var entry : worldGenSettings.dimensions().entrySet()) { for (var entry : worldGenSettings.dimensions().dimensions().entrySet()) {
WorldEventsImpl.ON_FINALIZE_LEVEL_STEM.emit(e -> e.now( WorldEventsImpl.ON_FINALIZE_LEVEL_STEM.emit(e -> e.now(
worldGenSettings, worldGenSettings,
entry.getKey(), entry.getKey(),
@ -320,13 +323,13 @@ public class WorldBootstrap {
WorldEventsImpl.ON_FINALIZED_WORLD_LOAD.emit(e -> e.done(worldGenSettings)); WorldEventsImpl.ON_FINALIZED_WORLD_LOAD.emit(e -> e.done(worldGenSettings));
} }
public static WorldGenSettings enforceInNewWorld(WorldGenSettings worldGenSettings) { public static WorldDimensions enforceInNewWorld(WorldDimensions worldGenSettings) {
return WorldGenUtil.repairBiomeSourceInAllDimensions(LAST_REGISTRY_ACCESS, worldGenSettings); return WorldGenUtil.repairBiomeSourceInAllDimensions(LAST_REGISTRY_ACCESS, worldGenSettings);
} }
public static WorldGenSettings enforceInLoadedWorld( public static WorldDimensions enforceInLoadedWorld(
Optional<RegistryOps<Tag>> registryOps, Optional<RegistryOps<Tag>> registryOps,
WorldGenSettings worldGenSettings WorldDimensions worldGenSettings
) { ) {
if (registryOps.orElse(null) instanceof RegistryOpsAccessor acc) { if (registryOps.orElse(null) instanceof RegistryOpsAccessor acc) {
return WorldGenUtil.repairBiomeSourceInAllDimensions(acc.bcl_getRegistryAccess(), worldGenSettings); return WorldGenUtil.repairBiomeSourceInAllDimensions(acc.bcl_getRegistryAccess(), worldGenSettings);

View file

@ -13,7 +13,6 @@ import com.mojang.serialization.Dynamic;
import com.mojang.serialization.codecs.RecordCodecBuilder; import com.mojang.serialization.codecs.RecordCodecBuilder;
import net.minecraft.core.Registry; import net.minecraft.core.Registry;
import net.minecraft.core.RegistryAccess; import net.minecraft.core.RegistryAccess;
import net.minecraft.data.BuiltinRegistries;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtOps; import net.minecraft.nbt.NbtOps;
import net.minecraft.nbt.Tag; import net.minecraft.nbt.Tag;
@ -108,11 +107,13 @@ public class TogetherWorldPreset extends WorldPreset {
try { try {
final RegistryAccess registryAccess = WorldBootstrap.getLastRegistryAccessOrElseBuiltin(); final RegistryAccess registryAccess = WorldBootstrap.getLastRegistryAccessOrElseBuiltin();
boolean globalRegistry = false; boolean globalRegistry = false;
if (registryAccess == BuiltinRegistries.ACCESS) { //TODO: 1.19.3 there is no longer a builtin registry acccess
/*if (registryAccess == BuiltinRegistries.ACCESS) {
if (Configs.MAIN_CONFIG.verboseLogging()) if (Configs.MAIN_CONFIG.verboseLogging())
BCLib.LOGGER.info("Loading from builtin Registry"); BCLib.LOGGER.info("Loading from builtin Registry");
globalRegistry = true; globalRegistry = true;
} else { } else */
{
if (Configs.MAIN_CONFIG.verboseLogging()) if (Configs.MAIN_CONFIG.verboseLogging())
BCLib.LOGGER.info("Loading from datapack Registry"); BCLib.LOGGER.info("Loading from datapack Registry");
} }
@ -145,11 +146,7 @@ public class TogetherWorldPreset extends WorldPreset {
return preset return preset
.get() .get()
.value() .value()
.createWorldGenSettings( .createWorldDimensions()
0,
true,
true
)
.dimensions(); .dimensions();
} }

View file

@ -31,7 +31,8 @@ public class WorldPresets {
private static ResourceKey<WorldPreset> DEFAULT = net.minecraft.world.level.levelgen.presets.WorldPresets.NORMAL; private static ResourceKey<WorldPreset> DEFAULT = net.minecraft.world.level.levelgen.presets.WorldPresets.NORMAL;
public static Holder<WorldPreset> get(RegistryAccess access, ResourceKey<WorldPreset> key) { public static Holder<WorldPreset> get(RegistryAccess access, ResourceKey<WorldPreset> key) {
return ((access != null) ? access : BuiltinRegistries.ACCESS) //TODO: 1.19.3 there is no longer a builtin registry acccess
return ((access != null) ? access : BuiltinRegistries.createAccess())
.registryOrThrow(Registry.WORLD_PRESET_REGISTRY) .registryOrThrow(Registry.WORLD_PRESET_REGISTRY)
.getHolderOrThrow(key); .getHolderOrThrow(key);
} }

View file

@ -13,9 +13,10 @@ extendable class net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator
accessible class net/minecraft/data/BuiltinRegistries$RegistryBootstrap accessible class net/minecraft/data/BuiltinRegistries$RegistryBootstrap
accessible class net/minecraft/core/Registry$RegistryBootstrap accessible class net/minecraft/core/Registry$RegistryBootstrap
accessible class net/minecraft/world/level/levelgen/SurfaceRules$SequenceRuleSource accessible class net/minecraft/world/level/levelgen/SurfaceRules$SequenceRuleSource
accessible class net/minecraft/server/dedicated/DedicatedServerProperties$WorldDimensionData
#Methods #Methods
accessible method net/minecraft/client/gui/screens/worldselection/WorldGenSettingsComponent updateSettings (Lnet/minecraft/client/gui/screens/worldselection/WorldCreationContext$Updater;)V accessible method net/minecraft/client/gui/screens/worldselection/WorldGenSettingsComponent updateSettings (Lnet/minecraft/client/gui/screens/worldselection/WorldCreationContext$DimensionsUpdater;)V
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/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/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/world/level/levelgen/SurfaceRules$SequenceRuleSource <init> (Ljava/util/List;)V

View file

@ -46,12 +46,10 @@
"bclib.mixins.client.json" "bclib.mixins.client.json"
], ],
"depends": { "depends": {
"fabricloader": ">=0.14.8", "fabricloader": ">=0.14.10",
"fabric": ">=0.58.0", "fabric": ">=0.65.0",
"minecraft": [ "minecraft": [
"1.19", "1.19.3-alpha.22.42.a"
"1.19.1",
"1.19.2"
] ]
}, },
"custom": { "custom": {