2025-11-24 22:52:51 +03:00

101 lines
3.8 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.world.entity.LivingEntity;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.DoublePlantBlock;
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.block.state.properties.DoubleBlockHalf;
import net.minecraft.world.level.block.state.properties.EnumProperty;
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.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape;
import org.jspecify.annotations.Nullable;
public class TallSeagrassBlock
extends DoublePlantBlock
implements LiquidBlockContainer {
public static final MapCodec<TallSeagrassBlock> CODEC = TallSeagrassBlock.simpleCodec(TallSeagrassBlock::new);
public static final EnumProperty<DoubleBlockHalf> HALF = DoublePlantBlock.HALF;
private static final VoxelShape SHAPE = Block.column(12.0, 0.0, 16.0);
public MapCodec<TallSeagrassBlock> codec() {
return CODEC;
}
public TallSeagrassBlock(BlockBehaviour.Properties properties) {
super(properties);
}
@Override
protected VoxelShape getShape(BlockState state, BlockGetter level, BlockPos pos, CollisionContext context) {
return SHAPE;
}
@Override
protected boolean mayPlaceOn(BlockState state, BlockGetter level, BlockPos pos) {
return state.isFaceSturdy(level, pos, Direction.UP) && !state.is(Blocks.MAGMA_BLOCK);
}
@Override
protected ItemStack getCloneItemStack(LevelReader level, BlockPos pos, BlockState state, boolean includeData) {
return new ItemStack(Blocks.SEAGRASS);
}
@Override
public @Nullable BlockState getStateForPlacement(BlockPlaceContext context) {
FluidState fluidState;
BlockState state = super.getStateForPlacement(context);
if (state != null && (fluidState = context.getLevel().getFluidState(context.getClickedPos().above())).is(FluidTags.WATER) && fluidState.getAmount() == 8) {
return state;
}
return null;
}
@Override
protected boolean canSurvive(BlockState state, LevelReader level, BlockPos pos) {
if (state.getValue(HALF) == DoubleBlockHalf.UPPER) {
BlockState belowState = level.getBlockState(pos.below());
return belowState.is(this) && belowState.getValue(HALF) == DoubleBlockHalf.LOWER;
}
FluidState fluidState = level.getFluidState(pos);
return super.canSurvive(state, level, pos) && fluidState.is(FluidTags.WATER) && fluidState.getAmount() == 8;
}
@Override
protected FluidState getFluidState(BlockState state) {
return Fluids.WATER.getSource(false);
}
@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;
}
}