Biome generator fix
This commit is contained in:
parent
7daf9f614c
commit
6c2c943b0d
9 changed files with 75 additions and 28 deletions
|
@ -2,7 +2,6 @@ package ru.bclib.api.biomes;
|
|||
|
||||
import net.minecraft.core.particles.ParticleOptions;
|
||||
import net.minecraft.data.worldgen.BiomeDefaultFeatures;
|
||||
import net.minecraft.data.worldgen.placement.OrePlacements;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.sounds.Music;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
|
@ -17,7 +16,6 @@ import net.minecraft.world.level.biome.Biome.BiomeBuilder;
|
|||
import net.minecraft.world.level.biome.Biome.BiomeCategory;
|
||||
import net.minecraft.world.level.biome.Biome.Precipitation;
|
||||
import net.minecraft.world.level.biome.BiomeGenerationSettings;
|
||||
import net.minecraft.world.level.biome.BiomeGenerationSettings.Builder;
|
||||
import net.minecraft.world.level.biome.BiomeSpecialEffects;
|
||||
import net.minecraft.world.level.biome.MobSpawnSettings;
|
||||
import net.minecraft.world.level.biome.MobSpawnSettings.SpawnerData;
|
||||
|
|
|
@ -189,7 +189,7 @@ public class Chunker extends DataHandler.FromServer {
|
|||
public static final int MAX_PACKET_SIZE = 1024*1024;
|
||||
private static final int MAX_PAYLOAD_SIZE = MAX_PACKET_SIZE - HEADER_SIZE;
|
||||
|
||||
public static DataHandlerDescriptor DESCRIPTOR = new DataHandlerDescriptor(new ResourceLocation(BCLib.MOD_ID, "chunker"), Chunker::new, false, false);
|
||||
public static final DataHandlerDescriptor DESCRIPTOR = new DataHandlerDescriptor(new ResourceLocation(BCLib.MOD_ID, "chunker"), Chunker::new, false, false);
|
||||
|
||||
private int serialNo;
|
||||
private UUID uuid;
|
||||
|
|
|
@ -48,7 +48,7 @@ public class HelloClient extends DataHandler.FromServer {
|
|||
public interface IServerModMap extends Map<String, OfferedModInfo> {}
|
||||
public static class ServerModMap extends HashMap<String, OfferedModInfo> implements IServerModMap {}
|
||||
|
||||
public static DataHandlerDescriptor DESCRIPTOR = new DataHandlerDescriptor(new ResourceLocation(BCLib.MOD_ID, "hello_client"), HelloClient::new, false, false);
|
||||
public static final DataHandlerDescriptor DESCRIPTOR = new DataHandlerDescriptor(new ResourceLocation(BCLib.MOD_ID, "hello_client"), HelloClient::new, false, false);
|
||||
|
||||
public HelloClient() {
|
||||
super(DESCRIPTOR.IDENTIFIER);
|
||||
|
|
|
@ -57,7 +57,7 @@ import java.io.File;
|
|||
* </table>
|
||||
*/
|
||||
public class HelloServer extends DataHandler.FromClient {
|
||||
public static DataHandlerDescriptor DESCRIPTOR = new DataHandlerDescriptor(new ResourceLocation(BCLib.MOD_ID, "hello_server"), HelloServer::new, true, false);
|
||||
public static final DataHandlerDescriptor DESCRIPTOR = new DataHandlerDescriptor(new ResourceLocation(BCLib.MOD_ID, "hello_server"), HelloServer::new, true, false);
|
||||
|
||||
protected String bclibVersion = "0.0.0";
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ import java.util.UUID;
|
|||
import java.util.stream.Collectors;
|
||||
|
||||
public class RequestFiles extends DataHandler.FromClient {
|
||||
public static DataHandlerDescriptor DESCRIPTOR = new DataHandlerDescriptor(new ResourceLocation(BCLib.MOD_ID, "request_files"), RequestFiles::new, false, false);
|
||||
public static final DataHandlerDescriptor DESCRIPTOR = new DataHandlerDescriptor(new ResourceLocation(BCLib.MOD_ID, "request_files"), RequestFiles::new, false, false);
|
||||
static String currentToken = "";
|
||||
|
||||
protected List<AutoSyncID> files;
|
||||
|
|
|
@ -24,7 +24,7 @@ import java.util.List;
|
|||
import java.util.stream.Collectors;
|
||||
|
||||
public class SendFiles extends DataHandler.FromServer {
|
||||
public static DataHandlerDescriptor DESCRIPTOR = new DataHandlerDescriptor(new ResourceLocation(BCLib.MOD_ID, "send_files"), SendFiles::new, false, false);
|
||||
public static final DataHandlerDescriptor DESCRIPTOR = new DataHandlerDescriptor(new ResourceLocation(BCLib.MOD_ID, "send_files"), SendFiles::new, false, false);
|
||||
|
||||
protected List<AutoFileSyncEntry> files;
|
||||
private String token;
|
||||
|
|
|
@ -13,8 +13,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
public abstract class Patch {
|
||||
|
||||
private static List<Patch> ALL = new ArrayList<>(10);
|
||||
private static final List<Patch> ALL = new ArrayList<>(10);
|
||||
|
||||
/**
|
||||
* The Patch-Level derived from {@link #version}
|
||||
|
@ -50,12 +49,7 @@ public abstract class Patch {
|
|||
* @return The highest Patch-Version that was found
|
||||
*/
|
||||
public static String maxPatchVersion(@NotNull String modID) {
|
||||
return ALL.stream()
|
||||
.filter(p -> p.modID
|
||||
.equals(modID))
|
||||
.map(p -> p.version)
|
||||
.reduce((p, c) -> c)
|
||||
.orElse("0.0.0");
|
||||
return ALL.stream().filter(p -> p.modID.equals(modID)).map(p -> p.version).reduce((p, c) -> c).orElse("0.0.0");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -66,12 +60,7 @@ public abstract class Patch {
|
|||
* @return The highest Patch-Level that was found
|
||||
*/
|
||||
public static int maxPatchLevel(@NotNull String modID) {
|
||||
return ALL.stream()
|
||||
.filter(p -> p.modID
|
||||
.equals(modID))
|
||||
.mapToInt(p -> p.level)
|
||||
.max()
|
||||
.orElse(0);
|
||||
return ALL.stream().filter(p -> p.modID.equals(modID)).mapToInt(p -> p.level).max().orElse(0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -103,21 +92,18 @@ public abstract class Patch {
|
|||
*/
|
||||
Patch(@NotNull String modID, String version, boolean alwaysApply) {
|
||||
//Patchlevels need to be unique and registered in ascending order
|
||||
if (modID == null || "".equals(modID)) {
|
||||
if (modID == null || modID.isEmpty()) {
|
||||
throw new RuntimeException("[INTERNAL ERROR] Patches need a valid modID!");
|
||||
}
|
||||
|
||||
if (version == null || "".equals(version)) {
|
||||
if (version == null || version.isEmpty()) {
|
||||
throw new RuntimeException("Invalid Mod-Version");
|
||||
}
|
||||
|
||||
this.version = version;
|
||||
this.alwaysApply = alwaysApply;
|
||||
this.level = ModUtil.convertModVersion(version);
|
||||
if (!ALL.stream()
|
||||
.filter(p -> p.modID
|
||||
.equals(modID))
|
||||
.noneMatch(p -> p.level >= this.level) || this.level <= 0) {
|
||||
if (!ALL.stream().filter(p -> p.modID.equals(modID)).noneMatch(p -> p.level >= this.level) || this.level <= 0) {
|
||||
throw new RuntimeException("[INTERNAL ERROR] Patch-levels need to be created in ascending order beginning with 1.");
|
||||
}
|
||||
|
||||
|
@ -239,5 +225,4 @@ public abstract class Patch {
|
|||
public List<String> getWorldDataIDPaths() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
63
src/main/java/ru/bclib/mixin/common/DimensionTypeMixin.java
Normal file
63
src/main/java/ru/bclib/mixin/common/DimensionTypeMixin.java
Normal file
|
@ -0,0 +1,63 @@
|
|||
package ru.bclib.mixin.common;
|
||||
|
||||
import com.mojang.serialization.Lifecycle;
|
||||
import net.minecraft.core.MappedRegistry;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.dimension.DimensionType;
|
||||
import net.minecraft.world.level.dimension.LevelStem;
|
||||
import net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator;
|
||||
import net.minecraft.world.level.levelgen.NoiseGeneratorSettings;
|
||||
import net.minecraft.world.level.levelgen.synth.NormalNoise;
|
||||
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.CallbackInfoReturnable;
|
||||
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||
import ru.bclib.world.generator.BCLibEndBiomeSource;
|
||||
import ru.bclib.world.generator.BCLibNetherBiomeSource;
|
||||
|
||||
import java.util.OptionalInt;
|
||||
|
||||
@Mixin(DimensionType.class)
|
||||
public class DimensionTypeMixin {
|
||||
@Inject(
|
||||
method = "defaultDimensions(Lnet/minecraft/core/RegistryAccess;JZ)Lnet/minecraft/core/MappedRegistry;",
|
||||
locals = LocalCapture.CAPTURE_FAILHARD,
|
||||
at = @At("TAIL")
|
||||
)
|
||||
private static void bclib_updateDimensions(RegistryAccess registryAccess, long seed, boolean bl, CallbackInfoReturnable<MappedRegistry<LevelStem>> info, MappedRegistry<LevelStem> mappedRegistry, Registry<DimensionType> registry, Registry<Biome> biomeRegistry, Registry<NoiseGeneratorSettings> noiseSettingsRegistry, Registry<NormalNoise.NoiseParameters> noiseParamRegistry) {
|
||||
int id = mappedRegistry.getId(mappedRegistry.get(LevelStem.NETHER));
|
||||
mappedRegistry.registerOrOverride(
|
||||
OptionalInt.of(id),
|
||||
LevelStem.NETHER,
|
||||
new LevelStem(
|
||||
() -> registry.getOrThrow(DimensionType.NETHER_LOCATION),
|
||||
new NoiseBasedChunkGenerator(
|
||||
noiseParamRegistry,
|
||||
new BCLibNetherBiomeSource(biomeRegistry, seed),
|
||||
seed,
|
||||
() -> noiseSettingsRegistry.getOrThrow(NoiseGeneratorSettings.NETHER)
|
||||
)
|
||||
),
|
||||
Lifecycle.stable()
|
||||
);
|
||||
|
||||
id = mappedRegistry.getId(mappedRegistry.get(LevelStem.END));
|
||||
mappedRegistry.registerOrOverride(
|
||||
OptionalInt.of(id),
|
||||
LevelStem.END,
|
||||
new LevelStem(
|
||||
() -> registry.getOrThrow(DimensionType.END_LOCATION),
|
||||
new NoiseBasedChunkGenerator(
|
||||
noiseParamRegistry,
|
||||
new BCLibEndBiomeSource(biomeRegistry, seed),
|
||||
seed,
|
||||
() -> noiseSettingsRegistry.getOrThrow(NoiseGeneratorSettings.END)
|
||||
)
|
||||
),
|
||||
Lifecycle.stable()
|
||||
);
|
||||
}
|
||||
}
|
|
@ -25,6 +25,7 @@
|
|||
"ChunkGeneratorMixin",
|
||||
"WorldGenRegionMixin",
|
||||
"WorldGenRegionMixin",
|
||||
"DimensionTypeMixin",
|
||||
"RecipeManagerMixin",
|
||||
"RecipeManagerMixin",
|
||||
"BoneMealItemMixin",
|
||||
|
|
Loading…
Reference in a new issue