minecraft-source/src/net/minecraft/world/level/block/MagmaBlock.java

84 lines
3.2 KiB
Java

package net.minecraft.world.level.block;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.core.particles.SimpleParticleType;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.world.entity.player.Player;
import net.minecraft.sounds.SoundSource;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.tags.FluidTags;
import net.minecraft.world.level.LevelReader;
import net.minecraft.core.Direction;
import net.minecraft.world.level.LevelAccessor;
import java.util.Random;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.item.enchantment.EnchantmentHelper;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.Entity;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.Level;
public class MagmaBlock extends Block {
public MagmaBlock(final Properties c) {
super(c);
}
@Override
public void stepOn(final Level bjt, final BlockPos fk, final Entity akn) {
if (!akn.fireImmune() && akn instanceof LivingEntity && !EnchantmentHelper.hasFrostWalker((LivingEntity)akn)) {
akn.hurt(DamageSource.HOT_FLOOR, 1.0f);
}
super.stepOn(bjt, fk, akn);
}
@Override
public boolean emissiveRendering(final BlockState byg) {
return true;
}
@Override
public void tick(final BlockState byg, final ServerLevel xd, final BlockPos fk, final Random random) {
BubbleColumnBlock.growColumn(xd, fk.above(), true);
}
@Override
public BlockState updateShape(final BlockState byg1, final Direction fp, final BlockState byg3, final LevelAccessor bju, final BlockPos fk5, final BlockPos fk6) {
if (fp == Direction.UP && byg3.getBlock() == Blocks.WATER) {
bju.getBlockTicks().scheduleTick(fk5, this, this.getTickDelay(bju));
}
return super.updateShape(byg1, fp, byg3, bju, fk5, fk6);
}
@Override
public void randomTick(final BlockState byg, final ServerLevel xd, final BlockPos fk, final Random random) {
final BlockPos fk2 = fk.above();
if (xd.getFluidState(fk).is(FluidTags.WATER)) {
xd.playSound(null, fk, SoundEvents.FIRE_EXTINGUISH, SoundSource.BLOCKS, 0.5f, 2.6f + (xd.random.nextFloat() - xd.random.nextFloat()) * 0.8f);
xd.<SimpleParticleType>sendParticles(ParticleTypes.LARGE_SMOKE, fk2.getX() + 0.5, fk2.getY() + 0.25, fk2.getZ() + 0.5, 8, 0.5, 0.25, 0.5, 0.0);
}
}
@Override
public int getTickDelay(final LevelReader bjw) {
return 20;
}
@Override
public void onPlace(final BlockState byg1, final Level bjt, final BlockPos fk, final BlockState byg4, final boolean boolean5) {
bjt.getBlockTicks().scheduleTick(fk, this, this.getTickDelay(bjt));
}
@Override
public boolean isValidSpawn(final BlockState byg, final BlockGetter bjd, final BlockPos fk, final EntityType<?> akr) {
return akr.fireImmune();
}
@Override
public boolean hasPostProcess(final BlockState byg, final BlockGetter bjd, final BlockPos fk) {
return true;
}
}