63 lines
2.7 KiB
Java
63 lines
2.7 KiB
Java
package net.minecraft.world.level.block;
|
|
|
|
import net.minecraft.world.level.block.state.AbstractStateHolder;
|
|
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
|
import net.minecraft.world.level.block.state.StateDefinition;
|
|
import net.minecraft.world.level.ItemLike;
|
|
import net.minecraft.world.item.Items;
|
|
import net.minecraft.world.item.ItemStack;
|
|
import java.util.Random;
|
|
import net.minecraft.server.level.ServerLevel;
|
|
import net.minecraft.world.phys.shapes.CollisionContext;
|
|
import net.minecraft.core.BlockPos;
|
|
import net.minecraft.world.level.BlockGetter;
|
|
import net.minecraft.world.level.block.state.properties.Property;
|
|
import net.minecraft.world.level.block.state.BlockState;
|
|
import net.minecraft.world.phys.shapes.VoxelShape;
|
|
import net.minecraft.world.level.block.state.properties.IntegerProperty;
|
|
|
|
public class NetherWartBlock extends BushBlock {
|
|
public static final IntegerProperty AGE;
|
|
private static final VoxelShape[] SHAPE_BY_AGE;
|
|
|
|
protected NetherWartBlock(final Properties c) {
|
|
super(c);
|
|
this.registerDefaultState(((AbstractStateHolder<O, BlockState>)this.stateDefinition.any()).<Comparable, Integer>setValue((Property<Comparable>)NetherWartBlock.AGE, 0));
|
|
}
|
|
|
|
@Override
|
|
public VoxelShape getShape(final BlockState byg, final BlockGetter bjd, final BlockPos fk, final CollisionContext cvn) {
|
|
return NetherWartBlock.SHAPE_BY_AGE[byg.<Integer>getValue((Property<Integer>)NetherWartBlock.AGE)];
|
|
}
|
|
|
|
@Override
|
|
protected boolean mayPlaceOn(final BlockState byg, final BlockGetter bjd, final BlockPos fk) {
|
|
return byg.getBlock() == Blocks.SOUL_SAND;
|
|
}
|
|
|
|
@Override
|
|
public void tick(BlockState byg, final ServerLevel xd, final BlockPos fk, final Random random) {
|
|
final int integer6 = byg.<Integer>getValue((Property<Integer>)NetherWartBlock.AGE);
|
|
if (integer6 < 3 && random.nextInt(10) == 0) {
|
|
byg = ((AbstractStateHolder<O, BlockState>)byg).<Comparable, Integer>setValue((Property<Comparable>)NetherWartBlock.AGE, integer6 + 1);
|
|
xd.setBlock(fk, byg, 2);
|
|
}
|
|
super.tick(byg, xd, fk, random);
|
|
}
|
|
|
|
@Override
|
|
public ItemStack getCloneItemStack(final BlockGetter bjd, final BlockPos fk, final BlockState byg) {
|
|
return new ItemStack(Items.NETHER_WART);
|
|
}
|
|
|
|
@Override
|
|
protected void createBlockStateDefinition(final StateDefinition.Builder<Block, BlockState> a) {
|
|
a.add(NetherWartBlock.AGE);
|
|
}
|
|
|
|
static {
|
|
AGE = BlockStateProperties.AGE_3;
|
|
SHAPE_BY_AGE = new VoxelShape[] { Block.box(0.0, 0.0, 0.0, 16.0, 5.0, 16.0), Block.box(0.0, 0.0, 0.0, 16.0, 8.0, 16.0), Block.box(0.0, 0.0, 0.0, 16.0, 11.0, 16.0), Block.box(0.0, 0.0, 0.0, 16.0, 14.0, 16.0) };
|
|
}
|
|
}
|