Merge branch 'master' into dev

# Conflicts:
#	src/main/java/noppes/npcs/client/model/ModelMPM.java
#	src/main/java/noppes/npcs/client/renderer/RenderNPCHumanMale.java
This commit is contained in:
Luis C.M committed 2022-06-12 03:40:50 -05:00
commit 13ddc19522
113 files changed
+3870 -934

No files matched your search

@@ -3,6 +3,7 @@ package noppes.npcs.client;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.TickEvent;
import net.minecraft.client.Minecraft;
import net.minecraft.item.ItemArmor;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.client.event.RenderHandEvent;
import net.minecraftforge.client.event.RenderPlayerEvent;
@@ -36,11 +37,17 @@ public class ClientEventHandler {
}
@SubscribeEvent
public void cancelSpecials(RenderPlayerEvent.Specials.Pre event) {
public void cancelSpecials(RenderPlayerEvent.Specials event) {
if (event.renderer instanceof RenderCNPCPlayer)
event.setCanceled(true);
}
@SubscribeEvent
public void cancelSpecials(RenderPlayerEvent.SetArmorModel event) {
if (event.renderer instanceof RenderCNPCPlayer && event.stack != null && event.stack.getItem() instanceof ItemArmor)
event.setCanceled(true);
}
@SubscribeEvent
public void onClientTick(TickEvent.ClientTickEvent event) {
Minecraft mc = Minecraft.getMinecraft();
@@ -4,6 +4,7 @@ import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.atomic.AtomicInteger;
@@ -160,6 +161,8 @@ public class ImageDownloadAlt extends SimpleTexture
ImageDownloadAlt.this.setBufferedImage(bufferedimage);
}
catch (MalformedURLException ignored) {
}
catch (Exception exception)
{
ImageDownloadAlt.logger.error("Couldn\'t download http texture", exception);
@@ -8,19 +8,25 @@ import net.minecraft.util.ChatComponentText;
import net.minecraft.util.ChatStyle;
import noppes.npcs.NoppesStringUtils;
import noppes.npcs.TextBlock;
import noppes.npcs.controllers.data.Dialog;
import noppes.npcs.entity.EntityNPCInterface;
public class TextBlockClient extends TextBlock{
private ChatStyle style;
public int color = 0xe0e0e0;
public int titleColor = 0xe0e0e0;
public int titlePos = 0;
private String name;
private ICommandSender sender;
public TextBlockClient(ICommandSender sender, String text, int lineWidth, int color, Object... obs) {
this(text, lineWidth, false, obs);
this.color = color;
public TextBlockClient(ICommandSender sender, Dialog dialog, Object... obs) {
this(dialog.text, dialog.textWidth, false, obs);
this.color = dialog.color;
this.titleColor = dialog.titleColor;
this.titlePos = dialog.titlePos;
this.sender = sender;
}
public TextBlockClient(String name, String text, int lineWidth, int color, Object... obs) {
this(text, lineWidth, false, obs);
this.color = color;
@@ -11,8 +11,7 @@ import org.lwjgl.opengl.GL11;
public class GuiNpcTextureOverlays extends GuiNpcSelectionInterface{
public GuiNpcTextureOverlays(EntityNPCInterface npc,GuiScreen parent){
//super(npc, parent, npc.display.glowTexture.isEmpty()?"customnpcs:textures/overlays/":npc.display.glowTexture);
super(npc, parent, npc.display.skinOverlayData.overlayList.containsKey(0) ? npc.display.skinOverlayData.overlayList.get(0).getTexture() : "");
super(npc, parent, npc.display.skinOverlayData.overlayList.containsKey(0) ? !npc.display.skinOverlayData.overlayList.get(0).getTexture().isEmpty() ? npc.display.skinOverlayData.overlayList.get(0).getTexture() : "customnpcs:textures/overlays/" : "customnpcs:textures/overlays/");
title = "Select Overlay";
this.parent = parent;
}
@@ -79,10 +78,7 @@ public class GuiNpcTextureOverlays extends GuiNpcSelectionInterface{
//npc.display.glowTexture = assets.getAsset(slot.selected);
//npc.textureGlowLocation = null;
npc.display.skinOverlayData.overlayList.put(0,new SkinOverlay(
assets.getAsset(slot.selected), true, 1.0F, 1.0F, 0.0F, 0.0F,
1.0F, 1.0F, 0.0F, 0.0F, 0.0F
));
npc.display.skinOverlayData.overlayList.put(0,new SkinOverlay(assets.getAsset(slot.selected)));
}
}
@@ -8,8 +8,7 @@ import net.minecraft.client.gui.GuiYesNoCallback;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.server.MinecraftServer;
import noppes.npcs.CustomNpcs;
import noppes.npcs.DataScript;
import noppes.npcs.controllers.data.DataScript;
import noppes.npcs.NoppesStringUtils;
import noppes.npcs.client.Client;
import noppes.npcs.client.NoppesUtil;
@@ -10,6 +10,7 @@ import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.ResourceLocation;
import noppes.npcs.CustomNpcs;
import noppes.npcs.controllers.data.Quest;
@@ -54,9 +55,12 @@ public class OverlayQuestTracking extends Gui {
private float posY;
private float renderOffsetY;
private final int overlayWidth = 120;
public static Quest trackedQuest = new Quest();
public static String categoryName = "";
public ArrayList<String> trackedQuestLines = new ArrayList<>();
public ArrayList<String> categoryNameLines = new ArrayList<>();
public ArrayList<String> objectiveLines = new ArrayList<>();
public ArrayList<String> turnInText = new ArrayList<>();
public OverlayQuestTracking(Minecraft mc) {
this.mc = mc;
@@ -102,64 +106,52 @@ public class OverlayQuestTracking extends Gui {
}
public void setOverlayData(NBTTagCompound compound) {
Quest trackedQuest = new Quest();
trackedQuest.readNBT(compound.getCompoundTag("Quest"));
categoryName = compound.getString("CategoryName");
trackedQuestLines = getLineList(trackedQuest.getName());
categoryNameLines = getLineList(compound.getString("CategoryName"));
NBTTagList nbtTagList = compound.getTagList("ObjectiveList",8);
for (int i = 0; i < nbtTagList.tagCount(); i++) {
String objective = nbtTagList.getStringTagAt(i);
String[] split = objective.split(":");
split = split[split.length-1].split("/");
boolean completed = false;
try {
int killed = Integer.parseInt(split[0].trim());
int total = Integer.parseInt(split[1].trim());
if (killed/total == 1) {
completed = true;
}
} catch (NumberFormatException e) {
if (objective.endsWith("(read)") || (objective.endsWith("Found") && !objective.endsWith("Not Found"))) {
completed = true;
}
}
if (completed) {
objective = "&a&o&m" + objective;
} else {
objective = "&o" + objective;
}
objectiveLines.add(objective);
}
String npcName = compound.getString("TurnInNPC");
if (!npcName.isEmpty()) {
turnInText.add("Complete with " + npcName);
}
this.initOverlay();
}
public void renderGameOverlay(float partialTicks){
res = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
scaledWidth = res.getScaledWidth();
scaledHeight = res.getScaledHeight();
GL11.glEnable(GL11.GL_BLEND);
OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0);
GL11.glDisable(GL11.GL_ALPHA_TEST);
GL11.glPushMatrix();
GL11.glTranslatef(CustomNpcs.TrackingInfoAlignment%3*((float)(scaledWidth)/2), (float) (Math.floor((float)(CustomNpcs.TrackingInfoAlignment/3))*((float)(scaledHeight)/2)),0.0F);
GL11.glTranslatef(CustomNpcs.TrackingInfoX - 10, CustomNpcs.TrackingInfoY, 0.0F);
red = (color >> 16 & 255) / 255f;
green = (color >> 8 & 255) / 255f;
blue = (color & 255) / 255f;
float centerX = -60;
float questTitleTop;
this.renderOffsetY = -40;
GL11.glPushMatrix();
GL11.glTranslatef(centerX, 0.0F, 0.0F);
this.renderStringLines(trackedQuest.getName(),1.2F, false, true);
GL11.glPopMatrix();
questTitleTop = this.renderOffsetY;
this.renderOffsetY -= 5;
GL11.glPushMatrix();
GL11.glTranslatef(centerX, 0.0F, 0.0F);
this.renderStringLines(categoryName,0.85F, false, false);
GL11.glPopMatrix();
//TODO: Add objectives list, with green strikethrough text for completed objectives. Then, add who the player should turn the quest in to.
this.renderOffsetY = -25;
GL11.glPushMatrix();
this.drawHorizontalLine((int)(-60 + centerX), (int)(60 + centerX), (int) (this.renderOffsetY+2), 0xFF777777);
this.drawHorizontalLine((int)(-60 + centerX), (int)(60 + centerX), (int) (this.renderOffsetY+1), 0xFFA8A8A8);
this.drawHorizontalLine((int)(-60 + centerX), (int)(60 + centerX), (int) (this.renderOffsetY), 0xFFFFFFFF);
GL11.glPopMatrix();
this.renderOffsetY = questTitleTop + 5;
GL11.glPushMatrix();
this.drawHorizontalLine((int)(-60 + centerX), (int)(60 + centerX), (int) (this.renderOffsetY), 0xFFFFFFFF);
this.drawHorizontalLine((int)(-60 + centerX), (int)(60 + centerX), (int) (this.renderOffsetY-1), 0xFFA8A8A8);
this.drawHorizontalLine((int)(-60 + centerX), (int)(60 + centerX), (int) (this.renderOffsetY-2), 0xFF777777);
GL11.glPopMatrix();
GL11.glPopMatrix();
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_ALPHA_TEST);
}
public void renderStringLines(String string, float scale, boolean upwards, boolean bold) {
public ArrayList<String> getLineList(String string) {
String[] split = string.split(" ");
ArrayList<String> lines = new ArrayList<>();
@@ -174,21 +166,105 @@ public class OverlayQuestTracking extends Gui {
}
}
return lines;
}
public void renderGameOverlay(float partialTicks){
res = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
scaledWidth = res.getScaledWidth();
scaledHeight = res.getScaledHeight();
GL11.glEnable(GL11.GL_BLEND);
OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0);
GL11.glDisable(GL11.GL_ALPHA_TEST);
GL11.glPushMatrix();
GL11.glTranslatef(CustomNpcs.TrackingInfoAlignment%3*((float)(scaledWidth)/2), (float) (Math.floor((float)(CustomNpcs.TrackingInfoAlignment/3))*((float)(scaledHeight)/2)),0.0F);
float offsetX = CustomNpcs.TrackingInfoAlignment%3 == 0 ? 5 : -5;
GL11.glTranslatef(CustomNpcs.TrackingInfoX + offsetX, CustomNpcs.TrackingInfoY, 0.0F);
red = (color >> 16 & 255) / 255f;
green = (color >> 8 & 255) / 255f;
blue = (color & 255) / 255f;
float centerX = -60;
centerX *= CustomNpcs.TrackingInfoAlignment%3 == 0 ? -1 : 1;
float questTitleTop;
this.renderOffsetY = -40;
GL11.glPushMatrix();
GL11.glTranslatef(centerX, 0.0F, 0.0F);
this.renderStringLines(trackedQuestLines,1.2F, false, true, 0);
GL11.glPopMatrix();
questTitleTop = this.renderOffsetY;
this.renderOffsetY -= 10;
GL11.glPushMatrix();
GL11.glTranslatef(centerX, 0.0F, 0.0F);
this.renderStringLines(categoryNameLines,0.85F, false, false, 0);
GL11.glPopMatrix();
this.renderOffsetY = -10;
GL11.glPushMatrix();
this.renderStringLines(objectiveLines,1F, true, false, CustomNpcs.TrackingInfoAlignment%3 == 0 ? 1 : 2);
GL11.glPopMatrix();
this.renderOffsetY += 10;
GL11.glPushMatrix();
this.renderStringLines(turnInText,1F, false, false, CustomNpcs.TrackingInfoAlignment%3 == 0 ? 1 : 2);
GL11.glPopMatrix();
this.renderOffsetY = -20;
GL11.glPushMatrix();
this.drawHorizontalLine((int)(-overlayWidth/2 + centerX), (int)(overlayWidth/2 + centerX), (int) (this.renderOffsetY+2), 0xFF777777);
this.drawHorizontalLine((int)(-overlayWidth/2 + centerX), (int)(overlayWidth/2 + centerX), (int) (this.renderOffsetY+1), 0xFFA8A8A8);
this.drawHorizontalLine((int)(-overlayWidth/2 + centerX), (int)(overlayWidth/2 + centerX), (int) (this.renderOffsetY), 0xFFFFFFFF);
GL11.glPopMatrix();
this.renderOffsetY = questTitleTop + 2;
GL11.glPushMatrix();
this.drawHorizontalLine((int)(-overlayWidth/2 + centerX), (int)(overlayWidth/2 + centerX), (int) (this.renderOffsetY), 0xFFFFFFFF);
this.drawHorizontalLine((int)(-overlayWidth/2 + centerX), (int)(overlayWidth/2 + centerX), (int) (this.renderOffsetY-1), 0xFFA8A8A8);
this.drawHorizontalLine((int)(-overlayWidth/2 + centerX), (int)(overlayWidth/2 + centerX), (int) (this.renderOffsetY-2), 0xFF777777);
GL11.glPopMatrix();
GL11.glPopMatrix();
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_ALPHA_TEST);
}
public void renderStringLines(ArrayList<String> lines, float scale, boolean downwards, boolean bold, int facing) {
for (int i = 0; i < lines.size(); i++) {
String s = lines.get(i);
if (!upwards) {
if (!downwards) {
s = lines.get(lines.size()-1 - i);
}
int stringWidth = this.fontRenderer.getStringWidth(s.replace("&o",""));
if (s.startsWith("&a&o&m")) {
stringWidth = this.fontRenderer.getStringWidth(s.replace("&a&o&m",""));
}
GL11.glPushMatrix();
GL11.glTranslatef(scale*(-this.fontRenderer.getStringWidth(s)/2.0F), this.renderOffsetY, 0.0F);
switch (facing) {
case 0://center
GL11.glTranslatef(scale * (-stringWidth / 2.0F), this.renderOffsetY, 0.0F);
break;
case 1://left
GL11.glTranslatef(0, this.renderOffsetY, 0.0F);
break;
case 2://right
GL11.glTranslatef(scale * (-stringWidth), this.renderOffsetY, 0.0F);
break;
}
GL11.glScalef(scale, scale, scale);
this.drawString(s, 0, 0, this.color, true);
if (bold) {
GL11.glTranslatef(0.2F, 0.2F, 0.0F);
this.drawString(s, 0, 0, this.color, false);
}
this.renderOffsetY += upwards ? 10 : -10;
this.renderOffsetY += downwards ? 10 : -10;
GL11.glPopMatrix();
}
}
@@ -39,19 +39,10 @@ public class SubGuiNpcDialogExtra extends SubGuiInterface implements ISubGuiList
addButton(new GuiNpcButton(10, guiLeft + 120, y += 22, 50, 20, "selectServer.edit"));
addLabel(new GuiNpcLabel(10, "advMode.command", guiLeft + 4, y + 5));
addButton(new GuiNpcButtonYesNo(11, guiLeft + 120, y += 22, dialog.hideNPC));
addLabel(new GuiNpcLabel(11, "dialog.hideNPC", guiLeft + 4, y + 5));
addButton(new GuiNpcButtonYesNo(12, guiLeft + 120, y += 22, dialog.showWheel));
addLabel(new GuiNpcLabel(12, "dialog.showWheel", guiLeft + 4, y + 5));
addButton(new GuiNpcButtonYesNo(15, guiLeft + 120, y += 22, dialog.disableEsc));
addLabel(new GuiNpcLabel(15, "dialog.disableEsc", guiLeft + 4, y + 5));
addButton(new GuiNpcButtonYesNo(16, guiLeft + 120, y += 22, dialog.darkenScreen));
addLabel(new GuiNpcLabel(16, "Darken Screen", guiLeft + 4, y + 5));
this.addButton(new GuiNpcButton(66, guiLeft + 82, guiTop + 192,98, 20, "gui.done"));
}
@@ -63,18 +54,9 @@ public class SubGuiNpcDialogExtra extends SubGuiInterface implements ISubGuiList
if(button.id == 10){
setSubGui(new SubGuiNpcCommand(dialog.command));
}
if(button.id == 11){
dialog.hideNPC = button.getValue() == 1;
}
if(button.id == 12){
dialog.showWheel = button.getValue() == 1;
}
if(button.id == 15){
dialog.disableEsc = button.getValue() == 1;
}
if(button.id == 16){
dialog.darkenScreen = button.getValue() == 1;
}
if(button.id == 13){
setSubGui(new SubGuiMailmanSendSetup(dialog.mail, getParent()));
}
@@ -0,0 +1,546 @@
package noppes.npcs.client.gui;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.client.Client;
import noppes.npcs.client.NoppesUtil;
import noppes.npcs.client.gui.global.GuiNPCManageDialogs;
import noppes.npcs.client.gui.util.*;
import noppes.npcs.constants.EnumPacketServer;
import noppes.npcs.controllers.data.Dialog;
import noppes.npcs.controllers.data.DialogImage;
import java.util.ArrayList;
import java.util.Collections;
public class SubGuiNpcDialogVisual extends SubGuiInterface implements ISubGuiListener, ITextfieldListener, ICustomScrollListener {
private final Dialog dialog;
public GuiScreen parent2;
private GuiMenuTopButton[] topButtons;
private int activeMenu = 1;
private GuiCustomScroll imageScroll;
private int selected = -1;
private int lastColorClicked = -1;
private int changedId = -1;
public SubGuiNpcDialogVisual(Dialog dialog, GuiScreen parent) {
this.parent2 = parent;
this.dialog = dialog;
setBackground("menubg.png");
xSize = 256;
ySize = 216;
closeOnEsc = true;
}
public void initGui()
{
super.initGui();
int y = guiTop - 10;
GuiMenuTopButton close = new GuiMenuTopButton(0,guiLeft + xSize - 22, guiTop - 17, "X");
GuiMenuTopButton general = new GuiMenuTopButton(1, guiLeft + 4, guiTop - 17, "General");
GuiMenuTopButton spacing = new GuiMenuTopButton(2, general.xPosition + general.getWidth(), guiTop - 17, "Spacing");
GuiMenuTopButton images = new GuiMenuTopButton(3, spacing.xPosition + spacing.getWidth(), guiTop - 17, "Images");
topButtons = new GuiMenuTopButton[]{general,images,spacing,close};
for(GuiMenuTopButton button : topButtons) {
button.active = button.id == activeMenu;
addButton(button);
}
if (activeMenu == 1) {
addButton(new GuiNpcButtonYesNo(10, guiLeft + 120, y += 22, dialog.hideNPC));
addLabel(new GuiNpcLabel(10, "dialog.hideNPC", guiLeft + 4, y + 5));
addButton(new GuiNpcButtonYesNo(11, guiLeft + 120, y += 22, dialog.showWheel));
addLabel(new GuiNpcLabel(11, "dialog.showWheel", guiLeft + 4, y + 5));
addButton(new GuiNpcButtonYesNo(12, guiLeft + 120, y += 22, dialog.darkenScreen));
addLabel(new GuiNpcLabel(12, "dialog.darkenScreen", guiLeft + 4, y + 5));
addButton(new GuiNpcButton(13, guiLeft + 120, y += 22, 50, 20, new String[]{"dialog.instant", "dialog.gradual"}, dialog.renderGradual ? 1 : 0));
addLabel(new GuiNpcLabel(13, "dialog.renderType", guiLeft + 4, y + 5));
addButton(new GuiNpcButton(14, guiLeft + 120, y += 22, 50, 20, new String[]{"display.hide", "display.show"}, dialog.showPreviousBlocks ? 1 : 0));
addLabel(new GuiNpcLabel(14, "dialog.previousBlocks", guiLeft + 4, y + 5));
addButton(new GuiNpcButton(15, guiLeft + 120, y += 22, 50, 20, new String[]{"display.hide", "display.show"}, dialog.showOptionLine ? 1 : 0));
addLabel(new GuiNpcLabel(15, "dialog.optionLine", guiLeft + 4, y + 5));
String color = Integer.toHexString(dialog.color);
while (color.length() < 6) {
color = 0 + color;
}
addButton(new GuiNpcButton(16, guiLeft + 35, y += 25, 60, 20, color));
addLabel(new GuiNpcLabel(16, "gui.color", guiLeft + 4, y + 5));
getButton(16).setTextColor(dialog.color);
color = Integer.toHexString(dialog.titleColor);
while (color.length() < 6) {
color = 0 + color;
}
addButton(new GuiNpcButton(17, guiLeft + 157, y, 60, 20, color));
addLabel(new GuiNpcLabel(17, "dialog.titleColor", guiLeft + 100, y + 5));
getButton(17).setTextColor(dialog.titleColor);
addTextField(new GuiNpcTextField(18, this, guiLeft + 80, y += 22, 165, 20, dialog.textSound));
addLabel(new GuiNpcLabel(18, "dialog.textSound", guiLeft + 4, y + 5));
getTextField(18).setVisible(dialog.renderGradual);
getLabel(18).enabled = dialog.renderGradual;
addTextField(new GuiNpcTextField(19, this, guiLeft + 125, y += 22, 40, 20, String.valueOf(dialog.textPitch)));
addLabel(new GuiNpcLabel(19, "dialog.textPitch", guiLeft + 4, y + 5));
getTextField(19).floatsOnly = true;
getTextField(19).setVisible(dialog.renderGradual);
getLabel(19).enabled = dialog.renderGradual;
} else if (activeMenu == 2) {
addButton(new GuiNpcButton(10, guiLeft + 70, y += 22, 50, 20, new String[]{"gui.text", "gui.option", "display.fixed"}, dialog.titlePos));
addLabel(new GuiNpcLabel(10, "dialog.titlePos", guiLeft + 4, y + 5));
addTextField(new GuiNpcTextField(11, this, guiLeft + 120, y += 25, 40, 20, String.valueOf(dialog.textWidth)));
addTextField(new GuiNpcTextField(12, this, guiLeft + 165, y, 40, 20, String.valueOf(dialog.textHeight)));
addLabel(new GuiNpcLabel(12, "gui.widthHeight", guiLeft + 4, y + 5));
getTextField(11).integersOnly = true;
getTextField(11).setMinMaxDefault(-Integer.MAX_VALUE, Integer.MAX_VALUE, 0);
getTextField(12).integersOnly = true;
getTextField(12).setMinMaxDefault(-Integer.MAX_VALUE, Integer.MAX_VALUE, 0);
addTextField(new GuiNpcTextField(13, this, guiLeft + 120, y += 25, 40, 20, String.valueOf(dialog.textOffsetX)));
addTextField(new GuiNpcTextField(14, this, guiLeft + 165, y, 40, 20, String.valueOf(dialog.textOffsetY)));
addLabel(new GuiNpcLabel(15, "dialog.textOffset", guiLeft + 4, y + 5));
getTextField(13).integersOnly = true;
getTextField(13).setMinMaxDefault(-Integer.MAX_VALUE, Integer.MAX_VALUE, 0);
getTextField(14).integersOnly = true;
getTextField(14).setMinMaxDefault(-Integer.MAX_VALUE, Integer.MAX_VALUE, 0);
addTextField(new GuiNpcTextField(15, this, guiLeft + 120, y += 25, 40, 20, String.valueOf(dialog.titleOffsetX)));
addTextField(new GuiNpcTextField(16, this, guiLeft + 165, y, 40, 20, String.valueOf(dialog.titleOffsetY)));
addLabel(new GuiNpcLabel(18, "dialog.titleOffset", guiLeft + 4, y + 5));
getTextField(15).integersOnly = true;
getTextField(15).setMinMaxDefault(-Integer.MAX_VALUE, Integer.MAX_VALUE, 0);
getTextField(16).integersOnly = true;
getTextField(16).setMinMaxDefault(-Integer.MAX_VALUE, Integer.MAX_VALUE, 0);
addTextField(new GuiNpcTextField(17, this, guiLeft + 120, y += 25, 40, 20, String.valueOf(dialog.optionOffsetX)));
addTextField(new GuiNpcTextField(18, this, guiLeft + 165, y, 40, 20, String.valueOf(dialog.optionOffsetY)));
addLabel(new GuiNpcLabel(21, "dialog.optionOffset", guiLeft + 4, y + 5));
getTextField(17).integersOnly = true;
getTextField(17).setMinMaxDefault(-Integer.MAX_VALUE, Integer.MAX_VALUE, 0);
getTextField(18).integersOnly = true;
getTextField(18).setMinMaxDefault(-Integer.MAX_VALUE, Integer.MAX_VALUE, 0);
addTextField(new GuiNpcTextField(19, this, guiLeft + 120, y += 25, 40, 20, String.valueOf(dialog.optionSpaceX)));
addTextField(new GuiNpcTextField(20, this, guiLeft + 165, y, 40, 20, String.valueOf(dialog.optionSpaceY)));
addLabel(new GuiNpcLabel(24, "dialog.optionSpacing", guiLeft + 4, y + 5));
getTextField(19).integersOnly = true;
getTextField(19).setMinMaxDefault(-Integer.MAX_VALUE, Integer.MAX_VALUE, 0);
getTextField(20).integersOnly = true;
getTextField(20).setMinMaxDefault(-Integer.MAX_VALUE, Integer.MAX_VALUE, 0);
addTextField(new GuiNpcTextField(21, this, guiLeft + 120, y += 25, 40, 20, String.valueOf(dialog.npcOffsetX)));
addTextField(new GuiNpcTextField(22, this, guiLeft + 165, y, 40, 20, String.valueOf(dialog.npcOffsetY)));
addLabel(new GuiNpcLabel(25, "dialog.npcOffset", guiLeft + 4, y + 5));
getTextField(21).integersOnly = true;
getTextField(21).setMinMaxDefault(-Integer.MAX_VALUE, Integer.MAX_VALUE, 0);
getTextField(21).setVisible(!dialog.hideNPC);
getTextField(22).integersOnly = true;
getTextField(22).setMinMaxDefault(-Integer.MAX_VALUE, Integer.MAX_VALUE, 0);
getTextField(22).setVisible(!dialog.hideNPC);
getLabel(25).enabled = !dialog.hideNPC;
addTextField(new GuiNpcTextField(23, this, guiLeft + 120, y += 25, 40, 20, String.valueOf(dialog.npcScale)));
addLabel(new GuiNpcLabel(26, "dialog.npcScale", guiLeft + 4, y + 5));
getTextField(23).floatsOnly = true;
getTextField(23).setMinMaxDefaultFloat(-Float.MAX_VALUE, Float.MAX_VALUE, 0);
getTextField(23).setVisible(!dialog.hideNPC);
getLabel(26).enabled = !dialog.hideNPC;
} else if (activeMenu == 3) {
if (imageScroll == null) {
imageScroll = new GuiCustomScroll(this, 0, false);
}
imageScroll.guiLeft = guiLeft + xSize;
imageScroll.guiTop = guiTop + 25;
imageScroll.setSize(50, this.ySize - 25);
updateScrollData();
addButton(new GuiNpcButton(1, guiLeft + xSize + 2, guiTop + 5, 20, 20, "+"));
if (getSelectedImage() != null) {
DialogImage dialogImage = getSelectedImage();
addButton(new GuiNpcButton(2, guiLeft + xSize + 24, guiTop + 5, 20, 20, "-"));
addTextField(new GuiNpcTextField(10, this, guiLeft + 17, y += 25, 30, 20, String.valueOf(dialogImage.id)));
addTextField(new GuiNpcTextField(11, this, guiLeft + 92, y, 150, 20, dialogImage.texture));
addLabel(new GuiNpcLabel(10, "gui.id", guiLeft + 4, y + 5));
addLabel(new GuiNpcLabel(11, "display.texture", guiLeft + 50, y + 5));
getTextField(10).integersOnly = true;
addTextField(new GuiNpcTextField(12, this, guiLeft + 120, y += 25, 40, 20, String.valueOf(dialogImage.x)));
addTextField(new GuiNpcTextField(13, this, guiLeft + 165, y, 40, 20, String.valueOf(dialogImage.y)));
addLabel(new GuiNpcLabel(12, "gui.position", guiLeft + 4, y + 5));
getTextField(12).integersOnly = true;
getTextField(12).setMinMaxDefault(-Integer.MAX_VALUE, Integer.MAX_VALUE, 0);
getTextField(13).integersOnly = true;
getTextField(13).setMinMaxDefault(-Integer.MAX_VALUE, Integer.MAX_VALUE, 0);
addTextField(new GuiNpcTextField(14, this, guiLeft + 120, y += 25, 40, 20, String.valueOf(dialogImage.width)));
addTextField(new GuiNpcTextField(15, this, guiLeft + 165, y, 40, 20, String.valueOf(dialogImage.height)));
addLabel(new GuiNpcLabel(13, "gui.widthHeight", guiLeft + 4, y + 5));
getTextField(14).integersOnly = true;
getTextField(14).setMinMaxDefault(-Integer.MAX_VALUE, Integer.MAX_VALUE, 0);
getTextField(15).integersOnly = true;
getTextField(15).setMinMaxDefault(-Integer.MAX_VALUE, Integer.MAX_VALUE, 0);
addTextField(new GuiNpcTextField(16, this, guiLeft + 120, y += 25, 40, 20, String.valueOf(dialogImage.textureX)));
addTextField(new GuiNpcTextField(17, this, guiLeft + 165, y, 40, 20, String.valueOf(dialogImage.textureY)));
addLabel(new GuiNpcLabel(14, "dialog.textureOffset", guiLeft + 4, y + 5));
getTextField(16).integersOnly = true;
getTextField(16).setMinMaxDefault(-Integer.MAX_VALUE, Integer.MAX_VALUE, 0);
getTextField(17).integersOnly = true;
getTextField(17).setMinMaxDefault(-Integer.MAX_VALUE, Integer.MAX_VALUE, 0);
String color = Integer.toHexString(dialogImage.color);
while(color.length() < 6)
color = 0 + color;
addButton(new GuiNpcButton(18, guiLeft + 35, y += 25, 60, 20, color));
addLabel(new GuiNpcLabel(15, "gui.color", guiLeft + 4, y + 5));
getButton(18).setTextColor(dialogImage.color);
String selectedColor = Integer.toHexString(dialogImage.selectedColor);
while (selectedColor.length() < 6)
selectedColor = 0 + selectedColor;
addButton(new GuiNpcButton(19, guiLeft + 180, y, 60, 20, selectedColor));
addLabel(new GuiNpcLabel(16, "dialog.selectedColor", guiLeft + 100, y + 5));
getButton(19).setTextColor(dialogImage.selectedColor);
getButton(19).setEnabled(dialogImage.imageType == 2);
getButton(19).setVisible(dialogImage.imageType == 2);
getLabel(16).enabled = dialogImage.imageType == 2;
addTextField(new GuiNpcTextField(20, this, guiLeft + 33, y += 25, 30, 20, String.valueOf(dialogImage.scale)));
addTextField(new GuiNpcTextField(21, this, guiLeft + 102, y, 30, 20, String.valueOf(dialogImage.alpha)));
addTextField(new GuiNpcTextField(22, this, guiLeft + 183, y, 45, 20, String.valueOf(dialogImage.rotation)));
addLabel(new GuiNpcLabel(17, "model.scale", guiLeft + 4, y + 5));
addLabel(new GuiNpcLabel(18, "display.alpha", guiLeft + 72, y + 5));
addLabel(new GuiNpcLabel(19, "movement.rotation", guiLeft + 140, y + 5));
getTextField(20).floatsOnly = true;
getTextField(21).floatsOnly = true;
getTextField(22).floatsOnly = true;
addButton(new GuiNpcButton(23, guiLeft + 35, y += 25, 60, 20, new String[]{"gui.screen", "gui.text", "gui.option"}, dialogImage.imageType));
addLabel(new GuiNpcLabel(20, "gui.type", guiLeft + 4, y + 5));
addButton(new GuiNpcButton(24, guiLeft + 160, y, 60, 20,
new String[]{"display.topLeft", "display.topCenter", "display.topRight",
"display.left", "display.center", "display.right",
"display.botLeft", "display.botCenter", "display.botRight"},
dialogImage.alignment));
addLabel(new GuiNpcLabel(21, "display.alignment", guiLeft + 110, y + 5));
getButton(24).setEnabled(dialogImage.imageType == 0);
getButton(24).setVisible(dialogImage.imageType == 0);
getLabel(21).enabled = dialogImage.imageType == 0;
}
}
}
public void updateScrollData() {
ArrayList<Integer> ids = new ArrayList<>(dialog.dialogImages.keySet());
Collections.sort(ids);
ArrayList<String> strings = new ArrayList<>();
for (int i : ids) {
strings.add(String.valueOf(i));
}
imageScroll.setUnsortedList(strings);
if (changedId != -1) {
selected = imageScroll.getList().indexOf(String.valueOf(changedId));
imageScroll.setSelected(String.valueOf(changedId));
changedId = -1;
}
addScroll(imageScroll);
}
private void topButtonPressed(GuiMenuTopButton button) {
NoppesUtil.clickSound();
int id = button.id;
if(id == 0){
close();
if(parent2 != null)
NoppesUtil.openGUI(player, parent2);
return;
}
save();
activeMenu = id;
initGui();
}
@Override
protected void actionPerformed(GuiButton guibutton){
GuiNpcButton button = (GuiNpcButton) guibutton;
if (guibutton instanceof GuiMenuTopButton) {
topButtonPressed((GuiMenuTopButton) guibutton);
}
if (activeMenu == 1) {
if (button.id == 10) {
dialog.hideNPC = button.getValue() == 1;
}
if (button.id == 11) {
dialog.showWheel = button.getValue() == 1;
}
if (button.id == 12) {
dialog.darkenScreen = button.getValue() == 1;
}
if (button.id == 13) {
dialog.renderGradual = button.getValue() == 1;
}
if (button.id == 14) {
dialog.showPreviousBlocks = button.getValue() == 1;
}
if (button.id == 15) {
dialog.showOptionLine = button.getValue() == 1;
}
if (button.id == 16) {
setSubGui(new SubGuiColorSelector(dialog.color));
lastColorClicked = 0;
}
if (button.id == 17) {
setSubGui(new SubGuiColorSelector(dialog.titleColor));
lastColorClicked = 1;
}
}
if (activeMenu == 2) {
if (button.id == 10) {
dialog.titlePos = button.getValue();
}
}
if (activeMenu == 3) {
if (button.id == 1) {
int addId = 0;
if (selected != -1 && imageScroll.getSelected() != null) {
DialogImage selectedImage = (DialogImage) dialog.dialogImages.get(Integer.valueOf(imageScroll.getSelected()));
ArrayList<Integer> keys = new ArrayList<>(dialog.dialogImages.keySet());
int keyIndex = keys.indexOf(selectedImage.id);
do {
addId = keys.get(keyIndex) + 1;
keyIndex++;
} while (dialog.dialogImages.containsKey(addId));
} else if (dialog.dialogImages.size() > 0) {
addId = (Integer) dialog.dialogImages.keySet().toArray()[dialog.dialogImages.size() - 1] + 1;
}
dialog.dialogImages.put(addId, new DialogImage(addId));
updateScrollData();
selected = imageScroll.getList().indexOf(String.valueOf(addId));
}
if (button.id == 2) {
if (imageScroll.getSelected() != null) {
dialog.dialogImages.remove(Integer.valueOf(imageScroll.getSelected()));
selected--;
}
}
if (button.id == 18) {
if (getSelectedImage() != null) {
DialogImage dialogImage = getSelectedImage();
setSubGui(new SubGuiColorSelector(dialogImage.color));
lastColorClicked = 0;
}
}
if (button.id == 19) {
if (getSelectedImage() != null) {
DialogImage dialogImage = getSelectedImage();
setSubGui(new SubGuiColorSelector(dialogImage.selectedColor));
lastColorClicked = 1;
}
}
if (button.id == 23) {
if (getSelectedImage() != null) {
DialogImage dialogImage = getSelectedImage();
dialogImage.imageType = button.getValue();
}
}
if (button.id == 24) {
if (getSelectedImage() != null) {
DialogImage dialogImage = getSelectedImage();
dialogImage.alignment = button.getValue();
}
}
}
initGui();
}
@Override
public void drawScreen(int i, int j, float f){
super.drawScreen(i,j,f);
for(GuiMenuTopButton button: topButtons)
button.drawButton(mc, i, j);
}
@Override
public void subGuiClosed(SubGuiInterface subgui){
if (activeMenu == 1) {
if (lastColorClicked == 0) {
dialog.color = ((SubGuiColorSelector) subgui).color;
} else if (lastColorClicked == 1) {
dialog.titleColor = ((SubGuiColorSelector) subgui).color;
}
initGui();
}
if (activeMenu == 3) {
if (getSelectedImage() != null) {
DialogImage dialogImage = getSelectedImage();
if (lastColorClicked == 0) {
dialogImage.color = ((SubGuiColorSelector) subgui).color;
} else if (lastColorClicked == 1) {
dialogImage.selectedColor = ((SubGuiColorSelector) subgui).color;
}
initGui();
}
}
save();
}
public void save() {
GuiNpcTextField.unfocus();
if(dialog.id >= 0)
Client.sendData(EnumPacketServer.DialogSave, ((GuiNPCManageDialogs)parent2).category.id, dialog.writeToNBT(new NBTTagCompound()));
}
private DialogImage getSelectedImage() {
if (selected > -1) {
return (DialogImage) dialog.dialogImages.get((dialog.dialogImages.keySet().toArray(new Integer[0]))[selected]);
} else {
return null;
}
}
@Override
public void unFocused(GuiNpcTextField textfield) {
if (activeMenu == 1) {
if (textfield.id == 18) {
dialog.textSound = textfield.getText();
}
if (textfield.id == 19) {
dialog.textPitch = textfield.getFloat();
}
}
if (activeMenu == 2) {
if (textfield.id == 11) {
dialog.textWidth = textfield.getInteger();
}
if (textfield.id == 12) {
dialog.textHeight = textfield.getInteger();
}
if (textfield.id == 13) {
dialog.textOffsetX = textfield.getInteger();
}
if (textfield.id == 14) {
dialog.textOffsetY = textfield.getInteger();
}
if (textfield.id == 15) {
dialog.titleOffsetX = textfield.getInteger();
}
if (textfield.id == 16) {
dialog.titleOffsetY = textfield.getInteger();
}
if (textfield.id == 17) {
dialog.optionOffsetX = textfield.getInteger();
}
if (textfield.id == 18) {
dialog.optionOffsetY = textfield.getInteger();
}
if (textfield.id == 19) {
dialog.optionSpaceX = textfield.getInteger();
}
if (textfield.id == 20) {
dialog.optionSpaceY = textfield.getInteger();
}
if (textfield.id == 21) {
dialog.npcOffsetX = textfield.getInteger();
}
if (textfield.id == 22) {
dialog.npcOffsetY = textfield.getInteger();
}
if (textfield.id == 23) {
dialog.npcScale = textfield.getFloat();
}
}
if (activeMenu == 3) {
DialogImage dialogImage = getSelectedImage();
if (dialogImage == null) {
return;
}
if (textfield.id == 10) {
if (imageScroll.getList().contains(String.valueOf(textfield.getInteger()))) {
textfield.setText(String.valueOf(dialogImage.id));
return;
}
dialog.dialogImages.remove(dialogImage.id);
dialogImage.id = textfield.getInteger();
dialog.dialogImages.put(dialogImage.id, dialogImage);
changedId = dialogImage.id;
updateScrollData();
initGui();
}
if (textfield.id == 11) {
dialogImage.texture = textfield.getText();
}
if (textfield.id == 12) {
dialogImage.x = textfield.getInteger();
}
if (textfield.id == 13) {
dialogImage.y = textfield.getInteger();
}
if (textfield.id == 14) {
dialogImage.width = textfield.getInteger();
}
if (textfield.id == 15) {
dialogImage.height = textfield.getInteger();
}
if (textfield.id == 16) {
dialogImage.textureX = textfield.getInteger();
}
if (textfield.id == 17) {
dialogImage.textureY = textfield.getInteger();
}
if (textfield.id == 20) {
dialogImage.scale = textfield.getFloat();
}
if (textfield.id == 21) {
dialogImage.alpha = textfield.getFloat();
}
if (textfield.id == 22) {
dialogImage.rotation = textfield.getFloat();
}
}
save();
}
@Override
public void customScrollClicked(int i, int j, int k, GuiCustomScroll guiCustomScroll) {
if(guiCustomScroll.id == 0 && imageScroll != null) {
selected = guiCustomScroll.selected;
initGui();
}
}
}
@@ -71,7 +71,7 @@ public class CustomOverlayTexturedRect extends Gui implements IOverlayComponent
float green = (color >> 8 & 255) / 255f;
float blue = (color & 255) / 255f;
GL11.glTranslatef(this.alignment%3*((float)(OverlayCustom.scaledWidth)/2), (float) (Math.floor((float)(alignment/3))*((float)(OverlayCustom.scaledHeight)/2)),0.0F);//alignment%3 * width/2 Math.floor(alignment/3) * height/2
GL11.glTranslatef(this.alignment%3*((float)(OverlayCustom.scaledWidth)/2), (float) (Math.floor((float)(alignment/3))*((float)(OverlayCustom.scaledHeight)/2)),0.0F);
GL11.glScalef(this.scale, this.scale, this.scale);
@@ -7,12 +7,7 @@ import net.minecraft.client.gui.GuiButton;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.client.Client;
import noppes.npcs.client.NoppesUtil;
import noppes.npcs.client.gui.GuiNpcSoundSelection;
import noppes.npcs.client.gui.SubGuiNpcAvailability;
import noppes.npcs.client.gui.SubGuiNpcDialogExtra;
import noppes.npcs.client.gui.SubGuiNpcDialogOptions;
import noppes.npcs.client.gui.SubGuiNpcFactionOptions;
import noppes.npcs.client.gui.SubGuiNpcTextArea;
import noppes.npcs.client.gui.*;
import noppes.npcs.client.gui.util.GuiCustomScroll;
import noppes.npcs.client.gui.util.ICustomScrollListener;
import noppes.npcs.client.gui.util.GuiNPCInterface2;
@@ -35,7 +30,7 @@ public class GuiNPCManageDialogs extends GuiNPCInterface2 implements IScrollData
private GuiCustomScroll scroll;
private HashMap<String,Integer> data = new HashMap<String,Integer>();
private Dialog dialog = new Dialog();
private DialogCategory category = new DialogCategory();
public DialogCategory category = new DialogCategory();
private boolean categorySelection = true;
private GuiNpcSoundSelection gui;
@@ -88,14 +83,17 @@ public class GuiNPCManageDialogs extends GuiNPCInterface2 implements IScrollData
addLabel(new GuiNpcLabel(6, "dialog.options", guiLeft + 4, guiTop + 93));
addButton(new GuiNpcButton(6, guiLeft + 120, guiTop + 89, 50, 20, "selectServer.edit"));
addButton(new GuiNpcButton(7, guiLeft + 4, guiTop + 114, 144, 20, "availability.selectquest"));
addButton(new GuiNpcButton(8, guiLeft + 150, guiTop + 114, 20, 20, "X"));
addLabel(new GuiNpcLabel(11, "dialog.visualOption", guiLeft + 4, guiTop + 115));
addButton(new GuiNpcButton(11, guiLeft + 120, guiTop + 110, 50, 20, "selectServer.edit"));
addLabel(new GuiNpcLabel(9, "gui.selectSound", guiLeft + 4, guiTop + 138));
addTextField(new GuiNpcTextField(2, this, fontRendererObj, guiLeft + 4, guiTop + 148, 144, 20, dialog.sound));
addButton(new GuiNpcButton(9, guiLeft + 150, guiTop + 148, 60, 20, "mco.template.button.select"));
addButton(new GuiNpcButton(7, guiLeft + 4, guiTop + 134, 144, 20, "availability.selectquest"));
addButton(new GuiNpcButton(8, guiLeft + 150, guiTop + 134, 20, 20, "X"));
addButton(new GuiNpcButton(10, guiLeft + 4, guiTop + 172, 120, 20, "gui.showmore"));
addLabel(new GuiNpcLabel(9, "gui.selectSound", guiLeft + 4, guiTop + 158));
addTextField(new GuiNpcTextField(2, this, fontRendererObj, guiLeft + 4, guiTop + 168, 144, 20, dialog.sound));
addButton(new GuiNpcButton(9, guiLeft + 150, guiTop + 168, 60, 20, "mco.template.button.select"));
addButton(new GuiNpcButton(10, guiLeft + 4, guiTop + 192, 120, 20, "gui.showmore"));
}
private void categoryGuiInit() {
@@ -183,6 +181,9 @@ public class GuiNPCManageDialogs extends GuiNPCInterface2 implements IScrollData
if(id == 10){
setSubGui(new SubGuiNpcDialogExtra(dialog, this));
}
if(id == 11){
setSubGui(new SubGuiNpcDialogVisual(dialog, this));
}
}
@Override
@@ -132,10 +132,7 @@ public class GuiNpcDisplay extends GuiNPCInterface2 implements ITextfieldListene
//npc.textureGlowLocation = null;
//display.glowTexture = textfield.getText();
if (!textfield.getText().isEmpty()) {
npc.display.skinOverlayData.overlayList.put(0, new SkinOverlay(
textfield.getText(), true, 1.0F, 1.0F, 0.0F, 0.0F,
1.0F, 1.0F, 0.0F, 0.0F, 0.0F
));
npc.display.skinOverlayData.overlayList.put(0,new SkinOverlay(textfield.getText()));
}
}
else if(textfield.id == 11){
@@ -16,7 +16,7 @@ import noppes.npcs.client.EntityUtil;
import noppes.npcs.client.gui.util.GuiNPCInterface;
import noppes.npcs.client.gui.util.GuiNPCStringSlot;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.entity.EntityCustomNpc;
import noppes.npcs.entity.*;
import org.lwjgl.opengl.GL11;
@@ -115,13 +115,29 @@ public class GuiEntitySelection extends GuiNPCInterface
super.drawScreen(i, j, f);
}
public void elementClicked(){
if (playerdata.getEntityClass().equals(parent.data.get(slot.selected))) {
return;
}
try{
playerdata.setEntityClass(parent.data.get(slot.selected));
EntityLivingBase entity = playerdata.getEntity(npc);
if(entity != null){
npc.display.modelType = 0;
RendererLivingEntity render = (RendererLivingEntity) RenderManager.instance.getEntityRenderObject(entity);
npc.display.texture = NPCRendererHelper.getTexture(render,entity);
if (entity instanceof EntityNpcCrystal) {
npc.display.texture = "customnpcs:textures/entity/crystal/EnderCrystal.png";
} else if (entity instanceof EntityNPCGolem) {
npc.display.texture = "customnpcs:textures/entity/golem/Iron Golem.png";
} else if (entity instanceof EntityNpcPony) {
npc.display.texture = "customnpcs:textures/entity/ponies/MineLP Derpy Hooves.png";
} else if (entity instanceof EntityNpcSlime) {
npc.display.texture = "customnpcs:textures/entity/slime/Slime.png";
} else if (entity instanceof EntityNpcDragon) {
npc.display.texture = "customnpcs:textures/entity/dragon/BlackDragon.png";
} else {
RendererLivingEntity render = (RendererLivingEntity) RenderManager.instance.getEntityRenderObject(entity);
npc.display.texture = NPCRendererHelper.getTexture(render, entity);
}
}
else{
npc.display.texture = "customnpcs:textures/entity/humanmale/Steve.png";
@@ -130,8 +146,7 @@ public class GuiEntitySelection extends GuiNPCInterface
npc.display.skinOverlayData.overlayList.remove(0);
npc.textureLocation = null;
npc.updateHitbox();
}
catch(Exception ex){
} catch(Exception ex) {
npc.display.texture = "customnpcs:textures/entity/humanmale/Steve.png";
}
}
@@ -0,0 +1,107 @@
package noppes.npcs.client.gui.player;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.texture.ITextureObject;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.util.ResourceLocation;
import noppes.npcs.client.ImageDownloadAlt;
import noppes.npcs.client.gui.customoverlay.OverlayCustom;
import noppes.npcs.client.renderer.ImageBufferDownloadAlt;
import noppes.npcs.controllers.data.DialogImage;
import org.lwjgl.opengl.GL11;
public class GuiDialogImage extends Gui {
GuiDialogInteract parent;
ResourceLocation location;
public int id;
public String texture;
public int x;
public int y;
public int width;
public int height;
public int textureX;
public int textureY;
public float scale;
public int color;
public int selectedColor;
public float alpha;
public float rotation;
public int imageType = 0; //0 - Default, 1 - Text, 2 - Option
public int alignment = 0;
public GuiDialogImage(DialogImage dialogImage) {
this.location = new ResourceLocation(dialogImage.texture);
this.id = dialogImage.id;
this.texture = dialogImage.texture;
this.x = dialogImage.x;
this.y = dialogImage.y;
this.width = dialogImage.width;
this.height = dialogImage.height;
this.textureX = dialogImage.textureX;
this.textureY = dialogImage.textureY;
this.scale = dialogImage.scale;
this.color = dialogImage.color;
this.selectedColor = dialogImage.selectedColor;
this.rotation = dialogImage.rotation;
this.alpha = dialogImage.alpha;
this.imageType = dialogImage.imageType;
this.alignment = dialogImage.alignment;
if(texture.startsWith("https://")){
TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager();
ITextureObject object = new ImageDownloadAlt(null, texture, new ResourceLocation("customnpcs:textures/gui/invisible.png"), new ImageBufferDownloadAlt(true,false));
texturemanager.loadTexture(this.location, object);
}
}
public void setParent(GuiDialogInteract parent) {
this.parent = parent;
}
public int getID() {
return this.id;
}
public void onRender(Minecraft mc) {
try {
mc.getTextureManager().bindTexture(this.location);
} catch (Exception ignored) { return; }
GL11.glPushMatrix();
float red = (color >> 16 & 255) / 255f;
float green = (color >> 8 & 255) / 255f;
float blue = (color & 255) / 255f;
GL11.glColor4f(red,green,blue,this.alpha);
GL11.glRotatef(this.rotation,0.0F,0.0F,1.0F);
GL11.glScalef(this.scale, this.scale, this.scale);
int p_73729_1_ = (int) (this.x/(this.scale));
int p_73729_2_ = (int) (this.y/(this.scale));
int p_73729_3_ = this.textureX;
int p_73729_4_ = this.textureY;
int p_73729_5_ = (int)(this.width);
int p_73729_6_ = (int)(this.height);
float f = 0.00390625F;
float f1 = 0.00390625F;
Tessellator tessellator = Tessellator.instance;
tessellator.startDrawingQuads();
tessellator.setColorOpaque_F(1, 1, 1);
tessellator.setColorRGBA_F(red, green, blue, alpha);
tessellator.addVertexWithUV((double)(p_73729_1_ + 0), (double)(p_73729_2_ + p_73729_6_), (double)this.zLevel, (double)((float)(p_73729_3_ + 0) * f), (double)((float)(p_73729_4_ + p_73729_6_) * f1));
tessellator.addVertexWithUV((double)(p_73729_1_ + p_73729_5_), (double)(p_73729_2_ + p_73729_6_), (double)this.zLevel, (double)((float)(p_73729_3_ + p_73729_5_) * f), (double)((float)(p_73729_4_ + p_73729_6_) * f1));
tessellator.addVertexWithUV((double)(p_73729_1_ + p_73729_5_), (double)(p_73729_2_ + 0), (double)this.zLevel, (double)((float)(p_73729_3_ + p_73729_5_) * f), (double)((float)(p_73729_4_ + 0) * f1));
tessellator.addVertexWithUV((double)(p_73729_1_ + 0), (double)(p_73729_2_ + 0), (double)this.zLevel, (double)((float)(p_73729_3_ + 0) * f), (double)((float)(p_73729_4_ + 0) * f1));
tessellator.draw();
GL11.glPopMatrix();
}
}
@@ -4,7 +4,9 @@ import java.util.ArrayList;
import java.util.List;
import net.minecraft.client.Minecraft;
import net.minecraft.client.audio.PositionedSoundRecord;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.entity.RenderManager;
@@ -22,9 +24,11 @@ import noppes.npcs.client.gui.util.IGuiClose;
import noppes.npcs.constants.EnumOptionType;
import noppes.npcs.constants.EnumPlayerPacket;
import noppes.npcs.controllers.data.Dialog;
import noppes.npcs.controllers.data.DialogImage;
import noppes.npcs.controllers.data.DialogOption;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.scripted.interfaces.handler.data.IDialogImage;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
@@ -34,21 +38,38 @@ public class GuiDialogInteract extends GuiNPCInterface implements IGuiClose
{
private Dialog dialog;
private int selected = 0;
private List<TextBlockClient> lines = new ArrayList<TextBlockClient>();
private List<TextBlockClient> lineBlocks = new ArrayList<TextBlockClient>();
private List<Integer> options = new ArrayList<Integer>();
private int rowStart = 0;
private int rowTotal = 0;
private int dialogHeight = 180;
private int totalRows = 0;
private ScaledResolution scaledResolution;
private String gradualText = "";
private int currentBlock = 0;
private int currentLine = 0;
private int gradualTextTime = 0;
private int optionStart = 0;
private int instantBlockPos = 0;
private int instantLinePos = 0;
private int prevPausePos = -1;
private static int textSpeed = 10;
private static boolean textSoundEnabled = true;
private int scrollY;
private ResourceLocation wheel;
private ResourceLocation[] wheelparts;
private ResourceLocation indicator;
private boolean isGrabbed = false;
private int textSoundTime = 0;
private int textPauseTime = 0;
public GuiDialogInteract(EntityNPCInterface npc, Dialog dialog){
super(npc);
this.dialog = dialog;
appendDialog(dialog);
ySize = 238;
@@ -57,16 +78,19 @@ public class GuiDialogInteract extends GuiNPCInterface implements IGuiClose
wheelparts = new ResourceLocation[]{getResource("wheel1.png"),getResource("wheel2.png"),getResource("wheel3.png"),
getResource("wheel4.png"),getResource("wheel5.png"),getResource("wheel6.png")};
}
public void initGui(){
super.initGui();
isGrabbed = false;
grabMouse(dialog.showWheel);
guiTop = (height - ySize);
calculateRowHeight();
this.scaledResolution = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
this.drawDefaultBackground = dialog.darkenScreen;
optionStart = scaledResolution.getScaledHeight() - (options.size()) * (ClientProxy.Font.height() + dialog.optionSpaceY) - 20;
}
public void grabMouse(boolean grab){
if(grab && !isGrabbed){
Minecraft.getMinecraft().mouseHelper.grabMouseCursor();
@@ -77,16 +101,16 @@ public class GuiDialogInteract extends GuiNPCInterface implements IGuiClose
isGrabbed = false;
}
}
public void drawScreen(int i, int j, float f){
GL11.glColor4f(1, 1, 1, 1);
if(!dialog.hideNPC){
float l = (guiLeft - 70);
float i1 = (guiTop + ySize);
GL11.glEnable(GL11.GL_COLOR_MATERIAL);
GL11.glPushMatrix();
GL11.glTranslatef(l, i1, 50F);
GL11.glTranslatef(l + dialog.npcOffsetX, i1 + dialog.npcOffsetY, 50F);
float zoomed = npc.height;
if(npc.width * 2 > zoomed)
zoomed = npc.width * 2;
@@ -111,12 +135,12 @@ public class GuiDialogInteract extends GuiNPCInterface implements IGuiClose
npc.prevRotationYawHead = npc.rotationYawHead = npc.rotationYaw;
GL11.glTranslatef(0.0F, npc.yOffset, 0.0F);
RenderManager.instance.playerViewY = 180F;
try{
GL11.glScalef(dialog.npcScale,dialog.npcScale,dialog.npcScale);
RenderManager.instance.renderEntityWithPosYaw(npc, 0.0D, 0.0D, 0.0D, 0.0F, 1.0F);
}
catch(Exception e){
}
} catch(Exception ignored){}
npc.ai.orientation = rotation;
npc.renderYawOffset = f2;
npc.rotationYaw = f3;
@@ -134,44 +158,227 @@ public class GuiDialogInteract extends GuiNPCInterface implements IGuiClose
GL11.glEnable(GL11.GL_BLEND);
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
GL11.glEnable(GL11.GL_ALPHA_TEST);
GL11.glPushMatrix();
GL11.glTranslatef(0.0F, 0.5f, 100.065F);
int count = 0;
for(TextBlockClient block : lines){
int size = ClientProxy.Font.width(block.getName() + ": ");
drawString(block.getName() + ": ", -4 - size, block.color, count);
for(IChatComponent line : block.lines){
drawString(line.getFormattedText(), 0, block.color, count);
count++;
}
count++;
}
if(!options.isEmpty()){
if(!dialog.showWheel)
drawLinedOptions(j);
else
drawWheel();
}
GL11.glTranslatef(0.0F, 0.5f, 100.065F);
if (dialog.renderGradual) {
drawString(fontRendererObj, "Text Speed: " + textSpeed, 10, 10, 0xFFFFFF);
drawString(fontRendererObj, "Text Sound: " + (textSoundEnabled ? "On" : "Off"), 10, 20, 0xFFFFFF);
}
for (IDialogImage dialogImage : dialog.dialogImages.values()) {
GuiDialogImage image = new GuiDialogImage((DialogImage) dialogImage);
if (image.imageType != 0)
continue;
GL11.glEnable(GL11.GL_BLEND);
OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0);
GL11.glDisable(GL11.GL_ALPHA_TEST);
GL11.glTranslatef(image.alignment%3*((float)(scaledResolution.getScaledWidth())/2), (float) (Math.floor((float)(image.alignment/3))*((float)(scaledResolution.getScaledHeight())/2)),0.0F);
image.onRender(mc);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_ALPHA_TEST);
}
GL11.glPushMatrix();
for (IDialogImage dialogImage : dialog.dialogImages.values()) {
GuiDialogImage image = new GuiDialogImage((DialogImage) dialogImage);
if (image.imageType != 1)
continue;
GL11.glEnable(GL11.GL_BLEND);
OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0);
GL11.glDisable(GL11.GL_ALPHA_TEST);
GL11.glTranslatef(guiLeft + dialog.textOffsetX, optionStart + dialog.textOffsetY - image.height * image.scale, 0.0F);
image.onRender(mc);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_ALPHA_TEST);
}
GL11.glPopMatrix();
if (!dialog.renderGradual) {
int count = 0;
blockLoop:
for (int b = 0; b < lineBlocks.size(); b++) {
TextBlockClient block = lineBlocks.get(b);
int size = ClientProxy.Font.width(block.getName() + " ");
drawDialogString(block.getName() + " ", -4 - size, count, false, block);
for (int l = 0; l < block.lines.size(); l++) {
IChatComponent line = block.lines.get(l);
String drawText = line.getFormattedText();
if (b >= instantBlockPos && l >= instantLinePos) {
if (drawText.matches("(.*)(\\{(\\d+)})(.*)")) {
if (textPauseTime > 0) {
drawText = drawText.substring(0, prevPausePos);
drawDialogString(drawText, 0, count, true, block);
textPauseTime--;
break blockLoop;
}
String strInt = "";
for (int c = 0; c < drawText.length(); c++) {
if (drawText.substring(c).matches("^(\\{(\\d+)})(.*)") && c > prevPausePos) {
prevPausePos = c;
strInt += drawText.charAt(++c);
} else if (c > prevPausePos && !strInt.isEmpty()) {
if (drawText.charAt(c) == '}')
break;
strInt += drawText.charAt(c);
}
}
if (!strInt.isEmpty()) {
drawText = drawText.substring(0, prevPausePos);
drawDialogString(drawText, 0, count, true, block);
instantBlockPos = b;
instantLinePos = l;
textPauseTime = Integer.parseInt(strInt);
break blockLoop;
}
} else {
prevPausePos = -1;
}
}
drawDialogString(drawText, 0, count, true, block);
count++;
}
count++;
}
} else {
int count = 0;
for (int pastBlock = 0; pastBlock < currentBlock; pastBlock++) {
TextBlockClient block = lineBlocks.get(pastBlock);
int size = ClientProxy.Font.width(block.getName() + " ");
drawDialogString(block.getName() + " ", -4 - size, count, false, block);
for (IChatComponent line : block.lines) {
drawDialogString(line.getFormattedText(), 0, count, true, block);
count++;
}
count++;
}
if (currentBlock < lineBlocks.size()) {
TextBlockClient block = lineBlocks.get(currentBlock);
int size = ClientProxy.Font.width(block.getName() + " ");
drawDialogString(block.getName() + " ", -4 - size, count, false, block);
for (int pastLine = 0; pastLine < currentLine; pastLine++) {
IChatComponent line = block.lines.get(pastLine);
drawDialogString(line.getFormattedText(), 0, count, true, block);
count++;
}
if (currentLine < block.lines.size()) {
IChatComponent line = block.lines.get(currentLine);
try {
if (textPauseTime > 0) {
textPauseTime--;
} else if (textSpeed > 10 || gradualTextTime%(11 - textSpeed) == 0) {
int addChar = textSpeed > 10 ? textSpeed - 9 : 1;
String addText = line.getFormattedText().substring(gradualText.length(), gradualText.length() + addChar);
if (addText.matches("^(\\{(\\d+)})(.*)")) {
StringBuilder numStr = new StringBuilder();
int numLength;
for (numLength = 1; numLength < addText.length(); numLength++) {
if (addText.charAt(numLength) == '}')
break;
numStr.append(addText.charAt(numLength));
}
textPauseTime = Integer.parseInt(numStr.toString());
addText = line.getFormattedText().substring(gradualText.length(), gradualText.length() + numLength + 1);
} else if (addText.matches("(.+)\\{(\\d+)(.*)")) {
StringBuilder str = new StringBuilder();
for (char c : addText.toCharArray()) {
if (c == '{')
break;
str.append(c);
}
addText = str.toString();
} else if (addText.matches("(\\{(\\d+))$") || addText.equals("{")) {
do {
if (addText.length() == gradualText.length() + addText.length() + 1)
break;
addText += line.getFormattedText().substring(gradualText.length() + addText.length(), gradualText.length() + addText.length() + 1);
} while (addText.matches("(.*)(\\{(\\d+))$"));
textPauseTime = Integer.parseInt(addText.replace("{","").replace("}",""));
}
gradualText += addText;
if (textSoundTime % 5 == 0) {
Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation(dialog.textSound), dialog.textPitch));
}
textSoundTime++;
}
} catch (IndexOutOfBoundsException exception) {
gradualText = line.getFormattedText();
}
drawDialogString(gradualText, 0, count, true, block);
if (gradualText.length() == line.getFormattedText().length()) {
gradualText = "";
currentLine++;
if (currentLine >= lineBlocks.get(currentBlock).lines.size()) {
currentBlock++;
}
}
gradualTextTime++;
}
}
}
GL11.glPopMatrix();
GL11.glPushMatrix();
if (!options.isEmpty()) {
if (!dialog.showWheel) {
GL11.glTranslatef(dialog.optionOffsetX, dialog.optionOffsetY, 0);
drawLinedOptions(j);
} else {
drawWheel();
}
}
GL11.glPopMatrix();
}
private int selectedX = 0;
private int selectedY = 0;
private void drawWheel(){
int yoffset = guiTop + dialogHeight + 14;
int yoffset = optionStart + dialog.optionOffsetY;
GL11.glColor4f(1, 1, 1, 1);
mc.renderEngine.bindTexture(wheel);
drawTexturedModalRect((width/2) - 31, yoffset, 0, 0, 63, 40);
selectedX += Mouse.getDX();
drawTexturedModalRect((width/2) - 31 + dialog.optionOffsetX, yoffset, 0, 0, 63, 40);
selectedX += Mouse.getDX();
selectedY += Mouse.getDY();
int limit = 80;
if(selectedX > limit)
selectedX = limit;
if(selectedX < -limit)
selectedX = -limit;
if(selectedY > limit)
selectedY = limit;
if(selectedY < -limit)
@@ -182,89 +389,167 @@ public class GuiDialogInteract extends GuiNPCInterface implements IGuiClose
selected++;
if(selectedY > 54)
selected--;
if(selectedX < 0)
selected += 3;
mc.renderEngine.bindTexture(wheelparts[selected]);
drawTexturedModalRect((width/2) - 31,yoffset, 0, 0, 85, 55);
drawTexturedModalRect((width/2) - 31 + dialog.optionOffsetX,yoffset, 0, 0, 85, 55);
for(int slot:dialog.options.keySet()){
DialogOption option = dialog.options.get(slot);
if(option == null || option.optionType == EnumOptionType.Disabled)
continue;
int color = option.optionColor;
int color = option.optionColor;
if(slot == (selected))
color = 0x838FD8;
//drawString(fontRenderer, option.title, width/2 -50 ,yoffset+ 162 + slot * 13 , color);
if(slot == 0)
drawString(fontRendererObj, option.title, width/2 + 13,yoffset - 6 , color);
drawString(fontRendererObj, option.title, width/2 + 13 + dialog.optionOffsetX,yoffset - 6 , color);
if(slot == 1)
drawString(fontRendererObj, option.title, width/2 + 33,yoffset + 12 , color);
drawString(fontRendererObj, option.title, width/2 + 33 + dialog.optionOffsetX,yoffset + 12 , color);
if(slot == 2)
drawString(fontRendererObj, option.title, width/2 + 27,yoffset + 32 , color);
drawString(fontRendererObj, option.title, width/2 + 27 + dialog.optionOffsetX,yoffset + 32 , color);
if(slot == 3)
drawString(fontRendererObj, option.title, width/2 - 13 - ClientProxy.Font.width(option.title),yoffset - 6 , color);
drawString(fontRendererObj, option.title, width/2 - 13 + dialog.optionOffsetX - ClientProxy.Font.width(option.title),yoffset - 6 , color);
if(slot == 4)
drawString(fontRendererObj, option.title, width/2 - 33 - ClientProxy.Font.width(option.title),yoffset + 12 , color);
drawString(fontRendererObj, option.title, width/2 - 33 + dialog.optionOffsetX - ClientProxy.Font.width(option.title),yoffset + 12 , color);
if(slot == 5)
drawString(fontRendererObj, option.title, width/2 - 27 - ClientProxy.Font.width(option.title),yoffset + 32 , color);
drawString(fontRendererObj, option.title, width/2 - 27 + dialog.optionOffsetX - ClientProxy.Font.width(option.title),yoffset + 32 , color);
}
mc.renderEngine.bindTexture(indicator);
drawTexturedModalRect(width/2 + selectedX/4 - 2,yoffset + 16 - selectedY/6, 0, 0, 8, 8);
drawTexturedModalRect(width/2 + selectedX/4 - 2 + dialog.optionOffsetX,yoffset + 16 - selectedY/6, 0, 0, 8, 8);
}
private void drawLinedOptions(int j){
drawHorizontalLine(guiLeft - 60, guiLeft + xSize + 120, guiTop + dialogHeight, 0xFFFFFFFF);
int offset = dialogHeight + 4;
if(j >= (int)((guiTop + offset))){
int selected = (int) ((j - (guiTop + offset)) / (ClientProxy.Font.height()));
int offset = optionStart;
if(j >= offset){
int selected = (j - offset - ClientProxy.Font.height() - dialog.optionOffsetY) / (ClientProxy.Font.height() + dialog.optionSpaceY);
if(selected < options.size())
this.selected = selected;
}
if(selected >= options.size())
selected = 0;
selected = options.size() - 1;
if(selected < 0)
selected = 0;
int count = 0;
if (dialog.showOptionLine) {
drawHorizontalLine(guiLeft - 60, guiLeft + xSize + 120, offset, 0xFFFFFFFF);
}
for(int k = 0; k < options.size(); k++){
GL11.glPushMatrix();
int id = options.get(k);
DialogOption option = dialog.options.get(id);
int y = (int)((guiTop + offset + (count * ClientProxy.Font.height())));
int y = offset + (k + 1) * ClientProxy.Font.height();
offset += dialog.optionSpaceY;
if(selected == k){
drawString(fontRendererObj, ">", guiLeft - 60, y, 0xe0e0e0);
}
drawString(fontRendererObj, NoppesStringUtils.formatText(option.title, player, npc), guiLeft - 30, y, option.optionColor);
count++;
}
}
private void drawString(String text, int left, int color, int count){
int height = count - rowStart;
drawString(fontRendererObj, text, guiLeft + left, guiTop + (height * ClientProxy.Font.height()), color);
GL11.glPushMatrix();
for (IDialogImage dialogImage : dialog.dialogImages.values()) {
GuiDialogImage image = new GuiDialogImage((DialogImage) dialogImage);
if (image.imageType != 2)
continue;
GL11.glEnable(GL11.GL_BLEND);
OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0);
GL11.glDisable(GL11.GL_ALPHA_TEST);
GL11.glTranslatef(guiLeft - 30 + dialog.optionSpaceX * k, y, 0.0F);
image.color = selected == k ? image.selectedColor : image.color;
image.onRender(mc);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_ALPHA_TEST);
}
GL11.glPopMatrix();
drawString(fontRendererObj, NoppesStringUtils.formatText(option.title, player, npc), guiLeft - 30 + dialog.optionSpaceX * k, y, option.optionColor);
GL11.glPopMatrix();
}
}
private void drawDialogString(String text, int left, int count, boolean mainDialogText, TextBlockClient block){
int lineOffset = dialog.renderGradual ? (currentBlock < lineBlocks.size() ? lineBlocks.get(currentBlock).lines.size() : lineBlocks.get(lineBlocks.size()-1).lines.size()) - currentLine : 0;
int height = count - totalRows + lineOffset;
int screenPos = optionStart;
int y = (height * ClientProxy.Font.height()) + screenPos + scrollY;
if (block.titlePos == 0 || mainDialogText) {
if (y < screenPos - dialog.textHeight || y > screenPos - ClientProxy.Font.height()) {
return;
}
}
int offsetX, offsetY, color;
if (mainDialogText) {
offsetX = dialog.textOffsetX;
offsetY = dialog.textOffsetY;
color = block.color;
} else {
offsetX = dialog.titleOffsetX;
offsetY = dialog.titleOffsetY;
color = block.titleColor;
if (block.titlePos == 1 && block.equals(lineBlocks.get(currentBlock < lineBlocks.size() ? currentBlock : currentBlock - 1))) {
y = screenPos - ClientProxy.Font.height() - 5;
}
}
text = text.replaceAll("\\{(\\d+)}","");
if (!mainDialogText && block.titlePos == 2 && block.equals(lineBlocks.get(currentBlock < lineBlocks.size() ? currentBlock : currentBlock - 1))) {
drawString(fontRendererObj, text, offsetX, offsetY, color);
} else {
drawString(fontRendererObj, text, guiLeft + left + offsetX, y + offsetY, color);
}
}
public void drawString(FontRenderer fontRendererIn, String text, int x, int y, int color){
ClientProxy.Font.drawString(text, x, y, color);
//super.drawString(fontRendererIn, text, x, y, color);
}
private int getSelected(){
if(selected <= 0)
return 0;
if(selected < options.size())
return selected;
return options.size() - 1;
}
@Override
public void keyTyped(char c, int i){
if(i == mc.gameSettings.keyBindForward.getKeyCode() || i == Keyboard.KEY_UP){
selected--;
if (dialog.showWheel) {
selected--;
} else {
selected++;
}
}
if(i == mc.gameSettings.keyBindBack.getKeyCode() || i == Keyboard.KEY_DOWN){
selected++;
if (dialog.showWheel) {
selected++;
} else {
selected--;
}
}
if(i == mc.gameSettings.keyBindForward.getKeyCode() || i == Keyboard.KEY_LEFT){
textSpeed--;
if (textSpeed < 1) {
textSpeed = 1;
}
}
if(i == mc.gameSettings.keyBindBack.getKeyCode() || i == Keyboard.KEY_RIGHT){
textSpeed++;
}
if(i == mc.gameSettings.keyBindJump.getKeyCode() || i == Keyboard.KEY_SPACE){
textSoundEnabled = !textSoundEnabled;
}
if (i == mc.gameSettings.keyBindBack.getKeyCode() || i == 201 && scrollY < (totalRows - 2) * ClientProxy.Font.height()) {//Page up
scrollY += ClientProxy.Font.height() * 2;
}
if (i == mc.gameSettings.keyBindBack.getKeyCode() || i == 209 && scrollY > 0) {//Page down
scrollY -= ClientProxy.Font.height() * 2;
}
if(i == 28){
handleDialogSelection();
}
@@ -278,8 +563,10 @@ public class GuiDialogInteract extends GuiNPCInterface implements IGuiClose
@Override
public void mouseClicked(int i,int j,int k){
if(selected == -1 && options.isEmpty() || selected >= 0)
handleDialogSelection();
if(selected == -1 && options.isEmpty() || selected >= 0) {
scrollY = 0;
handleDialogSelection();
}
}
private void handleDialogSelection(){
int optionId = -1;
@@ -299,20 +586,31 @@ public class GuiDialogInteract extends GuiNPCInterface implements IGuiClose
close();
return;
}
lines.add(new TextBlockClient(player.getDisplayName(), option.title, 280, option.optionColor, player, npc));
if (!dialog.showPreviousBlocks) {
lineBlocks.clear();
}
lineBlocks.add(new TextBlockClient(player.getDisplayName(), option.title, dialog.textWidth, option.optionColor, player, npc));
gradualText = "";
currentBlock = lineBlocks.size()-1;
currentLine = 0;
gradualTextTime = 0;
instantBlockPos = lineBlocks.size()-1;
instantLinePos = 0;
calculateRowHeight();
textPauseTime = 0;
NoppesUtil.clickSound();
}
private void closed(){
grabMouse(false);
NoppesUtilPlayer.sendData(EnumPlayerPacket.CheckQuestCompletion);
}
public void save() {
}
public void appendDialog(Dialog dialog) {
@@ -324,38 +622,31 @@ public class GuiDialogInteract extends GuiNPCInterface implements IGuiClose
MusicController.Instance.stopMusic();
MusicController.Instance.playSound(dialog.sound, (float)npc.posX, (float)npc.posY, (float)npc.posZ);
}
lines.add(new TextBlockClient(npc, dialog.text, 280, 0xe0e0e0, player, npc));
for(int slot:dialog.options.keySet()){
if (!dialog.showPreviousBlocks) {
lineBlocks.clear();
}
lineBlocks.add(new TextBlockClient(npc, dialog, player, npc));
gradualText = "";
currentBlock = lineBlocks.size()-1;
currentLine = 0;
gradualTextTime = 0;
for(int slot:dialog.options.keySet()){
DialogOption option = dialog.options.get(slot);
if(option == null || option.optionType == EnumOptionType.Disabled)
continue;
options.add(slot);
}
calculateRowHeight();
}
calculateRowHeight();
grabMouse(dialog.showWheel);
grabMouse(dialog.showWheel);
}
private void calculateRowHeight(){
if(dialog.showWheel){
dialogHeight = ySize - 58;
}
else{
dialogHeight = ySize - 3 * ClientProxy.Font.height() - 4;
if(dialog.options.size() > 3){
dialogHeight -= (dialog.options.size() - 3) * ClientProxy.Font.height();
}
}
rowTotal = 0;
for(TextBlockClient block : lines){
rowTotal += block.lines.size() + 1;
totalRows = 0;
for(TextBlockClient block : lineBlocks){
totalRows += block.lines.size() + 1;
}
int max = dialogHeight / ClientProxy.Font.height();
rowStart = rowTotal - max;
if(rowStart < 0)
rowStart = 0;
}
@Override
@@ -43,6 +43,10 @@ public class GuiNpcTextField extends GuiTextField{
private boolean charAllowed(char c, int i){
if(!integersOnly || Character.isDigit(c))
return true;
if(integersOnly && getText().isEmpty() && c == '-')
return true;
for(int j : allowedSpecialChars)
if(j == i)
return true;
@@ -64,6 +64,7 @@ public class ModelMPM extends ModelNPCMale{
public boolean currentlyPlayerTexture;
public boolean isArmor;
public boolean isAlexArmor;
public float alpha = 1;
// Steve 64x64 and Alex 64x64
@@ -198,6 +199,10 @@ public class ModelMPM extends ModelNPCMale{
super(par1);
isArmor = par1 > 0;
if (isArmor && alexArms == 1) {
isAlexArmor = true;
}
float par2 = 0;
this.bipedCloak = new ModelRenderer(this, 0, 0);
@@ -230,12 +235,18 @@ public class ModelMPM extends ModelNPCMale{
this.bipedLeftArm.setRotationPoint(5.0F, 2.0F + par2, 0.0F);
} else {
this.bipedRightArm = (new ModelScaleRenderer(this, 40, 16));
this.bipedRightArm.addBox(-2.0F, -2.0F, -2.0F, 3, 12, 4, par1);
this.bipedLeftArm = new ModelScaleRenderer(this, 40, 16);
this.bipedLeftArm.mirror = true;
this.bipedLeftArm.addBox(-1.0F, -2.0F, -2.0F, 3, 12, 4, par1);
this.bipedLeftArm.setRotationPoint(5.0F, 2.5F + par2, 0.0F);
if (isArmor) {
this.bipedLeftArm.setRotationPoint(5.0F, 2.5F + par2, 0.0F);
this.bipedRightArm.addBox(-4.5F, -2.0F, -2.0F, 4, 12, 4, par1);
this.bipedLeftArm.addBox(0.25F, -2.0F, -2.0F, 4, 12, 4, par1);
} else {
this.bipedLeftArm.setRotationPoint(5.0F, 2.5F + par2, 0.0F);
this.bipedRightArm.addBox(-2.0F, -2.0F, -2.0F, 3, 12, 4, par1);
this.bipedLeftArm.addBox(-1.0F, -2.0F, -2.0F, 3, 12, 4, par1);
}
}
this.bipedRightLeg = new ModelScaleRenderer(this, 0, 16);
@@ -598,6 +609,10 @@ public class ModelMPM extends ModelNPCMale{
GL11.glPushMatrix();
if (isAlexArmor) {
GL11.glScalef(0.75F,1.0F,1.0F);
}
if(entity.currentAnimation == EnumAnimation.DANCING){
float dancing = entity.ticksExisted / 4f;
GL11.glTranslatef((float)Math.sin(dancing) * 0.025F, (float)Math.abs(Math.cos(dancing)) * 0.125F - 0.02F, 0.0F);
@@ -45,7 +45,7 @@ public class RenderCNPCPlayer extends RenderPlayer {
this.setRenderManager(RenderManager.instance);
}
private boolean preRenderOverlay(EntityPlayer player, ResourceLocation overlayLocation, boolean glow,
private boolean preRenderOverlay(EntityPlayer player, ResourceLocation overlayLocation, boolean glow, boolean blend,
float alpha, float size, float speedX, float speedY, float scaleX, float scaleY,
float offsetX, float offsetY, float offsetZ) {
if (overlayLocation.getResourcePath().isEmpty())
@@ -67,7 +67,11 @@ public class RenderCNPCPlayer extends RenderPlayer {
// Overlay & Glow
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
if (blend) {
GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE);
} else {
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
}
GL11.glAlphaFunc(GL11.GL_GREATER, 0.003921569F);
if (glow) {
@@ -127,7 +131,7 @@ public class RenderCNPCPlayer extends RenderPlayer {
}
}
if (!preRenderOverlay(player, overlayData.location, overlayData.glow, overlayData.alpha, overlayData.size,
if (!preRenderOverlay(player, overlayData.location, overlayData.glow, overlayData.blend, overlayData.alpha, overlayData.size,
overlayData.speedX, overlayData.speedY, overlayData.scaleX, overlayData.scaleY,
overlayData.offsetX, overlayData.offsetY, overlayData.offsetZ
))
@@ -330,7 +334,7 @@ public class RenderCNPCPlayer extends RenderPlayer {
}
}
if (!preRenderOverlay(player, overlayData.location, overlayData.glow, overlayData.alpha, overlayData.size,
if (!preRenderOverlay(player, overlayData.location, overlayData.glow, overlayData.blend, overlayData.alpha, overlayData.size,
overlayData.speedX, overlayData.speedY, overlayData.scaleX, overlayData.scaleY,
overlayData.offsetX, overlayData.offsetY, overlayData.offsetZ
))
@@ -628,7 +632,7 @@ public class RenderCNPCPlayer extends RenderPlayer {
int j = 5095183;
h1 = 1.0F;
////renderPlayerJBRA.getMethod("glColor3f",int.class).invoke(null,bodycm);
ModelBipedDBC.getMethod("renderHairs",float.class,String.class).invoke(modelMain,0.0625F,"N");
//ModelBipedDBC.getMethod("renderHairs",float.class,String.class).invoke(modelMain,0.0625F,"N");
////renderPlayerJBRA.getMethod("glColor3f",int.class).invoke(null,bodycm);
ModelBipedDBC.getMethod("renderBody",float.class).invoke(modelMain,0.0625F);
@@ -660,7 +664,7 @@ public class RenderCNPCPlayer extends RenderPlayer {
short TransFrHrn = ((short[]) JRMCoreH.getField("TransFrHrn").get(null))[st];
ModelBipedDBC.getMethod("renderHairs",float.class,String.class).invoke(modelMain,0.0625F,(ts == 4 ? "n" : "") + "FR" + TransFrHrn);
//ModelBipedDBC.getMethod("renderHairs",float.class,String.class).invoke(modelMain,0.0625F,(ts == 4 ? "n" : "") + "FR" + TransFrHrn);
//renderPlayerJBRA.getMethod("glColor3f",int.class).invoke(null,bodyc1);
//ModelBipedDBC.getMethod("renderHairs",float.class,String.class).invoke(modelMain,0.0625F,(ts == 4 ? "n" : "") + "FR" + TransFrHrn);
@@ -784,7 +788,7 @@ public class RenderCNPCPlayer extends RenderPlayer {
}
//renderPlayerJBRA.getMethod("glColor3f",int.class).invoke(null,maxBody);
ModelBipedDBC.getMethod("renderHairs",float.class,String.class).invoke(modelMain,0.0625F,ts != 0 && ts != -1 ? (ts == 1 ? "SJT2" : "") : "SJT1");
//ModelBipedDBC.getMethod("renderHairs",float.class,String.class).invoke(modelMain,0.0625F,ts != 0 && ts != -1 ? (ts == 1 ? "SJT2" : "") : "SJT1");
}
h1 = 1.0F;
@@ -37,7 +37,9 @@ public class RenderNPCHumanMale extends RenderNPCInterface
protected final static ModelMPM steve64 = new ModelMPM(0, false);
protected final static ModelMPM alex = new ModelMPM(0, true);
protected final static ModelMPM alex32mainmodel = new ModelMPM(0,1);
protected final static ModelMPM steveArmorChest = new ModelMPM(1,0);
protected final static ModelMPM steveArmor = new ModelMPM(0.5F,0);
protected final static ModelMPM alex32armorChest = new ModelMPM(1,1);
protected final static ModelMPM alex32armor = new ModelMPM(0.5F,1);
@@ -119,28 +121,17 @@ public class RenderNPCHumanMale extends RenderNPCInterface
EntityCustomNpc test = (EntityCustomNpc) npc;
if(test.modelData.entityClass == null){
int modelVal = npc.display.modelType;
if(modelVal == 1 && npc.display.x64texture){
if(modelVal == 1){
this.mainModel = steve64;
this.modelBipedMain = steve64;
this.modelArmorChestplate = steveArmorChest;
this.modelArmor = steveArmor;
}
else if(modelVal == 2){
if (npc.display.x64texture) {
this.mainModel = alex;
this.modelBipedMain = alex;
} else {
((EntityCustomNpc) npc).modelData.bodywear = 0;
((EntityCustomNpc) npc).modelData.armwear = 0;
((EntityCustomNpc) npc).modelData.legwear = 0;
this.mainModel = alex32mainmodel;
this.modelBipedMain = alex32mainmodel;
}
}
else if(modelVal == 3){
((EntityCustomNpc) npc).modelData.bodywear = 0;
((EntityCustomNpc) npc).modelData.armwear = 0;
((EntityCustomNpc) npc).modelData.legwear = 0;
this.mainModel = alex32mainmodel;
this.modelBipedMain = alex32mainmodel;
this.mainModel = alex;
this.modelBipedMain = alex;
this.modelArmorChestplate = alex32armorChest;
this.modelArmor = alex32armor;
}
else{
((EntityCustomNpc) npc).modelData.bodywear = 0;
@@ -148,6 +139,8 @@ public class RenderNPCHumanMale extends RenderNPCInterface
((EntityCustomNpc) npc).modelData.legwear = 0;
this.mainModel = originalModel;
this.modelBipedMain = originalBipedMain;
this.modelArmorChestplate = steveArmorChest;
this.modelArmor = steveArmor;
}
}
}
@@ -243,7 +243,11 @@ public class RenderNPCInterface extends RenderLiving{
// Overlay & Glow
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
if (overlayData.getBlend()) {
GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE);
} else {
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
}
GL11.glAlphaFunc(GL11.GL_GREATER, 0.003921569F);
if (overlayData.getGlow()) {
@@ -309,11 +313,16 @@ public class RenderNPCInterface extends RenderLiving{
EntityNPCInterface npc = (EntityNPCInterface) entity;
if (npc.textureLocation == null) {
if (npc.display.skinType == 0) {
if (!(npc.display.texture).equals("")) {
//npc.textureLocation = new ResourceLocation(npc.display.texture);
try {
npc.textureLocation = adjustLocalTexture(npc, new ResourceLocation(npc.display.texture));
} catch (IOException ignored) {}
if (npc instanceof EntityCustomNpc && ((EntityCustomNpc) npc).modelData.entityClass == null) {
if (!(npc.display.texture).equals("")) {
//npc.textureLocation = new ResourceLocation(npc.display.texture);
try {
npc.textureLocation = adjustLocalTexture(npc, new ResourceLocation(npc.display.texture));
} catch (IOException ignored) {
}
}
} else {
npc.textureLocation = new ResourceLocation(npc.display.texture);
}
} else if(LastTextureTick < 5) { //fixes request flood somewhat
return AbstractClientPlayer.locationStevePng;