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;
}
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;
}
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);
}
}
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);
}
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);
}
Aggregations