mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-18 13:49:05 +00:00
Full Refactor and Now it looks better 💯
This commit is contained in:
1 parent
98e886703c
commit
e15e72d478
15 files changed
+1073
-1887
No files matched your search
@@ -17,6 +17,7 @@ import net.minecraft.util.Util;
|
||||
import noppes.npcs.CustomNpcs;
|
||||
import noppes.npcs.client.gui.player.GuiDialogInteract;
|
||||
import noppes.npcs.client.gui.player.GuiQuestCompletion;
|
||||
import noppes.npcs.client.gui.util.IPlayerDataInfo;
|
||||
import noppes.npcs.client.gui.util.GuiContainerNPCInterface;
|
||||
import noppes.npcs.client.gui.util.GuiNPCInterface;
|
||||
import noppes.npcs.client.gui.util.IScrollData;
|
||||
@@ -32,6 +33,7 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Vector;
|
||||
|
||||
public class NoppesUtil {
|
||||
@@ -258,4 +260,60 @@ public class NoppesUtil {
|
||||
public static void isGUIOpen(boolean isGUIOpen) {
|
||||
PacketClient.sendClient(new IsGuiOpenInform(isGUIOpen));
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the incoming large packet with full player data.
|
||||
* The packet writes:
|
||||
* - player name (String)
|
||||
* - questCategories, questActive, questFinished (maps)
|
||||
* - dialogCategories, dialogRead (maps)
|
||||
* - transportCategories, transportLocations (maps)
|
||||
* - bankData, factionData (maps)
|
||||
*
|
||||
* The existing PlayerDataController functions are used on the server side;
|
||||
* here we simply update the active SubGuiPlayerDataNew if present.
|
||||
*/
|
||||
public static void handlePlayerData(ByteBuf data, EntityPlayer player) throws IOException {
|
||||
String playerName = ByteBufUtils.readString(data);
|
||||
Map<String, Integer> questCategories = readMap(data);
|
||||
Map<String, Integer> questActive = readMap(data);
|
||||
Map<String, Integer> questFinished = readMap(data);
|
||||
Map<String, Integer> dialogCategories = readMap(data);
|
||||
Map<String, Integer> dialogRead = readMap(data);
|
||||
Map<String, Integer> transportCategories = readMap(data);
|
||||
Map<String, Integer> transportLocations = readMap(data);
|
||||
Map<String, Integer> bankData = readMap(data);
|
||||
Map<String, Integer> factionData = readMap(data);
|
||||
|
||||
|
||||
GuiScreen gui = Minecraft.getMinecraft().currentScreen;
|
||||
if(gui == null)
|
||||
return;
|
||||
if(gui instanceof GuiNPCInterface && ((GuiNPCInterface)gui).hasSubGui()){
|
||||
gui = (GuiScreen) ((GuiNPCInterface)gui).getSubGui();
|
||||
}
|
||||
|
||||
if(gui instanceof GuiContainerNPCInterface && ((GuiContainerNPCInterface)gui).hasSubGui()){
|
||||
gui = (GuiScreen) ((GuiContainerNPCInterface)gui).getSubGui();
|
||||
}
|
||||
if (gui instanceof IPlayerDataInfo) {
|
||||
IPlayerDataInfo info = (IPlayerDataInfo) gui;
|
||||
info.setQuestData(questCategories, questActive, questFinished);
|
||||
info.setDialogData(dialogCategories, dialogRead);
|
||||
info.setTransportData(transportCategories, transportLocations);
|
||||
info.setBankData(bankData);
|
||||
info.setFactionData(factionData);
|
||||
}
|
||||
}
|
||||
|
||||
private static Map<String, Integer> readMap(ByteBuf data) {
|
||||
int size = data.readInt();
|
||||
Map<String, Integer> map = new HashMap<>();
|
||||
for (int i = 0; i < size; i++) {
|
||||
String key = ByteBufUtils.readString(data);
|
||||
int value = data.readInt();
|
||||
map.put(key, value);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user