Skip to content

Commit

Permalink
Paste water at spawn_here sign location if sign is waterlogged
Browse files Browse the repository at this point in the history
Prevents the air block around the user when they spawn.
  • Loading branch information
tastybento committed Jan 25, 2025
1 parent 3c9e538 commit 8d89d62
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions src/main/java/world/bentobox/bentobox/util/DefaultPasteUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.bukkit.block.CreatureSpawner;
import org.bukkit.block.Sign;
import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.Waterlogged;
import org.bukkit.block.data.type.WallSign;
import org.bukkit.block.sign.Side;
import org.bukkit.block.sign.SignSide;
Expand All @@ -26,6 +27,7 @@
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.spawner.TrialSpawnerConfiguration;

import world.bentobox.bentobox.BentoBox;
import world.bentobox.bentobox.api.localization.TextVariables;
Expand Down Expand Up @@ -141,6 +143,9 @@ else if (bs instanceof InventoryHolder holder) {
else if (bs instanceof CreatureSpawner spawner) {
setSpawner(spawner, bpBlock.getCreatureSpawner());
}
else if (bs instanceof TrialSpawnerConfiguration spawner) {
bpBlock.getTrialSpawner().configTrialSpawner(spawner);
}
// Banners
else if (bs instanceof Banner banner && bpBlock.getBannerPatterns() != null) {
bpBlock.getBannerPatterns().removeIf(Objects::isNull);
Expand Down Expand Up @@ -261,21 +266,20 @@ static boolean spawnBlueprintEntity(BlueprintEntity k, Location location, Island
* @param bpSign - BlueprintBlock that is the sign
* @param side - the side being written
*/
@SuppressWarnings("deprecation")
public static void writeSign(Island island, final Block block, BlueprintBlock bpSign, Side side) {
List<String> lines = bpSign.getSignLines(side);
boolean glow = bpSign.isGlowingText(side);

BlockFace bf;
if (block.getType().name().contains("WALL_SIGN")) {
WallSign wallSign = (WallSign) block.getBlockData();
bf = wallSign.getFacing();
} else {
org.bukkit.block.data.type.Sign sign = (org.bukkit.block.data.type.Sign) block.getBlockData();
bf = sign.getRotation();
}
BlockData bd = block.getBlockData();
BlockFace bf = (bd instanceof WallSign ws) ? ws.getFacing()
: ((org.bukkit.block.data.type.Sign) bd).getRotation();
// Handle spawn sign
if (side == Side.FRONT && island != null && !lines.isEmpty() && lines.get(0).equalsIgnoreCase(TextVariables.SPAWN_HERE)) {
block.setType(Material.AIR);
if (bd instanceof Waterlogged wl && wl.isWaterlogged()) {
block.setType(Material.WATER);
} else {
block.setType(Material.AIR);
}
// Orient to face same direction as sign
Location spawnPoint = new Location(block.getWorld(), block.getX() + 0.5D, block.getY(),
block.getZ() + 0.5D, Util.blockFaceToFloat(bf.getOppositeFace()), 30F);
Expand Down

0 comments on commit 8d89d62

Please sign in to comment.