minecraft-src/net/minecraft/world/level/block/MagmaBlock.java
2025-07-04 01:41:11 +03:00

55 lines
1.8 KiB
Java

package net.minecraft.world.level.block;
import com.mojang.serialization.MapCodec;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.RandomSource;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.block.state.BlockState;
public class MagmaBlock extends Block {
public static final MapCodec<MagmaBlock> CODEC = simpleCodec(MagmaBlock::new);
private static final int BUBBLE_COLUMN_CHECK_DELAY = 20;
@Override
public MapCodec<MagmaBlock> codec() {
return CODEC;
}
public MagmaBlock(BlockBehaviour.Properties properties) {
super(properties);
}
@Override
public void stepOn(Level level, BlockPos pos, BlockState state, Entity entity) {
if (!entity.isSteppingCarefully() && entity instanceof LivingEntity) {
entity.hurt(level.damageSources().hotFloor(), 1.0F);
}
super.stepOn(level, pos, state, entity);
}
@Override
protected void tick(BlockState state, ServerLevel level, BlockPos pos, RandomSource random) {
BubbleColumnBlock.updateColumn(level, pos.above(), state);
}
@Override
protected BlockState updateShape(BlockState state, Direction direction, BlockState neighborState, LevelAccessor level, BlockPos pos, BlockPos neighborPos) {
if (direction == Direction.UP && neighborState.is(Blocks.WATER)) {
level.scheduleTick(pos, this, 20);
}
return super.updateShape(state, direction, neighborState, level, pos, neighborPos);
}
@Override
protected void onPlace(BlockState state, Level level, BlockPos pos, BlockState oldState, boolean movedByPiston) {
level.scheduleTick(pos, this, 20);
}
}