Jump to content

Recommended Posts

Posted

I'm trying to draw tabs, I have it set up so that when I click a certain area a boolean becomes true and then I'm based on the state of the boolean trying to draw a rectangle so it appears as if the the tab has been select

 

 

method for drawing the tabs:

 

public void drawSelectedTab(){
	int guiX = (width - guiWidth) / 2;
	int guiY = (height - guiHeight) / 2;





	int tabOU;

	if(tabOfficial){
		tabOU = 237;
	}
	else{
		tabOU = 233;
	}

	//tab Official
	drawTexturedModalRect(guiX + 203, guiY + 3,              tabOU, 15,             3, 22);


	int tabCU;
	if(tabCommunity){
		tabCU = 237;
	}
	else{
		tabCU = 233;
	}
	//tab Community
	drawTexturedModalRect(guiX + 203, guiY + 27,             tabCU, 15,             3, 22);

	int tabFU;
	if(tabFavorites){
		tabFU = 237;
	}
	else{
		tabFU = 233;
	}
	//tab Favorites
	drawTexturedModalRect(guiX + 203, guiY + 51,             tabFU, 15,             3, 22);	



}

 

and heres the part that determines which tab has been selected

@Override
protected void mouseClicked(int x, int y, int mouseButton) throws IOException {

	int guiX = (width - guiWidth) / 2;
	int guiY = (height - guiHeight) / 2;


	//tab Official
	if(trueZone(guiX + 205, guiY + 3, 19, 22, x, y)){

		tabOfficial = true;
		tabCommunity = false;
		tabFavorites = false;

		if(tabOfficial){
			System.out.println("Clicked tab Official");
		}
	}//tab Official

	//tab Community
	if(trueZone(guiX + 205, guiY + 27, 19, 22, x, y)){

		tabOfficial = false;
		tabCommunity = true;
		tabFavorites = false;

		if(tabCommunity){
			System.out.println("Clicked tab Community");
		}			
	}//tab Community	

	//tab Favorites
	if(trueZone(guiX + 205, guiY + 51, 19, 22, x, y)){

		tabOfficial = false;
		tabCommunity = false;
		tabFavorites = true;

		if(tabFavorites){
			System.out.println("Clicked tab Favorites");
		}
	}//tab Favorites

 

Heres the entire class:

package com.neg2013.main;

import java.io.IOException;
import java.util.List;

import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.GL11;

import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.util.ResourceLocation;

public class GuiServerPicker extends GuiScreen{

int buttonWidth = 194;
int buttonHeight = 21;

int tabWidth = 19;
int tabHeight = 22;

int guiWidth = 225;
int guiHeight = 154;

boolean clicked1 = false;
boolean clicked2 = false;
boolean clicked3 = false;
boolean clicked4 = false;
boolean clicked5 = false;
boolean clicked6 = false;

boolean tabOfficial = true;
boolean tabCommunity = false;
boolean tabFavorites = false;

int id = 0;
GuiButton menuButton;

//int serverV = 207;
int ServersOnPage = 5;

@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
	int guiX = (width - guiWidth) / 2;
	int guiY = (height - guiHeight) / 2;

	mc.renderEngine.bindTexture(new ResourceLocation(Reference.MODID, "textures/gui/gui.png"));
	GL11.glColor4f(1, 1, 1, 1);
	drawTexturedModalRect(guiX, guiY, 0, 0, guiWidth, guiHeight);

	serverButtons("NEG2013", "Is", "The", "God", "Of", "Sexiness", ServersOnPage);
	drawSelectedTab();











	super.drawScreen(mouseX, mouseY, partialTicks);

}//drawScreen

	//ADD THE PLAYER COUNT	

public void serverButtons(String name1, String name2, String name3, String name4, String name5, String name6, int ServersOnPage){
	int guiX = (width - guiWidth) / 2;
	int guiY = (height - guiHeight) / 2;

	int color = 0X000000;



	if(ServersOnPage < 1){
		return;
	}
	//server 1
		int i = 0;
		int serverV;

		if(clicked1){
			serverV = 229;
		}
		else{
			serverV = 207;
		}

		fontRendererObj.drawString( name1, guiX + 8 , guiY + 10 + (25 * i), color);
		mc.renderEngine.bindTexture(new ResourceLocation(Reference.MODID, "textures/gui/gui.png"));
		GL11.glColor4f(1, 1, 1, 1);	
		drawTexturedModalRect(guiX + 4 , guiY + 4 + (25 * i), 1, serverV, buttonWidth, buttonHeight);
		fontRendererObj.drawString( name1, guiX + 4 + 4 , guiY + 4 + 6 + (25 * i), color);
			//server 1 end


	if(ServersOnPage < 2){
		return;
	}
	//server 2
		int i1 = 1;
		int server1V;

		if(clicked2){
			server1V = 229;
		}
		else{
			server1V = 207;
		}

		fontRendererObj.drawString( name2, guiX + 8 , guiY + 10 + (25 * i1), color);
		mc.renderEngine.bindTexture(new ResourceLocation(Reference.MODID, "textures/gui/gui.png"));
		GL11.glColor4f(1, 1, 1, 1);	
		drawTexturedModalRect(guiX + 4 , guiY + 4 + (25 * i1), 1, server1V, buttonWidth, buttonHeight);
		fontRendererObj.drawString( name2, guiX + 4 + 4 , guiY + 4 + 6 + (25 * i1), color);
			//server 3 end

	if(ServersOnPage < 3){
		return;
	}
	//server 3
		int i2 = 2;
		int server2V;

		if(clicked3){
			server2V = 229;
		}
		else{
			server2V = 207;
		}

		fontRendererObj.drawString( name3, guiX + 8 , guiY + 10 + (25 * i2), color);
		mc.renderEngine.bindTexture(new ResourceLocation(Reference.MODID, "textures/gui/gui.png"));
		GL11.glColor4f(1, 1, 1, 1);	
		drawTexturedModalRect(guiX + 4 , guiY + 4 + (25 * i2), 1, server2V, buttonWidth, buttonHeight);
		fontRendererObj.drawString( name3, guiX + 4 + 4 , guiY + 4 + 6 + (25 * i2), color);
			//server 3 end

	if(ServersOnPage < 4){
		return;
	}
	//server 4
		int i3 = 3;
		int server3V;

		if(clicked4){
			server3V = 229;
		}
		else{
			server3V = 207;
		}

		fontRendererObj.drawString( name4, guiX + 8 , guiY + 10 + (25 * i3), color);
		mc.renderEngine.bindTexture(new ResourceLocation(Reference.MODID, "textures/gui/gui.png"));
		GL11.glColor4f(1, 1, 1, 1);	
		drawTexturedModalRect(guiX + 4 , guiY + 4 + (25 * i3), 1, server3V, buttonWidth, buttonHeight);
		fontRendererObj.drawString( name4, guiX + 4 + 4 , guiY + 4 + 6 + (25 * i3), color);
			//server 4 end

	if(ServersOnPage < 5){
		return;
	}
	//server 5
		int i4 = 4;
		int server4V;

		if(clicked5){
			server4V = 229;
		}
		else{
			server4V = 207;
		}

		fontRendererObj.drawString( name5, guiX + 8 , guiY + 10 + (25 * i4), color);
		mc.renderEngine.bindTexture(new ResourceLocation(Reference.MODID, "textures/gui/gui.png"));
		GL11.glColor4f(1, 1, 1, 1);	
		drawTexturedModalRect(guiX + 4 , guiY + 4 + (25 * i4), 1, server4V, buttonWidth, buttonHeight);
		fontRendererObj.drawString( name5, guiX + 4 + 4 , guiY + 4 + 6 + (25 * i4), color);
			//server 5 end

	if(ServersOnPage < 6){
		return;
	}
	//server 6
		int i5 = 5;
		int server5V;

		if(clicked6){
			server5V = 229;
		}
		else{
			server5V = 207;
		}

		fontRendererObj.drawString( name6, guiX + 8 , guiY + 10 + (25 * i5), color);
		mc.renderEngine.bindTexture(new ResourceLocation(Reference.MODID, "textures/gui/gui.png"));
		GL11.glColor4f(1, 1, 1, 1);	
		drawTexturedModalRect(guiX + 4 , guiY + 4 + (25 * i5), 1, server5V, buttonWidth, buttonHeight);
		fontRendererObj.drawString( name6, guiX + 4 + 4 , guiY + 4 + 6 + (25 * i5), color);
			//server 6 end
			if(ServersOnPage > 6){
				return;
			}


}//serverButtons

/*if(tabOfficial){
				//tab1
				drawTexturedModalRect(guiX + 203, guiY + 3,              237, 15,             3, 22);

				//tab2
				drawTexturedModalRect(guiX + 203, guiY + 27,             233, 15,             3, 22);

				//tab3
				drawTexturedModalRect(guiX + 203, guiY + 51,             233, 15,             3, 22);

			}//tabO

			if(tabCommunity){
				//tab1
				drawTexturedModalRect(guiX + 203, guiY + 3,              233, 15,             3, 22);

				//tab2
				drawTexturedModalRect(guiX + 203, guiY + 27,             237, 15,            3, 22);

				//tab3
				drawTexturedModalRect(guiX + 203, guiY + 51,             233, 15,             3, 22);

			}//tabC

			if(tabFavorites){
				//tab1
				drawTexturedModalRect(guiX + 203, guiY + 3,              233, 15,            3, 22);

				//tab2
				drawTexturedModalRect(guiX + 203, guiY + 27,             233, 15,             3, 22);

				//tab3
				drawTexturedModalRect(guiX + 203, guiY + 51,             237, 15,             3, 22);

			}//tabF*/

public void connectToServers(){

	//server 1

	if(clicked1){

	}

	//server 2
	if(clicked1){

	}

	//server 3
	if(clicked1){

	}

	//server 4
	if(clicked1){

	}//server 5

	if(clicked1){

	}

	//server 6
	if(clicked1){

	}

}//connectToServers



public void drawSelectedTab(){
	int guiX = (width - guiWidth) / 2;
	int guiY = (height - guiHeight) / 2;





	int tabOU;

	if(tabOfficial){
		tabOU = 237;
	}
	else{
		tabOU = 233;
	}

	//tab Official
	drawTexturedModalRect(guiX + 203, guiY + 3,              tabOU, 15,             3, 22);


	int tabCU;
	if(tabCommunity){
		tabCU = 237;
	}
	else{
		tabCU = 233;
	}
	//tab Community
	drawTexturedModalRect(guiX + 203, guiY + 27,             tabCU, 15,             3, 22);

	int tabFU;
	if(tabFavorites){
		tabFU = 237;
	}
	else{
		tabFU = 233;
	}
	//tab Favorites
	drawTexturedModalRect(guiX + 203, guiY + 51,             tabFU, 15,             3, 22);	



}
	public boolean trueZone(int OffsX, int OffsY, int Width, int Height, int MouseX, int MouseY){
	if(OffsX <= MouseX && MouseX <= OffsX + Width && OffsY <= MouseY && MouseY <= OffsY + Height ){
		return true;
	}
	else{
		return false;	
	}


}
@Override
protected void mouseClicked(int x, int y, int mouseButton) throws IOException {

	int guiX = (width - guiWidth) / 2;
	int guiY = (height - guiHeight) / 2;


	//tab Official
	if(trueZone(guiX + 205, guiY + 3, 19, 22, x, y)){

		tabOfficial = true;
		tabCommunity = false;
		tabFavorites = false;

		if(tabOfficial){
			System.out.println("Clicked tab Official");
		}
	}//tab Official

	//tab Community
	if(trueZone(guiX + 205, guiY + 27, 19, 22, x, y)){

		tabOfficial = false;
		tabCommunity = true;
		tabFavorites = false;

		if(tabCommunity){
			System.out.println("Clicked tab Community");
		}			
	}//tab Community	

	//tab Favorites
	if(trueZone(guiX + 205, guiY + 51, 19, 22, x, y)){

		tabOfficial = false;
		tabCommunity = false;
		tabFavorites = true;

		if(tabFavorites){
			System.out.println("Clicked tab Favorites");
		}
	}//tab Favorites




	if(ServersOnPage < 1){
		return;
	}
	//server1
	if(guiX + 0 <= x && x <= guiX + 0 + buttonWidth && guiY + 0 <= y && y <= guiY + 0 + buttonHeight ){
		System.out.println("Clicked Server 1");
		clicked1 = true;
		clicked2 = false;
		clicked3 = false;
		clicked4 = false;
		clicked5 = false;
		clicked6 = false;
	}
	if(ServersOnPage < 2){
		return;
	}
	//server2
	int i1 = 1;
	if(guiX + 0 <= x && x <= guiX + 0 + buttonWidth && guiY + 0  + (25 * i1) <= y && y <= guiY + 0  + (25 * i1) + buttonHeight ){
		System.out.println("Clicked Server 2");
		clicked1 = false;
		clicked2 = true;
		clicked3 = false;
		clicked4 = false;
		clicked5 = false;
		clicked6 = false;
	}
	if(ServersOnPage < 3){
		return;
	}
	//server3
	int i2 = 2;
	if(guiX + 0 <= x && x <= guiX + 0 + buttonWidth && guiY + 0  + (25 * i2) <= y && y <= guiY + 0  + (25 * i2) + buttonHeight ){
		System.out.println("Clicked Server 3");
		clicked1 = false;
		clicked2 = false;
		clicked3 = true;
		clicked4 = false;
		clicked5 = false;
		clicked6 = false;
	}
	if(ServersOnPage < 4){
		return;
	}
	//server4
	int i3 = 3;
	if(guiX + 0 <= x && x <= guiX + 0 + buttonWidth && guiY + 0  + (25 * i3)<= y && y <= guiY + 0 + (25 * i3) + buttonHeight ){
		System.out.println("Clicked Server 4");
		clicked1 = false;
		clicked2 = false;
		clicked3 = false;
		clicked4 = true;
		clicked5 = false;
		clicked6 = false;
	}
	if(ServersOnPage < 5){
		return;
	}
	//server5
	int i4 = 4;
	if(guiX + 0 <= x && x <= guiX + 0 + buttonWidth && guiY + 0 + (25 * i4) <= y && y <= guiY + 0 + (25 * i4) + buttonHeight ){
		System.out.println("Clicked Server 5");
		clicked1 = false;
		clicked2 = false;
		clicked3 = false;
		clicked4 = false;
		clicked5 = true;
		clicked6 = false;
	}
	if(ServersOnPage < 6){
		return;
	}
	//server6
	int i5 = 5;
	if(guiX + 0 <= x && x <= guiX + 0 + buttonWidth && guiY + 0 + (25 * i5) <= y && y <= guiY + 0 + (25 * i5) + buttonHeight ){
		System.out.println("Clicked Server 6");
		clicked1 = false;
		clicked2 = false;
		clicked3 = false;
		clicked4 = false;
		clicked5 = false;
		clicked6 = true;
	}


	super.mouseClicked(x, y, mouseButton);}//mouseclicked
@Override
protected void actionPerformed(GuiButton button) throws IOException {

	switch(button.id){

	case 666:

		Minecraft.getMinecraft().displayGuiScreen(new GuiServerPicker());

	break;

	}

	super.actionPerformed(button);}	
@Override
public void initGui() {
	buttonList.clear();
	buttonList.add(menuButton = new GuiButton(666, 0, 0, "NEG2013"));


	super.initGui();
}	
@Override
protected void keyTyped(char c, int key) throws IOException {

	switch(key){
	case Keyboard.KEY_E:
		Minecraft.getMinecraft().displayGuiScreen(null);
	break;




	}//switch

	super.keyTyped(c, key);
}//keyTyped	
@Override
public boolean doesGuiPauseGame() {
	return false;
}//doesGuiPauseGame
}//class


 

 

 

If you want to see anything else please just ask.

 

 

Posted

I already have it print out when there clicked and become truelike this

 

if(tabCommunity){

System.out.println("Clicked tab Community");

}

Posted

Don't use the default button I was saying use the default button "system". Make a class that extends GuiButton(which is where all the button rendering code is). Override the drawButton method and put your rendering code in there. And there is a method in GuiButton that checks if it is hovering over or not.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted

Interesting. I didn't know that. Did you want it to change size when you clicked it? Have you tried increasing the size it increases when you click it just to make sure that it is visible or not?

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted

Well if it worked before there are inconsistencies. And I would just switch over to the Vanilla GuiButton system it is much cleaner code. But why do you want to change the size when you click the button if the screen is going to change it won't render. Maybe you wanted it to render when it was being hovered over?

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted

I couldn't tell you why and yeah it has been a while since I have used drawTextureModelRect I forgot the parameters. Once you have switch over it should be much easier to pinpoint the problem.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Guest
This topic is now closed to further replies.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • "I want to understand how complex mods with ASM transformation and coremods work, such as Xray or AntiXray. Why do they break when you simply rename packages? What features of their architecture make refactoring difficult? And what techniques are used to protect these mods? I am interested in technical aspects in order to better understand the bytecode and Forge loader system."
    • I can't figure out if you're looking for help trying to steal someone elses work, or cheat at the game....
    • Title: Why Is It So Hard to Rename and Restructure Mods Like Xray or AntiXray? 🤔 Post text: Hey everyone! I’ve been digging into Minecraft modding for a while and have one big question that I can’t figure out on my own. Maybe someone with more experience could help or give me some advice. Here’s the issue: When I take a “normal” Minecraft mod — for example, one that just adds some blocks or new items — I can easily change its structure, package names, or even rebrand it entirely. It’s straightforward. But as soon as I try this with cheat-type mods like XrayMod or AntiXray, everything falls apart. Even if I just rename the classes, refactor the packages, or hide its identity somehow, the mod either breaks or stops working properly. XrayMod in particular is proving to be a nightmare to modify without losing its core function. So my question is — why is this so much harder with cheat mods like Xray? Is there something fundamentally different about how they’re coded, loaded, or protected that prevents simple renaming or restructuring? And if so, how can I actually learn to understand someone else’s cheat mod enough to safely refactor it without breaking the core features? I’ve already been spending over two months trying to figure this out and haven’t gotten anywhere. It feels like there must be some trick or knowledge I’m missing. Would really appreciate any thoughts, tips, or references — maybe there are guides or techniques for understanding cheat-mod internals? Or if you’ve successfully “disguised” a cheat mod like Xray before, I’d love to hear how you did it. Thanks in advance for any help or discussion. ✌️
    • just started making cinamatic contect check it out on my channel or check out my facebook page    Humbug City Minecraft Youtube https://www.youtube.com/watch?v=v2N6OveKwno https://www.facebook.com/profile.php?id=61575866982337  
    • Where did you get the schematic? Source/Link? And do use an own modpack or a pre-configured from curseforge? If yes, which one On a later time, I can make some tests on my own - but I need the schematic and the modpack name
  • Topics

×
×
  • Create New...

Important Information

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