move all checks from BlockStateInterface to MovementHelper
This commit is contained in:
parent
88e3bcdf63
commit
b65a199e54
@ -116,7 +116,7 @@ public abstract class Movement implements IMovement, Helper, MovementHelper {
|
|||||||
public MovementStatus update() {
|
public MovementStatus update() {
|
||||||
player().capabilities.isFlying = false;
|
player().capabilities.isFlying = false;
|
||||||
MovementState latestState = updateState(currentState);
|
MovementState latestState = updateState(currentState);
|
||||||
if (BlockStateInterface.isLiquid(playerFeet())) {
|
if (MovementHelper.isLiquid(playerFeet())) {
|
||||||
latestState.setInput(Input.JUMP, true);
|
latestState.setInput(Input.JUMP, true);
|
||||||
}
|
}
|
||||||
if (player().isEntityInsideOpaqueBlock()) {
|
if (player().isEntityInsideOpaqueBlock()) {
|
||||||
|
@ -105,7 +105,7 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||||||
}
|
}
|
||||||
throw new IllegalStateException();
|
throw new IllegalStateException();
|
||||||
}
|
}
|
||||||
if (BlockStateInterface.isFlowing(state)) {
|
if (isFlowing(state)) {
|
||||||
return false; // Don't walk through flowing liquids
|
return false; // Don't walk through flowing liquids
|
||||||
}
|
}
|
||||||
if (block instanceof BlockLiquid) {
|
if (block instanceof BlockLiquid) {
|
||||||
@ -254,7 +254,7 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (state.isBlockNormalCube()) {
|
if (state.isBlockNormalCube()) {
|
||||||
if (BlockStateInterface.isLava(block) || BlockStateInterface.isWater(block)) {
|
if (isLava(block) || isWater(block)) {
|
||||||
throw new IllegalStateException();
|
throw new IllegalStateException();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -268,20 +268,20 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||||||
if (block == Blocks.ENDER_CHEST || block == Blocks.CHEST) {
|
if (block == Blocks.ENDER_CHEST || block == Blocks.CHEST) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (BlockStateInterface.isWater(block)) {
|
if (isWater(block)) {
|
||||||
// since this is called literally millions of times per second, the benefit of not allocating millions of useless "pos.up()"
|
// since this is called literally millions of times per second, the benefit of not allocating millions of useless "pos.up()"
|
||||||
// BlockPos s that we'd just garbage collect immediately is actually noticeable. I don't even think its a decrease in readability
|
// BlockPos s that we'd just garbage collect immediately is actually noticeable. I don't even think its a decrease in readability
|
||||||
Block up = BlockStateInterface.get(x, y + 1, z).getBlock();
|
Block up = BlockStateInterface.get(x, y + 1, z).getBlock();
|
||||||
if (up == Blocks.WATERLILY) {
|
if (up == Blocks.WATERLILY) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (BlockStateInterface.isFlowing(state) || block == Blocks.FLOWING_WATER) {
|
if (isFlowing(state) || block == Blocks.FLOWING_WATER) {
|
||||||
// the only scenario in which we can walk on flowing water is if it's under still water with jesus off
|
// the only scenario in which we can walk on flowing water is if it's under still water with jesus off
|
||||||
return BlockStateInterface.isWater(up) && !Baritone.settings().assumeWalkOnWater.get();
|
return isWater(up) && !Baritone.settings().assumeWalkOnWater.get();
|
||||||
}
|
}
|
||||||
// if assumeWalkOnWater is on, we can only walk on water if there isn't water above it
|
// if assumeWalkOnWater is on, we can only walk on water if there isn't water above it
|
||||||
// if assumeWalkOnWater is off, we can only walk on water if there is water above it
|
// if assumeWalkOnWater is off, we can only walk on water if there is water above it
|
||||||
return BlockStateInterface.isWater(up) ^ Baritone.settings().assumeWalkOnWater.get();
|
return isWater(up) ^ Baritone.settings().assumeWalkOnWater.get();
|
||||||
}
|
}
|
||||||
if (block instanceof BlockGlass || block instanceof BlockStainedGlass) {
|
if (block instanceof BlockGlass || block instanceof BlockStainedGlass) {
|
||||||
return true;
|
return true;
|
||||||
@ -444,4 +444,47 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||||||
false
|
false
|
||||||
)).setInput(InputOverrideHandler.Input.MOVE_FORWARD, true);
|
)).setInput(InputOverrideHandler.Input.MOVE_FORWARD, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether or not the specified block is
|
||||||
|
* water, regardless of whether or not it is flowing.
|
||||||
|
*
|
||||||
|
* @param b The block
|
||||||
|
* @return Whether or not the block is water
|
||||||
|
*/
|
||||||
|
static boolean isWater(Block b) {
|
||||||
|
return b == Blocks.FLOWING_WATER || b == Blocks.WATER;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether or not the block at the specified pos is
|
||||||
|
* water, regardless of whether or not it is flowing.
|
||||||
|
*
|
||||||
|
* @param bp The block pos
|
||||||
|
* @return Whether or not the block is water
|
||||||
|
*/
|
||||||
|
static boolean isWater(BlockPos bp) {
|
||||||
|
return isWater(BlockStateInterface.getBlock(bp));
|
||||||
|
}
|
||||||
|
|
||||||
|
static boolean isLava(Block b) {
|
||||||
|
return b == Blocks.FLOWING_LAVA || b == Blocks.LAVA;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether or not the specified pos has a liquid
|
||||||
|
*
|
||||||
|
* @param p The pos
|
||||||
|
* @return Whether or not the block is a liquid
|
||||||
|
*/
|
||||||
|
static boolean isLiquid(BlockPos p) {
|
||||||
|
return BlockStateInterface.getBlock(p) instanceof BlockLiquid;
|
||||||
|
}
|
||||||
|
|
||||||
|
static boolean isFlowing(IBlockState state) {
|
||||||
|
// Will be IFluidState in 1.13
|
||||||
|
return state.getBlock() instanceof BlockLiquid
|
||||||
|
&& state.getPropertyKeys().contains(BlockLiquid.LEVEL)
|
||||||
|
&& state.getValue(BlockLiquid.LEVEL) != 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,7 @@ public class MovementAscend extends Movement {
|
|||||||
if (!context.canPlaceThrowawayAt(destX, y, destZ)) {
|
if (!context.canPlaceThrowawayAt(destX, y, destZ)) {
|
||||||
return COST_INF;
|
return COST_INF;
|
||||||
}
|
}
|
||||||
if (toPlace.getBlock() != Blocks.AIR && !BlockStateInterface.isWater(toPlace.getBlock()) && !MovementHelper.isReplacable(destX, y, destZ, toPlace)) {
|
if (toPlace.getBlock() != Blocks.AIR && !MovementHelper.isWater(toPlace.getBlock()) && !MovementHelper.isReplacable(destX, y, destZ, toPlace)) {
|
||||||
return COST_INF;
|
return COST_INF;
|
||||||
}
|
}
|
||||||
// TODO: add ability to place against .down() as well as the cardinal directions
|
// TODO: add ability to place against .down() as well as the cardinal directions
|
||||||
|
@ -130,7 +130,7 @@ public class MovementDescend extends Movement {
|
|||||||
}
|
}
|
||||||
IBlockState ontoBlock = BlockStateInterface.get(destX, newY, destZ);
|
IBlockState ontoBlock = BlockStateInterface.get(destX, newY, destZ);
|
||||||
double tentativeCost = WALK_OFF_BLOCK_COST + FALL_N_BLOCKS_COST[fallHeight] + frontBreak;
|
double tentativeCost = WALK_OFF_BLOCK_COST + FALL_N_BLOCKS_COST[fallHeight] + frontBreak;
|
||||||
if (ontoBlock.getBlock() == Blocks.WATER && !BlockStateInterface.isFlowing(ontoBlock) && BlockStateInterface.getBlock(destX, newY + 1, destZ) != Blocks.WATERLILY) { // TODO flowing check required here?
|
if (ontoBlock.getBlock() == Blocks.WATER && !MovementHelper.isFlowing(ontoBlock) && BlockStateInterface.getBlock(destX, newY + 1, destZ) != Blocks.WATERLILY) { // TODO flowing check required here?
|
||||||
// lilypads are canWalkThrough, but we can't end a fall that should be broken by water if it's covered by a lilypad
|
// lilypads are canWalkThrough, but we can't end a fall that should be broken by water if it's covered by a lilypad
|
||||||
// however, don't return impossible in the lilypad scenario, because we could still jump right on it (water that's below a lilypad is canWalkOn so it works)
|
// however, don't return impossible in the lilypad scenario, because we could still jump right on it (water that's below a lilypad is canWalkOn so it works)
|
||||||
if (Baritone.settings().assumeWalkOnWater.get()) {
|
if (Baritone.settings().assumeWalkOnWater.get()) {
|
||||||
@ -183,7 +183,7 @@ public class MovementDescend extends Movement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
BlockPos playerFeet = playerFeet();
|
BlockPos playerFeet = playerFeet();
|
||||||
if (playerFeet.equals(dest) && (BlockStateInterface.isLiquid(dest) || player().posY - playerFeet.getY() < 0.094)) { // lilypads
|
if (playerFeet.equals(dest) && (MovementHelper.isLiquid(dest) || player().posY - playerFeet.getY() < 0.094)) { // lilypads
|
||||||
// Wait until we're actually on the ground before saying we're done because sometimes we continue to fall if the next action starts immediately
|
// Wait until we're actually on the ground before saying we're done because sometimes we continue to fall if the next action starts immediately
|
||||||
return state.setStatus(MovementStatus.SUCCESS);
|
return state.setStatus(MovementStatus.SUCCESS);
|
||||||
/* else {
|
/* else {
|
||||||
|
@ -78,11 +78,11 @@ public class MovementDiagonal extends Movement {
|
|||||||
multiplier += (WALK_ONE_OVER_SOUL_SAND_COST - WALK_ONE_BLOCK_COST) / 2;
|
multiplier += (WALK_ONE_OVER_SOUL_SAND_COST - WALK_ONE_BLOCK_COST) / 2;
|
||||||
}
|
}
|
||||||
Block cuttingOver1 = BlockStateInterface.get(x, y - 1, destZ).getBlock();
|
Block cuttingOver1 = BlockStateInterface.get(x, y - 1, destZ).getBlock();
|
||||||
if (cuttingOver1 == Blocks.MAGMA || BlockStateInterface.isLava(cuttingOver1)) {
|
if (cuttingOver1 == Blocks.MAGMA || MovementHelper.isLava(cuttingOver1)) {
|
||||||
return COST_INF;
|
return COST_INF;
|
||||||
}
|
}
|
||||||
Block cuttingOver2 = BlockStateInterface.get(destX, y - 1, z).getBlock();
|
Block cuttingOver2 = BlockStateInterface.get(destX, y - 1, z).getBlock();
|
||||||
if (cuttingOver2 == Blocks.MAGMA || BlockStateInterface.isLava(cuttingOver2)) {
|
if (cuttingOver2 == Blocks.MAGMA || MovementHelper.isLava(cuttingOver2)) {
|
||||||
return COST_INF;
|
return COST_INF;
|
||||||
}
|
}
|
||||||
IBlockState pb0 = BlockStateInterface.get(x, y, destZ);
|
IBlockState pb0 = BlockStateInterface.get(x, y, destZ);
|
||||||
@ -115,7 +115,7 @@ public class MovementDiagonal extends Movement {
|
|||||||
return COST_INF;
|
return COST_INF;
|
||||||
}
|
}
|
||||||
boolean water = false;
|
boolean water = false;
|
||||||
if (BlockStateInterface.isWater(BlockStateInterface.getBlock(x, y, z)) || BlockStateInterface.isWater(destInto.getBlock())) {
|
if (MovementHelper.isWater(BlockStateInterface.getBlock(x, y, z)) || MovementHelper.isWater(destInto.getBlock())) {
|
||||||
// Ignore previous multiplier
|
// Ignore previous multiplier
|
||||||
// Whatever we were walking on (possibly soul sand) doesn't matter as we're actually floating on water
|
// Whatever we were walking on (possibly soul sand) doesn't matter as we're actually floating on water
|
||||||
// Not even touching the blocks below
|
// Not even touching the blocks below
|
||||||
@ -145,7 +145,7 @@ public class MovementDiagonal extends Movement {
|
|||||||
state.setStatus(MovementStatus.SUCCESS);
|
state.setStatus(MovementStatus.SUCCESS);
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
if (!BlockStateInterface.isLiquid(playerFeet())) {
|
if (!MovementHelper.isLiquid(playerFeet())) {
|
||||||
state.setInput(InputOverrideHandler.Input.SPRINT, true);
|
state.setInput(InputOverrideHandler.Input.SPRINT, true);
|
||||||
}
|
}
|
||||||
MovementHelper.moveTowards(state, dest);
|
MovementHelper.moveTowards(state, dest);
|
||||||
|
@ -25,7 +25,6 @@ import baritone.pathing.movement.Movement;
|
|||||||
import baritone.pathing.movement.MovementHelper;
|
import baritone.pathing.movement.MovementHelper;
|
||||||
import baritone.pathing.movement.MovementState;
|
import baritone.pathing.movement.MovementState;
|
||||||
import baritone.pathing.movement.MovementState.MovementTarget;
|
import baritone.pathing.movement.MovementState.MovementTarget;
|
||||||
import baritone.utils.BlockStateInterface;
|
|
||||||
import baritone.utils.InputOverrideHandler;
|
import baritone.utils.InputOverrideHandler;
|
||||||
import baritone.utils.pathing.MutableMoveResult;
|
import baritone.utils.pathing.MutableMoveResult;
|
||||||
import net.minecraft.entity.player.InventoryPlayer;
|
import net.minecraft.entity.player.InventoryPlayer;
|
||||||
@ -63,7 +62,7 @@ public class MovementFall extends Movement {
|
|||||||
|
|
||||||
BlockPos playerFeet = playerFeet();
|
BlockPos playerFeet = playerFeet();
|
||||||
Rotation targetRotation = null;
|
Rotation targetRotation = null;
|
||||||
if (!BlockStateInterface.isWater(dest) && src.getY() - dest.getY() > Baritone.settings().maxFallHeightNoWater.get() && !playerFeet.equals(dest)) {
|
if (!MovementHelper.isWater(dest) && src.getY() - dest.getY() > Baritone.settings().maxFallHeightNoWater.get() && !playerFeet.equals(dest)) {
|
||||||
if (!InventoryPlayer.isHotbar(player().inventory.getSlotFor(STACK_BUCKET_WATER)) || world().provider.isNether()) {
|
if (!InventoryPlayer.isHotbar(player().inventory.getSlotFor(STACK_BUCKET_WATER)) || world().provider.isNether()) {
|
||||||
return state.setStatus(MovementStatus.UNREACHABLE);
|
return state.setStatus(MovementStatus.UNREACHABLE);
|
||||||
}
|
}
|
||||||
@ -84,8 +83,8 @@ public class MovementFall extends Movement {
|
|||||||
} else {
|
} else {
|
||||||
state.setTarget(new MovementTarget(RotationUtils.calcRotationFromVec3d(playerHead(), VecUtils.getBlockPosCenter(dest)), false));
|
state.setTarget(new MovementTarget(RotationUtils.calcRotationFromVec3d(playerHead(), VecUtils.getBlockPosCenter(dest)), false));
|
||||||
}
|
}
|
||||||
if (playerFeet.equals(dest) && (player().posY - playerFeet.getY() < 0.094 || BlockStateInterface.isWater(dest))) { // 0.094 because lilypads
|
if (playerFeet.equals(dest) && (player().posY - playerFeet.getY() < 0.094 || MovementHelper.isWater(dest))) { // 0.094 because lilypads
|
||||||
if (BlockStateInterface.isWater(dest)) {
|
if (MovementHelper.isWater(dest)) {
|
||||||
if (InventoryPlayer.isHotbar(player().inventory.getSlotFor(STACK_BUCKET_EMPTY))) {
|
if (InventoryPlayer.isHotbar(player().inventory.getSlotFor(STACK_BUCKET_EMPTY))) {
|
||||||
player().inventory.currentItem = player().inventory.getSlotFor(STACK_BUCKET_EMPTY);
|
player().inventory.currentItem = player().inventory.getSlotFor(STACK_BUCKET_EMPTY);
|
||||||
if (player().motionY >= 0) {
|
if (player().motionY >= 0) {
|
||||||
|
@ -124,7 +124,7 @@ public class MovementParkour extends Movement {
|
|||||||
if (!context.canPlaceThrowawayAt(destX, y - 1, destZ)) {
|
if (!context.canPlaceThrowawayAt(destX, y - 1, destZ)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (toPlace.getBlock() != Blocks.AIR && !BlockStateInterface.isWater(toPlace.getBlock()) && !MovementHelper.isReplacable(destX, y - 1, destZ, toPlace)) {
|
if (toPlace.getBlock() != Blocks.AIR && !MovementHelper.isWater(toPlace.getBlock()) && !MovementHelper.isReplacable(destX, y - 1, destZ, toPlace)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
|
@ -67,9 +67,9 @@ public class MovementPillar extends Movement {
|
|||||||
return COST_INF;
|
return COST_INF;
|
||||||
}
|
}
|
||||||
Block srcUp = null;
|
Block srcUp = null;
|
||||||
if (BlockStateInterface.isWater(toBreakBlock) && BlockStateInterface.isWater(fromDown)) {
|
if (MovementHelper.isWater(toBreakBlock) && MovementHelper.isWater(fromDown)) {
|
||||||
srcUp = BlockStateInterface.get(x, y + 1, z).getBlock();
|
srcUp = BlockStateInterface.get(x, y + 1, z).getBlock();
|
||||||
if (BlockStateInterface.isWater(srcUp)) {
|
if (MovementHelper.isWater(srcUp)) {
|
||||||
return LADDER_UP_ONE_COST;
|
return LADDER_UP_ONE_COST;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -144,7 +144,7 @@ public class MovementPillar extends Movement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
IBlockState fromDown = BlockStateInterface.get(src);
|
IBlockState fromDown = BlockStateInterface.get(src);
|
||||||
if (BlockStateInterface.isWater(fromDown.getBlock()) && BlockStateInterface.isWater(dest)) {
|
if (MovementHelper.isWater(fromDown.getBlock()) && MovementHelper.isWater(dest)) {
|
||||||
// stay centered while swimming up a water column
|
// stay centered while swimming up a water column
|
||||||
state.setTarget(new MovementState.MovementTarget(RotationUtils.calcRotationFromVec3d(playerHead(), VecUtils.getBlockPosCenter(dest)), false));
|
state.setTarget(new MovementState.MovementTarget(RotationUtils.calcRotationFromVec3d(playerHead(), VecUtils.getBlockPosCenter(dest)), false));
|
||||||
Vec3d destCenter = VecUtils.getBlockPosCenter(dest);
|
Vec3d destCenter = VecUtils.getBlockPosCenter(dest);
|
||||||
@ -240,7 +240,7 @@ public class MovementPillar extends Movement {
|
|||||||
state.setInput(InputOverrideHandler.Input.SNEAK, true);
|
state.setInput(InputOverrideHandler.Input.SNEAK, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (BlockStateInterface.isWater(dest.up())) {
|
if (MovementHelper.isWater(dest.up())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return super.prepared(state);
|
return super.prepared(state);
|
||||||
|
@ -66,7 +66,7 @@ public class MovementTraverse extends Movement {
|
|||||||
if (MovementHelper.canWalkOn(destX, y - 1, destZ, destOn)) {//this is a walk, not a bridge
|
if (MovementHelper.canWalkOn(destX, y - 1, destZ, destOn)) {//this is a walk, not a bridge
|
||||||
double WC = WALK_ONE_BLOCK_COST;
|
double WC = WALK_ONE_BLOCK_COST;
|
||||||
boolean water = false;
|
boolean water = false;
|
||||||
if (BlockStateInterface.isWater(pb0.getBlock()) || BlockStateInterface.isWater(pb1.getBlock())) {
|
if (MovementHelper.isWater(pb0.getBlock()) || MovementHelper.isWater(pb1.getBlock())) {
|
||||||
WC = context.waterWalkSpeed();
|
WC = context.waterWalkSpeed();
|
||||||
water = true;
|
water = true;
|
||||||
} else {
|
} else {
|
||||||
@ -101,8 +101,8 @@ public class MovementTraverse extends Movement {
|
|||||||
return COST_INF;
|
return COST_INF;
|
||||||
}
|
}
|
||||||
if (destOn.getBlock().equals(Blocks.AIR) || MovementHelper.isReplacable(destX, y - 1, destZ, destOn)) {
|
if (destOn.getBlock().equals(Blocks.AIR) || MovementHelper.isReplacable(destX, y - 1, destZ, destOn)) {
|
||||||
boolean throughWater = BlockStateInterface.isWater(pb0.getBlock()) || BlockStateInterface.isWater(pb1.getBlock());
|
boolean throughWater = MovementHelper.isWater(pb0.getBlock()) || MovementHelper.isWater(pb1.getBlock());
|
||||||
if (BlockStateInterface.isWater(destOn.getBlock()) && throughWater) {
|
if (MovementHelper.isWater(destOn.getBlock()) && throughWater) {
|
||||||
return COST_INF;
|
return COST_INF;
|
||||||
}
|
}
|
||||||
if (!context.canPlaceThrowawayAt(destX, y - 1, destZ)) {
|
if (!context.canPlaceThrowawayAt(destX, y - 1, destZ)) {
|
||||||
@ -223,7 +223,7 @@ public class MovementTraverse extends Movement {
|
|||||||
if (playerFeet().equals(dest)) {
|
if (playerFeet().equals(dest)) {
|
||||||
return state.setStatus(MovementStatus.SUCCESS);
|
return state.setStatus(MovementStatus.SUCCESS);
|
||||||
}
|
}
|
||||||
if (wasTheBridgeBlockAlwaysThere && !BlockStateInterface.isLiquid(playerFeet())) {
|
if (wasTheBridgeBlockAlwaysThere && !MovementHelper.isLiquid(playerFeet())) {
|
||||||
state.setInput(InputOverrideHandler.Input.SPRINT, true);
|
state.setInput(InputOverrideHandler.Input.SPRINT, true);
|
||||||
}
|
}
|
||||||
Block destDown = BlockStateInterface.get(dest.down()).getBlock();
|
Block destDown = BlockStateInterface.get(dest.down()).getBlock();
|
||||||
|
@ -22,7 +22,6 @@ import baritone.cache.CachedRegion;
|
|||||||
import baritone.cache.WorldData;
|
import baritone.cache.WorldData;
|
||||||
import baritone.cache.WorldProvider;
|
import baritone.cache.WorldProvider;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockLiquid;
|
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.init.Blocks;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
@ -128,47 +127,4 @@ public class BlockStateInterface implements Helper {
|
|||||||
public static Block getBlock(int x, int y, int z) {
|
public static Block getBlock(int x, int y, int z) {
|
||||||
return get(x, y, z).getBlock();
|
return get(x, y, z).getBlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns whether or not the specified block is
|
|
||||||
* water, regardless of whether or not it is flowing.
|
|
||||||
*
|
|
||||||
* @param b The block
|
|
||||||
* @return Whether or not the block is water
|
|
||||||
*/
|
|
||||||
public static boolean isWater(Block b) {
|
|
||||||
return b == Blocks.FLOWING_WATER || b == Blocks.WATER;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns whether or not the block at the specified pos is
|
|
||||||
* water, regardless of whether or not it is flowing.
|
|
||||||
*
|
|
||||||
* @param bp The block pos
|
|
||||||
* @return Whether or not the block is water
|
|
||||||
*/
|
|
||||||
public static boolean isWater(BlockPos bp) {
|
|
||||||
return isWater(BlockStateInterface.getBlock(bp));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isLava(Block b) {
|
|
||||||
return b == Blocks.FLOWING_LAVA || b == Blocks.LAVA;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns whether or not the specified pos has a liquid
|
|
||||||
*
|
|
||||||
* @param p The pos
|
|
||||||
* @return Whether or not the block is a liquid
|
|
||||||
*/
|
|
||||||
public static boolean isLiquid(BlockPos p) {
|
|
||||||
return BlockStateInterface.getBlock(p) instanceof BlockLiquid;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isFlowing(IBlockState state) {
|
|
||||||
// Will be IFluidState in 1.13
|
|
||||||
return state.getBlock() instanceof BlockLiquid
|
|
||||||
&& state.getPropertyKeys().contains(BlockLiquid.LEVEL)
|
|
||||||
&& state.getValue(BlockLiquid.LEVEL) != 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user