[Change] Destroy Underwater Plants in tick (possibly helps with #133)

This commit is contained in:
Frank 2023-12-20 15:12:02 +01:00
parent 9646b4d0a8
commit bdc54be0d7

View file

@ -17,7 +17,6 @@ import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.BonemealableBlock;
import net.minecraft.world.level.block.LiquidBlockContainer;
import net.minecraft.world.level.block.state.BlockState;
@ -33,6 +32,7 @@ import net.minecraft.world.phys.shapes.VoxelShape;
import com.google.common.collect.Lists;
import java.util.List;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public abstract class UnderwaterPlantBlock extends BaseBlockNotFull implements RenderLayerProvider, BonemealableBlock, LiquidBlockContainer {
@ -59,9 +59,16 @@ public abstract class UnderwaterPlantBlock extends BaseBlockNotFull implements R
protected abstract boolean isTerrain(BlockState state);
@Override
public void tick(BlockState state, ServerLevel world, BlockPos pos, RandomSource randomSource) {
if (!canSurvive(state, world, pos)) {
world.destroyBlock(pos, true);
}
}
@Override
@SuppressWarnings("deprecation")
public BlockState updateShape(
public @NotNull BlockState updateShape(
BlockState state,
Direction facing,
BlockState neighborState,
@ -70,11 +77,10 @@ public abstract class UnderwaterPlantBlock extends BaseBlockNotFull implements R
BlockPos neighborPos
) {
if (!canSurvive(state, world, pos)) {
world.destroyBlock(pos, true);
return Blocks.WATER.defaultBlockState();
} else {
return state;
world.scheduleTick(pos, this, 1);
}
return state;
}
@Override