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

60 lines
2.6 KiB
Java

package net.minecraft.world.level.block;
import net.minecraft.core.particles.ParticleOptions;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.core.Direction;
import net.minecraft.sounds.SoundSource;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.world.level.block.state.properties.Property;
import java.util.Random;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.stats.Stats;
import net.minecraft.world.MenuProvider;
import net.minecraft.world.entity.player.Player;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.entity.BlastFurnaceBlockEntity;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.BlockGetter;
public class BlastFurnaceBlock extends AbstractFurnaceBlock {
protected BlastFurnaceBlock(final Properties c) {
super(c);
}
@Override
public BlockEntity newBlockEntity(final BlockGetter bjd) {
return new BlastFurnaceBlockEntity();
}
@Override
protected void openContainer(final Level bjt, final BlockPos fk, final Player ayg) {
final BlockEntity bwi5 = bjt.getBlockEntity(fk);
if (bwi5 instanceof BlastFurnaceBlockEntity) {
ayg.openMenu((MenuProvider)bwi5);
ayg.awardStat(Stats.INTERACT_WITH_BLAST_FURNACE);
}
}
@Override
public void animateTick(final BlockState byg, final Level bjt, final BlockPos fk, final Random random) {
if (!byg.<Boolean>getValue((Property<Boolean>)BlastFurnaceBlock.LIT)) {
return;
}
final double double6 = fk.getX() + 0.5;
final double double7 = fk.getY();
final double double8 = fk.getZ() + 0.5;
if (random.nextDouble() < 0.1) {
bjt.playLocalSound(double6, double7, double8, SoundEvents.BLASTFURNACE_FIRE_CRACKLE, SoundSource.BLOCKS, 1.0f, 1.0f, false);
}
final Direction fp12 = byg.<Direction>getValue((Property<Direction>)BlastFurnaceBlock.FACING);
final Direction.Axis a13 = fp12.getAxis();
final double double9 = 0.52;
final double double10 = random.nextDouble() * 0.6 - 0.3;
final double double11 = (a13 == Direction.Axis.X) ? (fp12.getStepX() * 0.52) : double10;
final double double12 = random.nextDouble() * 9.0 / 16.0;
final double double13 = (a13 == Direction.Axis.Z) ? (fp12.getStepZ() * 0.52) : double10;
bjt.addParticle(ParticleTypes.SMOKE, double6 + double11, double7 + double12, double8 + double13, 0.0, 0.0, 0.0);
}
}