Search in sources :

Example 1 with FenceBlock

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;
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) FenceBlock(net.minecraft.block.FenceBlock) BoatEntity(net.minecraft.entity.item.BoatEntity) Entity(net.minecraft.entity.Entity) BolloomBalloonEntity(com.minecraftabnormals.endergetic.common.entities.bolloom.BolloomBalloonEntity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) LivingEntity(net.minecraft.entity.LivingEntity) BolloomKnotEntity(com.minecraftabnormals.endergetic.common.entities.bolloom.BolloomKnotEntity) Block(net.minecraft.block.Block) FenceBlock(net.minecraft.block.FenceBlock) DispenserBlock(net.minecraft.block.DispenserBlock) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World) ItemStack(net.minecraft.item.ItemStack) BolloomKnotEntity(com.minecraftabnormals.endergetic.common.entities.bolloom.BolloomKnotEntity)

Example 2 with FenceBlock

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;
}
Also used : IBlockAccess(net.minecraft.world.IBlockAccess) PathNodeType(net.minecraft.pathfinding.PathNodeType) Material(net.minecraft.block.material.Material) PathFinder(net.minecraft.pathfinding.PathFinder) AbstractRailBlock(net.minecraft.block.AbstractRailBlock) PathPoint(net.minecraft.pathfinding.PathPoint) WalkNodeProcessor(net.minecraft.pathfinding.WalkNodeProcessor) FenceBlock(net.minecraft.block.FenceBlock) BlockState(net.minecraft.block.BlockState) WallBlock(net.minecraft.block.WallBlock) DoorBlock(net.minecraft.block.DoorBlock) AbstractRailBlock(net.minecraft.block.AbstractRailBlock) FenceBlock(net.minecraft.block.FenceBlock) WallBlock(net.minecraft.block.WallBlock) BlockPos(net.minecraft.util.math.BlockPos) DoorBlock(net.minecraft.block.DoorBlock)

Example 3 with FenceBlock

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;
}
Also used : FenceBlock(net.minecraft.block.FenceBlock) TrapDoorBlock(net.minecraft.block.TrapDoorBlock) BlockState(net.minecraft.block.BlockState) BlockPos(net.minecraft.util.math.BlockPos) Direction(net.minecraft.util.Direction) DoorBlock(net.minecraft.block.DoorBlock) TrapDoorBlock(net.minecraft.block.TrapDoorBlock)

Example 4 with FenceBlock

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;
}
Also used : FenceBlock(net.minecraft.block.FenceBlock) TrapDoorBlock(net.minecraft.block.TrapDoorBlock) BlockState(net.minecraft.block.BlockState) BlockPos(net.minecraft.util.math.BlockPos) Direction(net.minecraft.util.Direction) DoorBlock(net.minecraft.block.DoorBlock) TrapDoorBlock(net.minecraft.block.TrapDoorBlock)

Example 5 with FenceBlock

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;
}
Also used : FenceBlock(net.minecraft.block.FenceBlock) TrapDoorBlock(net.minecraft.block.TrapDoorBlock) BlockState(net.minecraft.block.BlockState) BlockPos(net.minecraft.util.math.BlockPos) Direction(net.minecraft.util.Direction) DoorBlock(net.minecraft.block.DoorBlock) TrapDoorBlock(net.minecraft.block.TrapDoorBlock)

Aggregations

FenceBlock (net.minecraft.block.FenceBlock)5 BlockPos (net.minecraft.util.math.BlockPos)5 BlockState (net.minecraft.block.BlockState)4 DoorBlock (net.minecraft.block.DoorBlock)4 TrapDoorBlock (net.minecraft.block.TrapDoorBlock)3 Direction (net.minecraft.util.Direction)3 BolloomBalloonEntity (com.minecraftabnormals.endergetic.common.entities.bolloom.BolloomBalloonEntity)1 BolloomKnotEntity (com.minecraftabnormals.endergetic.common.entities.bolloom.BolloomKnotEntity)1 AbstractRailBlock (net.minecraft.block.AbstractRailBlock)1 Block (net.minecraft.block.Block)1 DispenserBlock (net.minecraft.block.DispenserBlock)1 WallBlock (net.minecraft.block.WallBlock)1 Material (net.minecraft.block.material.Material)1 Entity (net.minecraft.entity.Entity)1 LivingEntity (net.minecraft.entity.LivingEntity)1 BoatEntity (net.minecraft.entity.item.BoatEntity)1 PlayerEntity (net.minecraft.entity.player.PlayerEntity)1 ItemStack (net.minecraft.item.ItemStack)1 PathFinder (net.minecraft.pathfinding.PathFinder)1 PathNodeType (net.minecraft.pathfinding.PathNodeType)1