2025-11-24 22:52:51 +03:00

84 lines
3.2 KiB
Java

/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* com.mojang.serialization.MapCodec
* org.jspecify.annotations.Nullable
*/
package net.minecraft.world.level.block;
import com.mojang.serialization.MapCodec;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource;
import net.minecraft.stats.Stats;
import net.minecraft.util.RandomSource;
import net.minecraft.world.MenuProvider;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.AbstractFurnaceBlock;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityTicker;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.entity.FurnaceBlockEntity;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.block.state.BlockState;
import org.jspecify.annotations.Nullable;
public class FurnaceBlock
extends AbstractFurnaceBlock {
public static final MapCodec<FurnaceBlock> CODEC = FurnaceBlock.simpleCodec(FurnaceBlock::new);
public MapCodec<FurnaceBlock> codec() {
return CODEC;
}
protected FurnaceBlock(BlockBehaviour.Properties properties) {
super(properties);
}
@Override
public BlockEntity newBlockEntity(BlockPos worldPosition, BlockState blockState) {
return new FurnaceBlockEntity(worldPosition, blockState);
}
@Override
public <T extends BlockEntity> @Nullable BlockEntityTicker<T> getTicker(Level level, BlockState blockState, BlockEntityType<T> type) {
return FurnaceBlock.createFurnaceTicker(level, type, BlockEntityType.FURNACE);
}
@Override
protected void openContainer(Level level, BlockPos pos, Player player) {
BlockEntity blockEntity = level.getBlockEntity(pos);
if (blockEntity instanceof FurnaceBlockEntity) {
player.openMenu((MenuProvider)((Object)blockEntity));
player.awardStat(Stats.INTERACT_WITH_FURNACE);
}
}
@Override
public void animateTick(BlockState state, Level level, BlockPos pos, RandomSource random) {
if (!state.getValue(LIT).booleanValue()) {
return;
}
double x = (double)pos.getX() + 0.5;
double y = pos.getY();
double z = (double)pos.getZ() + 0.5;
if (random.nextDouble() < 0.1) {
level.playLocalSound(x, y, z, SoundEvents.FURNACE_FIRE_CRACKLE, SoundSource.BLOCKS, 1.0f, 1.0f, false);
}
Direction direction = (Direction)state.getValue(FACING);
Direction.Axis axis = direction.getAxis();
double r = 0.52;
double ss = random.nextDouble() * 0.6 - 0.3;
double dx = axis == Direction.Axis.X ? (double)direction.getStepX() * 0.52 : ss;
double dy = random.nextDouble() * 6.0 / 16.0;
double dz = axis == Direction.Axis.Z ? (double)direction.getStepZ() * 0.52 : ss;
level.addParticle(ParticleTypes.SMOKE, x + dx, y + dy, z + dz, 0.0, 0.0, 0.0);
level.addParticle(ParticleTypes.FLAME, x + dx, y + dy, z + dz, 0.0, 0.0, 0.0);
}
}