9
0
mirror of https://github.com/Xiao-MoMi/craft-engine.git synced 2025-12-27 10:59:07 +00:00

修正交互

This commit is contained in:
halogly
2025-08-31 15:36:57 +08:00
parent 16334e0c88
commit 41c1ed3841
8 changed files with 1307 additions and 404 deletions

View File

@@ -108,7 +108,10 @@ public class AxeItemBehavior extends ItemBehavior {
if (!InteractUtils.isInteractable(
bukkitPlayer, BlockStateUtils.fromBlockData(customState.vanillaBlockState().literalObject()),
context.getHitResult(), item
) || player.isSecondaryUseActive()) {
) || (player.isSecondaryUseActive() && !InteractUtils.isIgnoreSneaking(
bukkitPlayer, BlockStateUtils.fromBlockData(customState.vanillaBlockState().literalObject()),
context.getHitResult(), item
))) {
player.swingHand(context.getHand());
}
// shrink item amount

View File

@@ -88,8 +88,9 @@ public class FlintAndSteelItemBehavior extends ItemBehavior {
context.getHitResult(), (Item<ItemStack>) context.getItem())) {
return InteractionResult.PASS;
}
// 且没有shift
if (!player.isSecondaryUseActive()) {
// 且没有shift或者忽略潜行的可交互方块
if (!player.isSecondaryUseActive() || InteractUtils.isIgnoreSneaking((Player) player.platformPlayer(), vanillaBlockState,
context.getHitResult(), (Item<ItemStack>) context.getItem())) {
player.playSound(FLINT_SOUND, firePos, SoundSource.BLOCK, 1f, RandomUtils.generateRandomFloat(0.8f, 1.2f));
}
} else {
@@ -110,7 +111,7 @@ public class FlintAndSteelItemBehavior extends ItemBehavior {
// 客户端觉得这玩意可交互,就会忽略声音
if (InteractUtils.isInteractable((Player) player.platformPlayer(), vanillaBlockState, context.getHitResult(), (Item<ItemStack>) context.getItem())) {
// 如果按住了shift则代表尝试对侧面方块点火
if (player.isSecondaryUseActive()) {
if (player.isSecondaryUseActive() && !InteractUtils.isIgnoreSneaking((Player) player.platformPlayer(), vanillaBlockState, context.getHitResult(), (Item<ItemStack>) context.getItem())) {
// 如果底部不能燃烧,则燃烧点位为侧面,需要补发
if (!belowCanBurn) {
player.playSound(FLINT_SOUND, firePos, SoundSource.BLOCK, 1f, RandomUtils.generateRandomFloat(0.8f, 1.2f));

View File

@@ -257,7 +257,7 @@ public class ItemEventListener implements Listener {
// so we should check and resend sounds on BlockPlaceEvent
BlockData craftBlockData = BlockStateUtils.fromBlockData(immutableBlockState.vanillaBlockState().literalObject());
if (InteractUtils.isInteractable(player, craftBlockData, hitResult, itemInHand)) {
if (!serverPlayer.isSecondaryUseActive()) {
if (!serverPlayer.isSecondaryUseActive() || InteractUtils.isIgnoreSneaking(player, craftBlockData, hitResult, itemInHand)) {
serverPlayer.setResendSound();
}
} else {
@@ -276,7 +276,7 @@ public class ItemEventListener implements Listener {
return;
} else {
// todo 实际上这里的处理并不正确,因为判断玩家是否能够放置那个方块需要更加细节的判断。比如玩家无法对着树叶放置火把,但是交互事件依然触发,此情况下不可丢弃自定义行为。
if (serverPlayer.isSecondaryUseActive() || !InteractUtils.isInteractable(player, blockData, hitResult, itemInHand)) {
if ((serverPlayer.isSecondaryUseActive() && InteractUtils.isIgnoreSneaking(player, blockData, hitResult, itemInHand)) || !InteractUtils.isInteractable(player, blockData, hitResult, itemInHand)) {
event.setCancelled(true);
}
}
@@ -290,9 +290,10 @@ public class ItemEventListener implements Listener {
if (optionalItemBehaviors.isPresent()) {
// 检测是否可交互应当只判断原版方块,因为自定义方块早就判断过了,如果可交互不可能到这一步
boolean interactable = immutableBlockState == null && InteractUtils.isInteractable(player, blockData, hitResult, itemInHand);
boolean isIgnoreSneaking = InteractUtils.isIgnoreSneaking(player, blockData, hitResult, itemInHand);
// 如果方块可交互但是玩家没shift那么原版的方块交互优先取消自定义物品的behavior
// todo 如果我的物品行为允许某些交互呢?是否值得进一步处理?
if (!serverPlayer.isSecondaryUseActive() && interactable) {
if ((!serverPlayer.isSecondaryUseActive() || isIgnoreSneaking) && interactable) {
return;
}
UseOnContext useOnContext = new UseOnContext(serverPlayer, hand, itemInHand, hitResult);
@@ -315,7 +316,7 @@ public class ItemEventListener implements Listener {
// 执行物品右键事件
if (hasCustomItem) {
// 要求服务端侧这个方块不可交互,或玩家处于潜行状态
if (serverPlayer.isSecondaryUseActive() || !InteractUtils.isInteractable(player, blockData, hitResult, itemInHand)) {
if ((serverPlayer.isSecondaryUseActive() && !InteractUtils.isIgnoreSneaking(player, blockData, hitResult, itemInHand)) || !InteractUtils.isInteractable(player, blockData, hitResult, itemInHand)) {
Cancellable dummy = Cancellable.dummy();
PlayerOptionalContext context = PlayerOptionalContext.of(serverPlayer, ContextHolder.builder()
.withParameter(DirectContextParameters.BLOCK, new BukkitExistingBlock(block))

View File

@@ -4,41 +4,72 @@ import net.momirealms.craftengine.core.util.Key;
public final class BlockKeys {
private BlockKeys() {}
// 特殊
public static final Key AIR = Key.of("minecraft:air");
public static final Key NOTE_BLOCK = Key.of("minecraft:note_block");
public static final Key TRIPWIRE = Key.of("minecraft:tripwire");
public static final Key CACTUS = Key.of("minecraft:cactus");
public static final Key POWDER_SNOW = Key.of("minecraft:powder_snow");
// 自然方块
public static final Key OBSIDIAN = Key.of("minecraft:obsidian");
public static final Key BEDROCK = Key.of("minecraft:bedrock");
// 功能方块
public static final Key CRAFTING_TABLE = Key.of("minecraft:crafting_table");
public static final Key CARTOGRAPHY_TABLE = Key.of("minecraft:cartography_table");
public static final Key STONECUTTER = Key.of("minecraft:stonecutter");
public static final Key BELL = Key.of("minecraft:bell");
public static final Key CARTOGRAPHY_TABLE = Key.of("minecraft:cartography_table");
public static final Key SMITHING_TABLE = Key.of("minecraft:smithing_table");
public static final Key GRINDSTONE = Key.of("minecraft:grindstone");
public static final Key LOOM = Key.of("minecraft:loom");
public static final Key BARREL = Key.of("minecraft:barrel");
public static final Key FURNACE = Key.of("minecraft:furnace");
public static final Key SMOKER = Key.of("minecraft:smoker");
public static final Key BLAST_FURNACE = Key.of("minecraft:blast_furnace");
public static final Key FURNACE = Key.of("minecraft:furnace");
public static final Key LEVER = Key.of("minecraft:lever");
public static final Key CAMPFIRE = Key.of("minecraft:campfire");
public static final Key SOUL_CAMPFIRE = Key.of("minecraft:soul_campfire");
public static final Key ANVIL = Key.of("minecraft:anvil");
public static final Key CHIPPED_ANVIL = Key.of("minecraft:chipped_anvil");
public static final Key DAMAGED_ANVIL = Key.of("minecraft:damaged_anvil");
public static final Key GRINDSTONE = Key.of("minecraft:grindstone");
public static final Key COMPOSTER = Key.of("minecraft:composter");
public static final Key JUKEBOX = Key.of("minecraft:jukebox");
public static final Key ENCHANTING_TABLE = Key.of("minecraft:enchanting_table");
public static final Key BREWING_STAND = Key.of("minecraft:brewing_stand");
public static final Key CAULDRON = Key.of("minecraft:cauldron");
public static final Key LAVA_CAULDRON = Key.of("minecraft:lava_cauldron");
public static final Key WATER_CAULDRON = Key.of("minecraft:water_cauldron");
public static final Key BELL = Key.of("minecraft:bell");
public static final Key BEACON = Key.of("minecraft:beacon");
public static final Key LODESTONE = Key.of("minecraft:lodestone");
public static final Key BEE_NEST = Key.of("minecraft:bee_nest");
public static final Key BEEHIVE = Key.of("minecraft:beehive");
public static final Key FLOWER_POT = Key.of("minecraft:flower_pot");
public static final Key DECORATED_POT = Key.of("minecraft:decorated_pot");
public static final Key CHISELED_BOOKSHELF = Key.of("minecraft:chiseled_bookshelf");
public static final Key LECTERN = Key.of("minecraft:lectern");
public static final Key CHEST = Key.of("minecraft:chest");
public static final Key CAMPFIRE = Key.of("minecraft:campfire");
public static final Key SOUL_CAMPFIRE = Key.of("minecraft:soul_campfire");
public static final Key BARREL = Key.of("minecraft:barrel");
public static final Key ENDER_CHEST = Key.of("minecraft:ender_chest");
public static final Key TRAPPED_CHEST = Key.of("minecraft:trapped_chest");
public static final Key DAYLIGHT_DETECTOR = Key.of("minecraft:daylight_detector");
public static final Key LECTERN = Key.of("minecraft:lectern");
public static final Key RESPAWN_ANCHOR = Key.of("minecraft:respawn_anchor");
public static final Key DRAGON_EGG = Key.of("minecraft:dragon_egg");
public static final Key END_PORTAL_FRAME = Key.of("minecraft:end_portal_frame");
public static final Key VAULT = Key.of("minecraft:vault");
public static final Key SPAWNER = Key.of("minecraft:spawner");
public static final Key TRIAL_SPAWNER = Key.of("minecraft:trial_spawner");
// 红石方块
public static final Key REPEATER = Key.of("minecraft:repeater");
public static final Key COMPARATOR = Key.of("minecraft:comparator");
public static final Key DRAGON_EGG = Key.of("minecraft:dragon_egg");
public static final Key HOPPER = Key.of("minecraft:hopper");
public static final Key LEVER = Key.of("minecraft:lever");
public static final Key DAYLIGHT_DETECTOR = Key.of("minecraft:daylight_detector");
public static final Key DISPENSER = Key.of("minecraft:dispenser");
public static final Key DROPPER = Key.of("minecraft:dropper");
public static final Key CRAFTER = Key.of("minecraft:crafter");
public static final Key HOPPER = Key.of("minecraft:hopper");
public static final Key TNT = Key.of("minecraft:tnt");
public static final Key REDSTONE_ORE = Key.of("minecraft:redstone_ore");
public static final Key DEEPSLATE_REDSTONE_ORE = Key.of("minecraft:deepslate_redstone_ore");
// 管理员用品
public static final Key COMMAND_BLOCK = Key.of("minecraft:command_block");
public static final Key CHAIN_COMMAND_BLOCK = Key.of("minecraft:chain_command_block");
public static final Key REPEATING_COMMAND_BLOCK = Key.of("minecraft:repeating_command_block");
@@ -47,113 +78,103 @@ public final class BlockKeys {
public static final Key TEST_INSTANCE_BLOCK = Key.of("minecraft:test_instance_block");
public static final Key TEST_BLOCK = Key.of("minecraft:test_block");
public static final Key LIGHT = Key.of("minecraft:light");
public static final Key DECORATED_POT = Key.of("minecraft:decorated_pot");
public static final Key FLOWER_POT = Key.of("minecraft:flower_pot");
public static final Key CHISELED_BOOKSHELF = Key.of("minecraft:chiseled_bookshelf");
public static final Key REDSTONE_ORE = Key.of("minecraft:redstone_ore");
public static final Key DEEPSLATE_REDSTONE_ORE = Key.of("minecraft:deepslate_redstone_ore");
public static final Key BEE_NEST = Key.of("minecraft:bee_nest");
public static final Key BEEHIVE = Key.of("minecraft:beehive");
public static final Key POWDER_SNOW = Key.of("minecraft:powder_snow");
public static final Key COMPOSTER = Key.of("minecraft:composter");
public static final Key CAULDRON = Key.of("minecraft:cauldron");
public static final Key WATER_CAULDRON = Key.of("minecraft:water_cauldron");
public static final Key LAVA_CAULDRON = Key.of("minecraft:lava_cauldron");
public static final Key RESPAWN_ANCHOR = Key.of("minecraft:respawn_anchor");
public static final Key LODESTONE = Key.of("minecraft:lodestone");
// 床
public static final Key WHITE_BED = Key.of("minecraft:white_bed");
public static final Key LIGHT_GRAY_BED = Key.of("minecraft:light_gray_bed");
public static final Key GRAY_BED = Key.of("minecraft:gray_bed");
public static final Key BLACK_BED = Key.of("minecraft:black_bed");
public static final Key BROWN_BED = Key.of("minecraft:brown_bed");
public static final Key RED_BED = Key.of("minecraft:red_bed");
public static final Key ORANGE_BED = Key.of("minecraft:orange_bed");
public static final Key YELLOW_BED = Key.of("minecraft:yellow_bed");
public static final Key LIME_BED = Key.of("minecraft:lime_bed");
public static final Key GREEN_BED = Key.of("minecraft:green_bed");
public static final Key CYAN_BED = Key.of("minecraft:cyan_bed");
public static final Key LIGHT_BLUE_BED = Key.of("minecraft:light_blue_bed");
public static final Key BLUE_BED = Key.of("minecraft:blue_bed");
public static final Key PURPLE_BED = Key.of("minecraft:purple_bed");
public static final Key MAGENTA_BED = Key.of("minecraft:magenta_bed");
public static final Key PINK_BED = Key.of("minecraft:pink_bed");
// 蜡烛
public static final Key CANDLE = Key.of("minecraft:candle");
public static final Key WHITE_CANDLE = Key.of("minecraft:white_candle");
public static final Key LIGHT_GRAY_CANDLE = Key.of("minecraft:light_gray_candle");
public static final Key GRAY_CANDLE = Key.of("minecraft:gray_candle");
public static final Key BLACK_CANDLE = Key.of("minecraft:black_candle");
public static final Key BROWN_CANDLE = Key.of("minecraft:brown_candle");
public static final Key RED_CANDLE = Key.of("minecraft:red_candle");
public static final Key ORANGE_CANDLE = Key.of("minecraft:orange_candle");
public static final Key YELLOW_CANDLE = Key.of("minecraft:yellow_candle");
public static final Key LIME_CANDLE = Key.of("minecraft:lime_candle");
public static final Key GREEN_CANDLE = Key.of("minecraft:green_candle");
public static final Key CYAN_CANDLE = Key.of("minecraft:cyan_candle");
public static final Key LIGHT_BLUE_CANDLE = Key.of("minecraft:light_blue_candle");
public static final Key BLUE_CANDLE = Key.of("minecraft:blue_candle");
public static final Key PURPLE_CANDLE = Key.of("minecraft:purple_candle");
public static final Key MAGENTA_CANDLE = Key.of("minecraft:magenta_candle");
public static final Key PINK_CANDLE = Key.of("minecraft:pink_candle");
// 蛋糕
public static final Key CAKE = Key.of("minecraft:cake");
public static final Key CANDLE_CAKE = Key.of("minecraft:candle_cake");
public static final Key WHITE_CANDLE_CAKE = Key.of("minecraft:white_candle_cake");
public static final Key LIGHT_GRAY_CANDLE_CAKE = Key.of("minecraft:light_gray_candle_cake");
public static final Key GRAY_CANDLE_CAKE = Key.of("minecraft:gray_candle_cake");
public static final Key BLACK_CANDLE_CAKE = Key.of("minecraft:black_candle_cake");
public static final Key BROWN_CANDLE_CAKE = Key.of("minecraft:brown_candle_cake");
public static final Key RED_CANDLE_CAKE = Key.of("minecraft:red_candle_cake");
public static final Key ORANGE_CANDLE_CAKE = Key.of("minecraft:orange_candle_cake");
public static final Key MAGENTA_CANDLE_CAKE = Key.of("minecraft:magenta_candle_cake");
public static final Key LIGHT_BLUE_CANDLE_CAKE = Key.of("minecraft:light_blue_candle_cake");
public static final Key YELLOW_CANDLE_CAKE = Key.of("minecraft:yellow_candle_cake");
public static final Key LIME_CANDLE_CAKE = Key.of("minecraft:lime_candle_cake");
public static final Key PINK_CANDLE_CAKE = Key.of("minecraft:pink_candle_cake");
public static final Key GRAY_CANDLE_CAKE = Key.of("minecraft:gray_candle_cake");
public static final Key LIGHT_GRAY_CANDLE_CAKE = Key.of("minecraft:light_gray_candle_cake");
public static final Key CYAN_CANDLE_CAKE = Key.of("minecraft:cyan_candle_cake");
public static final Key PURPLE_CANDLE_CAKE = Key.of("minecraft:purple_candle_cake");
public static final Key BLUE_CANDLE_CAKE = Key.of("minecraft:blue_candle_cake");
public static final Key BROWN_CANDLE_CAKE = Key.of("minecraft:brown_candle_cake");
public static final Key GREEN_CANDLE_CAKE = Key.of("minecraft:green_candle_cake");
public static final Key RED_CANDLE_CAKE = Key.of("minecraft:red_candle_cake");
public static final Key BLACK_CANDLE_CAKE = Key.of("minecraft:black_candle_cake");
public static final Key WHITE_BED = Key.of("minecraft:white_bed");
public static final Key ORANGE_BED = Key.of("minecraft:orange_bed");
public static final Key MAGENTA_BED = Key.of("minecraft:magenta_bed");
public static final Key LIGHT_BLUE_BED = Key.of("minecraft:light_blue_bed");
public static final Key YELLOW_BED = Key.of("minecraft:yellow_bed");
public static final Key LIME_BED = Key.of("minecraft:lime_bed");
public static final Key PINK_BED = Key.of("minecraft:pink_bed");
public static final Key GRAY_BED = Key.of("minecraft:gray_bed");
public static final Key LIGHT_GRAY_BED = Key.of("minecraft:light_gray_bed");
public static final Key CYAN_BED = Key.of("minecraft:cyan_bed");
public static final Key PURPLE_BED = Key.of("minecraft:purple_bed");
public static final Key BLUE_BED = Key.of("minecraft:blue_bed");
public static final Key BROWN_BED = Key.of("minecraft:brown_bed");
public static final Key GREEN_BED = Key.of("minecraft:green_bed");
public static final Key RED_BED = Key.of("minecraft:red_bed");
public static final Key BLACK_BED = Key.of("minecraft:black_bed");
public static final Key CYAN_CANDLE_CAKE = Key.of("minecraft:cyan_candle_cake");
public static final Key LIGHT_BLUE_CANDLE_CAKE = Key.of("minecraft:light_blue_candle_cake");
public static final Key BLUE_CANDLE_CAKE = Key.of("minecraft:blue_candle_cake");
public static final Key PURPLE_CANDLE_CAKE = Key.of("minecraft:purple_candle_cake");
public static final Key MAGENTA_CANDLE_CAKE = Key.of("minecraft:magenta_candle_cake");
public static final Key PINK_CANDLE_CAKE = Key.of("minecraft:pink_candle_cake");
// 潜影盒
public static final Key SHULKER_BOX = Key.of("minecraft:shulker_box");
public static final Key WHITE_SHULKER_BOX = Key.of("minecraft:white_shulker_box");
public static final Key LIGHT_GRAY_SHULKER_BOX = Key.of("minecraft:light_gray_shulker_box");
public static final Key GRAY_SHULKER_BOX = Key.of("minecraft:gray_shulker_box");
public static final Key BLACK_SHULKER_BOX = Key.of("minecraft:black_shulker_box");
public static final Key BROWN_SHULKER_BOX = Key.of("minecraft:brown_shulker_box");
public static final Key RED_SHULKER_BOX = Key.of("minecraft:red_shulker_box");
public static final Key ORANGE_SHULKER_BOX = Key.of("minecraft:orange_shulker_box");
public static final Key MAGENTA_SHULKER_BOX = Key.of("minecraft:magenta_shulker_box");
public static final Key LIGHT_BLUE_SHULKER_BOX = Key.of("minecraft:light_blue_shulker_box");
public static final Key YELLOW_SHULKER_BOX = Key.of("minecraft:yellow_shulker_box");
public static final Key LIME_SHULKER_BOX = Key.of("minecraft:lime_shulker_box");
public static final Key PINK_SHULKER_BOX = Key.of("minecraft:pink_shulker_box");
public static final Key GRAY_SHULKER_BOX = Key.of("minecraft:gray_shulker_box");
public static final Key LIGHT_GRAY_SHULKER_BOX = Key.of("minecraft:light_gray_shulker_box");
public static final Key CYAN_SHULKER_BOX = Key.of("minecraft:cyan_shulker_box");
public static final Key PURPLE_SHULKER_BOX = Key.of("minecraft:purple_shulker_box");
public static final Key BLUE_SHULKER_BOX = Key.of("minecraft:blue_shulker_box");
public static final Key BROWN_SHULKER_BOX = Key.of("minecraft:brown_shulker_box");
public static final Key GREEN_SHULKER_BOX = Key.of("minecraft:green_shulker_box");
public static final Key RED_SHULKER_BOX = Key.of("minecraft:red_shulker_box");
public static final Key BLACK_SHULKER_BOX = Key.of("minecraft:black_shulker_box");
public static final Key CYAN_SHULKER_BOX = Key.of("minecraft:cyan_shulker_box");
public static final Key LIGHT_BLUE_SHULKER_BOX = Key.of("minecraft:light_blue_shulker_box");
public static final Key BLUE_SHULKER_BOX = Key.of("minecraft:blue_shulker_box");
public static final Key PURPLE_SHULKER_BOX = Key.of("minecraft:purple_shulker_box");
public static final Key MAGENTA_SHULKER_BOX = Key.of("minecraft:magenta_shulker_box");
public static final Key PINK_SHULKER_BOX = Key.of("minecraft:pink_shulker_box");
// 按钮
public static final Key OAK_BUTTON = Key.of("minecraft:oak_button");
public static final Key SPRUCE_BUTTON = Key.of("minecraft:spruce_button");
public static final Key BIRCH_BUTTON = Key.of("minecraft:birch_button");
public static final Key JUNGLE_BUTTON = Key.of("minecraft:jungle_button");
public static final Key ACACIA_BUTTON = Key.of("minecraft:acacia_button");
public static final Key CHERRY_BUTTON = Key.of("minecraft:cherry_button");
public static final Key DARK_OAK_BUTTON = Key.of("minecraft:dark_oak_button");
public static final Key PALE_OAK_BUTTON = Key.of("minecraft:pale_oak_button");
public static final Key MANGROVE_BUTTON = Key.of("minecraft:mangrove_button");
public static final Key CHERRY_BUTTON = Key.of("minecraft:cherry_button");
public static final Key PALE_OAK_BUTTON = Key.of("minecraft:pale_oak_button");
public static final Key BAMBOO_BUTTON = Key.of("minecraft:bamboo_button");
public static final Key CRIMSON_BUTTON = Key.of("minecraft:crimson_button");
public static final Key WARPED_BUTTON = Key.of("minecraft:warped_button");
public static final Key STONE_BUTTON = Key.of("minecraft:stone_button");
public static final Key POLISHED_BLACKSTONE_BUTTON = Key.of("minecraft:polished_blackstone_button");
public static final Key OAK_TRAPDOOR = Key.of("minecraft:oak_trapdoor");
public static final Key SPRUCE_TRAPDOOR = Key.of("minecraft:spruce_trapdoor");
public static final Key BIRCH_TRAPDOOR = Key.of("minecraft:birch_trapdoor");
public static final Key JUNGLE_TRAPDOOR = Key.of("minecraft:jungle_trapdoor");
public static final Key ACACIA_TRAPDOOR = Key.of("minecraft:acacia_trapdoor");
public static final Key CHERRY_TRAPDOOR = Key.of("minecraft:cherry_trapdoor");
public static final Key DARK_OAK_TRAPDOOR = Key.of("minecraft:dark_oak_trapdoor");
public static final Key PALE_OAK_TRAPDOOR = Key.of("minecraft:pale_oak_trapdoor");
public static final Key MANGROVE_TRAPDOOR = Key.of("minecraft:mangrove_trapdoor");
public static final Key BAMBOO_TRAPDOOR = Key.of("minecraft:bamboo_trapdoor");
public static final Key CRIMSON_TRAPDOOR = Key.of("minecraft:crimson_trapdoor");
public static final Key WARPED_TRAPDOOR = Key.of("minecraft:warped_trapdoor");
public static final Key IRON_TRAPDOOR = Key.of("minecraft:iron_trapdoor");
// 门
public static final Key OAK_DOOR = Key.of("minecraft:oak_door");
public static final Key SPRUCE_DOOR = Key.of("minecraft:spruce_door");
public static final Key BIRCH_DOOR = Key.of("minecraft:birch_door");
public static final Key JUNGLE_DOOR = Key.of("minecraft:jungle_door");
public static final Key ACACIA_DOOR = Key.of("minecraft:acacia_door");
public static final Key CHERRY_DOOR = Key.of("minecraft:cherry_door");
public static final Key DARK_OAK_DOOR = Key.of("minecraft:dark_oak_door");
public static final Key PALE_OAK_DOOR = Key.of("minecraft:pale_oak_door");
public static final Key MANGROVE_DOOR = Key.of("minecraft:mangrove_door");
public static final Key CHERRY_DOOR = Key.of("minecraft:cherry_door");
public static final Key PALE_OAK_DOOR = Key.of("minecraft:pale_oak_door");
public static final Key BAMBOO_DOOR = Key.of("minecraft:bamboo_door");
public static final Key CRIMSON_DOOR = Key.of("minecraft:crimson_door");
public static final Key WARPED_DOOR = Key.of("minecraft:warped_door");
@@ -161,86 +182,98 @@ public final class BlockKeys {
public static final Key COPPER_DOOR = Key.of("minecraft:copper_door");
public static final Key EXPOSED_COPPER_DOOR = Key.of("minecraft:exposed_copper_door");
public static final Key OXIDIZED_COPPER_DOOR = Key.of("minecraft:oxidized_copper_door");
public static final Key WEATHERED_COPPER_DOOR = Key.of("minecraft:weathered_copper_door");
public static final Key OXIDIZED_COPPER_DOOR = Key.of("minecraft:oxidized_copper_door");
public static final Key WAXED_COPPER_DOOR = Key.of("minecraft:waxed_copper_door");
public static final Key WAXED_EXPOSED_COPPER_DOOR = Key.of("minecraft:waxed_exposed_copper_door");
public static final Key WAXED_OXIDIZED_COPPER_DOOR = Key.of("minecraft:waxed_oxidized_copper_door");
public static final Key WAXED_WEATHERED_COPPER_DOOR = Key.of("minecraft:waxed_weathered_copper_door");
public static final Key WAXED_OXIDIZED_COPPER_DOOR = Key.of("minecraft:waxed_oxidized_copper_door");
// 活板门
public static final Key OAK_TRAPDOOR = Key.of("minecraft:oak_trapdoor");
public static final Key SPRUCE_TRAPDOOR = Key.of("minecraft:spruce_trapdoor");
public static final Key BIRCH_TRAPDOOR = Key.of("minecraft:birch_trapdoor");
public static final Key JUNGLE_TRAPDOOR = Key.of("minecraft:jungle_trapdoor");
public static final Key ACACIA_TRAPDOOR = Key.of("minecraft:acacia_trapdoor");
public static final Key DARK_OAK_TRAPDOOR = Key.of("minecraft:dark_oak_trapdoor");
public static final Key MANGROVE_TRAPDOOR = Key.of("minecraft:mangrove_trapdoor");
public static final Key CHERRY_TRAPDOOR = Key.of("minecraft:cherry_trapdoor");
public static final Key PALE_OAK_TRAPDOOR = Key.of("minecraft:pale_oak_trapdoor");
public static final Key BAMBOO_TRAPDOOR = Key.of("minecraft:bamboo_trapdoor");
public static final Key CRIMSON_TRAPDOOR = Key.of("minecraft:crimson_trapdoor");
public static final Key WARPED_TRAPDOOR = Key.of("minecraft:warped_trapdoor");
public static final Key IRON_TRAPDOOR = Key.of("minecraft:iron_trapdoor");
public static final Key COPPER_TRAPDOOR = Key.of("minecraft:copper_trapdoor");
public static final Key EXPOSED_COPPER_TRAPDOOR = Key.of("minecraft:exposed_copper_trapdoor");
public static final Key OXIDIZED_COPPER_TRAPDOOR = Key.of("minecraft:oxidized_copper_trapdoor");
public static final Key WEATHERED_COPPER_TRAPDOOR = Key.of("minecraft:weathered_copper_trapdoor");
public static final Key OXIDIZED_COPPER_TRAPDOOR = Key.of("minecraft:oxidized_copper_trapdoor");
public static final Key WAXED_COPPER_TRAPDOOR = Key.of("minecraft:waxed_copper_trapdoor");
public static final Key WAXED_EXPOSED_COPPER_TRAPDOOR = Key.of("minecraft:waxed_exposed_copper_trapdoor");
public static final Key WAXED_OXIDIZED_COPPER_TRAPDOOR = Key.of("minecraft:waxed_oxidized_copper_trapdoor");
public static final Key WAXED_WEATHERED_COPPER_TRAPDOOR = Key.of("minecraft:waxed_weathered_copper_trapdoor");
public static final Key WAXED_OXIDIZED_COPPER_TRAPDOOR = Key.of("minecraft:waxed_oxidized_copper_trapdoor");
// 栅栏门
public static final Key OAK_FENCE_GATE = Key.of("minecraft:oak_fence_gate");
public static final Key SPRUCE_FENCE_GATE = Key.of("minecraft:spruce_fence_gate");
public static final Key BIRCH_FENCE_GATE = Key.of("minecraft:birch_fence_gate");
public static final Key JUNGLE_FENCE_GATE = Key.of("minecraft:jungle_fence_gate");
public static final Key ACACIA_FENCE_GATE = Key.of("minecraft:acacia_fence_gate");
public static final Key CHERRY_FENCE_GATE = Key.of("minecraft:cherry_fence_gate");
public static final Key DARK_OAK_FENCE_GATE = Key.of("minecraft:dark_oak_fence_gate");
public static final Key PALE_OAK_FENCE_GATE = Key.of("minecraft:pale_oak_fence_gate");
public static final Key MANGROVE_FENCE_GATE = Key.of("minecraft:mangrove_fence_gate");
public static final Key CHERRY_FENCE_GATE = Key.of("minecraft:cherry_fence_gate");
public static final Key PALE_OAK_FENCE_GATE = Key.of("minecraft:pale_oak_fence_gate");
public static final Key BAMBOO_FENCE_GATE = Key.of("minecraft:bamboo_fence_gate");
public static final Key CRIMSON_FENCE_GATE = Key.of("minecraft:crimson_fence_gate");
public static final Key WARPED_FENCE_GATE = Key.of("minecraft:warped_fence_gate");
// 告示牌
public static final Key OAK_SIGN = Key.of("minecraft:oak_sign");
public static final Key SPRUCE_SIGN = Key.of("minecraft:spruce_sign");
public static final Key ACACIA_SIGN = Key.of("minecraft:acacia_sign");
public static final Key BIRCH_SIGN = Key.of("minecraft:birch_sign");
public static final Key CHERRY_SIGN = Key.of("minecraft:cherry_sign");
public static final Key JUNGLE_SIGN = Key.of("minecraft:jungle_sign");
public static final Key ACACIA_SIGN = Key.of("minecraft:acacia_sign");
public static final Key DARK_OAK_SIGN = Key.of("minecraft:dark_oak_sign");
public static final Key PALE_OAK_SIGN = Key.of("minecraft:pale_oak_sign");
public static final Key MANGROVE_SIGN = Key.of("minecraft:mangrove_sign");
public static final Key CHERRY_SIGN = Key.of("minecraft:cherry_sign");
public static final Key PALE_OAK_SIGN = Key.of("minecraft:pale_oak_sign");
public static final Key BAMBOO_SIGN = Key.of("minecraft:bamboo_sign");
public static final Key WARPED_SIGN = Key.of("minecraft:warped_sign");
public static final Key CRIMSON_SIGN = Key.of("minecraft:crimson_sign");
public static final Key WARPED_SIGN = Key.of("minecraft:warped_sign");
// 靠墙告示牌
public static final Key OAK_WALL_SIGN = Key.of("minecraft:oak_wall_sign");
public static final Key SPRUCE_WALL_SIGN = Key.of("minecraft:spruce_wall_sign");
public static final Key BIRCH_WALL_SIGN = Key.of("minecraft:birch_wall_sign");
public static final Key ACACIA_WALL_SIGN = Key.of("minecraft:acacia_wall_sign");
public static final Key CHERRY_WALL_SIGN = Key.of("minecraft:cherry_wall_sign");
public static final Key JUNGLE_WALL_SIGN = Key.of("minecraft:jungle_wall_sign");
public static final Key ACACIA_WALL_SIGN = Key.of("minecraft:acacia_wall_sign");
public static final Key DARK_OAK_WALL_SIGN = Key.of("minecraft:dark_oak_wall_sign");
public static final Key PALE_OAK_WALL_SIGN = Key.of("minecraft:pale_oak_wall_sign");
public static final Key MANGROVE_WALL_SIGN = Key.of("minecraft:mangrove_wall_sign");
public static final Key CHERRY_WALL_SIGN = Key.of("minecraft:cherry_wall_sign");
public static final Key PALE_OAK_WALL_SIGN = Key.of("minecraft:pale_oak_wall_sign");
public static final Key BAMBOO_WALL_SIGN = Key.of("minecraft:bamboo_wall_sign");
public static final Key CRIMSON_WALL_SIGN = Key.of("minecraft:crimson_wall_sign");
public static final Key WARPED_WALL_SIGN = Key.of("minecraft:warped_wall_sign");
// 悬挂式告示牌
public static final Key OAK_HANGING_SIGN = Key.of("minecraft:oak_hanging_sign");
public static final Key SPRUCE_HANGING_SIGN = Key.of("minecraft:spruce_hanging_sign");
public static final Key BIRCH_HANGING_SIGN = Key.of("minecraft:birch_hanging_sign");
public static final Key ACACIA_HANGING_SIGN = Key.of("minecraft:acacia_hanging_sign");
public static final Key CHERRY_HANGING_SIGN = Key.of("minecraft:cherry_hanging_sign");
public static final Key JUNGLE_HANGING_SIGN = Key.of("minecraft:jungle_hanging_sign");
public static final Key ACACIA_HANGING_SIGN = Key.of("minecraft:acacia_hanging_sign");
public static final Key DARK_OAK_HANGING_SIGN = Key.of("minecraft:dark_oak_hanging_sign");
public static final Key MANGROVE_HANGING_SIGN = Key.of("minecraft:mangrove_hanging_sign");
public static final Key CHERRY_HANGING_SIGN = Key.of("minecraft:cherry_hanging_sign");
public static final Key PALE_OAK_HANGING_SIGN = Key.of("minecraft:pale_oak_hanging_sign");
public static final Key BAMBOO_HANGING_SIGN = Key.of("minecraft:bamboo_hanging_sign");
public static final Key CRIMSON_HANGING_SIGN = Key.of("minecraft:crimson_hanging_sign");
public static final Key WARPED_HANGING_SIGN = Key.of("minecraft:warped_hanging_sign");
public static final Key MANGROVE_HANGING_SIGN = Key.of("minecraft:mangrove_hanging_sign");
public static final Key BAMBOO_HANGING_SIGN = Key.of("minecraft:bamboo_hanging_sign");
// 靠墙悬挂式告示牌
public static final Key OAK_WALL_HANGING_SIGN = Key.of("minecraft:oak_wall_hanging_sign");
public static final Key SPRUCE_WALL_HANGING_SIGN = Key.of("minecraft:spruce_wall_hanging_sign");
public static final Key BIRCH_WALL_HANGING_SIGN = Key.of("minecraft:birch_wall_hanging_sign");
public static final Key ACACIA_WALL_HANGING_SIGN = Key.of("minecraft:acacia_wall_hanging_sign");
public static final Key CHERRY_WALL_HANGING_SIGN = Key.of("minecraft:cherry_wall_hanging_sign");
public static final Key JUNGLE_WALL_HANGING_SIGN = Key.of("minecraft:jungle_wall_hanging_sign");
public static final Key ACACIA_WALL_HANGING_SIGN = Key.of("minecraft:acacia_wall_hanging_sign");
public static final Key DARK_OAK_WALL_HANGING_SIGN = Key.of("minecraft:dark_oak_wall_hanging_sign");
public static final Key PALE_OAK_WALL_HANGING_SIGN = Key.of("minecraft:pale_oak_wall_hanging_sign");
public static final Key MANGROVE_WALL_HANGING_SIGN = Key.of("minecraft:mangrove_wall_hanging_sign");
public static final Key CHERRY_WALL_HANGING_SIGN = Key.of("minecraft:cherry_wall_hanging_sign");
public static final Key PALE_OAK_WALL_HANGING_SIGN = Key.of("minecraft:pale_oak_wall_hanging_sign");
public static final Key BAMBOO_WALL_HANGING_SIGN = Key.of("minecraft:bamboo_wall_hanging_sign");
public static final Key CRIMSON_WALL_HANGING_SIGN = Key.of("minecraft:crimson_wall_hanging_sign");
public static final Key WARPED_WALL_HANGING_SIGN = Key.of("minecraft:warped_wall_hanging_sign");
public static final Key BAMBOO_WALL_HANGING_SIGN = Key.of("minecraft:bamboo_wall_hanging_sign");
public static final Key CACTUS = Key.of("minecraft:cactus");
}

View File

@@ -81,4 +81,5 @@ public class EntityTypeKeys {
public static final Key FURNACE_MINECART = Key.of("minecraft:furnace_minecart");
public static final Key HOPPER_MINECART = Key.of("minecraft:hopper_minecart");
public static final Key COMMAND_BLOCK_MINECART = Key.of("minecraft:command_block_minecart");
public static final Key SPAWNER_MINECART = Key.of("minecraft:spawner_minecart");
}

View File

@@ -43,24 +43,26 @@ public final class ItemKeys {
public static final Key LIGHT = Key.of("minecraft:light");
public static final Key GLOWSTONE = Key.of("minecraft:glowstone");
public static final Key SADDLE = Key.of("minecraft:saddle");
public static final Key HARNESS = Key.of("minecraft:harness");
public static final Key FIREWORK_STAR = Key.of("minecraft:firework_star");
public static final Key ENDER_EYE = Key.of("minecraft:ender_eye");
public static final Key END_CRYSTAL = Key.of("minecraft:end_crystal");
public static final Key WHITE_DYE = Key.of("minecraft:white_dye");
public static final Key LIGHT_GRAY_DYE = Key.of("minecraft:light_gray_dye");
public static final Key GRAY_DYE = Key.of("minecraft:gray_dye");
public static final Key BLACK_DYE = Key.of("minecraft:black_dye");
public static final Key BROWN_DYE = Key.of("minecraft:brown_dye");
public static final Key RED_DYE = Key.of("minecraft:red_dye");
public static final Key ORANGE_DYE = Key.of("minecraft:orange_dye");
public static final Key MAGENTA_DYE = Key.of("minecraft:magenta_dye");
public static final Key LIGHT_BLUE_DYE = Key.of("minecraft:light_blue_dye");
public static final Key YELLOW_DYE = Key.of("minecraft:yellow_dye");
public static final Key LIME_DYE = Key.of("minecraft:lime_dye");
public static final Key PINK_DYE = Key.of("minecraft:pink_dye");
public static final Key GRAY_DYE = Key.of("minecraft:gray_dye");
public static final Key LIGHT_GRAY_DYE = Key.of("minecraft:light_gray_dye");
public static final Key CYAN_DYE = Key.of("minecraft:cyan_dye");
public static final Key PURPLE_DYE = Key.of("minecraft:purple_dye");
public static final Key BLUE_DYE = Key.of("minecraft:blue_dye");
public static final Key BROWN_DYE = Key.of("minecraft:brown_dye");
public static final Key GREEN_DYE = Key.of("minecraft:green_dye");
public static final Key RED_DYE = Key.of("minecraft:red_dye");
public static final Key BLACK_DYE = Key.of("minecraft:black_dye");
public static final Key FIREWORK_STAR = Key.of("minecraft:firework_star");
public static final Key CYAN_DYE = Key.of("minecraft:cyan_dye");
public static final Key LIGHT_BLUE_DYE = Key.of("minecraft:light_blue_dye");
public static final Key BLUE_DYE = Key.of("minecraft:blue_dye");
public static final Key PURPLE_DYE = Key.of("minecraft:purple_dye");
public static final Key MAGENTA_DYE = Key.of("minecraft:magenta_dye");
public static final Key PINK_DYE = Key.of("minecraft:pink_dye");
public static final Key[] AXES = new Key[] {
WOODEN_AXE, STONE_AXE, IRON_AXE, GOLDEN_AXE, DIAMOND_AXE, NETHERITE_AXE
@@ -69,4 +71,9 @@ public final class ItemKeys {
public static final Key[] WATER_BUCKETS = new Key[] {
WATER_BUCKET, COD_BUCKET, SALMON_BUCKET, TROPICAL_FISH_BUCKET, TADPOLE_BUCKET, PUFFERFISH_BUCKET, AXOLOTL_BUCKET
};
public static final Key[] DYES = new Key[] {
WHITE_DYE, LIGHT_GRAY_DYE, GRAY_DYE, BLACK_DYE, BROWN_DYE, RED_DYE, ORANGE_DYE, YELLOW_DYE, LIME_DYE,
GREEN_DYE, CYAN_DYE, LIGHT_BLUE_DYE, BLUE_DYE, PURPLE_DYE, MAGENTA_DYE, PINK_DYE
};
}

View File

@@ -57,6 +57,21 @@ public record Key(String namespace, String value) {
return this.value.equals(key.value()) && this.namespace.equals(key.namespace());
}
public boolean in(Key... items) {
if (items == null) {
return false;
}
for (Key key : items) {
if (key == this) {
return true;
}
if (this.value.equals(key.value()) && this.namespace.equals(key.namespace())) {
return true;
}
}
return false;
}
@Override
public @NotNull String toString() {
return asString();