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

Hey,

As the topic says I want to draw an items icon in my gui that it looks just like it actually is an item :D

How do i do that?

  • Author

I found drawTexturedModelRectFromIcon

and tried it with:

this.drawTexturedModelRectFromIcon(100, 100, new ItemStack(Items.apple).getIconIndex(), 16, 16);

but that's just painting a big fat "nul" :/

I guess I'm using that ItemStack thing completly wrong?

You need to bind the itemsheet first. Use this to bind the itemsheet:

TextureManager manager = Minecraft.getMinecraft().renderEngine;
            manager.bindTexture(manager.getResourceLocation(1));
//RENDER ITEMS

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

  • Author

me again :P

Uhm so i want to delete a slot and draw the items texture over it,

I have

	@Override
    public void mouseClicked(int x, int y, int z) {
	super.mouseClicked(x, y, z);		
	if(y - guiTop > 30 && y - guiTop < 55 && x - guiLeft > 92 &&  x - guiLeft < 141) {
		tileEntity.onButtonClick();
	}
}

in my gui

and

	public void onButtonClick() {
	slots[0] = null;
}

in my tileEntity, however the slot actually becomes invisible, but when i ckick it it still seems to contain the ItemStack

I guess thats because the Gui stuff where i call the method is client.

Then how do I solve that problem?

You need to send packets to tell the server a button was clicked, let the server decide if that was possible, and then set it to null.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

  • Author

You need to send packets to tell the server a button was clicked, let the server decide if that was possible, and then set it to null.

Is there a good tutorial for packets?

(never worked with that  ::))

  • Author

Well, I came up with this:

 

	@EventHandler
public static void preInit(FMLPreInitializationEvent event) {
network = NetworkRegistry.INSTANCE.newSimpleChannel("MyChannel");
        network.registerMessage(ClearSlotMessage.Handler.class, ClearSlotMessage.class, 0, Side.SERVER);

}


public class ClearSlotMessage implements IMessage{

public int x;
public int y;
public int z;
    public ClearSlotMessage(int x, int y, int z) { 
    	this.x = x;
    	this.y = y;
    	this.z = z;
    }
    
@Override
public void fromBytes(ByteBuf buf) {
}

@Override
public void toBytes(ByteBuf buf) {
}

public static class Handler implements IMessageHandler<ClearSlotMessage, IMessage> {
    
    @Override
    public IMessage onMessage(ClearSlotMessage message, MessageContext ctx) {
        TileEntityCutter entity = (TileEntityCutter) ctx.getServerHandler().playerEntity.worldObj.getTileEntity(message.x, message.y, message.z);
        if(entity != null) {
//	        	entity.
        	System.out.print("safasfasfasfasfafasfasfas");
        }
        return null;
    }
}

}


public void onButtonClick() { //the method in my tileEntity
	FM.network.sendToServer(new ClearSlotMessage(xCoord, yCoord, zCoord));
}



 

I'm not sure how I use the methods fromByte and toByte (just make x y z binary?)

And what is the "MyChannel"?

Rest ok?

You can use

buf.writeInt(int)

and

int = buf.readInt()

. For more complex stuff, like strings, you can use the ByteBufUtils class. The

"MyChannel"

is the channel it registers to. If two or more mods use the same channel, you get both messages (I think). You should probably prefix your channel name with your modid.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

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.