65 lines
		
	
	
	
		
			2 KiB
		
	
	
	
		
			Java
		
	
	
	
	
	
			
		
		
	
	
			65 lines
		
	
	
	
		
			2 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.LevelReader;
 | |
| import net.minecraft.world.level.ScheduledTickAccess;
 | |
| 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,
 | |
| 		LevelReader level,
 | |
| 		ScheduledTickAccess scheduledTickAccess,
 | |
| 		BlockPos pos,
 | |
| 		Direction direction,
 | |
| 		BlockPos neighborPos,
 | |
| 		BlockState neighborState,
 | |
| 		RandomSource random
 | |
| 	) {
 | |
| 		if (direction == Direction.UP && neighborState.is(Blocks.WATER)) {
 | |
| 			scheduledTickAccess.scheduleTick(pos, this, 20);
 | |
| 		}
 | |
| 
 | |
| 		return super.updateShape(state, level, scheduledTickAccess, pos, direction, neighborPos, neighborState, random);
 | |
| 	}
 | |
| 
 | |
| 	@Override
 | |
| 	protected void onPlace(BlockState state, Level level, BlockPos pos, BlockState oldState, boolean movedByPiston) {
 | |
| 		level.scheduleTick(pos, this, 20);
 | |
| 	}
 | |
| }
 |