Search in sources :

Example 1 with LazyBlockState

use of com.almuradev.content.type.block.state.LazyBlockState in project Almura by AlmuraDev.

the class GrassFeature method canPlace.

private boolean canPlace(final IBlockAccess access, final BlockPos pos, final IBlockState toPlaceState, final List<LazyBlockState> requires) {
    World world;
    if (access instanceof ChunkCache) {
        world = ((ChunkCacheAccessor) access).accessor$getWorld();
    } else {
        world = (World) access;
    }
    final Block toPlaceBlock = toPlaceState.getBlock();
    boolean canPlace = true;
    if (!requires.isEmpty()) {
        final IBlockState underState = access.getBlockState(pos.down());
        boolean found = false;
        for (final LazyBlockState lbs : requires) {
            if (lbs.partialTest(underState)) {
                found = true;
                break;
            }
        }
        canPlace = found;
    }
    if (canPlace) {
        if (toPlaceBlock instanceof BlockBush) {
            canPlace = ((BlockBush) toPlaceBlock).canBlockStay(world, pos, toPlaceState);
        }
    }
    return canPlace;
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) ChunkCache(net.minecraft.world.ChunkCache) Block(net.minecraft.block.Block) World(net.minecraft.world.World) WeightedLazyBlockState(com.almuradev.content.util.WeightedLazyBlockState) LazyBlockState(com.almuradev.content.type.block.state.LazyBlockState) BlockBush(net.minecraft.block.BlockBush)

Example 2 with LazyBlockState

use of com.almuradev.content.type.block.state.LazyBlockState in project Almura by AlmuraDev.

the class CactusFeature method canPlace.

private boolean canPlace(final IBlockAccess access, final BlockPos pos, final IBlockState toPlaceState, final List<LazyBlockState> requires) {
    World world;
    if (access instanceof ChunkCache) {
        world = ((ChunkCacheAccessor) access).accessor$getWorld();
    } else {
        world = (World) access;
    }
    final Block toPlaceBlock = toPlaceState.getBlock();
    boolean canPlace = true;
    if (!requires.isEmpty()) {
        final IBlockState underState = access.getBlockState(pos.down());
        boolean found = false;
        for (final LazyBlockState lbs : requires) {
            if (lbs.partialTest(underState)) {
                found = true;
                break;
            }
        }
        canPlace = found;
    }
    if (canPlace) {
        // Why Vanilla lol
        if (toPlaceBlock instanceof BlockCactus) {
            canPlace = ((BlockCactus) toPlaceBlock).canBlockStay(world, pos);
        } else if (toPlaceBlock instanceof BlockBush) {
            canPlace = ((BlockBush) toPlaceBlock).canBlockStay(world, pos, toPlaceState);
        }
    }
    return canPlace;
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) ChunkCache(net.minecraft.world.ChunkCache) Block(net.minecraft.block.Block) World(net.minecraft.world.World) BlockCactus(net.minecraft.block.BlockCactus) WeightedLazyBlockState(com.almuradev.content.util.WeightedLazyBlockState) LazyBlockState(com.almuradev.content.type.block.state.LazyBlockState) BlockBush(net.minecraft.block.BlockBush)

Example 3 with LazyBlockState

use of com.almuradev.content.type.block.state.LazyBlockState in project Almura by AlmuraDev.

the class FlowerFeature method canPlace.

private boolean canPlace(final IBlockAccess access, final BlockPos pos, final IBlockState toPlaceState, final List<LazyBlockState> requires) {
    World world;
    if (access instanceof ChunkCache) {
        world = ((ChunkCacheAccessor) access).accessor$getWorld();
    } else {
        world = (World) access;
    }
    final Block toPlaceBlock = toPlaceState.getBlock();
    boolean canPlace = true;
    if (!requires.isEmpty()) {
        final IBlockState underState = access.getBlockState(pos.down());
        boolean found = false;
        for (final LazyBlockState lbs : requires) {
            if (lbs.partialTest(underState)) {
                found = true;
                break;
            }
        }
        canPlace = found;
    }
    if (canPlace) {
        // Why Vanilla lol
        if (toPlaceBlock instanceof BlockCactus) {
            canPlace = ((BlockCactus) toPlaceBlock).canBlockStay(world, pos);
        } else if (toPlaceBlock instanceof BlockBush) {
            canPlace = ((BlockBush) toPlaceBlock).canBlockStay(world, pos, toPlaceState);
        }
    }
    return canPlace;
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) ChunkCache(net.minecraft.world.ChunkCache) Block(net.minecraft.block.Block) World(net.minecraft.world.World) BlockCactus(net.minecraft.block.BlockCactus) WeightedLazyBlockState(com.almuradev.content.util.WeightedLazyBlockState) LazyBlockState(com.almuradev.content.type.block.state.LazyBlockState) BlockBush(net.minecraft.block.BlockBush)

Example 4 with LazyBlockState

use of com.almuradev.content.type.block.state.LazyBlockState in project Almura by AlmuraDev.

the class DeadBushFeature method canPlace.

private boolean canPlace(final IBlockAccess access, final BlockPos pos, final IBlockState toPlaceState, final List<LazyBlockState> requires) {
    World world;
    if (access instanceof ChunkCache) {
        world = ((ChunkCacheAccessor) access).accessor$getWorld();
    } else {
        world = (World) access;
    }
    final Block toPlaceBlock = toPlaceState.getBlock();
    boolean canPlace = true;
    if (!requires.isEmpty()) {
        final IBlockState underState = access.getBlockState(pos.down());
        boolean found = false;
        for (final LazyBlockState lbs : requires) {
            if (lbs.partialTest(underState)) {
                found = true;
                break;
            }
        }
        canPlace = found;
    }
    if (canPlace) {
        // Why Vanilla lol
        if (toPlaceBlock instanceof BlockCactus) {
            canPlace = ((BlockCactus) toPlaceBlock).canBlockStay(world, pos);
        } else if (toPlaceBlock instanceof BlockBush) {
            canPlace = ((BlockBush) toPlaceBlock).canBlockStay(world, pos, toPlaceState);
        }
    }
    return canPlace;
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) ChunkCache(net.minecraft.world.ChunkCache) Block(net.minecraft.block.Block) World(net.minecraft.world.World) BlockCactus(net.minecraft.block.BlockCactus) WeightedLazyBlockState(com.almuradev.content.util.WeightedLazyBlockState) LazyBlockState(com.almuradev.content.type.block.state.LazyBlockState) BlockBush(net.minecraft.block.BlockBush)

Aggregations

LazyBlockState (com.almuradev.content.type.block.state.LazyBlockState)4 WeightedLazyBlockState (com.almuradev.content.util.WeightedLazyBlockState)4 Block (net.minecraft.block.Block)4 BlockBush (net.minecraft.block.BlockBush)4 IBlockState (net.minecraft.block.state.IBlockState)4 ChunkCache (net.minecraft.world.ChunkCache)4 World (net.minecraft.world.World)4 BlockCactus (net.minecraft.block.BlockCactus)3