mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-25 01:49:30 +00:00
小修改
This commit is contained in:
@@ -27,8 +27,8 @@ import java.util.*;
|
||||
public class InteractUtils {
|
||||
private static final Map<Key, QuadFunction<Player, Item<ItemStack>, BlockData, BlockHitResult, Boolean>> INTERACTIONS = new HashMap<>();
|
||||
private static final Map<Key, QuadFunction<Player, Item<ItemStack>, 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<Key, TriFunction<Player, Entity, @Nullable Item<ItemStack>, 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<ItemStack> 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());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user