Jump to content

Recommended Posts

Posted

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?

Posted

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/

Posted

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?

Posted

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/

Posted

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  ::))

Posted

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?

Posted

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

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