use of net.minecraft.block.DoublePlantBlock in project minecolonies by Minecolonies.
the class TileEntityCompostedDirt method updateTick.
/**
* Update tick running on the server world.
*
* @param worldIn the server world.
*/
private void updateTick(@NotNull final World worldIn) {
if (flower == null || flower.isEmpty()) {
this.composted = false;
return;
}
if (this.composted) {
((ServerWorld) worldIn).sendParticles(ParticleTypes.HAPPY_VILLAGER, this.getBlockPos().getX() + 0.5, this.getBlockPos().getY() + 1, this.getBlockPos().getZ() + 0.5, 1, 0.2, 0, 0.2, 0);
}
if (random.nextDouble() * 100 <= this.percentage) {
final BlockPos position = worldPosition.above();
if (worldIn.getBlockState(position).getBlock() instanceof AirBlock) {
if (flower.getItem() instanceof BlockItem) {
if (((BlockItem) flower.getItem()).getBlock() instanceof DoublePlantBlock) {
((DoublePlantBlock) ((BlockItem) flower.getItem()).getBlock()).placeAt(worldIn, position, UPDATE_FLAG);
} else {
worldIn.setBlockAndUpdate(position, ((BlockItem) flower.getItem()).getBlock().defaultBlockState());
}
} else {
worldIn.setBlockAndUpdate(position, BlockUtils.getBlockStateFromStack(flower));
}
}
}
if (this.ticker >= TICKER_LIMIT * TICKS_SECOND) {
this.ticker = 0;
this.composted = false;
}
}
use of net.minecraft.block.DoublePlantBlock in project minecolonies by ldtteam.
the class TileEntityCompostedDirt method updateTick.
/**
* Update tick running on the server world.
*
* @param worldIn the server world.
*/
private void updateTick(@NotNull final World worldIn) {
if (flower == null || flower.isEmpty()) {
this.composted = false;
return;
}
if (this.composted) {
((ServerWorld) worldIn).sendParticles(ParticleTypes.HAPPY_VILLAGER, this.getBlockPos().getX() + 0.5, this.getBlockPos().getY() + 1, this.getBlockPos().getZ() + 0.5, 1, 0.2, 0, 0.2, 0);
}
if (random.nextDouble() * 100 <= this.percentage) {
final BlockPos position = worldPosition.above();
if (worldIn.getBlockState(position).getBlock() instanceof AirBlock) {
if (flower.getItem() instanceof BlockItem) {
if (((BlockItem) flower.getItem()).getBlock() instanceof DoublePlantBlock) {
((DoublePlantBlock) ((BlockItem) flower.getItem()).getBlock()).placeAt(worldIn, position, UPDATE_FLAG);
} else {
worldIn.setBlockAndUpdate(position, ((BlockItem) flower.getItem()).getBlock().defaultBlockState());
}
} else {
worldIn.setBlockAndUpdate(position, BlockUtils.getBlockStateFromStack(flower));
}
}
}
if (this.ticker >= TICKER_LIMIT * TICKS_SECOND) {
this.ticker = 0;
this.composted = false;
}
}
Aggregations