From b8c74db0f3ac69d2a9e5b6f614193f3cd00d8fe8 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Thu, 5 Oct 2023 21:21:24 +0200 Subject: [PATCH] Fix PlaceItemUtils Signed-off-by: yoyosource --- .../bausystem/utils/PlaceItemUtils.java | 44 ++++++++++++++++--- 1 file changed, 38 insertions(+), 6 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/utils/PlaceItemUtils.java b/BauSystem_Main/src/de/steamwar/bausystem/utils/PlaceItemUtils.java index 5631a373..df31c32f 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/utils/PlaceItemUtils.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/utils/PlaceItemUtils.java @@ -39,10 +39,47 @@ import org.bukkit.util.RayTraceResult; import org.bukkit.util.Vector; import java.util.*; +import java.util.stream.Collectors; @UtilityClass public class PlaceItemUtils { + // https://github.com/Articdive/ArticData/blob/1.20.1/1_20_1_tags/1_20_1_block_tags.json + // #minecraft:replaceable + private static final Set replaceables; + + static { + replaceables = new HashSet<>(Arrays.asList( + "minecraft:air", + "minecraft:water", + "minecraft:lava", + "minecraft:grass", + "minecraft:fern", + "minecraft:dead_bush", + "minecraft:seagrass", + "minecraft:tall_seagrass", + "minecraft:fire", + "minecraft:soul_fire", + "minecraft:snow", + "minecraft:vine", + "minecraft:glow_lichen", + "minecraft:light", + "minecraft:tall_grass", + "minecraft:large_fern", + "minecraft:structure_void", + "minecraft:void_air", + "minecraft:cave_air", + "minecraft:bubble_column", + "minecraft:warped_roots", + "minecraft:nether_sprouts", + "minecraft:crimson_roots", + "minecraft:hanging_roots")) + .stream() + .map(s -> s.substring(10)) + .map(String::toUpperCase) + .collect(Collectors.toSet()); + } + private static final Map ITEM_MATERIAL_TO_BLOCK_MATERIAL = new HashMap<>(); private static final Map BLOCK_MATERIAL_TO_WALL_BLOCK_MATERIAL = new HashMap<>(); @@ -488,13 +525,8 @@ public class PlaceItemUtils { private boolean canPlace(Block block, BlockData blockData, boolean force) { if (!force && !block.canPlace(blockData)) return false; - if (block.getType().name().equals("LIGHT")) return true; if (block.getType().isSolid()) return false; - if (block.getType() == Material.LADDER) return false; - if (block.getType() == Material.SCAFFOLDING) return false; - if (block.getType() == Material.LEVER) return false; - if (block.getType().name().endsWith("_BUTTON")) return false; - return block.getPistonMoveReaction() == PistonMoveReaction.BREAK || block.isEmpty(); + return replaceables.contains(block.getType().name()); } @AllArgsConstructor