/** * @param sign treated as sign post if it is such, or else assumed to be a wall sign (i.e., * if you ask about a stone block, it's considered a wall * sign). * @return the cardinal or ordinal direction to a player's right they face the sign to read it; if the sign is * oriented in a further direction, the * result is rounded to the nearest ordinal direction. */ public static Direction getLeft(Location<World> sign) { Direction front = getFront(sign); if (front == null) return Direction.NONE; return getCounterClockWise(front); }
/** * @param sign treated as sign post if it is such, or else assumed to be a wall sign (i.e., * if you ask about a stone block, it's considered a wall * sign). * @return the cardinal or ordinal direction to a player's left as they face the sign to read it; if the sign is * oriented in a further direction, * the result is rounded to the nearest ordinal direction. */ public static Direction getRight(Location<World> sign) { Direction front = getFront(sign); if (front == null) return Direction.NONE; return getClockWise(front); }
public static Location<World> getFrontBlock(Location<World> sign) { return sign.getRelative(getFront(sign)); }
/** * @param sign treated as sign post if it is such, or else assumed to be a wall sign (i.e., * if you ask about a stone block, it's considered a wall * sign). * @return the blank side of the sign opposite the text. In the case of a wall sign, * the block in this direction is the block to which the sign is * attached. This is also the direction a player would be facing when reading the sign; see {@link #getFront(Location)}. */ public static Direction getBack(Location<World> sign) { Direction front = getFront(sign); if (front == null) return Direction.NONE; return front.getOpposite(); }
private boolean hasSign(Location<World> location, List<Location<World>> searched, Location<World> original) { boolean found = false; for (Direction face : BlockUtil.getDirectFaces()) { Location<World> otherBlock = location.getRelative(face); if (searched.contains(otherBlock)) continue; searched.add(otherBlock); if (found) break; if (location.getPosition().distanceSquared(original.getPosition()) > Math.pow(maxSignDistance.getValue(), 2)) continue; if (SignUtil.isSign(otherBlock) && SignUtil.getFront(otherBlock) == face) { found = true; break; } if (Objects.equals(location.getBlockType(), otherBlock.getBlockType())) { found = hasSign(otherBlock, searched, original); } } return found; }
@Override public void impact(Minecart minecart, CartMechanismBlocks blocks, boolean minor) { super.impact(minecart, blocks, minor); if (minecart.getPassengers().isEmpty() || isActive(blocks) == TernaryState.FALSE) { return; } Location<World> teleportTarget = null; if (blocks.matches("eject")) { teleportTarget = blocks.getRail().getRelative(SignUtil.getFront(blocks.getSign())); } List<Entity> passengers = minecart.getPassengers(); minecart.clearPassengers(); if (teleportTarget != null) { for (Entity passenger : passengers) { passenger.setLocationSafely(teleportTarget); } } }
@Override public Location<World> getPinLocation(int id, IC ic) { switch(id) { case 0: return ic.getBlock().getRelative(SignUtil.getFront(ic.getBlock())); case 1: return ic.getBlock().getRelative(SignUtil.getBack(ic.getBlock())).getRelative(SignUtil.getBack(ic.getBlock())); default: return null; } }
@Override public Location<World> getPinLocation(int id, IC ic) { switch(id) { case 0: return ic.getBlock().getRelative(SignUtil.getFront(ic.getBlock())); case 1: return ic.getBlock().getRelative(SignUtil.getLeft(ic.getBlock())); case 2: return ic.getBlock().getRelative(SignUtil.getRight(ic.getBlock())); case 3: return ic.getBlock().getRelative(SignUtil.getBack(ic.getBlock())).getRelative(SignUtil.getBack(ic.getBlock())); default: return null; } }
@Override public Location<World> getPinLocation(int id, IC ic) { switch(id) { case 0: return ic.getBlock().getRelative(SignUtil.getFront(ic.getBlock())); case 1: return ic.getBlock().getRelative(SignUtil.getBack(ic.getBlock())).getRelative(SignUtil.getBack(ic.getBlock())).getRelative(SignUtil.getBack(ic.getBlock())); case 2: return ic.getBlock().getRelative(SignUtil.getBack(ic.getBlock())).getRelative(SignUtil.getBack(ic.getBlock())).getRelative(SignUtil.getLeft(ic.getBlock())); case 3: return ic.getBlock().getRelative(SignUtil.getBack(ic.getBlock())).getRelative(SignUtil.getBack(ic.getBlock())).getRelative(SignUtil.getRight(ic.getBlock())); default: return null; } } }
@Override public Location<World> getPinLocation(int id, IC ic) { switch(id) { case 0: return ic.getBlock().getRelative(SignUtil.getFront(ic.getBlock())); case 1: return ic.getBlock().getRelative(SignUtil.getLeft(ic.getBlock())); case 2: return ic.getBlock().getRelative(SignUtil.getRight(ic.getBlock())); case 3: return ic.getBlock().getRelative(SignUtil.getBack(ic.getBlock())).getRelative(SignUtil.getBack(ic.getBlock())).getRelative(SignUtil.getBack(ic.getBlock())); case 4: return ic.getBlock().getRelative(SignUtil.getBack(ic.getBlock())).getRelative(SignUtil.getBack(ic.getBlock())).getRelative(SignUtil.getLeft(ic.getBlock())); case 5: return ic.getBlock().getRelative(SignUtil.getBack(ic.getBlock())).getRelative(SignUtil.getBack(ic.getBlock())).getRelative(SignUtil.getRight(ic.getBlock())); default: return null; } }
@Override public Location<World> getPinLocation(int id, IC ic) { switch(id) { case 0: return ic.getBlock().getRelative(SignUtil.getFront(ic.getBlock())); case 1: return ic.getBlock().getRelative(SignUtil.getBack(ic.getBlock())).getRelative(SignUtil.getBack(ic.getBlock())).getRelative(SignUtil.getBack(ic.getBlock())).getRelative(SignUtil.getBack(ic.getBlock())); case 2: return ic.getBlock().getRelative(SignUtil.getBack(ic.getBlock())).getRelative(SignUtil.getBack(ic.getBlock())).getRelative(SignUtil.getLeft(ic.getBlock())); case 3: return ic.getBlock().getRelative(SignUtil.getBack(ic.getBlock())).getRelative(SignUtil.getBack(ic.getBlock())).getRelative(SignUtil.getRight(ic.getBlock())); case 4: return ic.getBlock().getRelative(SignUtil.getBack(ic.getBlock())).getRelative(SignUtil.getBack(ic.getBlock())).getRelative(SignUtil.getBack(ic.getBlock())).getRelative(SignUtil.getLeft(ic.getBlock())); case 5: return ic.getBlock().getRelative(SignUtil.getBack(ic.getBlock())).getRelative(SignUtil.getBack(ic.getBlock())).getRelative(SignUtil.getBack(ic.getBlock())).getRelative(SignUtil.getRight(ic.getBlock())); default: return null; } } }