Jump to content

Recommended Posts

Posted

As long as it does not have an Inventory it is simple. Use

EntityPlayer#openGui

.

 

Why use EntityPlayer.openGui() which takes a bunch of "weird" parameters when you can use Minecraft.getMinecraft().displayGuiScreen() instead?  Of course you'd only call that on client side.  It just takes a GuiScreen as the parameter.

 

It seems that openGui() is still intended for use with containers, as you can call it from server side, and it wants position information passed in, as well as mod instance, and some sort of "modGuiID" integer parameter which it then passes with an FMLMessage ...

 

If you really just want a fully custom (non container) type GUI, seems to me that dipslayGuiScreen() is easier way to go.  Just pass the GuiScreen and have that send packets back to server if needed.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Posted

If you really just want a fully custom (non container) type GUI, seems to me that dipslayGuiScreen() is easier way to go.  Just pass the GuiScreen and have that send packets back to server if needed.

You'll have to make a method in your proxy for every specific screen to make this work. If you already have a GuiHandler it's much easier to just reuse that.

 

I just did this, and found it easiest to make a GuiScreen class, borrow some methods from GuiContainer, and make an empty container class for the server side, so it all handles well and I can still send packets and whatnot back and forth easily.

 

*code not meant for direct copy-paste

@Override
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
	return new FactionContainer();
}

@Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
	return new GuiFaction();
}

 

 

@SideOnly(Side.CLIENT)
public class GuiFaction extends GuiScreen {


protected void drawGuiContainerBackgroundLayer(float p_146976_1_,
		int p_146976_2_, int p_146976_3_) {
	mc.renderEngine.bindTexture(field_147085_u);
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        int x = (width - xSize) / 2;
        int y = (height - ySize) / 2;
        this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize);

       }

    @Override
 /**
     * Draws the screen and all the components in it.
     */
    public void drawScreen(int p_73863_1_, int p_73863_2_, float p_73863_3_)
    {
        this.drawDefaultBackground();
        int k = this.guiLeft;
        int l = this.guiTop;
        this.drawGuiContainerBackgroundLayer(p_73863_3_, p_73863_1_, p_73863_2_);
        GL11.glDisable(GL12.GL_RESCALE_NORMAL);
        RenderHelper.disableStandardItemLighting();
        GL11.glDisable(GL11.GL_LIGHTING);
        GL11.glDisable(GL11.GL_DEPTH_TEST);
        super.drawScreen(p_73863_1_, p_73863_2_, p_73863_3_);
    }

 

 

public class FactionContainer extends Container {

@Override
public boolean canInteractWith(EntityPlayer p_75145_1_) {
	// TODO Auto-generated method stub
	return true;
}

}

 

 

Edit: forgot these:

 

 

FMLNetworkHandler.openGui(player, IFaction.INSTANCE, 0, world,
					x, y, z);

 

 

NetworkRegistry.INSTANCE.registerGuiHandler(IFaction.INSTANCE, new FactionGuiHandler());

I'll need help, and I'll give help. Just ask, you know I will!

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.