use of net.minecraft.block.FenceBlock in project endergetic by team-abnormals.
the class BolloomBalloonItem method useOn.
@Override
public ActionResultType useOn(ItemUseContext context) {
BlockPos pos = context.getClickedPos();
World world = context.getLevel();
Block block = world.getBlockState(pos).getBlock();
if (block instanceof FenceBlock) {
if (this.isAirUpwards(world, pos)) {
if (!world.isClientSide) {
ItemStack stack = context.getItemInHand();
if (this.attachToFence(pos, world, stack)) {
stack.shrink(1);
return ActionResultType.SUCCESS;
}
}
} else {
return ActionResultType.FAIL;
}
for (Entity entity : world.getEntitiesOfClass(Entity.class, new AxisAlignedBB(pos))) {
if (entity instanceof BolloomKnotEntity) {
if (((BolloomKnotEntity) entity).hasMaxBalloons()) {
return ActionResultType.FAIL;
}
}
}
}
return ActionResultType.PASS;
}
use of net.minecraft.block.FenceBlock in project ChocolateQuestRepoured by TeamChocoQuest.
the class PathNavigateGroundCQR method getPathFinder.
@Override
protected PathFinder getPathFinder() {
this.nodeProcessor = new WalkNodeProcessor() {
@Override
public PathNodeType getPathNodeType(IBlockAccess p_193577_1_, int x, int y, int z, int xSize, int ySize, int zSize, boolean canOpenDoorsIn, boolean canEnterDoorsIn, EnumSet<PathNodeType> p_193577_10_, PathNodeType p_193577_11_, BlockPos p_193577_12_) {
for (int i = 0; i < xSize; ++i) {
for (int j = 0; j < ySize; ++j) {
for (int k = 0; k < zSize; ++k) {
int l = i + x;
int i1 = j + y;
int j1 = k + z;
PathNodeType pathnodetype = this.getPathNodeType(p_193577_1_, l, i1, j1);
if (pathnodetype == PathNodeType.DOOR_WOOD_CLOSED && canOpenDoorsIn && canEnterDoorsIn) {
pathnodetype = PathNodeType.WALKABLE;
}
// TODO better method for calculating the facing from which the door will be entered
if (pathnodetype == PathNodeType.DOOR_IRON_CLOSED && canOpenDoorsIn && canEnterDoorsIn && EntityAIOpenCloseDoor.canMoveThroughDoor(p_193577_1_, new BlockPos(l, i1, j1), Direction.getFacingFromVector(l - p_193577_12_.getX(), i1 - p_193577_12_.getY(), j1 - p_193577_12_.getZ()).getOpposite(), true)) {
pathnodetype = PathNodeType.WALKABLE;
}
if (pathnodetype == PathNodeType.DOOR_OPEN && !canEnterDoorsIn) {
pathnodetype = PathNodeType.BLOCKED;
}
if (pathnodetype == PathNodeType.RAIL && !(p_193577_1_.getBlockState(p_193577_12_).getBlock() instanceof AbstractRailBlock) && !(p_193577_1_.getBlockState(p_193577_12_.down()).getBlock() instanceof AbstractRailBlock)) {
pathnodetype = PathNodeType.FENCE;
}
if (i == 0 && j == 0 && k == 0) {
p_193577_11_ = pathnodetype;
}
p_193577_10_.add(pathnodetype);
}
}
}
return p_193577_11_;
}
@Override
protected PathNodeType getPathNodeTypeRaw(IBlockAccess p_189553_1_, int p_189553_2_, int p_189553_3_, int p_189553_4_) {
BlockPos blockpos = new BlockPos(p_189553_2_, p_189553_3_, p_189553_4_);
BlockState iblockstate = p_189553_1_.getBlockState(blockpos);
Block block = iblockstate.getBlock();
Material material = iblockstate.getMaterial();
PathNodeType type = block.getAiPathNodeType(iblockstate, p_189553_1_, blockpos, this.currentEntity);
if (type != null) {
return type;
}
if (material == Material.AIR) {
return PathNodeType.OPEN;
} else if (block != Blocks.TRAPDOOR && block != Blocks.IRON_TRAPDOOR && block != Blocks.WATERLILY) {
if (block == Blocks.FIRE) {
return PathNodeType.DAMAGE_FIRE;
} else if (block == Blocks.CACTUS) {
return PathNodeType.DAMAGE_CACTUS;
} else if (block instanceof DoorBlock && material == Material.WOOD && !iblockstate.getActualState(p_189553_1_, blockpos).getValue(DoorBlock.OPEN)) {
return PathNodeType.DOOR_WOOD_CLOSED;
} else if (block instanceof DoorBlock && material == Material.IRON && !iblockstate.getActualState(p_189553_1_, blockpos).getValue(DoorBlock.OPEN)) {
return PathNodeType.DOOR_IRON_CLOSED;
} else if (block instanceof DoorBlock && iblockstate.getActualState(p_189553_1_, blockpos).getValue(DoorBlock.OPEN)) {
return PathNodeType.DOOR_OPEN;
} else if (block instanceof AbstractRailBlock) {
return PathNodeType.RAIL;
} else if (!(block instanceof FenceBlock) && !(block instanceof WallBlock) && (!(block instanceof FenceGateBlock) || iblockstate.getValue(FenceGateBlock.OPEN).booleanValue())) {
if (material == Material.WATER) {
return PathNodeType.WATER;
} else if (material == Material.LAVA) {
return PathNodeType.LAVA;
} else {
return block.isPassable(p_189553_1_, blockpos) ? PathNodeType.OPEN : PathNodeType.BLOCKED;
}
} else {
return PathNodeType.FENCE;
}
} else {
return PathNodeType.TRAPDOOR;
}
}
};
this.nodeProcessor.setCanEnterDoors(true);
this.pathFinder = new PathFinder(this.nodeProcessor);
return this.pathFinder;
}
use of net.minecraft.block.FenceBlock in project MCMOD-Industria by M-Marvin.
the class BlockBurnedBlock method scann.
@SuppressWarnings("deprecation")
public static int scann(World world, BlockPos pos, List<BlockPos> posList, int depth) {
if (depth < 8 && !posList.contains(pos)) {
int dist = 8;
posList.add(pos);
for (Direction d : Direction.values()) {
BlockPos scanPos = pos.relative(d);
BlockState scanState = world.getBlockState(scanPos);
if (canHoldBurnedBlocks(world, pos, scanState)) {
return depth + 1;
} else if ((scanState.isSolidRender(world, pos) || scanState.getBlock() instanceof FenceBlock || scanState.getBlock() instanceof TrapDoorBlock || scanState.getBlock() instanceof DoorBlock) && !scanState.isAir()) {
int i = scann(world, scanPos, posList, depth + 1);
if (i < dist)
dist = i;
}
}
return dist;
}
return 8;
}
use of net.minecraft.block.FenceBlock in project MCMOD-Industria by M-Marvin.
the class BlockBurnedSlab method scann.
@SuppressWarnings("deprecation")
public static int scann(World world, BlockPos pos, List<BlockPos> posList, int depth) {
if (depth < 8 && !posList.contains(pos)) {
int dist = 8;
posList.add(pos);
for (Direction d : Direction.values()) {
BlockPos scanPos = pos.relative(d);
BlockState scanState = world.getBlockState(scanPos);
if (BlockBurnedBlock.canHoldBurnedBlocks(world, pos, scanState)) {
return depth + 1;
} else if ((scanState.isSolidRender(world, pos) || scanState.getBlock() instanceof FenceBlock || scanState.getBlock() instanceof TrapDoorBlock || scanState.getBlock() instanceof DoorBlock) && !scanState.isAir()) {
int i = scann(world, scanPos, posList, depth + 1);
if (i < dist)
dist = i;
}
}
return dist;
}
return 8;
}
use of net.minecraft.block.FenceBlock in project MCMOD-Industria by M-Marvin.
the class BlockBurnedStairs method scann.
@SuppressWarnings("deprecation")
public static int scann(World world, BlockPos pos, List<BlockPos> posList, int depth) {
if (depth < 8 && !posList.contains(pos)) {
int dist = 8;
posList.add(pos);
for (Direction d : Direction.values()) {
BlockPos scanPos = pos.relative(d);
BlockState scanState = world.getBlockState(scanPos);
if (BlockBurnedBlock.canHoldBurnedBlocks(world, pos, scanState)) {
return depth + 1;
} else if ((scanState.isSolidRender(world, pos) || scanState.getBlock() instanceof FenceBlock || scanState.getBlock() instanceof TrapDoorBlock || scanState.getBlock() instanceof DoorBlock) && !scanState.isAir()) {
int i = scann(world, scanPos, posList, depth + 1);
if (i < dist)
dist = i;
}
}
return dist;
}
return 8;
}
Aggregations