mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2025-01-28 18:31:24 +01:00
Hide some more warnings behind BlockProperties.
This commit is contained in:
parent
c449414d9a
commit
b25b2be62c
@ -19,7 +19,7 @@ public class BlockInit {
|
||||
* @param id
|
||||
*/
|
||||
public static void assertMaterialExists(int id) {
|
||||
if (Material.getMaterial(id) == null) {
|
||||
if (BlockProperties.getMaterial(id) == null) {
|
||||
throw new RuntimeException("Material " + id + " does not exist.");
|
||||
}
|
||||
}
|
||||
@ -30,7 +30,7 @@ public class BlockInit {
|
||||
* @param name
|
||||
*/
|
||||
public static void assertMaterialName(int id, String name) {
|
||||
Material mat = Material.getMaterial(id);
|
||||
Material mat = BlockProperties.getMaterial(id);
|
||||
if ( mat == null) {
|
||||
throw new RuntimeException("Material " + id + " does not exist.");
|
||||
}
|
||||
@ -45,7 +45,7 @@ public class BlockInit {
|
||||
* @param parts
|
||||
*/
|
||||
public static void assertMaterialNameMatch(int id, String... parts) {
|
||||
Material mat = Material.getMaterial(id);
|
||||
Material mat = BlockProperties.getMaterial(id);
|
||||
if ( mat == null) {
|
||||
throw new RuntimeException("Material " + id + " does not exist.");
|
||||
}
|
||||
@ -63,7 +63,7 @@ public class BlockInit {
|
||||
* @param mat
|
||||
*/
|
||||
public static void setPropsAs(int newId, Material mat) {
|
||||
setPropsAs(newId, mat.getId());
|
||||
setPropsAs(newId, mat);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -16,7 +16,7 @@ public class BlockFlags {
|
||||
* @param mat
|
||||
*/
|
||||
public static void setFlagsAs(int id, Material mat) {
|
||||
setFlagsAs(id, mat.getId());
|
||||
BlockProperties.setBlockFlags(id, BlockProperties.getBlockFlags(mat));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1240,6 +1240,15 @@ public class BlockProperties {
|
||||
public static int getId(final Material blockType) {
|
||||
return blockType.getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* Straw-man method to hide warnings.
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public static Material getMaterial(final int id) {
|
||||
return Material.getMaterial(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Typo in method name.
|
||||
@ -1289,6 +1298,16 @@ public class BlockProperties {
|
||||
public static final boolean isClimbable(final int id) {
|
||||
return (blockFlags[id] & F_CLIMBABLE) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Climbable material that needs to be attached to a block, to allow players to climb up.<br>
|
||||
* Currently only applies to vines. There is no flag for such, yet.
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public static final boolean isAttachedClimbable(final int id) {
|
||||
return id == Material.VINE.getId();
|
||||
}
|
||||
|
||||
public static final boolean isStairs(final int id) {
|
||||
return (blockFlags[id] & F_STAIRS) != 0;
|
||||
@ -1880,6 +1899,22 @@ public class BlockProperties {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for Material instead of block id.
|
||||
* @param access
|
||||
* @param minX
|
||||
* @param minY
|
||||
* @param minZ
|
||||
* @param maxX
|
||||
* @param maxY
|
||||
* @param maxZ
|
||||
* @param mat
|
||||
* @return
|
||||
*/
|
||||
public static final boolean collidesId(final BlockCache access, final double minX, double minY, final double minZ, final double maxX, final double maxY, final double maxZ, final Material mat){
|
||||
return collidesId(access, minX, minY, minZ, maxX, maxY, maxZ, mat.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a block with the given id is overlapping with the bounds, this does not check the blocks actual bounds (All bounds of the block are seen as 0...1, for exact box match use collidesBlock).
|
||||
* @param access
|
||||
|
@ -408,7 +408,7 @@ public class PlayerLocation {
|
||||
*/
|
||||
public boolean canClimbUp(double jumpHeigth) {
|
||||
// TODO: distinguish vines.
|
||||
if (getTypeId() == Material.VINE.getId()) {
|
||||
if (BlockProperties.isAttachedClimbable(getTypeId())) {
|
||||
// Check if vine is attached to something solid
|
||||
if (BlockProperties.canClimbUp(blockCache, blockX, blockY, blockZ)) {
|
||||
return true;
|
||||
@ -454,7 +454,7 @@ public class PlayerLocation {
|
||||
if (inWeb == null) {
|
||||
// TODO: inset still needed ?
|
||||
final double inset = 0.001d;
|
||||
inWeb = BlockProperties.collidesId(blockCache, minX + inset, minY + inset, minZ + inset, maxX - inset, maxY - inset, maxZ - inset, Material.WEB.getId());
|
||||
inWeb = BlockProperties.collidesId(blockCache, minX + inset, minY + inset, minZ + inset, maxX - inset, maxY - inset, maxZ - inset, Material.WEB);
|
||||
}
|
||||
return inWeb;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user