Compare commits

..
Author SHA1 Message Date
Kam 1a7ac52297 REMVOEOMOWAMo Arggg LOUIS! 2023-06-22 17:13:14 -04:00
Kam 37e9d5f899 Update to Main API 2023-06-01 16:31:22 -04:00
Kam 09423427a0 Merge branch 'patch' 2023-06-01 16:30:38 -04:00
Kam f213cab261 Add Search to Manage Banks 2023-06-01 16:10:38 -04:00
Kam bf78c1be0f Display Selected Wand Tags in Cloner 2023-06-01 12:29:28 -04:00
Kam ff5e7de1be Save NPC Quick Tags properly on Close 2023-06-01 12:29:16 -04:00
Luis C.M 01339e7baf ScriptLivingBase:
-Reverted previous change, not worth the inaccuracies it would cause on servers
2023-06-01 00:49:33 -05:00
Luis C.M 62ee42a23d ScriptLivingBase:
-Slightly improved getLookingAtPos() results
2023-06-01 00:36:40 -05:00
Luis C.M a8a0528275 ScriptWorld:
-Increased the accuracy of rayCastPos().
2023-05-31 23:59:11 -05:00
Luis C.M 0e9ddd75b6 Fixed index out of bounds error on custom GUI slot clicks. 2023-05-31 20:21:00 -05:00
Luis C.M 0c25d7ec1c Reverted changes to saving/loading player data from previous commit to 2023-05-31 19:59:20 -05:00
Luis C.M b3a5854ff1 Merge remote-tracking branch 'origin/patch' into patch 2023-05-31 18:55:12 -05:00
Luis C.M 7000b525f3 Fixed entity custom item rendering, and rendering of textures for custom GUI buttons and rectangles. 2023-05-31 18:55:06 -05:00
Kam 9bcb8133bb Update api 2023-05-31 19:46:21 -04:00
Kam 9d727499df Fix Gradle Order 2023-05-31 19:45:36 -04:00
Kam 075e3fdb41 1.8.4 Version Change 2023-05-31 19:34:24 -04:00
Kam 5befe141bd Fix Searching in Clone Tab to now account for the displayed tags 2023-05-31 18:45:10 -04:00
Luis C.M 895d20335f DataScript:
-Now doesn't create a new instance of NpcAPI
2023-05-30 01:27:34 -05:00
Luis C.M 1ce5b7b302 ScriptCustomItem:
-Fixed issue where NBT data was not being sent to the client side, caused by latest commit.
2023-05-30 00:56:39 -05:00
Luis C.M 7c4965d368 ScriptCustomItem:
-Made engine for containers also set on saving
2023-05-29 23:59:57 -05:00
Luis C.M a0adf0d7bd Fixed item toss event not being cancellable. Setting a script container's engine doesn't happen on every script call now, reducing lag. 2023-05-29 23:57:45 -05:00
Luis C.M 2ec6e5b753 PacketHandlerServer:
-Fixed global scripts still running old versions of their scripts when changed.
2023-05-26 00:22:14 -05:00
Luis C.M 130ac26879 ScriptContainer:
-Fixed issue where the full code the script engine evaluates wouldn't get remade after being changed
2023-05-25 22:18:54 -05:00
Luis C.M cbf99be297 PlayerData:
-Renamed loadPlayerDataFromFile() to load(), and moved it next to the save() function for later addition to the API.
-Moved saving/loading to EP functions where they used to be.
-Removed now unused PlayerData.get() and loadPlayerDataOld() functions

ServerEventsHandler:
-Added new EntityConstructing event to add the PlayerData EP earlier.

NoppesUtilPlayer:
-questCompletion() now saves player data right before its return statement.
2023-05-21 02:48:30 -05:00
Luis C.M dc42beee15 Merge branch 'dev' into patch
# Conflicts:
#	src/api
2023-05-20 21:15:14 -05:00
Luis C.M b49402f8bd Implemented ImageData object caching for custom GUI button & rect elements 2023-05-20 19:23:54 -05:00
Luis C.M 8df94aaf67 IDBCPlayer:
-Created separate mastery functions for racial and non-racial forms.
2023-05-20 16:13:15 -05:00
Luis C.M ed5cfad00d IDBCPlayer:
-Changed mastery functions to use a boolean for racial or non-racial forms.
2023-05-20 15:00:58 -05:00
Kam a9961ed740 Update to 1.8.4-beta 2023-05-19 14:29:08 -04:00
Kam 6700030890 Fix Animation on Players not finding body parts 2023-05-19 14:28:55 -04:00
Kam 02b44953cb Remove duplicate Quest Completed Message 2023-05-17 16:18:09 -04:00
Kam b8c3e9bef2 QuestData Null check for QuestKill 2023-05-17 12:21:38 -04:00
Kam 5b361d779f Fix Crate Crash 2023-05-17 11:43:43 -04:00
Kam 6df7d3643f Remove runTack() 2023-05-16 19:16:34 -04:00
Luis C.M e7ed34a591 Merge remote-tracking branch 'origin/dev' into dev 2023-05-16 18:02:19 -05:00
Kam a6cd55fcea Merge branch 'master' into patch 2023-05-16 17:46:42 -04:00
Kam f77a2ff101 Remove more threading 2023-05-16 17:45:23 -04:00
Kam 49fab85291 Revert lots of multithreading for better threaded saving and data synchronization 2023-05-16 17:43:54 -04:00
Kam 6f1914c002 Remove ClientSide 2023-05-16 17:33:28 -04:00
Kam d1901dcf0c Spoof 1.8.3 2023-05-16 17:17:47 -04:00
Kam 204e7a9c15 Revert Some Multithreading for Synchronization 2023-05-16 17:17:11 -04:00
64 changed files with 778 additions and 861 deletions

No files matched your search

+6 -6
View File
@@ -34,7 +34,7 @@ configurations {
apply plugin: 'forge' apply plugin: 'forge'
version = "1.9-sync" version = "1.8.4"
group= "com.kamkeel.customnpc-plus" // http://maven.apache.org/guides/mini/guide-naming-conventions.html group= "com.kamkeel.customnpc-plus" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "CustomNPC-Plus" archivesBaseName = "CustomNPC-Plus"
@@ -195,13 +195,13 @@ afterEvaluate {
} }
} }
task deobfJar(type: Jar) {
classifier = 'dev'
from sourceSets.main.output
}
sourceSets { sourceSets {
main { main {
ext.refMap = refMapForYourConfig ext.refMap = refMapForYourConfig
} }
} }
task deobfJar(type: Jar) {
from sourceSets.main.output
classifier = 'dev'
}
+1 -1
Submodule src/api updated: e1afcb4e90...8c61d07b10.
+2 -2
View File
@@ -50,7 +50,7 @@ public class CmdDialog extends ChMcLogger {
} }
for(PlayerData playerdata : data){ for(PlayerData playerdata : data){
playerdata.dialogData.dialogsRead.add(diagid); playerdata.dialogData.dialogsRead.add(diagid);
playerdata.save(true); playerdata.save();
} }
return true; return true;
} }
@@ -76,7 +76,7 @@ public class CmdDialog extends ChMcLogger {
} }
for(PlayerData playerdata : data){ for(PlayerData playerdata : data){
playerdata.dialogData.dialogsRead.remove(diagid); playerdata.dialogData.dialogsRead.remove(diagid);
playerdata.save(true); playerdata.save();
} }
return true; return true;
} }
+1 -1
View File
@@ -100,7 +100,7 @@ public class CmdNoppes extends ChMcLogger {
cmdfaction.processCommand(this.pcParam, args); cmdfaction.processCommand(this.pcParam, args);
for (PlayerData playerdata : cmdfaction.data) { for (PlayerData playerdata : cmdfaction.data) {
playerdata.save(true); playerdata.save();
} }
return true; return true;
} }
+4 -4
View File
@@ -56,7 +56,7 @@ public class CmdQuest extends ChMcLogger{
continue; continue;
QuestData questdata = new QuestData(quest); QuestData questdata = new QuestData(quest);
playerdata.questData.activeQuests.put(questid, questdata); playerdata.questData.activeQuests.put(questid, questdata);
playerdata.save(true); playerdata.save();
if(playerdata.player != null){ if(playerdata.player != null){
Server.sendData((EntityPlayerMP)playerdata.player, EnumPacketClient.MESSAGE, "quest.newquest", quest.title); Server.sendData((EntityPlayerMP)playerdata.player, EnumPacketClient.MESSAGE, "quest.newquest", quest.title);
Server.sendData((EntityPlayerMP)playerdata.player, EnumPacketClient.CHAT, "quest.newquest", ": ", quest.title); Server.sendData((EntityPlayerMP)playerdata.player, EnumPacketClient.CHAT, "quest.newquest", ": ", quest.title);
@@ -93,7 +93,7 @@ public class CmdQuest extends ChMcLogger{
} }
for(PlayerData playerdata : data){ for(PlayerData playerdata : data){
playerdata.questData.finishedQuests.put(questid, System.currentTimeMillis()); playerdata.questData.finishedQuests.put(questid, System.currentTimeMillis());
playerdata.save(true); playerdata.save();
} }
return true; return true;
} }
@@ -124,7 +124,7 @@ public class CmdQuest extends ChMcLogger{
} }
for(PlayerData playerdata : data){ for(PlayerData playerdata : data){
playerdata.questData.activeQuests.remove(questid); playerdata.questData.activeQuests.remove(questid);
playerdata.save(true); playerdata.save();
} }
return true; return true;
} }
@@ -156,7 +156,7 @@ public class CmdQuest extends ChMcLogger{
for(PlayerData playerdata : data){ for(PlayerData playerdata : data){
playerdata.questData.activeQuests.remove(questid); playerdata.questData.activeQuests.remove(questid);
playerdata.questData.finishedQuests.remove(questid); playerdata.questData.finishedQuests.remove(questid);
playerdata.save(true); playerdata.save();
} }
return true; return true;
} }
@@ -46,7 +46,7 @@ public class AnimationCommand extends CommandKamkeelBase {
processSubCommand(sender, args[1], Arrays.copyOfRange(args, 2, args.length)); processSubCommand(sender, args[1], Arrays.copyOfRange(args, 2, args.length));
data.get(0).animationData.updateClient(); data.get(0).animationData.updateClient();
data.get(0).save(true); data.get(0).save();
} }
@SubCommand(desc = "enable animation") @SubCommand(desc = "enable animation")
@@ -11,7 +11,6 @@ import noppes.npcs.client.EntityUtil;
import noppes.npcs.controllers.DialogController; import noppes.npcs.controllers.DialogController;
import noppes.npcs.controllers.PlayerDataController; import noppes.npcs.controllers.PlayerDataController;
import noppes.npcs.controllers.SyncController;
import noppes.npcs.controllers.data.Dialog; import noppes.npcs.controllers.data.Dialog;
import noppes.npcs.controllers.data.DialogOption; import noppes.npcs.controllers.data.DialogOption;
import noppes.npcs.controllers.data.PlayerData; import noppes.npcs.controllers.data.PlayerData;
@@ -49,7 +48,7 @@ public class DialogCommand extends CommandKamkeelBase {
} }
for(PlayerData playerdata : data){ for(PlayerData playerdata : data){
playerdata.dialogData.dialogsRead.add(diagid); playerdata.dialogData.dialogsRead.add(diagid);
playerdata.save(true); playerdata.save();
sendResult(sender, String.format("Forced Read for Dialog \u00A7e%d\u00A77 for Player '\u00A7b%s\u00A77'", diagid, playerdata.playername)); sendResult(sender, String.format("Forced Read for Dialog \u00A7e%d\u00A77 for Player '\u00A7b%s\u00A77'", diagid, playerdata.playername));
} }
} }
@@ -74,7 +73,7 @@ public class DialogCommand extends CommandKamkeelBase {
} }
for(PlayerData playerdata : data){ for(PlayerData playerdata : data){
playerdata.dialogData.dialogsRead.remove(diagid); playerdata.dialogData.dialogsRead.remove(diagid);
playerdata.save(true); playerdata.save();
sendResult(sender, String.format("Forced Unread for Dialog \u00A7e%d\u00A77 for Player '\u00A7b%s\u00A77'", diagid, playerdata.playername)); sendResult(sender, String.format("Forced Unread for Dialog \u00A7e%d\u00A77 for Player '\u00A7b%s\u00A77'", diagid, playerdata.playername));
} }
} }
@@ -84,7 +83,6 @@ public class DialogCommand extends CommandKamkeelBase {
) )
public void reload(ICommandSender sender, String args[]){ public void reload(ICommandSender sender, String args[]){
new DialogController(); new DialogController();
SyncController.syncAllDialogs();
sendResult(sender, "Dialogs Reloaded"); sendResult(sender, "Dialogs Reloaded");
} }
@@ -64,7 +64,7 @@ public class FactionCommand extends CommandKamkeelBase {
processSubCommand(sender, args[2], Arrays.copyOfRange(args, 3, args.length)); processSubCommand(sender, args[2], Arrays.copyOfRange(args, 3, args.length));
for(PlayerData playerdata : data){ for(PlayerData playerdata : data){
playerdata.save(true); playerdata.save();
} }
} }
@@ -10,7 +10,6 @@ import noppes.npcs.constants.EnumPacketClient;
import noppes.npcs.constants.EnumQuestRepeat; import noppes.npcs.constants.EnumQuestRepeat;
import noppes.npcs.controllers.PlayerDataController; import noppes.npcs.controllers.PlayerDataController;
import noppes.npcs.controllers.QuestController; import noppes.npcs.controllers.QuestController;
import noppes.npcs.controllers.SyncController;
import noppes.npcs.controllers.data.PlayerData; import noppes.npcs.controllers.data.PlayerData;
import noppes.npcs.controllers.data.Quest; import noppes.npcs.controllers.data.Quest;
import noppes.npcs.controllers.data.QuestData; import noppes.npcs.controllers.data.QuestData;
@@ -57,7 +56,7 @@ public class QuestCommand extends CommandKamkeelBase {
for(PlayerData playerdata : data){ for(PlayerData playerdata : data){
QuestData questdata = new QuestData(quest); QuestData questdata = new QuestData(quest);
playerdata.questData.activeQuests.put(questid, questdata); playerdata.questData.activeQuests.put(questid, questdata);
playerdata.save(true); playerdata.save();
if(playerdata.player != null && questdata.sendAlerts){ if(playerdata.player != null && questdata.sendAlerts){
Server.sendData((EntityPlayerMP)playerdata.player, EnumPacketClient.MESSAGE, "quest.newquest", quest.title); Server.sendData((EntityPlayerMP)playerdata.player, EnumPacketClient.MESSAGE, "quest.newquest", quest.title);
Server.sendData((EntityPlayerMP)playerdata.player, EnumPacketClient.CHAT, "quest.newquest", ": ", quest.title); Server.sendData((EntityPlayerMP)playerdata.player, EnumPacketClient.CHAT, "quest.newquest", ": ", quest.title);
@@ -102,7 +101,7 @@ public class QuestCommand extends CommandKamkeelBase {
else else
playerdata.questData.finishedQuests.put(quest.id, sender.getEntityWorld().getTotalWorldTime()); playerdata.questData.finishedQuests.put(quest.id, sender.getEntityWorld().getTotalWorldTime());
playerdata.save(true); playerdata.save();
if(playerdata.player != null){ if(playerdata.player != null){
Server.sendData((EntityPlayerMP)playerdata.player, EnumPacketClient.MESSAGE, "quest.completed", quest.title); Server.sendData((EntityPlayerMP)playerdata.player, EnumPacketClient.MESSAGE, "quest.completed", quest.title);
Server.sendData((EntityPlayerMP)playerdata.player, EnumPacketClient.CHAT, "quest.completed", ": ", quest.title); Server.sendData((EntityPlayerMP)playerdata.player, EnumPacketClient.CHAT, "quest.completed", ": ", quest.title);
@@ -136,7 +135,7 @@ public class QuestCommand extends CommandKamkeelBase {
} }
for(PlayerData playerdata : data){ for(PlayerData playerdata : data){
playerdata.questData.activeQuests.remove(questid); playerdata.questData.activeQuests.remove(questid);
playerdata.save(true); playerdata.save();
sendResult(sender, String.format("Stopped Quest \u00A7e%d\u00A77 for Player '\u00A7b%s\u00A77'", questid, playerdata.playername)); sendResult(sender, String.format("Stopped Quest \u00A7e%d\u00A77 for Player '\u00A7b%s\u00A77'", questid, playerdata.playername));
} }
} }
@@ -170,7 +169,7 @@ public class QuestCommand extends CommandKamkeelBase {
for(PlayerData playerdata : data){ for(PlayerData playerdata : data){
playerdata.questData.activeQuests.remove(questid); playerdata.questData.activeQuests.remove(questid);
playerdata.questData.finishedQuests.remove(questid); playerdata.questData.finishedQuests.remove(questid);
playerdata.save(true); playerdata.save();
sendResult(sender, String.format("Removed Quest \u00A7e%d\u00A77 for Player '\u00A7b%s\u00A77'", questid, playerdata.playername)); sendResult(sender, String.format("Removed Quest \u00A7e%d\u00A77 for Player '\u00A7b%s\u00A77'", questid, playerdata.playername));
} }
} }
@@ -182,7 +181,6 @@ public class QuestCommand extends CommandKamkeelBase {
public void reload(ICommandSender sender, String args[]){ public void reload(ICommandSender sender, String args[]){
new QuestController(); new QuestController();
QuestController.instance.load(); QuestController.instance.load();
SyncController.syncAllQuests();
sendResult(sender, "Quests Reloaded"); sendResult(sender, "Quests Reloaded");
} }
} }
+2 -5
View File
@@ -94,11 +94,8 @@ public class CommonProxy implements IGuiHandler {
if(gui == EnumGuiType.MerchantAdd) if(gui == EnumGuiType.MerchantAdd)
return new ContainerMerchantAdd(player, ServerEventsHandler.Merchant, player.worldObj); return new ContainerMerchantAdd(player, ServerEventsHandler.Merchant, player.worldObj);
if(gui == EnumGuiType.Crate){ if(gui == EnumGuiType.Crate)
if(player.inventory != null && (TileNpcContainer)player.worldObj.getTileEntity(x, y, z) != null){ return new ContainerCrate(player.inventory, (TileNpcContainer)player.worldObj.getTileEntity(x, y, z));
return new ContainerCrate(player.inventory, (TileNpcContainer)player.worldObj.getTileEntity(x, y, z));
}
}
if(gui == EnumGuiType.PlayerMailman) if(gui == EnumGuiType.PlayerMailman)
return new ContainerMail(player, x == 1, y == 1); return new ContainerMail(player, x == 1, y == 1);
+1 -1
View File
@@ -36,7 +36,7 @@ import java.util.ArrayList;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
@Mod(modid = "customnpcs", name = "CustomNPC+", version = "1.9-sync") @Mod(modid = "customnpcs", name = "CustomNPC+", version = "1.8.4")
public class CustomNpcs { public class CustomNpcs {
@SidedProxy(clientSide = "noppes.npcs.client.ClientProxy", serverSide = "noppes.npcs.CommonProxy") @SidedProxy(clientSide = "noppes.npcs.client.ClientProxy", serverSide = "noppes.npcs.CommonProxy")
@@ -441,6 +441,8 @@ public class NoppesUtilPlayer {
questData.trackQuest(nextQuest.quest); questData.trackQuest(nextQuest.quest);
} }
playerData.save();
return true; return true;
} }
+14 -17
View File
@@ -25,7 +25,10 @@ import net.minecraft.util.DamageSource;
import net.minecraft.util.MathHelper; import net.minecraft.util.MathHelper;
import net.minecraft.world.World; import net.minecraft.world.World;
import noppes.npcs.api.entity.IPlayer; import noppes.npcs.api.entity.IPlayer;
import noppes.npcs.constants.*; import noppes.npcs.constants.EnumGuiType;
import noppes.npcs.constants.EnumPacketClient;
import noppes.npcs.constants.EnumPlayerData;
import noppes.npcs.constants.EnumRoleType;
import noppes.npcs.containers.ContainerManageBanks; import noppes.npcs.containers.ContainerManageBanks;
import noppes.npcs.containers.ContainerManageRecipes; import noppes.npcs.containers.ContainerManageRecipes;
import noppes.npcs.controllers.*; import noppes.npcs.controllers.*;
@@ -159,7 +162,6 @@ public class NoppesUtilServer {
public static void openDialog(EntityPlayer player, EntityNPCInterface npc, Dialog dia, int optionId){ public static void openDialog(EntityPlayer player, EntityNPCInterface npc, Dialog dia, int optionId){
Dialog dialog = dia.copy(player); Dialog dialog = dia.copy(player);
PlayerData playerdata = PlayerDataController.instance.getPlayerData(player);
if (!npc.isRemote()) { if (!npc.isRemote()) {
if (EventHooks.onNPCDialog(npc, player, dialog.id, optionId, dialog)) { if (EventHooks.onNPCDialog(npc, player, dialog.id, optionId, dialog)) {
@@ -172,7 +174,7 @@ public class NoppesUtilServer {
if(npc instanceof EntityDialogNpc || dia.id < 0){ if(npc instanceof EntityDialogNpc || dia.id < 0){
dialog.hideNPC = true; dialog.hideNPC = true;
Server.sendDataDelayed((EntityPlayerMP)player, EnumPacketClient.DIALOG_DUMMY, 100, npc.getCommandSenderName(), dialog.writeToNBT(new NBTTagCompound())); Server.sendData((EntityPlayerMP)player, EnumPacketClient.DIALOG_DUMMY, npc.getCommandSenderName(), dialog.writeToNBT(new NBTTagCompound()));
} }
else else
Server.sendData((EntityPlayerMP)player, EnumPacketClient.DIALOG, npc.getEntityId(), dialog.writeToNBT(new NBTTagCompound())); Server.sendData((EntityPlayerMP)player, EnumPacketClient.DIALOG, npc.getEntityId(), dialog.writeToNBT(new NBTTagCompound()));
@@ -185,10 +187,8 @@ public class NoppesUtilServer {
if(dialog.mail.isValid()) if(dialog.mail.isValid())
PlayerDataController.instance.addPlayerMessage(player.getCommandSenderName(), dialog.mail); PlayerDataController.instance.addPlayerMessage(player.getCommandSenderName(), dialog.mail);
PlayerDialogData data = PlayerDataController.instance.getPlayerData(player).dialogData; PlayerDialogData data = PlayerDataController.instance.getPlayerData(player).dialogData;
if(!data.dialogsRead.contains(dialog.id)){ if(!data.dialogsRead.contains(dialog.id))
data.dialogsRead.add(dialog.id); data.dialogsRead.add(dialog.id);
playerdata.updateClient = true;
}
setEditingNpc(player, npc); setEditingNpc(player, npc);
} }
public static void runCommand(EntityPlayer player, String name, String command){ public static void runCommand(EntityPlayer player, String name, String command){
@@ -485,7 +485,7 @@ public class NoppesUtilServer {
return; return;
String name = Server.readString(buffer); String name = Server.readString(buffer);
EnumPlayerData type = EnumPlayerData.values()[id]; EnumPlayerData type = EnumPlayerData.values()[id];
EntityPlayerMP pl = MinecraftServer.getServer().getConfigurationManager().func_152612_a(name); EntityPlayer pl = MinecraftServer.getServer().getConfigurationManager().func_152612_a(name);
PlayerData playerdata = null; PlayerData playerdata = null;
if(pl == null) if(pl == null)
playerdata = PlayerDataController.instance.getDataFromUsername(name); playerdata = PlayerDataController.instance.getDataFromUsername(name);
@@ -499,7 +499,7 @@ public class NoppesUtilServer {
if(pl != null){ if(pl != null){
playerdata.setNBT(new NBTTagCompound()); playerdata.setNBT(new NBTTagCompound());
sendPlayerData(type, player, name); sendPlayerData(type, player, name);
playerdata.save(true); playerdata.save();
return; return;
} }
else { else {
@@ -512,31 +512,28 @@ public class NoppesUtilServer {
int questId = buffer.readInt(); int questId = buffer.readInt();
data.activeQuests.remove(questId); data.activeQuests.remove(questId);
data.finishedQuests.remove(questId); data.finishedQuests.remove(questId);
playerdata.save(true); playerdata.save();
} }
if(type == EnumPlayerData.Dialog){ if(type == EnumPlayerData.Dialog){
PlayerDialogData data = playerdata.dialogData; PlayerDialogData data = playerdata.dialogData;
data.dialogsRead.remove(buffer.readInt()); data.dialogsRead.remove(buffer.readInt());
playerdata.save(true); playerdata.save();
} }
if(type == EnumPlayerData.Transport){ if(type == EnumPlayerData.Transport){
PlayerTransportData data = playerdata.transportData; PlayerTransportData data = playerdata.transportData;
data.transports.remove(buffer.readInt()); data.transports.remove(buffer.readInt());
playerdata.save(true); playerdata.save();
} }
if(type == EnumPlayerData.Bank){ if(type == EnumPlayerData.Bank){
PlayerBankData data = playerdata.bankData; PlayerBankData data = playerdata.bankData;
data.banks.remove(buffer.readInt()); data.banks.remove(buffer.readInt());
playerdata.save(true); playerdata.save();
} }
if(type == EnumPlayerData.Factions){ if(type == EnumPlayerData.Factions){
PlayerFactionData data = playerdata.factionData; PlayerFactionData data = playerdata.factionData;
data.factionData.remove(buffer.readInt()); data.factionData.remove(buffer.readInt());
playerdata.save(true); playerdata.save();
} }
if(pl != null) {
SyncController.syncPlayer(pl);
}
sendPlayerData(type, player, name); sendPlayerData(type, player, name);
} }
@@ -227,7 +227,9 @@ public class PacketHandlerServer{
data.getScripts().add(new ScriptContainer(data)); data.getScripts().add(new ScriptContainer(data));
} }
NBTTagCompound tabCompound = Server.readNBT(buffer); NBTTagCompound tabCompound = Server.readNBT(buffer);
data.getScripts().get(tab).readFromNBT(tabCompound); ScriptContainer script = new ScriptContainer(data);
script.readFromNBT(tabCompound);
data.getScripts().set(tab,script);
} else { } else {
NBTTagCompound compound = Server.readNBT(buffer); NBTTagCompound compound = Server.readNBT(buffer);
data.setLanguage(compound.getString("ScriptLanguage")); data.setLanguage(compound.getString("ScriptLanguage"));
@@ -239,6 +241,9 @@ public class PacketHandlerServer{
} }
} }
data.setEnabled(compound.getBoolean("ScriptEnabled")); data.setEnabled(compound.getBoolean("ScriptEnabled"));
for (ScriptContainer container : data.getScripts()) {
container.setEngine(data.getLanguage());
}
} }
} }
@@ -289,6 +294,7 @@ public class PacketHandlerServer{
private void itemScriptPackets(EnumPacketServer type, ByteBuf buffer, EntityPlayerMP player) throws Exception { private void itemScriptPackets(EnumPacketServer type, ByteBuf buffer, EntityPlayerMP player) throws Exception {
if (type == EnumPacketServer.ScriptItemDataGet) { if (type == EnumPacketServer.ScriptItemDataGet) {
ScriptCustomItem iw = (ScriptCustomItem) NpcAPI.Instance().getIItemStack(player.getHeldItem()); ScriptCustomItem iw = (ScriptCustomItem) NpcAPI.Instance().getIItemStack(player.getHeldItem());
iw.loadScriptData();
NBTTagCompound compound = iw.getMCNbt(); NBTTagCompound compound = iw.getMCNbt();
compound.setTag("Languages", ScriptController.Instance.nbtLanguages()); compound.setTag("Languages", ScriptController.Instance.nbtLanguages());
Server.sendData(player, EnumPacketClient.GUI_DATA, new Object[]{compound}); Server.sendData(player, EnumPacketClient.GUI_DATA, new Object[]{compound});
@@ -300,7 +306,8 @@ public class PacketHandlerServer{
NBTTagCompound compound = Server.readNBT(buffer); NBTTagCompound compound = Server.readNBT(buffer);
ScriptCustomItem wrapper = (ScriptCustomItem) NpcAPI.Instance().getIItemStack(player.getHeldItem()); ScriptCustomItem wrapper = (ScriptCustomItem) NpcAPI.Instance().getIItemStack(player.getHeldItem());
wrapper.setMCNbt(compound); wrapper.setMCNbt(compound);
wrapper.lastInited = -1L; wrapper.loadScriptData();
wrapper.loaded = false;
wrapper.saveScriptData(); wrapper.saveScriptData();
player.sendContainerToPlayer(player.inventoryContainer); player.sendContainerToPlayer(player.inventoryContainer);
} }
@@ -58,7 +58,7 @@ public class ScriptItemEventHandler {
try { try {
if (event.entityItem.getEntityItem().getItem() == CustomItems.scripted_item && !event.isCanceled()) { if (event.entityItem.getEntityItem().getItem() == CustomItems.scripted_item && !event.isCanceled()) {
IItemCustom isw = ItemScripted.GetWrapper(event.entityItem.getEntityItem()); IItemCustom isw = ItemScripted.GetWrapper(event.entityItem.getEntityItem());
EventHooks.onScriptItemTossed(isw, event.player, event.entityItem); event.setCanceled(EventHooks.onScriptItemTossed(isw, event.player, event.entityItem));
} }
} catch (Exception e) {} } catch (Exception e) {}
} }
@@ -27,7 +27,6 @@ import net.minecraftforge.event.world.BlockEvent;
import noppes.npcs.api.entity.IPlayer; import noppes.npcs.api.entity.IPlayer;
import noppes.npcs.constants.EnumPacketClient; import noppes.npcs.constants.EnumPacketClient;
import noppes.npcs.constants.EnumQuestType; import noppes.npcs.constants.EnumQuestType;
import noppes.npcs.constants.SyncType;
import noppes.npcs.controllers.PlayerDataController; import noppes.npcs.controllers.PlayerDataController;
import noppes.npcs.controllers.ScriptController; import noppes.npcs.controllers.ScriptController;
import noppes.npcs.controllers.data.PlayerData; import noppes.npcs.controllers.data.PlayerData;
@@ -68,11 +67,6 @@ public class ScriptPlayerEventHandler {
if (PlayerDataController.instance != null) { if (PlayerDataController.instance != null) {
PlayerData playerData = PlayerDataController.instance.getPlayerData(player); PlayerData playerData = PlayerDataController.instance.getPlayerData(player);
if(playerData.updateClient) {
Server.sendData((EntityPlayerMP)player, EnumPacketClient.SYNC_END, SyncType.PLAYER_DATA, playerData.getSyncNBT());
playerData.updateClient = false;
}
if (playerData.timers.size() > 0) { if (playerData.timers.size() > 0) {
playerData.timers.update(); playerData.timers.update();
} }
@@ -335,7 +329,7 @@ public class ScriptPlayerEventHandler {
if(event.player.worldObj instanceof WorldServer) { if(event.player.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts; PlayerDataScript handler = ScriptController.Instance.playerScripts;
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.player); IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.player);
EventHooks.onPlayerToss(handler, scriptPlayer, event.entityItem); event.setCanceled(EventHooks.onPlayerToss(handler, scriptPlayer, event.entityItem));
} }
} }
+11 -26
View File
@@ -13,7 +13,7 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.PacketBuffer; import net.minecraft.network.PacketBuffer;
import net.minecraft.village.MerchantRecipeList; import net.minecraft.village.MerchantRecipeList;
import noppes.npcs.constants.EnumPacketClient; import noppes.npcs.constants.EnumPacketClient;
import noppes.npcs.util.CustomNPCsScheduler; import noppes.npcs.util.CustomNPCsThreader;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
@@ -22,20 +22,7 @@ import java.util.Map;
public class Server { public class Server {
public static void sendData(final EntityPlayerMP player, final EnumPacketClient enu, final Object... obs) { public static void sendData(final EntityPlayerMP player, final EnumPacketClient enu, final Object... obs) {
sendDataDelayed(player, enu, 0, obs); sendDataChecked(player, enu, obs);
}
public static void sendDataDelayed(final EntityPlayerMP player, final EnumPacketClient type, int delay, final Object... obs) {
CustomNPCsScheduler.runTack(() -> {
PacketBuffer buffer = new PacketBuffer(Unpooled.buffer());
try {
if (!fillBuffer(buffer, type, obs))
return;
CustomNpcs.Channel.sendTo(new FMLProxyPacket(buffer, "CustomNPCs"), player);
} catch (IOException e) {
LogWriter.error(type + " Errored", e);
}
}, delay);
} }
public static boolean sendDataChecked(EntityPlayerMP player, EnumPacketClient type, Object... obs) { public static boolean sendDataChecked(EntityPlayerMP player, EnumPacketClient type, Object... obs) {
@@ -51,17 +38,15 @@ public class Server {
} }
public static void sendAssociatedData(final Entity entity, final EnumPacketClient enu, final Object... obs) { public static void sendAssociatedData(final Entity entity, final EnumPacketClient enu, final Object... obs) {
CustomNPCsScheduler.runTack(() -> { ByteBuf buffer = Unpooled.buffer();
ByteBuf buffer = Unpooled.buffer(); try {
try { if(!fillBuffer(buffer, enu, obs))
if(!fillBuffer(buffer, enu, obs)) return;
return; TargetPoint point = new TargetPoint(entity.dimension, entity.posX, entity.posY, entity.posZ, 60);
TargetPoint point = new TargetPoint(entity.dimension, entity.posX, entity.posY, entity.posZ, 60); CustomNpcs.Channel.sendToAllAround(new FMLProxyPacket(buffer,"CustomNPCs"), point);
CustomNpcs.Channel.sendToAllAround(new FMLProxyPacket(buffer,"CustomNPCs"), point); } catch (IOException e) {
} catch (IOException e) { e.printStackTrace();
e.printStackTrace(); }
}
});
} }
public static void sendToAll(EnumPacketClient enu, Object... obs) { public static void sendToAll(EnumPacketClient enu, Object... obs) {
ByteBuf buffer = Unpooled.buffer(); ByteBuf buffer = Unpooled.buffer();
@@ -1,6 +1,7 @@
package noppes.npcs; package noppes.npcs;
import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.eventhandler.EventPriority;
import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import net.minecraft.block.Block; import net.minecraft.block.Block;
@@ -20,6 +21,7 @@ import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.util.MathHelper; import net.minecraft.util.MathHelper;
import net.minecraft.util.StatCollector; import net.minecraft.util.StatCollector;
import net.minecraft.village.MerchantRecipeList; import net.minecraft.village.MerchantRecipeList;
import net.minecraftforge.event.entity.EntityEvent;
import net.minecraftforge.event.entity.EntityJoinWorldEvent; import net.minecraftforge.event.entity.EntityJoinWorldEvent;
import net.minecraftforge.event.entity.living.LivingDeathEvent; import net.minecraftforge.event.entity.living.LivingDeathEvent;
import net.minecraftforge.event.entity.living.LivingHurtEvent; import net.minecraftforge.event.entity.living.LivingHurtEvent;
@@ -253,7 +255,7 @@ public class ServerEventsHandler {
doExcalibur((EntityPlayer) event.source.getEntity(),event.entityLiving); doExcalibur((EntityPlayer) event.source.getEntity(),event.entityLiving);
} }
if(event.source.getEntity() instanceof EntityNPCInterface && event.entityLiving != null){ if(event.source.getEntity() instanceof EntityNPCInterface){
EntityNPCInterface npc = (EntityNPCInterface) event.source.getEntity(); EntityNPCInterface npc = (EntityNPCInterface) event.source.getEntity();
Line line = npc.advanced.getKillLine(); Line line = npc.advanced.getKillLine();
if(line != null) if(line != null)
@@ -276,7 +278,7 @@ public class ServerEventsHandler {
} }
if(event.entityLiving instanceof EntityPlayer){ if(event.entityLiving instanceof EntityPlayer){
PlayerData data = PlayerDataController.instance.getPlayerData((EntityPlayer)event.entityLiving); PlayerData data = PlayerDataController.instance.getPlayerData((EntityPlayer)event.entityLiving);
data.save(false); data.save();
} }
} }
@@ -341,7 +343,6 @@ public class ServerEventsHandler {
killed.put(name, amount + 1); killed.put(name, amount + 1);
} }
quest.setKilled(data, killed); quest.setKilled(data, killed);
playerData.updateClient = true;
} }
if(!checkCompletion) if(!checkCompletion)
return; return;
@@ -359,6 +360,12 @@ public class ServerEventsHandler {
questData.checkQuestCompletion(playerData, EnumQuestType.Item); questData.checkQuestCompletion(playerData, EnumQuestType.Item);
} }
@SubscribeEvent
public void world(PlayerEvent.SaveToFile event){
PlayerData data = PlayerDataController.instance.getPlayerData((EntityPlayer) event.entity);
data.save();
}
@SubscribeEvent @SubscribeEvent
public void world(EntityJoinWorldEvent event){ public void world(EntityJoinWorldEvent event){
if(event.world.isRemote || !(event.entity instanceof EntityPlayer)) if(event.world.isRemote || !(event.entity instanceof EntityPlayer))
@@ -367,12 +374,6 @@ public class ServerEventsHandler {
data.updateCompanion(event.world); data.updateCompanion(event.world);
} }
@SubscribeEvent
public void world(PlayerEvent.SaveToFile event){
PlayerData data = PlayerDataController.instance.getPlayerData((EntityPlayer) event.entity);
data.save(false);
}
@SubscribeEvent @SubscribeEvent
public void populateChunk(PopulateChunkEvent.Post event){ public void populateChunk(PopulateChunkEvent.Post event){
NPCSpawning.performWorldGenSpawning(event.world, event.chunkX, event.chunkZ, event.rand); NPCSpawning.performWorldGenSpawning(event.world, event.chunkX, event.chunkZ, event.rand);
@@ -4,11 +4,9 @@ import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.PlayerEvent; import cpw.mods.fml.common.gameevent.PlayerEvent;
import cpw.mods.fml.common.gameevent.TickEvent; import cpw.mods.fml.common.gameevent.TickEvent;
import cpw.mods.fml.common.gameevent.TickEvent.Phase; import cpw.mods.fml.common.gameevent.TickEvent.Phase;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.server.MinecraftServer; import net.minecraft.server.MinecraftServer;
import net.minecraft.world.WorldServer; import net.minecraft.world.WorldServer;
import noppes.npcs.client.AnalyticsTracking; import noppes.npcs.client.AnalyticsTracking;
import noppes.npcs.controllers.SyncController;
import java.net.InetAddress; import java.net.InetAddress;
import java.net.UnknownHostException; import java.net.UnknownHostException;
@@ -42,9 +40,5 @@ public class ServerTickHandler {
serverName = e; serverName = e;
} }
AnalyticsTracking.sendData(event.player, "join", serverName); AnalyticsTracking.sendData(event.player, "join", serverName);
if(event.player instanceof EntityPlayerMP){
EntityPlayerMP player = (EntityPlayerMP) event.player;
SyncController.syncPlayer(player);
}
} }
} }
@@ -56,7 +56,6 @@ public class TileWaypoint extends TileEntity {
player.addChatMessage(new ChatComponentTranslation(name + " " + StatCollector.translateToLocal("quest.found"))); player.addChatMessage(new ChatComponentTranslation(name + " " + StatCollector.translateToLocal("quest.found")));
questData.checkQuestCompletion(playerData, EnumQuestType.Location); questData.checkQuestCompletion(playerData, EnumQuestType.Location);
playerData.updateClient = true;
} }
} }
} }
@@ -3,7 +3,6 @@ package noppes.npcs.client;
import cpw.mods.fml.common.network.internal.FMLProxyPacket; import cpw.mods.fml.common.network.internal.FMLProxyPacket;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled; import io.netty.buffer.Unpooled;
import net.minecraft.network.PacketBuffer;
import noppes.npcs.AnimationData; import noppes.npcs.AnimationData;
import noppes.npcs.CustomNpcs; import noppes.npcs.CustomNpcs;
import noppes.npcs.Server; import noppes.npcs.Server;
@@ -219,13 +219,12 @@ public class ClientProxy extends CommonProxy {
private GuiScreen getGui(EntityNPCInterface npc, EnumGuiType gui, Container container, int x, int y, int z) { private GuiScreen getGui(EntityNPCInterface npc, EnumGuiType gui, Container container, int x, int y, int z) {
if (gui == EnumGuiType.MainMenuDisplay){ if (gui == EnumGuiType.MainMenuDisplay) {
if(npc != null) if (npc != null)
return new GuiNpcDisplay(npc); return new GuiNpcDisplay(npc);
else else
Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("Unable to find npc")); Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("Unable to find npc"));
} } else if (gui == EnumGuiType.MainMenuStats)
else if (gui == EnumGuiType.MainMenuStats)
return new GuiNpcStats(npc); return new GuiNpcStats(npc);
else if (gui == EnumGuiType.MainMenuInv) else if (gui == EnumGuiType.MainMenuInv)
@@ -234,10 +233,10 @@ public class ClientProxy extends CommonProxy {
else if (gui == EnumGuiType.MainMenuAdvanced) else if (gui == EnumGuiType.MainMenuAdvanced)
return new GuiNpcAdvanced(npc); return new GuiNpcAdvanced(npc);
else if(gui == EnumGuiType.QuestReward) else if (gui == EnumGuiType.QuestReward)
return new GuiNpcQuestReward(npc, (ContainerNpcQuestReward) container); return new GuiNpcQuestReward(npc, (ContainerNpcQuestReward) container);
else if(gui == EnumGuiType.QuestItem) else if (gui == EnumGuiType.QuestItem)
return new GuiNpcQuestTypeItem(npc, (ContainerNpcQuestTypeItem) container); return new GuiNpcQuestTypeItem(npc, (ContainerNpcQuestTypeItem) container);
else if (gui == EnumGuiType.MovingPath) else if (gui == EnumGuiType.MovingPath)
@@ -261,16 +260,14 @@ public class ClientProxy extends CommonProxy {
animNpc.display.texture = "customnpcs:textures/entity/humanmale/AnimationBody.png"; animNpc.display.texture = "customnpcs:textures/entity/humanmale/AnimationBody.png";
} }
return new GuiNPCManageAnimations(animNpc); return new GuiNPCManageAnimations(animNpc);
} } else if (gui == EnumGuiType.ManageLinked)
else if (gui == EnumGuiType.ManageLinked)
return new GuiNPCManageLinkedNpc(npc); return new GuiNPCManageLinkedNpc(npc);
else if (gui == EnumGuiType.ManageTransport) else if (gui == EnumGuiType.ManageTransport)
return new GuiNPCManageTransporters(npc); return new GuiNPCManageTransporters(npc);
else if (gui == EnumGuiType.ManageRecipes) else if (gui == EnumGuiType.ManageRecipes)
return new GuiNpcManageRecipes(npc,(ContainerManageRecipes) container); return new GuiNpcManageRecipes(npc, (ContainerManageRecipes) container);
else if (gui == EnumGuiType.ManageDialogs) else if (gui == EnumGuiType.ManageDialogs)
return new GuiNPCManageDialogs(npc); return new GuiNPCManageDialogs(npc);
@@ -278,8 +275,8 @@ public class ClientProxy extends CommonProxy {
else if (gui == EnumGuiType.ManageQuests) else if (gui == EnumGuiType.ManageQuests)
return new GuiNPCManageQuest(npc); return new GuiNPCManageQuest(npc);
else if(gui == EnumGuiType.ManageBanks) else if (gui == EnumGuiType.ManageBanks)
return new GuiNPCManageBanks(npc,(ContainerManageBanks) container); return new GuiNPCManageBanks(npc, (ContainerManageBanks) container);
else if (gui == EnumGuiType.MainMenuGlobal) else if (gui == EnumGuiType.MainMenuGlobal)
return new GuiNPCGlobalMainMenu(npc); return new GuiNPCGlobalMainMenu(npc);
@@ -293,56 +290,56 @@ public class ClientProxy extends CommonProxy {
else if (gui == EnumGuiType.PlayerFollower) else if (gui == EnumGuiType.PlayerFollower)
return new GuiNpcFollower(npc, (ContainerNPCFollower) container); return new GuiNpcFollower(npc, (ContainerNPCFollower) container);
else if(gui == EnumGuiType.PlayerTrader) else if (gui == EnumGuiType.PlayerTrader)
return new GuiNPCTrader(npc, (ContainerNPCTrader) container); return new GuiNPCTrader(npc, (ContainerNPCTrader) container);
else if(gui == EnumGuiType.PlayerBankSmall || gui == EnumGuiType.PlayerBankUnlock || gui == EnumGuiType.PlayerBankUprade || gui == EnumGuiType.PlayerBankLarge) else if (gui == EnumGuiType.PlayerBankSmall || gui == EnumGuiType.PlayerBankUnlock || gui == EnumGuiType.PlayerBankUprade || gui == EnumGuiType.PlayerBankLarge)
return new GuiNPCBankChest(npc, (ContainerNPCBankInterface) container); return new GuiNPCBankChest(npc, (ContainerNPCBankInterface) container);
else if(gui == EnumGuiType.PlayerTransporter) else if (gui == EnumGuiType.PlayerTransporter)
return new GuiTransportSelection(npc); return new GuiTransportSelection(npc);
else if(gui == EnumGuiType.Script && ConfigScript.ScriptingEnabled) else if (gui == EnumGuiType.Script && ConfigScript.ScriptingEnabled)
return new GuiScript(npc); return new GuiScript(npc);
else if (gui == EnumGuiType.ScriptItem) else if (gui == EnumGuiType.ScriptItem)
return new GuiScriptItem(); return new GuiScriptItem();
else if(gui == EnumGuiType.PlayerAnvil) else if (gui == EnumGuiType.PlayerAnvil)
return new GuiNpcCarpentryBench((ContainerCarpentryBench) container); return new GuiNpcCarpentryBench((ContainerCarpentryBench) container);
else if (gui == EnumGuiType.SetupFollower) else if (gui == EnumGuiType.SetupFollower)
return new GuiNpcFollowerSetup(npc, (ContainerNPCFollowerSetup) container); return new GuiNpcFollowerSetup(npc, (ContainerNPCFollowerSetup) container);
else if (gui == EnumGuiType.SetupItemGiver) else if (gui == EnumGuiType.SetupItemGiver)
return new GuiNpcItemGiver(npc, (ContainerNpcItemGiver) container); return new GuiNpcItemGiver(npc, (ContainerNpcItemGiver) container);
else if(gui == EnumGuiType.SetupTrader) else if (gui == EnumGuiType.SetupTrader)
return new GuiNpcTraderSetup(npc, (ContainerNPCTraderSetup) container); return new GuiNpcTraderSetup(npc, (ContainerNPCTraderSetup) container);
else if(gui == EnumGuiType.SetupTransporter) else if (gui == EnumGuiType.SetupTransporter)
return new GuiNpcTransporter(npc); return new GuiNpcTransporter(npc);
else if(gui == EnumGuiType.SetupBank) else if (gui == EnumGuiType.SetupBank)
return new GuiNpcBankSetup(npc); return new GuiNpcBankSetup(npc);
else if(gui == EnumGuiType.NpcRemote && Minecraft.getMinecraft().currentScreen == null) else if (gui == EnumGuiType.NpcRemote && Minecraft.getMinecraft().currentScreen == null)
return new GuiNpcRemoteEditor(); return new GuiNpcRemoteEditor();
else if(gui == EnumGuiType.ScriptEvent && Minecraft.getMinecraft().currentScreen == null) else if (gui == EnumGuiType.ScriptEvent && Minecraft.getMinecraft().currentScreen == null)
return new GuiScriptGlobal(); return new GuiScriptGlobal();
else if(gui == EnumGuiType.PlayerMailman) else if (gui == EnumGuiType.PlayerMailman)
return new GuiMailmanWrite((ContainerMail) container, x == 1, y == 1); return new GuiMailmanWrite((ContainerMail) container, x == 1, y == 1);
else if(gui == EnumGuiType.PlayerMailbox) else if (gui == EnumGuiType.PlayerMailbox)
return new GuiMailbox(); return new GuiMailbox();
else if(gui == EnumGuiType.MerchantAdd) else if (gui == EnumGuiType.MerchantAdd)
return new GuiMerchantAdd(); return new GuiMerchantAdd();
else if(gui == EnumGuiType.Crate) else if (gui == EnumGuiType.Crate)
return new GuiCrate((ContainerCrate)container); return new GuiCrate((ContainerCrate) container);
else if(gui == EnumGuiType.NpcDimensions) else if(gui == EnumGuiType.NpcDimensions)
return new GuiNpcDimension(); return new GuiNpcDimension();
@@ -30,18 +30,14 @@ import noppes.npcs.client.gui.util.*;
import noppes.npcs.config.ConfigClient; import noppes.npcs.config.ConfigClient;
import noppes.npcs.constants.EnumGuiType; import noppes.npcs.constants.EnumGuiType;
import noppes.npcs.constants.EnumPacketClient; import noppes.npcs.constants.EnumPacketClient;
import noppes.npcs.constants.SyncType;
import noppes.npcs.controllers.RecipeController; import noppes.npcs.controllers.RecipeController;
import noppes.npcs.controllers.SyncController;
import noppes.npcs.controllers.data.Animation; import noppes.npcs.controllers.data.Animation;
import noppes.npcs.controllers.data.RecipeCarpentry; import noppes.npcs.controllers.data.RecipeCarpentry;
import noppes.npcs.entity.EntityDialogNpc; import noppes.npcs.entity.EntityDialogNpc;
import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.items.ItemScripted;
import java.io.IOException; import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map;
public class PacketHandlerClient extends PacketHandlerServer{ public class PacketHandlerClient extends PacketHandlerServer{
@@ -104,27 +100,6 @@ public class PacketHandlerClient extends PacketHandlerServer{
RecipeController.instance.anvilRecipes = RecipeController.syncRecipes; RecipeController.instance.anvilRecipes = RecipeController.syncRecipes;
RecipeController.syncRecipes = new HashMap<Integer, RecipeCarpentry>(); RecipeController.syncRecipes = new HashMap<Integer, RecipeCarpentry>();
} }
else if(type == EnumPacketClient.SYNC_ADD || type == EnumPacketClient.SYNC_END){
int synctype = buffer.readInt();
NBTTagCompound compound = Server.readNBT(buffer);
SyncController.clientSync(synctype, compound, type == EnumPacketClient.SYNC_END);
if(synctype == SyncType.PLAYER_DATA){
ClientProxy.playerData.setNBT(compound);
}
}
else if(type == EnumPacketClient.SYNC_UPDATE){
int synctype = buffer.readInt();
NBTTagCompound compound = Server.readNBT(buffer);
SyncController.clientSyncUpdate(synctype, compound, buffer);
}
else if(type == EnumPacketClient.SYNC_REMOVE){
int synctype = buffer.readInt();
int id = buffer.readInt();
SyncController.clientSyncRemove(synctype, id);
}
else if(type == EnumPacketClient.DIALOG){ else if(type == EnumPacketClient.DIALOG){
Entity entity = Minecraft.getMinecraft().theWorld.getEntityByID(buffer.readInt()); Entity entity = Minecraft.getMinecraft().theWorld.getEntityByID(buffer.readInt());
if(entity == null || !(entity instanceof EntityNPCInterface)) if(entity == null || !(entity instanceof EntityNPCInterface))
@@ -42,6 +42,7 @@ public class GuiNpcMobSpawner extends GuiNPCInterface implements IGuiData {
private int posX,posY,posZ; private int posX,posY,posZ;
private List<String> list; private List<String> list;
private List<String> rawList;
private List<String> tagList; private List<String> tagList;
private static int showingClones = 0; private static int showingClones = 0;
@@ -181,6 +182,7 @@ public class GuiNpcMobSpawner extends GuiNPCInterface implements IGuiData {
} }
} }
this.list = list; this.list = list;
this.rawList = new ArrayList<String>(this.list);
scroll.setList(getSearchList(), ascending == 0, sortType == 0); scroll.setList(getSearchList(), ascending == 0, sortType == 0);
} }
private void showClones() { private void showClones() {
@@ -198,6 +200,26 @@ public class GuiNpcMobSpawner extends GuiNPCInterface implements IGuiData {
} }
this.tagMap = ClientTagMapController.Instance.getTagMap(activeTab); this.tagMap = ClientTagMapController.Instance.getTagMap(activeTab);
this.rawList = new ArrayList<String>(this.list);
if(this.tagMap != null){
if(GuiNpcMobSpawner.displayTags == 0 || GuiNpcMobSpawner.displayTags == 1){
for(int i = 0; i < this.list.size(); i++){
StringBuilder npcName = new StringBuilder(list.get(i));
if (this.tagMap.hasClone(list.get(i))) {
for (UUID tagUUID : this.tagMap.getUUIDsList(list.get(i))){
Tag tag = tags.get(tagUUID);
if(tag != null){
if(GuiNpcMobSpawner.displayTags == 1 || !tag.getIsHidden()){
npcName.append(" [" + tag.name + "]");
}
}
}
}
this.rawList.set(i, npcName.toString());
}
}
}
scroll.setList(getSearchList(), ascending == 0, sortType == 0); scroll.setList(getSearchList(), ascending == 0, sortType == 0);
} }
public void keyTyped(char c, int i) public void keyTyped(char c, int i)
@@ -222,6 +244,9 @@ public class GuiNpcMobSpawner extends GuiNPCInterface implements IGuiData {
if(this.list == null){ if(this.list == null){
this.list = new ArrayList<String>(); this.list = new ArrayList<String>();
} }
if(this.rawList == null){
this.rawList = new ArrayList<String>();
}
// No Filters - or - Entities // No Filters - or - Entities
if(tagFilters.size() == 0 || showingClones == 1){ if(tagFilters.size() == 0 || showingClones == 1){
@@ -231,9 +256,10 @@ public class GuiNpcMobSpawner extends GuiNPCInterface implements IGuiData {
// Yes Search // Yes Search
else { else {
List<String> list = new ArrayList<String>(); List<String> list = new ArrayList<String>();
for(String name : this.list){ for(int i = 0; i < this.list.size(); i++){
if(name.toLowerCase().contains(search)) if(this.rawList.get(i).toLowerCase().contains(search)){
list.add(name); list.add(this.list.get(i));
}
} }
return list; return list;
} }
@@ -257,14 +283,16 @@ public class GuiNpcMobSpawner extends GuiNPCInterface implements IGuiData {
// Yes Search // Yes Search
List<String> list = new ArrayList<String>(); List<String> list = new ArrayList<String>();
for(String name : this.list){ for(int i = 0; i < this.list.size(); i++){
if(name.toLowerCase().contains(search)) { if(this.rawList.get(i).toLowerCase().contains(search)){
if(tagMap.hasClone(name)){ String npcName = this.list.get(i);
if(meetsCondition(name)){ if(tagMap.hasClone(npcName)){
list.add(name); if(meetsCondition(npcName)){
list.add(npcName);
} }
} }
} }
} }
return list; return list;
} }
@@ -481,6 +509,27 @@ public class GuiNpcMobSpawner extends GuiNPCInterface implements IGuiData {
} }
this.list = list; this.list = list;
this.rawList = new ArrayList<String>(this.list);
if(this.tagMap != null){
if(GuiNpcMobSpawner.displayTags == 0 || GuiNpcMobSpawner.displayTags == 1){
for(int i = 0; i < this.list.size(); i++){
StringBuilder npcName = new StringBuilder(list.get(i));
if (this.tagMap.hasClone(list.get(i))) {
for (UUID tagUUID : this.tagMap.getUUIDsList(list.get(i))){
Tag tag = tags.get(tagUUID);
if(tag != null){
if(GuiNpcMobSpawner.displayTags == 1 || !tag.getIsHidden()){
npcName.append(" [" + tag.name + "]");
}
}
}
}
this.rawList.set(i, npcName.toString());
}
}
}
scroll.setList(getSearchList(), ascending == 0, sortType == 0); scroll.setList(getSearchList(), ascending == 0, sortType == 0);
} }
} }
@@ -172,6 +172,10 @@ public class GuiNpcMobSpawnerAdd extends GuiNPCInterface implements GuiYesNoCall
@Override @Override
public void subGuiClosed(SubGuiInterface subgui) { public void subGuiClosed(SubGuiInterface subgui) {
if(subgui instanceof SubGuiClonerNPCTags){
close();
return;
}
initGui(); initGui();
} }
@@ -30,8 +30,8 @@ public class SubGuiClonerNPCTags extends SubGuiInterface implements IGuiData,ISc
setBackground("menubg.png"); setBackground("menubg.png");
xSize = 305; xSize = 305;
ySize = 220; ySize = 220;
closeOnEsc = false;
this.npc = npc; this.npc = npc;
closeOnEsc = false;
} }
public void initGui() public void initGui()
@@ -86,6 +86,7 @@ public class SubGuiClonerNPCTags extends SubGuiInterface implements IGuiData,ISc
tagNames.clear(); tagNames.clear();
} }
if (guibutton.id == 66) { if (guibutton.id == 66) {
save();
close(); close();
} }
initGui(); initGui();
@@ -154,11 +155,4 @@ public class SubGuiClonerNPCTags extends SubGuiInterface implements IGuiData,ISc
} }
return list; return list;
} }
@Override
public void close() {
save();
super.close();
}
} }
@@ -1,14 +1,9 @@
package noppes.npcs.client.gui; package noppes.npcs.client.gui;
import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiButton;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.StatCollector; import net.minecraft.util.StatCollector;
import noppes.npcs.client.Client;
import noppes.npcs.client.gui.util.*; import noppes.npcs.client.gui.util.*;
import noppes.npcs.constants.EnumPacketServer; import org.lwjgl.Sys;
import noppes.npcs.controllers.data.Tag;
import noppes.npcs.controllers.data.TagMap;
import java.util.*; import java.util.*;
@@ -16,6 +11,7 @@ public class SubGuiClonerQuickTags extends SubGuiInterface implements IScrollDat
{ {
public GuiNpcMobSpawnerAdd parent; public GuiNpcMobSpawnerAdd parent;
public GuiCustomScroll quickScroll = new GuiCustomScroll(this,0); public GuiCustomScroll quickScroll = new GuiCustomScroll(this,0);
public GuiCustomScroll selectedScroll = new GuiCustomScroll(this,5);
private static String quickSearch = ""; private static String quickSearch = "";
public SubGuiClonerQuickTags(GuiNpcMobSpawnerAdd par){ public SubGuiClonerQuickTags(GuiNpcMobSpawnerAdd par){
@@ -36,35 +32,60 @@ public class SubGuiClonerQuickTags extends SubGuiInterface implements IScrollDat
quickScroll.setSelectedList(GuiNpcMobSpawnerAdd.addTags); quickScroll.setSelectedList(GuiNpcMobSpawnerAdd.addTags);
this.addScroll(quickScroll); this.addScroll(quickScroll);
addLabel(new GuiNpcLabel(1, StatCollector.translateToLocal("cloner.wandtags"), guiLeft + 7, guiTop + 7)); addLabel(new GuiNpcLabel(1, StatCollector.translateToLocal("cloner.wandTags"), guiLeft + 7, guiTop + 7));
addScroll(quickScroll); addScroll(quickScroll);
addTextField(new GuiNpcTextField(2, this, fontRendererObj, guiLeft + 4, guiTop + 190, 140, 20, quickSearch)); addTextField(new GuiNpcTextField(2, this, fontRendererObj, guiLeft + 4, guiTop + 190, 140, 20, quickSearch));
addButton(new GuiNpcButton(10, guiLeft + 150, guiTop + 20, 120, 20, "gui.selectAll")); addButton(new GuiNpcButton(10, guiLeft + 150, guiTop + 20, 120, 20, "gui.selectAll"));
addButton(new GuiNpcButton(11, guiLeft + 150, guiTop + 43, 120, 20, "gui.deselectAll")); addButton(new GuiNpcButton(11, guiLeft + 150, guiTop + 43, 120, 20, "gui.deselectAll"));
addButton(new GuiNpcButton(66, guiLeft + 240, guiTop + 175, 60, 20, "gui.done")); selectedScroll.clear();
selectedScroll.setSize(145, 103);
selectedScroll.guiLeft = guiLeft + 150;
selectedScroll.guiTop = guiTop + 82;
selectedScroll.setUnselectable();
this.addScroll(selectedScroll);
getSelected(); addLabel(new GuiNpcLabel(3, StatCollector.translateToLocal("tags.selectedTags"), guiLeft + 153, guiTop + 68));
addScroll(selectedScroll);
addButton(new GuiNpcButton(66, guiLeft + 240, guiTop + 190, 60, 20, "gui.done"));
setSelected();
refreshSelected();
} }
protected void actionPerformed(GuiButton guibutton){ protected void actionPerformed(GuiButton guibutton){
if (guibutton.id == 10) { if (guibutton.id == 10) {
GuiNpcMobSpawnerAdd.addTags = new HashSet<>(parent.allTags); GuiNpcMobSpawnerAdd.addTags = new HashSet<>(parent.allTags);
quickScroll.setSelectedList(GuiNpcMobSpawnerAdd.addTags); quickScroll.setSelectedList(GuiNpcMobSpawnerAdd.addTags);
refreshSelected();
} }
if (guibutton.id == 11) { if (guibutton.id == 11) {
GuiNpcMobSpawnerAdd.addTags = new HashSet<>(); GuiNpcMobSpawnerAdd.addTags = new HashSet<>();
quickScroll.setSelectedList(GuiNpcMobSpawnerAdd.addTags); quickScroll.setSelectedList(GuiNpcMobSpawnerAdd.addTags);
refreshSelected();
} }
if (guibutton.id == 66) { if (guibutton.id == 66) {
close(); close();
} }
} }
public void getSelected(){ @Override
public void mouseClicked(int i, int j, int k)
{
super.mouseClicked(i, j, k);
refreshSelected();
}
public void setSelected(){
quickScroll.setList(getQuickTags()); quickScroll.setList(getQuickTags());
} }
public void refreshSelected(){
List<String> sortedList = new ArrayList<>(new TreeSet<>(GuiNpcMobSpawnerAdd.addTags));
selectedScroll.setList(sortedList);
}
@Override @Override
public void keyTyped(char c, int i) public void keyTyped(char c, int i)
{ {
@@ -9,26 +9,19 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.texture.ITextureObject;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.client.resources.IResource;
import net.minecraft.util.ResourceLocation;
import noppes.npcs.api.gui.ICustomGuiComponent; import noppes.npcs.api.gui.ICustomGuiComponent;
import noppes.npcs.client.ImageDownloadAlt; import noppes.npcs.client.Client;
import noppes.npcs.client.gui.custom.GuiCustom; import noppes.npcs.client.gui.custom.GuiCustom;
import noppes.npcs.client.gui.custom.interfaces.IClickListener; import noppes.npcs.client.gui.custom.interfaces.IClickListener;
import noppes.npcs.client.renderer.ImageBufferDownloadAlt; import noppes.npcs.client.renderer.customitem.ImageData;
import noppes.npcs.scripted.gui.ScriptGuiButton; import noppes.npcs.scripted.gui.ScriptGuiButton;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.InputStream;
public class CustomGuiButton extends GuiButton implements IClickListener { public class CustomGuiButton extends GuiButton implements IClickListener {
GuiCustom parent; GuiCustom parent;
ResourceLocation location = null;
ImageData imageData = null;
String texture;
public int textureX; public int textureX;
public int textureY; public int textureY;
boolean field_146123_n; boolean field_146123_n;
@@ -39,11 +32,6 @@ public class CustomGuiButton extends GuiButton implements IClickListener {
float alpha; float alpha;
float scale = 1.0F; float scale = 1.0F;
private int totalWidth, totalHeight;
private ImageDownloadAlt imageDownloadAlt = null;
private boolean isUrl = false;
private boolean gotWidthHeight = false;
public CustomGuiButton(int id, String buttonText, int x, int y) { public CustomGuiButton(int id, String buttonText, int x, int y) {
super(id, x, y, buttonText); super(id, x, y, buttonText);
} }
@@ -58,24 +46,12 @@ public class CustomGuiButton extends GuiButton implements IClickListener {
public CustomGuiButton(int buttonId, String buttonText, int x, int y, int width, int height, String texture, int textureX, int textureY) { public CustomGuiButton(int buttonId, String buttonText, int x, int y, int width, int height, String texture, int textureX, int textureY) {
this(buttonId, buttonText, x, y, width, height); this(buttonId, buttonText, x, y, width, height);
this.texture = texture;
this.textureX = textureX; this.textureX = textureX;
this.textureY = textureY; this.textureY = textureY;
this.label = buttonText; this.label = buttonText;
if (texture != null && !texture.isEmpty()) { if (texture != null && !texture.isEmpty()) {
this.location = new ResourceLocation(texture); this.imageData = Client.getImageData(texture);
if(texture.startsWith("https://")){
TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager();
ITextureObject object = new ImageDownloadAlt(null, texture, new ResourceLocation("customnpcs:textures/gui/invisible.png"), new ImageBufferDownloadAlt(true,false));
texturemanager.loadTexture(this.location, object);
} else {
try {
this.getWidthHeight();
} catch (IOException e) {
e.printStackTrace();
}
}
} else {
this.location = null;
} }
} }
@@ -115,42 +91,36 @@ public class CustomGuiButton extends GuiButton implements IClickListener {
public void onRender(Minecraft mc, int mouseX, int mouseY, int mouseWheel, float partialTicks) { public void onRender(Minecraft mc, int mouseX, int mouseY, int mouseWheel, float partialTicks) {
this.field_146123_n = mouseX >= this.xPosition + GuiCustom.guiLeft && mouseY >= this.yPosition + GuiCustom.guiTop && mouseX < this.xPosition + GuiCustom.guiLeft + this.width * this.scale && mouseY < this.yPosition + GuiCustom.guiTop + this.height * this.scale; this.field_146123_n = mouseX >= this.xPosition + GuiCustom.guiLeft && mouseY >= this.yPosition + GuiCustom.guiTop && mouseX < this.xPosition + GuiCustom.guiLeft + this.width * this.scale && mouseY < this.yPosition + GuiCustom.guiTop + this.height * this.scale;
if (this.location == null) {
totalWidth = totalHeight = 256;
textureX = textureY = 0;
}
float u1 = (float)textureX/(float)totalWidth;
float u2 = u1 + (float)width/(float)totalWidth;
float v1 = (float)textureY/(float)totalHeight;
float v2 = v1 + (float)height/(float)totalHeight;
if (this.location != null && this.enabled) {
if (this.field_146123_n) {
v1 = (float)(textureY + 2 * this.height)/(float)totalHeight;
} else {
v1 = (float)(textureY + this.height)/(float)totalHeight;
}
v2 = v1 + (float)height/(float)totalHeight;
}
if(imageDownloadAlt != null && isUrl && !gotWidthHeight){
getURLWidthHeight();
}
FontRenderer fontRenderer = mc.fontRenderer; FontRenderer fontRenderer = mc.fontRenderer;
GL11.glPushMatrix();
float red = (color >> 16 & 255) / 255f;
float green = (color >> 8 & 255) / 255f;
float blue = (color & 255) / 255f;
GL11.glColor4f(red,green,blue,this.alpha);
GL11.glTranslatef(GuiCustom.guiLeft + this.xPosition - u1 * totalWidth * this.scale, GuiCustom.guiTop + this.yPosition - v1 * totalHeight * this.scale,(float)this.id); if (this.imageData != null && this.imageData.imageLoaded()) {
GL11.glScalef(this.scale,this.scale,1.0F); int totalWidth = this.imageData.getTotalWidth();
int totalHeight = this.imageData.getTotalHeight();
if (this.location != null) { float u1 = (float)textureX/(float)totalWidth;
mc.getTextureManager().bindTexture(this.location); float u2 = u1 + (float)width/(float)totalWidth;
float v1 = (float)textureY/(float)totalHeight;
float v2 = v1 + (float)height/(float)totalHeight;
if (this.enabled) {
if (this.field_146123_n) {
v1 = (float)(textureY + 2 * this.height)/(float)totalHeight;
} else {
v1 = (float)(textureY + this.height)/(float)totalHeight;
}
v2 = v1 + (float)height/(float)totalHeight;
}
GL11.glPushMatrix();
float red = (color >> 16 & 255) / 255f;
float green = (color >> 8 & 255) / 255f;
float blue = (color & 255) / 255f;
GL11.glColor4f(red,green,blue,this.alpha);
GL11.glTranslatef(GuiCustom.guiLeft + this.xPosition - u1 * totalWidth * this.scale, GuiCustom.guiTop + this.yPosition - v1 * totalHeight * this.scale,(float)this.id);
GL11.glScalef(this.scale,this.scale,1.0F);
this.imageData.bindTexture();
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
Tessellator tessellator = Tessellator.instance; Tessellator tessellator = Tessellator.instance;
tessellator.startDrawingQuads(); tessellator.startDrawingQuads();
@@ -163,7 +133,9 @@ public class CustomGuiButton extends GuiButton implements IClickListener {
tessellator.draw(); tessellator.draw();
GL11.glTranslated(0.0D, 0.0D, 0.1D); GL11.glTranslated(0.0D, 0.0D, 0.1D);
this.drawCenteredString(fontRenderer, this.label, this.width / 2, (this.height - 8) / 2, this.color); this.drawCenteredString(fontRenderer, this.label, this.width / 2, (this.height - 8) / 2, this.color);
} else { GL11.glPopMatrix();
} else {
GL11.glPushMatrix();
mc.getTextureManager().bindTexture(buttonTextures); mc.getTextureManager().bindTexture(buttonTextures);
int i = this.getHoverState(this.field_146123_n); int i = this.getHoverState(this.field_146123_n);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
@@ -179,9 +151,9 @@ public class CustomGuiButton extends GuiButton implements IClickListener {
j = 16777120; j = 16777120;
} }
GL11.glTranslated(0.0D, 0.0D, 0.1D); GL11.glTranslated(0.0D, 0.0D, 0.1D);
this.drawCenteredString(fontRenderer, this.displayString, this.width / 2, (this.height-8)/2, j); this.drawCenteredString(fontRenderer, this.displayString, this.width / 2, (this.height - 8) / 2, j);
} GL11.glPopMatrix();
GL11.glPopMatrix(); }
if (this.field_146123_n && this.hoverText != null && this.hoverText.length > 0) { if (this.field_146123_n && this.hoverText != null && this.hoverText.length > 0) {
this.parent.hoverText = this.hoverText; this.parent.hoverText = this.hoverText;
@@ -189,7 +161,7 @@ public class CustomGuiButton extends GuiButton implements IClickListener {
} }
public ICustomGuiComponent toComponent() { public ICustomGuiComponent toComponent() {
ScriptGuiButton component = new ScriptGuiButton(this.id, this.label, this.xPosition, this.yPosition, this.width, this.height, this.location.toString(), this.textureX, this.textureY); ScriptGuiButton component = new ScriptGuiButton(this.id, this.label, this.xPosition, this.yPosition, this.width, this.height, this.texture, this.textureX, this.textureY);
component.setHoverText(this.hoverText); component.setHoverText(this.hoverText);
component.setColor(this.color); component.setColor(this.color);
component.setAlpha(this.alpha); component.setAlpha(this.alpha);
@@ -204,40 +176,4 @@ public class CustomGuiButton extends GuiButton implements IClickListener {
return false; return false;
} }
} }
public void getWidthHeight() throws IOException {
InputStream inputstream = null;
try {
IResource iresource = Minecraft.getMinecraft().getResourceManager().getResource(this.location);
inputstream = iresource.getInputStream();
BufferedImage bufferedimage = ImageIO.read(inputstream);
gotWidthHeight = true;
this.totalWidth = bufferedimage.getWidth();
this.totalHeight = bufferedimage.getHeight();
correctWidthHeight();
} catch (Exception e) {
e.printStackTrace();
} finally {
if (inputstream != null) {
inputstream.close();
}
}
}
public void getURLWidthHeight(){
if(imageDownloadAlt.getBufferedImage() != null) {
gotWidthHeight = true;
this.totalWidth = imageDownloadAlt.getBufferedImage().getWidth();
this.totalHeight = imageDownloadAlt.getBufferedImage().getHeight();
correctWidthHeight();
}
}
public void correctWidthHeight(){
totalWidth = Math.max(totalWidth, 1);
totalHeight = Math.max(totalHeight, 1);
this.width = width < 0 ? totalWidth : width;
this.height = height < 0 ? totalHeight : height;
}
} }
@@ -8,25 +8,19 @@ package noppes.npcs.client.gui.custom.components;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.Gui;
import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.client.resources.IResource;
import net.minecraft.util.ResourceLocation;
import noppes.npcs.api.gui.ICustomGuiComponent; import noppes.npcs.api.gui.ICustomGuiComponent;
import noppes.npcs.client.ImageDownloadAlt; import noppes.npcs.client.Client;
import noppes.npcs.client.gui.custom.GuiCustom; import noppes.npcs.client.gui.custom.GuiCustom;
import noppes.npcs.client.gui.custom.interfaces.IGuiComponent; import noppes.npcs.client.gui.custom.interfaces.IGuiComponent;
import noppes.npcs.client.renderer.ImageBufferDownloadAlt; import noppes.npcs.client.renderer.customitem.ImageData;
import noppes.npcs.scripted.gui.ScriptGuiTexturedRect; import noppes.npcs.scripted.gui.ScriptGuiTexturedRect;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.InputStream;
public class CustomGuiTexturedRect extends Gui implements IGuiComponent { public class CustomGuiTexturedRect extends Gui implements IGuiComponent {
GuiCustom parent; GuiCustom parent;
ResourceLocation location;
ImageData imageData = null;
String texture;
int id; int id;
int x; int x;
int y; int y;
@@ -41,11 +35,6 @@ public class CustomGuiTexturedRect extends Gui implements IGuiComponent {
float alpha; float alpha;
float rotation; float rotation;
private int totalWidth, totalHeight;
private ImageDownloadAlt imageDownloadAlt = null;
private boolean isUrl = false;
private boolean gotWidthHeight = false;
public CustomGuiTexturedRect(int id, String texture, int x, int y, int width, int height) { public CustomGuiTexturedRect(int id, String texture, int x, int y, int width, int height) {
this(id, texture, x, y, width, height, 0, 0); this(id, texture, x, y, width, height, 0, 0);
} }
@@ -53,25 +42,15 @@ public class CustomGuiTexturedRect extends Gui implements IGuiComponent {
public CustomGuiTexturedRect(int id, String directory, int x, int y, int width, int height, int textureX, int textureY) { public CustomGuiTexturedRect(int id, String directory, int x, int y, int width, int height, int textureX, int textureY) {
this.scale = 1.0F; this.scale = 1.0F;
this.id = id; this.id = id;
this.location = new ResourceLocation(directory); this.texture = directory;
this.x = x; this.x = x;
this.y = y; this.y = y;
this.width = width; this.width = width;
this.height = height; this.height = height;
this.textureX = textureX; this.textureX = textureX;
this.textureY = textureY; this.textureY = textureY;
if (texture != null && !texture.isEmpty()) {
if(directory.startsWith("https://")){ this.imageData = Client.getImageData(texture);
this.isUrl = true;
TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager();
this.imageDownloadAlt = new ImageDownloadAlt(null, directory, new ResourceLocation("customnpcs:textures/gui/invisible.png"), new ImageBufferDownloadAlt(true,false));
texturemanager.loadTexture(this.location, this.imageDownloadAlt);
} else {
try {
this.getWidthHeight();
} catch (IOException e) {
e.printStackTrace();
}
} }
} }
@@ -85,37 +64,38 @@ public class CustomGuiTexturedRect extends Gui implements IGuiComponent {
public void onRender(Minecraft mc, int mouseX, int mouseY, int mouseWheel, float partialTicks) { public void onRender(Minecraft mc, int mouseX, int mouseY, int mouseWheel, float partialTicks) {
boolean hovered = mouseX >= this.x + GuiCustom.guiLeft && mouseY >= this.y + GuiCustom.guiTop && mouseX < this.x + GuiCustom.guiLeft + this.width && mouseY < this.y + GuiCustom.guiTop + this.height; boolean hovered = mouseX >= this.x + GuiCustom.guiLeft && mouseY >= this.y + GuiCustom.guiTop && mouseX < this.x + GuiCustom.guiLeft + this.width && mouseY < this.y + GuiCustom.guiTop + this.height;
mc.getTextureManager().bindTexture(this.location);
float u1 = (float)textureX/(float)totalWidth; if (this.imageData != null && this.imageData.imageLoaded()) {
float u2 = u1 + (float)width/(float)totalWidth; int totalWidth = this.imageData.getTotalWidth();
float v1 = (float)textureY/(float)totalHeight; int totalHeight = this.imageData.getTotalHeight();
float v2 = v1 + (float)height/(float)totalHeight;
if(imageDownloadAlt != null && isUrl && !gotWidthHeight){ float u1 = (float) textureX / (float) totalWidth;
getURLWidthHeight(); float u2 = u1 + (float) width / (float) totalWidth;
} float v1 = (float) textureY / (float) totalHeight;
float v2 = v1 + (float) height / (float) totalHeight;
GL11.glPushMatrix(); GL11.glPushMatrix();
float red = (color >> 16 & 255) / 255f; float red = (color >> 16 & 255) / 255f;
float green = (color >> 8 & 255) / 255f; float green = (color >> 8 & 255) / 255f;
float blue = (color & 255) / 255f; float blue = (color & 255) / 255f;
GL11.glColor4f(red,green,blue,this.alpha); GL11.glColor4f(red, green, blue, this.alpha);
GL11.glTranslatef(GuiCustom.guiLeft + this.x - u1 * totalWidth, GuiCustom.guiTop + this.y - v1 * totalHeight,(float)this.id); GL11.glTranslatef(GuiCustom.guiLeft + this.x - u1 * totalWidth, GuiCustom.guiTop + this.y - v1 * totalHeight, (float) this.id);
GL11.glRotatef(this.rotation,0.0F,0.0F,1.0F); GL11.glRotatef(this.rotation, 0.0F, 0.0F, 1.0F);
GL11.glScalef(this.scale, this.scale, this.scale); GL11.glScalef(this.scale, this.scale, this.scale);
this.imageData.bindTexture();
Tessellator tessellator = Tessellator.instance; Tessellator tessellator = Tessellator.instance;
tessellator.startDrawingQuads(); tessellator.startDrawingQuads();
tessellator.setColorOpaque_F(1, 1, 1); tessellator.setColorOpaque_F(1, 1, 1);
tessellator.setColorRGBA_F(red, green, blue, alpha); tessellator.setColorRGBA_F(red, green, blue, alpha);
tessellator.addVertexWithUV( u2 * totalWidth, v2 * totalHeight, 0, u2, v2); tessellator.addVertexWithUV(u2 * totalWidth, v2 * totalHeight, 0, u2, v2);
tessellator.addVertexWithUV( u2 * totalWidth, v1 * totalHeight, 0, u2, v1); tessellator.addVertexWithUV(u2 * totalWidth, v1 * totalHeight, 0, u2, v1);
tessellator.addVertexWithUV( u1 * totalWidth, v1 * totalHeight, 0, u1, v1); tessellator.addVertexWithUV(u1 * totalWidth, v1 * totalHeight, 0, u1, v1);
tessellator.addVertexWithUV( u1 * totalWidth, v2 * totalHeight, 0, u1, v2); tessellator.addVertexWithUV(u1 * totalWidth, v2 * totalHeight, 0, u1, v2);
tessellator.draw(); tessellator.draw();
GL11.glPopMatrix(); GL11.glPopMatrix();
}
if (hovered && this.hoverText != null && this.hoverText.length > 0) { if (hovered && this.hoverText != null && this.hoverText.length > 0) {
this.parent.hoverText = this.hoverText; this.parent.hoverText = this.hoverText;
@@ -123,7 +103,7 @@ public class CustomGuiTexturedRect extends Gui implements IGuiComponent {
} }
public ICustomGuiComponent toComponent() { public ICustomGuiComponent toComponent() {
ScriptGuiTexturedRect component = new ScriptGuiTexturedRect(this.id, this.location.toString(), this.x, this.y, this.width, this.height, this.textureX, this.textureY); ScriptGuiTexturedRect component = new ScriptGuiTexturedRect(this.id, this.texture, this.x, this.y, this.width, this.height, this.textureX, this.textureY);
component.setHoverText(this.hoverText); component.setHoverText(this.hoverText);
component.setScale(this.scale); component.setScale(this.scale);
component.setColor(color); component.setColor(color);
@@ -151,40 +131,4 @@ public class CustomGuiTexturedRect extends Gui implements IGuiComponent {
return rect; return rect;
} }
public void getWidthHeight() throws IOException {
InputStream inputstream = null;
try {
IResource iresource = Minecraft.getMinecraft().getResourceManager().getResource(this.location);
inputstream = iresource.getInputStream();
BufferedImage bufferedimage = ImageIO.read(inputstream);
gotWidthHeight = true;
this.totalWidth = bufferedimage.getWidth();
this.totalHeight = bufferedimage.getHeight();
correctWidthHeight();
} catch (Exception e) {
e.printStackTrace();
} finally {
if (inputstream != null) {
inputstream.close();
}
}
}
public void getURLWidthHeight(){
if(imageDownloadAlt.getBufferedImage() != null) {
gotWidthHeight = true;
this.totalWidth = imageDownloadAlt.getBufferedImage().getWidth();
this.totalHeight = imageDownloadAlt.getBufferedImage().getHeight();
correctWidthHeight();
}
}
public void correctWidthHeight(){
totalWidth = Math.max(totalWidth, 1);
totalHeight = Math.max(totalHeight, 1);
this.width = width < 0 ? totalWidth : width;
this.height = height < 0 ? totalHeight : height;
}
} }
@@ -10,7 +10,9 @@ import noppes.npcs.containers.ContainerManageBanks;
import noppes.npcs.controllers.data.Bank; import noppes.npcs.controllers.data.Bank;
import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.entity.EntityNPCInterface;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Vector; import java.util.Vector;
public class GuiNPCManageBanks extends GuiContainerNPCInterface2 implements IScrollData,ICustomScrollListener,ITextfieldListener, IGuiData public class GuiNPCManageBanks extends GuiContainerNPCInterface2 implements IScrollData,ICustomScrollListener,ITextfieldListener, IGuiData
@@ -20,6 +22,7 @@ public class GuiNPCManageBanks extends GuiContainerNPCInterface2 implements IScr
private ContainerManageBanks container; private ContainerManageBanks container;
private Bank bank = new Bank(); private Bank bank = new Bank();
private String selected = null; private String selected = null;
private String search = "";
public GuiNPCManageBanks(EntityNPCInterface npc,ContainerManageBanks container) public GuiNPCManageBanks(EntityNPCInterface npc,ContainerManageBanks container)
{ {
@@ -61,6 +64,8 @@ public class GuiNPCManageBanks extends GuiContainerNPCInterface2 implements IScr
addTextField(new GuiNpcTextField(2,this, this.fontRendererObj, guiLeft+10, guiTop + 110, 16, 16, "")); addTextField(new GuiNpcTextField(2,this, this.fontRendererObj, guiLeft+10, guiTop + 110, 16, 16, ""));
getTextField(2).integersOnly = true; getTextField(2).integersOnly = true;
getTextField(2).setMaxStringLength(1); getTextField(2).setMaxStringLength(1);
addTextField(new GuiNpcTextField(33, this, fontRendererObj, guiLeft + 174, guiTop + 8 + 3 + 180, 160, 20, search));
} }
public void drawScreen(int x, int y, float f) public void drawScreen(int x, int y, float f)
@@ -137,12 +142,37 @@ public class GuiNPCManageBanks extends GuiContainerNPCInterface2 implements IScr
} }
setSelected(bank.name); setSelected(bank.name);
} }
public void keyTyped(char c, int i)
{
super.keyTyped(c, i);
if(getTextField(33) != null){
if(getTextField(33).isFocused()){
if(search.equals(getTextField(33).getText()))
return;
search = getTextField(33).getText().toLowerCase();
scroll.setList(getSearchList());
}
}
}
private List<String> getSearchList(){
if(search.isEmpty()){
return new ArrayList<String>(this.data.keySet());
}
List<String> list = new ArrayList<String>();
for(String name : this.data.keySet()){
if(name.toLowerCase().contains(search))
list.add(name);
}
return list;
}
@Override @Override
public void setData(Vector<String> list, HashMap<String, Integer> data) { public void setData(Vector<String> list, HashMap<String, Integer> data) {
String name = scroll.getSelected(); String name = scroll.getSelected();
this.data = data; this.data = data;
scroll.setList(list); scroll.setList(getSearchList());
if(name != null) if(name != null)
scroll.setSelected(name); scroll.setSelected(name);
@@ -29,6 +29,7 @@ public class GuiScriptItem extends GuiScriptInterface {
public void setGuiData(NBTTagCompound compound) { public void setGuiData(NBTTagCompound compound) {
this.item.setMCNbt(compound); this.item.setMCNbt(compound);
this.item.loadScriptData();
super.setGuiData(compound); super.setGuiData(compound);
} }
@@ -56,7 +56,7 @@ public class GuiCustomScrollCloner extends GuiCustomScroll {
} }
if((this.parent.getShowingClones() == 0 || this.parent.getShowingClones() == 2) && this.parent.tagMap != null){ if((this.parent.getShowingClones() == 0 || this.parent.getShowingClones() == 2) && this.parent.tagMap != null){
int tagStartX = j + fontRendererObj.getStringWidth(displayString) + 5; int tagStartX = j + fontRendererObj.getStringWidth(displayString) + 3;
if(GuiNpcMobSpawner.displayTags == 0 || GuiNpcMobSpawner.displayTags == 1){ if(GuiNpcMobSpawner.displayTags == 0 || GuiNpcMobSpawner.displayTags == 1){
if (this.parent.tagMap.hasClone(list.get(i))) { if (this.parent.tagMap.hasClone(list.get(i))) {
for (UUID tagUUID : this.parent.tagMap.getUUIDsList(list.get(i))){ for (UUID tagUUID : this.parent.tagMap.getUUIDsList(list.get(i))){
@@ -64,7 +64,7 @@ public class GuiCustomScrollCloner extends GuiCustomScroll {
if(tag != null){ if(tag != null){
if(GuiNpcMobSpawner.displayTags == 1 || !tag.getIsHidden()){ if(GuiNpcMobSpawner.displayTags == 1 || !tag.getIsHidden()){
fontRendererObj.drawString("[" + tag.name + "]", tagStartX, k, tag.color); fontRendererObj.drawString("[" + tag.name + "]", tagStartX, k, tag.color);
tagStartX += fontRendererObj.getStringWidth("[" + tag.name + "]") + 2; tagStartX += fontRendererObj.getStringWidth("[" + tag.name + "]") + 3;
} }
} }
} }
@@ -49,15 +49,10 @@ public class CustomItemRenderer implements IItemRenderer {
public void renderItem(ItemRenderType type, ItemStack itemStack, Object... data) { public void renderItem(ItemRenderType type, ItemStack itemStack, Object... data) {
ScriptCustomItem scriptCustomItem = ItemScripted.GetWrapper(itemStack); ScriptCustomItem scriptCustomItem = ItemScripted.GetWrapper(itemStack);
BufferedImage bufferedImage = Client.getImageData(scriptCustomItem.texture).getBufferedImage(); ImageData imageData = Client.getImageData(scriptCustomItem.texture);
if (bufferedImage != null && (scriptCustomItem.width != bufferedImage.getWidth() || scriptCustomItem.height != bufferedImage.getHeight())) { if (!imageData.imageLoaded()) {
scriptCustomItem.width = bufferedImage.getWidth();
scriptCustomItem.height = bufferedImage.getHeight();
scriptCustomItem.saveItemData();
}
if(scriptCustomItem.width < 1 || scriptCustomItem.height < 1)
return; return;
}
if (type == ItemRenderType.INVENTORY) { if (type == ItemRenderType.INVENTORY) {
GL11.glPushMatrix(); GL11.glPushMatrix();
@@ -80,7 +75,6 @@ public class CustomItemRenderer implements IItemRenderer {
GL11.glRotatef(scriptCustomItem.rotationYRate * entityRenderTicks%360, 0, 1, 0); GL11.glRotatef(scriptCustomItem.rotationYRate * entityRenderTicks%360, 0, 1, 0);
GL11.glRotatef(scriptCustomItem.rotationZRate * entityRenderTicks%360, 0, 0, 1); GL11.glRotatef(scriptCustomItem.rotationZRate * entityRenderTicks%360, 0, 0, 1);
GL11.glScalef(scriptCustomItem.scaleX, scriptCustomItem.scaleY, scriptCustomItem.scaleZ);
GL11.glTranslatef(0.0F, bobbingY, 0.0F); GL11.glTranslatef(0.0F, bobbingY, 0.0F);
int color = scriptCustomItem.getColor(); int color = scriptCustomItem.getColor();
@@ -184,6 +178,7 @@ public class CustomItemRenderer implements IItemRenderer {
b0 = 4; b0 = 4;
} }
GL11.glScalef(scriptCustomItem.scaleX, scriptCustomItem.scaleY, scriptCustomItem.scaleZ);
GL11.glTranslatef(-f7, -f8, -((f9 + f10) * (float)b0 / 2.0F)); GL11.glTranslatef(-f7, -f8, -((f9 + f10) * (float)b0 / 2.0F));
for (int k = 0; k < b0; ++k) for (int k = 0; k < b0; ++k)
@@ -253,6 +248,7 @@ public class CustomItemRenderer implements IItemRenderer {
for (int l = 0; l < b0; ++l) for (int l = 0; l < b0; ++l)
{ {
GL11.glPushMatrix(); GL11.glPushMatrix();
GL11.glScalef(scriptCustomItem.scaleX, scriptCustomItem.scaleY, scriptCustomItem.scaleZ);
if (l > 0) if (l > 0)
{ {
@@ -13,12 +13,13 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
public class ImageData { public class ImageData {
private ResourceLocation location; private final ResourceLocation location;
private final boolean isUrl; private final boolean isUrl;
private ImageDownloadAlt imageDownloadAlt = null; private ImageDownloadAlt imageDownloadAlt = null;
private BufferedImage bufferedImage = null; private BufferedImage bufferedImage = null;
private int totalWidth, totalHeight;
private int totalWidth, totalHeight;
private boolean gotWidthHeight; private boolean gotWidthHeight;
private boolean invalid; private boolean invalid;
@@ -28,14 +29,23 @@ public class ImageData {
this.isUrl = true; this.isUrl = true;
TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager(); TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager();
this.imageDownloadAlt = new ImageDownloadAlt(null, directory, new ResourceLocation("customnpcs:textures/gui/invisible.png"), new ImageBufferDownloadAlt(true, false)); this.imageDownloadAlt = new ImageDownloadAlt(null, directory, new ResourceLocation("customnpcs:textures/gui/invisible.png"), new ImageBufferDownloadAlt(true, false));
texturemanager.loadTexture(location, this.imageDownloadAlt); texturemanager.loadTexture(this.location, this.imageDownloadAlt);
} else { } else {
this.isUrl = false; this.isUrl = false;
} }
} }
public boolean invalidTexture() { public boolean imageLoaded() {
return this.invalid; if (!this.gotWidthHeight) {
try {
if (!this.isUrl) {
this.getWidthHeight();
} else {
this.getURLWidthHeight();
}
} catch (Exception ignored) {}
}
return !this.invalid && this.location != null && this.gotWidthHeight;
} }
public void bindTexture() { public void bindTexture() {
@@ -49,7 +59,7 @@ public class ImageData {
} }
} }
public ResourceLocation getLocation() { private ResourceLocation getLocation() {
return this.isUrl && this.imageDownloadAlt.getBufferedImage() == null ? null : this.location; return this.isUrl && this.imageDownloadAlt.getBufferedImage() == null ? null : this.location;
} }
@@ -69,6 +79,10 @@ public class ImageData {
} }
private void getWidthHeight() throws IOException { private void getWidthHeight() throws IOException {
if (this.invalid) {
return;
}
InputStream inputstream = null; InputStream inputstream = null;
try { try {
@@ -80,7 +94,7 @@ public class ImageData {
this.totalHeight = bufferedimage.getHeight(); this.totalHeight = bufferedimage.getHeight();
correctWidthHeight(); correctWidthHeight();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); this.invalid = true;
} finally { } finally {
if (inputstream != null) { if (inputstream != null) {
inputstream.close(); inputstream.close();
@@ -89,7 +103,7 @@ public class ImageData {
} }
private void getURLWidthHeight(){ private void getURLWidthHeight(){
if(this.imageDownloadAlt.getBufferedImage() != null) { if(this.imageDownloadAlt.getBufferedImage() != null && !this.invalid) {
this.gotWidthHeight = true; this.gotWidthHeight = true;
this.totalWidth = this.imageDownloadAlt.getBufferedImage().getWidth(); this.totalWidth = this.imageDownloadAlt.getBufferedImage().getWidth();
this.totalHeight = this.imageDownloadAlt.getBufferedImage().getHeight(); this.totalHeight = this.imageDownloadAlt.getBufferedImage().getHeight();
@@ -103,34 +117,10 @@ public class ImageData {
} }
public int getTotalWidth() { public int getTotalWidth() {
if (!this.gotWidthHeight) { return this.gotWidthHeight ? this.totalWidth : -1;
try {
if (!this.isUrl) {
this.getWidthHeight();
} else {
this.getURLWidthHeight();
}
} catch (Exception ignored) {}
if (!this.gotWidthHeight) {
return -1;
}
}
return this.totalWidth;
} }
public int getTotalHeight() { public int getTotalHeight() {
if (!this.gotWidthHeight) { return this.gotWidthHeight ? this.totalHeight : -1;
try {
if (!this.isUrl) {
this.getWidthHeight();
} else {
this.getURLWidthHeight();
}
} catch (Exception ignored) {}
if (!this.gotWidthHeight) {
return -1;
}
}
return this.totalHeight;
} }
} }
@@ -47,6 +47,5 @@ public enum EnumPacketClient {
STOP_SOUND_FOR, STOP_SOUND_FOR,
PAUSE_SOUNDS, PAUSE_SOUNDS,
CONTINUE_SOUNDS, CONTINUE_SOUNDS,
STOP_SOUNDS, STOP_SOUNDS
SYNC_ADD, SYNC_END, SYNC_UPDATE, SYNC_REMOVE,
} }
@@ -1,11 +0,0 @@
package noppes.npcs.constants;
public class SyncType {
public static final int FACTION = 1;
public static final int QUEST = 2;
public static final int QUEST_CATEGORY = 3;
public static final int DIALOG = 4;
public static final int DIALOG_CATEGORY = 5;
public static final int PLAYER_DATA = 8;
}
@@ -7,11 +7,9 @@ package noppes.npcs.containers;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container; import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory; import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot; import net.minecraft.inventory.Slot;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import noppes.npcs.EventHooks; import noppes.npcs.EventHooks;
import noppes.npcs.api.entity.IPlayer; import noppes.npcs.api.entity.IPlayer;
@@ -19,7 +17,6 @@ import noppes.npcs.api.gui.IItemSlot;
import noppes.npcs.client.gui.custom.components.CustomGuiSlot; import noppes.npcs.client.gui.custom.components.CustomGuiSlot;
import noppes.npcs.scripted.NpcAPI; import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.scripted.gui.ScriptGui; import noppes.npcs.scripted.gui.ScriptGui;
import noppes.npcs.util.CustomNPCsScheduler;
import java.util.Iterator; import java.util.Iterator;
@@ -111,6 +108,11 @@ public class ContainerCustomGui extends Container {
public ItemStack slotClick(int slotId, int dragType, int clickTypeIn, EntityPlayer player) { public ItemStack slotClick(int slotId, int dragType, int clickTypeIn, EntityPlayer player) {
if(slotId < 0) if(slotId < 0)
return super.slotClick(slotId, dragType, clickTypeIn, player); return super.slotClick(slotId, dragType, clickTypeIn, player);
if (slotId >= this.inventorySlots.size()) {
return null;
}
Slot mcSlot = (Slot)this.inventorySlots.get(slotId); Slot mcSlot = (Slot)this.inventorySlots.get(slotId);
if(!player.worldObj.isRemote && mcSlot != null) { if(!player.worldObj.isRemote && mcSlot != null) {
IItemSlot slot = null; IItemSlot slot = null;
@@ -135,7 +137,7 @@ public class ContainerCustomGui extends Container {
} }
EntityPlayerMP p = (EntityPlayerMP) player; EntityPlayerMP p = (EntityPlayerMP) player;
CustomNPCsScheduler.runTack(() -> {p.sendContainerToPlayer(this);}, 10); p.sendContainerToPlayer(this);
return item; return item;
} }
} }
@@ -6,13 +6,10 @@ import net.minecraft.nbt.NBTTagList;
import noppes.npcs.CustomNpcs; import noppes.npcs.CustomNpcs;
import noppes.npcs.LogWriter; import noppes.npcs.LogWriter;
import noppes.npcs.NoppesStringUtils; import noppes.npcs.NoppesStringUtils;
import noppes.npcs.Server;
import noppes.npcs.api.handler.IDialogHandler; import noppes.npcs.api.handler.IDialogHandler;
import noppes.npcs.api.handler.data.IDialog; import noppes.npcs.api.handler.data.IDialog;
import noppes.npcs.api.handler.data.IDialogCategory; import noppes.npcs.api.handler.data.IDialogCategory;
import noppes.npcs.constants.EnumOptionType; import noppes.npcs.constants.EnumOptionType;
import noppes.npcs.constants.EnumPacketClient;
import noppes.npcs.constants.SyncType;
import noppes.npcs.controllers.data.Dialog; import noppes.npcs.controllers.data.Dialog;
import noppes.npcs.controllers.data.DialogCategory; import noppes.npcs.controllers.data.DialogCategory;
import noppes.npcs.controllers.data.DialogOption; import noppes.npcs.controllers.data.DialogOption;
@@ -24,7 +21,6 @@ import java.util.*;
public class DialogController implements IDialogHandler { public class DialogController implements IDialogHandler {
public HashMap<Integer,DialogCategory> categories = new HashMap<Integer, DialogCategory>(); public HashMap<Integer,DialogCategory> categories = new HashMap<Integer, DialogCategory>();
public HashMap<Integer,DialogCategory> categoriesSync = new HashMap<Integer, DialogCategory>();
public HashMap<Integer,Dialog> dialogs = new HashMap<Integer, Dialog>(); public HashMap<Integer,Dialog> dialogs = new HashMap<Integer, Dialog>();
public static DialogController instance; public static DialogController instance;
@@ -231,7 +227,6 @@ public class DialogController implements IDialogHandler {
dir.mkdirs(); dir.mkdirs();
} }
categories.put(category.id, category); categories.put(category.id, category);
Server.sendToAll(EnumPacketClient.SYNC_UPDATE, SyncType.DIALOG_CATEGORY, category.writeNBT(new NBTTagCompound()));
} }
public void removeCategory(int category){ public void removeCategory(int category){
@@ -244,7 +239,6 @@ public class DialogController implements IDialogHandler {
for(int dia : cat.dialogs.keySet()) for(int dia : cat.dialogs.keySet())
dialogs.remove(dia); dialogs.remove(dia);
categories.remove(category); categories.remove(category);
Server.sendToAll(EnumPacketClient.SYNC_REMOVE, SyncType.DIALOG_CATEGORY, category);
} }
private boolean containsCategoryName(String name) { private boolean containsCategoryName(String name) {
@@ -287,12 +281,10 @@ public class DialogController implements IDialogHandler {
File file2 = new File(dir, dialog.id + ".json"); File file2 = new File(dir, dialog.id + ".json");
try { try {
NBTTagCompound compound = dialog.writeToNBT(new NBTTagCompound()); NBTJsonUtil.SaveFile(file, dialog.writeToNBTPartial(new NBTTagCompound()));
NBTJsonUtil.SaveFile(file, compound);
if(file2.exists()) if(file2.exists())
file2.delete(); file2.delete();
file.renameTo(file2); file.renameTo(file2);
Server.sendToAll(EnumPacketClient.SYNC_UPDATE, SyncType.DIALOG, compound, category.id);
} catch (Exception e) { } catch (Exception e) {
LogWriter.except(e); LogWriter.except(e);
} }
@@ -306,7 +298,7 @@ public class DialogController implements IDialogHandler {
return; return;
category.dialogs.remove(dialog.id); category.dialogs.remove(dialog.id);
dialogs.remove(dialog.id); dialogs.remove(dialog.id);
Server.sendToAll(EnumPacketClient.SYNC_REMOVE, SyncType.DIALOG, dialog.id);
} }
private File getDir(){ private File getDir(){
@@ -5,11 +5,8 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList; import net.minecraft.nbt.NBTTagList;
import noppes.npcs.CustomNpcs; import noppes.npcs.CustomNpcs;
import noppes.npcs.LogWriter; import noppes.npcs.LogWriter;
import noppes.npcs.Server;
import noppes.npcs.api.handler.IFactionHandler; import noppes.npcs.api.handler.IFactionHandler;
import noppes.npcs.api.handler.data.IFaction; import noppes.npcs.api.handler.data.IFaction;
import noppes.npcs.constants.EnumPacketClient;
import noppes.npcs.constants.SyncType;
import noppes.npcs.controllers.data.Faction; import noppes.npcs.controllers.data.Faction;
import java.io.*; import java.io.*;
@@ -21,7 +18,7 @@ import java.util.zip.GZIPInputStream;
public class FactionController implements IFactionHandler { public class FactionController implements IFactionHandler {
public HashMap<Integer,Faction> factions; public HashMap<Integer,Faction> factions;
public HashMap<Integer,Faction> factionsSync = new HashMap<Integer,Faction>();
private static FactionController instance; private static FactionController instance;
private int lastUsedID = 0; private int lastUsedID = 0;
@@ -154,9 +151,6 @@ public class FactionController implements IFactionHandler {
} }
factions.remove(faction.id); factions.remove(faction.id);
factions.put(faction.id, faction); factions.put(faction.id, faction);
NBTTagCompound nbtTagCompound = new NBTTagCompound();
faction.writeNBT(nbtTagCompound);
Server.sendToAll(EnumPacketClient.SYNC_UPDATE, SyncType.FACTION, nbtTagCompound);
saveFactions(); saveFactions();
} }
@@ -191,7 +185,6 @@ public class FactionController implements IFactionHandler {
} else { } else {
this.saveFactions(); this.saveFactions();
faction.id = -1; faction.id = -1;
Server.sendToAll(EnumPacketClient.SYNC_REMOVE, SyncType.FACTION, id);
return faction; return faction;
} }
} else { } else {
@@ -9,21 +9,19 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList; import net.minecraft.nbt.NBTTagList;
import net.minecraft.server.MinecraftServer; import net.minecraft.server.MinecraftServer;
import net.minecraft.util.ChatComponentText; import net.minecraft.util.ChatComponentText;
import net.minecraft.util.IChatComponent;
import noppes.npcs.CustomNpcs; import noppes.npcs.CustomNpcs;
import noppes.npcs.LogWriter; import noppes.npcs.LogWriter;
import noppes.npcs.controllers.data.*; import noppes.npcs.controllers.data.*;
import noppes.npcs.util.CustomNPCsScheduler;
import noppes.npcs.util.NBTJsonUtil; import noppes.npcs.util.NBTJsonUtil;
import org.lwjgl.Sys;
import java.io.*; import java.io.*;
import java.util.*; import java.util.*;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import java.util.zip.GZIPInputStream; import java.util.zip.GZIPInputStream;
import static noppes.npcs.util.CustomNPCsThreader.playerDataThread;
public class PlayerDataController { public class PlayerDataController {
public static PlayerDataController instance; public static PlayerDataController instance;
public HashMap<String, String> nameUUIDs; public HashMap<String, String> nameUUIDs;
@@ -169,7 +167,7 @@ public class PlayerDataController {
} }
public synchronized void savePlayerDataMap(){ public synchronized void savePlayerDataMap(){
CustomNPCsScheduler.runTack(() -> { playerDataThread.execute(() -> {
try { try {
File saveDir = getSaveDir(); File saveDir = getSaveDir();
File file = new File(saveDir, "___playermap.dat_new"); File file = new File(saveDir, "___playermap.dat_new");
@@ -273,7 +271,7 @@ public class PlayerDataController {
if(data == null){ if(data == null){
player.registerExtendedProperties("CustomNpcsData", data = new PlayerData()); player.registerExtendedProperties("CustomNpcsData", data = new PlayerData());
data.player = player; data.player = player;
data.loadPlayerDataFromFile(); data.load();
} }
data.player = player; data.player = player;
return data; return data;
@@ -311,7 +309,7 @@ public class PlayerDataController {
EntityPlayer player = MinecraftServer.getServer().getConfigurationManager().func_152612_a(username); EntityPlayer player = MinecraftServer.getServer().getConfigurationManager().func_152612_a(username);
PlayerData data = getDataFromUsername(username); PlayerData data = getDataFromUsername(username);
data.mailData.playermail.add(mail.copy()); data.mailData.playermail.add(mail.copy());
data.save(false); data.save();
} }
public List<PlayerData> getPlayersData(ICommandSender sender, String username){ public List<PlayerData> getPlayersData(ICommandSender sender, String username){
@@ -6,12 +6,9 @@ import net.minecraft.nbt.NBTTagList;
import noppes.npcs.CustomNpcs; import noppes.npcs.CustomNpcs;
import noppes.npcs.LogWriter; import noppes.npcs.LogWriter;
import noppes.npcs.NoppesStringUtils; import noppes.npcs.NoppesStringUtils;
import noppes.npcs.Server;
import noppes.npcs.api.handler.IQuestHandler; import noppes.npcs.api.handler.IQuestHandler;
import noppes.npcs.api.handler.data.IQuest; import noppes.npcs.api.handler.data.IQuest;
import noppes.npcs.api.handler.data.IQuestCategory; import noppes.npcs.api.handler.data.IQuestCategory;
import noppes.npcs.constants.EnumPacketClient;
import noppes.npcs.constants.SyncType;
import noppes.npcs.controllers.data.Quest; import noppes.npcs.controllers.data.Quest;
import noppes.npcs.controllers.data.QuestCategory; import noppes.npcs.controllers.data.QuestCategory;
import noppes.npcs.util.NBTJsonUtil; import noppes.npcs.util.NBTJsonUtil;
@@ -22,7 +19,6 @@ import java.util.*;
public class QuestController implements IQuestHandler { public class QuestController implements IQuestHandler {
public HashMap<Integer,QuestCategory> categories = new HashMap<Integer, QuestCategory>(); public HashMap<Integer,QuestCategory> categories = new HashMap<Integer, QuestCategory>();
public HashMap<Integer,QuestCategory> categoriesSync = new HashMap<Integer, QuestCategory>();
public HashMap<Integer,Quest> quests = new HashMap<Integer, Quest>(); public HashMap<Integer,Quest> quests = new HashMap<Integer, Quest>();
public static QuestController instance; public static QuestController instance;
@@ -146,7 +142,6 @@ public class QuestController implements IQuestHandler {
for(int dia : cat.quests.keySet()) for(int dia : cat.quests.keySet())
quests.remove(dia); quests.remove(dia);
categories.remove(category); categories.remove(category);
Server.sendToAll(EnumPacketClient.SYNC_REMOVE, SyncType.QUEST_CATEGORY, category);
} }
public void saveCategory(QuestCategory category){ public void saveCategory(QuestCategory category){
@@ -177,7 +172,6 @@ public class QuestController implements IQuestHandler {
dir.mkdirs(); dir.mkdirs();
} }
categories.put(category.id, category); categories.put(category.id, category);
Server.sendToAll(EnumPacketClient.SYNC_UPDATE, SyncType.QUEST_CATEGORY, category.writeNBT(new NBTTagCompound()));
} }
private boolean containsCategoryName(String name) { private boolean containsCategoryName(String name) {
name = name.toLowerCase(); name = name.toLowerCase();
@@ -225,7 +219,6 @@ public class QuestController implements IQuestHandler {
if(file2.exists()) if(file2.exists())
file2.delete(); file2.delete();
file.renameTo(file2); file.renameTo(file2);
Server.sendToAll(EnumPacketClient.SYNC_UPDATE, SyncType.QUEST, quest.writeToNBT(new NBTTagCompound()), category.id);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
@@ -237,7 +230,6 @@ public class QuestController implements IQuestHandler {
return; return;
quests.remove(quest.id); quests.remove(quest.id);
quest.category.quests.remove(quest.id); quest.category.quests.remove(quest.id);
Server.sendToAll(EnumPacketClient.SYNC_REMOVE, SyncType.QUEST, quest.id);
} }
private File getDir(){ private File getDir(){
@@ -33,7 +33,7 @@ public class ScriptContainer {
private String currentScriptLanguage = null; private String currentScriptLanguage = null;
public ScriptEngine engine = null; public ScriptEngine engine = null;
private IScriptHandler handler = null; private IScriptHandler handler = null;
private boolean init = false; private boolean evaluated = false;
private static Method luaCoerce; private static Method luaCoerce;
private static Method luaCall; private static Method luaCall;
private CompiledScript compScript = null; private CompiledScript compScript = null;
@@ -43,6 +43,7 @@ public class ScriptContainer {
} }
public void readFromNBT(NBTTagCompound compound) { public void readFromNBT(NBTTagCompound compound) {
String prevScript = this.script;
this.script = compound.getString("Script"); this.script = compound.getString("Script");
for (int i = 0; i < ConfigScript.ExpandedScriptLimit; i++) { for (int i = 0; i < ConfigScript.ExpandedScriptLimit; i++) {
if (compound.hasKey("ExpandedScript"+i)) { if (compound.hasKey("ExpandedScript"+i)) {
@@ -51,7 +52,11 @@ public class ScriptContainer {
break; break;
} }
} }
//this.type = compound.getString("Type");
if (!this.script.equals(prevScript)) {
this.evaluated = false;
}
this.console = NBTTags.GetLongStringMap(compound.getTagList("Console", 10)); this.console = NBTTags.GetLongStringMap(compound.getTagList("Console", 10));
this.scripts = NBTTags.getStringList(compound.getTagList("ScriptList", 10)); this.scripts = NBTTags.getStringList(compound.getTagList("ScriptList", 10));
this.lastCreated = 0L; this.lastCreated = 0L;
@@ -88,7 +93,7 @@ public class ScriptContainer {
} }
private String getFullCode() { private String getFullCode() {
if(!this.init) { if(!this.evaluated) {
this.fullscript = this.script; this.fullscript = this.script;
if(!this.fullscript.isEmpty()) { if(!this.fullscript.isEmpty()) {
this.fullscript = this.fullscript + "\n"; this.fullscript = this.fullscript + "\n";
@@ -145,12 +150,11 @@ public class ScriptContainer {
if(errored || !hasCode() || unknownFunctions.contains(type) || !ConfigScript.ScriptingEnabled) if(errored || !hasCode() || unknownFunctions.contains(type) || !ConfigScript.ScriptingEnabled)
return; return;
this.setEngine(handler.getLanguage());
if(engine == null) if(engine == null)
return; return;
if(ScriptController.Instance.lastLoaded > this.lastCreated){ if(ScriptController.Instance.lastLoaded > this.lastCreated){
this.lastCreated = ScriptController.Instance.lastLoaded; this.lastCreated = ScriptController.Instance.lastLoaded;
init = false; evaluated = false;
} }
synchronized (lock) { synchronized (lock) {
@@ -170,9 +174,9 @@ public class ScriptContainer {
} }
try { try {
if(!init){ if(!evaluated){
engine.eval(getFullCode()); engine.eval(getFullCode());
init = true; evaluated = true;
} }
if(engine.getFactory().getLanguageName().equals("lua")){ if(engine.getFactory().getLanguageName().equals("lua")){
Object ob = engine.get(type); Object ob = engine.get(type);
@@ -220,7 +224,7 @@ public class ScriptContainer {
} }
public boolean isValid() { public boolean isValid() {
return init && !errored; return evaluated && !errored;
} }
public boolean hasCode() { public boolean hasCode() {
@@ -233,9 +237,9 @@ public class ScriptContainer {
if (ConfigScript.ScriptingECMA6 && scriptLanguage.equals("ECMAScript")) { if (ConfigScript.ScriptingECMA6 && scriptLanguage.equals("ECMAScript")) {
System.setProperty("nashorn.args", "--language=es6"); System.setProperty("nashorn.args", "--language=es6");
} }
this.engine = new ScriptEngineManager().getEngineByName(scriptLanguage.toLowerCase()); this.engine = ScriptController.Instance.getEngineByName(scriptLanguage.toLowerCase());
currentScriptLanguage = scriptLanguage; currentScriptLanguage = scriptLanguage;
init = false; evaluated = false;
} }
} }
@@ -33,7 +33,7 @@ public class ScriptController {
public static ScriptController Instance; public static ScriptController Instance;
public static boolean HasStart = false; public static boolean HasStart = false;
private ScriptEngineManager manager; private final ScriptEngineManager manager;
public Map<String, String> languages = new HashMap<String, String>(); public Map<String, String> languages = new HashMap<String, String>();
public Map<String, String> scripts = new HashMap<String, String>(); public Map<String, String> scripts = new HashMap<String, String>();
public long lastLoaded = 0; public long lastLoaded = 0;
@@ -1,184 +0,0 @@
package noppes.npcs.controllers;
import net.minecraft.entity.player.EntityPlayer;
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.constants.EnumPacketClient;
import noppes.npcs.constants.SyncType;
import noppes.npcs.controllers.data.*;
import io.netty.buffer.ByteBuf;
import java.util.HashMap;
import java.util.List;
public class SyncController {
public static void syncPlayer(EntityPlayerMP player){
NBTTagList list = new NBTTagList();
NBTTagCompound compound = new NBTTagCompound();
for(Faction faction : FactionController.getInstance().factions.values()){
NBTTagCompound nbtTagCompound = new NBTTagCompound();
faction.writeNBT(nbtTagCompound);
list.appendTag(nbtTagCompound);
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());
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());
PlayerData data = PlayerDataController.instance.getPlayerData(player);
Server.sendData(player, EnumPacketClient.SYNC_END, SyncType.PLAYER_DATA, data.getNBT());
}
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());
}
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());
}
public static void clientSync(int synctype, NBTTagCompound compound, boolean syncEnd) {
if(synctype == SyncType.FACTION){
NBTTagList list = compound.getTagList("Data", 10);
for(int i = 0; i < list.tagCount(); i++)
{
Faction faction = new Faction();
faction.readNBT(list.getCompoundTagAt(i));
FactionController.getInstance().factionsSync.put(faction.id, faction);
}
if(syncEnd){
FactionController.getInstance().factions = FactionController.getInstance().factionsSync;
FactionController.getInstance().factionsSync = new HashMap<Integer, Faction>();
}
}
else if(synctype == SyncType.QUEST_CATEGORY){
if(!compound.hasNoTags()){
QuestCategory category = new QuestCategory();
category.readNBT(compound);
QuestController.instance.categoriesSync.put(category.id, category);
}
if(syncEnd){
HashMap<Integer,Quest> quests = new HashMap<Integer, Quest>();
for(QuestCategory category : QuestController.instance.categoriesSync.values()){
for(Quest quest : category.quests.values()){
quests.put(quest.id, quest);
}
}
QuestController.instance.categories = QuestController.instance.categoriesSync;
QuestController.instance.quests = quests;
QuestController.instance.categoriesSync = new HashMap<Integer, QuestCategory>();
}
}
else if(synctype == SyncType.DIALOG_CATEGORY){
if(!compound.hasNoTags()){
DialogCategory category = new DialogCategory();
category.readNBT(compound);
DialogController.instance.categoriesSync.put(category.id, category);
}
if(syncEnd){
HashMap<Integer,Dialog> dialogs = new HashMap<Integer, Dialog>();
for(DialogCategory category : DialogController.instance.categoriesSync.values()){
for(Dialog dialog : category.dialogs.values()){
dialogs.put(dialog.id, dialog);
}
}
DialogController.instance.categories = DialogController.instance.categoriesSync;
DialogController.instance.dialogs = dialogs;
DialogController.instance.categoriesSync = new HashMap<Integer, DialogCategory>();
}
}
}
public static void clientSyncUpdate(int synctype, NBTTagCompound compound, ByteBuf buffer) {
if(synctype == SyncType.FACTION){
Faction faction = new Faction();
faction.readNBT(compound);
FactionController.getInstance().factions.put(faction.id, faction);
}
else if(synctype == SyncType.DIALOG){
DialogCategory category = DialogController.instance.categories.get(buffer.readInt());
Dialog dialog = new Dialog();
dialog.category = category;
dialog.readNBT(compound);
DialogController.instance.dialogs.put(dialog.id, dialog);
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);
}
else if(synctype == SyncType.QUEST){
QuestCategory category = QuestController.instance.categories.get(buffer.readInt());
Quest quest = new Quest();
quest.category = category;
quest.readNBT(compound);
QuestController.instance.quests.put(quest.id, quest);
category.quests.put(quest.id, quest);
}
else if(synctype == SyncType.QUEST_CATEGORY){
QuestCategory category = new QuestCategory();
category.readNBT(compound);
QuestController.instance.categories.put(category.id, category);
}
}
public static void clientSyncRemove(int synctype, int id) {
if(synctype == SyncType.FACTION){
FactionController.getInstance().factions.remove(id);
}
else if(synctype == SyncType.DIALOG){
Dialog dialog = DialogController.instance.dialogs.remove(id);
if(dialog != null) {
dialog.category.dialogs.remove(id);
}
}
else if(synctype == SyncType.DIALOG_CATEGORY){
DialogCategory category = DialogController.instance.categories.remove(id);
if(category != null) {
DialogController.instance.dialogs.keySet().removeAll(category.dialogs.keySet());
}
}
else if(synctype == SyncType.QUEST){
Quest quest = QuestController.instance.quests.remove(id);
if(quest != null) {
quest.category.quests.remove(id);
}
}
else if(synctype == SyncType.QUEST_CATEGORY){
QuestCategory category = QuestController.instance.categories.remove(id);
if(category != null) {
QuestController.instance.quests.keySet().removeAll(category.quests.keySet());
}
}
}
}
@@ -15,7 +15,7 @@ import noppes.npcs.constants.EnumPacketClient;
import noppes.npcs.containers.ContainerNPCBankInterface; import noppes.npcs.containers.ContainerNPCBankInterface;
import noppes.npcs.controllers.BankController; import noppes.npcs.controllers.BankController;
import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.util.CustomNPCsScheduler; import noppes.npcs.util.CustomNPCsThreader;
import java.util.HashMap; import java.util.HashMap;
@@ -100,18 +100,16 @@ public class BankData {
NoppesUtilServer.sendOpenGui(player, EnumGuiType.PlayerBankSmall, npc, slot, bank.id, 0); NoppesUtilServer.sendOpenGui(player, EnumGuiType.PlayerBankSmall, npc, slot, bank.id, 0);
} }
final ItemStack item = currency; final ItemStack item = currency;
CustomNPCsScheduler.runTack(() -> { NBTTagCompound compound = new NBTTagCompound();
NBTTagCompound compound = new NBTTagCompound(); compound.setInteger("MaxSlots", bank.getMaxSlots());
compound.setInteger("MaxSlots", bank.getMaxSlots()); compound.setInteger("UnlockedSlots", unlockedSlots);
compound.setInteger("UnlockedSlots", unlockedSlots); if (item != null) {
if (item != null) { compound.setTag("Currency", NoppesUtilServer.writeItem(item, new NBTTagCompound()));
compound.setTag("Currency", NoppesUtilServer.writeItem(item, new NBTTagCompound())); ContainerNPCBankInterface container = getContainer(player);
ContainerNPCBankInterface container = getContainer(player); if (container != null)
if (container != null) container.setCurrency(item);
container.setCurrency(item); }
} Server.sendDataChecked((EntityPlayerMP) player, EnumPacketClient.GUI_DATA, compound);
Server.sendDataChecked((EntityPlayerMP) player, EnumPacketClient.GUI_DATA, compound);
}, 300);
} }
private ContainerNPCBankInterface getContainer(EntityPlayer player){ private ContainerNPCBankInterface getContainer(EntityPlayer player){
Container con = player.openContainer; Container con = player.openContainer;
@@ -72,11 +72,19 @@ public class DataScript implements IScriptHandler {
this.scriptLanguage = "ECMAScript"; this.scriptLanguage = "ECMAScript";
} }
} }
for (ScriptContainer container : this.scripts.values()) {
container.setEngine(this.getLanguage());
}
enabled = compound.getBoolean("ScriptEnabled"); enabled = compound.getBoolean("ScriptEnabled");
} }
public void readEventsFromNBT(NBTTagCompound compound) { public void readEventsFromNBT(NBTTagCompound compound) {
eventScripts = NBTTags.GetScript(compound,this); eventScripts = NBTTags.GetScript(compound,this);
for (ScriptContainer container : this.eventScripts) {
container.setEngine(this.getLanguage());
}
} }
public NBTTagCompound writeToNBT(NBTTagCompound compound) { public NBTTagCompound writeToNBT(NBTTagCompound compound) {
@@ -149,7 +157,6 @@ public class DataScript implements IScriptHandler {
ScriptContainer script = scripts.get(type); ScriptContainer script = scripts.get(type);
if(script == null || script.errored || !script.hasCode()) if(script == null || script.errored || !script.hasCode())
return false; return false;
script.setEngine(scriptLanguage);
if(script.engine == null) if(script.engine == null)
return false; return false;
for(int i = 0; i + 1 < obs.length; i += 2){ for(int i = 0; i + 1 < obs.length; i += 2){
@@ -173,7 +180,7 @@ public class DataScript implements IScriptHandler {
engine.put("npc", dummyNpc); engine.put("npc", dummyNpc);
engine.put("world", dummyWorld); engine.put("world", dummyWorld);
engine.put("event", event); engine.put("event", event);
engine.put("API", new NpcAPI()); engine.put("API", NpcAPI.Instance());
engine.put("EntityType", entities); engine.put("EntityType", entities);
engine.put("RoleType", roles); engine.put("RoleType", roles);
engine.put("JobType", jobs); engine.put("JobType", jobs);
@@ -5,6 +5,7 @@ import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.NBTTags; import noppes.npcs.NBTTags;
import noppes.npcs.api.entity.ICustomNpc; import noppes.npcs.api.entity.ICustomNpc;
import noppes.npcs.api.entity.IPlayer; import noppes.npcs.api.entity.IPlayer;
import noppes.npcs.api.handler.IPlayerFactionData;
import noppes.npcs.api.handler.data.IFaction; import noppes.npcs.api.handler.data.IFaction;
import noppes.npcs.controllers.FactionController; import noppes.npcs.controllers.FactionController;
import noppes.npcs.controllers.PlayerDataController; import noppes.npcs.controllers.PlayerDataController;
@@ -133,8 +134,8 @@ public class Faction implements IFaction {
} }
public int playerStatus(IPlayer player) { public int playerStatus(IPlayer player) {
PlayerFactionData data = PlayerDataController.instance.getPlayerData((EntityPlayer) player.getMCEntity()).factionData; IPlayerFactionData data = player.getData().getFactionData();
int points = data.getFactionPoints(this.id); int points = data.getPoints(this.id);
if (points >= this.friendlyPoints) { if (points >= this.friendlyPoints) {
return 1; return 1;
} else { } else {
@@ -46,6 +46,10 @@ public class ForgeDataScript implements IScriptHandler {
} }
} }
this.enabled = compound.getBoolean("ScriptEnabled"); this.enabled = compound.getBoolean("ScriptEnabled");
for (ScriptContainer container : this.scripts) {
container.setEngine(this.getLanguage());
}
} }
public NBTTagCompound writeToNBT(NBTTagCompound compound) { public NBTTagCompound writeToNBT(NBTTagCompound compound) {
@@ -49,6 +49,10 @@ public class GlobalNPCDataScript implements IScriptHandler {
} }
} }
this.enabled = compound.getBoolean("ScriptEnabled"); this.enabled = compound.getBoolean("ScriptEnabled");
for (ScriptContainer container : this.scripts) {
container.setEngine(this.getLanguage());
}
} }
public NBTTagCompound writeToNBT(NBTTagCompound compound) { public NBTTagCompound writeToNBT(NBTTagCompound compound) {
compound.setInteger("TotalScripts",this.scripts.size()); compound.setInteger("TotalScripts",this.scripts.size());
@@ -2,7 +2,6 @@ package noppes.npcs.controllers.data;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.CompressedStreamTools;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.IExtendedEntityProperties; import net.minecraftforge.common.IExtendedEntityProperties;
@@ -19,11 +18,10 @@ import noppes.npcs.entity.data.DataSkinOverlays;
import noppes.npcs.entity.data.DataTimers; import noppes.npcs.entity.data.DataTimers;
import noppes.npcs.roles.RoleCompanion; import noppes.npcs.roles.RoleCompanion;
import noppes.npcs.scripted.NpcAPI; import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.util.CustomNPCsScheduler; import noppes.npcs.util.CustomNPCsThreader;
import noppes.npcs.util.NBTJsonUtil; import noppes.npcs.util.NBTJsonUtil;
import java.io.File; import java.io.File;
import java.io.FileInputStream;
public class PlayerData implements IExtendedEntityProperties, IPlayerData { public class PlayerData implements IExtendedEntityProperties, IPlayerData {
public PlayerDialogData dialogData = new PlayerDialogData(this); public PlayerDialogData dialogData = new PlayerDialogData(this);
@@ -50,33 +48,13 @@ public class PlayerData implements IExtendedEntityProperties, IPlayerData {
public int companionID = 0; public int companionID = 0;
public boolean isGUIOpen = false; public boolean isGUIOpen = false;
public boolean updateClient = false;
@Override @Override
public void saveNBTData(NBTTagCompound nbtTagCompound) { public void saveNBTData(NBTTagCompound nbtTagCompound) {
//Do Nothing
} }
@Override @Override
public void loadNBTData(NBTTagCompound compound) { public void loadNBTData(NBTTagCompound compound) {
//Do Nothing
}
public void loadPlayerDataFromFile() {
NBTTagCompound data = PlayerDataController.instance.loadPlayerData(player.getPersistentID().toString());
if(data.hasNoTags()){
data = PlayerDataController.instance.loadPlayerDataOld(player.getCommandSenderName());
}
setNBT(data);
}
public NBTTagCompound getSyncNBT(){
NBTTagCompound compound = new NBTTagCompound();
dialogData.saveNBTData(compound);
questData.saveNBTData(compound);
factionData.saveNBTData(compound);
return compound;
} }
public void setNBT(NBTTagCompound data){ public void setNBT(NBTTagCompound data){
@@ -148,13 +126,11 @@ public class PlayerData implements IExtendedEntityProperties, IPlayerData {
} }
public void setGUIOpen(boolean bool) { public void setGUIOpen(boolean bool) {
isGUIOpen = bool; this.isGUIOpen = bool;
save(false);
} }
public boolean getGUIOpen() { public boolean getGUIOpen() {
loadPlayerDataFromFile(); return this.isGUIOpen;
return isGUIOpen;
} }
public boolean hasCompanion(){ public boolean hasCompanion(){
@@ -168,7 +144,7 @@ public class PlayerData implements IExtendedEntityProperties, IPlayerData {
activeCompanion = npc; activeCompanion = npc;
if(npc != null) if(npc != null)
((RoleCompanion)npc.roleInterface).companionID = companionID; ((RoleCompanion)npc.roleInterface).companionID = companionID;
save(false); save();
} }
public void updateCompanion(World world) { public void updateCompanion(World world) {
@@ -190,44 +166,6 @@ public class PlayerData implements IExtendedEntityProperties, IPlayerData {
world.spawnEntityInWorld(npc); world.spawnEntityInWorld(npc);
} }
public static NBTTagCompound loadPlayerDataOld(String player) {
File saveDir = CustomNpcs.getWorldSaveDirectory("playerdata");
String filename = player;
if (player.isEmpty()) {
filename = "noplayername";
}
filename = filename + ".dat";
File file;
try {
file = new File(saveDir, filename);
if (file.exists()) {
NBTTagCompound comp = CompressedStreamTools.readCompressed(new FileInputStream(file));
file.delete();
file = new File(saveDir, filename + "_old");
if (file.exists()) {
file.delete();
}
return comp;
}
} catch (Exception var6) {
LogWriter.except(var6);
}
try {
file = new File(saveDir, filename + "_old");
if (file.exists()) {
return CompressedStreamTools.readCompressed(new FileInputStream(file));
}
} catch (Exception var5) {
LogWriter.except(var5);
}
return new NBTTagCompound();
}
public static NBTTagCompound loadPlayerData(String player) { public static NBTTagCompound loadPlayerData(String player) {
File saveDir = CustomNpcs.getWorldSaveDirectory("playerdata"); File saveDir = CustomNpcs.getWorldSaveDirectory("playerdata");
String filename = player; String filename = player;
@@ -250,25 +188,6 @@ public class PlayerData implements IExtendedEntityProperties, IPlayerData {
return new NBTTagCompound(); return new NBTTagCompound();
} }
public static PlayerData get(EntityPlayer player) {
if(player.worldObj.isRemote) {
return CustomNpcs.proxy.getPlayerData(player);
} else {
PlayerData data = new PlayerData();
if (data.player == null) {
data.player = player;
NBTTagCompound compound = loadPlayerData(player.getPersistentID().toString());
if (compound.hasNoTags()) {
compound = loadPlayerDataOld(player.getCommandSenderName());
}
data.setNBT(compound);
}
return data;
}
}
public void setCompanion(ICustomNpc npc) { public void setCompanion(ICustomNpc npc) {
this.setCompanion((EntityNPCInterface) npc.getMCEntity()); this.setCompanion((EntityNPCInterface) npc.getMCEntity());
} }
@@ -309,11 +228,10 @@ public class PlayerData implements IExtendedEntityProperties, IPlayerData {
return mailData; return mailData;
} }
public synchronized void save(boolean update) { public synchronized void save() {
final NBTTagCompound compound = getNBT(); final NBTTagCompound compound = getNBT();
final String filename = uuid + ".json"; final String filename = uuid + ".json";
CustomNPCsThreader.playerDataThread.execute(() -> {
CustomNPCsScheduler.runTack(() -> {
try { try {
File saveDir = PlayerDataController.instance.getSaveDir(); File saveDir = PlayerDataController.instance.getSaveDir();
File file = new File(saveDir, filename + "_new"); File file = new File(saveDir, filename + "_new");
@@ -326,11 +244,15 @@ public class PlayerData implements IExtendedEntityProperties, IPlayerData {
} catch (Exception e) { } catch (Exception e) {
LogWriter.except(e); LogWriter.except(e);
} }
PlayerDataController.instance.putPlayerMap(playername, uuid);
}); });
PlayerDataController.instance.putPlayerMap(playername, uuid);
}
if(update) public void load() {
updateClient = true; NBTTagCompound data = PlayerDataController.instance.loadPlayerData(player.getPersistentID().toString());
if(data.hasNoTags()){
data = PlayerDataController.instance.loadPlayerDataOld(player.getCommandSenderName());
}
setNBT(data);
} }
} }
@@ -55,6 +55,10 @@ public class PlayerDataScript implements IScriptHandler {
} }
} }
this.enabled = compound.getBoolean("ScriptEnabled"); this.enabled = compound.getBoolean("ScriptEnabled");
for (ScriptContainer container : this.scripts) {
container.setEngine(this.getLanguage());
}
} }
public NBTTagCompound writeToNBT(NBTTagCompound compound) { public NBTTagCompound writeToNBT(NBTTagCompound compound) {
compound.setInteger("TotalScripts",this.scripts.size()); compound.setInteger("TotalScripts",this.scripts.size());
@@ -48,11 +48,9 @@ public class PlayerDialogData implements IPlayerDialogData {
public void readDialog(int id) { public void readDialog(int id) {
dialogsRead.add(id); dialogsRead.add(id);
parent.updateClient = true;
} }
public void unreadDialog(int id) { public void unreadDialog(int id) {
dialogsRead.remove(id); dialogsRead.remove(id);
parent.updateClient = true;
} }
} }
@@ -124,10 +124,6 @@ public class PlayerQuestData implements IPlayerQuestData {
QuestInterface inter = data.quest.questInterface; QuestInterface inter = data.quest.questInterface;
if(inter.isCompleted(playerData)){ if(inter.isCompleted(playerData)){
if((!data.isCompleted && data.quest.completion == EnumQuestCompletion.Npc) || data.quest.instantComplete(player,data)){ if((!data.isCompleted && data.quest.completion == EnumQuestCompletion.Npc) || data.quest.instantComplete(player,data)){
if (data.quest.completeText.isEmpty() && data.sendAlerts) {
Server.sendData((EntityPlayerMP)player, EnumPacketClient.MESSAGE, "quest.completed", data.quest.title);
Server.sendData((EntityPlayerMP)player, EnumPacketClient.CHAT, "quest.completed",": ",data.quest.title);
}
data.isCompleted = true; data.isCompleted = true;
if (data.quest.completion == EnumQuestCompletion.Npc) { if (data.quest.completion == EnumQuestCompletion.Npc) {
EventHooks.onQuestFinished(player, data.quest); EventHooks.onQuestFinished(player, data.quest);
@@ -175,7 +171,6 @@ public class PlayerQuestData implements IPlayerQuestData {
activeQuests.put(id, questdata); activeQuests.put(id, questdata);
Server.sendData((EntityPlayerMP)parent.player, EnumPacketClient.MESSAGE, "quest.newquest", quest.title); Server.sendData((EntityPlayerMP)parent.player, EnumPacketClient.MESSAGE, "quest.newquest", quest.title);
Server.sendData((EntityPlayerMP)parent.player, EnumPacketClient.CHAT, "quest.newquest", ": ", quest.title); Server.sendData((EntityPlayerMP)parent.player, EnumPacketClient.CHAT, "quest.newquest", ": ", quest.title);
parent.updateClient = true;
} }
public void finishQuest(int id) { public void finishQuest(int id) {
@@ -187,8 +182,6 @@ public class PlayerQuestData implements IPlayerQuestData {
finishedQuests.put(quest.id, System.currentTimeMillis()); finishedQuests.put(quest.id, System.currentTimeMillis());
else else
finishedQuests.put(quest.id, parent.player.worldObj.getTotalWorldTime()); finishedQuests.put(quest.id, parent.player.worldObj.getTotalWorldTime());
parent.updateClient = true;
} }
public void stopQuest(int id) { public void stopQuest(int id) {
@@ -196,7 +189,6 @@ public class PlayerQuestData implements IPlayerQuestData {
if (quest == null) if (quest == null)
return; return;
activeQuests.remove(id); activeQuests.remove(id);
parent.updateClient = true;
} }
public void removeQuest(int id) { public void removeQuest(int id) {
@@ -205,7 +197,6 @@ public class PlayerQuestData implements IPlayerQuestData {
return; return;
activeQuests.remove(id); activeQuests.remove(id);
finishedQuests.remove(id); finishedQuests.remove(id);
parent.updateClient = true;
} }
public boolean hasFinishedQuest(int id){ public boolean hasFinishedQuest(int id){
@@ -112,7 +112,7 @@ public abstract class MixinModelRenderer {
} }
if (ClientEventHandler.renderingPlayer != null && Client.playerAnimations.containsKey(ClientEventHandler.renderingPlayer.getUniqueID())) { if (ClientEventHandler.renderingPlayer != null && Client.playerAnimations.containsKey(ClientEventHandler.renderingPlayer.getUniqueID())) {
animData = Client.playerAnimations.get(ClientEventHandler.renderingPlayer.getUniqueID()); animData = Client.playerAnimations.get(ClientEventHandler.renderingPlayer.getUniqueID());
EnumAnimationPart mainPartType = null; EnumAnimationPart mainPartType = this.getPlayerPartType((ModelRenderer) (Object) this);
EnumAnimationPart pivotEqualPart = null; EnumAnimationPart pivotEqualPart = null;
if (mainPartType == null) { if (mainPartType == null) {
pivotEqualPart = this.pivotEqualPart((ModelRenderer) (Object) this); pivotEqualPart = this.pivotEqualPart((ModelRenderer) (Object) this);
@@ -99,15 +99,13 @@ public class QuestDialog extends QuestInterface implements IQuestDialog {
if (progress == 0 && completed) { if (progress == 0 && completed) {
data.dialogData.dialogsRead.remove(this.dialog.id); data.dialogData.dialogsRead.remove(this.dialog.id);
data.questData.checkQuestCompletion(data, EnumQuestType.values()[1]); data.questData.checkQuestCompletion(data, EnumQuestType.values()[1]);
data.updateClient = true; data.save();
data.save(true);
} }
if (progress == 1 && !completed) { if (progress == 1 && !completed) {
data.dialogData.dialogsRead.add(this.dialog.id); data.dialogData.dialogsRead.add(this.dialog.id);
data.questData.checkQuestCompletion(data, EnumQuestType.values()[1]); data.questData.checkQuestCompletion(data, EnumQuestType.values()[1]);
data.updateClient = true; data.save();
data.save(true);
} }
} else { } else {
@@ -146,8 +146,11 @@ public class QuestKill extends QuestInterface implements IQuestKill {
PlayerData data = PlayerDataController.instance.getPlayerData(player); PlayerData data = PlayerDataController.instance.getPlayerData(player);
PlayerQuestData playerdata = data.questData; PlayerQuestData playerdata = data.questData;
QuestData questdata = (QuestData)playerdata.activeQuests.get(this.parent.questId); QuestData questdata = (QuestData)playerdata.activeQuests.get(this.parent.questId);
HashMap<String, Integer> killed = this.parent.getKilled(questdata); if(questdata != null){
return !killed.containsKey(this.entity) ? 0 : (Integer)killed.get(this.entity); HashMap<String, Integer> killed = this.parent.getKilled(questdata);
return !killed.containsKey(this.entity) ? 0 : (Integer)killed.get(this.entity);
}
return 0;
} }
public void setProgress(int progress) { public void setProgress(int progress) {
@@ -155,13 +158,15 @@ public class QuestKill extends QuestInterface implements IQuestKill {
PlayerData data = PlayerDataController.instance.getPlayerData(player); PlayerData data = PlayerDataController.instance.getPlayerData(player);
PlayerQuestData playerdata = data.questData; PlayerQuestData playerdata = data.questData;
QuestData questdata = (QuestData)playerdata.activeQuests.get(this.parent.questId); QuestData questdata = (QuestData)playerdata.activeQuests.get(this.parent.questId);
HashMap<String, Integer> killed = this.parent.getKilled(questdata); if(questdata != null){
if (!killed.containsKey(this.entity) || (Integer)killed.get(this.entity) != progress) { HashMap<String, Integer> killed = this.parent.getKilled(questdata);
killed.put(this.entity, progress); if (!killed.containsKey(this.entity) || (Integer)killed.get(this.entity) != progress) {
this.parent.setKilled(questdata, killed); killed.put(this.entity, progress);
data.questData.checkQuestCompletion(data, EnumQuestType.values()[2]); this.parent.setKilled(questdata, killed);
data.questData.checkQuestCompletion(data, EnumQuestType.values()[4]); data.questData.checkQuestCompletion(data, EnumQuestType.values()[2]);
data.save(true); data.questData.checkQuestCompletion(data, EnumQuestType.values()[4]);
data.save();
}
} }
} else { } else {
throw new CustomNPCsException("Progress has to be between 0 and " + this.amount, new Object[0]); throw new CustomNPCsException("Progress has to be between 0 and " + this.amount, new Object[0]);
@@ -166,7 +166,7 @@ public class QuestLocation extends QuestInterface implements IQuestLocation {
if ((!completed || progress != 1) && (completed || progress != 0)) { if ((!completed || progress != 1) && (completed || progress != 0)) {
questData.extraData.setBoolean(this.nbtName, progress == 1); questData.extraData.setBoolean(this.nbtName, progress == 1);
data.questData.checkQuestCompletion(data, EnumQuestType.values()[3]); data.questData.checkQuestCompletion(data, EnumQuestType.values()[3]);
data.save(true); data.save();
} }
} else { } else {
throw new CustomNPCsException("Progress has to be 0 or 1", new Object[0]); throw new CustomNPCsException("Progress has to be 0 or 1", new Object[0]);
+15 -6
View File
@@ -74,7 +74,7 @@ public class NpcAPI extends AbstractNpcAPI {
public static final EventBus EVENT_BUS = new EventBus(); public static final EventBus EVENT_BUS = new EventBus();
private static AbstractNpcAPI instance = null; private static AbstractNpcAPI instance = null;
public NpcAPI() { private NpcAPI() {
} }
public static void clearCache() { public static void clearCache() {
@@ -248,10 +248,14 @@ public class NpcAPI extends AbstractNpcAPI {
} }
public IBlock getIBlock(IWorld world, IPos pos) { public IBlock getIBlock(IWorld world, IPos pos) {
return this.getIBlock(world, pos.getX(),pos.getY(),pos.getZ()); return pos == null ? null : this.getIBlock(world, pos.getX(),pos.getY(),pos.getZ());
} }
public ITileEntity getITileEntity(IWorld world, IPos pos) { public ITileEntity getITileEntity(IWorld world, IPos pos) {
if (pos == null) {
return null;
}
TileEntity tileEntity = world.getMCWorld().getTileEntity(pos.getX(), pos.getY(),pos.getZ()); TileEntity tileEntity = world.getMCWorld().getTileEntity(pos.getX(), pos.getY(),pos.getZ());
return this.getITileEntity(tileEntity); return this.getITileEntity(tileEntity);
} }
@@ -282,11 +286,13 @@ public class NpcAPI extends AbstractNpcAPI {
} }
public IPos[] getAllInBox(IPos from, IPos to, boolean sortByDistance) { public IPos[] getAllInBox(IPos from, IPos to, boolean sortByDistance) {
Iterator<BlockPos> posIterable = BlockPos.getAllInBox(from.getMCPos(),to.getMCPos()).iterator();
ArrayList<IPos> list = new ArrayList<>(); ArrayList<IPos> list = new ArrayList<>();
posIterable.forEachRemaining(BlockPos -> list.add(this.getIPos(BlockPos))); if (from != null && to != null) {
if (sortByDistance) { Iterator<BlockPos> posIterable = BlockPos.getAllInBox(from.getMCPos(),to.getMCPos()).iterator();
list.sort(Comparator.comparingDouble(pos -> pos.distanceTo(from))); posIterable.forEachRemaining(BlockPos -> list.add(this.getIPos(BlockPos)));
if (sortByDistance) {
list.sort(Comparator.comparingDouble(pos -> pos.distanceTo(from)));
}
} }
return list.toArray(new IPos[0]); return list.toArray(new IPos[0]);
} }
@@ -333,6 +339,9 @@ public class NpcAPI extends AbstractNpcAPI {
} }
public ICustomNpc<?> spawnNPC(IWorld world, IPos pos) { public ICustomNpc<?> spawnNPC(IWorld world, IPos pos) {
if (pos == null) {
return null;
}
return this.spawnNPC(world, pos.getX(), pos.getY(), pos.getZ()); return this.spawnNPC(world, pos.getX(), pos.getY(), pos.getZ());
} }
@@ -1,7 +1,9 @@
package noppes.npcs.scripted; package noppes.npcs.scripted;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockAir;
import net.minecraft.block.BlockLiquid; import net.minecraft.block.BlockLiquid;
import net.minecraft.block.material.Material;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.effect.EntityLightningBolt; import net.minecraft.entity.effect.EntityLightningBolt;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
@@ -15,6 +17,8 @@ import net.minecraft.server.MinecraftServer;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntitySign; import net.minecraft.tileentity.TileEntitySign;
import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.MathHelper;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3; import net.minecraft.util.Vec3;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.world.WorldServer; import net.minecraft.world.WorldServer;
@@ -520,36 +524,229 @@ public class ScriptWorld implements IWorld {
return this.isBreakCancelled(pos.getX(),pos.getY(),pos.getZ()); return this.isBreakCancelled(pos.getX(),pos.getY(),pos.getZ());
} }
public MovingObjectPosition func_147447_a(Vec3 startVec, Vec3 endVec, boolean stopOnBlock, boolean stopOnLiquid, boolean stopOnCollision)
{
if (!Double.isNaN(startVec.xCoord) && !Double.isNaN(startVec.yCoord) && !Double.isNaN(startVec.zCoord))
{
if (!Double.isNaN(endVec.xCoord) && !Double.isNaN(endVec.yCoord) && !Double.isNaN(endVec.zCoord))
{
int endX = MathHelper.floor_double(endVec.xCoord);
int endY = MathHelper.floor_double(endVec.yCoord);
int endZ = MathHelper.floor_double(endVec.zCoord);
int l = MathHelper.floor_double(startVec.xCoord);
int i1 = MathHelper.floor_double(startVec.yCoord);
int j1 = MathHelper.floor_double(startVec.zCoord);
Block block = this.world.getBlock(l, i1, j1);
int k1 = this.world.getBlockMetadata(l, i1, j1);
if (block.canCollideCheck(k1, false))
{
MovingObjectPosition movingobjectposition = block.collisionRayTrace(this.world, l, i1, j1, startVec, endVec);
if (movingobjectposition != null)
{
return movingobjectposition;
}
}
k1 = 200;
while (k1-- >= 0)
{
if (Double.isNaN(startVec.xCoord) || Double.isNaN(startVec.yCoord) || Double.isNaN(startVec.zCoord))
{
return null;
}
if (l == endX && i1 == endY && j1 == endZ)
{
return null;
}
boolean flag6 = true;
boolean flag3 = true;
boolean flag4 = true;
double d0 = 999.0D;
double d1 = 999.0D;
double d2 = 999.0D;
if (endX > l)
{
d0 = (double)l + 1.0D;
}
else if (endX < l)
{
d0 = (double)l + 0.0D;
}
else
{
flag6 = false;
}
if (endY > i1)
{
d1 = (double)i1 + 1.0D;
}
else if (endY < i1)
{
d1 = (double)i1 + 0.0D;
}
else
{
flag3 = false;
}
if (endZ > j1)
{
d2 = (double)j1 + 1.0D;
}
else if (endZ < j1)
{
d2 = (double)j1 + 0.0D;
}
else
{
flag4 = false;
}
double d3 = 999.0D;
double d4 = 999.0D;
double d5 = 999.0D;
double d6 = endVec.xCoord - startVec.xCoord;
double d7 = endVec.yCoord - startVec.yCoord;
double d8 = endVec.zCoord - startVec.zCoord;
if (flag6)
{
d3 = (d0 - startVec.xCoord) / d6;
}
if (flag3)
{
d4 = (d1 - startVec.yCoord) / d7;
}
if (flag4)
{
d5 = (d2 - startVec.zCoord) / d8;
}
byte b0;
if (d3 < d4 && d3 < d5)
{
if (endX > l)
{
b0 = 4;
}
else
{
b0 = 5;
}
startVec.xCoord = d0;
startVec.yCoord += d7 * d3;
startVec.zCoord += d8 * d3;
}
else if (d4 < d5)
{
if (endY > i1)
{
b0 = 0;
}
else
{
b0 = 1;
}
startVec.xCoord += d6 * d4;
startVec.yCoord = d1;
startVec.zCoord += d8 * d4;
}
else
{
if (endZ > j1)
{
b0 = 2;
}
else
{
b0 = 3;
}
startVec.xCoord += d6 * d5;
startVec.yCoord += d7 * d5;
startVec.zCoord = d2;
}
Vec3 vec32 = Vec3.createVectorHelper(startVec.xCoord, startVec.yCoord, startVec.zCoord);
l = (int)(vec32.xCoord = (double)MathHelper.floor_double(startVec.xCoord));
if (b0 == 5)
{
--l;
++vec32.xCoord;
}
i1 = (int)(vec32.yCoord = (double)MathHelper.floor_double(startVec.yCoord));
if (b0 == 1)
{
--i1;
++vec32.yCoord;
}
j1 = (int)(vec32.zCoord = (double)MathHelper.floor_double(startVec.zCoord));
if (b0 == 3)
{
--j1;
++vec32.zCoord;
}
Block block1 = this.world.getBlock(l, i1, j1);
int l1 = this.world.getBlockMetadata(l, i1, j1);
MovingObjectPosition movingobjectposition1 = block1.collisionRayTrace(this.world, l, i1, j1, startVec, endVec);
if (movingobjectposition1 != null)
{
if (block1.canCollideCheck(l1, false) && stopOnBlock ||
block1.getMaterial().isLiquid() && stopOnLiquid ||
!(block1 instanceof BlockAir) && block1.getCollisionBoundingBoxFromPool(this.world,l,i1,j1) == null && !stopOnCollision)
{
return movingobjectposition1;
}
}
}
return null;
}
else
{
return null;
}
}
else
{
return null;
}
}
public IPos rayCastPos(double[] startPos, double[] lookVector, int maxDistance, boolean stopOnBlock, boolean stopOnLiquid, boolean stopOnCollision) { public IPos rayCastPos(double[] startPos, double[] lookVector, int maxDistance, boolean stopOnBlock, boolean stopOnLiquid, boolean stopOnCollision) {
if (startPos.length != 3 || lookVector.length != 3) { if (startPos.length != 3 || lookVector.length != 3) {
return null; return null;
} }
IPos pos; Vec3 startVec = Vec3.createVectorHelper(startPos[0], startPos[1], startPos[2]);
Vec3 currentPos = Vec3.createVectorHelper(startPos[0], startPos[1], startPos[2]); int rep = 0; Vec3 endVec = startVec.addVector(lookVector[0]*maxDistance,lookVector[1]*maxDistance,lookVector[2]*maxDistance);
while (rep++ < maxDistance + 10) { IPos endPos = NpcAPI.Instance().getIPos(endVec.xCoord,endVec.yCoord,endVec.zCoord);
currentPos = currentPos.addVector(lookVector[0], lookVector[1], lookVector[2]); if (!stopOnBlock && !stopOnLiquid && !stopOnCollision) {
pos = NpcAPI.Instance().getIPos(currentPos.xCoord, currentPos.yCoord, currentPos.zCoord); return endPos;
IBlock block = getBlock((int)currentPos.xCoord, (int)currentPos.yCoord, (int)currentPos.zCoord);
if (block != null && stopOnBlock) {
if ((!stopOnLiquid || block.getMCBlock() instanceof BlockLiquid)
&& (!stopOnCollision || block.canCollide()))
return pos;
}
double distance = Math.pow(
Math.pow(currentPos.xCoord-startPos[0],2)
+Math.pow(currentPos.yCoord-startPos[1],2)
+Math.pow(currentPos.zCoord-startPos[2],2)
, 0.5);
if (distance > maxDistance) {
return pos;
}
} }
return null; MovingObjectPosition mob = this.func_147447_a(startVec,endVec,stopOnBlock,stopOnLiquid,stopOnCollision);
return mob != null ? NpcAPI.Instance().getIPos(mob.blockX,mob.blockY,mob.blockZ) : endPos;
} }
public IPos rayCastPos(double[] startPos, double[] lookVector, int maxDistance) { public IPos rayCastPos(double[] startPos, double[] lookVector, int maxDistance) {
@@ -1,8 +1,5 @@
package noppes.npcs.scripted.entity; package noppes.npcs.scripted.entity;
import net.minecraft.entity.Entity;
import net.minecraft.entity.IProjectile;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
@@ -12,9 +9,6 @@ import noppes.npcs.api.item.IItemStack;
import noppes.npcs.scripted.CustomNPCsException; import noppes.npcs.scripted.CustomNPCsException;
import noppes.npcs.scripted.NpcAPI; import noppes.npcs.scripted.NpcAPI;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
public class ScriptDBCPlayer<T extends EntityPlayerMP> extends ScriptPlayer<T> implements IDBCPlayer { public class ScriptDBCPlayer<T extends EntityPlayerMP> extends ScriptPlayer<T> implements IDBCPlayer {
public T player; public T player;
@@ -522,8 +516,9 @@ public class ScriptDBCPlayer<T extends EntityPlayerMP> extends ScriptPlayer<T> i
return player.getEntityData().getCompoundTag("PlayerPersisted").getByte("jrmcState2"); return player.getEntityData().getCompoundTag("PlayerPersisted").getByte("jrmcState2");
} }
public double getFormMastery(String formTree, byte form) { public double getRacialFormMastery(byte form) {
try { try {
String formTree = this.getRacialTreeName();
if (player.getEntityData().getCompoundTag("PlayerPersisted").hasKey("jrmcFormMastery" + formTree)) { if (player.getEntityData().getCompoundTag("PlayerPersisted").hasKey("jrmcFormMastery" + formTree)) {
String[] formMasteries = player.getEntityData().getCompoundTag("PlayerPersisted"). String[] formMasteries = player.getEntityData().getCompoundTag("PlayerPersisted").
getString("jrmcFormMastery" + formTree).split(";"); getString("jrmcFormMastery" + formTree).split(";");
@@ -534,8 +529,9 @@ public class ScriptDBCPlayer<T extends EntityPlayerMP> extends ScriptPlayer<T> i
return 0.0D; return 0.0D;
} }
public void setFormMastery(String formTree, byte form, double value) { public void setRacialFormMastery(byte form, double value) {
try { try {
String formTree = this.getRacialTreeName();
if (player.getEntityData().getCompoundTag("PlayerPersisted").hasKey("jrmcFormMastery" + formTree)) { if (player.getEntityData().getCompoundTag("PlayerPersisted").hasKey("jrmcFormMastery" + formTree)) {
String[] formMasteries = player.getEntityData().getCompoundTag("PlayerPersisted"). String[] formMasteries = player.getEntityData().getCompoundTag("PlayerPersisted").
getString("jrmcFormMastery" + formTree).split(";"); getString("jrmcFormMastery" + formTree).split(";");
@@ -558,8 +554,9 @@ public class ScriptDBCPlayer<T extends EntityPlayerMP> extends ScriptPlayer<T> i
} catch (Exception ignored) {} } catch (Exception ignored) {}
} }
public void addFormMastery(String formTree, byte form, double value) { public void addRacialFormMastery(byte form, double value) {
try { try {
String formTree = this.getRacialTreeName();
if (player.getEntityData().getCompoundTag("PlayerPersisted").hasKey("jrmcFormMastery" + formTree)) { if (player.getEntityData().getCompoundTag("PlayerPersisted").hasKey("jrmcFormMastery" + formTree)) {
String[] formMasteries = player.getEntityData().getCompoundTag("PlayerPersisted"). String[] formMasteries = player.getEntityData().getCompoundTag("PlayerPersisted").
getString("jrmcFormMastery" + formTree).split(";"); getString("jrmcFormMastery" + formTree).split(";");
@@ -583,6 +580,107 @@ public class ScriptDBCPlayer<T extends EntityPlayerMP> extends ScriptPlayer<T> i
} catch (Exception ignored) {} } catch (Exception ignored) {}
} }
private String getRacialTreeName() {
switch (this.getRace()) {
case 0:
return "Racial_Human";
case 1:
return "Racial_Saiyan";
case 2:
return "Racial_Half-Saiyan";
case 3:
return "Racial_Namekian";
case 4:
return "Racial_Arcosian";
case 5:
return "Racial_Majin";
}
return "Racial_Human";
}
public double getOtherFormMastery(String formName) {
try {
if (player.getEntityData().getCompoundTag("PlayerPersisted").hasKey("jrmcFormMasteryNonRacial")) {
String masteryData = player.getEntityData().getCompoundTag("PlayerPersisted").
getString("jrmcFormMasteryNonRacial");
if (!masteryData.contains(formName)) {
return 0.0D;
}
String[] formMasteries = masteryData.split(";");
for (String masteryString : formMasteries) {
if (masteryString.split(",")[0].equals(formName)) {
return Double.parseDouble(masteryString.split(",")[1]);
}
}
}
} catch (Exception ignored) {}
return 0.0D;
}
public void setOtherFormMastery(String formName, double value) {
try {
if (player.getEntityData().getCompoundTag("PlayerPersisted").hasKey("jrmcFormMasteryNonRacial")) {
String masteryData = player.getEntityData().getCompoundTag("PlayerPersisted").
getString("jrmcFormMasteryNonRacial");
if (!masteryData.contains(formName)) {
return;
}
String[] formMasteries = masteryData.split(";");
for (int i = 0; i < formMasteries.length; i++) {
String name = formMasteries[i].split(",")[0];
if (name.equals(formName)) {
formMasteries[i] = name + "," + value;
}
}
StringBuilder masteryString = new StringBuilder();
for (int i = 0; i < formMasteries.length; i++) {
masteryString.append(formMasteries[i]);
if (i < formMasteries.length - 1) {
masteryString.append(';');
}
}
player.getEntityData().getCompoundTag("PlayerPersisted").
setString("jrmcFormMasteryNonRacial", String.valueOf(masteryString));
}
} catch (Exception ignored) {}
}
public void addOtherFormMastery(String formName, double value) {
try {
if (player.getEntityData().getCompoundTag("PlayerPersisted").hasKey("jrmcFormMasteryNonRacial")) {
String masteryData = player.getEntityData().getCompoundTag("PlayerPersisted").
getString("jrmcFormMasteryNonRacial");
if (!masteryData.contains(formName)) {
return;
}
String[] formMasteries = masteryData.split(";");
for (int i = 0; i < formMasteries.length; i++) {
String name = formMasteries[i].split(",")[0];
if (name.equals(formName)) {
double newMastery = Double.parseDouble(formMasteries[i].split(",")[1]) + value;
formMasteries[i] = name + "," + newMastery;
}
}
StringBuilder masteryString = new StringBuilder();
for (int i = 0; i < formMasteries.length; i++) {
masteryString.append(formMasteries[i]);
if (i < formMasteries.length - 1) {
masteryString.append(';');
}
}
player.getEntityData().getCompoundTag("PlayerPersisted").
setString("jrmcFormMasteryNonRacial", String.valueOf(masteryString));
}
} catch (Exception ignored) {}
}
public void setPowerPoints(int points){ public void setPowerPoints(int points){
player.getEntityData().getCompoundTag("PlayerPersisted").setInteger("jrmcArcRsrv",points); player.getEntityData().getCompoundTag("PlayerPersisted").setInteger("jrmcArcRsrv",points);
} }
@@ -162,11 +162,7 @@ public class ScriptLivingBase<T extends EntityLivingBase> extends ScriptEntity<T
} }
public IBlock getLookingAtBlock(int maxDistance, boolean stopOnBlock, boolean stopOnLiquid, boolean stopOnCollision) { public IBlock getLookingAtBlock(int maxDistance, boolean stopOnBlock, boolean stopOnLiquid, boolean stopOnCollision) {
Vec3 lookVec = entity.getLookVec(); return NpcAPI.Instance().getIBlock(getWorld(),getLookingAtPos(maxDistance, stopOnBlock, stopOnLiquid, stopOnCollision));
return getWorld().rayCastBlock(
new double[] {entity.posX, entity.posY+entity.getEyeHeight(), entity.posZ},
new double[] {lookVec.xCoord, lookVec.yCoord, lookVec.zCoord},
maxDistance, stopOnBlock, stopOnLiquid, stopOnCollision);
} }
public IBlock getLookingAtBlock(int maxDistance) { public IBlock getLookingAtBlock(int maxDistance) {
@@ -176,7 +172,7 @@ public class ScriptLivingBase<T extends EntityLivingBase> extends ScriptEntity<T
public IPos getLookingAtPos(int maxDistance, boolean stopOnBlock, boolean stopOnLiquid, boolean stopOnCollision) { public IPos getLookingAtPos(int maxDistance, boolean stopOnBlock, boolean stopOnLiquid, boolean stopOnCollision) {
Vec3 lookVec = entity.getLookVec(); Vec3 lookVec = entity.getLookVec();
return getWorld().rayCastPos( return getWorld().rayCastPos(
new double[] {entity.posX, entity.posY+entity.getEyeHeight(), entity.posZ}, new double[] {entity.posX, entity.posY + entity.getEyeHeight(), entity.posZ},
new double[] {lookVec.xCoord, lookVec.yCoord, lookVec.zCoord}, new double[] {lookVec.xCoord, lookVec.yCoord, lookVec.zCoord},
maxDistance, stopOnBlock, stopOnLiquid, stopOnCollision); maxDistance, stopOnBlock, stopOnLiquid, stopOnCollision);
} }
@@ -19,7 +19,6 @@ public class ScriptCustomItem extends ScriptItemStack implements IItemCustom, IS
public List<Integer> errored = new ArrayList(); public List<Integer> errored = new ArrayList();
public String scriptLanguage = "ECMAScript"; public String scriptLanguage = "ECMAScript";
public boolean enabled = false; public boolean enabled = false;
public long lastInited = -1L;
public boolean loaded = false; public boolean loaded = false;
public boolean durabilityShow = false; public boolean durabilityShow = false;
@@ -43,11 +42,8 @@ public class ScriptCustomItem extends ScriptItemStack implements IItemCustom, IS
public float rotationX, rotationY, rotationZ; public float rotationX, rotationY, rotationZ;
public float rotationXRate, rotationYRate, rotationZRate; public float rotationXRate, rotationYRate, rotationZRate;
public int width = -1, height = -1;
public ScriptCustomItem(ItemStack item) { public ScriptCustomItem(ItemStack item) {
super(item); super(item);
loadScriptData();
loadItemData(); loadItemData();
} }
@@ -74,16 +70,12 @@ public class ScriptCustomItem extends ScriptItemStack implements IItemCustom, IS
if (!this.loaded) { if (!this.loaded) {
this.loadScriptData(); this.loadScriptData();
this.loaded = true; this.loaded = true;
if (type != EnumScriptType.INIT) {
EventHooks.onScriptItemInit(this);
}
} }
if (this.isEnabled()) { if (this.isEnabled()) {
if (ScriptController.Instance.lastLoaded > this.lastInited) {
this.lastInited = ScriptController.Instance.lastLoaded;
if (type != EnumScriptType.INIT) {
EventHooks.onScriptItemInit(this);
}
}
for (int i = 0; i < this.scripts.size(); i++) { for (int i = 0; i < this.scripts.size(); i++) {
ScriptContainer script = this.scripts.get(i); ScriptContainer script = this.scripts.get(i);
if (!this.errored.contains(i)) { if (!this.errored.contains(i)) {
@@ -421,12 +413,18 @@ public class ScriptCustomItem extends ScriptItemStack implements IItemCustom, IS
} }
c.setTag("ScriptedData", this.getScriptNBT(new NBTTagCompound())); c.setTag("ScriptedData", this.getScriptNBT(new NBTTagCompound()));
for (ScriptContainer container : this.scripts) {
container.setEngine(this.getLanguage());
}
} }
public void loadScriptData() { public void loadScriptData() {
NBTTagCompound c = this.item.getTagCompound(); NBTTagCompound c = this.item.getTagCompound();
if (c != null) { if (c != null) {
this.setScriptNBT(c.getCompoundTag("ScriptedData")); this.setScriptNBT(c.getCompoundTag("ScriptedData"));
for (ScriptContainer container : this.scripts) {
container.setEngine(this.getLanguage());
}
} }
} }
@@ -1,17 +1,11 @@
package noppes.npcs.util; package noppes.npcs.util;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
public class CustomNPCsScheduler { public class CustomNPCsThreader {
private final static ScheduledExecutorService executor = Executors.newScheduledThreadPool(1); private final static ScheduledExecutorService executor = Executors.newScheduledThreadPool(1);
public static final Executor playerDataThread = Executors.newSingleThreadExecutor();
public static void runTack(Runnable task, int delay){
executor.schedule(task, delay, TimeUnit.MILLISECONDS);
}
public static void runTack(Runnable task){
executor.schedule(task, 0, TimeUnit.MILLISECONDS);
}
} }
@@ -410,13 +410,13 @@ cloner.tagFilters=Tag Filters
cloner.tagVisibility=Tag Visibility cloner.tagVisibility=Tag Visibility
cloner.wandTags=Wand Tags cloner.wandTags=Wand Tags
cloner.npcTags=NPC Tags cloner.npcTags=NPC Tags
cloner.selectedTags=Selected Tags
cloner.order=Sort Order cloner.order=Sort Order
cloner.ascending=Ascending cloner.ascending=Ascending
cloner.descending=Descending cloner.descending=Descending
cloner.type=Sort Type cloner.type=Sort Type
cloner.name=Name cloner.name=Name
cloner.date=Date cloner.date=Date
cloner.wandtags=Wand Tags
cloner.wandtagsapplied=Wand Tags will be applied cloner.wandtagsapplied=Wand Tags will be applied
tags.allTags=All Tags tags.allTags=All Tags