mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-23 08:59:23 +00:00
* Add faster random generator for Entity random * Option for replace worldgen random with L64X128MixRandomSource & Cleanup * Allocate 1 thread for AsyncLocator by default * Rename to worldgen * Add config option for backed random generator * Add SplittableGenerator check * Cache random generator * Revert cache Caching RNGs will cause some issues during worldgen * Set to final & cleanup * LevelChunkMixin * Filter null values * Use Xoroshiro128PlusPlus by default * Benchmark results * Revert changes * Better smooth teleport api * Set seed to 0
98 lines
4.9 KiB
Diff
98 lines
4.9 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: violetc <58360096+s-yh-china@users.noreply.github.com>
|
|
Date: Fri, 27 Jan 2023 09:42:57 +0800
|
|
Subject: [PATCH] Leaves: Xaero Map Protocol
|
|
|
|
Original license: GPLv3
|
|
Original project: https://github.com/LeavesMC/Leaves
|
|
|
|
This patch is Powered by Xaero Map
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
|
|
index bbd64da6ffa78c7e2376f38456681aaf1823528a..135a53742607dfccff17aa86f80f106b4a31f6b0 100644
|
|
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
|
|
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
|
|
@@ -1338,6 +1338,7 @@ public abstract class PlayerList {
|
|
player.connection.send(new ClientboundInitializeBorderPacket(worldborder));
|
|
player.connection.send(new ClientboundSetTimePacket(world.getGameTime(), world.getDayTime(), world.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT)));
|
|
player.connection.send(new ClientboundSetDefaultSpawnPositionPacket(world.getSharedSpawnPos(), world.getSharedSpawnAngle()));
|
|
+ org.leavesmc.leaves.protocol.XaeroMapProtocol.onSendWorldInfo(player); // Leaves - xaero map protocol
|
|
if (world.isRaining()) {
|
|
// CraftBukkit start - handle player weather
|
|
// entityplayer.connection.send(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.START_RAINING, 0.0F));
|
|
diff --git a/src/main/java/org/dreeam/leaf/config/modules/network/ProtocolSupport.java b/src/main/java/org/dreeam/leaf/config/modules/network/ProtocolSupport.java
|
|
index ec6fd416786e4a38ed797819138fbdc83348541d..c159340c3d7d90601bb69a4e1b997e372d48841a 100644
|
|
--- a/src/main/java/org/dreeam/leaf/config/modules/network/ProtocolSupport.java
|
|
+++ b/src/main/java/org/dreeam/leaf/config/modules/network/ProtocolSupport.java
|
|
@@ -3,6 +3,8 @@ package org.dreeam.leaf.config.modules.network;
|
|
import org.dreeam.leaf.config.ConfigModules;
|
|
import org.dreeam.leaf.config.EnumConfigCategory;
|
|
|
|
+import java.util.Random;
|
|
+
|
|
public class ProtocolSupport extends ConfigModules {
|
|
|
|
public String getBasePath() {
|
|
@@ -11,10 +13,14 @@ public class ProtocolSupport extends ConfigModules {
|
|
|
|
public static boolean jadeProtocol = false;
|
|
public static boolean appleskinProtocol = false;
|
|
+ public static boolean xaeroMapProtocol = false;
|
|
+ public static int xaeroMapServerID = new Random().nextInt();
|
|
|
|
@Override
|
|
public void onLoaded() {
|
|
jadeProtocol = config.getBoolean(getBasePath() + ".jade-protocol", jadeProtocol);
|
|
appleskinProtocol = config.getBoolean(getBasePath() + ".appleskin-protocol", appleskinProtocol);
|
|
+ xaeroMapProtocol = config.getBoolean(getBasePath() + ".xaero-map-protocol", xaeroMapProtocol);
|
|
+ xaeroMapServerID = config.getInt(getBasePath() + ".xaero-map-server-id", xaeroMapServerID);
|
|
}
|
|
}
|
|
diff --git a/src/main/java/org/leavesmc/leaves/protocol/XaeroMapProtocol.java b/src/main/java/org/leavesmc/leaves/protocol/XaeroMapProtocol.java
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..9e35dfaf8bb5511b4cd0a71175d7ecb6d835042f
|
|
--- /dev/null
|
|
+++ b/src/main/java/org/leavesmc/leaves/protocol/XaeroMapProtocol.java
|
|
@@ -0,0 +1,41 @@
|
|
+package org.leavesmc.leaves.protocol;
|
|
+
|
|
+import net.minecraft.resources.ResourceLocation;
|
|
+import net.minecraft.server.level.ServerPlayer;
|
|
+import org.jetbrains.annotations.Contract;
|
|
+import org.jetbrains.annotations.NotNull;
|
|
+import org.leavesmc.leaves.protocol.core.LeavesProtocol;
|
|
+import org.leavesmc.leaves.protocol.core.ProtocolUtils;
|
|
+
|
|
+@LeavesProtocol(namespace = {"xaerominimap", "xaeroworldmap"})
|
|
+public class XaeroMapProtocol {
|
|
+
|
|
+ public static final String PROTOCOL_ID_MINI = "xaerominimap";
|
|
+ public static final String PROTOCOL_ID_WORLD = "xaeroworldmap";
|
|
+
|
|
+ private static final ResourceLocation MINIMAP_KEY = idMini("main");
|
|
+ private static final ResourceLocation WORLDMAP_KEY = idWorld("main");
|
|
+
|
|
+ @Contract("_ -> new")
|
|
+ public static @NotNull ResourceLocation idMini(String path) {
|
|
+ return new ResourceLocation(PROTOCOL_ID_MINI, path);
|
|
+ }
|
|
+
|
|
+ @Contract("_ -> new")
|
|
+ public static @NotNull ResourceLocation idWorld(String path) {
|
|
+ return new ResourceLocation(PROTOCOL_ID_WORLD, path);
|
|
+ }
|
|
+
|
|
+ public static void onSendWorldInfo(@NotNull ServerPlayer player) {
|
|
+ if (org.dreeam.leaf.config.modules.network.ProtocolSupport.xaeroMapProtocol) {
|
|
+ ProtocolUtils.sendPayloadPacket(player, MINIMAP_KEY, buf -> {
|
|
+ buf.writeByte(0);
|
|
+ buf.writeInt(org.dreeam.leaf.config.modules.network.ProtocolSupport.xaeroMapServerID);
|
|
+ });
|
|
+ ProtocolUtils.sendPayloadPacket(player, WORLDMAP_KEY, buf -> {
|
|
+ buf.writeByte(0);
|
|
+ buf.writeInt(org.dreeam.leaf.config.modules.network.ProtocolSupport.xaeroMapServerID);
|
|
+ });
|
|
+ }
|
|
+ }
|
|
+}
|