From c2e34ec965d471ea427f415f5ff2fe42d78dd7b9 Mon Sep 17 00:00:00 2001 From: halogly Date: Wed, 23 Jul 2025 00:04:23 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=8F=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bukkit/util/InteractUtils.java | 10 ++--- .../craftengine/core/entity/EntityKeys.java | 38 +++++++++---------- .../craftengine/core/item/ItemKeys.java | 1 + 3 files changed, 23 insertions(+), 26 deletions(-) diff --git a/bukkit/src/main/java/net/momirealms/craftengine/bukkit/util/InteractUtils.java b/bukkit/src/main/java/net/momirealms/craftengine/bukkit/util/InteractUtils.java index 0f93adcd7..2809910b7 100644 --- a/bukkit/src/main/java/net/momirealms/craftengine/bukkit/util/InteractUtils.java +++ b/bukkit/src/main/java/net/momirealms/craftengine/bukkit/util/InteractUtils.java @@ -27,8 +27,8 @@ import java.util.*; public class InteractUtils { private static final Map, BlockData, BlockHitResult, Boolean>> INTERACTIONS = new HashMap<>(); private static final Map, BlockData, BlockHitResult, Boolean>> WILL_CONSUME = new HashMap<>(); - private static final Key NOTE_BLOCK_TOP_INSTRUMENTS = Key.of("minecraft:noteblock_top_instruments"); private static final Map, Boolean>> ENTITY_INTERACTIONS = new HashMap<>(); + private static final Key NOTE_BLOCK_TOP_INSTRUMENTS = Key.of("minecraft:noteblock_top_instruments"); private InteractUtils() {} @@ -283,7 +283,7 @@ public class InteractUtils { } static { - // 有鞍 + 非潜行可交互(如猪、炽足兽) + registerEntityInteraction(EntityKeys.PIGLIN, (player, entity, item) -> item != null && item.vanillaId().equals(ItemKeys.GOLD_INGOT)); registerEntityInteraction(EntityKeys.PIG, (player, entity, item) -> hasSaddle(player, entity) && !player.isSneaking()); registerEntityInteraction(EntityKeys.STRIDER, (player, entity, item) -> hasSaddle(player, entity) && !player.isSneaking()); registerEntityInteraction(EntityKeys.WOLF, (player, entity, item) -> isPetOwner(player, entity)); @@ -301,8 +301,8 @@ public class InteractUtils { registerEntityInteraction(EntityKeys.MINECART, (player, entity, item) -> !player.isSneaking()); registerEntityInteraction(EntityKeys.HAPPY_GHAST, (player, entity, item) -> { if (!VersionHelper.isOrAbove1_21_6()) return false; - if (entity instanceof LivingEntity living && entity.getType() == EntityType.HAPPY_GHAST) { - ItemStack bodyItem = living.getEquipment().getItem(EquipmentSlot.BODY); + if (entity instanceof HappyGhast happyGhast) { + ItemStack bodyItem = happyGhast.getEquipment().getItem(EquipmentSlot.BODY); Item wrapped = BukkitItemManager.instance().wrap(bodyItem); return wrapped.is(Key.of("harnesses")); } @@ -397,6 +397,6 @@ public class InteractUtils { } public static boolean isPetOwner(Player player, Entity entity) { - return entity instanceof Tameable tameable && tameable.isTamed() && tameable.getOwnerUniqueId() == player.getUniqueId(); + return entity instanceof Tameable tameable && tameable.isTamed() && player.getUniqueId().equals(tameable.getOwnerUniqueId()); } } diff --git a/core/src/main/java/net/momirealms/craftengine/core/entity/EntityKeys.java b/core/src/main/java/net/momirealms/craftengine/core/entity/EntityKeys.java index 8691c0912..6f075e3d6 100644 --- a/core/src/main/java/net/momirealms/craftengine/core/entity/EntityKeys.java +++ b/core/src/main/java/net/momirealms/craftengine/core/entity/EntityKeys.java @@ -5,6 +5,23 @@ import net.momirealms.craftengine.core.util.Key; public class EntityKeys { private EntityKeys() {} + public static final Key PIG = Key.of("minecraft:PIG"); + public static final Key STRIDER = Key.of("minecraft:STRIDER"); + public static final Key WOLF = Key.of("minecraft:WOLF"); + public static final Key CAT = Key.of("minecraft:CAT"); + public static final Key PARROT = Key.of("minecraft:PARROT"); + public static final Key ACACIA_BOAT = Key.of("minecraft:ACACIA_BOAT"); + public static final Key BAMBOO_BOAT = Key.of("minecraft:BAMBOO_BOAT"); + public static final Key BIRCH_BOAT = Key.of("minecraft:BIRCH_BOAT"); + public static final Key CHERRY_BOAT = Key.of("minecraft:CHERRY_BOAT"); + public static final Key DARK_OAK_BOAT = Key.of("minecraft:DARK_OAK_BOAT"); + public static final Key JUNGLE_BOAT = Key.of("minecraft:JUNGLE_BOAT"); + public static final Key MANGROVE_BOAT = Key.of("minecraft:MANGROVE_BOAT"); + public static final Key OAK_BOAT = Key.of("minecraft:OAK_BOAT"); + public static final Key SPRUCE_BOAT = Key.of("minecraft:SPRUCE_BOAT"); + public static final Key MINECART = Key.of("minecraft:MINECART"); + public static final Key HAPPY_GHAST = Key.of("minecraft:HAPPY_GHAST"); + public static final Key PIGLIN = Key.of("minecraft:PIGLIN"); public static final Key ALLAY = Key.of("minecraft:ALLAY"); public static final Key HORSE = Key.of("minecraft:HORSE"); public static final Key ZOMBIE_HORSE = Key.of("minecraft:ZOMBIE_HORSE"); @@ -19,18 +36,6 @@ public class EntityKeys { public static final Key ITEM_FRAME = Key.of("minecraft:ITEM_FRAME"); public static final Key GLOW_ITEM_FRAME = Key.of("minecraft:GLOW_ITEM_FRAME"); public static final Key INTERACTION = Key.of("minecraft:INTERACTION"); - - public static final Key ACACIA_BOAT = Key.of("minecraft:ACACIA_BOAT"); - public static final Key BAMBOO_BOAT = Key.of("minecraft:BAMBOO_BOAT"); - public static final Key BIRCH_BOAT = Key.of("minecraft:BIRCH_BOAT"); - public static final Key CHERRY_BOAT = Key.of("minecraft:CHERRY_BOAT"); - public static final Key DARK_OAK_BOAT = Key.of("minecraft:DARK_OAK_BOAT"); - public static final Key JUNGLE_BOAT = Key.of("minecraft:JUNGLE_BOAT"); - public static final Key MANGROVE_BOAT = Key.of("minecraft:MANGROVE_BOAT"); - public static final Key OAK_BOAT = Key.of("minecraft:OAK_BOAT"); - public static final Key SPRUCE_BOAT = Key.of("minecraft:SPRUCE_BOAT"); - public static final Key MINECART = Key.of("minecraft:MINECART"); - public static final Key ACACIA_CHEST_BOAT = Key.of("minecraft:ACACIA_CHEST_BOAT"); public static final Key BAMBOO_CHEST_BOAT = Key.of("minecraft:BAMBOO_CHEST_BOAT"); public static final Key BIRCH_CHEST_BOAT = Key.of("minecraft:BIRCH_CHEST_BOAT"); @@ -49,13 +54,4 @@ public class EntityKeys { public static final Key MINECART_FURNACE = Key.of("minecraft:MINECART_FURNACE"); public static final Key MINECART_HOPPER = Key.of("minecraft:MINECART_HOPPER"); public static final Key MINECART_COMMAND = Key.of("minecraft:MINECART_COMMAND"); - - public static final Key PIG = Key.of("minecraft:PIG"); - public static final Key STRIDER = Key.of("minecraft:STRIDER"); - - public static final Key WOLF = Key.of("minecraft:WOLF"); - public static final Key CAT = Key.of("minecraft:CAT"); - public static final Key PARROT = Key.of("minecraft:PARROT"); - - public static final Key HAPPY_GHAST = Key.of("minecraft:HAPPY_GHAST"); } diff --git a/core/src/main/java/net/momirealms/craftengine/core/item/ItemKeys.java b/core/src/main/java/net/momirealms/craftengine/core/item/ItemKeys.java index 89916d9e3..7fc6b799a 100644 --- a/core/src/main/java/net/momirealms/craftengine/core/item/ItemKeys.java +++ b/core/src/main/java/net/momirealms/craftengine/core/item/ItemKeys.java @@ -33,6 +33,7 @@ public class ItemKeys { public static final Key BARRIER = Key.of("minecraft:barrier"); public static final Key CACTUS = Key.of("minecraft:cactus"); public static final Key REDSTONE = Key.of("minecraft:redstone"); + public static final Key GOLD_INGOT = Key.of("minecraft:gold_ingot"); public static final Key[] AXES = new Key[] { WOODEN_AXE, STONE_AXE, IRON_AXE, GOLDEN_AXE, DIAMOND_AXE, NETHERITE_AXE