diff --git a/leaf-server/minecraft-patches/features/0177-Add-configurable-death-item-drop-knockback-settings.patch b/leaf-server/minecraft-patches/features/0177-Add-configurable-death-item-drop-knockback-settings.patch new file mode 100644 index 00000000..20bcbf59 --- /dev/null +++ b/leaf-server/minecraft-patches/features/0177-Add-configurable-death-item-drop-knockback-settings.patch @@ -0,0 +1,31 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: adabugra <57899270+adabugra@users.noreply.github.com> +Date: Thu, 15 May 2025 19:09:04 +0300 +Subject: [PATCH] Add configurable death item drop knockback settings + + +diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java +index 943f48c41214f440517ecf7f392e08f0e4d1b888..52f720aa676e3875546731935c354e851d1cd5c4 100644 +--- a/net/minecraft/server/level/ServerPlayer.java ++++ b/net/minecraft/server/level/ServerPlayer.java +@@ -1096,7 +1096,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc + if (!keepInventory) { + for (ItemStack item : this.getInventory().getContents()) { + if (!item.isEmpty() && !EnchantmentHelper.has(item, net.minecraft.world.item.enchantment.EnchantmentEffectComponents.PREVENT_EQUIPMENT_DROP)) { +- loot.add(new DefaultDrop(item, stack -> this.drop(stack, true, false, false))); // Paper - Restore vanilla drops behavior; drop function taken from Inventory#dropAll (don't fire drop event) ++ loot.add(new DefaultDrop(item, stack -> this.drop(stack, org.dreeam.leaf.config.modules.gameplay.DeathItemDropKnockback.dropAround, false, false))); // Paper - Restore vanilla drops behavior; drop function taken from Inventory#dropAll (don't fire drop event) + } + } + } +@@ -2849,9 +2849,9 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc + } + + if (dropAround) { +- float f = this.random.nextFloat() * 0.5F; ++ float f = this.random.nextFloat() * (float) org.dreeam.leaf.config.modules.gameplay.DeathItemDropKnockback.horizontalForce; + float f1 = this.random.nextFloat() * (float) (Math.PI * 2); +- itemEntity.setDeltaMovement(-Mth.sin(f1) * f, 0.2F, Mth.cos(f1) * f); ++ itemEntity.setDeltaMovement(-Mth.sin(f1) * f, (float) org.dreeam.leaf.config.modules.gameplay.DeathItemDropKnockback.verticalForce, Mth.cos(f1) * f); + } else { + float f = 0.3F; + float f1 = Mth.sin(this.getXRot() * (float) (Math.PI / 180.0)); diff --git a/leaf-server/src/main/java/org/dreeam/leaf/config/modules/gameplay/DeathItemDropKnockback.java b/leaf-server/src/main/java/org/dreeam/leaf/config/modules/gameplay/DeathItemDropKnockback.java new file mode 100644 index 00000000..7807c456 --- /dev/null +++ b/leaf-server/src/main/java/org/dreeam/leaf/config/modules/gameplay/DeathItemDropKnockback.java @@ -0,0 +1,36 @@ +package org.dreeam.leaf.config.modules.gameplay; + +import org.dreeam.leaf.config.ConfigModules; +import org.dreeam.leaf.config.EnumConfigCategory; + +public class DeathItemDropKnockback extends ConfigModules { + + public String getBasePath() { + return EnumConfigCategory.GAMEPLAY.getBaseKeyName() + ".death-item-drop-knockback"; + } + + public static boolean dropAround = true; + public static double horizontalForce = 0.5; + public static double verticalForce = 0.2; + + @Override + public void onLoaded() { + dropAround = config.getBoolean(getBasePath() + ".drop-around", dropAround, + config.pickStringRegionBased( + "If true, items will drop randomly around the player on death.", + "如果为 “true”,物品会在玩家死亡时随机掉落在其周围." + )); + + horizontalForce = config.getDouble(getBasePath() + ".horizontal-force", horizontalForce, + config.pickStringRegionBased( + "Base speed for horizontal velocity when randomly dropping items.", + "随机掉落物品时水平速度的基本速度." + )); + + verticalForce = config.getDouble(getBasePath() + ".vertical-force", verticalForce, + config.pickStringRegionBased( + "Upward motion for randomly dropped items.", + "随机掉落物品的向上运动." + )); + } +}