| 1 | package net.minecraft.world.level.block;
|
| 2 |
|
| 3 | import net.minecraft.core.BlockPos;
|
| 4 | import net.minecraft.network.chat.Component;
|
| 5 | import net.minecraft.stats.Stats;
|
| 6 | import net.minecraft.world.InteractionResult;
|
| 7 | import net.minecraft.world.MenuProvider;
|
| 8 | import net.minecraft.world.SimpleMenuProvider;
|
| 9 | import net.minecraft.world.entity.player.Player;
|
| 10 | import net.minecraft.world.inventory.CartographyTableMenu;
|
| 11 | import net.minecraft.world.inventory.ContainerLevelAccess;
|
| 12 | import net.minecraft.world.level.Level;
|
| 13 | import net.minecraft.world.level.block.state.BlockBehaviour;
|
| 14 | import net.minecraft.world.level.block.state.BlockState;
|
| 15 | import net.minecraft.world.phys.BlockHitResult;
|
| 16 | import org.jspecify.annotations.Nullable;
|
| 17 |
|
| 18 | /**
|
| 19 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 20 | */
|
| 21 | public class CartographyTableBlock extends Block {
|
| 22 | private static final Component CONTAINER_TITLE = Component.translatable("container.cartography_table");
|
| 23 |
|
| 24 | /**
|
| 25 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 26 | */
|
| 27 | public CartographyTableBlock(final BlockBehaviour.Properties properties) {
|
| 28 | super(properties);
|
| 29 | }
|
| 30 |
|
| 31 | @Override
|
| 32 | protected InteractionResult useWithoutItem(final BlockState state, final Level level, final BlockPos pos, final Player player, final BlockHitResult hitResult) {
|
| 33 | if (!level.isClientSide()) {
|
| 34 | player.openMenu(state.getMenuProvider(level, pos));
|
| 35 | player.awardStat(Stats.INTERACT_WITH_CARTOGRAPHY_TABLE);
|
| 36 | }
|
| 37 |
|
| 38 | return InteractionResult.SUCCESS;
|
| 39 | }
|
| 40 |
|
| 41 | @Override
|
| 42 | protected @Nullable MenuProvider getMenuProvider(final BlockState state, final Level level, final BlockPos pos) {
|
| 43 | return new SimpleMenuProvider(
|
| 44 | (containerId, inventory, player) -> new CartographyTableMenu(containerId, inventory, ContainerLevelAccess.create(level, pos)), CONTAINER_TITLE
|
| 45 | );
|
| 46 | }
|
| 47 | }
|
| 48 |
|