use of net.minecraft.block.BlockState in project Bookshelf by Darkhax-Minecraft.
the class SerializerBlockState method read.
@Override
public BlockState read(JsonElement json) {
if (json.isJsonObject()) {
final JsonObject obj = json.getAsJsonObject();
final Block block = Serializers.BLOCK.read(obj, "block");
BlockState state = block.defaultBlockState();
if (obj.has("properties")) {
final JsonElement properties = obj.get("properties");
for (final Entry<String, JsonElement> property : properties.getAsJsonObject().entrySet()) {
state = this.readProperty(state, property.getKey(), property.getValue());
}
}
return state;
} else {
throw new JsonParseException("Expected properties to be an object. Recieved " + JSONUtils.getType(json));
}
}
use of net.minecraft.block.BlockState in project Bookshelf by Darkhax-Minecraft.
the class TileEntityBasic method sync.
/**
* Synchronizes the server state of the tile with all clients tracking it.
*
* @param renderUpdate Whether or not a render update should happen as well. Only use this
* if you need to change the block model.
*/
public void sync(boolean renderUpdate) {
if (renderUpdate) {
this.setChanged();
final BlockState state = this.getState();
this.level.sendBlockUpdated(this.worldPosition, state, state, BlockFlags.DEFAULT_AND_RERENDER);
} else if (this.level instanceof ServerWorld) {
final IPacket<?> packet = this.getUpdatePacket();
WorldUtils.sendToTracking((ServerWorld) this.level, this.getChunkPos(), packet, false);
}
}
use of net.minecraft.block.BlockState in project NetherEx by LogicTechCorp.
the class NetherSurfaceBuilderWrapper method buildSurface.
@Override
public void buildSurface(Random random, IChunk chunk, Biome biome, int chunkX, int chunkZ, int startHeight, double noise, BlockState defaultState, BlockState defaultLiquid, int seaLevel, long seed, Config config) {
if (seaLevel != 32) {
config.getOriginalBuilder().buildSurface(random, chunk, biome, chunkX, chunkZ, startHeight, noise, defaultState, defaultLiquid, seaLevel, seed);
} else {
int posX = chunkX & 15;
int posZ = chunkZ & 15;
BlockPos.Mutable mutablePos = new BlockPos.Mutable();
boolean wasLastBlockNonSolid = false;
for (int posY = 127; posY >= 0; posY--) {
mutablePos = mutablePos.setPos(posX, posY, posZ);
BlockState checkState = chunk.getBlockState(mutablePos);
if (checkState.isAir(chunk, mutablePos)) {
wasLastBlockNonSolid = true;
} else if (checkState == defaultState) {
if (wasLastBlockNonSolid) {
if (posY < seaLevel) {
chunk.setBlockState(mutablePos, config.getLiquid(), false);
} else {
chunk.setBlockState(mutablePos, config.getTop(), false);
}
} else {
chunk.setBlockState(mutablePos, config.getUnder(), false);
}
wasLastBlockNonSolid = false;
} else if (checkState == defaultLiquid) {
chunk.setBlockState(mutablePos, config.getLiquid(), false);
wasLastBlockNonSolid = true;
}
}
}
}
use of net.minecraft.block.BlockState in project NetherEx by LogicTechCorp.
the class EnokiStemBlock method isValidPosition.
@Override
public boolean isValidPosition(BlockState state, IWorldReader world, BlockPos pos) {
BlockState upState = world.getBlockState(pos.up());
boolean flag = !world.getBlockState(pos.down()).isAir() && !upState.isAir();
for (Direction direction : Direction.Plane.HORIZONTAL) {
BlockPos offsetPos = pos.offset(direction);
Block block = world.getBlockState(offsetPos).getBlock();
if (block == this) {
if (flag) {
return false;
}
Block upBlock = world.getBlockState(offsetPos.up()).getBlock();
if (upBlock == this || upBlock == NetherExBlocks.LIVELY_NETHERRACK.get()) {
return true;
}
}
}
Block upBlock = upState.getBlock();
return upBlock == this || upBlock == NetherExBlocks.LIVELY_NETHERRACK.get();
}
use of net.minecraft.block.BlockState in project NetherEx by LogicTechCorp.
the class NetherCaveCarverOverride method func_225556_a_.
@Override
protected boolean func_225556_a_(IChunk chunk, Function<BlockPos, Biome> posBiomeFunction, BitSet carvingMask, Random random, BlockPos.Mutable mutablePos, BlockPos.Mutable mutablePosUp, BlockPos.Mutable mutablePosDown, int minY, int minX, int minZ, int posX, int posZ, int p_222703_12_, int posY, int p_222703_14_, AtomicBoolean isDefaultTopBlock) {
int bitIndex = p_222703_12_ | p_222703_14_ << 4 | posY << 8;
if (carvingMask.get(bitIndex)) {
return false;
} else {
carvingMask.set(bitIndex);
mutablePos.setPos(posX, posY, posZ);
mutablePosUp.setPos(mutablePos).move(Direction.UP);
if (this.canCarveBlock(chunk.getBlockState(mutablePos), chunk.getBlockState(mutablePosUp))) {
BlockState state;
if (posY <= 31) {
state = LAVA.getBlockState();
BiomeData biomeData = NetherEx.BIOME_DATA_MANAGER.getBiomeData(posBiomeFunction.apply(mutablePos));
if (biomeData != BiomeData.EMPTY) {
state = biomeData.getBiomeBlock(BiomeData.BlockType.LIQUID_BLOCK);
}
} else {
state = CAVE_AIR;
}
chunk.setBlockState(mutablePos, state, false);
return true;
} else {
return false;
}
}
}
Aggregations