54 lines
2.0 KiB
Java
54 lines
2.0 KiB
Java
package net.minecraft.world.level.block;
|
|
|
|
import net.minecraft.core.particles.ParticleOptions;
|
|
import net.minecraft.core.particles.ParticleTypes;
|
|
import java.util.Random;
|
|
import net.minecraft.world.level.Level;
|
|
import net.minecraft.world.level.LevelReader;
|
|
import net.minecraft.world.level.LevelAccessor;
|
|
import net.minecraft.core.Direction;
|
|
import net.minecraft.world.phys.shapes.CollisionContext;
|
|
import net.minecraft.core.BlockPos;
|
|
import net.minecraft.world.level.BlockGetter;
|
|
import net.minecraft.world.level.block.state.BlockState;
|
|
import net.minecraft.world.phys.shapes.VoxelShape;
|
|
|
|
public class TorchBlock extends Block {
|
|
protected static final VoxelShape AABB;
|
|
|
|
protected TorchBlock(final Properties c) {
|
|
super(c);
|
|
}
|
|
|
|
@Override
|
|
public VoxelShape getShape(final BlockState byg, final BlockGetter bjd, final BlockPos fk, final CollisionContext cvn) {
|
|
return TorchBlock.AABB;
|
|
}
|
|
|
|
@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.DOWN && !this.canSurvive(byg1, bju, fk5)) {
|
|
return Blocks.AIR.defaultBlockState();
|
|
}
|
|
return super.updateShape(byg1, fp, byg3, bju, fk5, fk6);
|
|
}
|
|
|
|
@Override
|
|
public boolean canSurvive(final BlockState byg, final LevelReader bjw, final BlockPos fk) {
|
|
return Block.canSupportCenter(bjw, fk.below(), Direction.UP);
|
|
}
|
|
|
|
@Override
|
|
public void animateTick(final BlockState byg, final Level bjt, final BlockPos fk, final Random random) {
|
|
final double double6 = fk.getX() + 0.5;
|
|
final double double7 = fk.getY() + 0.7;
|
|
final double double8 = fk.getZ() + 0.5;
|
|
bjt.addParticle(ParticleTypes.SMOKE, double6, double7, double8, 0.0, 0.0, 0.0);
|
|
bjt.addParticle(ParticleTypes.FLAME, double6, double7, double8, 0.0, 0.0, 0.0);
|
|
}
|
|
|
|
static {
|
|
AABB = Block.box(6.0, 0.0, 6.0, 10.0, 10.0, 10.0);
|
|
}
|
|
}
|