Started by
equanmills
on
Topic category: Help with Minecraft modding (Java Edition)
I have been researching this topic for the last two hours and any post on this site that showed a method horribly explained it and then dipped with out any elaboration. Please help.
[Materials]
Custom Block, Custom GUI (just create it for procedure addition), Procedure, Additional Code Modifications Needed
Add a procedure to the block right-click event.
Add an "Open GUI" trigger and save it.
Go to the procedure's code editor and add the following import statements:
import net.minecraft.world.inventory.EnchantmentMenu; //add
import net.minecraft.world.inventory.ContainerLevelAccess; //add
import net.minecraft.world.level.Level; //add
Find and modify the following code.
[Original Code]
@Override
public AbstractContainerMenu createMenu(int id, Inventory inventory, Player player) {
return new TestguiMenu(id, inventory, new FriendlyByteBuf(Unpooled.buffer()).writeBlockPos(_bpos));
}
[Modified Code]
@Override
public AbstractContainerMenu createMenu(int id, Inventory inventory, Player player) {
return new EnchantmentMenu(id, inventory, ContainerLevelAccess.NULL);
}