From c711f8cea68d8efc3765f57e9c86e96ad03e4c98 Mon Sep 17 00:00:00 2001 From: LOOHP Date: Sun, 9 Aug 2020 21:01:10 +0800 Subject: [PATCH] Use actaul dimension code from vanilla minecraft, use the right biome for each dimension, allow limbo.yml instead of plugin.yml for plugins --- pom.xml | 2 +- .../loohp/limbo/Plugins/PluginManager.java | 2 +- .../loohp/limbo/Server/ClientConnection.java | 4 +- .../Server/Packets/PacketPlayOutMapChunk.java | 31 ++++++++++++++-- .../loohp/limbo/World/DimensionRegistry.java | 37 ++++++++++++++----- src/server.properties | 8 ++-- 6 files changed, 63 insertions(+), 21 deletions(-) diff --git a/pom.xml b/pom.xml index 0411e5d..b64b739 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 Limbo Limbo - 0.2.3-ALPHA + 0.2.4-ALPHA src diff --git a/src/com/loohp/limbo/Plugins/PluginManager.java b/src/com/loohp/limbo/Plugins/PluginManager.java index 3882008..393bf06 100644 --- a/src/com/loohp/limbo/Plugins/PluginManager.java +++ b/src/com/loohp/limbo/Plugins/PluginManager.java @@ -40,7 +40,7 @@ public class PluginManager { break; } String name = entry.getName(); - if (name.endsWith("plugin.yml")) { + if (name.endsWith("plugin.yml") || name.endsWith("limbo.yml")) { found = true; FileConfiguration pluginYaml = new FileConfiguration(zip); diff --git a/src/com/loohp/limbo/Server/ClientConnection.java b/src/com/loohp/limbo/Server/ClientConnection.java index 0ee20cd..f4b3ad6 100644 --- a/src/com/loohp/limbo/Server/ClientConnection.java +++ b/src/com/loohp/limbo/Server/ClientConnection.java @@ -280,7 +280,7 @@ public class ClientConnection extends Thread { TimeUnit.MILLISECONDS.sleep(500); ServerProperties p = Limbo.getInstance().getServerProperties(); - PacketPlayOutLogin join = new PacketPlayOutLogin(player.getEntityId(), false, p.getDefaultGamemode(), Limbo.getInstance().getWorlds().stream().map(each -> new NamespacedKey(each.getName()).toString()).collect(Collectors.toList()).toArray(new String[Limbo.getInstance().getWorlds().size()]), DimensionRegistry.getCodec(), p.getWorldSpawn().getWorld(), 0, (byte) p.getMaxPlayers(), 8, p.isReducedDebugInfo(), true, false, false); + PacketPlayOutLogin join = new PacketPlayOutLogin(player.getEntityId(), false, p.getDefaultGamemode(), Limbo.getInstance().getWorlds().stream().map(each -> new NamespacedKey(each.getName()).toString()).collect(Collectors.toList()).toArray(new String[Limbo.getInstance().getWorlds().size()]), DimensionRegistry.getCodec(), p.getWorldSpawn().getWorld(), 0, (byte) p.getMaxPlayers(), 8, p.isReducedDebugInfo(), true, false, true); sendPacket(join); player.setGamemodeSilent(p.getDefaultGamemode()); @@ -294,7 +294,7 @@ public class ClientConnection extends Thread { for (int z = 0; z < world.getChunks()[x].length; z++) { Chunk chunk = world.getChunks()[x][z]; if (chunk != null) { - PacketPlayOutMapChunk chunkdata = new PacketPlayOutMapChunk(x, z, chunk); + PacketPlayOutMapChunk chunkdata = new PacketPlayOutMapChunk(x, z, chunk, world.getEnvironment()); sendPacket(chunkdata); //System.out.println(x + ", " + z); } diff --git a/src/com/loohp/limbo/Server/Packets/PacketPlayOutMapChunk.java b/src/com/loohp/limbo/Server/Packets/PacketPlayOutMapChunk.java index 949f2b2..f633d2c 100644 --- a/src/com/loohp/limbo/Server/Packets/PacketPlayOutMapChunk.java +++ b/src/com/loohp/limbo/Server/Packets/PacketPlayOutMapChunk.java @@ -8,6 +8,7 @@ import java.util.Iterator; import com.loohp.limbo.Utils.ChunkDataUtils; import com.loohp.limbo.Utils.DataTypeIO; import com.loohp.limbo.Utils.GeneratedDataUtils; +import com.loohp.limbo.World.World.Environment; import net.querz.mca.Chunk; import net.querz.mca.Section; @@ -19,11 +20,18 @@ public class PacketPlayOutMapChunk extends PacketOut { private int chunkX; private int chunkZ; private Chunk chunk; - - public PacketPlayOutMapChunk(int chunkX, int chunkZ, Chunk chunk) { + private Environment environment; + + public PacketPlayOutMapChunk(int chunkX, int chunkZ, Chunk chunk, Environment environment) { this.chunkX = chunkX; this.chunkZ = chunkZ; this.chunk = chunk; + this.environment = environment; + } + + @Deprecated + public PacketPlayOutMapChunk(int chunkX, int chunkZ, Chunk chunk) { + this(chunkZ, chunkZ, chunk, Environment.NORMAL); } public Chunk getChunk() { @@ -38,6 +46,10 @@ public class PacketPlayOutMapChunk extends PacketOut { return chunkZ; } + public Environment getEnvironment() { + return environment; + } + @Override public byte[] serializePacket() throws IOException { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); @@ -61,8 +73,21 @@ public class PacketPlayOutMapChunk extends PacketOut { //for (int i : chunk.getBiomes()) { // output.writeInt(i); //} + int biome; + switch (environment) { + case END: + biome = 9; //the_end + break; + case NETHER: + biome = 8; //nether_waste + break; + case NORMAL: + default: + biome = 1; //plains + break; + } for (int i = 0; i < 1024; i++) { - output.writeInt(127); + output.writeInt(biome); } ByteArrayOutputStream dataBuffer = new ByteArrayOutputStream(); diff --git a/src/com/loohp/limbo/World/DimensionRegistry.java b/src/com/loohp/limbo/World/DimensionRegistry.java index 1076082..60a75c5 100644 --- a/src/com/loohp/limbo/World/DimensionRegistry.java +++ b/src/com/loohp/limbo/World/DimensionRegistry.java @@ -15,7 +15,7 @@ public class DimensionRegistry { CompoundTag overworld = new CompoundTag(); overworld.putString("name", "minecraft:overworld"); overworld.putByte("natural", (byte) 1); - overworld.putFloat("ambient_light", 0.4F); + overworld.putFloat("ambient_light", 0.0F); overworld.putByte("has_ceiling", (byte) 0); overworld.putByte("has_skylight", (byte) 1); overworld.putLong("fixed_time", 0); @@ -26,15 +26,31 @@ public class DimensionRegistry { overworld.putByte("bed_works", (byte) 1); overworld.putByte("piglin_safe", (byte) 0); overworld.putInt("logical_height", 256); - overworld.putString("infiniburn", ""); + overworld.putString("infiniburn", "minecraft:infiniburn_overworld"); + + CompoundTag overworld_caves = new CompoundTag(); + overworld_caves.putString("name", "minecraft:overworld_caves"); + overworld_caves.putByte("natural", (byte) 1); + overworld_caves.putFloat("ambient_light", 0.0F); + overworld_caves.putByte("has_ceiling", (byte) 1); + overworld_caves.putByte("has_skylight", (byte) 1); + overworld_caves.putLong("fixed_time", 0); + overworld_caves.putByte("shrunk", (byte) 0); + overworld_caves.putByte("ultrawarm", (byte) 0); + overworld_caves.putByte("has_raids", (byte) 1); + overworld_caves.putByte("respawn_anchor_works", (byte) 0); + overworld_caves.putByte("bed_works", (byte) 1); + overworld_caves.putByte("piglin_safe", (byte) 0); + overworld_caves.putInt("logical_height", 256); + overworld_caves.putString("infiniburn", "minecraft:infiniburn_overworld"); CompoundTag nether = new CompoundTag(); nether.putString("name", "minecraft:the_nether"); nether.putByte("natural", (byte) 0); - nether.putFloat("ambient_light", 0.3F); + nether.putFloat("ambient_light", 0.1F); nether.putByte("has_ceiling", (byte) 1); nether.putByte("has_skylight", (byte) 0); - nether.putLong("fixed_time", 0); + nether.putLong("fixed_time", 18000); nether.putByte("shrunk", (byte) 1); nether.putByte("ultrawarm", (byte) 1); nether.putByte("has_raids", (byte) 0); @@ -42,26 +58,27 @@ public class DimensionRegistry { nether.putByte("bed_works", (byte) 0); nether.putByte("piglin_safe", (byte) 1); nether.putInt("logical_height", 128); - nether.putString("infiniburn", ""); + nether.putString("infiniburn", "minecraft:infiniburn_nether"); CompoundTag the_end = new CompoundTag(); the_end.putString("name", "minecraft:the_end"); the_end.putByte("natural", (byte) 0); - the_end.putFloat("ambient_light", 0.3F); + the_end.putFloat("ambient_light", 0.0F); the_end.putByte("has_ceiling", (byte) 0); the_end.putByte("has_skylight", (byte) 0); - the_end.putLong("fixed_time", 0); + the_end.putLong("fixed_time", 6000); the_end.putByte("shrunk", (byte) 0); the_end.putByte("ultrawarm", (byte) 0); - the_end.putByte("has_raids", (byte) 0); + the_end.putByte("has_raids", (byte) 1); the_end.putByte("respawn_anchor_works", (byte) 0); the_end.putByte("bed_works", (byte) 0); - the_end.putByte("piglin_safe", (byte) 1); + the_end.putByte("piglin_safe", (byte) 0); the_end.putInt("logical_height", 256); - the_end.putString("infiniburn", ""); + the_end.putString("infiniburn", "minecraft:infiniburn_end"); ListTag listtag = new ListTag(CompoundTag.class); listtag.add(overworld); + listtag.add(overworld_caves); listtag.add(nether); listtag.add(the_end); diff --git a/src/server.properties b/src/server.properties index 97b8c1c..bdd0132 100644 --- a/src/server.properties +++ b/src/server.properties @@ -5,16 +5,16 @@ max-players=-1 server-port=30000 #Server ip, localhost for local access only -server-ip=localhost +server-ip=0.0.0.0 #Whether this is server is behind a bungeecord proxy -bungeecord=true +bungeecord=false #World Name and the Schematic file containing map level-name=world;spawn.schem #Dimension, "minecraft:overworld", "minecraft:the_nether" or "minecraft:the_end" -level-dimension=minecraft:the_end +level-dimension=minecraft:overworld #Whether Flying is allowed allow-flight=false @@ -29,7 +29,7 @@ world-spawn=world;20.5;17;22.5;-90;0 reduced-debug-info=false #Server list message in Json -motd={"text":"","extra":[{"text":"H ","color":"#E8162E"},{"text":"M ","color":"#F9D52B"},{"text":"G ","color":"#28B31F"},{"text":"! ","color":"blue"},{"text":"!","color":"dark_purple"},{"text":"\n"},{"text":"Limbo Demo Server!","color":"yellow"}]} +motd={"text":"","extra":[{"text":"Limbo Server!","color":"yellow"}]} #Server list version as string version=Limbo! \ No newline at end of file