Merge Dev into PR 110

This commit is contained in:
Kam committed 2024-01-18 14:45:08 -05:00
commit 3e43855128
39 files changed
+1149 -355

No files matched your search

@@ -1,11 +1,13 @@
package noppes.npcs.client;
import net.minecraft.util.ResourceLocation;
import noppes.npcs.controllers.data.Animation;
import noppes.npcs.controllers.data.AnimationData;
import noppes.npcs.client.gui.OverlayQuestTracking;
import noppes.npcs.client.gui.customoverlay.OverlayCustom;
import noppes.npcs.client.renderer.ImageData;
import noppes.npcs.config.ConfigClient;
import noppes.npcs.controllers.data.Party;
import noppes.npcs.controllers.data.SkinOverlay;
import noppes.npcs.util.CacheHashMap;
@@ -14,11 +16,15 @@ import java.util.UUID;
public class ClientCacheHandler {
private static final CacheHashMap<String, CacheHashMap.CachedObject<ImageData>> imageDataCache = new CacheHashMap<>((long) ConfigClient.CacheLife * 60 * 1000);
public static final HashMap<Integer, Animation> animationCache = new HashMap<>();
public static OverlayQuestTracking questTrackingOverlay = null;
public static HashMap<Integer, OverlayCustom> customOverlays = new HashMap<>();
public static HashMap<UUID, HashMap<Integer, SkinOverlay>> skinOverlays = new HashMap<>();
public static HashMap<UUID, AnimationData> playerAnimations = new HashMap<>();
public static Party party;
public static ImageData getImageData(String directory) {
synchronized (imageDataCache) {
if (!imageDataCache.containsKey(directory)) {
@@ -39,9 +45,11 @@ public class ClientCacheHandler {
public static void clearCache() {
ClientCacheHandler.imageDataCache.clear();
ClientCacheHandler.animationCache.clear();
ClientCacheHandler.questTrackingOverlay = null;
ClientCacheHandler.customOverlays.clear();
ClientCacheHandler.skinOverlays.clear();
ClientCacheHandler.playerAnimations.clear();
party = null;
}
}
@@ -108,7 +108,7 @@ public class ClientEventHandler {
ClientEventHandler.playerModel = null;
}
if (data != null && data.isActive()) {
if (data != null && data.isActive() && !Minecraft.getMinecraft().isGamePaused()) {
Animation animation = data.animation;
if (data.isActive() && animation.currentFrame().useRenderTicks()) {
animation.increaseTime();
@@ -62,8 +62,7 @@ import noppes.npcs.entity.data.ModelData;
import noppes.npcs.entity.data.ModelPartData;
import noppes.npcs.items.ItemScripted;
import org.lwjgl.input.Keyboard;
import tconstruct.client.tabs.InventoryTabFactions;
import tconstruct.client.tabs.InventoryTabQuests;
import tconstruct.client.tabs.InventoryTabCustomNpc;
import tconstruct.client.tabs.InventoryTabVanilla;
import tconstruct.client.tabs.TabRegistry;
@@ -152,8 +151,7 @@ public class ClientProxy extends CommonProxy {
if (TabRegistry.getTabList().size() < 2){
TabRegistry.registerTab(new InventoryTabVanilla());
}
TabRegistry.registerTab(new InventoryTabFactions());
TabRegistry.registerTab(new InventoryTabQuests());
TabRegistry.registerTab(new InventoryTabCustomNpc());
}
}
@@ -3,18 +3,16 @@ package noppes.npcs.client;
import cpw.mods.fml.common.eventhandler.EventPriority;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.InputEvent;
import cpw.mods.fml.common.gameevent.PlayerEvent;
import cpw.mods.fml.common.gameevent.TickEvent;
import cpw.mods.fml.common.gameevent.TickEvent.Phase;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ContainerPlayer;
import net.minecraft.world.World;
import noppes.npcs.CustomNpcs;
import noppes.npcs.NoppesUtilPlayer;
import noppes.npcs.client.controllers.MusicController;
import noppes.npcs.client.controllers.ScriptSoundController;
import noppes.npcs.client.gui.player.GuiQuestLog;
import noppes.npcs.client.gui.player.inventory.GuiQuestLog;
import noppes.npcs.client.renderer.RenderNPCInterface;
import noppes.npcs.constants.EnumPlayerPacket;
import org.lwjgl.input.Keyboard;
@@ -28,17 +28,18 @@ import noppes.npcs.client.gui.customoverlay.OverlayCustom;
import noppes.npcs.client.gui.player.GuiBook;
import noppes.npcs.client.gui.util.*;
import noppes.npcs.config.ConfigClient;
import noppes.npcs.constants.EnumAnimationPart;
import noppes.npcs.constants.EnumGuiType;
import noppes.npcs.constants.EnumPacketClient;
import noppes.npcs.constants.EnumPacketServer;
import noppes.npcs.controllers.RecipeController;
import noppes.npcs.controllers.data.Animation;
import noppes.npcs.controllers.data.AnimationData;
import noppes.npcs.controllers.data.RecipeCarpentry;
import noppes.npcs.controllers.data.*;
import noppes.npcs.entity.EntityDialogNpc;
import noppes.npcs.entity.EntityNPCInterface;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
public class PacketHandlerClient extends PacketHandlerServer{
@@ -299,22 +300,56 @@ public class PacketHandlerClient extends PacketHandlerServer{
}
else if(type == EnumPacketClient.UPDATE_ANIMATIONS) {
NBTTagCompound compound = Server.readNBT(buffer);
AnimationData animationData = null;
if (compound.hasKey("EntityId")) {
Entity entity = Minecraft.getMinecraft().theWorld.getEntityByID(compound.getInteger("EntityId"));
if (entity instanceof EntityNPCInterface) {
AnimationData data = ((EntityNPCInterface) entity).display.animationData;
data.readFromNBT(compound);
data.animation = new Animation();
data.animation.readFromNBT(compound.getCompoundTag("Animation"));
animationData = ((EntityNPCInterface) entity).display.animationData;
}
} else {
EntityPlayer sendingPlayer = Minecraft.getMinecraft().theWorld.getPlayerEntityByName(Server.readString(buffer));
if (sendingPlayer != null) {
AnimationData data = new AnimationData(sendingPlayer);
data.readFromNBT(compound);
data.animation = new Animation();
data.animation.readFromNBT(compound.getCompoundTag("Animation"));
ClientCacheHandler.playerAnimations.put(sendingPlayer.getUniqueID(), data);
if (!ClientCacheHandler.playerAnimations.containsKey(sendingPlayer.getUniqueID())) {
ClientCacheHandler.playerAnimations.put(sendingPlayer.getUniqueID(), new AnimationData(sendingPlayer));
}
animationData = ClientCacheHandler.playerAnimations.get(sendingPlayer.getUniqueID());
}
}
if (animationData != null) {
animationData.readFromNBT(compound);
int animationId;
if (compound.hasKey("AnimationID")) {
animationId = compound.getInteger("AnimationID");
} else {
Animation animation = new Animation();
animation.readFromNBT(compound.getCompoundTag("Animation"));
ClientCacheHandler.animationCache.put(animation.getID(), animation);
animationId = animation.getID();
}
if (animationData.allowAnimation) {
Animation animation = new Animation();
animation.readFromNBT(ClientCacheHandler.animationCache.get(animationId).writeToNBT());
if (animationData.animation != null && animation.frames.size() > 0) {
Frame frame = (Frame) animationData.animation.currentFrame();
if (frame != null) {
Frame firstFrame = animation.frames.get(0);
for (Map.Entry<EnumAnimationPart, FramePart> entry : frame.frameParts.entrySet()) {
if (firstFrame.frameParts.containsKey(entry.getKey())) {
FramePart prevFramePart = entry.getValue();
FramePart newFramePart = firstFrame.frameParts.get(entry.getKey());
for (int i = 0; i < 3; i++) {
newFramePart.prevPivots[i] = prevFramePart.prevPivots[i];
newFramePart.prevRotations[i] = prevFramePart.prevRotations[i];
}
}
}
}
}
animationData.animation = animation;
animation.parent = animationData;
Client.sendData(EnumPacketServer.CacheAnimation, animationId);
}
}
}
@@ -46,36 +46,43 @@ public class GuiNpcManageRecipes extends GuiContainerNPCInterface2 implements IS
scroll.guiLeft = guiLeft + 172;
scroll.guiTop = guiTop + 8;
addScroll(scroll);
addTextField(new GuiNpcTextField(55, this, fontRendererObj, guiLeft + 172, guiTop + 8 + 3 + 180, 130, 20, search));
this.addButton(new GuiNpcButton(0,guiLeft + 306, guiTop + 10, 94, 30, "menu.global"));
this.addButton(new GuiNpcButton(1,guiLeft + 306, guiTop + 32, 94, 20, "tile.npcCarpentyBench.name"));
this.getButton(0).setEnabled(container.width == 4);
this.getButton(1).setEnabled(container.width == 3);
this.addButton(new GuiNpcButton(3,guiLeft + 306, guiTop + 60, 94, 20, "gui.add"));
this.addButton(new GuiNpcButton(4,guiLeft + 306, guiTop + 82, 94, 20, "gui.remove"));
this.addButton(new GuiNpcButton(0,guiLeft + 306, guiTop + 10, 84, 20, "menu.global"));
this.addButton(new GuiNpcButton(1,guiLeft + 306, guiTop + 32, 84, 20, "tile.npcCarpentyBench.name"));
this.getButton(0).setEnabled(container.width == 4);
this.getButton(1).setEnabled(container.width == 3);
this.addButton(new GuiNpcButton(3,guiLeft + 306, guiTop + 60, 84, 20, "gui.add"));
this.addButton(new GuiNpcButton(4,guiLeft + 306, guiTop + 82, 84, 20, "gui.remove"));
this.addLabel(new GuiNpcLabel(0, "gui.ignoreDamage", guiLeft + 86, guiTop + 32));
this.addButton(new GuiNpcButtonYesNo(5,guiLeft + 114, guiTop + 40, 50, 20, container.recipe.ignoreDamage));
this.addLabel(new GuiNpcLabel(1, "gui.ignoreNBT", guiLeft + 86, guiTop + 82));
this.addButton(new GuiNpcButtonYesNo(6,guiLeft + 114, guiTop + 90, 50, 20, container.recipe.ignoreNBT));
this.addTextField(new GuiNpcTextField(0, this, fontRendererObj, guiLeft + 8, guiTop + 8, 160, 20, container.recipe.name));
this.getTextField(0).enabled = false;
this.getButton(5).setEnabled(false);
this.getButton(6).setEnabled(false);
}
this.addTextField(new GuiNpcTextField(0, this, fontRendererObj, guiLeft + 8, guiTop + 8, 160, 20, container.recipe.name));
this.getTextField(0).enabled = false;
this.getButton(5).setEnabled(false);
this.getButton(6).setEnabled(false);
this.addTextField(new GuiNpcTextField(55, this, fontRendererObj, guiLeft + 172, guiTop + 8 + 3 + 180, 130, 20, search));
}
@Override
protected void actionPerformed(GuiButton guibutton){
GuiNpcButton button = (GuiNpcButton) guibutton;
if(button.id == 0){
getTextField(55).setText("");
search = "";
scroll.clear();
save();
NoppesUtil.requestOpenGUI(EnumGuiType.ManageRecipes,3,0,0);
}
if(button.id == 1){
getTextField(55).setText("");
search = "";
scroll.clear();
save();
NoppesUtil.requestOpenGUI(EnumGuiType.ManageRecipes,4,0,0);
}
@@ -192,14 +199,16 @@ public class GuiNpcManageRecipes extends GuiContainerNPCInterface2 implements IS
@Override
public void unFocused(GuiNpcTextField guiNpcTextField) {
String name = guiNpcTextField.getText();
if(!name.isEmpty() && !data.containsKey(name)){
String old = container.recipe.name;
data.remove(container.recipe.name);
container.recipe.name = name;
data.put(container.recipe.name, container.recipe.id);
selected = name;
scroll.replace(old,container.recipe.name);
if(guiNpcTextField.id == 0){
String name = guiNpcTextField.getText();
if(!name.isEmpty() && !data.containsKey(name)){
String old = container.recipe.name;
data.remove(container.recipe.name);
container.recipe.name = name;
data.put(container.recipe.name, container.recipe.id);
selected = name;
scroll.replace(old,container.recipe.name);
}
}
}
}
@@ -1,186 +0,0 @@
package noppes.npcs.client.gui.player;
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.GuiButtonNextPage;
import noppes.npcs.client.gui.util.GuiNPCInterface;
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.InventoryTabFactions;
import tconstruct.client.tabs.TabRegistry;
import java.util.ArrayList;
public class GuiFaction extends GuiNPCInterface implements IGuiData{
private int xSize;
private int ySize;
private int guiLeft;
private int guiTop;
private ArrayList<Faction> playerFactions = new ArrayList<Faction>();
private int page = 0;
private int pages = 1;
private GuiButtonNextPage buttonNextPage;
private GuiButtonNextPage buttonPreviousPage;
private ResourceLocation indicator;
public GuiFaction() {
super();
xSize = 200;
ySize = 195;
this.drawDefaultBackground = false;
title = "";
NoppesUtilPlayer.sendData(EnumPlayerPacket.FactionsGet);
indicator = getResource("standardbg.png");
}
@Override
public void initGui()
{
super.initGui();
guiLeft = (width - xSize) / 2;
guiTop = (height - ySize) / 2 + 12;
TabRegistry.updateTabValues(guiLeft, guiTop + 8, InventoryTabFactions.class);
TabRegistry.addTabsToList(buttonList);
this.buttonList.add(buttonNextPage = new GuiButtonNextPage(1, guiLeft + xSize - 43, guiTop + 180, true));
this.buttonList.add(buttonPreviousPage = new GuiButtonNextPage(2, guiLeft + 20, guiTop + 180, false));
updateButtons();
}
@Override
public void drawScreen(int i, int j, float f)
{
drawDefaultBackground();
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
mc.renderEngine.bindTexture(indicator);
drawTexturedModalRect(guiLeft, guiTop + 8, 0, 0, xSize, ySize);
drawTexturedModalRect(guiLeft + 4, guiTop + 8, 56, 0, 200, ySize);
if(playerFactions.isEmpty()){
String noFaction = StatCollector.translateToLocal("faction.nostanding");
fontRendererObj.drawString(noFaction,guiLeft + (xSize - fontRendererObj.getStringWidth(noFaction)) / 2,guiTop + 80, CustomNpcResourceListener.DefaultTextColor);
}
else
renderScreen();
super.drawScreen(i, j, f);
}
private void renderScreen(){
int size = 5;
if(playerFactions.size() % 5 != 0 && page == pages)
size = playerFactions.size() % 5;
for(int id = 0 ; id < size; id++){
drawHorizontalLine(guiLeft + 2, guiLeft + xSize, guiTop + 14 + id * 30, 0xFF000000 + CustomNpcResourceListener.DefaultTextColor);
Faction faction = playerFactions.get((page - 1) * 5 + id);
String name = faction.name;
String points = " : " + faction.defaultPoints;
String standing = StatCollector.translateToLocal("faction.friendly");
int color = 0x00FF00;
if(faction.defaultPoints < faction.neutralPoints){
standing = StatCollector.translateToLocal("faction.unfriendly");
color = 0xFF0000;
points += "/" + faction.neutralPoints;
}
else if(faction.defaultPoints < faction.friendlyPoints){
standing = StatCollector.translateToLocal("faction.neutral");
color = 0xF2FF00;
points += "/" + faction.friendlyPoints;
}
else{
points += "/-";
}
fontRendererObj.drawString(name, guiLeft + (xSize - fontRendererObj.getStringWidth(name)) / 2, guiTop + 19 + id * 30, faction.color);
fontRendererObj.drawString(standing, width / 2 - fontRendererObj.getStringWidth(standing) - 1, guiTop + 33 + id * 30, color);
fontRendererObj.drawString(points, width / 2, guiTop + 33 + id * 30, CustomNpcResourceListener.DefaultTextColor);
}
drawHorizontalLine(guiLeft + 2, guiLeft + xSize, guiTop + 14 + size * 30, 0xFF000000 + CustomNpcResourceListener.DefaultTextColor);
if(pages > 1){
String s = page +"/" + pages;
fontRendererObj.drawString(s, guiLeft + (xSize - fontRendererObj.getStringWidth(s)) / 2, guiTop + 203, CustomNpcResourceListener.DefaultTextColor);
}
}
@Override
protected void actionPerformed(GuiButton guibutton){
if(!(guibutton instanceof GuiButtonNextPage))
return;
int id = guibutton.id;
if(id == 1){
page++;
}
if(id == 2){
page--;
}
updateButtons();
}
private void updateButtons(){
buttonNextPage.setVisible(page < pages);
buttonPreviousPage.setVisible(page > 1);
}
protected void drawGuiContainerBackgroundLayer(float f, int i, int j)
{
}
@Override
public void keyTyped(char c, int i)
{
if (i == 1 || isInventoryKey(i))
{
close();
}
}
@Override
public void save() {
}
@Override
public void setGuiData(NBTTagCompound compound) {
playerFactions = new ArrayList<Faction>();
NBTTagList list = compound.getTagList("FactionList", 10);
for(int i = 0; i < list.tagCount(); i++){
Faction faction = new Faction();
faction.readNBT(list.getCompoundTagAt(i));
playerFactions.add(faction);
}
PlayerFactionData data = new PlayerFactionData();
data.loadNBTData(compound);
for(int id : data.factionData.keySet()){
int points = data.factionData.get(id);
for(Faction faction : playerFactions){
if(faction.id == id)
faction.defaultPoints = points;
}
}
pages = (playerFactions.size() - 1) / 5 ;
pages++;
page = 1;
updateButtons();
}
}
@@ -0,0 +1,52 @@
package noppes.npcs.client.gui.player.inventory;
import net.minecraft.client.Minecraft;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import noppes.npcs.CustomItems;
import noppes.npcs.client.gui.util.GuiMenuSideButton;
import noppes.npcs.client.gui.util.GuiNPCInterface;
import tconstruct.client.tabs.InventoryTabCustomNpc;
import tconstruct.client.tabs.TabRegistry;
public class GuiCNPCInventory extends GuiNPCInterface {
private final ResourceLocation resource = new ResourceLocation("customnpcs","textures/gui/standardbg.png");
protected static int activeTab = 0;
private Minecraft mc = Minecraft.getMinecraft();
public GuiCNPCInventory() {
super();
xSize = 280;
ySize = 180;
drawDefaultBackground = false;
}
public void initGui(){
super.initGui();
guiTop +=10;
TabRegistry.addTabsToList(buttonList);
TabRegistry.updateTabValues(guiLeft, guiTop, InventoryTabCustomNpc.class);
GuiMenuSideButton questsButton = new GuiMenuSideButton(100, guiLeft + xSize + 37, this.guiTop + 3, 22, 22, "");
questsButton.rightSided = true;
questsButton.active = activeTab == 0;
questsButton.renderStack = new ItemStack(CustomItems.letter);
addButton(questsButton);
GuiMenuSideButton partyButton = new GuiMenuSideButton(101, guiLeft + xSize + 37, this.guiTop + 3 + 21, 22, 22, "");
partyButton.rightSided = true;
partyButton.active = activeTab == 1;
partyButton.renderStack = new ItemStack(CustomItems.bag);
addButton(partyButton);
GuiMenuSideButton factionButton = new GuiMenuSideButton(102, guiLeft + xSize + 37, this.guiTop + 3 + 21*2, 22, 22, "");
factionButton.rightSided = true;
factionButton.active = activeTab == 2;
factionButton.renderStack = new ItemStack(CustomItems.wallBanner);
addButton(factionButton);
}
@Override
public void save() {}
}
@@ -0,0 +1,211 @@
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.GuiButtonNextPage;
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{
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;
private GuiButtonNextPage buttonNextPage;
private GuiButtonNextPage buttonPreviousPage;
public GuiFaction() {
super();
xSize = 280;
ySize = 180;
this.drawDefaultBackground = false;
title = "";
activeTab = 2;
NoppesUtilPlayer.sendData(EnumPlayerPacket.FactionsGet);
}
@Override
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));
updateButtons();
}
@Override
public void drawScreen(int i, int j, float f)
{
drawDefaultBackground();
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
mc.renderEngine.bindTexture(resource);
drawTexturedModalRect(guiLeft, guiTop, 0, 0, 252, 195);
drawTexturedModalRect(guiLeft + 252, guiTop, 188, 0, 67, 195);
if(playerFactions.isEmpty()){
String noFaction = StatCollector.translateToLocal("faction.nostanding");
fontRendererObj.drawString(noFaction,guiLeft + (xSize - fontRendererObj.getStringWidth(noFaction)) / 2,guiTop + 80, CustomNpcResourceListener.DefaultTextColor);
}
else
renderScreen();
super.drawScreen(i, j, f);
}
private void renderScreen(){
int size = 10;
if(playerFactions.size() % 10 != 0 && page == pages)
size = playerFactions.size() % 10;
int hLine = 5;
if(size < 5){
hLine = size;
}
int count = -1;
for(int id = 0 ; id < size; id++){
count++;
Faction faction = playerFactions.get((page - 1) * 10 + id);
String name = faction.name;
String points = " : " + faction.defaultPoints;
String standing = StatCollector.translateToLocal("faction.friendly");
int color = 0x00FF00;
if(faction.defaultPoints < faction.neutralPoints){
standing = StatCollector.translateToLocal("faction.unfriendly");
color = 0xFF0000;
points += "/" + faction.neutralPoints;
}
else if(faction.defaultPoints < faction.friendlyPoints){
standing = StatCollector.translateToLocal("faction.neutral");
color = 0xF2FF00;
points += "/" + faction.friendlyPoints;
}
else{
points += "/-";
}
drawVerticalLine(guiLeft + (xSize + 45) / 2, (guiTop + ySize - 15), guiTop + 13, 0xFF000000 + CustomNpcResourceListener.DefaultTextColor);
if(count < 5){
drawHorizontalLine(guiLeft + 2, guiLeft + xSize + 35, guiTop + 14 + count * 30, 0xFF000000 + CustomNpcResourceListener.DefaultTextColor);
fontRendererObj.drawString(name, guiLeft + (xSize + 45 - fontRendererObj.getStringWidth(name)) / 4, guiTop + 19 + count * 30, faction.color);
fontRendererObj.drawString(standing, (guiLeft + (xSize + 45) / 4) - fontRendererObj.getStringWidth(standing), guiTop + 33 + count * 30, color);
fontRendererObj.drawString(points, (guiLeft + (xSize + 45) / 4), guiTop + 33 + count * 30, CustomNpcResourceListener.DefaultTextColor);
}
else {
fontRendererObj.drawString(name, guiLeft + 3*(xSize + 45 - fontRendererObj.getStringWidth(name)) / 4, guiTop + 19 + (count - 5) * 30, faction.color);
fontRendererObj.drawString(standing, (guiLeft + 3*(xSize + 45) / 4) - fontRendererObj.getStringWidth(standing) - 10, guiTop + 33 + (count - 5) * 30, color);
fontRendererObj.drawString(points, (guiLeft + 3*(xSize + 45) / 4) - 10, guiTop + 33 + (count - 5) * 30, CustomNpcResourceListener.DefaultTextColor);
}
drawHorizontalLine(guiLeft + 2, guiLeft + xSize + 35, guiTop + 14 + hLine * 30, 0xFF000000 + CustomNpcResourceListener.DefaultTextColor);
}
if(pages > 1){
String s = page +"/" + pages;
fontRendererObj.drawString(s, guiLeft + (xSize + 45 - fontRendererObj.getStringWidth(s)) / 2, guiTop + 175, CustomNpcResourceListener.DefaultTextColor);
}
}
@Override
protected void actionPerformed(GuiButton guibutton){
if (guibutton.id >= 100) {
if (guibutton.id == 100 && activeTab != 0) {
activeTab = 0;
mc.displayGuiScreen(new GuiQuestLog(mc.thePlayer));
}
if (guibutton.id == 101 && activeTab != 1) {
activeTab = 1;
mc.displayGuiScreen(new GuiParty(mc.thePlayer));
}
if (guibutton.id == 102 && activeTab != 2) {
activeTab = 2;
mc.displayGuiScreen(new GuiFaction());
}
}
if(!(guibutton instanceof GuiButtonNextPage))
return;
int id = guibutton.id;
if(id == 1){
page++;
}
if(id == 2){
page--;
}
updateButtons();
}
private void updateButtons(){
buttonNextPage.setVisible(page < pages);
buttonPreviousPage.setVisible(page > 1);
}
protected void drawGuiContainerBackgroundLayer(float f, int i, int j)
{
}
@Override
public void keyTyped(char c, int i)
{
if (i == 1 || isInventoryKey(i))
{
close();
}
}
@Override
public void save() {
}
@Override
public void setGuiData(NBTTagCompound compound) {
playerFactions = new ArrayList<Faction>();
NBTTagList list = compound.getTagList("FactionList", 10);
for(int i = 0; i < list.tagCount(); i++){
Faction faction = new Faction();
faction.readNBT(list.getCompoundTagAt(i));
playerFactions.add(faction);
}
PlayerFactionData data = new PlayerFactionData();
data.loadNBTData(compound);
for(int id : data.factionData.keySet()){
int points = data.factionData.get(id);
for(Faction faction : playerFactions){
if(faction.id == id)
faction.defaultPoints = points;
}
}
pages = (playerFactions.size() - 1) / 10 ;
pages++;
page = 1;
updateButtons();
}
}
@@ -0,0 +1,229 @@
package noppes.npcs.client.gui.player.inventory;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import noppes.npcs.client.Client;
import noppes.npcs.client.ClientCacheHandler;
import noppes.npcs.client.CustomNpcResourceListener;
import noppes.npcs.client.gui.util.*;
import noppes.npcs.constants.EnumPacketServer;
import noppes.npcs.controllers.data.Party;
import org.lwjgl.opengl.GL11;
import tconstruct.client.tabs.InventoryTabCustomNpc;
import tconstruct.client.tabs.TabRegistry;
import java.util.ArrayList;
import java.util.UUID;
public class GuiParty extends GuiCNPCInventory implements ITextfieldListener, ITopButtonListener,ICustomScrollListener, IGuiData {
private final ResourceLocation resource = new ResourceLocation("customnpcs","textures/gui/standardbg.png");
private final EntityPlayer player;
private Minecraft mc = Minecraft.getMinecraft();
private boolean receivedData;
private long renderTicks;
public GuiParty(EntityPlayer player) {
super();
this.player = player;
xSize = 280;
ySize = 180;
drawDefaultBackground = false;
activeTab = 1;
Client.sendData(EnumPacketServer.GetPartyData);
}
public void initGui(){
super.initGui();
Party party = ClientCacheHandler.party;
TabRegistry.addTabsToList(buttonList);
TabRegistry.updateTabValues(guiLeft, guiTop, InventoryTabCustomNpc.class);
if (receivedData) {
if (party == null) {
//
//create party button
//
GuiNpcButton createPartyButton = new GuiNpcButton(200, guiLeft + xSize/2 + 45, guiTop + ySize/2 + 20, "Create Party");
createPartyButton.width = 100;
this.addButton(createPartyButton);
this.addLabel(new GuiNpcLabel(201, "You're not in a party!", guiLeft + xSize/2 + 30, guiTop + ySize/2 - 30));
this.addLabel(new GuiNpcLabel(202, "Either wait for an invite", guiLeft + xSize/2 + 30, guiTop + ySize/2 - 20));
this.addLabel(new GuiNpcLabel(203, "or create one.", guiLeft + xSize/2 + 30, guiTop + ySize/2 - 10));
//party invites list
//
GuiCustomScroll inviteScroll = new GuiCustomScroll(this, 210, false);
inviteScroll.setSize(150, 160);
inviteScroll.guiLeft = guiLeft + 5;
inviteScroll.guiTop = guiTop + 5;
this.addScroll(inviteScroll);
GuiNpcButton acceptButton = new GuiNpcButton(215, guiLeft + 15, guiTop + ySize - 12, "Accept");
acceptButton.width = 60;
this.addButton(acceptButton);
GuiNpcButton ignoreButton = new GuiNpcButton(220, guiLeft + 80, guiTop + ySize - 12, "Ignore");
ignoreButton.width = 60;
this.addButton(ignoreButton);
} else {
//
//party player list
//
GuiCustomScroll playerScroll = new GuiCustomScroll(this, 300, false);
playerScroll.setSize(150, 160);
playerScroll.guiLeft = guiLeft + 5;
playerScroll.guiTop = guiTop + 5;
playerScroll.setList(new ArrayList<>(party.getPlayerNames()));
this.addScroll(playerScroll);
//set leader button
//
GuiNpcButton leaderButton = new GuiNpcButton(305, guiLeft + 5, guiTop + ySize - 12, "Make Leader");
leaderButton.width = 70;
this.addButton(leaderButton);
//kick player button
//
GuiNpcButton kickButton = new GuiNpcButton(315, guiLeft + 85, guiTop + ySize - 12, "Kick");
kickButton.width = 70;
this.addButton(kickButton);
//toggle friendly fire
//
GuiNpcButton friendlyFireButton = new GuiNpcButton(320, guiLeft + xSize/2 + 95, guiTop + ySize/2, new String[] {"On", "Off"}, 0); //party.friendlyFire() ? 0 : 1
friendlyFireButton.width = 40;
this.addButton(friendlyFireButton);
GuiNpcLabel friendlyFireLabel = new GuiNpcLabel(321, "Friendly Fire:", guiLeft + xSize/2 + 20, guiTop + ySize/2 + 5);
this.addLabel(friendlyFireLabel);
//send invite button (opens subgui)
//
GuiNpcTextField playerTextField = new GuiNpcTextField(325, this, guiLeft + xSize/2 + 20, guiTop + ySize/2 + 40,100, 20, "");
this.addTextField(playerTextField);
GuiNpcButton inviteButton = new GuiNpcButton(330, guiLeft + xSize/2 + 125, guiTop + ySize/2 + 40, "Invite");
inviteButton.width = 50;
this.addButton(inviteButton);
//disband party
//
GuiNpcButton disbandButton = new GuiNpcButton(335, guiLeft + xSize/2 + 45, guiTop + ySize/2 + 70, "Disband Party");
disbandButton.width = 100;
this.addButton(disbandButton);
}
}
}
@Override
protected void actionPerformed(GuiButton guibutton){
switch (guibutton.id) {
case 200:
Client.sendData(EnumPacketServer.CreateParty);
receivedData = false;
break;
case 335:
Client.sendData(EnumPacketServer.DisbandParty);
receivedData = false;
break;
}
initGui();
if (guibutton.id == 100 && activeTab != 0) {
activeTab = 0;
mc.displayGuiScreen(new GuiQuestLog(mc.thePlayer));
}
if (guibutton.id == 101 && activeTab != 1) {
activeTab = 1;
mc.displayGuiScreen(new GuiParty(mc.thePlayer));
}
if (guibutton.id == 102 && activeTab != 2) {
activeTab = 2;
mc.displayGuiScreen(new GuiFaction());
}
}
@Override
public void drawScreen(int i, int j, float f){
renderTicks++;
drawDefaultBackground();
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
mc.renderEngine.bindTexture(resource);
drawTexturedModalRect(guiLeft, guiTop, 0, 0, 252, 195);
drawTexturedModalRect(guiLeft + 252, guiTop, 188, 0, 67, 195);
super.drawScreen(i, j, f);
if(!receivedData){
String periods = "";
for (int k = 0; k < (renderTicks/10)%4; k++) {
periods += ".";
}
fontRendererObj.drawString(StatCollector.translateToLocal("gui.loading") + periods,guiLeft + xSize/2,guiTop + 80, CustomNpcResourceListener.DefaultTextColor);
}
}
@Override
public void keyTyped(char c, int i)
{
super.keyTyped(c, i);
if (!GuiNpcTextField.isFieldActive()) {
if (i == 1 || i == mc.gameSettings.keyBindInventory.getKeyCode()) // inventory key
{
mc.displayGuiScreen(null);
mc.setIngameFocus();
}
}
}
@Override
public boolean doesGuiPauseGame()
{
return false;
}
@Override
public void setGuiData(NBTTagCompound compound) {
this.receivedData = true;
if (compound.hasKey("PartyUUID")) {
Party party = ClientCacheHandler.party;
UUID uuid = UUID.fromString(compound.getString("PartyUUID"));
if (party == null || !party.getPartyUUID().equals(uuid)) {
ClientCacheHandler.party = new Party(uuid);
party = ClientCacheHandler.party;
}
party.readFromNBT(compound);
} else if (compound.hasKey("Disband")) {
ClientCacheHandler.party = null;
}
initGui();
}
@Override
public void onGuiClosed() {
super.onGuiClosed();
this.save();
}
@Override
public void save() {
}
@Override
public void customScrollClicked(int i, int j, int k, GuiCustomScroll guiCustomScroll) {
}
@Override
public void unFocused(GuiNpcTextField textfield) {
}
}
@@ -1,4 +1,4 @@
package noppes.npcs.client.gui.player;
package noppes.npcs.client.gui.player.inventory;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
@@ -17,14 +17,13 @@ import noppes.npcs.client.gui.util.*;
import noppes.npcs.constants.EnumPacketServer;
import noppes.npcs.constants.EnumPlayerPacket;
import noppes.npcs.util.ValueUtil;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
import tconstruct.client.tabs.InventoryTabQuests;
import tconstruct.client.tabs.InventoryTabCustomNpc;
import tconstruct.client.tabs.TabRegistry;
import java.util.*;
public class GuiQuestLog extends GuiNPCInterface implements ITopButtonListener,ICustomScrollListener, IGuiData{
public class GuiQuestLog extends GuiCNPCInventory implements ITopButtonListener,ICustomScrollListener, IGuiData{
private final ResourceLocation resource = new ResourceLocation("customnpcs","textures/gui/standardbg.png");
@@ -51,14 +50,13 @@ public class GuiQuestLog extends GuiNPCInterface implements ITopButtonListener,I
ySize = 180;
NoppesUtilPlayer.sendData(EnumPlayerPacket.QuestLog);
drawDefaultBackground = false;
activeTab = 0;
}
public void initGui(){
super.initGui();
sideButtons.clear();
guiTop +=10;
TabRegistry.addTabsToList(buttonList);
TabRegistry.updateTabValues(guiLeft, guiTop, InventoryTabQuests.class);
TabRegistry.updateTabValues(guiLeft, guiTop, InventoryTabCustomNpc.class);
noQuests = false;
@@ -124,6 +122,18 @@ public class GuiQuestLog extends GuiNPCInterface implements ITopButtonListener,I
data.toggleQuestAlerts();
}
initGui();
if (guibutton.id == 100 && activeTab != 0) {
activeTab = 0;
mc.displayGuiScreen(new GuiQuestLog(mc.thePlayer));
}
if (guibutton.id == 101 && activeTab != 1) {
activeTab = 1;
mc.displayGuiScreen(new GuiParty(mc.thePlayer));
}
if (guibutton.id == 102 && activeTab != 2) {
activeTab = 2;
mc.displayGuiScreen(new GuiFaction());
}
}
@Override
public void drawScreen(int i, int j, float f){
@@ -2,20 +2,27 @@ package noppes.npcs.client.gui.util;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
public class GuiMenuSideButton extends GuiNpcButton{
public static final ResourceLocation resource = new ResourceLocation("customnpcs","textures/gui/menusidebutton.png");
public static final ResourceLocation resource2 = new ResourceLocation("customnpcs","textures/gui/menusidebutton2.png");
public boolean active;
public boolean rightSided;
public ItemStack renderStack;
public GuiMenuSideButton(int i, int j, int k, String s){
this(i, j, k, 200, 20, s);
public GuiMenuSideButton(int id, int x, int y, String s){
this(id, x, y, 200, 20, s);
}
public GuiMenuSideButton(int i, int j, int k, int l, int i1, String s){
super(i, j, k, l, i1, s);
public GuiMenuSideButton(int id, int x, int y, int width, int height, String s){
super(id, x, y, width, height, s);
active = false;
}
@@ -23,7 +30,7 @@ public class GuiMenuSideButton extends GuiNpcButton{
public int getHoverState(boolean flag){
if (active)
return 0;
return 1;
return super.getHoverState(flag);
}
@Override
@@ -32,13 +39,38 @@ public class GuiMenuSideButton extends GuiNpcButton{
return;
}
FontRenderer fontrenderer = minecraft.fontRenderer;
minecraft.renderEngine.bindTexture(resource);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
int width = this.width + (active?2:0);
field_146123_n = i >= xPosition && j >= yPosition && i < xPosition + width && j < yPosition + height;
int k = getHoverState(field_146123_n);
drawTexturedModalRect(xPosition, yPosition, 0, k * 22, width, height);
if (this.rightSided) {
minecraft.renderEngine.bindTexture(resource2);
drawTexturedModalRect(xPosition, yPosition, 197 - width, k * 22, width, height);
} else {
minecraft.renderEngine.bindTexture(resource);
drawTexturedModalRect(xPosition, yPosition, 0, k * 22, width, height);
}
mouseDragged(minecraft, i, j);
if (this.renderStack != null) {
RenderHelper.enableGUIStandardItemLighting();
this.zLevel = 100.0F;
RenderItem itemRenderer = RenderItem.getInstance();
itemRenderer.zLevel = 100.0F;
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
itemRenderer.renderItemAndEffectIntoGUI(minecraft.fontRenderer,
minecraft.renderEngine, this.renderStack, xPosition + 2, yPosition + height/2 - 8);
itemRenderer.renderItemOverlayIntoGUI(minecraft.fontRenderer,
minecraft.renderEngine, this.renderStack, xPosition + 2, yPosition + height/2 - 8);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_BLEND);
itemRenderer.zLevel = 0.0F;
this.zLevel = 0.0F;
RenderHelper.disableStandardItemLighting();
}
String text = "";
float maxWidth = width * 0.75f;