mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2025-01-15 03:51:20 +01:00
Reduce use of using block-ids in more places.
* Use Material directly in more places. * Hide id-getting within BlockProperties. TODO: * BlockInit, BlockFlags + use of those. * Possibly other.
This commit is contained in:
parent
5bfad6016c
commit
75224adf63
@ -81,11 +81,11 @@ public class FastConsume extends Check implements Listener{
|
||||
final Material mat = stack == null ? null : stack.getType();
|
||||
if (mat != null){
|
||||
if (cc.fastConsumeWhitelist){
|
||||
if (!cc.fastConsumeItems.contains(mat.getId())){
|
||||
if (!cc.fastConsumeItems.contains(mat)){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (cc.fastConsumeItems.contains(mat.getId())){
|
||||
else if (cc.fastConsumeItems.contains(mat)){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -171,42 +171,43 @@ public class MCAccessBukkit implements MCAccess, BlockPropertiesSetup{
|
||||
// TODO: Might try stuff like setNoDamageTicks.
|
||||
BridgeHealth.damage(player, 1.0);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
|
||||
@Override
|
||||
public void setupBlockProperties(final WorldConfigProvider<?> worldConfigProvider) {
|
||||
// Note deprecation suppression: These ids should be unique for a server run, that should be ok for setting up generic properties.
|
||||
// TODO: (?) Set some generic properties matching what BlockCache.getShape returns.
|
||||
final Set<Integer> fullBlocks = new HashSet<Integer>();
|
||||
final Set<Material> fullBlocks = new HashSet<Material>();
|
||||
for (final Material mat : new Material[]{
|
||||
// TODO: Ice !? / Packed ice !?
|
||||
Material.GLASS, Material.GLOWSTONE, Material.ICE, Material.LEAVES,
|
||||
Material.COMMAND, Material.BEACON,
|
||||
Material.PISTON_BASE,
|
||||
}) {
|
||||
fullBlocks.add(mat.getId());
|
||||
fullBlocks.add(mat);
|
||||
}
|
||||
for (final Material mat : Material.values()) {
|
||||
if (!mat.isBlock()) continue;
|
||||
final int id = mat.getId();
|
||||
if (id < 0 || id >= 4096 || fullBlocks.contains(id)) continue;
|
||||
if (!mat.isBlock()) {
|
||||
continue;
|
||||
}
|
||||
if (fullBlocks.contains(mat)) {
|
||||
continue;
|
||||
}
|
||||
if (!mat.isOccluding() || !mat.isSolid() || mat.isTransparent()) {
|
||||
// Uncertain bounding-box, allow passing through.
|
||||
long flags = BlockProperties.F_IGN_PASSABLE;
|
||||
if ((BlockProperties.isSolid(id) || BlockProperties.isGround(id)) && !BlockProperties.isLiquid(id)) {
|
||||
if ((BlockProperties.isSolid(mat) || BlockProperties.isGround(mat)) && !BlockProperties.isLiquid(mat)) {
|
||||
// Block can be ground, so allow standing on any height.
|
||||
flags |= BlockProperties.F_GROUND_HEIGHT;
|
||||
}
|
||||
BlockProperties.setBlockFlags(id, BlockProperties.getBlockFlags(id) | flags);
|
||||
BlockProperties.setBlockFlags(mat, BlockProperties.getBlockFlags(mat) | flags);
|
||||
}
|
||||
}
|
||||
// Blocks that are reported to be full and solid, but which are not.
|
||||
for (final Material mat : new Material[]{
|
||||
Material.ENDER_PORTAL_FRAME,
|
||||
}) {
|
||||
final int id = mat.getId();
|
||||
final long flags = BlockProperties.F_IGN_PASSABLE | BlockProperties.F_GROUND_HEIGHT;
|
||||
BlockProperties.setBlockFlags(id, BlockProperties.getBlockFlags(id) | flags);
|
||||
BlockProperties.setBlockFlags(mat, BlockProperties.getBlockFlags(mat) | flags);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,8 @@ package fr.neatmonster.nocheatplus.actions;
|
||||
*/
|
||||
public enum ParameterName {
|
||||
// TODO: Cleanup for some kind of policies: useful names, alternative names, prefer generic names.
|
||||
BLOCK_ID("blockid"), // TODO: Block name ?
|
||||
BLOCK_ID("blockid"),
|
||||
BLOCK_TYPE("blocktype"),
|
||||
CHECK("check"),
|
||||
TAGS("tags"),
|
||||
DISTANCE("distance"),
|
||||
|
@ -124,7 +124,7 @@ public class BlockBreakListener extends CheckListener {
|
||||
}
|
||||
|
||||
// Destroying liquid blocks.
|
||||
if (!cancelled && BlockProperties.isLiquid(block.getTypeId()) && !player.hasPermission(Permissions.BLOCKBREAK_BREAK_LIQUID) && !NCPExemptionManager.isExempted(player, CheckType.BLOCKBREAK_BREAK)){
|
||||
if (!cancelled && BlockProperties.isLiquid(block.getType()) && !player.hasPermission(Permissions.BLOCKBREAK_BREAK_LIQUID) && !NCPExemptionManager.isExempted(player, CheckType.BLOCKBREAK_BREAK)){
|
||||
cancelled = true;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
package fr.neatmonster.nocheatplus.checks.blockbreak;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@ -45,8 +46,8 @@ public class FastBreak extends Check {
|
||||
boolean cancel = false;
|
||||
|
||||
// Determine expected breaking time by block type.
|
||||
final int id = block.getTypeId();
|
||||
final long expectedBreakingTime = Math.max(0, Math.round((double) BlockProperties.getBreakingDuration(id, player) * (double) cc.fastBreakModSurvival / 100D));
|
||||
final Material blockType = block.getType();
|
||||
final long expectedBreakingTime = Math.max(0, Math.round((double) BlockProperties.getBreakingDuration(blockType, player) * (double) cc.fastBreakModSurvival / 100D));
|
||||
|
||||
final long elapsedTime;
|
||||
// TODO: Concept for unbreakable blocks? Context: extreme VL.
|
||||
@ -89,7 +90,8 @@ public class FastBreak extends Check {
|
||||
data.fastBreakVL += vlAdded;
|
||||
final ViolationData vd = new ViolationData(this, player, data.fastBreakVL, vlAdded, cc.fastBreakActions);
|
||||
if (vd.needsParameters()) {
|
||||
vd.setParameter(ParameterName.BLOCK_ID, "" + id);
|
||||
vd.setParameter(ParameterName.BLOCK_TYPE, blockType.toString());
|
||||
vd.setParameter(ParameterName.BLOCK_ID, Integer.toString(BlockProperties.getId(blockType)));
|
||||
}
|
||||
cancel = executeActions(vd);
|
||||
}
|
||||
@ -104,16 +106,15 @@ public class FastBreak extends Check {
|
||||
if ((cc.fastBreakDebug || cc.debug) && player.hasPermission(Permissions.ADMINISTRATION_DEBUG)) {
|
||||
// General stats:
|
||||
if (data.stats != null) {
|
||||
data.stats.addStats(data.stats.getId(Integer.toString(block.getTypeId())+"u", true), elapsedTime);
|
||||
data.stats.addStats(data.stats.getId(Integer.toString(block.getTypeId())+ "r", true), expectedBreakingTime);
|
||||
data.stats.addStats(data.stats.getId(blockType+ "/u", true), elapsedTime);
|
||||
data.stats.addStats(data.stats.getId(blockType + "/r", true), expectedBreakingTime);
|
||||
player.sendMessage(data.stats.getStatsStr(true));
|
||||
}
|
||||
// Send info about current break:
|
||||
final int blockId = block.getTypeId();
|
||||
final ItemStack stack = player.getItemInHand();
|
||||
final boolean isValidTool = BlockProperties.isValidTool(blockId, stack);
|
||||
final boolean isValidTool = BlockProperties.isValidTool(blockType, stack);
|
||||
final double haste = PotionUtil.getPotionEffectAmplifier(player, PotionEffectType.FAST_DIGGING);
|
||||
String msg = (isInstaBreak.decideOptimistically() ? ("[Insta=" + isInstaBreak + "]") : "[Normal]") + "[" + blockId + "] "+ elapsedTime + "u / " + expectedBreakingTime +"r (" + (isValidTool?"tool":"no-tool") + ")" + (haste == Double.NEGATIVE_INFINITY ? "" : " haste=" + ((int) haste + 1));
|
||||
String msg = (isInstaBreak.decideOptimistically() ? ("[Insta=" + isInstaBreak + "]") : "[Normal]") + "[" + blockType + "] "+ elapsedTime + "u / " + expectedBreakingTime +"r (" + (isValidTool?"tool":"no-tool") + ")" + (haste == Double.NEGATIVE_INFINITY ? "" : " haste=" + ((int) haste + 1));
|
||||
player.sendMessage(msg);
|
||||
// net.minecraft.server.Item mcItem = net.minecraft.server.Item.byId[stack.getTypeId()];
|
||||
// if (mcItem != null) {
|
||||
|
@ -78,8 +78,8 @@ public class BlockInteractListener extends CheckListener {
|
||||
break;
|
||||
case RIGHT_CLICK_BLOCK:
|
||||
final ItemStack stack = player.getItemInHand();
|
||||
if (stack != null && stack.getTypeId() == Material.ENDER_PEARL.getId()){
|
||||
if (!BlockProperties.isPassable(block.getTypeId())){
|
||||
if (stack != null && stack.getType() == Material.ENDER_PEARL){
|
||||
if (!BlockProperties.isPassable(block.getType())){
|
||||
final CombinedConfig ccc = CombinedConfig.getConfig(player);
|
||||
if (ccc.enderPearlCheck && ccc.enderPearlPreventClickBlock){
|
||||
event.setUseItemInHand(Result.DENY);
|
||||
|
@ -9,7 +9,6 @@ import fr.neatmonster.nocheatplus.actions.ParameterName;
|
||||
import fr.neatmonster.nocheatplus.checks.Check;
|
||||
import fr.neatmonster.nocheatplus.checks.CheckType;
|
||||
import fr.neatmonster.nocheatplus.checks.ViolationData;
|
||||
import fr.neatmonster.nocheatplus.checks.blockbreak.BlockBreakData;
|
||||
import fr.neatmonster.nocheatplus.checks.blockinteract.BlockInteractData;
|
||||
import fr.neatmonster.nocheatplus.utilities.BlockProperties;
|
||||
import fr.neatmonster.nocheatplus.utilities.TickTask;
|
||||
@ -29,8 +28,8 @@ public class Against extends Check {
|
||||
boolean violation = false;
|
||||
// TODO: Make more precise (workarounds like WATER_LILY, general points).
|
||||
// Workaround for signs on cactus and similar.
|
||||
final int againstId = blockAgainst.getTypeId();
|
||||
if (againstId == Material.AIR.getId()) {
|
||||
final Material againstType = blockAgainst.getType();
|
||||
if (againstType == null || againstType == Material.AIR) {
|
||||
// Attempt to workaround blocks like cactus.
|
||||
final BlockInteractData bdata = BlockInteractData.getData(player);
|
||||
if (bdata.lastType != null && bdata.lastX != Integer.MAX_VALUE && TickTask.getTick() == bdata.lastTick && TrigUtil.manhattan(bdata.lastX, bdata.lastY, bdata.lastZ, blockAgainst) == 0) {
|
||||
@ -41,19 +40,20 @@ public class Against extends Check {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (BlockProperties.isLiquid(againstId)) {
|
||||
if ((placedMat != Material.WATER_LILY || !BlockProperties.isLiquid(block.getRelative(BlockFace.DOWN).getTypeId()))) {
|
||||
if (BlockProperties.isLiquid(againstType)) {
|
||||
if ((placedMat != Material.WATER_LILY || !BlockProperties.isLiquid(block.getRelative(BlockFace.DOWN).getType()))) {
|
||||
violation = true;
|
||||
}
|
||||
}
|
||||
else if (againstId == Material.AIR.getId()) {
|
||||
else if (againstType == Material.AIR) {
|
||||
violation = true;
|
||||
}
|
||||
// Handle violation and return.
|
||||
if (violation) {
|
||||
data.againstVL += 1.0;
|
||||
final ViolationData vd = new ViolationData(this, player, data.againstVL, 1, cc.againstActions);
|
||||
vd.setParameter(ParameterName.BLOCK_ID, Integer.toString(placedMat.getId()));
|
||||
vd.setParameter(ParameterName.BLOCK_TYPE, placedMat.toString());
|
||||
vd.setParameter(ParameterName.BLOCK_ID, Integer.toString(BlockProperties.getId(placedMat)));
|
||||
return executeActions(vd);
|
||||
} else {
|
||||
data.againstVL *= 0.99; // Assume one false positive every 100 blocks.
|
||||
|
@ -305,7 +305,7 @@ public class BlockPlaceListener extends CheckListener {
|
||||
else{
|
||||
final Material mat = player.getLocation(useLoc).getBlock().getType();
|
||||
final long flags = BlockProperties.F_CLIMBABLE | BlockProperties.F_LIQUID | BlockProperties.F_IGN_PASSABLE;
|
||||
if (mat != Material.AIR && (BlockProperties.getBlockFlags(mat.getId()) & flags) == 0 && !mcAccess.hasGravity(mat)){
|
||||
if (mat != null && mat != Material.AIR && (BlockProperties.getBlockFlags(mat) & flags) == 0 && !mcAccess.hasGravity(mat)){
|
||||
// Still fails on piston traps etc.
|
||||
if (!BlockProperties.isPassable(player.getLocation(), projectile.getLocation()) && !BlockProperties.isOnGroundOrResetCond(player, player.getLocation(), MovingConfig.getConfig(player).yOnGround)){
|
||||
cancel = true;
|
||||
|
@ -5,6 +5,7 @@ import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import fr.neatmonster.nocheatplus.actions.ActionList;
|
||||
@ -71,7 +72,7 @@ public class InventoryConfig extends ACheckConfig {
|
||||
public final boolean fastConsumeCheck;
|
||||
public final long fastConsumeDuration;
|
||||
public final boolean fastConsumeWhitelist;
|
||||
public final Set<Integer> fastConsumeItems = new HashSet<Integer>();
|
||||
public final Set<Material> fastConsumeItems = new HashSet<Material>();
|
||||
public final ActionList fastConsumeActions;
|
||||
|
||||
public final boolean instantBowCheck;
|
||||
@ -111,7 +112,7 @@ public class InventoryConfig extends ACheckConfig {
|
||||
fastConsumeCheck = data.getBoolean(ConfPaths.INVENTORY_FASTCONSUME_CHECK);
|
||||
fastConsumeDuration = (long) (1000.0 * data.getDouble(ConfPaths.INVENTORY_FASTCONSUME_DURATION));
|
||||
fastConsumeWhitelist = data.getBoolean(ConfPaths.INVENTORY_FASTCONSUME_WHITELIST);
|
||||
data.readMaterialIdsFromList(ConfPaths.INVENTORY_FASTCONSUME_ITEMS, fastConsumeItems);
|
||||
data.readMaterialFromList(ConfPaths.INVENTORY_FASTCONSUME_ITEMS, fastConsumeItems);
|
||||
fastConsumeActions = data.getOptimizedActionList(ConfPaths.INVENTORY_FASTCONSUME_ACTIONS, Permissions.INVENTORY_FASTCONSUME);
|
||||
|
||||
instantBowCheck = data.getBoolean(ConfPaths.INVENTORY_INSTANTBOW_CHECK);
|
||||
|
@ -271,7 +271,7 @@ public class InventoryListener extends CheckListener implements JoinLeaveListen
|
||||
return;
|
||||
}
|
||||
final ItemStack stack = player.getItemInHand();
|
||||
if (stack != null && stack.getTypeId() == Material.MONSTER_EGG.getId() && items.isEnabled(player)){
|
||||
if (stack != null && stack.getType() == Material.MONSTER_EGG && items.isEnabled(player)){
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
@ -223,7 +223,7 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
|
||||
if (Math.abs(loc.getX() - 0.5 - block.getX()) <= 1D
|
||||
&& Math.abs(loc.getZ() - 0.5 - block.getZ()) <= 1D
|
||||
&& loc.getY() - blockY > 0D && loc.getY() - blockY < 2D
|
||||
&& (canJumpOffTop(mat.getId()) || BlockProperties.isLiquid(mat.getId()))) {
|
||||
&& (canJumpOffTop(mat) || BlockProperties.isLiquid(mat))) {
|
||||
// The creative fly and/or survival fly check is enabled, the
|
||||
// block was placed below the player and is
|
||||
// solid, so do what we have to do.
|
||||
@ -238,9 +238,9 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
private static boolean canJumpOffTop(final int id) {
|
||||
private static boolean canJumpOffTop(final Material blockType) {
|
||||
// TODO: Test if this can be removed!
|
||||
return BlockProperties.isGround(id) || BlockProperties.isSolid(id);
|
||||
return BlockProperties.isGround(blockType) || BlockProperties.isSolid(blockType);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1415,7 +1415,7 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
|
||||
}
|
||||
|
||||
// Adjust loc if in liquid (meant for boats !?).
|
||||
if (BlockProperties.isLiquid(loc.getBlock().getTypeId())) {
|
||||
if (BlockProperties.isLiquid(loc.getBlock().getType())) {
|
||||
loc.setY(Location.locToBlock(loc.getY()) + 1.25);
|
||||
}
|
||||
|
||||
|
@ -152,8 +152,6 @@ public class SurvivalFly extends Check {
|
||||
// Mixed checks (lost ground).
|
||||
/////////////////////////////////
|
||||
|
||||
// data.stats.addStats(data.stats.getId("sfCheck", true), 1);
|
||||
|
||||
|
||||
// "Lost ground" workaround.
|
||||
if (fromOnGround || from.isResetCond()) {
|
||||
@ -165,7 +163,6 @@ public class SurvivalFly extends Check {
|
||||
// TODO: Consider if (!resetTo) ?
|
||||
// Check lost-ground workarounds.
|
||||
resetFrom = lostGround(player, from, to, hDistance, yDistance, sprinting, data, cc);
|
||||
// data.stats.addStats(data.stats.getId("sfLostGround", true), resetFrom ? 1 : 0);
|
||||
// Note: if not setting resetFrom, other places have to check assumeGround...
|
||||
}
|
||||
|
||||
@ -1094,7 +1091,6 @@ public class SurvivalFly extends Check {
|
||||
if (data.sfLastYDist < 0.0 || from.isOnGround(0.5 - Math.abs(yDistance))) {
|
||||
return applyLostGround(player, from, true, data, "step");
|
||||
}
|
||||
// else data.stats.addStats(data.stats.getId("sfLostGround_" + "step", true), 0);
|
||||
}
|
||||
|
||||
// Interpolation check.
|
||||
@ -1123,7 +1119,6 @@ public class SurvivalFly extends Check {
|
||||
if (BlockProperties.isOnGround(from.getBlockCache(), Math.min(data.fromX, from.getX()) - r, iY - yMargin, Math.min(data.fromZ, from.getZ()) - r, Math.max(data.fromX, from.getX()) + r, iY + 0.25, Math.max(data.fromZ, from.getZ()) + r, 0L)) {
|
||||
return applyLostGround(player, from, true, data, "interpolate");
|
||||
}
|
||||
// else data.stats.addStats(data.stats.getId("sfLostGround_" + "interpolate", true), 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1163,7 +1158,6 @@ public class SurvivalFly extends Check {
|
||||
// Temporary "fix".
|
||||
return applyLostGround(player, from, true, data, "pyramid");
|
||||
}
|
||||
// else data.stats.addStats(data.stats.getId("sfLostGround_" + "pyramid", true), 0);
|
||||
}
|
||||
|
||||
// Check for jumping up strange blocks like flower pots on top of other blocks.
|
||||
@ -1173,7 +1167,6 @@ public class SurvivalFly extends Check {
|
||||
// Temporary "fix".
|
||||
return applyLostGround(player, from, true, data, "ministep");
|
||||
}
|
||||
// else data.stats.addStats(data.stats.getId("sfLostGround_" + "ministep", true), 0);
|
||||
}
|
||||
}
|
||||
// Lost ground while falling onto/over edges of blocks.
|
||||
@ -1185,7 +1178,6 @@ public class SurvivalFly extends Check {
|
||||
if (from.isOnGround(0.5, 0.2, 0) || to.isOnGround(0.5, Math.min(0.2, 0.01 + hDistance), Math.min(0.1, 0.01 + -yDistance))) {
|
||||
return applyLostGround(player, from, true, data, "edge");
|
||||
}
|
||||
// else data.stats.addStats(data.stats.getId("sfLostGround_" + "edge", true), 0);
|
||||
}
|
||||
|
||||
// Nothing found.
|
||||
@ -1220,7 +1212,6 @@ public class SurvivalFly extends Check {
|
||||
// (Usually yDistance should be -0.078)
|
||||
return applyLostGround(player, from, true, data, "fastedge");
|
||||
}
|
||||
// else data.stats.addStats(data.stats.getId("sfLostGround_" + "fastedge", true), 0);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -1253,7 +1244,6 @@ public class SurvivalFly extends Check {
|
||||
// Tell NoFall that we assume the player to have been on ground somehow.
|
||||
data.noFallAssumeGround = true;
|
||||
tags.add("lostground_" + tag);
|
||||
// data.stats.addStats(data.stats.getId("sfLostGround_" + tag, true), 1);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,9 @@ public class RawConfigFile extends YamlConfiguration{
|
||||
catch(NumberFormatException e){}
|
||||
try{
|
||||
Material mat = Material.matchMaterial(prepareMatchMaterial(content));
|
||||
if (mat != null) return mat.getId();
|
||||
if (mat != null) {
|
||||
return mat.getId();
|
||||
}
|
||||
}
|
||||
catch (Exception e) {}
|
||||
return null;
|
||||
|
@ -876,6 +876,16 @@ public class BlockProperties {
|
||||
else return blocks[blockId];
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method.
|
||||
* @param blockType
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public static long getBreakingDuration(final Material BlockType, final Player player){
|
||||
return getBreakingDuration(BlockType.getId(), player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method.
|
||||
* @param blockId
|
||||
@ -1148,8 +1158,11 @@ public class BlockProperties {
|
||||
if (blockId < 0 || blockId >= blocks.length) throw new IllegalArgumentException("The blockId is outside of supported range: " + blockId);
|
||||
blocks[blockId] = blockProps;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static boolean isValidTool(final Material blockType, final ItemStack itemInHand) {
|
||||
return isValidTool(blockType.getId(), itemInHand);
|
||||
}
|
||||
|
||||
public static boolean isValidTool(final int blockId, final ItemStack itemInHand) {
|
||||
final BlockProps blockProps = getBlockProps(blockId);
|
||||
final ToolProps toolProps = getToolProps(itemInHand);
|
||||
@ -1217,6 +1230,15 @@ public class BlockProperties {
|
||||
pLoc.cleanup();
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Straw-man-method to hide warnings. Rather intended for display in debug/alert messages.
|
||||
* @param blockType
|
||||
* @return
|
||||
*/
|
||||
public static int getId(final Material blockType) {
|
||||
return blockType.getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Typo in method name.
|
||||
@ -1227,9 +1249,17 @@ public class BlockProperties {
|
||||
return blockFlags[id];
|
||||
}
|
||||
|
||||
public static final long getBlockFlags(final Material blockType){
|
||||
return getBlockFlags(blockType.getId());
|
||||
}
|
||||
|
||||
public static final long getBlockFlags(final int id){
|
||||
return blockFlags[id];
|
||||
}
|
||||
|
||||
public static final void setBlockFlags(final Material blockType, final long flags){
|
||||
setBlockFlags(blockType.getId(), flags);
|
||||
}
|
||||
|
||||
public static final void setBlockFlags(final int id, final long flags){
|
||||
blockFlags[id] = flags;
|
||||
@ -1262,8 +1292,11 @@ public class BlockProperties {
|
||||
public static final boolean isStairs(final int id) {
|
||||
return (blockFlags[id] & F_STAIRS) != 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static final boolean isLiquid(final Material blockType) {
|
||||
return isLiquid(blockType.getId());
|
||||
}
|
||||
|
||||
public static final boolean isLiquid(final int id) {
|
||||
return (blockFlags[id] & F_LIQUID) != 0;
|
||||
}
|
||||
@ -1276,6 +1309,15 @@ public class BlockProperties {
|
||||
return (blockFlags[id] & F_LEAVES) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Might hold true for liquids too.
|
||||
* @param blockType
|
||||
* @return
|
||||
*/
|
||||
public static final boolean isSolid(final Material blockType){
|
||||
return isSolid(blockType.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Might hold true for liquids too.
|
||||
* @param id
|
||||
@ -1285,6 +1327,15 @@ public class BlockProperties {
|
||||
return (blockFlags[id] & F_SOLID) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Might hold true for liquids too.
|
||||
* @param blockType
|
||||
* @return
|
||||
*/
|
||||
public static final boolean isGround(final Material blockType){
|
||||
return isGround(blockType.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Might hold true for liquids too.
|
||||
* @param id
|
||||
@ -1293,6 +1344,16 @@ public class BlockProperties {
|
||||
public static final boolean isGround(final int id){
|
||||
return (blockFlags[id] & F_GROUND) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Just check if a position is not inside of a block that has a bounding box.<br>
|
||||
* This is an inaccurate check, it also returns false for doors etc.
|
||||
* @param blockType
|
||||
* @return
|
||||
*/
|
||||
public static final boolean isPassable(final Material blockType){
|
||||
return isPassable(blockType.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Just check if a position is not inside of a block that has a bounding box.<br>
|
||||
|
Loading…
Reference in New Issue
Block a user