From 10a35e379836ba9fdaf98e7b4b3a3019cbc6f8f6 Mon Sep 17 00:00:00 2001 From: jhqwqmc <2110242767@qq.com> Date: Wed, 10 Sep 2025 10:31:48 +0800 Subject: [PATCH] =?UTF-8?q?refactor(block):=20=E8=A7=A3=E5=86=B3=E7=91=95?= =?UTF-8?q?=E7=96=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bukkit/block/behavior/BouncingBlockBehavior.java | 12 ++++++++---- .../resources/default/configuration/blocks.yml | 1 + 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/bukkit/src/main/java/net/momirealms/craftengine/bukkit/block/behavior/BouncingBlockBehavior.java b/bukkit/src/main/java/net/momirealms/craftengine/bukkit/block/behavior/BouncingBlockBehavior.java index 6a68455aa..d94e9f95a 100644 --- a/bukkit/src/main/java/net/momirealms/craftengine/bukkit/block/behavior/BouncingBlockBehavior.java +++ b/bukkit/src/main/java/net/momirealms/craftengine/bukkit/block/behavior/BouncingBlockBehavior.java @@ -7,7 +7,6 @@ import net.momirealms.craftengine.core.block.CustomBlock; import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory; import net.momirealms.craftengine.core.util.ResourceConfigUtils; import net.momirealms.craftengine.core.util.VersionHelper; -import org.bukkit.util.Vector; import java.util.Map; import java.util.concurrent.Callable; @@ -15,10 +14,12 @@ import java.util.concurrent.Callable; public class BouncingBlockBehavior extends BukkitBlockBehavior { public static final Factory FACTORY = new Factory(); private final double bounceHeight; + private final boolean syncPlayerSelf; - public BouncingBlockBehavior(CustomBlock customBlock, double bounceHeight) { + public BouncingBlockBehavior(CustomBlock customBlock, double bounceHeight, boolean syncPlayerSelf) { super(customBlock); this.bounceHeight = bounceHeight; + this.syncPlayerSelf = syncPlayerSelf; } @Override @@ -57,7 +58,9 @@ public class BouncingBlockBehavior extends BukkitBlockBehavior { -FastNMS.INSTANCE.field$Vec3$y(deltaMovement) * this.bounceHeight * d, FastNMS.INSTANCE.field$Vec3$z(deltaMovement) ); - FastNMS.INSTANCE.field$Entity$hurtMarked(entity, true); + if (this.syncPlayerSelf) { + FastNMS.INSTANCE.field$Entity$hurtMarked(entity, true); + } } } @@ -66,7 +69,8 @@ public class BouncingBlockBehavior extends BukkitBlockBehavior { @Override public BlockBehavior create(CustomBlock block, Map arguments) { double bounceHeight = ResourceConfigUtils.getAsDouble(arguments.getOrDefault("bounce-height", 0.66), "bounce-height"); - return new BouncingBlockBehavior(block, bounceHeight); + boolean syncPlayerSelf = ResourceConfigUtils.getAsBoolean(arguments.getOrDefault("sync-player-self", true), "sync-player-self"); + return new BouncingBlockBehavior(block, bounceHeight, syncPlayerSelf); } } } diff --git a/common-files/src/main/resources/resources/default/configuration/blocks.yml b/common-files/src/main/resources/resources/default/configuration/blocks.yml index 71db60034..32d9d92d4 100644 --- a/common-files/src/main/resources/resources/default/configuration/blocks.yml +++ b/common-files/src/main/resources/resources/default/configuration/blocks.yml @@ -590,6 +590,7 @@ items#misc: behavior: type: bouncing_block bounce-height: 0.66 + sync-player-self: false state: id: 0 state: white_bed[facing=west,occupied=false,part=foot]