mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-20 06:29:41 +00:00
Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
1d57877230
30 files changed
+1374
-672
No files matched your search
@@ -14,11 +14,9 @@ import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.village.MerchantRecipeList;
|
||||
import noppes.npcs.constants.EnumPacketClient;
|
||||
|
||||
import java.io.*;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
|
||||
public class Server {
|
||||
|
||||
@@ -100,60 +98,24 @@ public class Server {
|
||||
else if(ob instanceof NBTTagCompound)
|
||||
writeNBT(buffer, (NBTTagCompound) ob);
|
||||
}
|
||||
// if(buffer.array().length >= 32767){
|
||||
// LogWriter.error("Packet " + enu + " was too big to be send");
|
||||
// return false;
|
||||
// }
|
||||
if(buffer.array().length >= Short.MAX_VALUE * 2){
|
||||
LogWriter.error("Packet " + enu + " was too big to be send");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(buffer.array().length >= 32767){
|
||||
LogWriter.error("Packet " + enu + " was too big to be send");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// public static void writeNBT(ByteBuf buffer, NBTTagCompound compound) throws IOException {
|
||||
// byte[] bytes = CompressedStreamTools.compress(compound);
|
||||
// buffer.writeShort((short)bytes.length);
|
||||
// buffer.writeBytes(bytes);
|
||||
// }
|
||||
public static void writeNBT(ByteBuf buffer, NBTTagCompound compound) throws IOException {
|
||||
byte[] bytes = CompressedStreamTools.compress(compound);
|
||||
buffer.writeShort((short)bytes.length);
|
||||
buffer.writeBytes(bytes);
|
||||
}
|
||||
|
||||
|
||||
// public static NBTTagCompound readNBT(ByteBuf buffer) throws IOException {
|
||||
// byte[] bytes = new byte[buffer.readShort()];
|
||||
// buffer.readBytes(bytes);
|
||||
// return CompressedStreamTools.func_152457_a(bytes, new NBTSizeTracker(2097152L));
|
||||
// }
|
||||
|
||||
|
||||
public static void writeNBT(ByteBuf buffer, NBTTagCompound compound) throws IOException {
|
||||
ByteArrayOutputStream bytearrayoutputstream = new ByteArrayOutputStream();
|
||||
DataOutputStream dataoutputstream = new DataOutputStream(new GZIPOutputStream(bytearrayoutputstream));
|
||||
|
||||
try
|
||||
{
|
||||
CompressedStreamTools.write(compound, dataoutputstream);
|
||||
}
|
||||
finally
|
||||
{
|
||||
dataoutputstream.close();
|
||||
}
|
||||
byte[] bytes = bytearrayoutputstream.toByteArray();
|
||||
buffer.writeInt(bytes.length);
|
||||
buffer.writeBytes(bytes);
|
||||
}
|
||||
|
||||
public static NBTTagCompound readNBT(ByteBuf buffer) throws IOException {
|
||||
byte[] bytes = new byte[buffer.readInt()];
|
||||
buffer.readBytes(bytes);
|
||||
DataInputStream datainputstream = new DataInputStream(new BufferedInputStream(new GZIPInputStream(new ByteArrayInputStream(bytes))));
|
||||
try{
|
||||
return CompressedStreamTools.func_152457_a(bytes, NBTSizeTracker.field_152451_a);
|
||||
}
|
||||
finally{
|
||||
datainputstream.close();
|
||||
}
|
||||
}
|
||||
public static NBTTagCompound readNBT(ByteBuf buffer) throws IOException {
|
||||
byte[] bytes = new byte[buffer.readShort()];
|
||||
buffer.readBytes(bytes);
|
||||
return CompressedStreamTools.func_152457_a(bytes, new NBTSizeTracker(2097152L));
|
||||
}
|
||||
|
||||
public static void writeString(ByteBuf buffer, String s){
|
||||
byte[] bytes = s.getBytes(Charsets.UTF_8);
|
||||
|
||||
@@ -7,42 +7,27 @@ import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
public class EntityAISprintToTarget extends EntityAIBase
|
||||
{
|
||||
/** The entity that is leaping. */
|
||||
private EntityNPCInterface runner;
|
||||
private EntityNPCInterface npc;
|
||||
|
||||
/** The entity that the leaper is leaping towards. */
|
||||
private EntityLivingBase runTarget;
|
||||
|
||||
public EntityAISprintToTarget(EntityNPCInterface par1EntityLiving)
|
||||
{
|
||||
this.runner = par1EntityLiving;
|
||||
public EntityAISprintToTarget(EntityNPCInterface par1EntityLiving){
|
||||
this.npc = par1EntityLiving;
|
||||
this.setMutexBits(AiMutex.PASSIVE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the EntityAIBase should begin execution.
|
||||
*/
|
||||
public boolean shouldExecute()
|
||||
{
|
||||
this.runTarget = this.runner.getAttackTarget();
|
||||
@Override
|
||||
public boolean shouldExecute(){
|
||||
EntityLivingBase runTarget = this.npc.getAttackTarget();
|
||||
|
||||
if (this.runTarget == null)
|
||||
{
|
||||
if (runTarget == null || this.npc.getNavigator().noPath()){
|
||||
return false;
|
||||
}
|
||||
else if (this.runner.getNavigator().noPath())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
switch(this.runner.ai.onAttack)
|
||||
{
|
||||
case 0 : return !this.runner.isInRange(runTarget, 8)? (!this.runner.onGround ? false : true) : false;
|
||||
case 2 : return this.runner.isInRange(runTarget, 7)? (!this.runner.onGround ? false : true) : false;
|
||||
default : return false;
|
||||
}
|
||||
|
||||
switch(this.npc.ai.onAttack){
|
||||
case 0 : return !this.npc.isInRange(runTarget, 8)? (!this.npc.onGround ? false : true) : false;
|
||||
case 2 : return this.npc.isInRange(runTarget, 7)? (!this.npc.onGround ? false : true) : false;
|
||||
default : return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -50,22 +35,22 @@ public class EntityAISprintToTarget extends EntityAIBase
|
||||
*/
|
||||
public boolean continueExecuting()
|
||||
{
|
||||
return this.runner.isEntityAlive() && this.runner.onGround && this.runner.hurtTime <= 0 && (this.runner.motionX != 0.0D && this.runner.motionZ != 0.0D);
|
||||
return this.npc.isEntityAlive() && this.npc.onGround && this.npc.hurtTime <= 0 && (this.npc.motionX != 0.0D && this.npc.motionZ != 0.0D);
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute a one shot task or start executing a continuous task
|
||||
*/
|
||||
public void startExecuting()
|
||||
{
|
||||
this.runner.setSprinting(true);
|
||||
@Override
|
||||
public void startExecuting(){
|
||||
this.npc.setSprinting(true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Resets the task
|
||||
*/
|
||||
public void resetTask()
|
||||
{
|
||||
this.runner.setSprinting(false);
|
||||
@Override
|
||||
public void resetTask(){
|
||||
this.npc.setSprinting(false);
|
||||
}
|
||||
}
|
||||
@@ -6,20 +6,25 @@ import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
public class EntityAIWorldLines extends EntityAIBase {
|
||||
|
||||
private EntityNPCInterface npc;
|
||||
public EntityAIWorldLines(EntityNPCInterface npc){
|
||||
this.npc = npc;
|
||||
private EntityNPCInterface npc;
|
||||
private int cooldown = 100;
|
||||
|
||||
public EntityAIWorldLines(EntityNPCInterface npc){
|
||||
this.npc = npc;
|
||||
this.setMutexBits(AiMutex.PASSIVE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldExecute() {
|
||||
return !npc.isAttacking() && !npc.isKilled() && npc.advanced.hasWorldLines() && npc.getRNG().nextInt(1900) == 1;
|
||||
}
|
||||
|
||||
public void startExecuting()
|
||||
{
|
||||
npc.saySurrounding(npc.advanced.getWorldLine());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean shouldExecute() {
|
||||
if(cooldown > 0){
|
||||
cooldown--;
|
||||
}
|
||||
return !npc.isAttacking() && !npc.isKilled() && npc.advanced.hasWorldLines() && npc.getRNG().nextInt(1800) == 1;
|
||||
}
|
||||
|
||||
public void startExecuting(){
|
||||
cooldown = 100;
|
||||
npc.saySurrounding(npc.advanced.getWorldLine());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,10 +4,8 @@ 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.util.GuiNPCInterface2;
|
||||
import noppes.npcs.client.gui.util.GuiNpcButton;
|
||||
import noppes.npcs.client.gui.util.GuiNpcTextField;
|
||||
import noppes.npcs.client.gui.util.IGuiData;
|
||||
import noppes.npcs.client.gui.select.GuiSoundSelection;
|
||||
import noppes.npcs.client.gui.util.*;
|
||||
import noppes.npcs.constants.EnumPacketServer;
|
||||
import noppes.npcs.controllers.data.Line;
|
||||
import noppes.npcs.controllers.data.Lines;
|
||||
@@ -15,12 +13,12 @@ import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class GuiNPCLinesEdit extends GuiNPCInterface2 implements IGuiData
|
||||
public class GuiNPCLinesEdit extends GuiNPCInterface2 implements IGuiData, ISubGuiListener, ITextfieldListener
|
||||
{
|
||||
private Lines lines;
|
||||
private GuiNpcTextField field;
|
||||
private GuiNpcSoundSelection gui;
|
||||
|
||||
private int selectedId = -1;
|
||||
private GuiSoundSelection gui;
|
||||
|
||||
public GuiNPCLinesEdit(EntityNPCInterface npc, Lines lines)
|
||||
{
|
||||
super(npc);
|
||||
@@ -35,57 +33,63 @@ public class GuiNPCLinesEdit extends GuiNPCInterface2 implements IGuiData
|
||||
String text = "";
|
||||
String sound = "";
|
||||
if(lines.lines.containsKey(i)){
|
||||
Line line = lines.lines.get(i);
|
||||
text = line.text;
|
||||
sound = line.sound;
|
||||
Line line = lines.lines.get(i);
|
||||
text = line.getText();
|
||||
sound = line.getSound();
|
||||
}
|
||||
addTextField(new GuiNpcTextField(i,this, fontRendererObj, guiLeft + 4, guiTop + 4 + i * 24, 200, 20,text));
|
||||
addTextField(new GuiNpcTextField(i + 8,this, fontRendererObj, guiLeft + 208, guiTop + 4 + i * 24, 146, 20,sound));
|
||||
addButton(new GuiNpcButton(i, guiLeft + 358, guiTop + 4 + i * 24, 60, 20, "gui.select"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void actionPerformed(GuiButton guibutton)
|
||||
{
|
||||
GuiNpcButton button = (GuiNpcButton) guibutton;
|
||||
field = getTextField(button.id + 8);
|
||||
gui = new GuiNpcSoundSelection(this, field.getText());
|
||||
NoppesUtil.openGUI(player, gui);
|
||||
GuiNpcButton button = (GuiNpcButton) guibutton;
|
||||
selectedId = button.id + 8;
|
||||
setSubGui(new GuiSoundSelection(getTextField(selectedId).getText()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void elementClicked() {
|
||||
field.setText(gui.getSelected());
|
||||
saveLines();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGuiData(NBTTagCompound compound) {
|
||||
npc.advanced.readToNBT(compound);
|
||||
initGui();
|
||||
}
|
||||
|
||||
private void saveLines(){
|
||||
HashMap<Integer,Line> lines = new HashMap<Integer,Line>();
|
||||
for(int i = 0; i < 8; i++){
|
||||
GuiNpcTextField tf = getTextField(i);
|
||||
GuiNpcTextField tf2 = getTextField(i + 8);
|
||||
if(!tf.isEmpty()){
|
||||
Line line = new Line();
|
||||
line.text = tf.getText();
|
||||
line.sound = tf2.getText();
|
||||
lines.put(i, line);
|
||||
}
|
||||
|
||||
}
|
||||
this.lines.lines = lines;
|
||||
}
|
||||
|
||||
|
||||
private void saveLines(){
|
||||
HashMap<Integer,Line> lines = new HashMap<Integer,Line>();
|
||||
for(int i = 0; i < 8; i++){
|
||||
GuiNpcTextField tf = getTextField(i);
|
||||
GuiNpcTextField tf2 = getTextField(i + 8);
|
||||
if(!tf.isEmpty() || !tf2.isEmpty()){
|
||||
Line line = new Line();
|
||||
line.setText(tf.getText());
|
||||
line.setSound(tf2.getText());
|
||||
lines.put(i, line);
|
||||
}
|
||||
|
||||
}
|
||||
this.lines.lines = lines;
|
||||
}
|
||||
|
||||
public void save() {
|
||||
saveLines();
|
||||
Client.sendData(EnumPacketServer.MainmenuAdvancedSave, npc.advanced.writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void subGuiClosed(SubGuiInterface subgui) {
|
||||
GuiSoundSelection gss = (GuiSoundSelection) subgui;
|
||||
if(gss.selectedResource != null) {
|
||||
getTextField(selectedId).setText(gss.selectedResource.toString());
|
||||
saveLines();
|
||||
initGui();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unFocused(GuiNpcTextField textfield) {
|
||||
saveLines();
|
||||
initGui();
|
||||
}
|
||||
}
|
||||
@@ -1,139 +0,0 @@
|
||||
package noppes.npcs.client.gui;
|
||||
|
||||
import cpw.mods.fml.common.ObfuscationReflectionHelper;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.audio.SoundHandler;
|
||||
import net.minecraft.client.audio.SoundRegistry;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import noppes.npcs.client.NoppesUtil;
|
||||
import noppes.npcs.client.controllers.MusicController;
|
||||
import noppes.npcs.client.gui.util.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class GuiNpcSoundSelection extends GuiNPCInterface {
|
||||
|
||||
public GuiNPCStringSlot slot;
|
||||
public String domain;
|
||||
private final GuiScreen parent;
|
||||
public GuiSelectionListener listener;
|
||||
|
||||
private String up = "..<" + StatCollector.translateToLocal("gui.up") + ">..";
|
||||
|
||||
private HashMap<String,List<String>> domains = new HashMap<String,List<String>>();
|
||||
|
||||
public GuiNpcSoundSelection(GuiScreen parent, String sound)
|
||||
{
|
||||
SoundHandler handler = Minecraft.getMinecraft().getSoundHandler();
|
||||
SoundRegistry registry = ObfuscationReflectionHelper.getPrivateValue(SoundHandler.class, handler, 4);
|
||||
|
||||
Set<ResourceLocation> set = registry.getKeys();
|
||||
for(ResourceLocation location : set){
|
||||
List<String> list = domains.get(location.getResourceDomain());
|
||||
if(list == null)
|
||||
domains.put(location.getResourceDomain(), list = new ArrayList<String>());
|
||||
list.add(location.getResourcePath());
|
||||
domains.put(location.getResourceDomain(), list);
|
||||
}
|
||||
drawDefaultBackground = false;
|
||||
this.parent = parent;
|
||||
if(parent instanceof GuiSelectionListener)
|
||||
listener = (GuiSelectionListener) parent;
|
||||
}
|
||||
|
||||
public void initGui()
|
||||
{
|
||||
super.initGui();
|
||||
String ss = "Current domain: " + domain;
|
||||
if(domain == null)
|
||||
ss = "Select domain";
|
||||
addLabel(new GuiNpcLabel(0,ss, width / 2 - (this.fontRendererObj.getStringWidth(ss)/2), 20, 0xffffff));
|
||||
|
||||
Collection<String> col = domains.keySet();
|
||||
|
||||
if(domain != null){
|
||||
col = domains.get(domain);
|
||||
if(!col.contains(up))
|
||||
col.add(up);
|
||||
}
|
||||
slot = new GuiNPCStringSlot(col, this, false, 18);
|
||||
slot.registerScrollButtons(4, 5);
|
||||
if(domain != null){
|
||||
this.addButton(new GuiNpcButton(1, width / 2 - 100, height - 27,198, 20, "gui.play"));
|
||||
this.addButton(new GuiNpcButton(3, width / 2 - 100, height - 50,98, 20, "gui.done"));
|
||||
}
|
||||
else
|
||||
this.addButton(new GuiNpcButton(4, width / 2 - 100, height - 50,98, 20, "gui.open"));
|
||||
|
||||
this.addButton(new GuiNpcButton(2, width / 2 + 2, height - 50,98, 20, "gui.cancel"));
|
||||
}
|
||||
|
||||
public void drawScreen(int i, int j, float f)
|
||||
{
|
||||
slot.drawScreen(i, j, f);
|
||||
super.drawScreen(i, j, f);
|
||||
}
|
||||
|
||||
public void doubleClicked() {
|
||||
if(slot.selected == null || slot.selected.isEmpty())
|
||||
return;
|
||||
if(slot.selected.equals(up)){
|
||||
domain = null;
|
||||
initGui();
|
||||
}
|
||||
else if(domain == null){
|
||||
domain = slot.selected;
|
||||
initGui();
|
||||
}
|
||||
else{
|
||||
if(parent instanceof GuiNPCInterface){
|
||||
((GuiNPCInterface)parent).elementClicked();
|
||||
}
|
||||
else if(this.parent instanceof GuiNPCInterface2){
|
||||
((GuiNPCInterface2)parent).elementClicked();
|
||||
}
|
||||
close();
|
||||
NoppesUtil.openGUI(player, parent);
|
||||
}
|
||||
}
|
||||
|
||||
protected void actionPerformed(GuiButton guibutton)
|
||||
{
|
||||
super.actionPerformed(guibutton);
|
||||
if(guibutton.id == 1){
|
||||
MusicController.Instance.stopMusic();
|
||||
MusicController.Instance.playSound(getSelected(), (float)player.posX, (float)player.posY, (float)player.posZ);
|
||||
}
|
||||
if(guibutton.id == 2){
|
||||
close();
|
||||
NoppesUtil.openGUI(player, parent);
|
||||
}
|
||||
if(guibutton.id == 3){
|
||||
if(slot.selected == null || slot.selected.equals(up))
|
||||
return;
|
||||
doubleClicked();
|
||||
}
|
||||
if(guibutton.id == 4){
|
||||
doubleClicked();
|
||||
}
|
||||
}
|
||||
public void save() {
|
||||
|
||||
}
|
||||
public void close() {
|
||||
this.save();
|
||||
super.close();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String getSelected(){
|
||||
if(slot.selected == null || slot.selected.isEmpty())
|
||||
return "";
|
||||
return domain + ":" + slot.selected;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import noppes.npcs.client.Client;
|
||||
import noppes.npcs.client.NoppesUtil;
|
||||
import noppes.npcs.client.gui.global.GuiNPCManageDialogs;
|
||||
import noppes.npcs.client.gui.global.GuiNPCQuestSelection;
|
||||
import noppes.npcs.client.gui.select.GuiSoundSelection;
|
||||
import noppes.npcs.client.gui.util.*;
|
||||
import noppes.npcs.constants.EnumPacketServer;
|
||||
import noppes.npcs.controllers.data.Dialog;
|
||||
@@ -17,7 +18,6 @@ public class SubGuiNpcDialog extends SubGuiInterface implements ISubGuiListener,
|
||||
public int dialogCategoryID;
|
||||
public Dialog dialog;
|
||||
private final GuiNPCManageDialogs parent;
|
||||
private GuiNpcSoundSelection gui;
|
||||
private GuiNPCQuestSelection questSelection;
|
||||
|
||||
public SubGuiNpcDialog(GuiNPCManageDialogs parent, Dialog dialog, int catId)
|
||||
@@ -79,7 +79,7 @@ public class SubGuiNpcDialog extends SubGuiInterface implements ISubGuiListener,
|
||||
if(!dialog.mail.subject.isEmpty())
|
||||
getButton(13).setDisplayText(dialog.mail.subject);
|
||||
}
|
||||
|
||||
|
||||
public void buttonEvent(GuiButton guibutton)
|
||||
{
|
||||
int id = guibutton.id;
|
||||
@@ -106,9 +106,7 @@ public class SubGuiNpcDialog extends SubGuiInterface implements ISubGuiListener,
|
||||
initGui();
|
||||
}
|
||||
if(id == 9 && dialog.id >= 0){
|
||||
gui = new GuiNpcSoundSelection(getParent(), getTextField(2).getText());
|
||||
gui.listener = this;
|
||||
NoppesUtil.openGUI(player, gui);
|
||||
setSubGui(new GuiSoundSelection((getTextField(2).getText())));
|
||||
}
|
||||
if(id == 10){
|
||||
setSubGui(new SubGuiNpcCommand(dialog.command));
|
||||
@@ -169,12 +167,14 @@ public class SubGuiNpcDialog extends SubGuiInterface implements ISubGuiListener,
|
||||
else if(subgui instanceof SubGuiMailmanSendSetup){
|
||||
initGui();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void elementClicked(){
|
||||
getTextField(2).setText(gui.getSelected());
|
||||
unFocused(getTextField(2));
|
||||
else if (subgui instanceof GuiSoundSelection){
|
||||
GuiSoundSelection gss = (GuiSoundSelection) subgui;
|
||||
if(gss.selectedResource != null) {
|
||||
getTextField(2).setText(gss.selectedResource.toString());
|
||||
unFocused(getTextField(2));
|
||||
initGui();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -3,13 +3,14 @@ package noppes.npcs.client.gui;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import noppes.npcs.DataStats;
|
||||
import noppes.npcs.client.NoppesUtil;
|
||||
import noppes.npcs.client.gui.select.GuiSoundSelection;
|
||||
import noppes.npcs.client.gui.util.*;
|
||||
|
||||
public class SubGuiNpcRangeProperties extends SubGuiInterface implements ITextfieldListener
|
||||
public class SubGuiNpcRangeProperties extends SubGuiInterface implements ITextfieldListener, ISubGuiListener
|
||||
{
|
||||
private DataStats stats;
|
||||
private GuiNpcSoundSelection gui;
|
||||
|
||||
private GuiNpcTextField soundSelected = null;
|
||||
|
||||
public SubGuiNpcRangeProperties(DataStats stats)
|
||||
{
|
||||
this.stats = stats;
|
||||
@@ -22,42 +23,50 @@ public class SubGuiNpcRangeProperties extends SubGuiInterface implements ITextfi
|
||||
public void initGui(){
|
||||
super.initGui();
|
||||
int y = guiTop + 4;
|
||||
addTextField(new GuiNpcTextField(1,this, fontRendererObj, guiLeft + 85, y, 50, 18, stats.accuracy+""));
|
||||
addTextField(new GuiNpcTextField(1,this, fontRendererObj, guiLeft + 80, y, 50, 18, stats.accuracy+""));
|
||||
addLabel(new GuiNpcLabel(1,"stats.accuracy", guiLeft + 5, y + 5));
|
||||
getTextField(1).integersOnly = true;
|
||||
getTextField(1).setMinMaxDefault(0, 100, 90);
|
||||
addTextField(new GuiNpcTextField(2,this, fontRendererObj, guiLeft + 85, y += 22, 50, 18, stats.rangedRange+""));
|
||||
|
||||
addTextField(new GuiNpcTextField(8, this, fontRendererObj, guiLeft + 200, y, 50, 18, stats.shotCount + ""));
|
||||
addLabel(new GuiNpcLabel(8, "stats.shotcount", guiLeft + 135, y + 5));
|
||||
getTextField(8).integersOnly = true;
|
||||
getTextField(8).setMinMaxDefault(1, Integer.MAX_VALUE, 1);
|
||||
|
||||
addTextField(new GuiNpcTextField(2,this, fontRendererObj, guiLeft + 80, y += 22, 50, 18, stats.rangedRange+""));
|
||||
addLabel(new GuiNpcLabel(2,"stats.rangedrange", guiLeft + 5, y + 5));
|
||||
getTextField(2).integersOnly = true;
|
||||
getTextField(2).setMinMaxDefault(1, Integer.MAX_VALUE, 2);
|
||||
addTextField(new GuiNpcTextField(3,this, fontRendererObj, guiLeft + 85, y += 22, 50, 18, stats.minDelay+""));
|
||||
getTextField(2).setMinMaxDefault(1, 64, 2);
|
||||
|
||||
addTextField(new GuiNpcTextField(3,this, fontRendererObj, guiLeft + 80, y += 22, 50, 18, stats.minDelay+""));
|
||||
addLabel(new GuiNpcLabel(3,"stats.mindelay", guiLeft + 5, y + 5));
|
||||
getTextField(3).integersOnly = true;
|
||||
getTextField(3).setMinMaxDefault(1, Integer.MAX_VALUE, 20);
|
||||
addTextField(new GuiNpcTextField(4,this, fontRendererObj, guiLeft + 85, y += 22, 50, 18, stats.maxDelay+""));
|
||||
addLabel(new GuiNpcLabel(4,"stats.maxdelay", guiLeft + 5, y + 5));
|
||||
|
||||
addTextField(new GuiNpcTextField(4,this, fontRendererObj, guiLeft + 200, y, 50, 18, stats.maxDelay+""));
|
||||
addLabel(new GuiNpcLabel(4,"stats.maxdelay", guiLeft + 135, y + 5));
|
||||
getTextField(4).integersOnly = true;
|
||||
getTextField(4).setMinMaxDefault(1, Integer.MAX_VALUE, 20);
|
||||
|
||||
addTextField(new GuiNpcTextField(5, this, fontRendererObj, guiLeft + 85, y += 22, 50, 18, stats.fireRate + ""));
|
||||
addLabel(new GuiNpcLabel(5, "stats.burstspeed", guiLeft + 5, y + 5));
|
||||
|
||||
addTextField(new GuiNpcTextField(6, this, fontRendererObj, guiLeft + 80, y += 22, 50, 18, stats.burstCount + ""));
|
||||
addLabel(new GuiNpcLabel(6, "stats.burstcount", guiLeft + 5, y + 5));
|
||||
getTextField(6).integersOnly = true;
|
||||
getTextField(6).setMinMaxDefault(1, Integer.MAX_VALUE, 20);
|
||||
|
||||
addTextField(new GuiNpcTextField(5, this, fontRendererObj, guiLeft + 200, y , 50, 18, stats.fireRate + ""));
|
||||
addLabel(new GuiNpcLabel(5, "stats.burstspeed", guiLeft + 135, y + 5));
|
||||
getTextField(5).integersOnly = true;
|
||||
getTextField(5).setMinMaxDefault(0, Integer.MAX_VALUE, 0);
|
||||
addTextField(new GuiNpcTextField(6, this, fontRendererObj, guiLeft + 85, y += 22, 50, 18, stats.burstCount + ""));
|
||||
addLabel(new GuiNpcLabel(6, "stats.burstcount", guiLeft + 5, y + 5));
|
||||
getTextField(6).integersOnly = true;
|
||||
getTextField(6).setMinMaxDefault(1, Integer.MAX_VALUE, 20);
|
||||
addTextField(new GuiNpcTextField(7,this, fontRendererObj, guiLeft + 85, y += 22, 100, 20, stats.fireSound));
|
||||
|
||||
|
||||
addTextField(new GuiNpcTextField(7,this, fontRendererObj, guiLeft + 80, y += 22, 100, 20, stats.fireSound));
|
||||
addLabel(new GuiNpcLabel(7, "stats.firesound:", guiLeft + 5, y + 5));
|
||||
addButton(new GuiNpcButton(7, guiLeft + 187, y, 60, 20, "gui.select"));
|
||||
addTextField(new GuiNpcTextField(8, this, fontRendererObj, guiLeft + 85, y += 22, 50, 18, stats.shotCount + ""));
|
||||
addLabel(new GuiNpcLabel(8, "stats.shotcount", guiLeft + 5, y + 5));
|
||||
getTextField(8).integersOnly = true;
|
||||
getTextField(8).setMinMaxDefault(1, Integer.MAX_VALUE, 1);
|
||||
|
||||
addButton(new GuiNpcButtonYesNo(9, guiLeft + 100, y += 22, stats.aimWhileShooting));
|
||||
addLabel(new GuiNpcLabel(9, "stats.aimWhileShooting", guiLeft + 5, y + 5));
|
||||
|
||||
|
||||
addButton(new GuiNpcButton(66, guiLeft + 190, guiTop + 190, 60, 20, "gui.done"));
|
||||
}
|
||||
|
||||
@@ -103,21 +112,14 @@ public class SubGuiNpcRangeProperties extends SubGuiInterface implements ITextfi
|
||||
stats.shotCount = textfield.getInteger();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void elementClicked(){
|
||||
getTextField(7).setText(gui.getSelected());
|
||||
unFocused(getTextField(7));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton guibutton){
|
||||
int id = guibutton.id;
|
||||
if(id == 7)
|
||||
{
|
||||
gui = new GuiNpcSoundSelection(parent, getTextField(7).getText());
|
||||
NoppesUtil.openGUI(player, gui);
|
||||
}
|
||||
if(id == 7){
|
||||
soundSelected = getTextField(7);
|
||||
setSubGui(new GuiSoundSelection(soundSelected.getText()));
|
||||
}
|
||||
if(id == 66)
|
||||
{
|
||||
close();
|
||||
@@ -126,4 +128,13 @@ public class SubGuiNpcRangeProperties extends SubGuiInterface implements ITextfi
|
||||
stats.aimWhileShooting = ((GuiNpcButtonYesNo)guibutton).getBoolean();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void subGuiClosed(SubGuiInterface subgui) {
|
||||
GuiSoundSelection gss = (GuiSoundSelection) subgui;
|
||||
if(gss.selectedResource != null) {
|
||||
soundSelected.setText(gss.selectedResource.toString());
|
||||
unFocused(soundSelected);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,135 +0,0 @@
|
||||
package noppes.npcs.client.gui;
|
||||
|
||||
import cpw.mods.fml.common.ObfuscationReflectionHelper;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.audio.SoundHandler;
|
||||
import net.minecraft.client.audio.SoundRegistry;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import noppes.npcs.client.controllers.MusicController;
|
||||
import noppes.npcs.client.gui.util.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class SubGuiNpcSoundSelection extends SubGuiInterface {
|
||||
|
||||
public GuiNPCStringSlot slot;
|
||||
public String domain;
|
||||
private final GuiScreen parent;
|
||||
public GuiSelectionListener listener;
|
||||
|
||||
private String up = "..<" + StatCollector.translateToLocal("gui.up") + ">..";
|
||||
|
||||
private HashMap<String,List<String>> domains = new HashMap<String,List<String>>();
|
||||
|
||||
public SubGuiNpcSoundSelection(GuiScreen parent, String sound)
|
||||
{
|
||||
SoundHandler handler = Minecraft.getMinecraft().getSoundHandler();
|
||||
SoundRegistry registry = ObfuscationReflectionHelper.getPrivateValue(SoundHandler.class, handler, 4);
|
||||
|
||||
Set<ResourceLocation> set = registry.getKeys();
|
||||
for(ResourceLocation location : set){
|
||||
List<String> list = domains.get(location.getResourceDomain());
|
||||
if(list == null)
|
||||
domains.put(location.getResourceDomain(), list = new ArrayList<String>());
|
||||
list.add(location.getResourcePath());
|
||||
domains.put(location.getResourceDomain(), list);
|
||||
}
|
||||
drawDefaultBackground = false;
|
||||
this.parent = parent;
|
||||
if(parent instanceof GuiSelectionListener)
|
||||
listener = (GuiSelectionListener) parent;
|
||||
}
|
||||
|
||||
public void initGui()
|
||||
{
|
||||
super.initGui();
|
||||
String ss = "Current domain: " + domain;
|
||||
if(domain == null)
|
||||
ss = "Select domain";
|
||||
addLabel(new GuiNpcLabel(0,ss, width / 2 - (this.fontRendererObj.getStringWidth(ss)/2), 20, 0xffffff));
|
||||
|
||||
Collection<String> col = domains.keySet();
|
||||
|
||||
if(domain != null){
|
||||
col = domains.get(domain);
|
||||
if(!col.contains(up))
|
||||
col.add(up);
|
||||
}
|
||||
slot = new GuiNPCStringSlot(col, this, false, 18);
|
||||
slot.registerScrollButtons(4, 5);
|
||||
if(domain != null){
|
||||
this.addButton(new GuiNpcButton(1, width / 2 - 100, height - 27,198, 20, "gui.play"));
|
||||
this.addButton(new GuiNpcButton(3, width / 2 - 100, height - 50,98, 20, "gui.done"));
|
||||
}
|
||||
else
|
||||
this.addButton(new GuiNpcButton(4, width / 2 - 100, height - 50,98, 20, "gui.open"));
|
||||
|
||||
this.addButton(new GuiNpcButton(2, width / 2 + 2, height - 50,98, 20, "gui.cancel"));
|
||||
}
|
||||
|
||||
public void drawScreen(int i, int j, float f)
|
||||
{
|
||||
slot.drawScreen(i, j, f);
|
||||
super.drawScreen(i, j, f);
|
||||
}
|
||||
|
||||
public void doubleClicked() {
|
||||
if(slot.selected == null || slot.selected.isEmpty())
|
||||
return;
|
||||
if(slot.selected.equals(up)){
|
||||
domain = null;
|
||||
initGui();
|
||||
}
|
||||
else if(domain == null){
|
||||
domain = slot.selected;
|
||||
initGui();
|
||||
}
|
||||
else{
|
||||
if(parent instanceof GuiNPCInterface){
|
||||
((GuiNPCInterface)parent).elementClicked();
|
||||
}
|
||||
else if(this.parent instanceof GuiNPCInterface2){
|
||||
((GuiNPCInterface2)parent).elementClicked();
|
||||
}
|
||||
close();
|
||||
}
|
||||
}
|
||||
|
||||
protected void actionPerformed(GuiButton guibutton)
|
||||
{
|
||||
super.actionPerformed(guibutton);
|
||||
if(guibutton.id == 1){
|
||||
MusicController.Instance.stopMusic();
|
||||
MusicController.Instance.playSound(getSelected(), (float)player.posX, (float)player.posY, (float)player.posZ);
|
||||
}
|
||||
if(guibutton.id == 2){
|
||||
close();
|
||||
}
|
||||
if(guibutton.id == 3){
|
||||
if(slot.selected == null || slot.selected.equals(up))
|
||||
return;
|
||||
doubleClicked();
|
||||
}
|
||||
if(guibutton.id == 4){
|
||||
doubleClicked();
|
||||
}
|
||||
}
|
||||
public void save() {
|
||||
|
||||
}
|
||||
|
||||
public void close() {
|
||||
this.save();
|
||||
super.close();
|
||||
}
|
||||
|
||||
public String getSelected(){
|
||||
if(slot.selected == null || slot.selected.isEmpty())
|
||||
return "";
|
||||
return domain + ":" + slot.selected;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,15 +3,13 @@ package noppes.npcs.client.gui.advanced;
|
||||
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.select.GuiSoundSelection;
|
||||
import noppes.npcs.client.gui.util.*;
|
||||
import noppes.npcs.constants.EnumPacketServer;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
public class GuiNPCSoundsMenu extends GuiNPCInterface2 implements ITextfieldListener
|
||||
public class GuiNPCSoundsMenu extends GuiNPCInterface2 implements ITextfieldListener, ISubGuiListener
|
||||
{
|
||||
private GuiNpcSoundSelection gui;
|
||||
private GuiNpcTextField selectedField;
|
||||
public GuiNPCSoundsMenu(EntityNPCInterface npc){
|
||||
super(npc);
|
||||
@@ -23,37 +21,36 @@ public class GuiNPCSoundsMenu extends GuiNPCInterface2 implements ITextfieldList
|
||||
addLabel(new GuiNpcLabel(0,"advanced.idlesound", guiLeft + 5, guiTop + 20));
|
||||
addTextField(new GuiNpcTextField(0,this, fontRendererObj, guiLeft + 80, guiTop + 15, 200, 20, npc.advanced.idleSound));
|
||||
addButton(new GuiNpcButton(0, guiLeft + 290, guiTop + 15, 80, 20, "gui.selectSound"));
|
||||
|
||||
|
||||
addLabel(new GuiNpcLabel(2,"advanced.angersound", guiLeft + 5, guiTop + 45));
|
||||
addTextField(new GuiNpcTextField(2,this, fontRendererObj, guiLeft + 80, guiTop + 40, 200, 20, npc.advanced.angrySound));
|
||||
addButton(new GuiNpcButton(2, guiLeft + 290, guiTop + 40, 80, 20, "gui.selectSound"));
|
||||
|
||||
|
||||
addLabel(new GuiNpcLabel(3,"advanced.hurtsound", guiLeft + 5, guiTop + 70));
|
||||
addTextField(new GuiNpcTextField(3,this, fontRendererObj, guiLeft + 80, guiTop + 65, 200, 20, npc.advanced.hurtSound));
|
||||
addButton(new GuiNpcButton(3, guiLeft + 290, guiTop + 65, 80, 20, "gui.selectSound"));
|
||||
|
||||
|
||||
addLabel(new GuiNpcLabel(4,"advanced.deathsound", guiLeft + 5, guiTop + 95));
|
||||
addTextField(new GuiNpcTextField(4,this, fontRendererObj, guiLeft + 80, guiTop + 90, 200, 20, npc.advanced.deathSound));
|
||||
addButton(new GuiNpcButton(4, guiLeft + 290, guiTop + 90, 80, 20, "gui.selectSound"));
|
||||
|
||||
|
||||
addLabel(new GuiNpcLabel(5,"advanced.stepsound", guiLeft + 5, guiTop + 120));
|
||||
addTextField(new GuiNpcTextField(5,this, fontRendererObj, guiLeft + 80, guiTop + 115, 200, 20, npc.advanced.stepSound));
|
||||
addButton(new GuiNpcButton(5, guiLeft + 290, guiTop + 115, 80, 20, "gui.selectSound"));
|
||||
|
||||
addLabel(new GuiNpcLabel(6,"advanced.haspitch", guiLeft + 5, guiTop + 150));
|
||||
addButton(new GuiNpcButton(6, guiLeft + 120, guiTop + 145, 80, 20, new String[]{"gui.no","gui.yes"}, npc.advanced.disablePitch?0:1));
|
||||
|
||||
|
||||
}
|
||||
public void buttonEvent(GuiButton button){
|
||||
|
||||
if(button.id == 6)
|
||||
npc.advanced.disablePitch =((GuiNpcButton)button).getValue() == 0;
|
||||
else{
|
||||
selectedField = getTextField(button.id);
|
||||
gui = new GuiNpcSoundSelection(this, selectedField.getText());
|
||||
NoppesUtil.openGUI(player, gui);
|
||||
selectedField = getTextField(button.id);
|
||||
setSubGui(new GuiSoundSelection(selectedField.getText()));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@Override
|
||||
public void unFocused(GuiNpcTextField textfield) {
|
||||
@@ -68,13 +65,16 @@ public class GuiNPCSoundsMenu extends GuiNPCInterface2 implements ITextfieldList
|
||||
if(textfield.id == 5)
|
||||
npc.advanced.stepSound = textfield.getText();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void elementClicked(){
|
||||
selectedField.setText(gui.getSelected());
|
||||
unFocused(selectedField);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void subGuiClosed(SubGuiInterface subgui) {
|
||||
GuiSoundSelection gss = (GuiSoundSelection) subgui;
|
||||
if(gss.selectedResource != null) {
|
||||
selectedField.setText(gss.selectedResource.toString());
|
||||
unFocused(selectedField);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
Client.sendData(EnumPacketServer.MainmenuAdvancedSave, npc.advanced.writeToNBT(new NBTTagCompound()));
|
||||
|
||||
@@ -157,7 +157,6 @@ public class GuiNPCManageDialogs extends GuiNPCInterface2 implements IScrollGrou
|
||||
int id = guibutton.id;
|
||||
// Edit Cat
|
||||
if(id == 6){
|
||||
saveType(false);
|
||||
if(category != null && category.id > -1){
|
||||
setSubGui(new SubGuiEditText(category.title));
|
||||
}
|
||||
@@ -167,7 +166,6 @@ public class GuiNPCManageDialogs extends GuiNPCInterface2 implements IScrollGrou
|
||||
}
|
||||
// Add Cat
|
||||
if(id == 4){
|
||||
saveType(false);
|
||||
String name = "New";
|
||||
while(catData.containsKey(name))
|
||||
name += "_";
|
||||
@@ -181,7 +179,6 @@ public class GuiNPCManageDialogs extends GuiNPCInterface2 implements IScrollGrou
|
||||
}
|
||||
// Remove Cat
|
||||
if(id == 5){
|
||||
saveType(false);
|
||||
if(catData.containsKey(catScroll.getSelected())) {
|
||||
Client.sendData(EnumPacketServer.DialogCategoryRemove, category.id);
|
||||
clearCategory();
|
||||
@@ -250,7 +247,7 @@ public class GuiNPCManageDialogs extends GuiNPCInterface2 implements IScrollGrou
|
||||
|
||||
boolean diagEnabled = dialogData != null;
|
||||
if(diagEnabled){
|
||||
if(!(dialog.id >= 0)){
|
||||
if(dialog == null ||!(dialog.id >= 0)){
|
||||
diagEnabled = false;
|
||||
}
|
||||
}
|
||||
@@ -323,12 +320,10 @@ public class GuiNPCManageDialogs extends GuiNPCInterface2 implements IScrollGrou
|
||||
public void customScrollClicked(int i, int j, int k, GuiCustomScroll guiCustomScroll) {
|
||||
if(guiCustomScroll.id == 0)
|
||||
{
|
||||
saveType(false);
|
||||
getCategory(false);
|
||||
}
|
||||
if(guiCustomScroll.id == 1)
|
||||
{
|
||||
saveType(false);
|
||||
getDialog(false);
|
||||
}
|
||||
}
|
||||
@@ -338,6 +333,13 @@ public class GuiNPCManageDialogs extends GuiNPCInterface2 implements IScrollGrou
|
||||
String selected = catScroll.getSelected();
|
||||
if(!selected.equals(prevCatName) || override){
|
||||
category = new DialogCategory();
|
||||
|
||||
dialogScroll.selected = -1;
|
||||
dialogScroll.resetScroll();
|
||||
diagSearch = "";
|
||||
dialog = null;
|
||||
getTextField(66).setText("");
|
||||
|
||||
Client.sendData(EnumPacketServer.DialogCategoryGet, catData.get(selected));
|
||||
setPrevCatName(selected);
|
||||
}
|
||||
|
||||
@@ -161,7 +161,6 @@ public class GuiNPCManageQuest extends GuiNPCInterface2 implements IScrollGroup,
|
||||
int id = guibutton.id;
|
||||
// Edit Cat
|
||||
if(id == 6){
|
||||
saveType(false);
|
||||
if(category != null && category.id > -1){
|
||||
setSubGui(new SubGuiEditText(category.title));
|
||||
}
|
||||
@@ -171,7 +170,6 @@ public class GuiNPCManageQuest extends GuiNPCInterface2 implements IScrollGroup,
|
||||
}
|
||||
// Add Cat
|
||||
if(id == 4){
|
||||
saveType(false);
|
||||
String name = "New";
|
||||
while(catData.containsKey(name))
|
||||
name += "_";
|
||||
@@ -185,7 +183,6 @@ public class GuiNPCManageQuest extends GuiNPCInterface2 implements IScrollGroup,
|
||||
}
|
||||
// Remove Cat
|
||||
if(id == 5){
|
||||
saveType(false);
|
||||
if(catData.containsKey(catScroll.getSelected())) {
|
||||
Client.sendData(EnumPacketServer.QuestCategoryRemove, category.id);
|
||||
clearCategory();
|
||||
@@ -254,7 +251,7 @@ public class GuiNPCManageQuest extends GuiNPCInterface2 implements IScrollGroup,
|
||||
|
||||
boolean questEnabled = questData != null;
|
||||
if(questEnabled){
|
||||
if(!(quest.id >= 0)){
|
||||
if(quest == null || !(quest.id >= 0)){
|
||||
questEnabled = false;
|
||||
}
|
||||
}
|
||||
@@ -302,7 +299,7 @@ public class GuiNPCManageQuest extends GuiNPCInterface2 implements IScrollGroup,
|
||||
catData.put(category.title, category.id);
|
||||
catScroll.replace(old,category.title);
|
||||
}
|
||||
saveType(false);
|
||||
saveType(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -327,12 +324,10 @@ public class GuiNPCManageQuest extends GuiNPCInterface2 implements IScrollGroup,
|
||||
public void customScrollClicked(int i, int j, int k, GuiCustomScroll guiCustomScroll) {
|
||||
if(guiCustomScroll.id == 0)
|
||||
{
|
||||
saveType(false);
|
||||
getCategory(false);
|
||||
}
|
||||
if(guiCustomScroll.id == 1)
|
||||
{
|
||||
saveType(false);
|
||||
getQuest(false);
|
||||
}
|
||||
}
|
||||
@@ -342,6 +337,13 @@ public class GuiNPCManageQuest extends GuiNPCInterface2 implements IScrollGroup,
|
||||
String selected = catScroll.getSelected();
|
||||
if(!selected.equals(prevCatName) || override){
|
||||
category = new QuestCategory();
|
||||
|
||||
questScroll.selected = -1;
|
||||
questScroll.resetScroll();
|
||||
questSearch = "";
|
||||
quest = null;
|
||||
getTextField(66).setText("");
|
||||
|
||||
Client.sendData(EnumPacketServer.QuestCategoryGet, catData.get(selected));
|
||||
setPrevCatName(selected);
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ public class GuiNpcAI extends GuiNPCInterface2 implements ITextfieldListener, IG
|
||||
{
|
||||
super.initGui();
|
||||
addLabel(new GuiNpcLabel(0,"ai.enemyresponse", guiLeft + 5, guiTop + 17));
|
||||
addButton(new GuiNpcButton(0,guiLeft + 86, guiTop + 10, 60, 20, new String[]{"gui.retaliate","gui.panic","gui.retreat","gui.nothing"} ,npc.ai.onAttack));
|
||||
addButton(new GuiNpcButton(0,guiLeft + 86, guiTop + 10, 60, 20, new String[]{"gui.retaliate","gui.panic","gui.retreat","gui.nothing"} ,npc.ai.onAttack));
|
||||
addLabel(new GuiNpcLabel(1,"ai.door", guiLeft + 5, guiTop + 40));
|
||||
addButton(new GuiNpcButton(1,guiLeft + 86, guiTop + 35, 60, 20, new String[]{"gui.break","gui.open","gui.disabled"} ,npc.ai.doorInteract));
|
||||
addLabel(new GuiNpcLabel(12,"ai.swim", guiLeft + 5, guiTop + 65));
|
||||
@@ -75,8 +75,8 @@ public class GuiNpcAI extends GuiNPCInterface2 implements ITextfieldListener, IG
|
||||
{
|
||||
String label = "";
|
||||
label = "gui.combatchance";
|
||||
addLabel(new GuiNpcLabel(21, label, guiLeft + 300, guiTop + 140));
|
||||
addTextField(new GuiNpcTextField(4,this, fontRendererObj, guiLeft + 380, guiTop + 135, 30, 20, ai.tacticalChance + ""));
|
||||
addLabel(new GuiNpcLabel(21, label, guiLeft + 300, guiTop + 165));
|
||||
addTextField(new GuiNpcTextField(4,this, fontRendererObj, guiLeft + 380, guiTop + 160, 30, 20, ai.tacticalChance + ""));
|
||||
getTextField(4).integersOnly = true;
|
||||
getTextField(4).setMinMaxDefault(1, 100, 5);
|
||||
}
|
||||
@@ -91,7 +91,7 @@ public class GuiNpcAI extends GuiNPCInterface2 implements ITextfieldListener, IG
|
||||
addLabel(new GuiNpcLabel(2,"ai.movement", guiLeft + 4, guiTop + 165));
|
||||
addButton(new GuiNpcButton(2, guiLeft + 86, guiTop + 160, 60, 20, "selectServer.edit"));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void unFocused(GuiNpcTextField textfield){
|
||||
if(textfield.id == 3){
|
||||
@@ -104,7 +104,7 @@ public class GuiNpcAI extends GuiNPCInterface2 implements ITextfieldListener, IG
|
||||
ai.distanceToMelee = textfield.getInteger();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton guibutton)
|
||||
{
|
||||
@@ -154,9 +154,10 @@ public class GuiNpcAI extends GuiNPCInterface2 implements ITextfieldListener, IG
|
||||
}
|
||||
else if (button.id == 25) {
|
||||
ai.combatPolicy = EnumCombatPolicy.values()[button.getValue()];
|
||||
initGui();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
Client.sendData(EnumPacketServer.MainmenuAISave, ai.writeToNBT(new NBTTagCompound()));
|
||||
|
||||
@@ -3,25 +3,20 @@ package noppes.npcs.client.gui.roles;
|
||||
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.controllers.MusicController;
|
||||
import noppes.npcs.client.gui.GuiNpcSoundSelection;
|
||||
import noppes.npcs.client.gui.util.GuiNPCInterface2;
|
||||
import noppes.npcs.client.gui.util.GuiNpcButton;
|
||||
import noppes.npcs.client.gui.util.GuiNpcLabel;
|
||||
import noppes.npcs.client.gui.util.GuiNpcTextField;
|
||||
import noppes.npcs.client.gui.select.GuiSoundSelection;
|
||||
import noppes.npcs.client.gui.util.*;
|
||||
import noppes.npcs.constants.EnumPacketServer;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import noppes.npcs.roles.JobBard;
|
||||
|
||||
public class GuiNpcBard extends GuiNPCInterface2
|
||||
{
|
||||
public class GuiNpcBard extends GuiNPCInterface2 implements ISubGuiListener
|
||||
{
|
||||
private JobBard job;
|
||||
private GuiNpcSoundSelection gui;
|
||||
|
||||
|
||||
public GuiNpcBard(EntityNPCInterface npc)
|
||||
{
|
||||
super(npc);
|
||||
super(npc);
|
||||
job = (JobBard) npc.jobInterface;
|
||||
}
|
||||
|
||||
@@ -36,7 +31,7 @@ public class GuiNpcBard extends GuiNPCInterface2
|
||||
this.addButton(new GuiNpcButton(2, guiLeft + 75, guiTop + 71, new String[]{"gui.none","item.npcBanjo.name","item.npcViolin.name","item.npcGuitar.name","item.npcHarp.name","item.npcFrenchHorn.name"}, job.getInstrument().ordinal()));
|
||||
this.addButton(new GuiNpcButton(3, guiLeft + 75, guiTop + 92, new String[]{"bard.jukebox","bard.background"}, job.isStreamer?0:1));
|
||||
|
||||
|
||||
|
||||
addLabel(new GuiNpcLabel(2,"bard.ondistance", guiLeft + 60, guiTop + 143));
|
||||
addTextField(new GuiNpcTextField(2,this, this.fontRendererObj, guiLeft+160, guiTop + 138, 40, 20, job.minRange + ""));
|
||||
getTextField(2).integersOnly = true;
|
||||
@@ -44,7 +39,7 @@ public class GuiNpcBard extends GuiNPCInterface2
|
||||
|
||||
addLabel(new GuiNpcLabel(4,"bard.hasoff", guiLeft + 60, guiTop + 166));
|
||||
addButton(new GuiNpcButton(4, guiLeft + 160, guiTop + 161, 60, 20, new String[]{"gui.no","gui.yes"}, job.hasOffRange?1:0));
|
||||
|
||||
|
||||
addLabel(new GuiNpcLabel(3,"bard.offdistance", guiLeft + 60, guiTop + 189));
|
||||
addTextField(new GuiNpcTextField(3,this, this.fontRendererObj, guiLeft+160, guiTop + 184, 40, 20, job.maxRange + ""));
|
||||
getTextField(3).integersOnly = true;
|
||||
@@ -52,11 +47,7 @@ public class GuiNpcBard extends GuiNPCInterface2
|
||||
|
||||
getLabel(3).enabled = job.hasOffRange;
|
||||
getTextField(3).enabled = job.hasOffRange;
|
||||
|
||||
}
|
||||
@Override
|
||||
public void elementClicked(){
|
||||
job.song = gui.getSelected();
|
||||
|
||||
}
|
||||
|
||||
protected void actionPerformed(GuiButton guibutton)
|
||||
@@ -64,12 +55,8 @@ public class GuiNpcBard extends GuiNPCInterface2
|
||||
GuiNpcButton button = (GuiNpcButton) guibutton;
|
||||
if(button.id == 0)
|
||||
{
|
||||
|
||||
gui = new GuiNpcSoundSelection(this, job.song);
|
||||
NoppesUtil.openGUI(player, gui);
|
||||
|
||||
job.song = "";
|
||||
MusicController.Instance.stopMusic();
|
||||
setSubGui(new GuiSoundSelection(job.song));
|
||||
MusicController.Instance.stopMusic();
|
||||
}
|
||||
if(button.id == 1)
|
||||
{
|
||||
@@ -91,14 +78,14 @@ public class GuiNpcBard extends GuiNPCInterface2
|
||||
job.hasOffRange = button.getValue() == 1;
|
||||
initGui();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
job.minRange = getTextField(2).getInteger();
|
||||
job.maxRange = getTextField(3).getInteger();
|
||||
|
||||
|
||||
if(job.minRange > job.maxRange)
|
||||
job.maxRange = job.minRange;
|
||||
|
||||
@@ -107,4 +94,12 @@ public class GuiNpcBard extends GuiNPCInterface2
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void subGuiClosed(SubGuiInterface subgui) {
|
||||
GuiSoundSelection gss = (GuiSoundSelection) subgui;
|
||||
if(gss.selectedResource != null) {
|
||||
job.song = gss.selectedResource.toString();
|
||||
getLabel(0).label = job.song;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,13 @@
|
||||
package noppes.npcs.client.gui.roles;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import noppes.npcs.client.NoppesUtil;
|
||||
import noppes.npcs.client.gui.GuiNpcSoundSelection;
|
||||
import noppes.npcs.client.gui.select.GuiSoundSelection;
|
||||
import noppes.npcs.client.gui.util.*;
|
||||
|
||||
public class SubGuiNpcConversationLine extends SubGuiInterface implements ITextfieldListener{
|
||||
public class SubGuiNpcConversationLine extends SubGuiInterface implements ITextfieldListener, ISubGuiListener {
|
||||
public String line;
|
||||
public String sound;
|
||||
private GuiNpcSoundSelection gui;
|
||||
|
||||
|
||||
public SubGuiNpcConversationLine(String line, String sound){
|
||||
this.line = line;
|
||||
this.sound = sound;
|
||||
@@ -21,31 +19,27 @@ public class SubGuiNpcConversationLine extends SubGuiInterface implements ITextf
|
||||
|
||||
public void initGui(){
|
||||
super.initGui();
|
||||
|
||||
|
||||
addLabel(new GuiNpcLabel(0, "Line", guiLeft + 4, guiTop+ 10));
|
||||
addTextField(new GuiNpcTextField(0, this, fontRendererObj, guiLeft + 4, guiTop + 22, 200, 20, line));
|
||||
|
||||
addButton(new GuiNpcButton(1, guiLeft + 4, guiTop + 55, 90, 20, "Select Sound"));
|
||||
addButton(new GuiNpcButton(2, guiLeft + 96, guiTop + 55, 20, 20, "X"));
|
||||
addLabel(new GuiNpcLabel(1, sound, guiLeft + 4, guiTop + 81));
|
||||
|
||||
|
||||
addButton(new GuiNpcButton(66, guiLeft + 162, guiTop + 192, 90, 20, "gui.done"));
|
||||
}
|
||||
|
||||
public void unFocused(GuiNpcTextField textfield) {
|
||||
line = textfield.getText();
|
||||
}
|
||||
@Override
|
||||
public void unFocused(GuiNpcTextField textfield) {
|
||||
line = textfield.getText();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void elementClicked(){
|
||||
sound = gui.getSelected();
|
||||
}
|
||||
|
||||
protected void actionPerformed(GuiButton guibutton){
|
||||
int id = guibutton.id;
|
||||
if(id == 1){
|
||||
gui = new GuiNpcSoundSelection(parent, sound);
|
||||
NoppesUtil.openGUI(player, gui);
|
||||
setSubGui(new GuiSoundSelection(sound));
|
||||
}
|
||||
if(id == 2){
|
||||
sound = "";
|
||||
@@ -56,4 +50,12 @@ public class SubGuiNpcConversationLine extends SubGuiInterface implements ITextf
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void subGuiClosed(SubGuiInterface subgui) {
|
||||
GuiSoundSelection gss = (GuiSoundSelection) subgui;
|
||||
if(gss.selectedResource != null) {
|
||||
sound = gss.selectedResource.toString();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
//package noppes.npcs.client.gui.select;
|
||||
//
|
||||
//import com.google.common.collect.Lists;
|
||||
//import net.minecraft.client.gui.GuiButton;
|
||||
//import noppes.npcs.client.gui.util.*;
|
||||
//import noppes.npcs.controllers.DialogController;
|
||||
//import noppes.npcs.controllers.data.Dialog;
|
||||
//import noppes.npcs.controllers.data.DialogCategory;
|
||||
//
|
||||
//import java.util.HashMap;
|
||||
//
|
||||
//public class GuiDialogSelection extends SubGuiInterface implements ICustomScrollListener{
|
||||
// private HashMap<String,DialogCategory> categoryData = new HashMap<String,DialogCategory>();
|
||||
// private HashMap<String,Dialog> dialogData = new HashMap<String,Dialog>();
|
||||
//
|
||||
// private GuiCustomScroll scrollCategories;
|
||||
// private GuiCustomScroll scrollDialogs;
|
||||
//
|
||||
// private DialogCategory selectedCategory;
|
||||
// public Dialog selectedDialog;
|
||||
//
|
||||
// private GuiSelectionListener listener;
|
||||
//
|
||||
// public GuiDialogSelection(int dialog){
|
||||
// drawDefaultBackground = false;
|
||||
// title = "";
|
||||
// setBackground("menubg.png");
|
||||
// xSize = 366;
|
||||
// ySize = 226;
|
||||
// this.selectedDialog = DialogController.instance.dialogs.get(dialog);
|
||||
// if(selectedDialog != null) {
|
||||
// selectedCategory = selectedDialog.category;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void initGui(){
|
||||
// super.initGui();
|
||||
//
|
||||
// if(parent instanceof GuiSelectionListener){
|
||||
// listener = (GuiSelectionListener) parent;
|
||||
// }
|
||||
// this.addLabel(new GuiNpcLabel(0, "gui.categories", guiLeft + 8, guiTop + 4));
|
||||
// this.addLabel(new GuiNpcLabel(1, "dialog.dialogs", guiLeft + 175, guiTop + 4));
|
||||
//
|
||||
// this.addButton(new GuiNpcButton(2, guiLeft + xSize - 26, guiTop + 4, 20, 20, "X"));
|
||||
//
|
||||
// HashMap<String,DialogCategory> categoryData = new HashMap<String,DialogCategory>();
|
||||
// HashMap<String,Dialog> dialogData = new HashMap<String,Dialog>();
|
||||
//
|
||||
// for(DialogCategory category : DialogController.instance.categories.values()) {
|
||||
// categoryData.put(category.title, category);
|
||||
// }
|
||||
// this.categoryData = categoryData;
|
||||
//
|
||||
// if(selectedCategory != null) {
|
||||
// for(Dialog dialog : selectedCategory.dialogs.values()) {
|
||||
// dialogData.put(dialog.title, dialog);
|
||||
// }
|
||||
// }
|
||||
// this.dialogData = dialogData;
|
||||
//
|
||||
// if(scrollCategories == null){
|
||||
// scrollCategories = new GuiCustomScroll(this,0);
|
||||
// scrollCategories.setSize(170, 200);
|
||||
// }
|
||||
// scrollCategories.setList(Lists.newArrayList(categoryData.keySet()));
|
||||
// if(selectedCategory != null) {
|
||||
// scrollCategories.setSelected(selectedCategory.title);
|
||||
// }
|
||||
//
|
||||
// scrollCategories.guiLeft = guiLeft + 4;
|
||||
// scrollCategories.guiTop = guiTop + 14;
|
||||
// this.addScroll(scrollCategories);
|
||||
//
|
||||
// if(scrollDialogs == null){
|
||||
// scrollDialogs = new GuiCustomScroll(this,1);
|
||||
// scrollDialogs.setSize(170, 200);
|
||||
// }
|
||||
// scrollDialogs.setList(Lists.newArrayList(dialogData.keySet()));
|
||||
// if(selectedDialog != null) {
|
||||
// scrollDialogs.setSelected(selectedDialog.title);
|
||||
// }
|
||||
// scrollDialogs.guiLeft = guiLeft + 175;
|
||||
// scrollDialogs.guiTop = guiTop + 14;
|
||||
// this.addScroll(scrollDialogs);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void scrollClicked(int i, int j, int k, GuiCustomScroll guiCustomScroll) {
|
||||
// if(guiCustomScroll.id == 0){
|
||||
// selectedCategory = categoryData.get(scrollCategories.getSelected());
|
||||
// selectedDialog = null;
|
||||
// scrollDialogs.selected = -1;
|
||||
// }
|
||||
// if(guiCustomScroll.id == 1){
|
||||
// selectedDialog = dialogData.get(scrollDialogs.getSelected());
|
||||
// }
|
||||
// initGui();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void scrollDoubleClicked(String selection, GuiCustomScroll scroll) {
|
||||
// if(selectedDialog == null)
|
||||
// return;
|
||||
// if(listener != null) {
|
||||
// listener.selected(selectedDialog.id, selectedDialog.title);
|
||||
// }
|
||||
// close();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// protected void actionPerformed(GuiButton guibutton){
|
||||
// int id = guibutton.id;
|
||||
// if(id == 2){
|
||||
// if(selectedDialog != null) {
|
||||
// scrollDoubleClicked(null, null);
|
||||
// }
|
||||
// else {
|
||||
// close();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
@@ -0,0 +1,124 @@
|
||||
//package noppes.npcs.client.gui.select;
|
||||
//
|
||||
//import com.google.common.collect.Lists;
|
||||
//import net.minecraft.client.gui.GuiButton;
|
||||
//import noppes.npcs.client.gui.util.*;
|
||||
//import noppes.npcs.controllers.QuestController;
|
||||
//import noppes.npcs.controllers.data.Quest;
|
||||
//import noppes.npcs.controllers.data.QuestCategory;
|
||||
//
|
||||
//import java.util.HashMap;
|
||||
//
|
||||
//public class GuiQuestSelection extends SubGuiInterface implements ICustomScrollListener{
|
||||
// private HashMap<String,QuestCategory> categoryData = new HashMap<String,QuestCategory>();
|
||||
// private HashMap<String,Quest> questData = new HashMap<String,Quest>();
|
||||
//
|
||||
// private GuiCustomScroll scrollCategories;
|
||||
// private GuiCustomScroll scrollQuests;
|
||||
//
|
||||
// private QuestCategory selectedCategory;
|
||||
// public Quest selectedQuest;
|
||||
//
|
||||
// private GuiSelectionListener listener;
|
||||
//
|
||||
// public GuiQuestSelection(int quest){
|
||||
// drawDefaultBackground = false;
|
||||
// title = "";
|
||||
// setBackground("menubg.png");
|
||||
// xSize = 366;
|
||||
// ySize = 226;
|
||||
// this.selectedQuest = QuestController.instance.quests.get(quest);
|
||||
// if(selectedQuest != null) {
|
||||
// selectedCategory = selectedQuest.category;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void initGui(){
|
||||
// super.initGui();
|
||||
//
|
||||
// if(parent instanceof GuiSelectionListener){
|
||||
// listener = (GuiSelectionListener) parent;
|
||||
// }
|
||||
// this.addLabel(new GuiNpcLabel(0, "gui.categories", guiLeft + 8, guiTop + 4));
|
||||
// this.addLabel(new GuiNpcLabel(1, "quest.quests", guiLeft + 175, guiTop + 4));
|
||||
//
|
||||
// this.addButton(new GuiNpcButton(2, guiLeft + xSize - 26, guiTop + 4, 20, 20, "X"));
|
||||
//
|
||||
// HashMap<String,QuestCategory> categoryData = new HashMap<String,QuestCategory>();
|
||||
// HashMap<String,Quest> questData = new HashMap<String,Quest>();
|
||||
//
|
||||
// for(QuestCategory category : QuestController.instance.categories.values()) {
|
||||
// categoryData.put(category.title, category);
|
||||
// }
|
||||
// this.categoryData = categoryData;
|
||||
//
|
||||
// if(selectedCategory != null) {
|
||||
// for(Quest quest : selectedCategory.quests.values()) {
|
||||
// questData.put(quest.title, quest);
|
||||
// }
|
||||
// }
|
||||
// this.questData = questData;
|
||||
//
|
||||
// if(scrollCategories == null){
|
||||
// scrollCategories = new GuiCustomScroll(this,0);
|
||||
// scrollCategories.setSize(170, 200);
|
||||
// }
|
||||
// scrollCategories.setList(Lists.newArrayList(categoryData.keySet()));
|
||||
// if(selectedCategory != null) {
|
||||
// scrollCategories.setSelected(selectedCategory.title);
|
||||
// }
|
||||
//
|
||||
// scrollCategories.guiLeft = guiLeft + 4;
|
||||
// scrollCategories.guiTop = guiTop + 14;
|
||||
// this.addScroll(scrollCategories);
|
||||
//
|
||||
// if(scrollQuests == null){
|
||||
// scrollQuests = new GuiCustomScroll(this,1);
|
||||
// scrollQuests.setSize(170, 200);
|
||||
// }
|
||||
// scrollQuests.setList(Lists.newArrayList(questData.keySet()));
|
||||
// if(selectedQuest != null) {
|
||||
// scrollQuests.setSelected(selectedQuest.title);
|
||||
// }
|
||||
// scrollQuests.guiLeft = guiLeft + 175;
|
||||
// scrollQuests.guiTop = guiTop + 14;
|
||||
// this.addScroll(scrollQuests);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void scrollClicked(int i, int j, int k, GuiCustomScroll guiCustomScroll) {
|
||||
// if(guiCustomScroll.id == 0){
|
||||
// selectedCategory = categoryData.get(scrollCategories.getSelected());
|
||||
// selectedQuest = null;
|
||||
// scrollQuests.selected = -1;
|
||||
// }
|
||||
// if(guiCustomScroll.id == 1){
|
||||
// selectedQuest = questData.get(scrollQuests.getSelected());
|
||||
// }
|
||||
// initGui();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void scrollDoubleClicked(String selection, GuiCustomScroll scroll) {
|
||||
// if(selectedQuest == null)
|
||||
// return;
|
||||
// if(listener != null) {
|
||||
// listener.selected(selectedQuest.id, selectedQuest.title);
|
||||
// }
|
||||
// close();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// protected void actionPerformed(GuiButton guibutton){
|
||||
// int id = guibutton.id;
|
||||
// if(id == 2){
|
||||
// if(selectedQuest != null) {
|
||||
// scrollDoubleClicked(null, null);
|
||||
// }
|
||||
// else {
|
||||
// close();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
@@ -0,0 +1,181 @@
|
||||
package noppes.npcs.client.gui.select;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import cpw.mods.fml.relauncher.ReflectionHelper;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.audio.SoundHandler;
|
||||
import net.minecraft.client.audio.SoundRegistry;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import noppes.npcs.client.controllers.MusicController;
|
||||
import noppes.npcs.client.gui.util.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class GuiSoundSelection extends SubGuiInterface implements ICustomScrollListener{
|
||||
|
||||
private GuiCustomScroll scrollCategories;
|
||||
private GuiCustomScroll scrollSounds;
|
||||
|
||||
private String selectedDomain;
|
||||
public ResourceLocation selectedResource;
|
||||
|
||||
private String catSearch = "";
|
||||
private String soundSearch = "";
|
||||
|
||||
private HashMap<String,List<String>> domains = new HashMap<String,List<String>>();
|
||||
|
||||
public GuiSoundSelection(String sound){
|
||||
drawDefaultBackground = false;
|
||||
title = "";
|
||||
setBackground("menubg.png");
|
||||
xSize = 366;
|
||||
ySize = 226;
|
||||
|
||||
SoundHandler handler = Minecraft.getMinecraft().getSoundHandler();
|
||||
SoundRegistry registry = ReflectionHelper.getPrivateValue(SoundHandler.class, handler, 4);
|
||||
|
||||
Set<ResourceLocation> set = registry.getKeys();
|
||||
for(ResourceLocation location : set){
|
||||
List<String> list = domains.get(location.getResourceDomain());
|
||||
if(list == null)
|
||||
domains.put(location.getResourceDomain(), list = new ArrayList<String>());
|
||||
list.add(location.getResourcePath());
|
||||
domains.put(location.getResourceDomain(), list);
|
||||
}
|
||||
if(sound != null && !sound.isEmpty()){
|
||||
selectedResource = new ResourceLocation(sound);
|
||||
selectedDomain = selectedResource.getResourceDomain();
|
||||
if(!domains.containsKey(selectedDomain)) {
|
||||
selectedDomain = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui(){
|
||||
super.initGui();
|
||||
this.addButton(new GuiNpcButton(2, guiLeft + xSize - 45, guiTop + ySize - 35, 40, 20, "gui.done"));
|
||||
this.addButton(new GuiNpcButton(1, guiLeft + 4, guiTop + ySize - 35, 70, 20, "gui.play"));
|
||||
getButton(1).enabled = selectedResource != null;
|
||||
|
||||
if(scrollCategories == null){
|
||||
scrollCategories = new GuiCustomScroll(this,0, 0);
|
||||
scrollCategories.setSize(90, 163);
|
||||
}
|
||||
scrollCategories.setList(Lists.newArrayList(domains.keySet()));
|
||||
if(selectedDomain != null) {
|
||||
scrollCategories.setSelected(selectedDomain);
|
||||
}
|
||||
|
||||
scrollCategories.guiLeft = guiLeft + 4;
|
||||
scrollCategories.guiTop = guiTop + 4;
|
||||
this.addScroll(scrollCategories);
|
||||
addTextField(new GuiNpcTextField(55, this, fontRendererObj, guiLeft + 4, guiTop + 169, 90, 20, catSearch));
|
||||
|
||||
if(scrollSounds == null){
|
||||
scrollSounds = new GuiCustomScroll(this,1, 0);
|
||||
scrollSounds.setSize(265, 163);
|
||||
}
|
||||
if(selectedDomain != null) {
|
||||
scrollSounds.setList(domains.get(selectedDomain));
|
||||
}
|
||||
if(selectedResource != null) {
|
||||
scrollSounds.setSelected(selectedResource.getResourcePath());
|
||||
}
|
||||
scrollSounds.guiLeft = guiLeft + 95;
|
||||
scrollSounds.guiTop = guiTop + 4;
|
||||
this.addScroll(scrollSounds);
|
||||
|
||||
addTextField(new GuiNpcTextField(66, this, fontRendererObj, guiLeft + 95, guiTop + 169, 265, 20, soundSearch));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton guibutton){
|
||||
super.actionPerformed(guibutton);
|
||||
if(guibutton.id == 1){
|
||||
MusicController.Instance.stopMusic();
|
||||
MusicController.Instance.playSound(selectedResource.toString(), (float)player.posX, (float)player.posY, (float)player.posZ);
|
||||
}
|
||||
if(guibutton.id == 2){
|
||||
close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void customScrollDoubleClicked(String selection, GuiCustomScroll scroll) {
|
||||
if(selectedResource == null)
|
||||
return;
|
||||
close();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void customScrollClicked(int i, int j, int k, GuiCustomScroll guiCustomScroll) {
|
||||
if(guiCustomScroll.id == 0){
|
||||
selectedDomain = guiCustomScroll.getSelected();
|
||||
selectedResource = null;
|
||||
scrollSounds.selected = -1;
|
||||
scrollSounds.resetScroll();
|
||||
getTextField(66).setText("");
|
||||
soundSearch = "";
|
||||
}
|
||||
if(guiCustomScroll.id == 1){
|
||||
selectedResource = new ResourceLocation(selectedDomain, guiCustomScroll.getSelected());
|
||||
}
|
||||
initGui();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped(char c, int i)
|
||||
{
|
||||
super.keyTyped(c, i);
|
||||
if(getTextField(55) != null){
|
||||
if(getTextField(55).isFocused()){
|
||||
if(catSearch.equals(getTextField(55).getText()))
|
||||
return;
|
||||
catSearch = getTextField(55).getText().toLowerCase();
|
||||
scrollCategories.setList(getCatSearch());
|
||||
}
|
||||
}
|
||||
if(getTextField(66) != null){
|
||||
if(getTextField(66).isFocused()){
|
||||
if(soundSearch.equals(getTextField(66).getText()))
|
||||
return;
|
||||
soundSearch = getTextField(66).getText().toLowerCase();
|
||||
scrollSounds.setList(getSoundSearch());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private List<String> getCatSearch(){
|
||||
if(catSearch.isEmpty()){
|
||||
return new ArrayList<String>(this.domains.keySet());
|
||||
}
|
||||
List<String> list = new ArrayList<String>();
|
||||
for(String name : this.domains.keySet()){
|
||||
if(name.toLowerCase().contains(catSearch))
|
||||
list.add(name);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private List<String> getSoundSearch(){
|
||||
if(selectedDomain == null){
|
||||
return new ArrayList<String>();
|
||||
}
|
||||
|
||||
if(soundSearch.isEmpty()){
|
||||
return new ArrayList<String>(this.domains.get(selectedDomain));
|
||||
}
|
||||
List<String> list = new ArrayList<String>();
|
||||
for(String name : this.domains.get(selectedDomain)){
|
||||
if(name.toLowerCase().contains(soundSearch))
|
||||
list.add(name);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,376 @@
|
||||
//package noppes.npcs.client.gui.select;
|
||||
//
|
||||
//import com.google.common.collect.Lists;
|
||||
//import net.minecraft.client.Minecraft;
|
||||
//import net.minecraft.client.gui.GuiButton;
|
||||
//import net.minecraft.client.resources.*;
|
||||
//import net.minecraft.item.crafting.CraftingManager;
|
||||
//import net.minecraft.util.ResourceLocation;
|
||||
//import noppes.npcs.CustomNpcs;
|
||||
//import noppes.npcs.LogWriter;
|
||||
//import noppes.npcs.client.gui.util.GuiCustomScroll;
|
||||
//import noppes.npcs.client.gui.util.GuiNpcButton;
|
||||
//import noppes.npcs.client.gui.util.ICustomScrollListener;
|
||||
//import noppes.npcs.client.gui.util.SubGuiInterface;
|
||||
//import noppes.npcs.entity.EntityNPCInterface;
|
||||
//
|
||||
//import java.io.File;
|
||||
//import java.io.UnsupportedEncodingException;
|
||||
//import java.net.URL;
|
||||
//import java.net.URLDecoder;
|
||||
//import java.nio.charset.StandardCharsets;
|
||||
//import java.util.*;
|
||||
//import java.util.zip.ZipEntry;
|
||||
//import java.util.zip.ZipFile;
|
||||
//
|
||||
//public class GuiTextureSelection extends SubGuiInterface implements ICustomScrollListener{
|
||||
//
|
||||
// private String up = "..<" + I18n.translateToLocal("gui.up") + ">..";
|
||||
// private GuiCustomScroll scrollCategories;
|
||||
// private GuiCustomScroll scrollQuests;
|
||||
//
|
||||
// private String location = "";
|
||||
// private String selectedDomain;
|
||||
// public ResourceLocation selectedResource;
|
||||
//
|
||||
// private HashMap<String,List<TextureData>> domains = new HashMap<String,List<TextureData>>();
|
||||
// private HashMap<String, TextureData> textures = new HashMap<String, TextureData>();
|
||||
//
|
||||
// public GuiTextureSelection(EntityNPCInterface npc, String texture){
|
||||
// this.npc = npc;
|
||||
// drawDefaultBackground = false;
|
||||
// title = "";
|
||||
// setBackground("menubg.png");
|
||||
// xSize = 366;
|
||||
// ySize = 226;
|
||||
//
|
||||
// SimpleReloadableResourceManager simplemanager = (SimpleReloadableResourceManager) Minecraft.getMinecraft().getResourceManager();
|
||||
//
|
||||
// Map<String, FallbackResourceManager> map = ObfuscationReflectionHelper.getPrivateValue(SimpleReloadableResourceManager.class, simplemanager, 2);
|
||||
// HashSet<String> set = new HashSet<String>();
|
||||
// for(String name: map.keySet()){
|
||||
// FallbackResourceManager manager = map.get(name);
|
||||
// List<IResourcePack> list = ObfuscationReflectionHelper.getPrivateValue(FallbackResourceManager.class, manager, 1);
|
||||
// for(IResourcePack pack : list){
|
||||
// if(pack instanceof LegacyV2Adapter) {
|
||||
// pack = ObfuscationReflectionHelper.getPrivateValue(LegacyV2Adapter.class, (LegacyV2Adapter)pack, 0);;
|
||||
// }
|
||||
// if(pack instanceof AbstractResourcePack){
|
||||
// AbstractResourcePack p = (AbstractResourcePack) pack;
|
||||
// File file = p.resourcePackFile;
|
||||
// if(file != null)
|
||||
// set.add(file.getAbsolutePath());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// for(String file : set){
|
||||
// File f = new File(file);
|
||||
// if(f.isDirectory()) {
|
||||
// checkFolder(new File(f, "assets"), f.getAbsolutePath().length());
|
||||
// }
|
||||
// else {
|
||||
// progressFile(f);
|
||||
// }
|
||||
// }
|
||||
// for (ModContainer mod : Loader.instance().getModList()) {
|
||||
// if(mod.getSource().exists())
|
||||
// progressFile(mod.getSource());
|
||||
// }
|
||||
//
|
||||
// ResourcePackRepository repos = Minecraft.getMinecraft().getResourcePackRepository();
|
||||
// repos.updateRepositoryEntriesAll();
|
||||
// List<ResourcePackRepository.Entry> list = repos.getRepositoryEntries();
|
||||
// if(repos.getServerResourcePack() != null) {
|
||||
// AbstractResourcePack p = (AbstractResourcePack) repos.getServerResourcePack();
|
||||
// File file = p.resourcePackFile;
|
||||
// if(file != null)
|
||||
// progressFile(file);
|
||||
// }
|
||||
// for(ResourcePackRepository.Entry entry : list) {
|
||||
// File file = new File(repos.getDirResourcepacks(),entry.getResourcePackName());
|
||||
// if(file.exists()){
|
||||
// progressFile(file);
|
||||
// }
|
||||
// }
|
||||
// checkFolder(new File(CustomNpcs.Dir,"assets"),CustomNpcs.Dir.getAbsolutePath().length());
|
||||
//
|
||||
// URL url = DefaultResourcePack.class.getResource("/");
|
||||
// if(url != null) {
|
||||
// File f = decodeFile(url.getFile());
|
||||
// if(f.isDirectory()) {
|
||||
// checkFolder(new File(f,"assets"), url.getFile().length());
|
||||
// }
|
||||
// else {
|
||||
// progressFile(f);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// url = CraftingManager.class.getResource("/assets/.mcassetsroot");
|
||||
// if(url != null) {
|
||||
// File f = decodeFile(url.getFile());
|
||||
// if(f.isDirectory()) {
|
||||
// checkFolder(new File(f,"assets"), url.getFile().length());
|
||||
// }
|
||||
// else {
|
||||
// progressFile(f);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if(texture != null && !texture.isEmpty()){
|
||||
// selectedResource = new ResourceLocation(texture);
|
||||
// selectedDomain = selectedResource.getResourceDomain();
|
||||
// if(!domains.containsKey(selectedDomain)) {
|
||||
// selectedDomain = null;
|
||||
// }
|
||||
// int i = selectedResource.getResourcePath().lastIndexOf('/');
|
||||
// location = selectedResource.getResourcePath().substring(0, i + 1);
|
||||
// if(location.startsWith("textures/")){
|
||||
// location = location.substring(9);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// private File decodeFile(String url) {
|
||||
// if(url.startsWith("file:")) {
|
||||
// url = url.substring(5);
|
||||
// }
|
||||
// url = url.replace('/', File.separatorChar);
|
||||
// int i = url.indexOf('!');
|
||||
// if(i > 0) {
|
||||
// url = url.substring(0, i);
|
||||
// }
|
||||
// try {
|
||||
// url = URLDecoder.decode(url, StandardCharsets.UTF_8.name());
|
||||
// } catch (UnsupportedEncodingException e) {
|
||||
// }
|
||||
// return new File(url);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void initGui(){
|
||||
// super.initGui();
|
||||
//
|
||||
// if(selectedDomain != null) {
|
||||
// title = selectedDomain + ":" + location;
|
||||
// }
|
||||
// else {
|
||||
// title = "";
|
||||
// }
|
||||
//
|
||||
// this.addButton(new GuiNpcButton(2, guiLeft + 264, guiTop + 170, 90, 20, "gui.done"));
|
||||
// this.addButton(new GuiNpcButton(1, guiLeft + 264, guiTop + 190, 90, 20, "gui.cancel"));
|
||||
//
|
||||
// if(scrollCategories == null){
|
||||
// scrollCategories = new GuiCustomScroll(this,0);
|
||||
// scrollCategories.setSize(120, 200);
|
||||
// }
|
||||
//
|
||||
// if(selectedDomain == null) {
|
||||
// scrollCategories.setList(Lists.newArrayList(domains.keySet()));
|
||||
// if(selectedDomain != null) {
|
||||
// scrollCategories.setSelected(selectedDomain);
|
||||
// }
|
||||
// }
|
||||
// else {
|
||||
// List<String> list = new ArrayList<String>();
|
||||
// list.add(up);
|
||||
// List<TextureData> data = domains.get(selectedDomain);
|
||||
// for(TextureData td : data) {
|
||||
// if(location.isEmpty() || td.path.startsWith(location) && !td.path.equals(location)) {
|
||||
// String path = td.path.substring(location.length());
|
||||
// int i = path.indexOf('/');
|
||||
// if(i < 0)
|
||||
// continue;
|
||||
// path = path.substring(0, i);
|
||||
// if(!path.isEmpty() && !list.contains(path)) {
|
||||
// list.add(path);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// scrollCategories.setList(list);
|
||||
// }
|
||||
// scrollCategories.guiLeft = guiLeft + 4;
|
||||
// scrollCategories.guiTop = guiTop + 14;
|
||||
// this.addScroll(scrollCategories);
|
||||
//
|
||||
// if(scrollQuests == null){
|
||||
// scrollQuests = new GuiCustomScroll(this,1);
|
||||
// scrollQuests.setSize(130, 200);
|
||||
// }
|
||||
// if(selectedDomain != null) {
|
||||
// textures.clear();
|
||||
// List<TextureData> data = domains.get(selectedDomain);
|
||||
// List<String> list = new ArrayList<String>();
|
||||
// String loc = location;
|
||||
// if(scrollCategories.hasSelected() && !scrollCategories.getSelected().equals(up)) {
|
||||
// loc += scrollCategories.getSelected() + '/';
|
||||
// }
|
||||
// for(TextureData td : data) {
|
||||
// if(td.path.equals(loc) && !list.contains(td.name)) {
|
||||
// list.add(td.name);
|
||||
// textures.put(td.name, td);
|
||||
// }
|
||||
// }
|
||||
// scrollQuests.setList(list);
|
||||
// }
|
||||
// if(selectedResource != null) {
|
||||
// scrollQuests.setSelected(selectedResource.getResourcePath());
|
||||
// }
|
||||
// scrollQuests.guiLeft = guiLeft + 125;
|
||||
// scrollQuests.guiTop = guiTop + 14;
|
||||
// this.addScroll(scrollQuests);
|
||||
//
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// protected void actionPerformed(GuiButton guibutton){
|
||||
// super.actionPerformed(guibutton);
|
||||
// if(guibutton.id == 2){
|
||||
// npc.display.setSkinTexture(selectedResource.toString());
|
||||
// }
|
||||
// npc.textureLocation = null;
|
||||
// close();
|
||||
// parent.initGui();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void drawScreen(int i, int j, float f){
|
||||
// super.drawScreen(i, j, f);
|
||||
//
|
||||
// npc.textureLocation = selectedResource;
|
||||
// drawNpc(npc, guiLeft + 276, guiTop + 140, 2, 0);
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @Override
|
||||
// public void scrollClicked(int i, int j, int k, GuiCustomScroll scroll) {
|
||||
// if(scroll == scrollQuests) {
|
||||
// if(scroll.id == 1){
|
||||
// TextureData data = textures.get(scroll.getSelected());
|
||||
// selectedResource = new ResourceLocation(selectedDomain, data.absoluteName);
|
||||
// }
|
||||
// }
|
||||
// else {
|
||||
// initGui();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void scrollDoubleClicked(String selection, GuiCustomScroll scroll) {
|
||||
// if(scroll == scrollCategories) {
|
||||
// if(selectedDomain == null) {
|
||||
// selectedDomain = selection;
|
||||
// }
|
||||
// else if(selection.equals(up)) {
|
||||
// int i = location.lastIndexOf('/', location.length() - 2);
|
||||
// if(i < 0) {
|
||||
// if(location.isEmpty()) {
|
||||
// selectedDomain = null;
|
||||
// }
|
||||
// location = "";
|
||||
// }
|
||||
// else {
|
||||
// location = location.substring(0, i + 1);
|
||||
// }
|
||||
// }
|
||||
// else {
|
||||
// location = location + selection + '/';
|
||||
// }
|
||||
// scrollCategories.selected = -1;
|
||||
// scrollQuests.selected = -1;
|
||||
// initGui();
|
||||
// }
|
||||
// else {
|
||||
// npc.display.setSkinTexture(selectedResource.toString());
|
||||
// close();
|
||||
// parent.initGui();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private void progressFile(File file){
|
||||
// try {
|
||||
// if (!file.isDirectory() && (file.getName().endsWith(".jar") || file.getName().endsWith(".zip")))
|
||||
// {
|
||||
// ZipFile zip = new ZipFile(file);
|
||||
// Enumeration<? extends ZipEntry> entries = zip.entries();
|
||||
// while(entries.hasMoreElements()){
|
||||
// ZipEntry zipentry = entries.nextElement();
|
||||
// String entryName = zipentry.getName();
|
||||
// addFile(entryName);
|
||||
//
|
||||
// }
|
||||
// zip.close();
|
||||
// }
|
||||
// else if(file.isDirectory()){
|
||||
// int length = file.getAbsolutePath().length();
|
||||
// checkFolder(file,length);
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private void checkFolder(File file, int length){
|
||||
// File[] files = file.listFiles();
|
||||
// if(files == null){
|
||||
// return;
|
||||
// }
|
||||
// for(File f : files){
|
||||
// String name = null;
|
||||
// try {
|
||||
// name = f.getAbsolutePath().substring(length);
|
||||
// name = name.replace("\\", "/");
|
||||
// if(!name.startsWith("/"))
|
||||
// name = "/" + name;
|
||||
// if(f.isDirectory()){
|
||||
// addFile(name + "/");
|
||||
// checkFolder(f, length);
|
||||
// }
|
||||
// else
|
||||
// addFile(name);
|
||||
// }
|
||||
// catch(Throwable e) {
|
||||
// LogWriter.error("error with: " + name, e);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// private void addFile(String name) {
|
||||
// name = name.toLowerCase();
|
||||
// if(name.startsWith("/")) {
|
||||
// name = name.substring(1);
|
||||
// }
|
||||
// if(!name.startsWith("assets/") || !name.toLowerCase().endsWith(".png")) {
|
||||
// return;
|
||||
// }
|
||||
// name = name.substring(7);
|
||||
// int i = name.indexOf('/');
|
||||
// String domain = name.substring(0, i);
|
||||
// name = name.substring(i + 10);
|
||||
//
|
||||
// List<TextureData> list = domains.get(domain);
|
||||
// if(list == null) {
|
||||
// domains.put(domain, list = new ArrayList<TextureData>());
|
||||
// }
|
||||
// boolean contains = false;
|
||||
// for(TextureData data : list) {
|
||||
// if(data.absoluteName.equals(name)) {
|
||||
// contains = true;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// if(!contains)
|
||||
// list.add(new TextureData(domain, name));
|
||||
// }
|
||||
// class TextureData{
|
||||
// String domain;
|
||||
// String absoluteName;
|
||||
// String name;
|
||||
// String path;
|
||||
// public TextureData(String domain, String absoluteName) {
|
||||
// this.domain = domain;
|
||||
// int i = absoluteName.lastIndexOf('/');
|
||||
// name = absoluteName.substring(i + 1);
|
||||
// path = absoluteName.substring(0, i + 1);
|
||||
// this.absoluteName = "textures/" + absoluteName;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
@@ -36,6 +36,9 @@ public class GuiCustomScroll extends GuiScreen
|
||||
public boolean visible = true;
|
||||
private boolean selectable = true;
|
||||
|
||||
private int lastClickedItem;
|
||||
private long lastClickedTime = 0;
|
||||
|
||||
public GuiCustomScroll(GuiScreen parent, int id)
|
||||
{
|
||||
width = 176;
|
||||
@@ -274,8 +277,16 @@ public class GuiCustomScroll extends GuiScreen
|
||||
selected = hover;
|
||||
hover = -1;
|
||||
}
|
||||
if(listener != null)
|
||||
listener.customScrollClicked(i, j, k,this);
|
||||
|
||||
if(listener != null) {
|
||||
long time = System.currentTimeMillis();
|
||||
listener.customScrollClicked(i, j, k, this);
|
||||
if(selected >= 0 && selected == lastClickedItem && time - lastClickedTime < 500) {
|
||||
listener.customScrollDoubleClicked(list.get(selected), this);
|
||||
}
|
||||
lastClickedTime = time;
|
||||
lastClickedItem = selected;
|
||||
}
|
||||
}
|
||||
|
||||
private void drawScrollBar()
|
||||
@@ -359,4 +370,8 @@ public class GuiCustomScroll extends GuiScreen
|
||||
public boolean isMouseOver(int x, int y) {
|
||||
return x >= this.guiLeft && x <= this.guiLeft + this.xSize && y >= this.guiTop && y <= this.guiTop + this.ySize;
|
||||
}
|
||||
|
||||
public void resetScroll(){
|
||||
scrollY = 0;
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,7 @@ public abstract class GuiNPCInterface2 extends GuiNPCInterface
|
||||
{
|
||||
private ResourceLocation background = new ResourceLocation("customnpcs:textures/gui/menubg.png");
|
||||
private GuiNpcMenu menu;
|
||||
|
||||
|
||||
public GuiNPCInterface2(EntityNPCInterface npc){
|
||||
this(npc, -1);
|
||||
}
|
||||
@@ -17,29 +17,29 @@ public abstract class GuiNPCInterface2 extends GuiNPCInterface
|
||||
xSize = 420;
|
||||
ySize = 200;
|
||||
menu = new GuiNpcMenu(this, activeMenu, npc);
|
||||
|
||||
|
||||
}
|
||||
@Override
|
||||
public void initGui(){
|
||||
super.initGui();
|
||||
menu.initGui(guiLeft, guiTop, xSize);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void mouseClicked(int i, int j, int k){
|
||||
super.mouseClicked(i, j, k);
|
||||
if(!hasSubGui())
|
||||
menu.mouseClicked(i, j, k);
|
||||
}
|
||||
|
||||
super.mouseClicked(i, j, k);
|
||||
}
|
||||
|
||||
public void delete(){
|
||||
npc.delete();
|
||||
displayGuiScreen(null);
|
||||
mc.setIngameFocus();
|
||||
}
|
||||
public abstract void save();
|
||||
|
||||
|
||||
@Override
|
||||
public void drawScreen(int i, int j, float f)
|
||||
{
|
||||
@@ -47,7 +47,7 @@ public abstract class GuiNPCInterface2 extends GuiNPCInterface
|
||||
drawDefaultBackground(); //drawDefaultBackground
|
||||
drawBackground();
|
||||
menu.drawElements(getFontRenderer(), i, j, mc, f);
|
||||
|
||||
|
||||
boolean bo = drawDefaultBackground;
|
||||
drawDefaultBackground = false;
|
||||
super.drawScreen(i, j, f);
|
||||
|
||||
@@ -6,4 +6,5 @@ public interface ICustomScrollListener {
|
||||
|
||||
void customScrollClicked(int i, int j, int k, GuiCustomScroll guiCustomScroll);
|
||||
|
||||
default void customScrollDoubleClicked(String selection, GuiCustomScroll scroll){}
|
||||
}
|
||||
@@ -16,6 +16,7 @@ public class ConfigMain
|
||||
public final static String GENERAL = "General";
|
||||
public final static String NPC = "NPC";
|
||||
public final static String UPDATE = "Update";
|
||||
public final static String SYNC = "SYNC";
|
||||
|
||||
/**
|
||||
* General Main Properties
|
||||
@@ -110,6 +111,19 @@ public class ConfigMain
|
||||
public static Property TrackedQuestUpdateFrequencyProperty;
|
||||
public static int TrackedQuestUpdateFrequency = 5;
|
||||
|
||||
/**
|
||||
* Sync Properties
|
||||
**/
|
||||
|
||||
public static Property SyncQuestAutoProperty;
|
||||
public static boolean SyncQuestAuto = true;
|
||||
|
||||
public static Property SyncDialogAutoProperty;
|
||||
public static boolean SyncDialogAuto = true;
|
||||
|
||||
public static Property SyncFactionAutoProperty;
|
||||
public static boolean SyncFactionAuto = true;
|
||||
|
||||
public static void init(File configFile)
|
||||
{
|
||||
config = new Configuration(configFile);
|
||||
@@ -202,6 +216,16 @@ public class ConfigMain
|
||||
TrackedQuestUpdateFrequencyProperty = config.get(UPDATE, "Tracked Quest Update Frequency", 5, "How often in seconds to update a players tracked quest. [Only applies to Item Quest currently]");
|
||||
TrackedQuestUpdateFrequency = TrackedQuestUpdateFrequencyProperty.getInt(5);
|
||||
|
||||
// Sync
|
||||
SyncQuestAutoProperty = config.get(SYNC, "Auto Sync Quest Data", true, "If enabled client will all Quest Data upon joining the world");
|
||||
SyncQuestAuto = SyncQuestAutoProperty.getBoolean(true);
|
||||
|
||||
SyncDialogAutoProperty = config.get(SYNC, "Auto Sync Dialog Data", true, "If enabled client will all Dialog Data upon joining the world");
|
||||
SyncDialogAuto = SyncDialogAutoProperty.getBoolean(true);
|
||||
|
||||
SyncFactionAutoProperty = config.get(SYNC, "Auto Sync Faction Data", true, "If enabled client will all Faction Data upon joining the world");
|
||||
SyncFactionAuto = SyncFactionAutoProperty.getBoolean(true);
|
||||
|
||||
// Convert to Legacy
|
||||
if(CustomNpcs.legacyExist){
|
||||
EnableUpdateChecker = LegacyConfig.EnableUpdateChecker;
|
||||
|
||||
@@ -6,7 +6,5 @@ public class SyncType {
|
||||
public static final int QUEST_CATEGORY = 3;
|
||||
public static final int DIALOG = 4;
|
||||
public static final int DIALOG_CATEGORY = 5;
|
||||
public static final int RECIPE_NORMAL = 6;
|
||||
public static final int RECIPE_CARPENTRY = 7;
|
||||
public static final int PLAYER_DATA = 8;
|
||||
public static final int PLAYER_DATA = 6;
|
||||
}
|
||||
@@ -230,7 +230,7 @@ public class DialogController implements IDialogHandler {
|
||||
dir.mkdirs();
|
||||
}
|
||||
categories.put(category.id, category);
|
||||
Server.sendToAll(EnumPacketClient.SYNC_UPDATE, SyncType.DIALOG_CATEGORY, category.writeNBT(new NBTTagCompound()));
|
||||
SyncController.updateDialogCat(category);
|
||||
}
|
||||
|
||||
public void removeCategory(int category){
|
||||
|
||||
@@ -177,8 +177,8 @@ public class QuestController implements IQuestHandler {
|
||||
dir.mkdirs();
|
||||
}
|
||||
categories.put(category.id, category);
|
||||
Server.sendToAll(EnumPacketClient.SYNC_UPDATE, SyncType.QUEST_CATEGORY, category.writeNBT(new NBTTagCompound()));
|
||||
}
|
||||
SyncController.updateQuestCat(category);
|
||||
}
|
||||
private boolean containsCategoryName(String name) {
|
||||
name = name.toLowerCase();
|
||||
for(QuestCategory cat : categories.values()){
|
||||
|
||||
@@ -208,10 +208,6 @@ public class RecipeController implements IRecipeHandler {
|
||||
return null;
|
||||
globalRecipes.remove(recipe.id);
|
||||
anvilRecipes.remove(recipe.id);
|
||||
if(recipe.isGlobal)
|
||||
Server.sendToAll(EnumPacketClient.SYNC_REMOVE, SyncType.RECIPE_NORMAL, id);
|
||||
else
|
||||
Server.sendToAll(EnumPacketClient.SYNC_REMOVE, SyncType.RECIPE_CARPENTRY, id);
|
||||
saveCategories();
|
||||
reloadGlobalRecipes(globalRecipes);
|
||||
return recipe;
|
||||
|
||||
@@ -4,14 +4,11 @@ import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import noppes.npcs.CustomNpcs;
|
||||
import noppes.npcs.NBTTags;
|
||||
import noppes.npcs.Server;
|
||||
import noppes.npcs.config.ConfigMain;
|
||||
import noppes.npcs.constants.EnumPacketClient;
|
||||
import noppes.npcs.constants.SyncType;
|
||||
import noppes.npcs.controllers.data.*;
|
||||
import noppes.npcs.items.ItemScripted;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
@@ -21,58 +18,77 @@ public class SyncController {
|
||||
NBTTagList list = new NBTTagList();
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
|
||||
for(Faction faction : FactionController.getInstance().factions.values()){
|
||||
NBTTagCompound factioNBT = new NBTTagCompound();
|
||||
faction.writeNBT(factioNBT);
|
||||
list.appendTag(factioNBT);
|
||||
if(list.tagCount() > 20){
|
||||
compound = new NBTTagCompound();
|
||||
compound.setTag("Data", list);
|
||||
Server.sendData(player, EnumPacketClient.SYNC_ADD, SyncType.FACTION, compound);
|
||||
list = new NBTTagList();
|
||||
}
|
||||
}
|
||||
compound = new NBTTagCompound();
|
||||
compound.setTag("Data", list);
|
||||
Server.sendData(player, EnumPacketClient.SYNC_END, SyncType.FACTION, compound);
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Faction Sync
|
||||
if(ConfigMain.SyncFactionAuto){
|
||||
for(Faction faction : FactionController.getInstance().factions.values()){
|
||||
NBTTagCompound factioNBT = new NBTTagCompound();
|
||||
faction.writeNBT(factioNBT);
|
||||
list.appendTag(factioNBT);
|
||||
if(list.tagCount() > 20){
|
||||
compound = new NBTTagCompound();
|
||||
compound.setTag("Data", list);
|
||||
Server.sendData(player, EnumPacketClient.SYNC_ADD, SyncType.FACTION, compound);
|
||||
list = new NBTTagList();
|
||||
}
|
||||
}
|
||||
compound = new NBTTagCompound();
|
||||
compound.setTag("Data", list);
|
||||
Server.sendData(player, EnumPacketClient.SYNC_END, SyncType.FACTION, compound);
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
for(QuestCategory category : QuestController.Instance.categories.values()){
|
||||
Server.sendData(player, EnumPacketClient.SYNC_ADD, SyncType.QUEST_CATEGORY, category.writeNBT(new NBTTagCompound()));
|
||||
}
|
||||
Server.sendData(player, EnumPacketClient.SYNC_END, SyncType.QUEST_CATEGORY, new NBTTagCompound());
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Quest Sync
|
||||
if(ConfigMain.SyncQuestAuto){
|
||||
for(QuestCategory category : QuestController.Instance.categories.values()){
|
||||
NBTTagCompound questCompound;
|
||||
NBTTagList questList = new NBTTagList();
|
||||
for(int questID : category.quests.keySet()){
|
||||
Quest quest = category.quests.get(questID);
|
||||
questList.appendTag(quest.writeToNBT(new NBTTagCompound()));
|
||||
if(questList.tagCount() > 50){
|
||||
questCompound = new NBTTagCompound();
|
||||
questCompound.setTag("Data", questList);
|
||||
questCompound.setTag("CatNBT", category.writeSmallNBT(new NBTTagCompound()));
|
||||
Server.sendData(player, EnumPacketClient.SYNC_ADD, SyncType.QUEST_CATEGORY, questCompound);
|
||||
questList = new NBTTagList();
|
||||
}
|
||||
}
|
||||
questCompound = new NBTTagCompound();
|
||||
questCompound.setTag("Data", questList);
|
||||
questCompound.setTag("CatNBT", category.writeSmallNBT(new NBTTagCompound()));
|
||||
Server.sendData(player, EnumPacketClient.SYNC_ADD, SyncType.QUEST_CATEGORY, questCompound);
|
||||
}
|
||||
Server.sendData(player, EnumPacketClient.SYNC_END, SyncType.QUEST_CATEGORY, new NBTTagCompound());
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
for(DialogCategory category : DialogController.Instance.categories.values()){
|
||||
Server.sendData(player, EnumPacketClient.SYNC_ADD, SyncType.DIALOG_CATEGORY, category.writeNBT(new NBTTagCompound()));
|
||||
}
|
||||
Server.sendData(player, EnumPacketClient.SYNC_END, SyncType.DIALOG_CATEGORY, new NBTTagCompound());
|
||||
|
||||
list = new NBTTagList();
|
||||
for(RecipeCarpentry category : RecipeController.Instance.globalRecipes.values()){
|
||||
list.appendTag(category.writeNBT());
|
||||
if(list.tagCount() > 10){
|
||||
compound = new NBTTagCompound();
|
||||
compound.setTag("Data", list);
|
||||
Server.sendData(player, EnumPacketClient.SYNC_ADD, SyncType.RECIPE_NORMAL, compound);
|
||||
list = new NBTTagList();
|
||||
}
|
||||
}
|
||||
compound = new NBTTagCompound();
|
||||
compound.setTag("Data", list);
|
||||
Server.sendData(player, EnumPacketClient.SYNC_END, SyncType.RECIPE_NORMAL, compound);
|
||||
|
||||
list = new NBTTagList();
|
||||
for(RecipeCarpentry category : RecipeController.Instance.anvilRecipes.values()){
|
||||
list.appendTag(category.writeNBT());
|
||||
if(list.tagCount() > 10){
|
||||
compound = new NBTTagCompound();
|
||||
compound.setTag("Data", list);
|
||||
Server.sendData(player, EnumPacketClient.SYNC_ADD, SyncType.RECIPE_CARPENTRY, compound);
|
||||
list = new NBTTagList();
|
||||
}
|
||||
}
|
||||
compound = new NBTTagCompound();
|
||||
compound.setTag("Data", list);
|
||||
Server.sendData(player, EnumPacketClient.SYNC_END, SyncType.RECIPE_CARPENTRY, compound);
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Dialog Sync
|
||||
if(ConfigMain.SyncDialogAuto){
|
||||
for(DialogCategory category : DialogController.Instance.categories.values()){
|
||||
NBTTagCompound dialogCompound;
|
||||
NBTTagList dialogList = new NBTTagList();
|
||||
for(int dialogID : category.dialogs.keySet()){
|
||||
Dialog dialog = category.dialogs.get(dialogID);
|
||||
dialogList.appendTag(dialog.writeToNBT(new NBTTagCompound()));
|
||||
if(dialogList.tagCount() > 50){
|
||||
dialogCompound = new NBTTagCompound();
|
||||
dialogCompound.setTag("Data", dialogList);
|
||||
dialogCompound.setTag("CatNBT", category.writeSmallNBT(new NBTTagCompound()));
|
||||
Server.sendData(player, EnumPacketClient.SYNC_ADD, SyncType.DIALOG_CATEGORY, dialogCompound);
|
||||
dialogList = new NBTTagList();
|
||||
}
|
||||
}
|
||||
dialogCompound = new NBTTagCompound();
|
||||
dialogCompound.setTag("Data", dialogList);
|
||||
dialogCompound.setTag("CatNBT", category.writeSmallNBT(new NBTTagCompound()));
|
||||
Server.sendData(player, EnumPacketClient.SYNC_ADD, SyncType.DIALOG_CATEGORY, dialogCompound);
|
||||
}
|
||||
Server.sendData(player, EnumPacketClient.SYNC_END, SyncType.DIALOG_CATEGORY, new NBTTagCompound());
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
PlayerData data = PlayerData.get(player);
|
||||
if(data != null)
|
||||
@@ -80,19 +96,99 @@ public class SyncController {
|
||||
}
|
||||
|
||||
public static void syncAllDialogs() {
|
||||
for(DialogCategory category : DialogController.Instance.categories.values()){
|
||||
Server.sendToAll(EnumPacketClient.SYNC_ADD, SyncType.DIALOG_CATEGORY, category.writeNBT(new NBTTagCompound()));
|
||||
}
|
||||
Server.sendToAll(EnumPacketClient.SYNC_END, SyncType.DIALOG_CATEGORY, new NBTTagCompound());
|
||||
if(ConfigMain.SyncDialogAuto){
|
||||
for(DialogCategory category : DialogController.Instance.categories.values()){
|
||||
NBTTagCompound dialogCompound;
|
||||
NBTTagList dialogList = new NBTTagList();
|
||||
for(int dialogID : category.dialogs.keySet()){
|
||||
Dialog dialog = category.dialogs.get(dialogID);
|
||||
dialogList.appendTag(dialog.writeToNBT(new NBTTagCompound()));
|
||||
if(dialogList.tagCount() > 50){
|
||||
dialogCompound = new NBTTagCompound();
|
||||
dialogCompound.setTag("Data", dialogList);
|
||||
dialogCompound.setTag("CatNBT", category.writeSmallNBT(new NBTTagCompound()));
|
||||
Server.sendToAll(EnumPacketClient.SYNC_ADD, SyncType.DIALOG_CATEGORY, dialogCompound);
|
||||
dialogList = new NBTTagList();
|
||||
}
|
||||
}
|
||||
dialogCompound = new NBTTagCompound();
|
||||
dialogCompound.setTag("Data", dialogList);
|
||||
dialogCompound.setTag("CatNBT", category.writeSmallNBT(new NBTTagCompound()));
|
||||
Server.sendToAll(EnumPacketClient.SYNC_ADD, SyncType.DIALOG_CATEGORY, dialogCompound);
|
||||
}
|
||||
Server.sendToAll(EnumPacketClient.SYNC_END, SyncType.DIALOG_CATEGORY, new NBTTagCompound());
|
||||
}
|
||||
}
|
||||
|
||||
public static void syncAllQuests() {
|
||||
for(QuestCategory category : QuestController.Instance.categories.values()){
|
||||
Server.sendToAll(EnumPacketClient.SYNC_ADD, SyncType.QUEST_CATEGORY, category.writeNBT(new NBTTagCompound()));
|
||||
}
|
||||
Server.sendToAll(EnumPacketClient.SYNC_END, SyncType.QUEST_CATEGORY, new NBTTagCompound());
|
||||
if(ConfigMain.SyncQuestAuto){
|
||||
for(QuestCategory category : QuestController.Instance.categories.values()){
|
||||
NBTTagCompound questCompound;
|
||||
NBTTagList questList = new NBTTagList();
|
||||
for(int questID : category.quests.keySet()){
|
||||
Quest quest = category.quests.get(questID);
|
||||
questList.appendTag(quest.writeToNBT(new NBTTagCompound()));
|
||||
if(questList.tagCount() > 50){
|
||||
questCompound = new NBTTagCompound();
|
||||
questCompound.setTag("Data", questList);
|
||||
questCompound.setTag("CatNBT", category.writeSmallNBT(new NBTTagCompound()));
|
||||
Server.sendToAll(EnumPacketClient.SYNC_ADD, SyncType.QUEST_CATEGORY, questCompound);
|
||||
questList = new NBTTagList();
|
||||
}
|
||||
}
|
||||
questCompound = new NBTTagCompound();
|
||||
questCompound.setTag("Data", questList);
|
||||
questCompound.setTag("CatNBT", category.writeSmallNBT(new NBTTagCompound()));
|
||||
Server.sendToAll(EnumPacketClient.SYNC_ADD, SyncType.QUEST_CATEGORY, questCompound);
|
||||
}
|
||||
Server.sendToAll(EnumPacketClient.SYNC_END, SyncType.QUEST_CATEGORY, new NBTTagCompound());
|
||||
}
|
||||
}
|
||||
|
||||
public static void updateQuestCat(QuestCategory questCategory) {
|
||||
if(ConfigMain.SyncQuestAuto){
|
||||
NBTTagCompound questCompound;
|
||||
NBTTagList questList = new NBTTagList();
|
||||
for(int questID : questCategory.quests.keySet()){
|
||||
Quest quest = questCategory.quests.get(questID);
|
||||
questList.appendTag(quest.writeToNBT(new NBTTagCompound()));
|
||||
if(questList.tagCount() > 50){
|
||||
questCompound = new NBTTagCompound();
|
||||
questCompound.setTag("Data", questList);
|
||||
questCompound.setTag("CatNBT", questCategory.writeSmallNBT(new NBTTagCompound()));
|
||||
Server.sendToAll(EnumPacketClient.SYNC_UPDATE, SyncType.QUEST_CATEGORY, questCompound);
|
||||
questList = new NBTTagList();
|
||||
}
|
||||
}
|
||||
questCompound = new NBTTagCompound();
|
||||
questCompound.setTag("Data", questList);
|
||||
questCompound.setTag("CatNBT", questCategory.writeSmallNBT(new NBTTagCompound()));
|
||||
Server.sendToAll(EnumPacketClient.SYNC_UPDATE, SyncType.QUEST_CATEGORY, questCompound);
|
||||
}
|
||||
}
|
||||
|
||||
public static void updateDialogCat(DialogCategory dialogCategory) {
|
||||
if(ConfigMain.SyncDialogAuto){
|
||||
NBTTagCompound dialogCompound;
|
||||
NBTTagList dialogList = new NBTTagList();
|
||||
for(int questID : dialogCategory.dialogs.keySet()){
|
||||
Dialog dialog = dialogCategory.dialogs.get(questID);
|
||||
dialogList.appendTag(dialog.writeToNBT(new NBTTagCompound()));
|
||||
if(dialogList.tagCount() > 50){
|
||||
dialogCompound = new NBTTagCompound();
|
||||
dialogCompound.setTag("Data", dialogList);
|
||||
dialogCompound.setTag("CatNBT", dialogCategory.writeSmallNBT(new NBTTagCompound()));
|
||||
Server.sendToAll(EnumPacketClient.SYNC_UPDATE, SyncType.DIALOG_CATEGORY, dialogCompound);
|
||||
dialogList = new NBTTagList();
|
||||
}
|
||||
}
|
||||
dialogCompound = new NBTTagCompound();
|
||||
dialogCompound.setTag("Data", dialogList);
|
||||
dialogCompound.setTag("CatNBT", dialogCategory.writeSmallNBT(new NBTTagCompound()));
|
||||
Server.sendToAll(EnumPacketClient.SYNC_UPDATE, SyncType.DIALOG_CATEGORY, dialogCompound);
|
||||
}
|
||||
}
|
||||
|
||||
public static void clientSync(int synctype, NBTTagCompound compound, boolean syncEnd) {
|
||||
if(synctype == SyncType.FACTION){
|
||||
NBTTagList list = compound.getTagList("Data", 10);
|
||||
@@ -109,9 +205,21 @@ public class SyncController {
|
||||
}
|
||||
else if(synctype == SyncType.QUEST_CATEGORY){
|
||||
if(!compound.hasNoTags()){
|
||||
QuestCategory category = new QuestCategory();
|
||||
category.readNBT(compound);
|
||||
QuestController.Instance.categoriesSync.put(category.id, category);
|
||||
QuestCategory category = new QuestCategory();
|
||||
category.readSmallNBT(compound.getCompoundTag("CatNBT"));
|
||||
NBTTagList list = compound.getTagList("Data", 10);
|
||||
if(QuestController.Instance.categoriesSync.containsKey(category.id)){
|
||||
category = QuestController.Instance.categoriesSync.get(category.id);
|
||||
category.readSmallNBT(compound.getCompoundTag("CatNBT"));
|
||||
}
|
||||
for(int i = 0; i < list.tagCount(); i++)
|
||||
{
|
||||
Quest quest = new Quest();
|
||||
quest.readNBT(list.getCompoundTagAt(i));
|
||||
quest.category = category;
|
||||
category.quests.put(quest.id, quest);
|
||||
}
|
||||
QuestController.Instance.categoriesSync.put(category.id, category);
|
||||
}
|
||||
if(syncEnd){
|
||||
HashMap<Integer,Quest> quests = new HashMap<Integer, Quest>();
|
||||
@@ -127,9 +235,21 @@ public class SyncController {
|
||||
}
|
||||
else if(synctype == SyncType.DIALOG_CATEGORY){
|
||||
if(!compound.hasNoTags()){
|
||||
DialogCategory category = new DialogCategory();
|
||||
category.readNBT(compound);
|
||||
DialogController.Instance.categoriesSync.put(category.id, category);
|
||||
DialogCategory category = new DialogCategory();
|
||||
category.readSmallNBT(compound.getCompoundTag("CatNBT"));
|
||||
NBTTagList list = compound.getTagList("Data", 10);
|
||||
if(DialogController.Instance.categoriesSync.containsKey(category.id)){
|
||||
category = DialogController.Instance.categoriesSync.get(category.id);
|
||||
category.readSmallNBT(compound.getCompoundTag("CatNBT"));
|
||||
}
|
||||
for(int i = 0; i < list.tagCount(); i++)
|
||||
{
|
||||
Dialog dialog = new Dialog();
|
||||
dialog.readNBT(list.getCompoundTagAt(i));
|
||||
dialog.category = category;
|
||||
category.dialogs.put(dialog.id, dialog);
|
||||
}
|
||||
DialogController.Instance.categoriesSync.put(category.id, category);
|
||||
}
|
||||
if(syncEnd){
|
||||
HashMap<Integer,Dialog> dialogs = new HashMap<Integer, Dialog>();
|
||||
@@ -160,9 +280,21 @@ public class SyncController {
|
||||
category.dialogs.put(dialog.id, dialog);
|
||||
}
|
||||
else if(synctype == SyncType.DIALOG_CATEGORY){
|
||||
DialogCategory category = new DialogCategory();
|
||||
category.readNBT(compound);
|
||||
DialogController.Instance.categories.put(category.id, category);
|
||||
DialogCategory category = new DialogCategory();
|
||||
category.readSmallNBT(compound.getCompoundTag("CatNBT"));
|
||||
NBTTagList list = compound.getTagList("Data", 10);
|
||||
if(DialogController.Instance.categoriesSync.containsKey(category.id)){
|
||||
category = DialogController.Instance.categoriesSync.get(category.id);
|
||||
category.readSmallNBT(compound.getCompoundTag("CatNBT"));
|
||||
}
|
||||
for(int i = 0; i < list.tagCount(); i++)
|
||||
{
|
||||
Dialog dialog = new Dialog();
|
||||
dialog.readNBT(list.getCompoundTagAt(i));
|
||||
dialog.category = category;
|
||||
category.dialogs.put(dialog.id, dialog);
|
||||
}
|
||||
DialogController.Instance.categoriesSync.put(category.id, category);
|
||||
}
|
||||
else if(synctype == SyncType.QUEST){
|
||||
QuestCategory category = QuestController.Instance.categories.get(buffer.readInt());
|
||||
@@ -174,7 +306,19 @@ public class SyncController {
|
||||
}
|
||||
else if(synctype == SyncType.QUEST_CATEGORY){
|
||||
QuestCategory category = new QuestCategory();
|
||||
category.readNBT(compound);
|
||||
category.readSmallNBT(compound.getCompoundTag("CatNBT"));
|
||||
NBTTagList list = compound.getTagList("Data", 10);
|
||||
if(QuestController.Instance.categoriesSync.containsKey(category.id)){
|
||||
category = QuestController.Instance.categoriesSync.get(category.id);
|
||||
category.readSmallNBT(compound.getCompoundTag("CatNBT"));
|
||||
}
|
||||
for(int i = 0; i < list.tagCount(); i++)
|
||||
{
|
||||
Quest quest = new Quest();
|
||||
quest.readNBT(list.getCompoundTagAt(i));
|
||||
quest.category = category;
|
||||
category.quests.put(quest.id, quest);
|
||||
}
|
||||
QuestController.Instance.categories.put(category.id, category);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,15 +14,15 @@ public class DialogCategory implements IDialogCategory {
|
||||
public int id = -1;
|
||||
public String title = "";
|
||||
public HashMap<Integer,Dialog> dialogs;
|
||||
|
||||
|
||||
public DialogCategory(){
|
||||
dialogs = new HashMap<Integer, Dialog>();
|
||||
}
|
||||
|
||||
|
||||
public void readNBT(NBTTagCompound compound){
|
||||
id = compound.getInteger("Slot");
|
||||
title = compound.getString("Title");
|
||||
|
||||
|
||||
NBTTagList dialogsList = compound.getTagList("Dialogs", 10);
|
||||
if(dialogsList != null){
|
||||
for(int ii = 0; ii < dialogsList.tagCount(); ii++)
|
||||
@@ -37,17 +37,28 @@ public class DialogCategory implements IDialogCategory {
|
||||
}
|
||||
}
|
||||
|
||||
public NBTTagCompound writeNBT(NBTTagCompound nbtfactions) {
|
||||
nbtfactions.setInteger("Slot", id);
|
||||
nbtfactions.setString("Title", title);
|
||||
public NBTTagCompound writeNBT(NBTTagCompound dialogCat) {
|
||||
dialogCat.setInteger("Slot", id);
|
||||
dialogCat.setString("Title", title);
|
||||
NBTTagList dialogs = new NBTTagList();
|
||||
for(Dialog dialog : this.dialogs.values()){
|
||||
dialogs.appendTag(dialog.writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
nbtfactions.setTag("Dialogs", dialogs);
|
||||
return nbtfactions;
|
||||
dialogCat.setTag("Dialogs", dialogs);
|
||||
return dialogCat;
|
||||
}
|
||||
|
||||
public NBTTagCompound writeSmallNBT(NBTTagCompound dialogCat) {
|
||||
dialogCat.setInteger("Slot", id);
|
||||
dialogCat.setString("Title", title);
|
||||
return dialogCat;
|
||||
}
|
||||
|
||||
public void readSmallNBT(NBTTagCompound compound){
|
||||
id = compound.getInteger("Slot");
|
||||
title = compound.getString("Title");
|
||||
}
|
||||
|
||||
public List<IDialog> dialogs() {
|
||||
return new ArrayList(this.dialogs.values());
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ public class QuestCategory implements IQuestCategory {
|
||||
public HashMap<Integer,Quest> quests;
|
||||
public int id = -1;
|
||||
public String title = "";
|
||||
|
||||
|
||||
public QuestCategory(){
|
||||
quests = new HashMap<Integer, Quest>();
|
||||
}
|
||||
@@ -21,11 +21,11 @@ public class QuestCategory implements IQuestCategory {
|
||||
public void readNBT(NBTTagCompound nbttagcompound) {
|
||||
id = nbttagcompound.getInteger("Slot");
|
||||
title = nbttagcompound.getString("Title");
|
||||
NBTTagList dialogsList = nbttagcompound.getTagList("Dialogs", 10);
|
||||
if(dialogsList != null){
|
||||
for(int ii = 0; ii < dialogsList.tagCount(); ii++)
|
||||
NBTTagList questList = nbttagcompound.getTagList("Quests", 10);
|
||||
if(questList != null){
|
||||
for(int ii = 0; ii < questList.tagCount(); ii++)
|
||||
{
|
||||
NBTTagCompound nbttagcompound2 = dialogsList.getCompoundTagAt(ii);
|
||||
NBTTagCompound nbttagcompound2 = questList.getCompoundTagAt(ii);
|
||||
Quest quest = new Quest();
|
||||
quest.readNBT(nbttagcompound2);
|
||||
quest.category = this;
|
||||
@@ -37,17 +37,28 @@ public class QuestCategory implements IQuestCategory {
|
||||
public NBTTagCompound writeNBT(NBTTagCompound nbttagcompound) {
|
||||
nbttagcompound.setInteger("Slot", id);
|
||||
nbttagcompound.setString("Title", title);
|
||||
NBTTagList dialogs = new NBTTagList();
|
||||
for(int dialogId : quests.keySet()){
|
||||
Quest quest = quests.get(dialogId);
|
||||
dialogs.appendTag(quest.writeToNBT(new NBTTagCompound()));
|
||||
NBTTagList quests = new NBTTagList();
|
||||
for(int questID : this.quests.keySet()){
|
||||
Quest quest = this.quests.get(questID);
|
||||
quests.appendTag(quest.writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
|
||||
nbttagcompound.setTag("Dialogs", dialogs);
|
||||
|
||||
|
||||
nbttagcompound.setTag("Quests", quests);
|
||||
|
||||
return nbttagcompound;
|
||||
}
|
||||
|
||||
public NBTTagCompound writeSmallNBT(NBTTagCompound nbttagcompound) {
|
||||
nbttagcompound.setInteger("Slot", id);
|
||||
nbttagcompound.setString("Title", title);
|
||||
return nbttagcompound;
|
||||
}
|
||||
|
||||
public void readSmallNBT(NBTTagCompound nbttagcompound) {
|
||||
id = nbttagcompound.getInteger("Slot");
|
||||
title = nbttagcompound.getString("Title");
|
||||
}
|
||||
|
||||
public List<IQuest> quests() {
|
||||
return new ArrayList(this.quests.values());
|
||||
}
|
||||
|
||||
@@ -675,18 +675,22 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
||||
}
|
||||
|
||||
private void clearTasks(EntityAITasks tasks){
|
||||
Iterator iterator = tasks.taskEntries.iterator();
|
||||
List<EntityAITaskEntry> list = new ArrayList(tasks.taskEntries);
|
||||
for (EntityAITaskEntry entityaitaskentry : list)
|
||||
{
|
||||
tasks.removeTask(entityaitaskentry.action);
|
||||
}
|
||||
tasks.taskEntries = new ArrayList<EntityAITaskEntry>();
|
||||
Iterator iterator = tasks.taskEntries.iterator();
|
||||
List<EntityAITaskEntry> list = new ArrayList(tasks.taskEntries);
|
||||
for (EntityAITaskEntry entityaitaskentry : list)
|
||||
{
|
||||
try {
|
||||
tasks.removeTask(entityaitaskentry.action);
|
||||
}
|
||||
catch(Throwable e) {
|
||||
|
||||
}
|
||||
}
|
||||
tasks.taskEntries = new ArrayList<EntityAITaskEntry>();
|
||||
}
|
||||
public void updateTasks() {
|
||||
if (worldObj == null || worldObj.isRemote)
|
||||
return;
|
||||
aiLeap = aiAttackTarget = aiResponse = aiSprint = aiRange = null;
|
||||
|
||||
clearTasks(tasks);
|
||||
clearTasks(targetTasks);
|
||||
@@ -707,11 +711,11 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
||||
}
|
||||
|
||||
this.taskCount = 1;
|
||||
this.addRegularEntries();
|
||||
this.doorInteractType();
|
||||
this.seekShelter();
|
||||
this.setResponse();
|
||||
this.setMoveType();
|
||||
this.addRegularEntries();
|
||||
}
|
||||
|
||||
private void removeTask(EntityAIBase task){
|
||||
@@ -723,31 +727,29 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
||||
* Branch task function for setting how an NPC responds to a threat
|
||||
*/
|
||||
public void setResponse(){
|
||||
removeTask(aiLeap);
|
||||
removeTask(aiResponse);
|
||||
removeTask(aiSprint);
|
||||
removeTask(aiAttackTarget);
|
||||
removeTask(aiRange);
|
||||
aiLeap = aiAttackTarget = aiResponse = aiSprint = aiRange = null;
|
||||
removeTask(aiLeap);
|
||||
removeTask(aiResponse);
|
||||
removeTask(aiSprint);
|
||||
removeTask(aiAttackTarget);
|
||||
removeTask(aiRange);
|
||||
aiLeap = aiAttackTarget = aiResponse = aiSprint = aiRange = null;
|
||||
|
||||
if (this.ai.canSprint)
|
||||
this.tasks.addTask(this.taskCount++, new EntityAISprintToTarget(this));
|
||||
|
||||
if (this.ai.onAttack == 1)
|
||||
this.tasks.addTask(this.taskCount++, aiResponse = new EntityAIPanic(this, 1.2F));
|
||||
|
||||
else if (this.ai.onAttack == 2) {
|
||||
this.tasks.addTask(this.taskCount++, aiResponse = new EntityAIAvoidTarget(this));
|
||||
}
|
||||
|
||||
else if (this.ai.onAttack == 0) {
|
||||
this.setLeapTask();
|
||||
if (this.inventory.getProjectile() == null || this.ai.useRangeMelee == 2)
|
||||
{
|
||||
switch(this.ai.tacticalVariant)
|
||||
{
|
||||
case Dodge : this.tasks.addTask(this.taskCount++, aiResponse = new EntityAIZigZagTarget(this, 1.0D, this.ai.tacticalRadius)); break;
|
||||
case Surround : this.tasks.addTask(this.taskCount++, aiResponse = new EntityAIOrbitTarget(this, 1.0D, this.ai.tacticalRadius, true)); break;
|
||||
case Dodge : this.tasks.addTask(this.taskCount++, aiResponse = new EntityAIZigZagTarget(this, 1.2D, this.ai.tacticalRadius)); break;
|
||||
case Surround : this.tasks.addTask(this.taskCount++, aiResponse = new EntityAIOrbitTarget(this, 1.2D, this.ai.tacticalRadius, true)); break;
|
||||
case HitNRun : this.tasks.addTask(this.taskCount++, aiResponse = new EntityAIAvoidTarget(this)); break;
|
||||
case Ambush : this.tasks.addTask(this.taskCount++, aiResponse = new EntityAIAmbushTarget(this, 1.2D, this.ai.tacticalRadius, false)); break;
|
||||
case Stalk : this.tasks.addTask(this.taskCount++, aiResponse = new EntityAIStalkTarget(this, this.ai.tacticalRadius)); break;
|
||||
@@ -760,7 +762,7 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
||||
switch(this.ai.tacticalVariant)
|
||||
{
|
||||
case Dodge : this.tasks.addTask(this.taskCount++, aiResponse = new EntityAIDodgeShoot(this)); break;
|
||||
case Surround : this.tasks.addTask(this.taskCount++, aiResponse = new EntityAIOrbitTarget(this, 1.0D, stats.rangedRange, false)); break;
|
||||
case Surround : this.tasks.addTask(this.taskCount++, aiResponse = new EntityAIOrbitTarget(this, 1.2D, stats.rangedRange, false)); break;
|
||||
case HitNRun : this.tasks.addTask(this.taskCount++, aiResponse = new EntityAIAvoidTarget(this)); break;
|
||||
case Ambush : this.tasks.addTask(this.taskCount++, aiResponse = new EntityAIAmbushTarget(this, 1.2D, this.ai.tacticalRadius, false)); break;
|
||||
case Stalk : this.tasks.addTask(this.taskCount++, aiResponse = new EntityAIStalkTarget(this, this.ai.tacticalRadius)); break;
|
||||
|
||||
Reference in new issue
Block a user