From c083abae281b25235d941cc9160feb4038eb4e70 Mon Sep 17 00:00:00 2001 From: Nan1t Date: Sun, 27 Dec 2020 20:08:08 +0200 Subject: [PATCH] Fixed compatibility with OptiFine --- .../ru/nanit/limbo/server/LimboServer.java | 2 +- .../nanit/limbo/world/DimensionRegistry.java | 131 ++---------------- src/main/resources/dimension_registry.nbt | Bin 0 -> 2840 bytes 3 files changed, 14 insertions(+), 119 deletions(-) create mode 100644 src/main/resources/dimension_registry.nbt diff --git a/src/main/java/ru/nanit/limbo/server/LimboServer.java b/src/main/java/ru/nanit/limbo/server/LimboServer.java index 2c0cdb4..5f87f0a 100644 --- a/src/main/java/ru/nanit/limbo/server/LimboServer.java +++ b/src/main/java/ru/nanit/limbo/server/LimboServer.java @@ -63,7 +63,7 @@ public final class LimboServer { Logger.setLevel(config.getDebugLevel()); dimensionRegistry = new DimensionRegistry(); - dimensionRegistry.load(config.getDimensionType()); + dimensionRegistry.load(this, config.getDimensionType()); connections = new Connections(); ClientConnection.preInitPackets(this); diff --git a/src/main/java/ru/nanit/limbo/world/DimensionRegistry.java b/src/main/java/ru/nanit/limbo/world/DimensionRegistry.java index 3ddefc8..d021207 100644 --- a/src/main/java/ru/nanit/limbo/world/DimensionRegistry.java +++ b/src/main/java/ru/nanit/limbo/world/DimensionRegistry.java @@ -1,9 +1,14 @@ package ru.nanit.limbo.world; +import net.kyori.adventure.nbt.BinaryTagIO; import net.kyori.adventure.nbt.CompoundBinaryTag; import net.kyori.adventure.nbt.ListBinaryTag; +import ru.nanit.limbo.server.LimboServer; import ru.nanit.limbo.util.Logger; +import java.io.IOException; +import java.io.InputStream; + public final class DimensionRegistry { private CompoundBinaryTag defaultDimension; @@ -33,8 +38,14 @@ public final class DimensionRegistry { return nether; } - public void load(String def){ - initDimensions(); + public void load(LimboServer server, String def) throws IOException { + InputStream in = server.getClass().getResourceAsStream("/dimension_registry.nbt"); + codec = BinaryTagIO.readCompressedInputStream(in); + ListBinaryTag dimensions = codec.getCompound("minecraft:dimension_type").getList("value"); + + overWorld = (CompoundBinaryTag) ((CompoundBinaryTag) dimensions.get(0)).get("element"); + nether = (CompoundBinaryTag) ((CompoundBinaryTag) dimensions.get(2)).get("element"); + theEnd = (CompoundBinaryTag) ((CompoundBinaryTag) dimensions.get(3)).get("element"); switch (def.toLowerCase()){ case "overworld": @@ -52,120 +63,4 @@ public final class DimensionRegistry { break; } } - - private void initDimensions(){ - overWorld = CompoundBinaryTag.builder() - .putString("name", "minecraft:overworld") - .putByte("piglin_safe", (byte) 0) - .putByte("natural", (byte) 1) - .putFloat("ambient_light", 0.0F) - .putString("infiniburn", "minecraft:infiniburn_overworld") - .putByte("respawn_anchor_works", (byte) 0) - .putByte("has_skylight", (byte) 1) - .putByte("bed_works", (byte) 1) - .putString("effects", "minecraft:overworld") - .putLong("fixed_time", 6000L) - .putByte("has_raids", (byte) 1) - .putInt("logical_height", 256) - .putDouble("coordinate_scale", 1.0) - .putByte("ultrawarm", (byte) 0) - .putByte("has_ceiling", (byte) 0) - .build(); - - nether = CompoundBinaryTag.builder() - .putString("name", "minecraft:the_nether") - .putByte("piglin_safe", (byte) 1) - .putByte("natural", (byte) 0) - .putFloat("ambient_light", 0.1F) - .putString("infiniburn", "minecraft:infiniburn_nether") - .putByte("respawn_anchor_works", (byte) 1) - .putByte("has_skylight", (byte) 0) - .putByte("bed_works", (byte) 0) - .putString("effects", "minecraft:the_nether") - .putLong("fixed_time", 18000L) - .putByte("has_raids", (byte) 0) - .putInt("logical_height", 128) - .putDouble("coordinate_scale", 1.0) - .putByte("ultrawarm", (byte) 1) - .putByte("has_ceiling", (byte) 1) - .build(); - - theEnd = CompoundBinaryTag.builder() - .putString("name", "minecraft:the_end") - .putByte("piglin_safe", (byte) 0) - .putByte("natural", (byte) 0) - .putFloat("ambient_light", 0.0F) - .putString("infiniburn", "minecraft:infiniburn_end") - .putByte("respawn_anchor_works", (byte) 0) - .putByte("has_skylight", (byte) 0) - .putByte("bed_works", (byte) 0) - .putString("effects", "minecraft:the_end") - .putLong("fixed_time", 6000L) - .putByte("has_raids", (byte) 1) - .putInt("logical_height", 256) - .putDouble("coordinate_scale", 1.0) - .putByte("ultrawarm", (byte) 0) - .putByte("has_ceiling", (byte) 0) - .build(); - - CompoundBinaryTag overWorldData = CompoundBinaryTag.builder() - .putString("name", "minecraft:overworld") - .putInt("id", 0) - .put("element", overWorld) - .build(); - - CompoundBinaryTag netherData = CompoundBinaryTag.builder() - .putString("name", "minecraft:the_nether") - .putInt("id", 1) - .put("element", nether) - .build(); - - CompoundBinaryTag endData = CompoundBinaryTag.builder() - .putString("name", "minecraft:the_end") - .putInt("id", 2) - .put("element", theEnd) - .build(); - - CompoundBinaryTag plains = CompoundBinaryTag.builder() - .putString("name", "minecraft:plains") - .putInt("id", 1) - .put("element", CompoundBinaryTag.builder() - .putString("precipitation", "rain") - .putFloat("depth", 0.125F) - .putFloat("temperature", 0.8F) - .putFloat("scale", 0.05F) - .putFloat("downfall", 0.4F) - .putString("category", "plains") - .put("effects", CompoundBinaryTag.builder() - .putInt("sky_color", 7907327) - .putInt("water_fog_color", 329011) - .putInt("fog_color", 12638463) - .putInt("water_color", 4159204) - .put("mood_sound", CompoundBinaryTag.builder() - .putInt("tick_delay", 6000) - .putFloat("offset", 2.0F) - .putString("sound", "minecraft:ambient.cave") - .putInt("block_search_extent", 8) - .build()) - .build()) - .build()) - .build(); - - codec = CompoundBinaryTag.builder() - .put("minecraft:dimension_type", CompoundBinaryTag.builder() - .putString("type", "minecraft:dimension_type") - .put("value", ListBinaryTag.builder() - .add(overWorldData) - .add(netherData) - .add(endData) - .build()) - .build()) - .put("minecraft:worldgen/biome", CompoundBinaryTag.builder() - .putString("type", "minecraft:worldgen/biome") - .put("value", ListBinaryTag.builder() - .add(plains) - .build()) - .build()) - .build(); - } } diff --git a/src/main/resources/dimension_registry.nbt b/src/main/resources/dimension_registry.nbt new file mode 100644 index 0000000000000000000000000000000000000000..c38a8569792a187baf26071ab8df3a0a0d536a2e GIT binary patch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