Search in sources :

Example 1 with WorldView

use of net.minecraft.world.WorldView in project Blockus by Brandcraf06.

the class Barrier method getPlacementState.

public BlockState getPlacementState(ItemPlacementContext ctx) {
    WorldView worldView = ctx.getWorld();
    BlockPos blockPos = ctx.getBlockPos();
    FluidState fluidState = ctx.getWorld().getFluidState(ctx.getBlockPos());
    BlockPos blockPos2 = blockPos.north();
    BlockPos blockPos3 = blockPos.east();
    BlockPos blockPos4 = blockPos.south();
    BlockPos blockPos5 = blockPos.west();
    BlockPos blockPos6 = blockPos.up();
    BlockState blockState = worldView.getBlockState(blockPos2);
    BlockState blockState2 = worldView.getBlockState(blockPos3);
    BlockState blockState3 = worldView.getBlockState(blockPos4);
    BlockState blockState4 = worldView.getBlockState(blockPos5);
    BlockState blockState5 = worldView.getBlockState(blockPos6);
    boolean bl = this.shouldConnectTo(blockState, blockState.isSideSolidFullSquare(worldView, blockPos2, Direction.SOUTH), Direction.SOUTH);
    boolean bl2 = this.shouldConnectTo(blockState2, blockState2.isSideSolidFullSquare(worldView, blockPos3, Direction.WEST), Direction.WEST);
    boolean bl3 = this.shouldConnectTo(blockState3, blockState3.isSideSolidFullSquare(worldView, blockPos4, Direction.NORTH), Direction.NORTH);
    boolean bl4 = this.shouldConnectTo(blockState4, blockState4.isSideSolidFullSquare(worldView, blockPos5, Direction.EAST), Direction.EAST);
    BlockState blockState6 = this.getDefaultState().with(WATERLOGGED, fluidState.getFluid() == Fluids.WATER);
    return this.method_24422(worldView, blockState6, blockPos6, blockState5, bl, bl2, bl3, bl4);
}
Also used : WorldView(net.minecraft.world.WorldView) BlockPos(net.minecraft.util.math.BlockPos) FluidState(net.minecraft.fluid.FluidState)

Example 2 with WorldView

use of net.minecraft.world.WorldView in project Biome-Makeover by Lemonszz.

the class AdjudicatorTapestryWallBlock method getPlacementState.

public BlockState getPlacementState(ItemPlacementContext ctx) {
    BlockState blockState = this.getDefaultState();
    WorldView worldView = ctx.getWorld();
    BlockPos blockPos = ctx.getBlockPos();
    Direction[] directions = ctx.getPlacementDirections();
    Direction[] var6 = directions;
    int var7 = directions.length;
    for (int i = 0; i < var7; ++i) {
        Direction direction = var6[i];
        if (direction.getAxis().isHorizontal()) {
            Direction direction2 = direction.getOpposite();
            blockState = blockState.with(FACING, direction2);
            if (blockState.canPlaceAt(worldView, blockPos)) {
                return blockState;
            }
        }
    }
    return null;
}
Also used : WorldView(net.minecraft.world.WorldView) BlockPos(net.minecraft.util.math.BlockPos) Direction(net.minecraft.util.math.Direction)

Example 3 with WorldView

use of net.minecraft.world.WorldView in project Biome-Makeover by Lemonszz.

the class TapestryWallBlock method getPlacementState.

public BlockState getPlacementState(ItemPlacementContext ctx) {
    BlockState blockState = this.getDefaultState();
    WorldView worldView = ctx.getWorld();
    BlockPos blockPos = ctx.getBlockPos();
    Direction[] directions = ctx.getPlacementDirections();
    Direction[] var6 = directions;
    int var7 = directions.length;
    for (int i = 0; i < var7; ++i) {
        Direction direction = var6[i];
        if (direction.getAxis().isHorizontal()) {
            Direction direction2 = direction.getOpposite();
            blockState = blockState.with(FACING, direction2);
            if (blockState.canPlaceAt(worldView, blockPos)) {
                return blockState;
            }
        }
    }
    return null;
}
Also used : WorldView(net.minecraft.world.WorldView) BlockPos(net.minecraft.util.math.BlockPos) Direction(net.minecraft.util.math.Direction)

Example 4 with WorldView

use of net.minecraft.world.WorldView in project Blockus by Brandcraf06.

the class SmallHedgeBlock method getPlacementState.

public BlockState getPlacementState(ItemPlacementContext ctx) {
    WorldView worldView = ctx.getWorld();
    BlockPos blockPos = ctx.getBlockPos();
    FluidState fluidState = ctx.getWorld().getFluidState(ctx.getBlockPos());
    BlockPos blockPos2 = blockPos.north();
    BlockPos blockPos3 = blockPos.east();
    BlockPos blockPos4 = blockPos.south();
    BlockPos blockPos5 = blockPos.west();
    BlockPos blockPos6 = blockPos.up();
    BlockState blockState = worldView.getBlockState(blockPos2);
    BlockState blockState2 = worldView.getBlockState(blockPos3);
    BlockState blockState3 = worldView.getBlockState(blockPos4);
    BlockState blockState4 = worldView.getBlockState(blockPos5);
    BlockState blockState5 = worldView.getBlockState(blockPos6);
    boolean bl = this.shouldConnectTo(blockState, blockState.isSideSolidFullSquare(worldView, blockPos2, Direction.SOUTH), Direction.SOUTH);
    boolean bl2 = this.shouldConnectTo(blockState2, blockState2.isSideSolidFullSquare(worldView, blockPos3, Direction.WEST), Direction.WEST);
    boolean bl3 = this.shouldConnectTo(blockState3, blockState3.isSideSolidFullSquare(worldView, blockPos4, Direction.NORTH), Direction.NORTH);
    boolean bl4 = this.shouldConnectTo(blockState4, blockState4.isSideSolidFullSquare(worldView, blockPos5, Direction.EAST), Direction.EAST);
    BlockState blockState6 = this.getDefaultState().with(WATERLOGGED, fluidState.getFluid() == Fluids.WATER);
    return this.method_24422(worldView, blockState6, blockPos6, blockState5, bl, bl2, bl3, bl4);
}
Also used : WorldView(net.minecraft.world.WorldView) BlockPos(net.minecraft.util.math.BlockPos) FluidState(net.minecraft.fluid.FluidState)

Example 5 with WorldView

use of net.minecraft.world.WorldView in project beyond-earth-fabricated by SomeoneIs404.

the class WallCoalTorchBlock method getPlacementState.

@Override
public BlockState getPlacementState(ItemPlacementContext ctx) {
    BlockState blockState = this.getDefaultState();
    WorldView worldView = ctx.getWorld();
    BlockPos blockPos = ctx.getBlockPos();
    for (Direction direction : ctx.getPlacementDirections()) {
        if (direction.getAxis().isHorizontal()) {
            blockState = blockState.with(FACING, direction.getOpposite());
            if (blockState.canPlaceAt(worldView, blockPos)) {
                return blockState;
            }
        }
    }
    return null;
}
Also used : WorldView(net.minecraft.world.WorldView) BlockPos(net.minecraft.util.math.BlockPos) Direction(net.minecraft.util.math.Direction)

Aggregations

BlockPos (net.minecraft.util.math.BlockPos)5 WorldView (net.minecraft.world.WorldView)5 Direction (net.minecraft.util.math.Direction)3 FluidState (net.minecraft.fluid.FluidState)2