diff --git a/patches/server/0077-Fix-MC-172047.patch b/patches/server/0077-Fix-MC-172047.patch deleted file mode 100644 index 0050f16a9..000000000 --- a/patches/server/0077-Fix-MC-172047.patch +++ /dev/null @@ -1,55 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: HaHaWTH -Date: Fri, 15 Mar 2024 02:12:38 +0800 -Subject: [PATCH] Fix-MC-172047 - - -diff --git a/src/main/java/net/minecraft/world/entity/animal/Wolf.java b/src/main/java/net/minecraft/world/entity/animal/Wolf.java -index a90055fe8819a32180754b6060a0f88e81d1a3b6..35d4645ebad044c5c216bc7d0126a055d623ee9f 100644 ---- a/src/main/java/net/minecraft/world/entity/animal/Wolf.java -+++ b/src/main/java/net/minecraft/world/entity/animal/Wolf.java -@@ -58,6 +58,7 @@ import net.minecraft.world.entity.ai.goal.target.OwnerHurtTargetGoal; - import net.minecraft.world.entity.ai.goal.target.ResetUniversalAngerTargetGoal; - import net.minecraft.world.entity.animal.horse.AbstractHorse; - import net.minecraft.world.entity.animal.horse.Llama; -+import net.minecraft.world.entity.decoration.ArmorStand; - import net.minecraft.world.entity.monster.AbstractSkeleton; - import net.minecraft.world.entity.monster.Creeper; - import net.minecraft.world.entity.monster.Ghast; -@@ -672,13 +673,33 @@ public class Wolf extends TamableAnimal implements NeutralMob { - - @Override - public boolean wantsToAttack(LivingEntity target, LivingEntity owner) { -- if (!(target instanceof Creeper) && !(target instanceof Ghast)) { -+ if (!(target instanceof Creeper) && !(target instanceof Ghast) && !(target instanceof ArmorStand)) { // Leaf - Fix MC-172047 - if (target instanceof Wolf) { - Wolf entitywolf = (Wolf) target; -- - return !entitywolf.isTame() || entitywolf.getOwner() != owner; - } else { -- return target instanceof Player && owner instanceof Player && !((Player) owner).canHarmPlayer((Player) target) ? false : (target instanceof AbstractHorse && ((AbstractHorse) target).isTamed() ? false : !(target instanceof TamableAnimal) || !((TamableAnimal) target).isTame()); -+ // Leaf start -+ if (target instanceof Player) { -+ Player targetPlayer = (Player) target; -+ if (owner instanceof Player) { -+ Player ownerPlayer = (Player) owner; -+ if (!ownerPlayer.canHarmPlayer(targetPlayer)) { -+ return false; -+ } -+ } -+ } -+ if (target instanceof AbstractHorse) { -+ AbstractHorse targetHorse = (AbstractHorse) target; -+ if (targetHorse.isTamed()) { -+ return false; -+ } -+ } -+ if (target instanceof TamableAnimal) { -+ TamableAnimal tamableAnimalTarget = (TamableAnimal) target; -+ return !tamableAnimalTarget.isTame(); -+ } -+ return true; -+ // Leaf end - } - } else { - return false; diff --git a/patches/server/0078-asteor-bar-protocol.patch b/patches/server/0078-asteor-bar-protocol.patch new file mode 100644 index 000000000..c9158dee7 --- /dev/null +++ b/patches/server/0078-asteor-bar-protocol.patch @@ -0,0 +1,128 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: HaHaWTH +Date: Fri, 22 Mar 2024 04:36:25 +0800 +Subject: [PATCH] asteor-bar-protocol + + +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 1c1abbb3a74a519520d2c1229721887c19d9df2e..92bac2a84fef7b91f033479f2362ce7a2009a51a 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 +@@ -25,6 +25,9 @@ public class ProtocolSupport implements IConfigModule { + @ConfigInfo(baseName = "appleskin-protocol") + public static boolean appleskinProtocol = false; + ++ @ConfigInfo(baseName = "asteorbar-protocol") ++ public static boolean asteorBarProtocol = false; ++ + @ConfigInfo(baseName = "chatImage-protocol") + public static boolean chatImageProtocol = false; + +diff --git a/src/main/java/top/leavesmc/leaves/protocol/AsteorBarProtocol.java b/src/main/java/top/leavesmc/leaves/protocol/AsteorBarProtocol.java +new file mode 100644 +index 0000000000000000000000000000000000000000..9651c6c83d17b42edd81070890bd81dcb887f898 +--- /dev/null ++++ b/src/main/java/top/leavesmc/leaves/protocol/AsteorBarProtocol.java +@@ -0,0 +1,102 @@ ++package top.leavesmc.leaves.protocol; ++ ++import net.minecraft.resources.ResourceLocation; ++import net.minecraft.server.MinecraftServer; ++import net.minecraft.server.level.ServerPlayer; ++import net.minecraft.world.food.FoodData; ++import org.jetbrains.annotations.Contract; ++import org.jetbrains.annotations.NotNull; ++import top.leavesmc.leaves.protocol.core.LeavesProtocol; ++import top.leavesmc.leaves.protocol.core.ProtocolHandler; ++import top.leavesmc.leaves.protocol.core.ProtocolUtils; ++ ++import java.util.*; ++ ++@LeavesProtocol(namespace = "asteorbar") ++public class AsteorBarProtocol { ++ ++ public static final String PROTOCOL_ID = "asteorbar"; ++ ++ private static final ResourceLocation NETWORK_KEY = id("network"); ++ ++ private static final Map previousSaturationLevels = new HashMap<>(); ++ private static final Map previousExhaustionLevels = new HashMap<>(); ++ ++ private static final float THRESHOLD = 0.01F; ++ ++ private static final Set players = new HashSet<>(); ++ ++ @Contract("_ -> new") ++ public static @NotNull ResourceLocation id(String path) { ++ return new ResourceLocation(PROTOCOL_ID, path); ++ } ++ ++ @ProtocolHandler.PlayerJoin ++ public static void onPlayerLoggedIn(@NotNull ServerPlayer player) { ++ if (org.dreeam.leaf.config.modules.network.ProtocolSupport.asteorBarProtocol) { ++ resetPlayerData(player); ++ } ++ } ++ ++ @ProtocolHandler.PlayerLeave ++ public static void onPlayerLoggedOut(@NotNull ServerPlayer player) { ++ if (org.dreeam.leaf.config.modules.network.ProtocolSupport.asteorBarProtocol) { ++ players.remove(player); ++ resetPlayerData(player); ++ } ++ } ++ ++ @ProtocolHandler.MinecraftRegister(ignoreId = true) ++ public static void onPlayerSubscribed(@NotNull ServerPlayer player) { ++ if (org.dreeam.leaf.config.modules.network.ProtocolSupport.asteorBarProtocol) { ++ players.add(player); ++ } ++ } ++ ++ @ProtocolHandler.Ticker ++ public static void tick() { ++ if (org.dreeam.leaf.config.modules.network.ProtocolSupport.asteorBarProtocol) { ++ for (ServerPlayer player : players) { ++ FoodData data = player.getFoodData(); ++ ++ float saturation = data.getSaturationLevel(); ++ Float previousSaturation = previousSaturationLevels.get(player.getUUID()); ++ if (previousSaturation == null || saturation != previousSaturation) { ++ ProtocolUtils.sendPayloadPacket(player, NETWORK_KEY, buf -> { ++ buf.writeByte(1); ++ buf.writeFloat(saturation); ++ }); ++ previousSaturationLevels.put(player.getUUID(), saturation); ++ } ++ ++ float exhaustion = data.getExhaustionLevel(); ++ Float previousExhaustion = previousExhaustionLevels.get(player.getUUID()); ++ if (previousExhaustion == null || Math.abs(exhaustion - previousExhaustion) >= THRESHOLD) { ++ ProtocolUtils.sendPayloadPacket(player, NETWORK_KEY, buf -> { ++ buf.writeByte(0); ++ buf.writeFloat(exhaustion); ++ }); ++ previousExhaustionLevels.put(player.getUUID(), exhaustion); ++ } ++ } ++ } ++ } ++ ++ @ProtocolHandler.ReloadServer ++ public static void onServerReload() { ++ if (!org.dreeam.leaf.config.modules.network.ProtocolSupport.asteorBarProtocol) { ++ disableAllPlayer(); ++ } ++ } ++ ++ public static void disableAllPlayer() { ++ for (ServerPlayer player : MinecraftServer.getServer().getPlayerList().getPlayers()) { ++ onPlayerLoggedOut(player); ++ } ++ } ++ ++ private static void resetPlayerData(@NotNull ServerPlayer player) { ++ previousExhaustionLevels.remove(player.getUUID()); ++ previousSaturationLevels.remove(player.getUUID()); ++ } ++}