Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Hello, I am making a block that is identical in  many ways to a crafting table but with extra recipes.

Therefore I am using some of the crafting table parts to create my own custom one.

However, when I use it, nothing appears, it just spits out my debug messages saying it has been clicked, it has opened and a GUI is being shown to the client and a container to the server.

 

I expect it to open a crafting GUI and allow me to craft things and when you change any slot it outputs "Change!" but it just carries on.

 

GuiHandler:

public class GuiHandler implements IGuiHandler {
@Override
public Object getServerGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) {
	if (id == 0) {
	        log.info("Load Server");
		return new ContainerCrafting(player.inventory, world, x, y, z);
	}
	return null;
}

@Override
public Object getClientGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) {
        if (id == 0) {
          	log.info("Load Client");
        	return new GuiCrafting(player.inventory, world, x, y, z);
        }
        return null;
    }
}

 

Main Class

NetworkRegistry.INSTANCE.registerGuiHandler(this, new GuiHandler());

 

GuiCrafting:

public class GuiCrafting extends GuiCrafting{

public GuiCrafting(InventoryPlayer par1InventoryPlayer, World par2World, int par3, int par4, int par5) {
	super(par1InventoryPlayer, par2World, par3, par4, par5);
	log.info("Loaded GUI!");
}

}

 

ContainerCrafting:


public class ContainerCrafting extends ContainerWorkbench{
private World worldObj;
public ContainerCrafting(InventoryPlayer inventory, World world, int x, int y, int z) {
	super(inventory, world, x, y, z);
	worldObj = world;
	log.info("Loaded Server Container!");
}

@Override
        public void onCraftMatrixChanged(IInventory par1IInventory)
        {
	log.info("Change!");
                this.craftResult.setInventorySlotContents(0, CraftingManager.getInstance().findMatchingRecipe(this.craftMatrix, this.worldObj));
    }
}

 

Output (When block clicked)

    Load Server

    Change!

    Loaded Server Container!

    Load Client

    Loaded GUI!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.