Skip to content

Commit

Permalink
MaterialDirectional: pointed dripstone support
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Nov 13, 2021
1 parent 35ccf40 commit f750031
Showing 1 changed file with 32 additions and 4 deletions.
@@ -1,5 +1,7 @@
package com.denizenscript.denizen.objects.properties.material;

import com.denizenscript.denizen.nms.NMSHandler;
import com.denizenscript.denizen.nms.NMSVersion;
import com.denizenscript.denizen.objects.MaterialTag;
import com.denizenscript.denizen.utilities.debugging.Debug;
import com.denizenscript.denizencore.objects.core.ElementTag;
Expand All @@ -11,6 +13,7 @@
import org.bukkit.Axis;
import org.bukkit.block.BlockFace;
import org.bukkit.block.data.*;
import org.bukkit.block.data.type.PointedDripstone;
import org.bukkit.util.Vector;

public class MaterialDirectional implements Property {
Expand All @@ -24,7 +27,8 @@ public static boolean describes(ObjectTag material) {
return false;
}
BlockData data = mat.getModernData();
if (!(data instanceof Directional || data instanceof Orientable || data instanceof Rotatable || data instanceof Rail)) {
if (!(data instanceof Directional || data instanceof Orientable || data instanceof Rotatable || data instanceof Rail
|| (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_17) && data instanceof PointedDripstone))) {
return false;
}
return true;
Expand Down Expand Up @@ -77,7 +81,12 @@ else if (material.isDirectional()) {
toReturn.add(face.name());
}
}
else {
else if (material.isDripstone()) {
for (BlockFace face : material.getDripstone().getVerticalDirections()) {
toReturn.add(face.name());
}
}
else { // applies to rotatable
return null;
}
return toReturn;
Expand Down Expand Up @@ -136,9 +145,13 @@ else if (isRail()) {
}
return null; // Unreachable.
}
else {
else if (isDirectional()) {
return getDirectional().getFacing().getDirection();
}
else if (isDripstone()) {
return getDripstone().getVerticalDirection().getDirection();
}
return null; // Unreachable.
}

public String getDirectionName() {
Expand All @@ -151,9 +164,13 @@ else if (isRotatable()) {
else if (isRail()) {
return getRail().getShape().name();
}
else {
else if (isDirectional()) {
return getDirectional().getFacing().name();
}
else if (isDripstone()) {
return getDripstone().getVerticalDirection().name();
}
return null; // Unreachable
}

public boolean isOrientable() {
Expand All @@ -168,6 +185,10 @@ public boolean isDirectional() {
return material.getModernData() instanceof Directional;
}

public boolean isDripstone() {
return NMSHandler.getVersion().isAtLeast(NMSVersion.v1_17) && material.getModernData() instanceof PointedDripstone;
}

public boolean isRail() {
return material.getModernData() instanceof Rail;
}
Expand All @@ -184,6 +205,10 @@ public Directional getDirectional() {
return (Directional) material.getModernData();
}

public PointedDripstone getDripstone() {
return (PointedDripstone) material.getModernData();
}

public Rail getRail() {
return (Rail) material.getModernData();
}
Expand Down Expand Up @@ -229,6 +254,9 @@ else if (isRail()) {
else if (isDirectional()) {
getDirectional().setFacing(face);
}
else if (isDripstone()) {
getDripstone().setVerticalDirection(face);
}
}

@Override
Expand Down

0 comments on commit f750031

Please sign in to comment.