Search in sources :

Example 26 with ChunkCache

use of net.minecraft.world.ChunkCache 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 27 with ChunkCache

use of net.minecraft.world.ChunkCache 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)

Example 28 with ChunkCache

use of net.minecraft.world.ChunkCache in project RFTools by McJty.

the class LogicSlabBlock method getActualState.

@Override
public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) {
    int meta = state.getValue(META_INTERMEDIATE);
    TileEntity te = world instanceof ChunkCache ? ((ChunkCache) world).getTileEntity(pos, Chunk.EnumCreateEntityType.CHECK) : world.getTileEntity(pos);
    if (te instanceof LogicTileEntity) {
        LogicTileEntity logicTileEntity = (LogicTileEntity) te;
        LogicFacing facing = logicTileEntity.getFacing(state);
        facing = LogicFacing.getFacingWithMeta(facing, meta);
        return state.withProperty(LOGIC_FACING, facing);
    } else {
        Logging.warn(null, "LogicSlabBlock missing its tile entity!");
        return state.withProperty(LOGIC_FACING, LogicFacing.DOWN_TONORTH);
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) ChunkCache(net.minecraft.world.ChunkCache) LogicFacing(mcjty.rftools.blocks.logic.generic.LogicFacing)

Example 29 with ChunkCache

use of net.minecraft.world.ChunkCache in project RFTools by McJty.

the class SolidShieldBlock method getActualState.

@Override
public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) {
    TileEntity te = world instanceof ChunkCache ? ((ChunkCache) world).getTileEntity(pos, Chunk.EnumCreateEntityType.CHECK) : world.getTileEntity(pos);
    if (te instanceof NoTickShieldBlockTileEntity) {
        NoTickShieldBlockTileEntity tileEntity = (NoTickShieldBlockTileEntity) te;
        ShieldRenderingMode mode = tileEntity.getShieldRenderingMode();
        if (mode == ShieldRenderingMode.MODE_TRANSP) {
            return state.withProperty(ICON_TOPDOWN, 4).withProperty(ICON_SIDE, 4);
        } else if (mode == ShieldRenderingMode.MODE_SOLID) {
            return state.withProperty(ICON_TOPDOWN, 5).withProperty(ICON_SIDE, 5);
        }
    }
    int x = pos.getX();
    int y = pos.getY();
    int z = pos.getZ();
    int topdown = (z & 0x1) * 2 + (x & 0x1);
    int side = (y & 0x1) * 2 + ((x + z) & 0x1);
    return state.withProperty(ICON_TOPDOWN, topdown).withProperty(ICON_SIDE, side);
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) ChunkCache(net.minecraft.world.ChunkCache)

Example 30 with ChunkCache

use of net.minecraft.world.ChunkCache in project XNet by McJty.

the class RouterBlock method getActualState.

@Override
public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) {
    TileEntity te = world instanceof ChunkCache ? ((ChunkCache) world).getTileEntity(pos, Chunk.EnumCreateEntityType.CHECK) : world.getTileEntity(pos);
    boolean error = false;
    if (te instanceof TileEntityRouter) {
        error = ((TileEntityRouter) te).inError();
    }
    return state.withProperty(ERROR, error);
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) ChunkCache(net.minecraft.world.ChunkCache)

Aggregations

ChunkCache (net.minecraft.world.ChunkCache)36 TileEntity (net.minecraft.tileentity.TileEntity)16 BlockPos (net.minecraft.util.math.BlockPos)9 IBlockState (net.minecraft.block.state.IBlockState)8 Block (net.minecraft.block.Block)5 World (net.minecraft.world.World)5 LazyBlockState (com.almuradev.content.type.block.state.LazyBlockState)4 WeightedLazyBlockState (com.almuradev.content.util.WeightedLazyBlockState)4 ArrayList (java.util.ArrayList)4 BlockBush (net.minecraft.block.BlockBush)4 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)4 IBlockAccess (net.minecraft.world.IBlockAccess)4 TIntArrayList (gnu.trove.list.array.TIntArrayList)3 BlockCactus (net.minecraft.block.BlockCactus)3 ItemStack (net.minecraft.item.ItemStack)3 PathEntity (net.minecraft.pathfinding.PathEntity)3 PathPoint (net.minecraft.pathfinding.PathPoint)3 MutableBlockPos (net.minecraft.util.math.BlockPos.MutableBlockPos)3 Chunk (net.minecraft.world.chunk.Chunk)3 ExtendedBlockStorage (net.minecraft.world.chunk.storage.ExtendedBlockStorage)3