[Change] Destroy Underwater Plants in tick (possibly helps with #133)
This commit is contained in:
parent
9646b4d0a8
commit
bdc54be0d7
1 changed files with 12 additions and 6 deletions
|
@ -17,7 +17,6 @@ import net.minecraft.world.level.BlockGetter;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.LevelAccessor;
|
import net.minecraft.world.level.LevelAccessor;
|
||||||
import net.minecraft.world.level.LevelReader;
|
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.BonemealableBlock;
|
||||||
import net.minecraft.world.level.block.LiquidBlockContainer;
|
import net.minecraft.world.level.block.LiquidBlockContainer;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
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 com.google.common.collect.Lists;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
public abstract class UnderwaterPlantBlock extends BaseBlockNotFull implements RenderLayerProvider, BonemealableBlock, LiquidBlockContainer {
|
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);
|
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
|
@Override
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public BlockState updateShape(
|
public @NotNull BlockState updateShape(
|
||||||
BlockState state,
|
BlockState state,
|
||||||
Direction facing,
|
Direction facing,
|
||||||
BlockState neighborState,
|
BlockState neighborState,
|
||||||
|
@ -70,11 +77,10 @@ public abstract class UnderwaterPlantBlock extends BaseBlockNotFull implements R
|
||||||
BlockPos neighborPos
|
BlockPos neighborPos
|
||||||
) {
|
) {
|
||||||
if (!canSurvive(state, world, pos)) {
|
if (!canSurvive(state, world, pos)) {
|
||||||
world.destroyBlock(pos, true);
|
world.scheduleTick(pos, this, 1);
|
||||||
return Blocks.WATER.defaultBlockState();
|
|
||||||
} else {
|
|
||||||
return state;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue