| 1 | package net.minecraft.world.level.block;
|
| 2 |
|
| 3 | import java.util.Collection;
|
| 4 | import net.minecraft.core.BlockPos;
|
| 5 | import net.minecraft.core.Direction;
|
| 6 | import net.minecraft.util.RandomSource;
|
| 7 | import net.minecraft.world.level.LevelAccessor;
|
| 8 | import net.minecraft.world.level.block.state.BlockState;
|
| 9 | import net.minecraft.world.level.material.Fluids;
|
| 10 | import org.jspecify.annotations.Nullable;
|
| 11 |
|
| 12 | public interface SculkBehaviour {
|
| 13 | SculkBehaviour DEFAULT = new SculkBehaviour() {
|
| 14 | @Override
|
| 15 | public boolean attemptSpreadVein(
|
| 16 | final LevelAccessor level, final BlockPos pos, final BlockState state, final @Nullable Collection<Direction> facings, final boolean postProcess
|
| 17 | ) {
|
| 18 | if (facings == null) {
|
| 19 | return ((SculkVeinBlock)Blocks.SCULK_VEIN).getSameSpaceSpreader().spreadAll(level.getBlockState(pos), level, pos, postProcess) > 0L;
|
| 20 | } else if (!facings.isEmpty()) {
|
| 21 | return !state.isAir() && !state.getFluidState().is(Fluids.WATER) ? false : SculkVeinBlock.regrow(level, pos, state, facings);
|
| 22 | } else {
|
| 23 | return SculkBehaviour.super.attemptSpreadVein(level, pos, state, facings, postProcess);
|
| 24 | }
|
| 25 | }
|
| 26 |
|
| 27 | @Override
|
| 28 | public int attemptUseCharge(
|
| 29 | final SculkSpreader.ChargeCursor cursor,
|
| 30 | final LevelAccessor level,
|
| 31 | final BlockPos originPos,
|
| 32 | final RandomSource random,
|
| 33 | final SculkSpreader spreader,
|
| 34 | final boolean spreadVeins
|
| 35 | ) {
|
| 36 | return cursor.getDecayDelay() > 0 ? cursor.getCharge() : 0;
|
| 37 | }
|
| 38 |
|
| 39 | @Override
|
| 40 | public int updateDecayDelay(final int age) {
|
| 41 | return Math.max(age - 1, 0);
|
| 42 | }
|
| 43 | };
|
| 44 |
|
| 45 | default byte getSculkSpreadDelay() {
|
| 46 | return 1;
|
| 47 | }
|
| 48 |
|
| 49 | default void onDischarged(final LevelAccessor level, final BlockState state, final BlockPos pos, final RandomSource random) {
|
| 50 | }
|
| 51 |
|
| 52 | default boolean depositCharge(final LevelAccessor level, final BlockPos pos, final RandomSource random) {
|
| 53 | return false;
|
| 54 | }
|
| 55 |
|
| 56 | default boolean attemptSpreadVein(
|
| 57 | final LevelAccessor level, final BlockPos pos, final BlockState state, final @Nullable Collection<Direction> facings, final boolean postProcess
|
| 58 | ) {
|
| 59 | return ((MultifaceSpreadeableBlock)Blocks.SCULK_VEIN).getSpreader().spreadAll(state, level, pos, postProcess) > 0L;
|
| 60 | }
|
| 61 |
|
| 62 | default boolean canChangeBlockStateOnSpread() {
|
| 63 | return true;
|
| 64 | }
|
| 65 |
|
| 66 | default int updateDecayDelay(final int age) {
|
| 67 | return 1;
|
| 68 | }
|
| 69 |
|
| 70 | int attemptUseCharge(
|
| 71 | SculkSpreader.ChargeCursor cursor, LevelAccessor level, BlockPos originPos, RandomSource random, SculkSpreader spreader, boolean spreadVeins
|
| 72 | );
|
| 73 | }
|
| 74 |
|