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

68 lines
2.4 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.stats.Stats;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.DyeColor;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.BaseEntityBlock;
import net.minecraft.world.level.block.BeaconBeamBlock;
import net.minecraft.world.level.block.entity.BeaconBlockEntity;
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.state.BlockBehaviour;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.BlockHitResult;
import org.jspecify.annotations.Nullable;
public class BeaconBlock
extends BaseEntityBlock
implements BeaconBeamBlock {
public static final MapCodec<BeaconBlock> CODEC = BeaconBlock.simpleCodec(BeaconBlock::new);
public MapCodec<BeaconBlock> codec() {
return CODEC;
}
public BeaconBlock(BlockBehaviour.Properties properties) {
super(properties);
}
@Override
public DyeColor getColor() {
return DyeColor.WHITE;
}
@Override
public BlockEntity newBlockEntity(BlockPos worldPosition, BlockState blockState) {
return new BeaconBlockEntity(worldPosition, blockState);
}
@Override
public <T extends BlockEntity> @Nullable BlockEntityTicker<T> getTicker(Level level, BlockState blockState, BlockEntityType<T> type) {
return BeaconBlock.createTickerHelper(type, BlockEntityType.BEACON, BeaconBlockEntity::tick);
}
@Override
protected InteractionResult useWithoutItem(BlockState state, Level level, BlockPos pos, Player player, BlockHitResult hitResult) {
BlockEntity blockEntity;
if (!level.isClientSide() && (blockEntity = level.getBlockEntity(pos)) instanceof BeaconBlockEntity) {
BeaconBlockEntity beacon = (BeaconBlockEntity)blockEntity;
player.openMenu(beacon);
player.awardStat(Stats.INTERACT_WITH_BEACON);
}
return InteractionResult.SUCCESS;
}
}