/* * Decompiled with CFR 0.152. * * Could not load the following classes: * com.mojang.serialization.MapCodec */ package net.minecraft.world.level.block; import com.mojang.serialization.MapCodec; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.core.particles.BlockParticleOption; import net.minecraft.core.particles.ParticleTypes; import net.minecraft.server.level.ServerLevel; import net.minecraft.tags.BlockTags; import net.minecraft.util.ParticleUtils; import net.minecraft.util.RandomSource; import net.minecraft.world.entity.item.FallingBlockEntity; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Level; import net.minecraft.world.level.LevelReader; import net.minecraft.world.level.ScheduledTickAccess; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Fallable; import net.minecraft.world.level.block.state.BlockBehaviour; import net.minecraft.world.level.block.state.BlockState; public abstract class FallingBlock extends Block implements Fallable { public FallingBlock(BlockBehaviour.Properties properties) { super(properties); } protected abstract MapCodec codec(); @Override protected void onPlace(BlockState state, Level level, BlockPos pos, BlockState oldState, boolean movedByPiston) { level.scheduleTick(pos, this, this.getDelayAfterPlace()); } @Override protected BlockState updateShape(BlockState state, LevelReader level, ScheduledTickAccess ticks, BlockPos pos, Direction directionToNeighbour, BlockPos neighbourPos, BlockState neighbourState, RandomSource random) { ticks.scheduleTick(pos, this, this.getDelayAfterPlace()); return super.updateShape(state, level, ticks, pos, directionToNeighbour, neighbourPos, neighbourState, random); } @Override protected void tick(BlockState state, ServerLevel level, BlockPos pos, RandomSource random) { if (!FallingBlock.isFree(level.getBlockState(pos.below())) || pos.getY() < level.getMinY()) { return; } FallingBlockEntity entity = FallingBlockEntity.fall(level, pos, state); this.falling(entity); } protected void falling(FallingBlockEntity entity) { } protected int getDelayAfterPlace() { return 2; } public static boolean isFree(BlockState state) { return state.isAir() || state.is(BlockTags.FIRE) || state.liquid() || state.canBeReplaced(); } @Override public void animateTick(BlockState state, Level level, BlockPos pos, RandomSource random) { BlockPos below; if (random.nextInt(16) == 0 && FallingBlock.isFree(level.getBlockState(below = pos.below()))) { ParticleUtils.spawnParticleBelow(level, pos, random, new BlockParticleOption(ParticleTypes.FALLING_DUST, state)); } } public abstract int getDustColor(BlockState var1, BlockGetter var2, BlockPos var3); }