use of org.bukkit.block.data.type.PointedDripstone in project Denizen-For-Bukkit by DenizenScript.
the class MaterialDirectional method setFacing.
public void setFacing(BlockFace face) {
if (isOrientable()) {
Axis axis;
Vector vec = face.getDirection();
if (Math.abs(vec.getX()) >= 0.5) {
axis = Axis.X;
} else if (Math.abs(vec.getY()) >= 0.5) {
axis = Axis.Y;
} else {
axis = Axis.Z;
}
getOrientable().setAxis(axis);
} else if (isRotatable()) {
getRotatable().setRotation(face);
} else if (isRail()) {
switch(face) {
case EAST:
case WEST:
getRail().setShape(Rail.Shape.EAST_WEST);
case NORTH:
case SOUTH:
getRail().setShape(Rail.Shape.NORTH_SOUTH);
case NORTH_EAST:
getRail().setShape(Rail.Shape.NORTH_EAST);
case NORTH_WEST:
getRail().setShape(Rail.Shape.NORTH_WEST);
case SOUTH_EAST:
getRail().setShape(Rail.Shape.SOUTH_EAST);
case SOUTH_WEST:
getRail().setShape(Rail.Shape.SOUTH_WEST);
default:
Debug.echoError("Unsupported rail direction '" + face + "'.");
}
} else if (isDirectional()) {
getDirectional().setFacing(face);
} else if (isDripstone()) {
// TODO: 1.17
((PointedDripstone) material.getModernData()).setVerticalDirection(face);
}
}
use of org.bukkit.block.data.type.PointedDripstone in project Denizen-For-Bukkit by DenizenScript.
the class MaterialDirectional method registerTags.
public static void registerTags() {
// <--[tag]
// @attribute <MaterialTag.valid_directions>
// @returns ListTag
// @mechanism MaterialTag.direction
// @group properties
// @description
// Returns a list of directions that are valid for a directional material.
// See also <@link tag MaterialTag.direction>
// -->
PropertyParser.<MaterialDirectional, ListTag>registerStaticTag(ListTag.class, "valid_directions", (attribute, material) -> {
ListTag toReturn = new ListTag();
if (material.isOrientable()) {
for (Axis axis : material.getOrientable().getAxes()) {
toReturn.add(axis.name());
}
} else if (material.isRail()) {
for (Rail.Shape shape : material.getRail().getShapes()) {
toReturn.add(shape.name());
}
} else if (material.isDirectional()) {
for (BlockFace face : material.getDirectional().getFaces()) {
toReturn.add(face.name());
}
} else if (material.isRotatable()) {
for (BlockFace face : rotatableValidFaces) {
toReturn.add(face.name());
}
} else if (material.isDripstone()) {
for (BlockFace face : ((PointedDripstone) material.material.getModernData()).getVerticalDirections()) {
// TODO: 1.17
toReturn.add(face.name());
}
} else if (material.isJigsaw()) {
for (Jigsaw.Orientation orientation : Jigsaw.Orientation.values()) {
toReturn.add(orientation.name());
}
} else {
// Unreachable
return null;
}
return toReturn;
});
// <--[tag]
// @attribute <MaterialTag.direction>
// @returns ElementTag
// @mechanism MaterialTag.direction
// @group properties
// @description
// Returns the current facing direction for a directional material (like a door or a bed).
// This includes materials that Spigot classifies as "directional", "orientable", or "rotatable", as well as rails, dripstone, and jigsaw blocks.
// Output is a direction name like "NORTH", or an axis like "X", or a rail direction like "ASCENDING_NORTH".
// -->
PropertyParser.<MaterialDirectional, ElementTag>registerStaticTag(ElementTag.class, "direction", (attribute, material) -> {
return new ElementTag(material.getDirectionName());
});
}
use of org.bukkit.block.data.type.PointedDripstone in project Denizen-For-Bukkit by DenizenScript.
the class MaterialDirectional method describes.
public static boolean describes(ObjectTag material) {
if (!(material instanceof MaterialTag)) {
return false;
}
MaterialTag mat = (MaterialTag) material;
if (!mat.hasModernData()) {
return false;
}
BlockData data = mat.getModernData();
return data instanceof Directional || data instanceof Orientable || data instanceof Rotatable || data instanceof Rail || data instanceof Jigsaw || (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_17) && data instanceof PointedDripstone);
}
Aggregations