Separate GUI Data from PartyData so that overwrites don't consistently occur to GUI Page

This commit is contained in:
Kam committed 2024-03-01 20:56:24 -05:00
1 parent 32dc6e86e2
commit 1cbd306c50
6 files changed
+30 -9

No files matched your search

@@ -127,7 +127,7 @@ public class PacketHandlerServer{
NBTTagCompound compound = new NBTTagCompound();
compound.setBoolean("Disband", true);
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
Server.sendData(player, EnumPacketClient.PARTY_DATA, compound);
} else if (type == EnumPacketServer.KickPlayer) {
EntityPlayer kickPlayer = NoppesUtilServer.getPlayerByName(Server.readString(buffer));
if (kickPlayer != null) {
@@ -171,7 +171,6 @@ public class PacketHandlerServer{
if (!party.getIsLocked()) {
party.setLeader(NoppesUtilServer.getPlayerByName(Server.readString(buffer)));
PartyController.Instance().pingPartyUpdate(party);
// Server.sendData(player, EnumPacketClient.GUI_DATA, party.writeToNBT());
}
}
} else if (type == EnumPacketServer.PartyInvite) {
@@ -220,7 +219,7 @@ public class PacketHandlerServer{
break;
}
}
Server.sendData(player, EnumPacketClient.GUI_DATA, party.writeToNBT());
Server.sendData(player, EnumPacketClient.PARTY_DATA, party.writeToNBT());
}
}
@@ -288,7 +287,7 @@ public class PacketHandlerServer{
compound.setString("QuestCompleteWith", quest.completerNpc);
}
}
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
Server.sendData(player, EnumPacketClient.PARTY_DATA, compound);
} else {
sendInviteData(player);
}
@@ -308,7 +307,7 @@ public class PacketHandlerServer{
list.appendTag(partyCompound);
}
compound.setTag("PartyInvites", list);
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
Server.sendData(player, EnumPacketClient.PARTY_DATA, compound);
}
}
@@ -400,5 +400,19 @@ public class PacketHandlerClient extends PacketHandlerServer{
ItemStack stack = ItemStack.loadItemStackFromNBT(Server.readNBT(buffer));
npc.inventory.weapons.put(weaponSlotIndex,stack);
}
else if(type == EnumPacketClient.PARTY_DATA){
GuiScreen gui = Minecraft.getMinecraft().currentScreen;
if(gui == null)
return;
if(gui instanceof GuiNPCInterface && ((GuiNPCInterface)gui).hasSubGui()){
gui = (GuiScreen) ((GuiNPCInterface)gui).getSubGui();
}
else if(gui instanceof GuiContainerNPCInterface && ((GuiContainerNPCInterface)gui).hasSubGui()){
gui = (GuiScreen) ((GuiContainerNPCInterface)gui).getSubGui();
}
if(gui instanceof IPartyData)
((IPartyData)gui).setPartyData(Server.readNBT(buffer));
}
}
}
@@ -23,7 +23,7 @@ import tconstruct.client.tabs.TabRegistry;
import java.util.*;
public class GuiParty extends GuiCNPCInventory implements ITextfieldListener, ITopButtonListener,ICustomScrollListener, IGuiData, GuiYesNoCallback {
public class GuiParty extends GuiCNPCInventory implements ITextfieldListener, ITopButtonListener,ICustomScrollListener, IPartyData, GuiYesNoCallback {
private final ResourceLocation resource = new ResourceLocation("customnpcs","textures/gui/standardbg.png");
private final EntityPlayer player;
private final Minecraft mc = Minecraft.getMinecraft();
@@ -370,7 +370,7 @@ public class GuiParty extends GuiCNPCInventory implements ITextfieldListener, IT
}
@Override
public void setGuiData(NBTTagCompound compound) {
public void setPartyData(NBTTagCompound compound) {
this.receivedData = true;
ClientCacheHandler.party = null;
@@ -0,0 +1,7 @@
package noppes.npcs.client.gui.util;
import net.minecraft.nbt.NBTTagCompound;
public interface IPartyData {
public void setPartyData(NBTTagCompound compound);
}
@@ -54,5 +54,6 @@ public enum EnumPacketClient {
CONTINUE_SOUNDS,
STOP_SOUNDS,
SYNC_WEAPON,
MARK_DATA
MARK_DATA,
PARTY_DATA
}
@@ -121,7 +121,7 @@ public class PartyController {
compound.setString("QuestCompleteWith", quest.completerNpc);
}
}
Server.sendData((EntityPlayerMP) playerMP, EnumPacketClient.GUI_DATA, compound);
Server.sendData((EntityPlayerMP) playerMP, EnumPacketClient.PARTY_DATA, compound);
}
}
}