SmithingTableBlock .java

net.minecraft.world.level.block.SmithingTableBlock (class, 47 lines): members: CONTAINER_TITLE, getMenuProvider, useWithoutItem. imports: SmithingMenu.

net.minecraft.world.level.blockclass47 linescommonextends CraftingTableBlock1.7 KB

API Surface (2)

MenuProvider getMenuProvider(final BlockState state, final Level level, final BlockPos pos)
InteractionResult useWithoutItem(final BlockState state, final Level level, final BlockPos pos, final Player player, final BlockHitResult hitResult)

Fields & Constants (1)

CONTAINER_TITLE

String literals (1)

"container.upgrade"

Full Source

SmithingTableBlock.java47 lines · Minecraft 26.3 · verbatim
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.ContainerLevelAccess;
11
import net.minecraft.world.inventory.SmithingMenu;
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
17
/**
18
 * Access widened by fabric-transitive-access-wideners-v1 to accessible
19
 */
20
public class SmithingTableBlock extends CraftingTableBlock {
21
	private static final Component CONTAINER_TITLE = Component.translatable("container.upgrade");
22
23
	/**
24
	 * Access widened by fabric-transitive-access-wideners-v1 to accessible
25
	 */
26
	public SmithingTableBlock(final BlockBehaviour.Properties properties) {
27
		super(properties);
28
	}
29
30
	@Override
31
	protected MenuProvider getMenuProvider(final BlockState state, final Level level, final BlockPos pos) {
32
		return new SimpleMenuProvider(
33
			(containerId, inventory, player) -> new SmithingMenu(containerId, inventory, ContainerLevelAccess.create(level, pos)), CONTAINER_TITLE
34
		);
35
	}
36
37
	@Override
38
	protected InteractionResult useWithoutItem(final BlockState state, final Level level, final BlockPos pos, final Player player, final BlockHitResult hitResult) {
39
		if (!level.isClientSide()) {
40
			player.openMenu(state.getMenuProvider(level, pos));
41
			player.awardStat(Stats.INTERACT_WITH_SMITHING_TABLE);
42
		}
43
44
		return InteractionResult.SUCCESS;
45
	}
46
}
47

Decompiled Minecraft 26.3 source of SmithingTableBlock (net/minecraft/world/level/block/SmithingTableBlock.java) with Mojang official mappings, stored verbatim on the site.