From aab16be43c0adeeefbe410d0655ca592b5601280 Mon Sep 17 00:00:00 2001 From: XiaoMoMi Date: Sat, 6 Dec 2025 17:20:34 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bukkit/entity/BukkitEntity.java | 2 +- .../bukkit/plugin/user/BukkitServerPlayer.java | 18 +++++++++--------- .../craftengine/bukkit/util/PlayerUtils.java | 8 ++++---- .../craftengine/core/entity/Entity.java | 2 +- .../core/entity/furniture/Furniture.java | 2 +- .../craftengine/core/plugin/config/Config.java | 7 +++++++ .../plugin/config/template/ArgumentString.java | 2 +- 7 files changed, 24 insertions(+), 17 deletions(-) diff --git a/bukkit/src/main/java/net/momirealms/craftengine/bukkit/entity/BukkitEntity.java b/bukkit/src/main/java/net/momirealms/craftengine/bukkit/entity/BukkitEntity.java index 3d4780635..efda7a2c5 100644 --- a/bukkit/src/main/java/net/momirealms/craftengine/bukkit/entity/BukkitEntity.java +++ b/bukkit/src/main/java/net/momirealms/craftengine/bukkit/entity/BukkitEntity.java @@ -46,7 +46,7 @@ public class BukkitEntity extends AbstractEntity { } @Override - public int entityID() { + public int entityId() { return platformEntity().getEntityId(); } diff --git a/bukkit/src/main/java/net/momirealms/craftengine/bukkit/plugin/user/BukkitServerPlayer.java b/bukkit/src/main/java/net/momirealms/craftengine/bukkit/plugin/user/BukkitServerPlayer.java index f42c9713d..af3c1a1a1 100644 --- a/bukkit/src/main/java/net/momirealms/craftengine/bukkit/plugin/user/BukkitServerPlayer.java +++ b/bukkit/src/main/java/net/momirealms/craftengine/bukkit/plugin/user/BukkitServerPlayer.java @@ -588,7 +588,7 @@ public class BukkitServerPlayer extends Player { } if (Config.predictBreaking() && this.eyeLocation != null && !this.isDestroyingCustomBlock && !unsureEyeLocation.equals(this.eyeLocation)) { // if it's not destroying blocks, we do predict - if ((gameTicks() + entityID()) % Config.predictBreakingInterval() == 0) { + if ((gameTicks() + entityId()) % Config.predictBreakingInterval() == 0) { this.predictNextBlockToMine(); } } @@ -807,7 +807,7 @@ public class BukkitServerPlayer extends Player { if (VersionHelper.isOrAbove1_20_5()) { Object serverPlayer = serverPlayer(); Object attributeInstance = CoreReflections.methodHandle$ServerPlayer$getAttributeMethod.invokeExact(serverPlayer, MAttributeHolders.BLOCK_BREAK_SPEED); - Object newPacket = NetworkReflections.methodHandle$ClientboundUpdateAttributesPacket0Constructor.invokeExact(entityID(), (List) Lists.newArrayList(attributeInstance)); + Object newPacket = NetworkReflections.methodHandle$ClientboundUpdateAttributesPacket0Constructor.invokeExact(entityId(), (List) Lists.newArrayList(attributeInstance)); sendPacket(newPacket, true); } else { resetEffect(MMobEffects.MINING_FATIGUE); @@ -819,11 +819,11 @@ public class BukkitServerPlayer extends Player { CoreReflections.constructor$AttributeModifier.newInstance(KeyUtils.toResourceLocation(Key.DEFAULT_NAMESPACE, "custom_hardness"), -9999d, CoreReflections.instance$AttributeModifier$Operation$ADD_VALUE) : CoreReflections.constructor$AttributeModifier.newInstance(UUID.randomUUID(), Key.DEFAULT_NAMESPACE + ":custom_hardness", -9999d, CoreReflections.instance$AttributeModifier$Operation$ADD_VALUE); Object attributeSnapshot = NetworkReflections.constructor$ClientboundUpdateAttributesPacket$AttributeSnapshot.newInstance(MAttributeHolders.BLOCK_BREAK_SPEED, 1d, Lists.newArrayList(attributeModifier)); - Object newPacket = NetworkReflections.constructor$ClientboundUpdateAttributesPacket1.newInstance(entityID(), Lists.newArrayList(attributeSnapshot)); + Object newPacket = NetworkReflections.constructor$ClientboundUpdateAttributesPacket1.newInstance(entityId(), Lists.newArrayList(attributeSnapshot)); sendPacket(newPacket, true); } else { - Object fatiguePacket = MobEffectUtils.createPacket(MMobEffects.MINING_FATIGUE, entityID(), (byte) 9, -1, false, false, false); - Object hastePacket = MobEffectUtils.createPacket(MMobEffects.HASTE, entityID(), (byte) 0, -1, false, false, false); + Object fatiguePacket = MobEffectUtils.createPacket(MMobEffects.MINING_FATIGUE, entityId(), (byte) 9, -1, false, false, false); + Object hastePacket = MobEffectUtils.createPacket(MMobEffects.HASTE, entityId(), (byte) 0, -1, false, false, false); sendPackets(List.of(fatiguePacket, hastePacket), true); } } @@ -863,9 +863,9 @@ public class BukkitServerPlayer extends Player { Object effectInstance = CoreReflections.method$ServerPlayer$getEffect.invoke(serverPlayer(), mobEffect); Object packet; if (effectInstance != null) { - packet = NetworkReflections.constructor$ClientboundUpdateMobEffectPacket.newInstance(entityID(), effectInstance); + packet = NetworkReflections.constructor$ClientboundUpdateMobEffectPacket.newInstance(entityId(), effectInstance); } else { - packet = NetworkReflections.constructor$ClientboundRemoveMobEffectPacket.newInstance(entityID(), mobEffect); + packet = NetworkReflections.constructor$ClientboundRemoveMobEffectPacket.newInstance(entityId(), mobEffect); } sendPacket(packet, true); } @@ -975,7 +975,7 @@ public class BukkitServerPlayer extends Player { } private void broadcastDestroyProgress(org.bukkit.entity.Player player, BlockPos hitPos, Object blockPos, int stage) { - Object packet = FastNMS.INSTANCE.constructor$ClientboundBlockDestructionPacket(Integer.MAX_VALUE - entityID(), blockPos, stage); + Object packet = FastNMS.INSTANCE.constructor$ClientboundBlockDestructionPacket(Integer.MAX_VALUE - entityId(), blockPos, stage); for (org.bukkit.entity.Player other : player.getWorld().getPlayers()) { Location otherLocation = other.getLocation(); double d0 = (double) hitPos.x() - otherLocation.getX(); @@ -1036,7 +1036,7 @@ public class BukkitServerPlayer extends Player { } @Override - public int entityID() { + public int entityId() { return platformPlayer().getEntityId(); } diff --git a/bukkit/src/main/java/net/momirealms/craftengine/bukkit/util/PlayerUtils.java b/bukkit/src/main/java/net/momirealms/craftengine/bukkit/util/PlayerUtils.java index ee138d4d8..96de3b3c8 100644 --- a/bukkit/src/main/java/net/momirealms/craftengine/bukkit/util/PlayerUtils.java +++ b/bukkit/src/main/java/net/momirealms/craftengine/bukkit/util/PlayerUtils.java @@ -71,20 +71,20 @@ public final class PlayerUtils { Object previousOffHandItem = player.getItemInHand(InteractionHand.OFF_HAND).getLiteralObject(); if (isMainHandTotem) { packets.add(NetworkReflections.constructor$ClientboundSetEquipmentPacket.newInstance( - player.entityID(), List.of(Pair.of(CoreReflections.instance$EquipmentSlot$MAINHAND, BukkitItemManager.instance().uniqueEmptyItem().item().getLiteralObject())) + player.entityId(), List.of(Pair.of(CoreReflections.instance$EquipmentSlot$MAINHAND, BukkitItemManager.instance().uniqueEmptyItem().item().getLiteralObject())) )); } packets.add(NetworkReflections.constructor$ClientboundSetEquipmentPacket.newInstance( - player.entityID(), List.of(Pair.of(CoreReflections.instance$EquipmentSlot$OFFHAND, totemItem)) + player.entityId(), List.of(Pair.of(CoreReflections.instance$EquipmentSlot$OFFHAND, totemItem)) )); packets.add(NetworkReflections.constructor$ClientboundEntityEventPacket.newInstance(player.serverPlayer(), (byte) 35)); if (isMainHandTotem) { packets.add(NetworkReflections.constructor$ClientboundSetEquipmentPacket.newInstance( - player.entityID(), List.of(Pair.of(CoreReflections.instance$EquipmentSlot$MAINHAND, previousMainHandItem.getLiteralObject())) + player.entityId(), List.of(Pair.of(CoreReflections.instance$EquipmentSlot$MAINHAND, previousMainHandItem.getLiteralObject())) )); } packets.add(NetworkReflections.constructor$ClientboundSetEquipmentPacket.newInstance( - player.entityID(), List.of(Pair.of(CoreReflections.instance$EquipmentSlot$OFFHAND, previousOffHandItem)) + player.entityId(), List.of(Pair.of(CoreReflections.instance$EquipmentSlot$OFFHAND, previousOffHandItem)) )); if (sound != null || silent) { packets.add(NetworkReflections.constructor$ClientboundStopSoundPacket.newInstance( diff --git a/core/src/main/java/net/momirealms/craftengine/core/entity/Entity.java b/core/src/main/java/net/momirealms/craftengine/core/entity/Entity.java index 81ab02cf7..7acf7a186 100644 --- a/core/src/main/java/net/momirealms/craftengine/core/entity/Entity.java +++ b/core/src/main/java/net/momirealms/craftengine/core/entity/Entity.java @@ -27,7 +27,7 @@ public interface Entity { float yRot(); - int entityID(); + int entityId(); World world(); diff --git a/core/src/main/java/net/momirealms/craftengine/core/entity/furniture/Furniture.java b/core/src/main/java/net/momirealms/craftengine/core/entity/furniture/Furniture.java index 98033012d..18e3d467c 100644 --- a/core/src/main/java/net/momirealms/craftengine/core/entity/furniture/Furniture.java +++ b/core/src/main/java/net/momirealms/craftengine/core/entity/furniture/Furniture.java @@ -274,7 +274,7 @@ public abstract class Furniture implements Cullable { } public int entityId() { - return this.metaDataEntity.entityID(); + return this.metaDataEntity.entityId(); } public boolean hasExternalModel() { diff --git a/core/src/main/java/net/momirealms/craftengine/core/plugin/config/Config.java b/core/src/main/java/net/momirealms/craftengine/core/plugin/config/Config.java index a00dc1f0e..c38549237 100644 --- a/core/src/main/java/net/momirealms/craftengine/core/plugin/config/Config.java +++ b/core/src/main/java/net/momirealms/craftengine/core/plugin/config/Config.java @@ -215,6 +215,9 @@ public class Config { protected int client_optimization$entity_culling$rate_limiting$bucket_size; protected int client_optimization$entity_culling$rate_limiting$restore_per_tick; + protected boolean bedrock_edition_support$enable; + protected String bedrock_edition_support$player_prefix; + public Config(CraftEngine plugin) { this.plugin = plugin; this.configVersion = PluginProperties.getValue("config"); @@ -589,6 +592,10 @@ public class Config { client_optimization$entity_culling$rate_limiting$bucket_size = config.getInt("client-optimization.entity-culling.rate-limiting.bucket-size", 300); client_optimization$entity_culling$rate_limiting$restore_per_tick = config.getInt("client-optimization.entity-culling.rate-limiting.restore-per-tick", 5); + // bedrock support + bedrock_edition_support$enable = config.getBoolean("bedrock-edition-support.enable", true); + bedrock_edition_support$player_prefix = config.getString("bedrock-edition-support.player-prefix", "!"); + firstTime = false; } diff --git a/core/src/main/java/net/momirealms/craftengine/core/plugin/config/template/ArgumentString.java b/core/src/main/java/net/momirealms/craftengine/core/plugin/config/template/ArgumentString.java index 3394bed15..71336065d 100644 --- a/core/src/main/java/net/momirealms/craftengine/core/plugin/config/template/ArgumentString.java +++ b/core/src/main/java/net/momirealms/craftengine/core/plugin/config/template/ArgumentString.java @@ -152,7 +152,7 @@ public interface ArgumentString { @Override public boolean equals(Object o) { - if (!(o instanceof Complex that)) return false; + if (!(o instanceof Complex2 that)) return false; return this.rawText.equals(that.rawText); }