From b2bb67d2667f0bcda3fd02cceabde5de4508ac95 Mon Sep 17 00:00:00 2001 From: TiagoFar78 Date: Sat, 8 Jun 2024 18:11:46 +0100 Subject: [PATCH] made trap doors spawn on upper half of block --- .../prisonescape/bukkit/BukkitWorldEditor.java | 4 ---- .../prisonescape/game/prisonbuilding/Vent.java | 17 +++++++++++++++-- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/main/java/net/tiagofar78/prisonescape/bukkit/BukkitWorldEditor.java b/src/main/java/net/tiagofar78/prisonescape/bukkit/BukkitWorldEditor.java index 6892787a..15f95bd8 100644 --- a/src/main/java/net/tiagofar78/prisonescape/bukkit/BukkitWorldEditor.java +++ b/src/main/java/net/tiagofar78/prisonescape/bukkit/BukkitWorldEditor.java @@ -146,10 +146,6 @@ public static void fillWithBars(PrisonEscapeLocation upperCorner, PrisonEscapeLo fill(upperCorner, lowerCorner, Material.IRON_BARS); } - public static void putVent(PrisonEscapeLocation location) { - WORLD.getBlockAt(location.getX(), location.getY(), location.getZ()).setType(Material.IRON_TRAPDOOR); - } - // ######################################## // # Util # // ######################################## diff --git a/src/main/java/net/tiagofar78/prisonescape/game/prisonbuilding/Vent.java b/src/main/java/net/tiagofar78/prisonescape/game/prisonbuilding/Vent.java index fe0d8560..b5c72042 100644 --- a/src/main/java/net/tiagofar78/prisonescape/game/prisonbuilding/Vent.java +++ b/src/main/java/net/tiagofar78/prisonescape/game/prisonbuilding/Vent.java @@ -4,6 +4,12 @@ import net.tiagofar78.prisonescape.items.ToolItem; import net.tiagofar78.prisonescape.items.WrenchItem; +import org.bukkit.Material; +import org.bukkit.World; +import org.bukkit.block.Block; +import org.bukkit.block.data.Bisected.Half; +import org.bukkit.block.data.type.TrapDoor; + public class Vent extends Obstacle { private PrisonEscapeLocation _location; @@ -24,11 +30,18 @@ public boolean contains(PrisonEscapeLocation location) { @Override public void removeFromWorld() { - BukkitWorldEditor.clear(_location, _location); + World world = BukkitWorldEditor.getWorld(); + world.getBlockAt(_location.getX(), _location.getY(), _location.getZ()).setType(Material.AIR); } public void generate() { - BukkitWorldEditor.putVent(_location); + World world = BukkitWorldEditor.getWorld(); + Block block = world.getBlockAt(_location.getX(), _location.getY(), _location.getZ()); + block.setType(Material.IRON_TRAPDOOR); + TrapDoor trapdoor = (TrapDoor) block.getBlockData(); + trapdoor.setHalf(Half.TOP); + + block.setBlockData(trapdoor); } }