Fix MP gui

This commit is contained in:
catfoolyou 2025-02-04 10:44:01 -05:00
parent c8acff384a
commit c0a1dc5639
8 changed files with 151 additions and 193 deletions

Binary file not shown.

View File

@ -31,7 +31,7 @@ public class GuiLanguage extends GuiScreen {
StringTranslate var1 = StringTranslate.getInstance(); StringTranslate var1 = StringTranslate.getInstance();
this.buttonList.add(this.doneButton = new GuiSmallButton(6, this.width / 2 - 75, this.height - 38, var1.translateKey("gui.done"))); this.buttonList.add(this.doneButton = new GuiSmallButton(6, this.width / 2 - 75, this.height - 38, var1.translateKey("gui.done")));
this.languageList = new GuiSlotLanguage(this); this.languageList = new GuiSlotLanguage(this);
this.languageList.registerScrollButtons(7, 8); this.languageList.registerScrollButtons(this.buttonList, 7, 8);
} }
/** /**

View File

@ -79,7 +79,7 @@ public class GuiSelectWorld extends GuiScreen
this.localizedGameModeText[EnumGameType.CREATIVE.getID()] = StatCollector.translateToLocal("gameMode.creative"); this.localizedGameModeText[EnumGameType.CREATIVE.getID()] = StatCollector.translateToLocal("gameMode.creative");
this.localizedGameModeText[EnumGameType.ADVENTURE.getID()] = StatCollector.translateToLocal("gameMode.adventure"); this.localizedGameModeText[EnumGameType.ADVENTURE.getID()] = StatCollector.translateToLocal("gameMode.adventure");
this.worldSlotContainer = new GuiWorldSlot(this); this.worldSlotContainer = new GuiWorldSlot(this);
this.worldSlotContainer.registerScrollButtons(4, 5); this.worldSlotContainer.registerScrollButtons(this.buttonList, 4, 5);
this.initButtons(); this.initButtons();
} }

View File

@ -1,20 +1,24 @@
package net.minecraft.src; package net.minecraft.src;
import org.lwjgl.input.Mouse; import java.util.List;
import net.lax1dude.eaglercraft.EaglerAdapter; import net.lax1dude.eaglercraft.EaglerAdapter;
import net.lax1dude.eaglercraft.TextureLocation;
import net.lax1dude.eaglercraft.adapter.Tessellator; import net.lax1dude.eaglercraft.adapter.Tessellator;
import net.minecraft.src.Minecraft;
public abstract class GuiSlot public abstract class GuiSlot {
{ protected final Minecraft mc;
public final Minecraft mc;
/** /**
* The width of the GuiScreen. Affects the container rendering, but not the overlays. * The width of the GuiScreen. Affects the container rendering, but not the
* overlays.
*/ */
int width; private int width;
/** /**
* The height of the GuiScreen. Affects the container rendering, but not the overlays or the scrolling. * The height of the GuiScreen. Affects the container rendering, but not the
* overlays or the scrolling.
*/ */
private int height; private int height;
@ -45,8 +49,8 @@ public abstract class GuiSlot
private float initialClickY = -2.0F; private float initialClickY = -2.0F;
/** /**
* what to multiply the amount you moved your mouse by(used for slowing down scrolling when over the items and no on * what to multiply the amount you moved your mouse by(used for slowing down
* scroll bar) * scrolling when over the items and no on scroll bar)
*/ */
private float scrollMultiplier; private float scrollMultiplier;
@ -57,15 +61,15 @@ public abstract class GuiSlot
private int selectedElement = -1; private int selectedElement = -1;
/** the time when this button was last clicked. */ /** the time when this button was last clicked. */
private long lastClicked; private long lastClicked = 0L;
/** true if a selected element in this gui will show an outline box */ /** true if a selected element in this gui will show an outline box */
private boolean showSelectionBox = true; private boolean showSelectionBox = true;
private boolean field_77243_s; private boolean field_77243_s;
private int field_77242_t; private int field_77242_t;
protected int elementWidth = 110;
public GuiSlot(Minecraft par1Minecraft, int par2, int par3, int par4, int par5, int par6) public GuiSlot(Minecraft par1Minecraft, int par2, int par3, int par4, int par5, int par6) {
{
this.mc = par1Minecraft; this.mc = par1Minecraft;
this.width = par2; this.width = par2;
this.height = par3; this.height = par3;
@ -76,8 +80,7 @@ public abstract class GuiSlot
this.right = par2; this.right = par2;
} }
public void func_77207_a(int par1, int par2, int par3, int par4) public void func_77207_a(int par1, int par2, int par3, int par4) {
{
this.width = par1; this.width = par1;
this.height = par2; this.height = par2;
this.top = par3; this.top = par3;
@ -86,18 +89,15 @@ public abstract class GuiSlot
this.right = par1; this.right = par1;
} }
public void setShowSelectionBox(boolean par1) public void setShowSelectionBox(boolean par1) {
{
this.showSelectionBox = par1; this.showSelectionBox = par1;
} }
protected void func_77223_a(boolean par1, int par2) protected void func_77223_a(boolean par1, int par2) {
{
this.field_77243_s = par1; this.field_77243_s = par1;
this.field_77242_t = par2; this.field_77242_t = par2;
if (!par1) if (!par1) {
{
this.field_77242_t = 0; this.field_77242_t = 0;
} }
} }
@ -108,7 +108,8 @@ public abstract class GuiSlot
protected abstract int getSize(); protected abstract int getSize();
/** /**
* the element in the slot that was clicked, boolean for wether it was double clicked or not * the element in the slot that was clicked, boolean for wether it was double
* clicked or not
*/ */
protected abstract void elementClicked(int var1, boolean var2); protected abstract void elementClicked(int var1, boolean var2);
@ -120,8 +121,7 @@ public abstract class GuiSlot
/** /**
* return the height of the content being scrolled * return the height of the content being scrolled
*/ */
protected int getContentHeight() protected int getContentHeight() {
{
return this.getSize() * this.slotHeight + this.field_77242_t; return this.getSize() * this.slotHeight + this.field_77242_t;
} }
@ -129,16 +129,18 @@ public abstract class GuiSlot
protected abstract void drawSlot(int var1, int var2, int var3, int var4, Tessellator var5); protected abstract void drawSlot(int var1, int var2, int var3, int var4, Tessellator var5);
protected void func_77222_a(int par1, int par2, Tessellator par3Tessellator) {} protected void func_77222_a(int par1, int par2, Tessellator par3Tessellator) {
}
protected void func_77224_a(int par1, int par2) {} protected void func_77224_a(int par1, int par2) {
}
protected void func_77215_b(int par1, int par2) {} protected void func_77215_b(int par1, int par2) {
}
public int func_77210_c(int par1, int par2) public int func_77210_c(int par1, int par2) {
{ int var3 = this.width / 2 - elementWidth;
int var3 = this.width / 2 - 110; int var4 = this.width / 2 + elementWidth;
int var4 = this.width / 2 + 110;
int var5 = par2 - this.top - this.field_77242_t + (int) this.amountScrolled - 4; int var5 = par2 - this.top - this.field_77242_t + (int) this.amountScrolled - 4;
int var6 = var5 / this.slotHeight; int var6 = var5 / this.slotHeight;
return par1 >= var3 && par1 <= var4 && var6 >= 0 && var5 >= 0 && var6 < this.getSize() ? var6 : -1; return par1 >= var3 && par1 <= var4 && var6 >= 0 && var5 >= 0 && var6 < this.getSize() ? var6 : -1;
@ -147,59 +149,47 @@ public abstract class GuiSlot
/** /**
* Registers the IDs that can be used for the scrollbar's buttons. * Registers the IDs that can be used for the scrollbar's buttons.
*/ */
public void registerScrollButtons(int par1, int par2) public void registerScrollButtons(List par1List, int par2, int par3) {
{ this.scrollUpButtonID = par2;
this.scrollUpButtonID = par1; this.scrollDownButtonID = par3;
this.scrollDownButtonID = par2;
} }
/** /**
* stop the thing from scrolling out of bounds * stop the thing from scrolling out of bounds
*/ */
private void bindAmountScrolled() private void bindAmountScrolled() {
{
int var1 = this.func_77209_d(); int var1 = this.func_77209_d();
if (var1 < 0) if (var1 < 0) {
{
var1 /= 2; var1 /= 2;
} }
if (this.amountScrolled < 0.0F) if (this.amountScrolled < 0.0F) {
{
this.amountScrolled = 0.0F; this.amountScrolled = 0.0F;
} }
if (this.amountScrolled > (float)var1) if (this.amountScrolled > (float) var1) {
{
this.amountScrolled = (float) var1; this.amountScrolled = (float) var1;
} }
} }
public int func_77209_d() public int func_77209_d() {
{
return this.getContentHeight() - (this.bottom - this.top - 4); return this.getContentHeight() - (this.bottom - this.top - 4);
} }
public void func_77208_b(int par1) public void func_77208_b(int par1) {
{
this.amountScrolled += (float) par1; this.amountScrolled += (float) par1;
this.bindAmountScrolled(); this.bindAmountScrolled();
this.initialClickY = -2.0F; this.initialClickY = -2.0F;
} }
public void actionPerformed(GuiButton par1GuiButton) public void actionPerformed(GuiButton par1GuiButton) {
{ if (par1GuiButton.enabled) {
if (par1GuiButton.enabled) if (par1GuiButton.id == this.scrollUpButtonID) {
{
if (par1GuiButton.id == this.scrollUpButtonID)
{
this.amountScrolled -= (float) (this.slotHeight * 2 / 3); this.amountScrolled -= (float) (this.slotHeight * 2 / 3);
this.initialClickY = -2.0F; this.initialClickY = -2.0F;
this.bindAmountScrolled(); this.bindAmountScrolled();
} } else if (par1GuiButton.id == this.scrollDownButtonID) {
else if (par1GuiButton.id == this.scrollDownButtonID)
{
this.amountScrolled += (float) (this.slotHeight * 2 / 3); this.amountScrolled += (float) (this.slotHeight * 2 / 3);
this.initialClickY = -2.0F; this.initialClickY = -2.0F;
this.bindAmountScrolled(); this.bindAmountScrolled();
@ -207,11 +197,13 @@ public abstract class GuiSlot
} }
} }
private static final TextureLocation tex = new TextureLocation("/gui/background.png");
/** /**
* draws the slot to the screen, pass in mouse's current x and y and partial ticks * draws the slot to the screen, pass in mouse's current x and y and partial
* ticks
*/ */
public void drawScreen(int par1, int par2, float par3) public void drawScreen(int par1, int par2, float par3) {
{
this.mouseX = par1; this.mouseX = par1;
this.mouseY = par2; this.mouseY = par2;
this.drawBackground(); this.drawBackground();
@ -224,95 +216,69 @@ public abstract class GuiSlot
int var13; int var13;
int var20; int var20;
if (Mouse.isButtonDown(0)) if (EaglerAdapter.mouseIsButtonDown(0)) {
{ if (this.initialClickY == -1.0F) {
if (this.initialClickY == -1.0F)
{
boolean var7 = true; boolean var7 = true;
if (par2 >= this.top && par2 <= this.bottom) if (par2 >= this.top && par2 <= this.bottom) {
{ int var8 = this.width / 2 - elementWidth;
int var8 = this.width / 2 - 110; var9 = this.width / 2 + elementWidth;
var9 = this.width / 2 + 110;
var10 = par2 - this.top - this.field_77242_t + (int) this.amountScrolled - 4; var10 = par2 - this.top - this.field_77242_t + (int) this.amountScrolled - 4;
var11 = var10 / this.slotHeight; var11 = var10 / this.slotHeight;
if (par1 >= var8 && par1 <= var9 && var11 >= 0 && var10 >= 0 && var11 < var4) if (par1 >= var8 && par1 <= var9 && var11 >= 0 && var10 >= 0 && var11 < var4) {
{
boolean var12 = var11 == this.selectedElement && Minecraft.getSystemTime() - this.lastClicked < 250L; boolean var12 = var11 == this.selectedElement && Minecraft.getSystemTime() - this.lastClicked < 250L;
this.elementClicked(var11, var12); this.elementClicked(var11, var12);
this.selectedElement = var11; this.selectedElement = var11;
this.lastClicked = Minecraft.getSystemTime(); this.lastClicked = Minecraft.getSystemTime();
} } else if (par1 >= var8 && par1 <= var9 && var10 < 0) {
else if (par1 >= var8 && par1 <= var9 && var10 < 0)
{
this.func_77224_a(par1 - var8, par2 - this.top + (int) this.amountScrolled - 4); this.func_77224_a(par1 - var8, par2 - this.top + (int) this.amountScrolled - 4);
var7 = false; var7 = false;
} }
if (par1 >= var5 && par1 <= var6) if (par1 >= var5 && par1 <= var6) {
{
this.scrollMultiplier = -1.0F; this.scrollMultiplier = -1.0F;
var20 = this.func_77209_d(); var20 = this.func_77209_d();
if (var20 < 1) if (var20 < 1) {
{
var20 = 1; var20 = 1;
} }
var13 = (int) ((float) ((this.bottom - this.top) * (this.bottom - this.top)) / (float) this.getContentHeight()); var13 = (int) ((float) ((this.bottom - this.top) * (this.bottom - this.top)) / (float) this.getContentHeight());
if (var13 < 32) if (var13 < 32) {
{
var13 = 32; var13 = 32;
} }
if (var13 > this.bottom - this.top - 8) if (var13 > this.bottom - this.top - 8) {
{
var13 = this.bottom - this.top - 8; var13 = this.bottom - this.top - 8;
} }
this.scrollMultiplier /= (float) (this.bottom - this.top - var13) / (float) var20; this.scrollMultiplier /= (float) (this.bottom - this.top - var13) / (float) var20;
} } else {
else
{
this.scrollMultiplier = 1.0F; this.scrollMultiplier = 1.0F;
} }
if (var7) if (var7) {
{
this.initialClickY = (float) par2; this.initialClickY = (float) par2;
} } else {
else
{
this.initialClickY = -2.0F; this.initialClickY = -2.0F;
} }
} } else {
else
{
this.initialClickY = -2.0F; this.initialClickY = -2.0F;
} }
} } else if (this.initialClickY >= 0.0F) {
else if (this.initialClickY >= 0.0F)
{
this.amountScrolled -= ((float) par2 - this.initialClickY) * this.scrollMultiplier; this.amountScrolled -= ((float) par2 - this.initialClickY) * this.scrollMultiplier;
this.initialClickY = (float) par2; this.initialClickY = (float) par2;
} }
} } else {
else while (EaglerAdapter.mouseNext()) {
{ int var16 = EaglerAdapter.mouseGetEventDWheel();
while (!this.mc.gameSettings.touchscreen && Mouse.next())
{
int var16 = Mouse.getEventDWheel();
if (var16 != 0) if (var16 != 0) {
{ if (var16 > 0) {
if (var16 > 0)
{
var16 = -1; var16 = -1;
} } else if (var16 < 0) {
else if (var16 < 0)
{
var16 = 1; var16 = 1;
} }
@ -327,7 +293,7 @@ public abstract class GuiSlot
EaglerAdapter.glDisable(EaglerAdapter.GL_LIGHTING); EaglerAdapter.glDisable(EaglerAdapter.GL_LIGHTING);
EaglerAdapter.glDisable(EaglerAdapter.GL_FOG); EaglerAdapter.glDisable(EaglerAdapter.GL_FOG);
Tessellator var18 = Tessellator.instance; Tessellator var18 = Tessellator.instance;
Gui.optionsBackground.bindTexture(); tex.bindTexture();
EaglerAdapter.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); EaglerAdapter.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
float var17 = 32.0F; float var17 = 32.0F;
var18.startDrawingQuads(); var18.startDrawingQuads();
@ -337,27 +303,26 @@ public abstract class GuiSlot
var18.addVertexWithUV((double) this.right, (double) this.top, 0.0D, (double) ((float) this.right / var17), (double) ((float) (this.top + (int) this.amountScrolled) / var17)); var18.addVertexWithUV((double) this.right, (double) this.top, 0.0D, (double) ((float) this.right / var17), (double) ((float) (this.top + (int) this.amountScrolled) / var17));
var18.addVertexWithUV((double) this.left, (double) this.top, 0.0D, (double) ((float) this.left / var17), (double) ((float) (this.top + (int) this.amountScrolled) / var17)); var18.addVertexWithUV((double) this.left, (double) this.top, 0.0D, (double) ((float) this.left / var17), (double) ((float) (this.top + (int) this.amountScrolled) / var17));
var18.draw(); var18.draw();
var9 = this.width / 2 - 92 - 16; var9 = this.width / 2 + 2 - elementWidth;
var10 = this.top + 4 - (int) this.amountScrolled; var10 = this.top + 4 - (int) this.amountScrolled;
if (this.field_77243_s) if (this.field_77243_s) {
{
this.func_77222_a(var9, var10, var18); this.func_77222_a(var9, var10, var18);
} }
int var14; int var14;
for (var11 = 0; var11 < var4; ++var11) EaglerAdapter.glEnable(EaglerAdapter.GL_BLEND);
{ EaglerAdapter.glBlendFunc(EaglerAdapter.GL_SRC_ALPHA, EaglerAdapter.GL_ONE_MINUS_SRC_ALPHA);
for (var11 = 0; var11 < var4; ++var11) {
var20 = var10 + var11 * this.slotHeight + this.field_77242_t; var20 = var10 + var11 * this.slotHeight + this.field_77242_t;
var13 = this.slotHeight - 4; var13 = this.slotHeight - 4;
if (var20 <= this.bottom && var20 + var13 >= this.top) if (var20 <= this.bottom && var20 + var13 >= this.top) {
{ if (this.showSelectionBox && this.isSelected(var11)) {
if (this.showSelectionBox && this.isSelected(var11)) var14 = this.width / 2 - elementWidth;
{ int var15 = this.width / 2 + elementWidth;
var14 = this.width / 2 - 110;
int var15 = this.width / 2 + 110;
EaglerAdapter.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); EaglerAdapter.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
EaglerAdapter.glDisable(EaglerAdapter.GL_TEXTURE_2D); EaglerAdapter.glDisable(EaglerAdapter.GL_TEXTURE_2D);
var18.startDrawingQuads(); var18.startDrawingQuads();
@ -406,24 +371,20 @@ public abstract class GuiSlot
var18.draw(); var18.draw();
var20 = this.func_77209_d(); var20 = this.func_77209_d();
if (var20 > 0) if (var20 > 0) {
{
var13 = (this.bottom - this.top) * (this.bottom - this.top) / this.getContentHeight(); var13 = (this.bottom - this.top) * (this.bottom - this.top) / this.getContentHeight();
if (var13 < 32) if (var13 < 32) {
{
var13 = 32; var13 = 32;
} }
if (var13 > this.bottom - this.top - 8) if (var13 > this.bottom - this.top - 8) {
{
var13 = this.bottom - this.top - 8; var13 = this.bottom - this.top - 8;
} }
var14 = (int) this.amountScrolled * (this.bottom - this.top - var13) / var20 + this.top; var14 = (int) this.amountScrolled * (this.bottom - this.top - var13) / var20 + this.top;
if (var14 < this.top) if (var14 < this.top) {
{
var14 = this.top; var14 = this.top;
} }
@ -457,18 +418,16 @@ public abstract class GuiSlot
EaglerAdapter.glDisable(EaglerAdapter.GL_BLEND); EaglerAdapter.glDisable(EaglerAdapter.GL_BLEND);
} }
protected int getScrollBarX() protected int getScrollBarX() {
{ return this.width / 2 + elementWidth + 28;
return this.width / 2 + 124;
} }
/** /**
* Overlays the background to hide scrolled items * Overlays the background to hide scrolled items
*/ */
private void overlayBackground(int par1, int par2, int par3, int par4) private void overlayBackground(int par1, int par2, int par3, int par4) {
{
Tessellator var5 = Tessellator.instance; Tessellator var5 = Tessellator.instance;
Gui.optionsBackground.bindTexture(); tex.bindTexture();
EaglerAdapter.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); EaglerAdapter.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
float var6 = 32.0F; float var6 = 32.0F;
var5.startDrawingQuads(); var5.startDrawingQuads();

View File

@ -70,7 +70,7 @@ class GuiSlotServer extends GuiSlot {
protected void drawSlot(int par1, int par2, int par3, int par4, Tessellator par5Tessellator) { protected void drawSlot(int par1, int par2, int par3, int par4, Tessellator par5Tessellator) {
if (par1 < GuiMultiplayer.getInternetServerList(this.parentGui).countServers()) { if (par1 < GuiMultiplayer.getInternetServerList(this.parentGui).countServers()) {
try { try {
this.func_77247_d(par1, par2, par3, par4, par5Tessellator); this.func_77247_d(par1, par2 - 28, par3, par4, par5Tessellator);
}catch(Throwable t) { }catch(Throwable t) {
} }
} else if (par1 < GuiMultiplayer.getInternetServerList(this.parentGui).countServers() } else if (par1 < GuiMultiplayer.getInternetServerList(this.parentGui).countServers()

View File

@ -38,11 +38,11 @@ public class GuiStats extends GuiScreen
{ {
this.statsTitle = StatCollector.translateToLocal("gui.stats"); this.statsTitle = StatCollector.translateToLocal("gui.stats");
this.slotGeneral = new GuiSlotStatsGeneral(this); this.slotGeneral = new GuiSlotStatsGeneral(this);
this.slotGeneral.registerScrollButtons(1, 1); this.slotGeneral.registerScrollButtons(this.buttonList, 1, 1);
this.slotItem = new GuiSlotStatsItem(this); this.slotItem = new GuiSlotStatsItem(this);
this.slotItem.registerScrollButtons(1, 1); this.slotItem.registerScrollButtons(this.buttonList, 1, 1);
this.slotBlock = new GuiSlotStatsBlock(this); this.slotBlock = new GuiSlotStatsBlock(this);
this.slotBlock.registerScrollButtons(1, 1); this.slotBlock.registerScrollButtons(this.buttonList, 1, 1);
this.selectedSlot = this.slotGeneral; this.selectedSlot = this.slotGeneral;
this.addHeaderButtons(); this.addHeaderButtons();
} }

View File

@ -44,7 +44,7 @@ public class GuiTexturePacks extends GuiScreen {
this.mc.texturePackList.updateAvaliableTexturePacks(); this.mc.texturePackList.updateAvaliableTexturePacks();
this.fileLocation = "texturepacks"; this.fileLocation = "texturepacks";
this.guiTexturePackSlot = new GuiTexturePackSlot(this); this.guiTexturePackSlot = new GuiTexturePackSlot(this);
this.guiTexturePackSlot.registerScrollButtons(7, 8); this.guiTexturePackSlot.registerScrollButtons(this.buttonList, 7, 8);
} }
/** /**

View File

@ -2128,9 +2128,8 @@ public class Minecraft
/** /**
* Gets the system time in milliseconds. * Gets the system time in milliseconds.
*/ */
public static long getSystemTime() public static long getSystemTime() {
{ return EaglerAdapter.steadyTimeMillis();
return Sys.getTime() * 1000L / Sys.getTimerResolution();
} }
/** /**