mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-19 15:09:25 +00:00
Added RaytraceAntiXray SDK integration
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: LeeGodSRC <lee20040919@gmail.com>
|
||||
Date: Sat Mar 8 11:40:46 2025 +0800
|
||||
Subject: [PATCH] Raytrace AntiXray SDK integration
|
||||
|
||||
Integrated with Imanity Software's Raytrace AntiXray for better performance
|
||||
|
||||
Original project: https://github.com/Imanity-Software/raytrace-antixray-spigot-sdk
|
||||
|
||||
diff --git a/src/main/java/dev/imanity/antixray/sdk/AntiXrayAdapter.java b/src/main/java/dev/imanity/antixray/sdk/AntiXrayAdapter.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..3104caaf8463de31231f7503c86e9c7016f13372
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/dev/imanity/antixray/sdk/AntiXrayAdapter.java
|
||||
@@ -0,0 +1,34 @@
|
||||
+package dev.imanity.antixray.sdk;
|
||||
+
|
||||
+import org.bukkit.Material;
|
||||
+import org.bukkit.World;
|
||||
+import org.bukkit.entity.Player;
|
||||
+
|
||||
+public interface AntiXrayAdapter {
|
||||
+
|
||||
+ /**
|
||||
+ * Call a block change to the AntiXray system
|
||||
+ * It should be at Level.setBlock(BlockPos, BlockState, flags, maxUpdateDepth)
|
||||
+ * Or World.setTypeAndData(BlockPosition, IBlockData, i) in legacy spigot versions
|
||||
+ *
|
||||
+ * @param world the bukkit world
|
||||
+ * @param x the x
|
||||
+ * @param y the y
|
||||
+ * @param z the z
|
||||
+ * @param material the bukkit material
|
||||
+ */
|
||||
+ void callBlockChange(World world, int x, int y, int z, Material material);
|
||||
+
|
||||
+ /**
|
||||
+ * Call a player left click block to the AntiXray system
|
||||
+ * It should be at ServerPlayerGameMode.handleBlockBreakAction(BlockPos, ServerboundPlayerActionPacket.Action, Direction, worldHeight, sequence)
|
||||
+ * Or PlayerInteractManager.a(BlockPosition, EnumDirection) in legacy spigot versions
|
||||
+ *
|
||||
+ * @param world the bukkit world
|
||||
+ * @param player the bukkit player
|
||||
+ * @param x the x
|
||||
+ * @param y the y
|
||||
+ * @param z the z
|
||||
+ */
|
||||
+ void callPlayerLeftClickBlock(World world, Player player, int x, int y, int z);
|
||||
+}
|
||||
diff --git a/src/main/java/dev/imanity/antixray/sdk/AntiXraySDK.java b/src/main/java/dev/imanity/antixray/sdk/AntiXraySDK.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..33fae921cb4cf4631d17837c5f26a01af9619957
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/dev/imanity/antixray/sdk/AntiXraySDK.java
|
||||
@@ -0,0 +1,14 @@
|
||||
+package dev.imanity.antixray.sdk;
|
||||
+
|
||||
+public class AntiXraySDK {
|
||||
+
|
||||
+ private static AntiXrayAdapter ADAPTER;
|
||||
+
|
||||
+ public static AntiXrayAdapter getAdapter() {
|
||||
+ return ADAPTER;
|
||||
+ }
|
||||
+
|
||||
+ public static void setAdapter(AntiXrayAdapter adapter) {
|
||||
+ ADAPTER = adapter;
|
||||
+ }
|
||||
+}
|
||||
@@ -0,0 +1,43 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: LeeGodSRC <lee20040919@gmail.com>
|
||||
Date: Sat, 8 Mar 2025 11:40:46 +0800
|
||||
Subject: [PATCH] Raytrace AntiXray SDK integration
|
||||
|
||||
Integrated with Imanity Software's Raytrace AntiXray for better performance
|
||||
|
||||
Original project: https://github.com/Imanity-Software/raytrace-antixray-spigot-sdk
|
||||
|
||||
diff --git a/net/minecraft/server/level/ServerPlayerGameMode.java b/net/minecraft/server/level/ServerPlayerGameMode.java
|
||||
index a660bad3dfdb442c6aca5eb939ee103e14d37b4b..7e4cfe12312e0e36a6a19210cd76858a6eaf8abd 100644
|
||||
--- a/net/minecraft/server/level/ServerPlayerGameMode.java
|
||||
+++ b/net/minecraft/server/level/ServerPlayerGameMode.java
|
||||
@@ -299,6 +299,12 @@ public class ServerPlayerGameMode {
|
||||
org.bukkit.craftbukkit.event.CraftEventFactory.callBlockDamageAbortEvent(this.player, pos, this.player.getInventory().getSelected()); // CraftBukkit
|
||||
}
|
||||
}
|
||||
+ // Imanity start - AntiXraySDK integration
|
||||
+ dev.imanity.antixray.sdk.AntiXrayAdapter adapter = dev.imanity.antixray.sdk.AntiXraySDK.getAdapter();
|
||||
+ if (adapter != null) {
|
||||
+ adapter.callPlayerLeftClickBlock(this.level.getWorld(), this.player.getBukkitEntity(), pos.getX(), pos.getY(), pos.getZ());
|
||||
+ }
|
||||
+ // Imanity end - AntiXraySDK integration
|
||||
this.level.chunkPacketBlockController.onPlayerLeftClickBlock(this, pos, action, face, maxBuildHeight, sequence); // Paper - Anti-Xray
|
||||
}
|
||||
|
||||
diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java
|
||||
index e0d9d7075b2c10f686c8c144c9869fa574cd19d3..ac7729d1caa80155697bfe0e8646e4eda5d1780e 100644
|
||||
--- a/net/minecraft/world/level/Level.java
|
||||
+++ b/net/minecraft/world/level/Level.java
|
||||
@@ -1191,6 +1191,12 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
|
||||
// CraftBukkit end
|
||||
|
||||
BlockState blockState = chunkAt.setBlockState(pos, state, (flags & 64) != 0, (flags & 1024) == 0); // CraftBukkit custom NO_PLACE flag
|
||||
+ // Imanity start - AntiXraySDK integration
|
||||
+ dev.imanity.antixray.sdk.AntiXrayAdapter adapter = dev.imanity.antixray.sdk.AntiXraySDK.getAdapter();
|
||||
+ if (adapter != null) {
|
||||
+ adapter.callBlockChange(world, pos.getX(), pos.getY(), pos.getZ(), state.getBukkitMaterial());
|
||||
+ }
|
||||
+ // Imanity end - AntiXraySDK integration
|
||||
this.chunkPacketBlockController.onBlockChange(this, pos, state, blockState, flags, recursionLeft); // Paper - Anti-Xray
|
||||
|
||||
if (blockState == null) {
|
||||
Reference in New Issue
Block a user