From 33be1ca501c0bc84432dc60e5eb312d1f41ead2e Mon Sep 17 00:00:00 2001 From: asofold Date: Wed, 20 Mar 2013 06:11:57 +0100 Subject: [PATCH] Add RAILS flag. --- .../utilities/BlockProperties.java | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/NCPCompat/src/main/java/fr/neatmonster/nocheatplus/utilities/BlockProperties.java b/NCPCompat/src/main/java/fr/neatmonster/nocheatplus/utilities/BlockProperties.java index c5cd0102..de465ffb 100644 --- a/NCPCompat/src/main/java/fr/neatmonster/nocheatplus/utilities/BlockProperties.java +++ b/NCPCompat/src/main/java/fr/neatmonster/nocheatplus/utilities/BlockProperties.java @@ -287,7 +287,10 @@ public class BlockProperties { public static final long F_XZ100 = 0x800; /** This flag indicates that even though a passable workaround, everything above passable height is still ground. */ - public static final long F_GROUND_HEIGHT = 0x1000; + public static final long F_GROUND_HEIGHT = 0x1000; + + /** All rail types a minecart can move on. */ + public static final long F_RAILS = 0x2000; /** * The height is assumed to decrease from 1.0 with increasing data value from 0 to 0x7, with 0x7 being the lowest. @@ -440,6 +443,13 @@ public class BlockProperties { blockFlags[mat.getId()] |= F_STAIRS | F_HEIGHT100 | F_XZ100 | F_GROUND; // Set ground too, to be sure. } + // Rails + for (final Material mat : new Material[] { + Material.RAILS, Material.DETECTOR_RAIL, Material.POWERED_RAIL, + }) { + blockFlags[mat.getId()] |= F_RAILS; + } + // WATER. for (final Material mat : new Material[]{ Material.STATIONARY_WATER, Material.WATER, @@ -1196,6 +1206,15 @@ public class BlockProperties { else return (flags & F_SOLID) == 0; } + /** + * All rail types a minecart can move on. + * @param id + * @return + */ + public static final boolean isRails(final int id){ + return (blockFlags[id] & F_RAILS) != 0; + } + /** * Test if a position can be passed through (collidesBlock + passable test, no fences yet).
* NOTE: This is experimental.