Jump to content

Recommended Posts

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...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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