| 1 | package net.minecraft.world.level.block;
|
| 2 |
|
| 3 | import net.minecraft.core.BlockPos;
|
| 4 | import net.minecraft.stats.Stats;
|
| 5 | import net.minecraft.world.InteractionResult;
|
| 6 | import net.minecraft.world.entity.player.Player;
|
| 7 | import net.minecraft.world.item.DyeColor;
|
| 8 | import net.minecraft.world.level.Level;
|
| 9 | import net.minecraft.world.level.block.entity.BeaconBlockEntity;
|
| 10 | import net.minecraft.world.level.block.entity.BlockEntity;
|
| 11 | import net.minecraft.world.level.block.entity.BlockEntityTicker;
|
| 12 | import net.minecraft.world.level.block.entity.BlockEntityType;
|
| 13 | import net.minecraft.world.level.block.entity.BlockEntityTypes;
|
| 14 | import net.minecraft.world.level.block.state.BlockBehaviour;
|
| 15 | import net.minecraft.world.level.block.state.BlockState;
|
| 16 | import net.minecraft.world.phys.BlockHitResult;
|
| 17 | import org.jspecify.annotations.Nullable;
|
| 18 |
|
| 19 | public class BeaconBlock extends BaseEntityBlock implements BeaconBeamBlock {
|
| 20 | public BeaconBlock(final BlockBehaviour.Properties properties) {
|
| 21 | super(properties);
|
| 22 | }
|
| 23 |
|
| 24 | @Override
|
| 25 | public DyeColor getColor() {
|
| 26 | return DyeColor.WHITE;
|
| 27 | }
|
| 28 |
|
| 29 | @Override
|
| 30 | public BlockEntity newBlockEntity(final BlockPos worldPosition, final BlockState blockState) {
|
| 31 | return new BeaconBlockEntity(worldPosition, blockState);
|
| 32 | }
|
| 33 |
|
| 34 | @Override
|
| 35 | public <T extends BlockEntity> @Nullable BlockEntityTicker<T> getTicker(final Level level, final BlockState blockState, final BlockEntityType<T> type) {
|
| 36 | return createTickerHelper(type, BlockEntityTypes.BEACON, BeaconBlockEntity::tick);
|
| 37 | }
|
| 38 |
|
| 39 | @Override
|
| 40 | protected InteractionResult useWithoutItem(final BlockState state, final Level level, final BlockPos pos, final Player player, final BlockHitResult hitResult) {
|
| 41 | if (!level.isClientSide() && level.getBlockEntity(pos) instanceof BeaconBlockEntity beacon) {
|
| 42 | player.openMenu(beacon);
|
| 43 | player.awardStat(Stats.INTERACT_WITH_BEACON);
|
| 44 | }
|
| 45 |
|
| 46 | return InteractionResult.SUCCESS;
|
| 47 | }
|
| 48 | }
|
| 49 |
|