Skip to content

Commit

Permalink
fix and improve stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
SpoilerRules committed Jan 25, 2024
1 parent 6592ec8 commit 1d4dc2d
Show file tree
Hide file tree
Showing 15 changed files with 237 additions and 323 deletions.
4 changes: 2 additions & 2 deletions src/main/java/net/minecraft/client/Minecraft.java
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,7 @@ public void runGameLoop() {
}

this.mcProfiler.profilingEnabled = true;
this.displayDebugInfo(i1);
this.displayDebugInfo();
} else {
this.mcProfiler.profilingEnabled = false;
this.prevFrameTime = System.nanoTime();
Expand Down Expand Up @@ -840,7 +840,7 @@ public void updateDebugProfilerName(int keyCount) {
}
}

private void displayDebugInfo(long elapsedTicksTime) {
private void displayDebugInfo() {
if (this.mcProfiler.profilingEnabled) {
List<Profiler.Result> list = this.mcProfiler.getProfilingData(this.debugProfilerName);
Profiler.Result profiler$result = list.remove(0);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package net.minecraft.client.gui;

import net.minecraft.client.Minecraft;
import org.lwjgl.input.Mouse;

public abstract class GuiClickableScrolledSelectionListProxy extends GuiSlot
{
Expand Down Expand Up @@ -36,7 +35,7 @@ protected void drawSelectionBox(int p_148120_1_, int p_148120_2_, int mouseXIn,

if (k > this.bottom || k + l < this.top)
{
this.func_178040_a(j, p_148120_1_, k);
this.setSelected(j, p_148120_1_, k);
}

this.drawSlot(j, p_148120_1_, k, l, mouseXIn, mouseYIn);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package net.minecraft.client.gui;

import java.io.IOException;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.GlStateManager;
Expand All @@ -16,6 +15,8 @@
import net.minecraft.world.gen.FlatGeneratorInfo;
import net.minecraft.world.gen.FlatLayerInfo;

import java.io.IOException;

public class GuiCreateFlatWorld extends GuiScreen
{
private final GuiCreateWorld createWorldGui;
Expand Down Expand Up @@ -178,7 +179,7 @@ protected void elementClicked(int slotIndex, boolean isDoubleClick, int mouseX,
GuiCreateFlatWorld.this.func_146375_g();
}

protected boolean isSelected(int slotIndex)
protected boolean isElementSelected(int slotIndex)
{
return slotIndex == this.field_148228_k;
}
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/net/minecraft/client/gui/GuiFlatPresets.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@

import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import net.minecraft.block.BlockTallGrass;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.RenderHelper;
Expand All @@ -21,6 +18,10 @@
import net.minecraft.world.gen.FlatLayerInfo;
import org.lwjgl.input.Keyboard;

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

public class GuiFlatPresets extends GuiScreen
{
private static final List<GuiFlatPresets.LayerItem> FLAT_WORLD_PRESETS = Lists.<GuiFlatPresets.LayerItem>newArrayList();
Expand Down Expand Up @@ -234,7 +235,7 @@ protected void elementClicked(int slotIndex, boolean isDoubleClick, int mouseX,
GuiFlatPresets.this.field_146433_u.setText(((GuiFlatPresets.LayerItem)GuiFlatPresets.FLAT_WORLD_PRESETS.get(GuiFlatPresets.this.field_146435_s.field_148175_k)).field_148233_c);
}

protected boolean isSelected(int slotIndex)
protected boolean isElementSelected(int slotIndex)
{
return slotIndex == this.field_148175_k;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/minecraft/client/gui/GuiLanguage.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ protected void elementClicked(int slotIndex, boolean isDoubleClick, int mouseX,
GuiLanguage.this.game_settings_3.saveOptions();
}

protected boolean isSelected(int slotIndex)
protected boolean isElementSelected(int slotIndex)
{
return this.langCodeList.get(slotIndex).equals(GuiLanguage.this.languageManager.getCurrentLanguage().getLanguageCode());
}
Expand Down
86 changes: 36 additions & 50 deletions src/main/java/net/minecraft/client/gui/GuiListExtended.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,52 +2,41 @@

import net.minecraft.client.Minecraft;

public abstract class GuiListExtended extends GuiSlot
{
public GuiListExtended(Minecraft mcIn, int widthIn, int heightIn, int topIn, int bottomIn, int slotHeightIn)
{
super(mcIn, widthIn, heightIn, topIn, bottomIn, slotHeightIn);
public abstract class GuiListExtended extends GuiSlot {
public GuiListExtended(Minecraft minecraft, int width, int height, int top, int bottom, int slotHeight) {
super(minecraft, width, height, top, bottom, slotHeight);
}

protected void elementClicked(int slotIndex, boolean isDoubleClick, int mouseX, int mouseY)
{
protected void elementClicked(int slotIndex, boolean isDoubleClick, int mouseX, int mouseY) {
}

protected boolean isSelected(int slotIndex)
{
protected boolean isElementSelected(int slotIndex) {
return false;
}

protected void drawBackground()
{
protected void drawBackground() {
}

protected void drawSlot(int entryID, int p_180791_2_, int p_180791_3_, int p_180791_4_, int mouseXIn, int mouseYIn)
{
this.getListEntry(entryID).drawEntry(entryID, p_180791_2_, p_180791_3_, this.getListWidth(), p_180791_4_, mouseXIn, mouseYIn, this.getSlotIndexFromScreenCoords(mouseXIn, mouseYIn) == entryID);
protected void drawSlot(int entryID, int x, int y, int slotHeight, int mouseX, int mouseY) {
getListEntry(entryID).drawEntry(entryID, x, y, getListWidth(), slotHeight, mouseX, mouseY, getSlotIndexFromScreenCoords(mouseX, mouseY) == entryID);
}

protected void func_178040_a(int p_178040_1_, int p_178040_2_, int p_178040_3_)
{
this.getListEntry(p_178040_1_).setSelected(p_178040_1_, p_178040_2_, p_178040_3_);
protected void setSelected(int index, int x, int y) {
getListEntry(index).setSelected(index, x, y);
}

public boolean mouseClicked(int mouseX, int mouseY, int mouseEvent)
{
if (this.isMouseYWithinSlotBounds(mouseY))
{
int i = this.getSlotIndexFromScreenCoords(mouseX, mouseY);

if (i >= 0)
{
int j = this.left + this.width / 2 - this.getListWidth() / 2 + 2;
int k = this.top + 4 - this.getAmountScrolled() + i * this.slotHeight + this.headerPadding;
int l = mouseX - j;
int i1 = mouseY - k;

if (this.getListEntry(i).mousePressed(i, mouseX, mouseY, mouseEvent, l, i1))
{
this.setEnabled(false);
public boolean mouseClicked(int mouseX, int mouseY, int mouseEvent) {
if (isMouseYWithinSlotBounds(mouseY)) {
int index = getSlotIndexFromScreenCoords(mouseX, mouseY);

if (index >= 0) {
int slotX = left + width / 2 - getListWidth() / 2 + 2;
int slotY = top + 4 - getAmountScrolled() + index * slotHeight + headerPadding;
int relativeX = mouseX - slotX;
int relativeY = mouseY - slotY;

if (getListEntry(index).mousePressed(index, mouseX, mouseY, mouseEvent, relativeX, relativeY)) {
setEnabled(false);
return true;
}
}
Expand All @@ -56,31 +45,28 @@ public boolean mouseClicked(int mouseX, int mouseY, int mouseEvent)
return false;
}

public boolean mouseReleased(int p_148181_1_, int p_148181_2_, int p_148181_3_)
{
for (int i = 0; i < this.getSize(); ++i)
{
int j = this.left + this.width / 2 - this.getListWidth() / 2 + 2;
int k = this.top + 4 - this.getAmountScrolled() + i * this.slotHeight + this.headerPadding;
int l = p_148181_1_ - j;
int i1 = p_148181_2_ - k;
this.getListEntry(i).mouseReleased(i, p_148181_1_, p_148181_2_, p_148181_3_, l, i1);
public boolean mouseReleased(int mouseX, int mouseY, int mouseEvent) {
for (int i = 0; i < getSize(); ++i) {
int slotX = left + width / 2 - getListWidth() / 2 + 2;
int slotY = top + 4 - getAmountScrolled() + i * slotHeight + headerPadding;
int relativeX = mouseX - slotX;
int relativeY = mouseY - slotY;
getListEntry(i).mouseReleased(i, mouseX, mouseY, mouseEvent, relativeX, relativeY);
}

this.setEnabled(true);
setEnabled(true);
return false;
}

public abstract GuiListExtended.IGuiListEntry getListEntry(int index);
public abstract IGuiListEntry getListEntry(int index);

public interface IGuiListEntry
{
void setSelected(int p_178011_1_, int p_178011_2_, int p_178011_3_);
public interface IGuiListEntry {
void setSelected(int index, int x, int y);

void drawEntry(int slotIndex, int x, int y, int listWidth, int slotHeight, int mouseX, int mouseY, boolean isSelected);

boolean mousePressed(int slotIndex, int p_148278_2_, int p_148278_3_, int p_148278_4_, int p_148278_5_, int p_148278_6_);
boolean mousePressed(int index, int mouseX, int mouseY, int mouseEvent, int relativeX, int relativeY);

void mouseReleased(int slotIndex, int x, int y, int mouseEvent, int relativeX, int relativeY);
void mouseReleased(int index, int x, int y, int mouseEvent, int relativeX, int relativeY);
}
}
}
43 changes: 18 additions & 25 deletions src/main/java/net/minecraft/client/gui/GuiResourcePackList.java
Original file line number Diff line number Diff line change
@@ -1,55 +1,48 @@
package net.minecraft.client.gui;

import java.util.List;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.resources.ResourcePackListEntry;
import net.minecraft.util.EnumChatFormatting;

public abstract class GuiResourcePackList extends GuiListExtended
{
import java.util.List;

public abstract class GuiResourcePackList extends GuiListExtended {
protected final Minecraft mc;
protected final List<ResourcePackListEntry> field_148204_l;
protected final List<ResourcePackListEntry> resourcePackList;

public GuiResourcePackList(Minecraft mcIn, int p_i45055_2_, int p_i45055_3_, List<ResourcePackListEntry> p_i45055_4_)
{
super(mcIn, p_i45055_2_, p_i45055_3_, 32, p_i45055_3_ - 55 + 4, 36);
public GuiResourcePackList(Minecraft mcIn, int width, int height, List<ResourcePackListEntry> resourcePackList) {
super(mcIn, width, height, 32, height - 55 + 4, 36);
this.mc = mcIn;
this.field_148204_l = p_i45055_4_;
this.resourcePackList = resourcePackList;
this.field_148163_i = false;
this.setHasListHeader(true, (int)((float)mcIn.fontRendererObj.FONT_HEIGHT * 1.5F));
this.setHasListHeader((int)(mcIn.fontRendererObj.FONT_HEIGHT * 1.5F));
}

protected void drawListHeader(int p_148129_1_, int p_148129_2_, Tessellator p_148129_3_)
{
String s = EnumChatFormatting.UNDERLINE + String.valueOf(EnumChatFormatting.BOLD) + this.getListHeader();
this.mc.fontRendererObj.drawString(s, p_148129_1_ + this.width / 2 - this.mc.fontRendererObj.getStringWidth(s) / 2, Math.min(this.top + 3, p_148129_2_), 16777215);
protected void drawListHeader(int x, int y, Tessellator tessellator) {
String header = EnumChatFormatting.UNDERLINE + "" + EnumChatFormatting.BOLD + getListHeader();
this.mc.fontRendererObj.drawString(header, x + this.width / 2 - this.mc.fontRendererObj.getStringWidth(header) / 2, Math.min(this.top + 3, y), 16777215);
}

protected abstract String getListHeader();

public List<ResourcePackListEntry> getList()
{
return this.field_148204_l;
public List<ResourcePackListEntry> getList() {
return this.resourcePackList;
}

protected int getSize()
{
protected int getSize() {
return this.getList().size();
}

public ResourcePackListEntry getListEntry(int index)
{
public ResourcePackListEntry getListEntry(int index) {
return this.getList().get(index);
}

public int getListWidth()
{
public int getListWidth() {
return this.width;
}

protected int getScrollBarX()
{
protected int getScrollBarX() {
return this.right - 6;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package net.minecraft.client.gui;

import com.google.common.collect.Lists;
import java.io.IOException;
import java.util.List;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.WorldRenderer;
Expand All @@ -12,6 +10,9 @@
import net.minecraft.world.gen.ChunkProviderSettings;
import org.lwjgl.input.Keyboard;

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

public class GuiScreenCustomizePresets extends GuiScreen
{
private static final List<GuiScreenCustomizePresets.Info> field_175310_f = Lists.<GuiScreenCustomizePresets.Info>newArrayList();
Expand Down Expand Up @@ -170,7 +171,7 @@ protected void elementClicked(int slotIndex, boolean isDoubleClick, int mouseX,
GuiScreenCustomizePresets.this.field_175317_i.setText(((GuiScreenCustomizePresets.Info)GuiScreenCustomizePresets.field_175310_f.get(GuiScreenCustomizePresets.this.field_175311_g.field_178053_u)).field_178954_c.toString());
}

protected boolean isSelected(int slotIndex)
protected boolean isElementSelected(int slotIndex)
{
return slotIndex == this.field_178053_u;
}
Expand Down
13 changes: 7 additions & 6 deletions src/main/java/net/minecraft/client/gui/GuiSelectWorld.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
package net.minecraft.client.gui;

import java.io.IOException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Collections;
import java.util.Date;
import net.minecraft.client.AnvilConverterException;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.LocalizationHelper;
Expand All @@ -18,6 +13,12 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.io.IOException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Collections;
import java.util.Date;

public class GuiSelectWorld extends GuiScreen implements GuiYesNoCallback
{
private static final Logger logger = LogManager.getLogger();
Expand Down Expand Up @@ -258,7 +259,7 @@ protected void elementClicked(int slotIndex, boolean isDoubleClick, int mouseX,
}
}

protected boolean isSelected(int slotIndex)
protected boolean isElementSelected(int slotIndex)
{
return slotIndex == GuiSelectWorld.this.selectedIndex;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ protected void elementClicked(int slotIndex, boolean isDoubleClick, int mouseX,
* @return
*/
@Override
protected boolean isSelected(int slotIndex) {
protected boolean isElementSelected(int slotIndex) {
return false;
}

Expand Down Expand Up @@ -109,8 +109,8 @@ public void drawScreen(int mouseXIn, int mouseYIn, float p_148128_3_)
this.drawSelectionBox(k, l, mouseXIn, mouseYIn);
GlStateManager.disableDepth();
int i1 = 4;
this.overlayBackground(0, this.top, 255, 255);
this.overlayBackground(this.bottom, this.height, 255, 255);
this.overlayBackground(0, this.top);
this.overlayBackground(this.bottom, this.height);
GlStateManager.enableBlend();
GlStateManager.tryBlendFuncSeparate(770, 771, 0, 1);
GlStateManager.disableAlpha();
Expand Down
Loading

0 comments on commit 1d4dc2d

Please sign in to comment.