Search in sources :

Example 1 with DoublePlantBlock

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;
    }
}
Also used : ServerWorld(net.minecraft.world.server.ServerWorld) AirBlock(net.minecraft.block.AirBlock) BlockPos(net.minecraft.util.math.BlockPos) BlockItem(net.minecraft.item.BlockItem) DoublePlantBlock(net.minecraft.block.DoublePlantBlock)

Example 2 with DoublePlantBlock

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;
    }
}
Also used : ServerWorld(net.minecraft.world.server.ServerWorld) AirBlock(net.minecraft.block.AirBlock) BlockPos(net.minecraft.util.math.BlockPos) BlockItem(net.minecraft.item.BlockItem) DoublePlantBlock(net.minecraft.block.DoublePlantBlock)

Aggregations

AirBlock (net.minecraft.block.AirBlock)2 DoublePlantBlock (net.minecraft.block.DoublePlantBlock)2 BlockItem (net.minecraft.item.BlockItem)2 BlockPos (net.minecraft.util.math.BlockPos)2 ServerWorld (net.minecraft.world.server.ServerWorld)2