More conversions
This commit is contained in:
parent
6419e11414
commit
f4b143965f
12 changed files with 33 additions and 286 deletions
|
@ -8,7 +8,7 @@ import org.betterx.bclib.noise.OpenSimplexNoise;
|
||||||
import org.betterx.bclib.util.MHelper;
|
import org.betterx.bclib.util.MHelper;
|
||||||
|
|
||||||
import net.minecraft.world.level.ChunkPos;
|
import net.minecraft.world.level.ChunkPos;
|
||||||
import net.minecraft.world.level.levelgen.LegacyRandom;
|
import net.minecraft.world.level.levelgen.LegacyRandomSource;
|
||||||
import net.minecraft.world.level.levelgen.WorldgenRandom;
|
import net.minecraft.world.level.levelgen.WorldgenRandom;
|
||||||
|
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
|
@ -29,7 +29,7 @@ public class SquareBiomeMap implements BiomeMap {
|
||||||
private TriConsumer<Integer, Integer, Integer> processor;
|
private TriConsumer<Integer, Integer, Integer> processor;
|
||||||
|
|
||||||
public SquareBiomeMap(long seed, int size, BiomePicker picker) {
|
public SquareBiomeMap(long seed, int size, BiomePicker picker) {
|
||||||
random = new WorldgenRandom(new LegacyRandom(seed));
|
random = new WorldgenRandom(new LegacyRandomSource(seed));
|
||||||
noiseX = new OpenSimplexNoise(random.nextLong());
|
noiseX = new OpenSimplexNoise(random.nextLong());
|
||||||
noiseZ = new OpenSimplexNoise(random.nextLong());
|
noiseZ = new OpenSimplexNoise(random.nextLong());
|
||||||
this.sizeXZ = size;
|
this.sizeXZ = size;
|
||||||
|
|
|
@ -10,6 +10,7 @@ import org.betterx.bclib.api.v2.levelgen.biomes.InternalBiomeAPI;
|
||||||
import org.betterx.bclib.registry.PresetsRegistry;
|
import org.betterx.bclib.registry.PresetsRegistry;
|
||||||
import org.betterx.worlds.together.world.event.WorldEvents;
|
import org.betterx.worlds.together.world.event.WorldEvents;
|
||||||
import org.betterx.worlds.together.worldPreset.TogetherWorldPreset;
|
import org.betterx.worlds.together.worldPreset.TogetherWorldPreset;
|
||||||
|
import org.betterx.worlds.together.worldPreset.WorldPreset;
|
||||||
|
|
||||||
import net.minecraft.core.Holder;
|
import net.minecraft.core.Holder;
|
||||||
import net.minecraft.core.RegistryAccess;
|
import net.minecraft.core.RegistryAccess;
|
||||||
|
@ -17,7 +18,6 @@ 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.WorldGenSettings;
|
import net.minecraft.world.level.levelgen.WorldGenSettings;
|
||||||
import net.minecraft.world.level.levelgen.presets.WorldPreset;
|
|
||||||
import net.minecraft.world.level.storage.LevelStorageSource;
|
import net.minecraft.world.level.storage.LevelStorageSource;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
|
@ -11,6 +11,7 @@ import org.betterx.worlds.together.levelgen.WorldGenUtil;
|
||||||
import org.betterx.worlds.together.util.ModUtil;
|
import org.betterx.worlds.together.util.ModUtil;
|
||||||
import org.betterx.worlds.together.world.WorldConfig;
|
import org.betterx.worlds.together.world.WorldConfig;
|
||||||
import org.betterx.worlds.together.worldPreset.TogetherWorldPreset;
|
import org.betterx.worlds.together.worldPreset.TogetherWorldPreset;
|
||||||
|
import org.betterx.worlds.together.worldPreset.WorldPreset;
|
||||||
|
|
||||||
import com.mojang.serialization.Lifecycle;
|
import com.mojang.serialization.Lifecycle;
|
||||||
import net.minecraft.core.Holder;
|
import net.minecraft.core.Holder;
|
||||||
|
|
|
@ -14,7 +14,10 @@ import net.minecraft.world.level.levelgen.blockpredicates.BlockPredicate;
|
||||||
import net.minecraft.world.level.levelgen.feature.configurations.FeatureConfiguration;
|
import net.minecraft.world.level.levelgen.feature.configurations.FeatureConfiguration;
|
||||||
import net.minecraft.world.level.levelgen.feature.stateproviders.BlockStateProvider;
|
import net.minecraft.world.level.levelgen.feature.stateproviders.BlockStateProvider;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class PillarFeatureConfig implements FeatureConfiguration {
|
public class PillarFeatureConfig implements FeatureConfiguration {
|
||||||
@FunctionalInterface
|
@FunctionalInterface
|
||||||
|
@ -65,9 +68,13 @@ public class PillarFeatureConfig implements FeatureConfiguration {
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
public static final StringRepresentable.EnumCodec<KnownTransformers> CODEC = StringRepresentable
|
public static final Codec<KnownTransformers> CODEC = StringRepresentable
|
||||||
.fromEnum(KnownTransformers::values);
|
.fromEnum(KnownTransformers::values, KnownTransformers::byName);
|
||||||
|
private static final Map<String, KnownTransformers> BY_NAME = Arrays.stream(KnownTransformers.values())
|
||||||
|
.collect(Collectors.toMap(
|
||||||
|
KnownTransformers::name,
|
||||||
|
a -> a
|
||||||
|
));
|
||||||
|
|
||||||
public final String name;
|
public final String name;
|
||||||
public final StateTransform stateTransform;
|
public final StateTransform stateTransform;
|
||||||
|
@ -92,6 +99,10 @@ public class PillarFeatureConfig implements FeatureConfiguration {
|
||||||
public String getSerializedName() {
|
public String getSerializedName() {
|
||||||
return this.name;
|
return this.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static KnownTransformers byName(String string) {
|
||||||
|
return BY_NAME.get(string);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final Codec<PillarFeatureConfig> CODEC = RecordCodecBuilder.create(instance -> instance
|
public static final Codec<PillarFeatureConfig> CODEC = RecordCodecBuilder.create(instance -> instance
|
||||||
|
|
|
@ -18,10 +18,8 @@ import net.minecraft.network.chat.CommonComponents;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
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.BuiltinDimensionTypes;
|
|
||||||
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.presets.WorldPresets;
|
|
||||||
|
|
||||||
import net.fabricmc.api.EnvType;
|
import net.fabricmc.api.EnvType;
|
||||||
import net.fabricmc.api.Environment;
|
import net.fabricmc.api.Environment;
|
||||||
|
|
|
@ -7,7 +7,6 @@ import com.mojang.brigadier.Command;
|
||||||
import com.mojang.brigadier.CommandDispatcher;
|
import com.mojang.brigadier.CommandDispatcher;
|
||||||
import com.mojang.brigadier.context.CommandContext;
|
import com.mojang.brigadier.context.CommandContext;
|
||||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||||
import net.minecraft.commands.CommandBuildContext;
|
|
||||||
import net.minecraft.commands.CommandSourceStack;
|
import net.minecraft.commands.CommandSourceStack;
|
||||||
import net.minecraft.commands.Commands;
|
import net.minecraft.commands.Commands;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
|
@ -29,12 +28,12 @@ import java.util.Map;
|
||||||
|
|
||||||
public class CommandRegistry {
|
public class CommandRegistry {
|
||||||
public static void register() {
|
public static void register() {
|
||||||
CommandRegistrationCallback.EVENT.register(CommandRegistry::register);
|
CommandRegistrationCallback.EVENT.register((a, b, c) -> register(a, c));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static void register(
|
private static void register(
|
||||||
CommandDispatcher<CommandSourceStack> dispatcher,
|
CommandDispatcher<CommandSourceStack> dispatcher,
|
||||||
CommandBuildContext commandBuildContext,
|
|
||||||
Commands.CommandSelection commandSelection
|
Commands.CommandSelection commandSelection
|
||||||
) {
|
) {
|
||||||
dispatcher.register(
|
dispatcher.register(
|
||||||
|
@ -44,10 +43,6 @@ public class CommandRegistry {
|
||||||
.requires(source -> source.hasPermission(Commands.LEVEL_OWNERS))
|
.requires(source -> source.hasPermission(Commands.LEVEL_OWNERS))
|
||||||
.executes(ctx -> requestGC(ctx))
|
.executes(ctx -> requestGC(ctx))
|
||||||
)
|
)
|
||||||
.then(Commands.literal("dump_datapack")
|
|
||||||
.requires(source -> source.hasPermission(Commands.LEVEL_OWNERS))
|
|
||||||
.executes(ctx -> DumpDatapack.dumpDatapack(ctx))
|
|
||||||
)
|
|
||||||
.then(Commands.literal("debug_ore")
|
.then(Commands.literal("debug_ore")
|
||||||
.requires(source -> source.hasPermission(Commands.LEVEL_OWNERS))
|
.requires(source -> source.hasPermission(Commands.LEVEL_OWNERS))
|
||||||
.executes(ctx -> revealOre(ctx))
|
.executes(ctx -> revealOre(ctx))
|
||||||
|
|
|
@ -1,259 +0,0 @@
|
||||||
package org.betterx.bclib.commands;
|
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
import com.google.gson.GsonBuilder;
|
|
||||||
import com.google.gson.JsonElement;
|
|
||||||
import com.google.gson.JsonObject;
|
|
||||||
import com.mojang.brigadier.Command;
|
|
||||||
import com.mojang.brigadier.context.CommandContext;
|
|
||||||
import com.mojang.serialization.Codec;
|
|
||||||
import com.mojang.serialization.JsonOps;
|
|
||||||
import com.mojang.serialization.codecs.KeyDispatchCodec;
|
|
||||||
import net.minecraft.commands.CommandSourceStack;
|
|
||||||
import net.minecraft.core.Holder;
|
|
||||||
import net.minecraft.core.RegistryAccess;
|
|
||||||
import net.minecraft.resources.RegistryOps;
|
|
||||||
import net.minecraft.tags.TagEntry;
|
|
||||||
import net.minecraft.tags.TagFile;
|
|
||||||
import net.minecraft.util.KeyDispatchDataCodec;
|
|
||||||
import net.minecraft.world.effect.MobEffect;
|
|
||||||
import net.minecraft.world.level.biome.BiomeSource;
|
|
||||||
import net.minecraft.world.level.dimension.LevelStem;
|
|
||||||
import net.minecraft.world.level.gameevent.GameEvent;
|
|
||||||
import net.minecraft.world.level.levelgen.WorldGenSettings;
|
|
||||||
import net.minecraft.world.level.levelgen.structure.Structure;
|
|
||||||
import net.minecraft.world.level.levelgen.structure.templatesystem.PosRuleTestType;
|
|
||||||
import net.minecraft.world.level.levelgen.structure.templatesystem.RuleTestType;
|
|
||||||
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureProcessorList;
|
|
||||||
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureProcessorType;
|
|
||||||
import net.minecraft.world.level.material.Fluid;
|
|
||||||
import org.betterx.bclib.BCLib;
|
|
||||||
import org.betterx.bclib.blocks.BaseStairsBlock;
|
|
||||||
|
|
||||||
import java.awt.Taskbar.Feature;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.lang.reflect.Modifier;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.nio.file.Files;
|
|
||||||
|
|
||||||
public class DumpDatapack {
|
|
||||||
static int dumpDatapack(CommandContext<CommandSourceStack> ctx) {
|
|
||||||
dumpDatapack(ctx.getSource().getLevel().registryAccess());
|
|
||||||
return Command.SINGLE_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void dumpDatapack(RegistryAccess registryAccess) {
|
|
||||||
final RegistryOps<JsonElement> registryOps = RegistryOps.create(JsonOps.INSTANCE, registryAccess);
|
|
||||||
GsonBuilder gsonBuilder = new GsonBuilder();
|
|
||||||
gsonBuilder = gsonBuilder.setPrettyPrinting();
|
|
||||||
Gson gson = gsonBuilder.create();
|
|
||||||
registryAccess.registries().forEach(r -> dumpDatapack(r, registryOps, gson));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static <T> void dumpDatapack(
|
|
||||||
RegistryAccess.RegistryEntry<T> registry,
|
|
||||||
RegistryOps<JsonElement> registryOps,
|
|
||||||
Gson gson
|
|
||||||
) {
|
|
||||||
File base = new File(System.getProperty("user.dir"), "bclib_datapack_dump");
|
|
||||||
BCLib.LOGGER.info(registry.key().toString());
|
|
||||||
// Tag Output
|
|
||||||
registry.value()
|
|
||||||
.getTagNames()
|
|
||||||
.map(tagKey -> registry.value().getTag(tagKey))
|
|
||||||
.filter(tag -> tag.isPresent())
|
|
||||||
.map(tag -> tag.get())
|
|
||||||
.forEach(tag -> {
|
|
||||||
File f1 = new File(base, tag.key().location().getNamespace());
|
|
||||||
f1 = new File(f1, "tags");
|
|
||||||
f1 = new File(f1, registry.key().location().getPath());
|
|
||||||
f1.mkdirs();
|
|
||||||
f1 = new File(f1, tag.key().location().getPath() + ".json");
|
|
||||||
|
|
||||||
TagFile tf = new TagFile(
|
|
||||||
tag.stream()
|
|
||||||
.map(holder -> holder.unwrapKey())
|
|
||||||
.filter(k -> k.isPresent())
|
|
||||||
.map(k -> TagEntry.element(k.get().location()))
|
|
||||||
.toList(),
|
|
||||||
true
|
|
||||||
);
|
|
||||||
var o = TagFile.CODEC
|
|
||||||
.encodeStart(registryOps, tf)
|
|
||||||
.result()
|
|
||||||
.orElse(new JsonObject());
|
|
||||||
String content = gson.toJson(o);
|
|
||||||
try {
|
|
||||||
Files.writeString(f1.toPath(), content, StandardCharsets.UTF_8);
|
|
||||||
} catch (IOException e) {
|
|
||||||
BCLib.LOGGER.error(" ->> Unable to WRITE: " + e.getMessage());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
registry
|
|
||||||
.value()
|
|
||||||
.entrySet()
|
|
||||||
.stream()
|
|
||||||
.map(e -> e.getKey()).map(key -> registry.value().getHolder(key).get())
|
|
||||||
.forEach(holder -> {
|
|
||||||
File f1 = new File(base, holder.unwrapKey().get().location().getNamespace());
|
|
||||||
f1 = new File(f1, registry.key().location().getPath());
|
|
||||||
f1.mkdirs();
|
|
||||||
f1 = new File(f1, holder.unwrapKey().get().location().getPath() + ".json");
|
|
||||||
f1.getParentFile().mkdirs();
|
|
||||||
|
|
||||||
Codec[] codec = {null};
|
|
||||||
|
|
||||||
BCLib.LOGGER.info(" - " + f1);
|
|
||||||
Object obj = holder;
|
|
||||||
|
|
||||||
while (obj instanceof Holder<?>) {
|
|
||||||
obj = ((Holder<?>) obj).value();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (obj instanceof BiomeSource || obj instanceof Feature) {
|
|
||||||
System.out.print("");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (obj instanceof Structure s) {
|
|
||||||
codec[0] = s.type().codec();
|
|
||||||
} else if (obj instanceof StructureProcessorList s) {
|
|
||||||
codec[0] = StructureProcessorType.LIST_OBJECT_CODEC;
|
|
||||||
} else if (obj instanceof GameEvent) {
|
|
||||||
return;
|
|
||||||
} else if (obj instanceof Fluid) {
|
|
||||||
return;
|
|
||||||
} else if (obj instanceof MobEffect) {
|
|
||||||
return;
|
|
||||||
} else if (obj instanceof BaseStairsBlock) {
|
|
||||||
return;
|
|
||||||
} else if (obj instanceof RuleTestType<?>) {
|
|
||||||
codec[0] = registry.value().byNameCodec();
|
|
||||||
} else if (obj instanceof PosRuleTestType<?>) {
|
|
||||||
codec[0] = registry.value().byNameCodec();
|
|
||||||
}else if (obj instanceof WorldGenSettings) {
|
|
||||||
codec[0] = registry.value().byNameCodec();
|
|
||||||
}else if (obj instanceof LevelStem) {
|
|
||||||
codec[0] = registry.value().byNameCodec();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (codec[0] == null) {
|
|
||||||
for (Method m : obj.getClass().getMethods()) {
|
|
||||||
if (!Modifier.isStatic(m.getModifiers())) {
|
|
||||||
m.setAccessible(true);
|
|
||||||
if (m.getParameterTypes().length == 0) {
|
|
||||||
if (Codec.class.isAssignableFrom(m.getReturnType())) {
|
|
||||||
try {
|
|
||||||
codec[0] = (Codec) m.invoke(obj);
|
|
||||||
BCLib.LOGGER.info(" Got Codec from " + m);
|
|
||||||
break;
|
|
||||||
} catch (Exception e) {
|
|
||||||
BCLib.LOGGER.error(" !!! Unable to get Codec from " + m);
|
|
||||||
}
|
|
||||||
} else if (KeyDispatchCodec.class.isAssignableFrom(m.getReturnType())) {
|
|
||||||
try {
|
|
||||||
codec[0] = ((KeyDispatchCodec) m.invoke(obj)).codec();
|
|
||||||
BCLib.LOGGER.info(" Got Codec from " + m);
|
|
||||||
break;
|
|
||||||
} catch (Exception e) {
|
|
||||||
BCLib.LOGGER.error(" !!! Unable to get Codec from " + m);
|
|
||||||
}
|
|
||||||
} else if (KeyDispatchDataCodec.class.isAssignableFrom(m.getReturnType())) {
|
|
||||||
try {
|
|
||||||
codec[0] = ((KeyDispatchDataCodec) m.invoke(obj)).codec();
|
|
||||||
BCLib.LOGGER.info(" Got Codec from " + m);
|
|
||||||
break;
|
|
||||||
} catch (Exception e) {
|
|
||||||
BCLib.LOGGER.error(" !!! Unable to get Codec from " + m);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (codec[0] == null) {
|
|
||||||
//Try to find DIRECT_CODEC field
|
|
||||||
for (Field f : obj.getClass().getFields()) {
|
|
||||||
if (Modifier.isStatic(f.getModifiers())) {
|
|
||||||
if ("DIRECT_CODEC".equals(f.getName())) {
|
|
||||||
f.setAccessible(true);
|
|
||||||
try {
|
|
||||||
codec[0] = (Codec) f.get(null);
|
|
||||||
BCLib.LOGGER.info(" Got Codec from " + f);
|
|
||||||
} catch (Exception e) {
|
|
||||||
BCLib.LOGGER.error(" !!! Unable to get Codec from " + f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Try to find CODEC field
|
|
||||||
if (codec[0] == null) {
|
|
||||||
for (Field f : obj.getClass().getFields()) {
|
|
||||||
if (Modifier.isStatic(f.getModifiers())) {
|
|
||||||
if ("CODEC".equals(f.getName())) {
|
|
||||||
try {
|
|
||||||
f.setAccessible(true);
|
|
||||||
codec[0] = (Codec) f.get(null);
|
|
||||||
BCLib.LOGGER.info(" Got Codec from " + f);
|
|
||||||
} catch (Exception e) {
|
|
||||||
BCLib.LOGGER.error(" !!! Unable to get Codec from " + f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Try to find any Codec field
|
|
||||||
if (codec[0] == null) {
|
|
||||||
for (Field f : obj.getClass().getFields()) {
|
|
||||||
if (Modifier.isStatic(f.getModifiers())) {
|
|
||||||
if (Codec.class.isAssignableFrom(f.getType())) {
|
|
||||||
f.setAccessible(true);
|
|
||||||
try {
|
|
||||||
codec[0] = (Codec) f.get(null);
|
|
||||||
BCLib.LOGGER.info(" Got Codec from " + f);
|
|
||||||
} catch (Exception e) {
|
|
||||||
BCLib.LOGGER.error(" !!! Unable to get Codec from " + f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (codec[0]==null){
|
|
||||||
codec[0] = registry.value().byNameCodec();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (codec[0] == null) {
|
|
||||||
codec[0] = registry.value().byNameCodec();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (codec[0] != null) {
|
|
||||||
try {
|
|
||||||
var o = codec[0]
|
|
||||||
.encodeStart(registryOps, obj)
|
|
||||||
.result()
|
|
||||||
.orElse(new JsonObject());
|
|
||||||
|
|
||||||
String content = gson.toJson(o);
|
|
||||||
try {
|
|
||||||
Files.writeString(f1.toPath(), content, StandardCharsets.UTF_8);
|
|
||||||
} catch (IOException e) {
|
|
||||||
BCLib.LOGGER.error(" ->> Unable to WRITE: " + e.getMessage());
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
BCLib.LOGGER.error(" ->> Unable to encode: " + e.getMessage());
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
BCLib.LOGGER.error(" !!! Could not determine Codec: " + obj.getClass());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -6,11 +6,11 @@ import org.betterx.bclib.api.v2.generator.config.BCLNetherBiomeSourceConfig;
|
||||||
import org.betterx.bclib.api.v2.levelgen.LevelGenUtil;
|
import org.betterx.bclib.api.v2.levelgen.LevelGenUtil;
|
||||||
import org.betterx.worlds.together.levelgen.WorldGenUtil;
|
import org.betterx.worlds.together.levelgen.WorldGenUtil;
|
||||||
import org.betterx.worlds.together.worldPreset.TogetherWorldPreset;
|
import org.betterx.worlds.together.worldPreset.TogetherWorldPreset;
|
||||||
|
import org.betterx.worlds.together.worldPreset.WorldPreset;
|
||||||
import org.betterx.worlds.together.worldPreset.WorldPresets;
|
import org.betterx.worlds.together.worldPreset.WorldPresets;
|
||||||
|
|
||||||
import net.minecraft.resources.ResourceKey;
|
import net.minecraft.resources.ResourceKey;
|
||||||
import net.minecraft.world.level.dimension.LevelStem;
|
import net.minecraft.world.level.dimension.LevelStem;
|
||||||
import net.minecraft.world.level.levelgen.presets.WorldPreset;
|
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,8 @@ package org.betterx.bclib.util;
|
||||||
|
|
||||||
import com.mojang.math.Vector3f;
|
import com.mojang.math.Vector3f;
|
||||||
import net.minecraft.core.Vec3i;
|
import net.minecraft.core.Vec3i;
|
||||||
import net.minecraft.world.level.levelgen.LegacyRandom;
|
import net.minecraft.world.level.levelgen.LegacyRandomSource;
|
||||||
|
import net.minecraft.world.level.levelgen.RandomSource;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
|
@ -12,7 +13,7 @@ public class MHelper {
|
||||||
public static final float PHI = (float) (Math.PI * (3 - Math.sqrt(5)));
|
public static final float PHI = (float) (Math.PI * (3 - Math.sqrt(5)));
|
||||||
public static final float PI2 = (float) (Math.PI * 2);
|
public static final float PI2 = (float) (Math.PI * 2);
|
||||||
public static final Random RANDOM = new Random();
|
public static final Random RANDOM = new Random();
|
||||||
public static final Random RANDOM_SOURCE = new LegacyRandom(RANDOM.nextLong());
|
public static final RandomSource RANDOM_SOURCE = new LegacyRandomSource(RANDOM.nextLong());
|
||||||
|
|
||||||
public static int randRange(int min, int max, Random random) {
|
public static int randRange(int min, int max, Random random) {
|
||||||
return min + random.nextInt(max - min + 1);
|
return min + random.nextInt(max - min + 1);
|
||||||
|
|
|
@ -16,7 +16,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
@Mixin(DedicatedServerProperties.WorldGenProperties.class)
|
@Mixin(DedicatedServerProperties.WorldGenProperties.class)
|
||||||
public class WorldGenPropertiesMixin {
|
public class WorldGenPropertiesMixin {
|
||||||
@Inject(method = "<init>", at = @At(value = "TAIL"))
|
@Inject(method = "<init>", at = @At(value = "TAIL"))
|
||||||
private static void bcl_create(String string, JsonObject jsonObject, boolean bl, String string2, CallbackInfo ci) {
|
private static void bcl_create(String seed, JsonObject jsonObject, boolean bl, String string2, CallbackInfo ci) {
|
||||||
return seed;
|
return seed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,8 +35,10 @@ public class CommonBlockTags {
|
||||||
public static final TagKey<Block> TERRAIN = TagManager.BLOCKS.makeCommonTag("terrain");
|
public static final TagKey<Block> TERRAIN = TagManager.BLOCKS.makeCommonTag("terrain");
|
||||||
public static final TagKey<Block> NETHER_TERRAIN = TagManager.BLOCKS.makeCommonTag("nether_terrain");
|
public static final TagKey<Block> NETHER_TERRAIN = TagManager.BLOCKS.makeCommonTag("nether_terrain");
|
||||||
|
|
||||||
|
public static final TagKey<Block> NETHER_CARVER_REPLACEABLES = TagManager.BLOCKS.makeCommonTag(
|
||||||
|
"nether_carver_replaceables");
|
||||||
|
|
||||||
static void prepareTags() {
|
static void prepareTags() {
|
||||||
TagManager.BLOCKS.add(SCULK_LIKE, Blocks.SCULK);
|
|
||||||
TagManager.BLOCKS.addOtherTags(DRAGON_IMMUNE, BlockTags.DRAGON_IMMUNE);
|
TagManager.BLOCKS.addOtherTags(DRAGON_IMMUNE, BlockTags.DRAGON_IMMUNE);
|
||||||
|
|
||||||
TagManager.BLOCKS.add(END_STONES, Blocks.END_STONE);
|
TagManager.BLOCKS.add(END_STONES, Blocks.END_STONE);
|
||||||
|
@ -67,8 +69,7 @@ public class CommonBlockTags {
|
||||||
Blocks.SAND,
|
Blocks.SAND,
|
||||||
Blocks.RED_SAND,
|
Blocks.RED_SAND,
|
||||||
Blocks.GLOWSTONE,
|
Blocks.GLOWSTONE,
|
||||||
Blocks.BONE_BLOCK,
|
Blocks.BONE_BLOCK
|
||||||
Blocks.SCULK
|
|
||||||
);
|
);
|
||||||
TagManager.BLOCKS.addOtherTags(
|
TagManager.BLOCKS.addOtherTags(
|
||||||
TERRAIN,
|
TERRAIN,
|
||||||
|
@ -102,14 +103,13 @@ public class CommonBlockTags {
|
||||||
TagManager.BLOCKS.add(CommonBlockTags.CHEST, Blocks.CHEST);
|
TagManager.BLOCKS.add(CommonBlockTags.CHEST, Blocks.CHEST);
|
||||||
|
|
||||||
TagManager.BLOCKS.add(
|
TagManager.BLOCKS.add(
|
||||||
BlockTags.NETHER_CARVER_REPLACEABLES,
|
NETHER_CARVER_REPLACEABLES,
|
||||||
Blocks.BASALT,
|
Blocks.BASALT,
|
||||||
Blocks.RED_SAND,
|
Blocks.RED_SAND,
|
||||||
Blocks.MAGMA_BLOCK,
|
Blocks.MAGMA_BLOCK
|
||||||
Blocks.SCULK
|
|
||||||
);
|
);
|
||||||
TagManager.BLOCKS.addOtherTags(
|
TagManager.BLOCKS.addOtherTags(
|
||||||
BlockTags.NETHER_CARVER_REPLACEABLES,
|
NETHER_CARVER_REPLACEABLES,
|
||||||
CommonBlockTags.NETHER_STONES,
|
CommonBlockTags.NETHER_STONES,
|
||||||
CommonBlockTags.NETHERRACK
|
CommonBlockTags.NETHERRACK
|
||||||
);
|
);
|
||||||
|
|
|
@ -122,7 +122,7 @@ public class TogetherWorldPreset extends org.betterx.worlds.together.worldPreset
|
||||||
|
|
||||||
public static Registry<LevelStem> getDimensions(ResourceKey<WorldPreset> key) {
|
public static Registry<LevelStem> getDimensions(ResourceKey<WorldPreset> key) {
|
||||||
RegistryAccess access = WorldBootstrap.getLastRegistryAccessOrElseBuiltin();
|
RegistryAccess access = WorldBootstrap.getLastRegistryAccessOrElseBuiltin();
|
||||||
var preset = access.registryOrThrow(Registry.WORLD_PRESET_REGISTRY).getHolder(key);
|
var preset = access.registryOrThrow(WorldPresets.WORLD_PRESET_REGISTRY).getHolder(key);
|
||||||
if (preset.isEmpty()) return null;
|
if (preset.isEmpty()) return null;
|
||||||
return preset
|
return preset
|
||||||
.get()
|
.get()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue