MCREATOR: Custom Block Which Opens Crafting Table

Started by nazcew on

Topic category: Minecraft mod ideas exchange

Joined Jan 2026
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
MCREATOR: Custom Block Which Opens Crafting Table

This isn't a problem, but a solution.

The Crafting Table Top Texture in the Get Block is my Custom Block.

if (event instanceof net.minecraftforge.event.entity.player.PlayerInteractEvent.RightClickBlock _rbEvent) {
   if (!world.isClientSide() && _rbEvent.getEntity() instanceof net.minecraft.server.level.ServerPlayer _player) {
       _player.openMenu(new net.minecraft.world.SimpleMenuProvider((id, inv, p) -> 
           new net.minecraft.world.inventory.CraftingMenu(id, inv, net.minecraft.world.inventory.ContainerLevelAccess.create(_player.level(), net.minecraft.core.BlockPos.containing(x, y, z))) {
               @Override
               public boolean stillValid(net.minecraft.world.entity.player.Player _p) {
                   return _p.level().getBlockState(net.minecraft.core.BlockPos.containing(x, y, z)).is([Modname]ModBlocks.[BLOCKNAME].get());
               }
           }, net.minecraft.network.chat.Component.translatable("container.crafting")));
   }
   _rbEvent.setCancellationResult(net.minecraft.world.InteractionResult.sidedSuccess(world.isClientSide()));
   _rbEvent.setCanceled(true);
}

 

Ensure to replace [Modname] with your mods name keeping the capitalisation identical.

Ensure to replace [BLOCKNAME] with your blocks name keeping the capitalisation identical.