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

When I use a for loop to draw buttons the first ones draw normal and then the rest all draw weird

 

heres the gui class

package com.neg2013.main;

import java.io.IOException;

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 tabWidth = 194;
int tabHeight = 21;

int guiWidth = 247;
int guiHeight = 165;

boolean clicked1 = false;
boolean clicked2 = false;

int id = 0;
GuiButton serverButton;

int serverV = 207;

int ServersOnPage = 6;







@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
	mc.renderEngine.bindTexture(new ResourceLocation(Reference.MODID, "textures/gui/gui.png"));

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

	GL11.glColor4f(1, 1, 1, 1);

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


	//the gui
	drawTexturedModalRect(guiX, guiY, 0, 0, guiWidth, guiHeight);




	for(int i = 0; i < ServersOnPage; i++){
	drawTexturedModalRect(guiX + 4 , guiY + 4+ (25 * i), 1, serverV, tabWidth, tabHeight);


	fontRendererObj.drawString( "Server " + (i + 1),              guiX + 4 + 4 , guiY + 4 + 6 + (25 * i),          0X000000);
	}





	//drawDefaultBackground();



	super.drawScreen(mouseX, mouseY, partialTicks);
}//drawScreen




@Override
public void initGui() {

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


	buttonList.clear();
	//buttonList.add(serverButton = new GuiButton(id, guiX, guiY, 194, 21, "ServerTest"));

	super.initGui();
}//initGui

@Override
protected void actionPerformed(GuiButton button) throws IOException {

	switch(button.id){
	case 0:


	break;


	}//switch


	super.actionPerformed(button);
}//acttionPerformed

@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


//drawTexturedModalRect(guiX + 4, guiY + 4, 1, 229, tabWidth, tabHeight);






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

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

	if(guiX + 0 <= x && x <= guiX + 0 + tabWidth && guiY + 0 <= y && y <= guiY + 0 + tabHeight ){
		System.out.println("clicked1");
		clicked1 = true;
		clicked2 = false;
	}




	super.mouseClicked(x, y, mouseButton);
	}//mouseclicked



@Override
public boolean doesGuiPauseGame() {
	return false;
}//doesGuiPauseGame
}//class

 

and this is what it looks like

 

 

  • Author

I changed the for loop so that it binds the texture back every iteration and now they're just solid black.

 

Guest
This topic is now closed to further replies.

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.