Made GuiNpcButtons with multiple displays i.e ("Hair","Eyes","Fur")

right clickable to select in reverse
This commit is contained in:
bigguy345 committed 2025-12-09 17:46:07 +02:00
1 parent ddee62f2ce
commit 93e6a92b59
5 files changed
+91 -3

No files matched your search

@@ -5,6 +5,8 @@ import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.GuiYesNoCallback;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.event.GuiScreenEvent;
import net.minecraftforge.common.MinecraftForge;
import noppes.npcs.entity.EntityNPCInterface;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
@@ -12,6 +14,7 @@ import org.lwjgl.opengl.GL11;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.concurrent.atomic.AtomicBoolean;
public class GuiScrollWindow extends GuiScreen implements ITextfieldListener, ICustomScrollListener, GuiYesNoCallback {
public static final ResourceLocation resource = new ResourceLocation("customnpcs", "textures/gui/misc.png");
@@ -107,9 +110,39 @@ public class GuiScrollWindow extends GuiScreen implements ITextfieldListener, IC
}
}
mouseEvent(i, j, k);
super.mouseClicked(i, j, k);
vanillaMouseClicked(i, j, k);
}
protected void vanillaMouseClicked(int mouseX, int mouseY, int mouseButton) {
if (mouseButton == 0 || mouseButton == 1) {
for (int l = 0; l < this.buttonList.size(); ++l) {
GuiButton guibutton = (GuiButton) this.buttonList.get(l);
AtomicBoolean rightClicked = null;
if (mouseButton == 1) {
if (guibutton instanceof GuiNpcButton && ((GuiNpcButton) guibutton).rightClickable) {
rightClicked = ((GuiNpcButton) guibutton).rightClicked;
rightClicked.set(true);
} else
continue;
}
if (guibutton.mousePressed(this.mc, mouseX, mouseY)) {
GuiScreenEvent.ActionPerformedEvent.Pre event = new GuiScreenEvent.ActionPerformedEvent.Pre(this, guibutton, this.buttonList);
if (MinecraftForge.EVENT_BUS.post(event))
break;
this.selectedButton = event.button;
event.button.func_146113_a(this.mc.getSoundHandler());
this.actionPerformed(event.button);
if (this.equals(this.mc.currentScreen))
MinecraftForge.EVENT_BUS.post(new GuiScreenEvent.ActionPerformedEvent.Post(this, event.button, this.buttonList));
}
if (rightClicked != null)
rightClicked.set(false);
}
}
}
public void mouseEvent(int i, int j, int k) {
}