Merge branch '1.19' into 1.19.3

# Conflicts:
#	gradle.properties
#	src/main/java/org/betterx/bclib/BCLib.java
#	src/main/java/org/betterx/bclib/api/v2/generator/BCLChunkGenerator.java
#	src/main/java/org/betterx/worlds/together/mixin/common/WorldPresetsBootstrapMixin.java
#	src/main/java/org/betterx/worlds/together/worldPreset/WorldPresets.java
#	src/main/resources/bclib.accesswidener
This commit is contained in:
Frank 2022-11-29 09:41:10 +01:00
commit 0dcb7809b8
41 changed files with 1586 additions and 75 deletions

View file

@ -6,6 +6,7 @@ import org.betterx.worlds.together.worldPreset.WorldPresets;
import net.minecraft.core.Holder;
import net.minecraft.core.Registry;
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.biome.BiomeSource;
import net.minecraft.world.level.dimension.DimensionType;
import net.minecraft.world.level.dimension.LevelStem;
import net.minecraft.world.level.levelgen.NoiseGeneratorSettings;
@ -47,7 +48,17 @@ public abstract class WorldPresetsBootstrapMixin {
private Holder<NoiseGeneratorSettings> endNoiseSettings;
//see WorldPresets.register
@Shadow
protected abstract LevelStem makeNoiseBasedOverworld(
BiomeSource biomeSource,
Holder<NoiseGeneratorSettings> holder
);
@Shadow
@Final
private Registry<NoiseGeneratorSettings> noiseSettings;
@ModifyArg(method = "run", at = @At(value = "INVOKE", ordinal = 0, target = "Lnet/minecraft/world/level/levelgen/presets/WorldPresets$Bootstrap;registerCustomOverworldPreset(Lnet/minecraft/resources/ResourceKey;Lnet/minecraft/world/level/dimension/LevelStem;)Lnet/minecraft/core/Holder;"))
private LevelStem bcl_getOverworldStem(LevelStem overworldStem) {
WorldGenUtil.Context netherContext = new WorldGenUtil.Context(
@ -65,7 +76,14 @@ public abstract class WorldPresetsBootstrapMixin {
this.endNoiseSettings
);
WorldPresets.bootstrapPresets(presets, overworldStem, netherContext, endContext);
WorldPresets.bootstrapPresets(
presets,
overworldStem,
netherContext,
endContext,
noiseSettings,
this::makeNoiseBasedOverworld
);
return overworldStem;
}

View file

@ -119,7 +119,7 @@ public class TagManager {
public static boolean isToolWithMineableTag(ItemStack stack, TagKey<Block> tag) {
if (stack.getItem() instanceof DiggerItemAccessor dig) {
return dig.bclib_getBlockTag().equals(tag);
return dig.bclib_getBlockTag() == tag;
}
return false;
}

View file

@ -207,6 +207,10 @@ public class TagRegistry<T> {
return creatTagKey(new ResourceLocation("c", name));
}
public TagKey<T> makeTogetherTag(String name) {
return creatTagKey(WorldsTogether.makeID(name));
}
public void addUntyped(TagKey<T> tagID, ResourceLocation... elements) {
if (isFrozen) WorldsTogether.LOGGER.warning("Adding Tag " + tagID + " after the API was frozen.");
Set<TagEntry> set = getSetForTag(tagID);

View file

@ -16,7 +16,9 @@ import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.WorldPresetTags;
import net.minecraft.world.level.biome.BiomeSource;
import net.minecraft.world.level.dimension.LevelStem;
import net.minecraft.world.level.levelgen.NoiseGeneratorSettings;
import net.minecraft.world.level.levelgen.presets.WorldPreset;
import com.google.common.collect.Maps;
@ -25,6 +27,10 @@ import java.util.Map;
import org.jetbrains.annotations.ApiStatus;
public class WorldPresets {
@FunctionalInterface
public interface OverworldBuilder {
LevelStem make(BiomeSource biomeSource, Holder<NoiseGeneratorSettings> noiseGeneratorSettings);
}
public static final TagRegistry.Simple<WorldPreset> WORLD_PRESETS =
TagManager.registerType(BuiltInRegistries.WORLD_PRESET, "tags/worldgen/world_preset");
@ -79,17 +85,24 @@ public class WorldPresets {
return key;
}
@ApiStatus.Internal
public static void bootstrapPresets(
Registry<WorldPreset> presets,
LevelStem overworldStem,
WorldGenUtil.Context netherContext,
WorldGenUtil.Context endContext
WorldGenUtil.Context endContext,
Registry<NoiseGeneratorSettings> noiseSettings,
OverworldBuilder noiseBasedOverworld
) {
EntrypointUtil.getCommon(WorldPresetBootstrap.class)
.forEach(e -> e.bootstrapWorldPresets());
for (Map.Entry<ResourceKey<WorldPreset>, PresetBuilder> e : BUILDERS.entrySet()) {
TogetherWorldPreset preset = e.getValue().create(overworldStem, netherContext, endContext);
TogetherWorldPreset preset = e.getValue()
.create(
overworldStem, netherContext, endContext,
noiseSettings, noiseBasedOverworld
);
BuiltInRegistries.register(presets, e.getKey(), preset);
}
BUILDERS = null;
@ -113,7 +126,9 @@ public class WorldPresets {
TogetherWorldPreset create(
LevelStem overworldStem,
WorldGenUtil.Context netherContext,
WorldGenUtil.Context endContext
WorldGenUtil.Context endContext,
Registry<NoiseGeneratorSettings> noiseSettings,
OverworldBuilder noiseBasedOverworld
);
}
}