91 lines
2.9 KiB
Java
91 lines
2.9 KiB
Java
/*
|
|
* Decompiled with CFR 0.152.
|
|
*
|
|
* Could not load the following classes:
|
|
* com.mojang.serialization.MapCodec
|
|
* org.jspecify.annotations.Nullable
|
|
*/
|
|
package net.minecraft.world.level.block;
|
|
|
|
import com.mojang.serialization.MapCodec;
|
|
import net.minecraft.core.BlockPos;
|
|
import net.minecraft.core.Direction;
|
|
import net.minecraft.tags.FluidTags;
|
|
import net.minecraft.util.RandomSource;
|
|
import net.minecraft.world.entity.LivingEntity;
|
|
import net.minecraft.world.item.context.BlockPlaceContext;
|
|
import net.minecraft.world.level.BlockGetter;
|
|
import net.minecraft.world.level.LevelAccessor;
|
|
import net.minecraft.world.level.block.Block;
|
|
import net.minecraft.world.level.block.Blocks;
|
|
import net.minecraft.world.level.block.GrowingPlantHeadBlock;
|
|
import net.minecraft.world.level.block.LiquidBlockContainer;
|
|
import net.minecraft.world.level.block.state.BlockBehaviour;
|
|
import net.minecraft.world.level.block.state.BlockState;
|
|
import net.minecraft.world.level.material.Fluid;
|
|
import net.minecraft.world.level.material.FluidState;
|
|
import net.minecraft.world.level.material.Fluids;
|
|
import net.minecraft.world.phys.shapes.VoxelShape;
|
|
import org.jspecify.annotations.Nullable;
|
|
|
|
public class KelpBlock
|
|
extends GrowingPlantHeadBlock
|
|
implements LiquidBlockContainer {
|
|
public static final MapCodec<KelpBlock> CODEC = KelpBlock.simpleCodec(KelpBlock::new);
|
|
private static final double GROW_PER_TICK_PROBABILITY = 0.14;
|
|
private static final VoxelShape SHAPE = Block.column(16.0, 0.0, 9.0);
|
|
|
|
public MapCodec<KelpBlock> codec() {
|
|
return CODEC;
|
|
}
|
|
|
|
protected KelpBlock(BlockBehaviour.Properties properties) {
|
|
super(properties, Direction.UP, SHAPE, true, 0.14);
|
|
}
|
|
|
|
@Override
|
|
protected boolean canGrowInto(BlockState state) {
|
|
return state.is(Blocks.WATER);
|
|
}
|
|
|
|
@Override
|
|
protected Block getBodyBlock() {
|
|
return Blocks.KELP_PLANT;
|
|
}
|
|
|
|
@Override
|
|
protected boolean canAttachTo(BlockState state) {
|
|
return !state.is(Blocks.MAGMA_BLOCK);
|
|
}
|
|
|
|
@Override
|
|
public boolean canPlaceLiquid(@Nullable LivingEntity user, BlockGetter level, BlockPos pos, BlockState state, Fluid type) {
|
|
return false;
|
|
}
|
|
|
|
@Override
|
|
public boolean placeLiquid(LevelAccessor level, BlockPos pos, BlockState state, FluidState fluidState) {
|
|
return false;
|
|
}
|
|
|
|
@Override
|
|
protected int getBlocksToGrowWhenBonemealed(RandomSource random) {
|
|
return 1;
|
|
}
|
|
|
|
@Override
|
|
public @Nullable BlockState getStateForPlacement(BlockPlaceContext context) {
|
|
FluidState fluidState = context.getLevel().getFluidState(context.getClickedPos());
|
|
if (fluidState.is(FluidTags.WATER) && fluidState.getAmount() == 8) {
|
|
return super.getStateForPlacement(context);
|
|
}
|
|
return null;
|
|
}
|
|
|
|
@Override
|
|
protected FluidState getFluidState(BlockState state) {
|
|
return Fluids.WATER.getSource(false);
|
|
}
|
|
}
|
|
|