From 33e01b3d35d429f1bd983961713d7a1705874c59 Mon Sep 17 00:00:00 2001 From: TheWhiteDog9487 <60037547+TheWhiteDog9487@users.noreply.github.com> Date: Sun, 5 Oct 2025 14:13:32 +0800 Subject: [PATCH] =?UTF-8?q?=E7=8E=B0=E5=9C=A8=E8=A2=AB=E4=BC=A0=E9=80=81?= =?UTF-8?q?=E5=AE=9E=E4=BD=93=E4=BC=9A=E5=9C=A8=E8=87=AA=E5=B7=B1=E6=89=80?= =?UTF-8?q?=E5=9C=A8=E4=B8=96=E7=95=8C=E5=86=85=E8=A2=AB=E4=BC=A0=E9=80=81?= =?UTF-8?q?=EF=BC=8C=E4=B8=8D=E4=BC=9A=E5=8F=97=E5=88=B0=E5=91=BD=E4=BB=A4?= =?UTF-8?q?=E6=89=A7=E8=A1=8C=E6=96=B9=E6=89=80=E5=9C=A8=E4=B8=96=E7=95=8C?= =?UTF-8?q?=E5=92=8C=E8=87=AA=E5=B7=B1=E4=B8=8D=E4=B8=80=E8=87=B4=E7=9A=84?= =?UTF-8?q?=E5=BD=B1=E5=93=8D=20=E9=87=8D=E5=91=BD=E5=90=8D=E5=87=BD?= =?UTF-8?q?=E6=95=B0=E5=92=8C=E5=8F=98=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xyz/thewhitedog9487/CommandRegister.java | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/main/java/xyz/thewhitedog9487/CommandRegister.java b/src/main/java/xyz/thewhitedog9487/CommandRegister.java index 46b61e3..ce95f1c 100644 --- a/src/main/java/xyz/thewhitedog9487/CommandRegister.java +++ b/src/main/java/xyz/thewhitedog9487/CommandRegister.java @@ -189,21 +189,21 @@ public class CommandRegister { * * @param Source 命令执行者 * @param Radius 随机选择的目的坐标距离参数 {@code Origin} 的最大距离 - * @param Player 被传送的玩家 + * @param Entity 被传送的实体 * @param Origin 随机选择的目的坐标的中心 * @return 命令运行是否成功 */ - static int execute_command(ServerCommandSource Source, @Nullable Integer Radius, @Nullable Entity Player, @Nullable Vec2f Origin){ - Entity entity = Player == null ? Source.getPlayer() : Player; + static int ExecuteCommand(ServerCommandSource Source, @Nullable Integer Radius, @Nullable Entity Entity, @Nullable Vec2f Origin){ + Entity TargetEntity = Entity == null ? Source.getPlayer() : Entity; /* ↑ - Entity entity = null; - if (Player == null){ - entity = Source.getPlayer();} + Entity TargetEntity = null; + if (TargetEntity == null){ + TargetEntity = Source.getPlayer();} else{ - entity = Player;} + TargetEntity = Entity;} */ - if (entity == null) { + if (TargetEntity == null) { Source.sendFeedback(()->{ return Text.translatableWithFallback("error.no_target","不存在被传送目标,由非玩家物体执行命令时请显式指定被传送玩家ID"); }, true); return -1;} if (Radius == null){Radius = (int) (WorldBorder - 1e4);} @@ -250,13 +250,13 @@ public class CommandRegister { // 只替换空气、水和岩浆,其余保留 Source.getWorld().setBlockState(BlockPos, Blocks.GLASS.getDefaultState());}}} // if ( String.valueOf(entity.getWorld().getBiome(new BlockPos(Math.toIntExact(Coordinate_X), Coordinate_Y, Math.toIntExact(Coordinate_Z))).getKey()).equals("minecraft:the_void") ) { + World EntityWorld = TargetEntity.getEntityWorld(); + World EntityWorld = TargetEntity.getEntityWorld(); if ( ReplaceToTargetBlock.contains(CurrentBlock) ) { // 只替换ReplaceToTargetBlock内的方块,其余保留 EntityWorld.setBlockState(BlockPos, TargetBlock.getDefaultState());}}} // Coordinate_Y++;} - Coordinate_Y++; - // ↑ 高一层,人别站在土里了 - entity.teleport(Source.getWorld(),Coordinate_X + 0.5, Coordinate_Y, Coordinate_Z + 0.5, new HashSet<>(), entity.getYaw(), entity.getPitch(), false); + TargetEntity.teleport((ServerWorld) EntityWorld,Coordinate_X + 0.5, Coordinate_Y, Coordinate_Z + 0.5, new HashSet<>(), TargetEntity.getYaw(), TargetEntity.getPitch(), false); int finalCoordinate_X = Coordinate_X; int finalCoordinate_Y = Coordinate_Y; int finalCoordinate_Z = Coordinate_Z;