diff --git a/modules/Movecraft/src/main/java/net/countercraft/movecraft/listener/BlockListener.java b/modules/Movecraft/src/main/java/net/countercraft/movecraft/listener/BlockListener.java index 927cd34d4..5853e1b1b 100644 --- a/modules/Movecraft/src/main/java/net/countercraft/movecraft/listener/BlockListener.java +++ b/modules/Movecraft/src/main/java/net/countercraft/movecraft/listener/BlockListener.java @@ -23,10 +23,10 @@ import net.countercraft.movecraft.craft.CraftManager; import net.countercraft.movecraft.craft.PilotedCraft; import net.countercraft.movecraft.craft.PlayerCraft; -import net.countercraft.movecraft.localisation.I18nSupport; +import net.countercraft.movecraft.craft.type.CraftType; import net.countercraft.movecraft.util.MathUtils; import net.countercraft.movecraft.util.Tags; -import org.bukkit.Bukkit; +import net.countercraft.movecraft.util.hitboxes.BitmapHitBox; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; @@ -47,6 +47,7 @@ import org.bukkit.event.entity.ItemSpawnEvent; import org.bukkit.event.inventory.InventoryMoveItemEvent; import org.bukkit.material.Attachable; +import org.bukkit.util.Vector; import org.jetbrains.annotations.NotNull; public class BlockListener implements Listener { @@ -154,9 +155,19 @@ public void onPistonEvent(BlockPistonExtendEvent event) { Block block = event.getBlock(); CraftManager.getInstance().getCraftsInWorld(block.getWorld()); for (Craft tcraft : CraftManager.getInstance().getCraftsInWorld(block.getWorld())) { - MovecraftLocation mloc = new MovecraftLocation(block.getX(), block.getY(), block.getZ()); - if (MathUtils.locIsNearCraftFast(tcraft, mloc) && tcraft.getCruising() && !tcraft.isNotProcessing()) { + if(tcraft == null || !MathUtils.locationInHitBox(tcraft.getHitBox(), block.getLocation())) + continue; + + if (tcraft.getCruising() && !tcraft.isNotProcessing()) { event.setCancelled(true); + } + else if(tcraft.getType().getBoolProperty(CraftType.MERGE_PISTON_EXTENSIONS)){ + BitmapHitBox hitBox = new BitmapHitBox(); + for (Block b : event.getBlocks()) { + Vector dir = event.getDirection().getDirection(); + hitBox.add(new MovecraftLocation(b.getX() + dir.getBlockX(), b.getY() + dir.getBlockY(), b.getZ() + dir.getBlockZ())); + } + tcraft.setHitBox(tcraft.getHitBox().union(hitBox)); return; } } diff --git a/modules/Movecraft/src/main/resources/types/Elevator.craft b/modules/Movecraft/src/main/resources/types/Elevator.craft index 33a94d6b5..ed4191ee2 100644 --- a/modules/Movecraft/src/main/resources/types/Elevator.craft +++ b/modules/Movecraft/src/main/resources/types/Elevator.craft @@ -85,4 +85,4 @@ detectionMultiplier: 30.0 underwaterDetectionMultiplier: 3.0 speed: 1.0 tryNudge: false -sinkPercent: 99.0 \ No newline at end of file +sinkPercent: 99.0 diff --git a/modules/Movecraft/src/main/resources/types/Submarine.craft b/modules/Movecraft/src/main/resources/types/Submarine.craft index 66469fa26..8b89d57c7 100644 --- a/modules/Movecraft/src/main/resources/types/Submarine.craft +++ b/modules/Movecraft/src/main/resources/types/Submarine.craft @@ -115,4 +115,4 @@ flyblocks: - 1.0 iron_block: - 15.0 - - 100.0 \ No newline at end of file + - 100.0 diff --git a/modules/Movecraft/src/main/resources/types/Turret.craft b/modules/Movecraft/src/main/resources/types/Turret.craft index f4cf07941..1a386a1cd 100644 --- a/modules/Movecraft/src/main/resources/types/Turret.craft +++ b/modules/Movecraft/src/main/resources/types/Turret.craft @@ -75,4 +75,4 @@ allowHorizontalMovement: false allowVerticalMovement: false speed: 1.0 tryNudge: false -sinkPercent: 99.0 \ No newline at end of file +sinkPercent: 99.0 diff --git a/modules/api/src/main/java/net/countercraft/movecraft/craft/type/CraftType.java b/modules/api/src/main/java/net/countercraft/movecraft/craft/type/CraftType.java index f9d7cd468..8f0c67580 100644 --- a/modules/api/src/main/java/net/countercraft/movecraft/craft/type/CraftType.java +++ b/modules/api/src/main/java/net/countercraft/movecraft/craft/type/CraftType.java @@ -185,6 +185,7 @@ final public class CraftType { public static final NamespacedKey GEAR_SHIFTS_AFFECT_CRUISE_SKIP_BLOCKS = buildKey( "gear_shifts_affect_cruise_skip_blocks"); public static final NamespacedKey RELEASE_TIMEOUT = buildKey("release_timeout"); + public static final NamespacedKey MERGE_PISTON_EXTENSIONS = buildKey("merge_piston_extensions"); //endregion @Contract("_ -> new") @@ -558,6 +559,7 @@ else if (o instanceof Integer) type -> false )); registerProperty(new IntegerProperty("releaseTimeout", RELEASE_TIMEOUT, type -> 30)); + registerProperty(new BooleanProperty("mergePistonExtensions", MERGE_PISTON_EXTENSIONS, type -> false)); /* Craft type transforms */ // Convert speed to TICK_COOLDOWN