Inventory Tab Fixes

- Super Class now Registers Inventory Tabs
- Side Button Actions now moved to Super Class
- First Pass for Registering Top Tab Values (no offset error)
- Minecraft.getMinecraft() moved to the top level
This commit is contained in:
Kam committed 2024-03-14 15:12:43 -04:00
1 parent e39855ddd3
commit 9d73db3076
7 files changed
+33 -66

No files matched your search

@@ -94,10 +94,10 @@ public class ClientTickHandler{
if(mc.currentScreen == null){
switch (GuiCNPCInventory.activeTab){
case 0:
NoppesUtil.openGUI(mc.thePlayer, new GuiQuestLog(mc.thePlayer));
NoppesUtil.openGUI(mc.thePlayer, new GuiQuestLog());
break;
case 1:
NoppesUtil.openGUI(mc.thePlayer, new GuiParty(mc.thePlayer));
NoppesUtil.openGUI(mc.thePlayer, new GuiParty());
break;
case 2:
NoppesUtil.openGUI(mc.thePlayer, new GuiFaction());
@@ -17,7 +17,8 @@ public class GuiCNPCInventory extends GuiNPCInterface {
public static final ResourceLocation specialIcons = new ResourceLocation("customnpcs","textures/gui/icons.png");
public static int activeTab = 0;
private Minecraft mc = Minecraft.getMinecraft();
protected Minecraft mc = Minecraft.getMinecraft();
protected boolean firstPass = true;
public GuiCNPCInventory() {
super();
@@ -30,6 +31,13 @@ public class GuiCNPCInventory extends GuiNPCInterface {
super.initGui();
guiTop +=10;
if(firstPass){
TabRegistry.updateTabValues(guiLeft, guiTop, InventoryTabCustomNpc.class);
firstPass = false;
}
TabRegistry.addTabsToList(buttonList);
int y = 3;
GuiMenuSideButton questsButton = new GuiMenuSideButton(100, guiLeft + xSize + 37, this.guiTop + y, 22, 22, "");
questsButton.rightSided = true;
@@ -69,11 +77,11 @@ public class GuiCNPCInventory extends GuiNPCInterface {
if (guibutton.id >= 100) {
if (guibutton.id == 100 && activeTab != 0) {
activeTab = 0;
mc.displayGuiScreen(new GuiQuestLog(mc.thePlayer));
mc.displayGuiScreen(new GuiQuestLog());
}
if (guibutton.id == 101 && activeTab != 1) {
activeTab = 1;
mc.displayGuiScreen(new GuiParty(mc.thePlayer));
mc.displayGuiScreen(new GuiParty());
}
if (guibutton.id == 102 && activeTab != 2) {
activeTab = 2;
@@ -9,22 +9,20 @@ import net.minecraft.util.StatCollector;
import noppes.npcs.NoppesUtilPlayer;
import noppes.npcs.client.CustomNpcResourceListener;
import noppes.npcs.client.gui.util.GuiButtonNextPage;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.IGuiData;
import noppes.npcs.constants.EnumPlayerPacket;
import noppes.npcs.controllers.data.Faction;
import noppes.npcs.controllers.data.PlayerFactionData;
import org.lwjgl.opengl.GL11;
import tconstruct.client.tabs.InventoryTabCustomNpc;
import tconstruct.client.tabs.TabRegistry;
import java.util.ArrayList;
public class GuiFaction extends GuiCNPCInventory implements IGuiData{
public class GuiFaction extends GuiCNPCInventory implements IGuiData {
private final ResourceLocation resource = new ResourceLocation("customnpcs","textures/gui/standardbg.png");
private ArrayList<Faction> playerFactions = new ArrayList<Faction>();
private Minecraft mc = Minecraft.getMinecraft();
private int page = 0;
private int pages = 1;
@@ -45,8 +43,6 @@ public class GuiFaction extends GuiCNPCInventory implements IGuiData{
public void initGui()
{
super.initGui();
TabRegistry.addTabsToList(buttonList);
TabRegistry.updateTabValues(guiLeft, guiTop, InventoryTabCustomNpc.class);
this.buttonList.add(buttonNextPage = new GuiButtonNextPage(1, (guiLeft + (xSize + 35) / 2) + 25, guiTop + 170, true));
this.buttonList.add(buttonPreviousPage = new GuiButtonNextPage(2, (guiLeft + (xSize + 35) / 2) - 40, guiTop + 170, false));
@@ -133,7 +129,7 @@ public class GuiFaction extends GuiCNPCInventory implements IGuiData{
@Override
protected void actionPerformed(GuiButton guibutton){
if (guibutton.id >= 100) {
if (guibutton.id >= 100 && guibutton.id <= 105) {
super.actionPerformed(guibutton);
return;
}
@@ -18,15 +18,12 @@ import noppes.npcs.constants.EnumPacketServer;
import noppes.npcs.controllers.data.Party;
import noppes.npcs.controllers.data.Quest;
import org.lwjgl.opengl.GL11;
import tconstruct.client.tabs.InventoryTabCustomNpc;
import tconstruct.client.tabs.TabRegistry;
import java.util.*;
public class GuiParty extends GuiCNPCInventory implements ITextfieldListener, ITopButtonListener,ICustomScrollListener, IPartyData, GuiYesNoCallback {
public class GuiParty extends GuiCNPCInventory implements ITextfieldListener,ICustomScrollListener, IPartyData, GuiYesNoCallback {
private final ResourceLocation resource = new ResourceLocation("customnpcs","textures/gui/standardbg.png");
private final EntityPlayer player;
private final Minecraft mc = Minecraft.getMinecraft();
private boolean receivedData;
private long renderTicks;
@@ -43,9 +40,9 @@ public class GuiParty extends GuiCNPCInventory implements ITextfieldListener, IT
private final Vector<String> questLogStatus = new Vector<>();
private String questCompleteWith;
public GuiParty(EntityPlayer player) {
public GuiParty() {
super();
this.player = player;
this.player = mc.thePlayer;
xSize = 280;
ySize = 180;
drawDefaultBackground = false;
@@ -54,8 +51,6 @@ public class GuiParty extends GuiCNPCInventory implements ITextfieldListener, IT
public void initGui(){
super.initGui();
TabRegistry.addTabsToList(buttonList);
TabRegistry.updateTabValues(guiLeft, guiTop, InventoryTabCustomNpc.class);
this.selectedInvite = this.selectedPlayer = null;
Party party = ClientCacheHandler.party;
@@ -215,11 +210,11 @@ public class GuiParty extends GuiCNPCInventory implements ITextfieldListener, IT
@Override
protected void actionPerformed(GuiButton guibutton){
if (guibutton.id >= 100) {
Party party = ClientCacheHandler.party;
if (guibutton.id >= 100 && guibutton.id <= 105) {
super.actionPerformed(guibutton);
return;
}
Party party = ClientCacheHandler.party;
switch (guibutton.id) {
case 200:
@@ -366,12 +361,6 @@ public class GuiParty extends GuiCNPCInventory implements ITextfieldListener, IT
}
}
@Override
public boolean doesGuiPauseGame()
{
return false;
}
@Override
public void setPartyData(NBTTagCompound compound) {
this.receivedData = true;
@@ -18,12 +18,10 @@ import noppes.npcs.constants.EnumPlayerPacket;
import noppes.npcs.controllers.data.Party;
import noppes.npcs.util.ValueUtil;
import org.lwjgl.opengl.GL11;
import tconstruct.client.tabs.InventoryTabCustomNpc;
import tconstruct.client.tabs.TabRegistry;
import java.util.*;
public class GuiQuestLog extends GuiCNPCInventory implements ITopButtonListener,ICustomScrollListener, IGuiData, IPartyData, GuiYesNoCallback {
public class GuiQuestLog extends GuiCNPCInventory implements ICustomScrollListener, IGuiData, IPartyData, GuiYesNoCallback {
private final ResourceLocation resource = new ResourceLocation("customnpcs","textures/gui/standardbg.png");
@@ -39,26 +37,21 @@ public class GuiQuestLog extends GuiCNPCInventory implements ITopButtonListener,
private HashMap<String,String> questAlertsOnOpen;
private String trackedQuestKeyOnOpen;
private Minecraft mc = Minecraft.getMinecraft();
private float sideButtonScroll = 0;
private float destSideButtonScroll = 0;
public GuiQuestLog(EntityPlayer player) {
public GuiQuestLog() {
super();
this.player = player;
this.player = mc.thePlayer;
xSize = 280;
ySize = 180;
NoppesUtilPlayer.sendData(EnumPlayerPacket.QuestLog);
drawDefaultBackground = false;
}
NoppesUtilPlayer.sendData(EnumPlayerPacket.QuestLog);
}
public void initGui(){
super.initGui();
sideButtons.clear();
TabRegistry.addTabsToList(buttonList);
TabRegistry.updateTabValues(guiLeft, guiTop, InventoryTabCustomNpc.class);
noQuests = false;
if(data.categories.isEmpty()){
@@ -164,14 +157,14 @@ public class GuiQuestLog extends GuiCNPCInventory implements ITopButtonListener,
@Override
protected void actionPerformed(GuiButton guibutton){
if(lastClicked > System.currentTimeMillis() - 10){
return;
}
if (guibutton.id >= 100) {
if (guibutton.id >= 100 && guibutton.id <= 105) {
super.actionPerformed(guibutton);
return;
}
if(lastClicked > System.currentTimeMillis() - 10){
return;
}
if (guibutton.id == 3)
{
if (Objects.equals(ClientCacheHandler.party.getCurrentQuestName(), data.selectedQuest)) {
@@ -2,28 +2,14 @@ package noppes.npcs.client.gui.player.inventory;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import noppes.npcs.NoppesUtilPlayer;
import noppes.npcs.client.CustomNpcResourceListener;
import noppes.npcs.client.gui.util.*;
import noppes.npcs.config.ConfigClient;
import noppes.npcs.constants.EnumPlayerPacket;
import noppes.npcs.controllers.data.Faction;
import noppes.npcs.controllers.data.PlayerFactionData;
import org.lwjgl.opengl.GL11;
import tconstruct.client.tabs.InventoryTabCustomNpc;
import tconstruct.client.tabs.TabRegistry;
import java.util.ArrayList;
public class GuiSettings extends GuiCNPCInventory implements ITextfieldListener {
private final ResourceLocation resource = new ResourceLocation("customnpcs","textures/gui/standardbg.png");
private Minecraft mc = Minecraft.getMinecraft();
public GuiSettings() {
super();
@@ -37,8 +23,6 @@ public class GuiSettings extends GuiCNPCInventory implements ITextfieldListener
public void initGui()
{
super.initGui();
TabRegistry.addTabsToList(buttonList);
TabRegistry.updateTabValues(guiLeft, guiTop, InventoryTabCustomNpc.class);
int y = 0;
this.addLabel(new GuiNpcLabel(1, "Chat Bubbles", guiLeft + 8, guiTop + 14 + y));
@@ -88,7 +72,7 @@ public class GuiSettings extends GuiCNPCInventory implements ITextfieldListener
@Override
protected void actionPerformed(GuiButton btn){
if (btn.id >= 100) {
if (btn.id >= 100 && btn.id <= 105) {
super.actionPerformed(btn);
return;
}
@@ -27,15 +27,12 @@ public class InventoryTabCustomNpc extends AbstractTab {
e.printStackTrace();
}
Minecraft mc = Minecraft.getMinecraft();
if(mc.currentScreen instanceof GuiCNPCInventory)
return;
switch (GuiCNPCInventory.activeTab){
case 0:
mc.displayGuiScreen(new GuiQuestLog(mc.thePlayer));
mc.displayGuiScreen(new GuiQuestLog());
break;
case 1:
mc.displayGuiScreen(new GuiParty(mc.thePlayer));
mc.displayGuiScreen(new GuiParty());
break;
case 2:
mc.displayGuiScreen(new GuiFaction());