mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-18 17:19:05 +00:00
Merge branch 'dev' into hitbox-settings
This commit is contained in:
99 files changed
+2437
-721
No files matched your search
@@ -1,58 +1,256 @@
|
||||
package foxz.utils;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.nbt.CompressedStreamTools;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import noppes.npcs.CustomNpcs;
|
||||
import noppes.npcs.LogWriter;
|
||||
import noppes.npcs.config.ConfigMain;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import noppes.npcs.roles.RoleTrader;
|
||||
import noppes.npcs.util.CacheHashMap;
|
||||
import noppes.npcs.util.MarketCachedObject;
|
||||
import noppes.npcs.util.NBTJsonUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
import static noppes.npcs.util.CustomNPCsThreader.customNPCThread;
|
||||
|
||||
public class Market {
|
||||
|
||||
static public void save(RoleTrader r, String name) {
|
||||
if(name.isEmpty())
|
||||
return;
|
||||
File file = getFile(name + "_new");
|
||||
File file1 = getFile(name);
|
||||
private static final CacheHashMap<String, MarketCachedObject> marketCache = new CacheHashMap<>(5 * 60 * 1000, 1 * 60 * 1000);
|
||||
|
||||
try {
|
||||
NBTJsonUtil.SaveFile(file, r.writeNBT(new NBTTagCompound()));
|
||||
if(file1.exists()){
|
||||
file1.delete();
|
||||
}
|
||||
file.renameTo(file1);
|
||||
} catch (Exception e) {
|
||||
public static void save(RoleTrader r, String name) {
|
||||
if(name.isEmpty())
|
||||
return;
|
||||
|
||||
}
|
||||
NBTTagCompound roleCompound = r.writeNBT(new NBTTagCompound());
|
||||
roleCompound.setString("SaveName", name);
|
||||
putMarketCache(name, roleCompound);
|
||||
if(r.recordHistory)
|
||||
return;
|
||||
|
||||
saveFile(roleCompound);
|
||||
}
|
||||
|
||||
public static void saveFile(NBTTagCompound compound) {
|
||||
String name = compound.getString("SaveName");
|
||||
File file = getFile(name + "_new");
|
||||
File file1 = getFile(name);
|
||||
customNPCThread.execute(() -> {
|
||||
try {
|
||||
if(ConfigMain.MarketDatFormat){
|
||||
CompressedStreamTools.writeCompressed(compound, new FileOutputStream(file));
|
||||
} else {
|
||||
NBTJsonUtil.SaveFile(file, compound);
|
||||
}
|
||||
if(file1.exists()){
|
||||
file1.delete();
|
||||
}
|
||||
file.renameTo(file1);
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void getMarket(RoleTrader role, String name){
|
||||
NBTTagCompound data = getMarketCache(name);
|
||||
if(data != null){
|
||||
role.readNBT(data);
|
||||
return;
|
||||
}
|
||||
|
||||
load(role, name);
|
||||
}
|
||||
|
||||
public static NBTTagCompound getMarketCache(final String name) {
|
||||
synchronized (marketCache) {
|
||||
if (!marketCache.containsKey(name)) {
|
||||
return null;
|
||||
}
|
||||
return marketCache.get(name).getObject();
|
||||
}
|
||||
}
|
||||
|
||||
public static void putMarketCache(final String name, final NBTTagCompound role) {
|
||||
synchronized (marketCache) {
|
||||
marketCache.put(name, new MarketCachedObject(role));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static public void load(RoleTrader role, String name){
|
||||
if(role.npc.worldObj.isRemote)
|
||||
return;
|
||||
File file = getFile(name);
|
||||
if(!file.exists())
|
||||
return;
|
||||
if(role.npc.worldObj.isRemote)
|
||||
return;
|
||||
File file = getFile(name);
|
||||
if(!file.exists())
|
||||
return;
|
||||
|
||||
try {
|
||||
role.readNBT(NBTJsonUtil.LoadFile(file));
|
||||
} catch (Exception e) {
|
||||
}
|
||||
try {
|
||||
if(ConfigMain.MarketDatFormat){
|
||||
NBTTagCompound compound = NBTJsonUtil.loadNBTData(file);
|
||||
role.readNBT(compound);
|
||||
}
|
||||
else {
|
||||
role.readNBT(NBTJsonUtil.LoadFile(file));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
|
||||
public static File getMarketDir(){
|
||||
try{
|
||||
File file = new File(CustomNpcs.getWorldSaveDirectory(),"markets");
|
||||
if(!file.exists())
|
||||
file.mkdir();
|
||||
return file;
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static File getNewMarketDir(){
|
||||
try{
|
||||
File file = new File(CustomNpcs.getWorldSaveDirectory(),"markets_new");
|
||||
if(file.exists()){
|
||||
return null;
|
||||
}
|
||||
file.mkdir();
|
||||
return file;
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static File getFile(String name){
|
||||
File dir = new File(CustomNpcs.getWorldSaveDirectory(), "markets");
|
||||
if(!dir.exists())
|
||||
dir.mkdir();
|
||||
return new File(dir, name.toLowerCase() + ".json");
|
||||
String filename = name.toLowerCase();
|
||||
if(ConfigMain.MarketDatFormat){
|
||||
filename += ".dat";
|
||||
} else {
|
||||
filename += ".json";
|
||||
}
|
||||
|
||||
return new File(getMarketDir(), filename);
|
||||
}
|
||||
|
||||
static public void setMarket(EntityNPCInterface npc, String marketName) {
|
||||
if(marketName.isEmpty())
|
||||
return;
|
||||
if(!getFile(marketName).exists())
|
||||
Market.save((RoleTrader) npc.roleInterface, marketName);
|
||||
if(marketName.isEmpty())
|
||||
return;
|
||||
if(!getFile(marketName).exists())
|
||||
Market.save((RoleTrader) npc.roleInterface, marketName);
|
||||
|
||||
Market.load((RoleTrader) npc.roleInterface, marketName);
|
||||
Market.getMarket((RoleTrader) npc.roleInterface, marketName);
|
||||
}
|
||||
|
||||
|
||||
public static void convertMarketFiles(final EntityPlayerMP sender, final boolean type){
|
||||
ExecutorService executor = Executors.newSingleThreadExecutor();
|
||||
executor.execute(() -> {
|
||||
String fileType;
|
||||
if(type){
|
||||
fileType = ".dat";
|
||||
}
|
||||
else {
|
||||
fileType = ".json";
|
||||
}
|
||||
|
||||
if(sender != null){
|
||||
LogWriter.info("Market Conversion queued by " + sender.getCommandSenderName());
|
||||
sender.addChatMessage(new ChatComponentText("Market Conversion to " + fileType + " format"));
|
||||
}
|
||||
|
||||
File dir = getMarketDir();
|
||||
LogWriter.info("Converting Market to " + fileType + " format");
|
||||
File[] files = dir.listFiles(); // Get an array of all files in the directory
|
||||
if(files != null){
|
||||
int length = files.length;
|
||||
if(length != 0){
|
||||
if(length > 100){
|
||||
LogWriter.info("Found " + length + " Market files... This may take a few minutes");
|
||||
}
|
||||
int tenPercent = (int) ((double) length * 0.1);
|
||||
int progress = 0;
|
||||
File saveDir = getNewMarketDir();
|
||||
if(saveDir == null){
|
||||
if(sender != null){
|
||||
sender.addChatMessage(new ChatComponentText("markets_new folder already exists please delete it or rename it"));
|
||||
}
|
||||
LogWriter.error("markets_new folder already exists please delete it or rename it");
|
||||
return;
|
||||
}
|
||||
// Load the files in parallel using a stream
|
||||
for(int i = 0; i < length; i++){
|
||||
File file = files[i];
|
||||
if(file.isDirectory() || (!file.getName().endsWith(".json") && !file.getName().endsWith(".dat")))
|
||||
continue;
|
||||
try {
|
||||
String filename = "error";
|
||||
boolean valid = false;
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
if(type){
|
||||
if(file.getName().endsWith(".json")){
|
||||
compound = NBTJsonUtil.LoadFile(file);
|
||||
if(compound.hasKey("PlayerName")) {
|
||||
filename = file.getName().substring(0, file.getName().length() - 5);
|
||||
valid = true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(file.getName().endsWith(".dat")){
|
||||
compound = NBTJsonUtil.loadNBTData(file);
|
||||
if(compound.hasKey("PlayerName")){
|
||||
filename = file.getName().substring(0, file.getName().length() - 4);
|
||||
valid = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(valid){
|
||||
try {
|
||||
File newFile = new File(saveDir, filename + "_new" + fileType);
|
||||
File oldFile = new File(saveDir, filename + fileType);
|
||||
if(type){
|
||||
CompressedStreamTools.writeCompressed(compound, new FileOutputStream(newFile));
|
||||
} else {
|
||||
NBTJsonUtil.SaveFile(newFile, compound);
|
||||
}
|
||||
if(oldFile.exists()){
|
||||
oldFile.delete();
|
||||
}
|
||||
newFile.renameTo(oldFile);
|
||||
} catch (Exception e) {
|
||||
LogWriter.except(e);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LogWriter.error("Error loading: " + file.getAbsolutePath(), e);
|
||||
}
|
||||
if(tenPercent != 0 ){
|
||||
if(progress != 100){
|
||||
if (i % tenPercent == 0) {
|
||||
progress += 10;
|
||||
LogWriter.info("Converting Market: Progress: " + progress + "%");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(sender != null){
|
||||
sender.addChatMessage(new ChatComponentText("Market Conversion complete"));
|
||||
}
|
||||
LogWriter.info("Market Converted - Please rename the markets_new folder to markets and restart");
|
||||
});
|
||||
|
||||
executor.shutdown();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package kamkeel.command;
|
||||
|
||||
import foxz.utils.Market;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockIce;
|
||||
import net.minecraft.block.BlockLeavesBase;
|
||||
@@ -30,7 +31,7 @@ public class ConfigCommand extends CommandKamkeelBase {
|
||||
public String getDescription() {
|
||||
return "Some config things you can set";
|
||||
}
|
||||
|
||||
|
||||
@SubCommand(
|
||||
desc = "Disable/Enable the natural leaves decay",
|
||||
usage = "[true/false]",
|
||||
@@ -56,7 +57,7 @@ public class ConfigCommand extends CommandKamkeelBase {
|
||||
sendResult(sender, "LeavesDecay is now \u00A7c" + ConfigMain.LeavesDecayEnabled);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@SubCommand(
|
||||
desc = "Disable/Enable the vines growing",
|
||||
usage = "[true/false]",
|
||||
@@ -82,7 +83,7 @@ public class ConfigCommand extends CommandKamkeelBase {
|
||||
sendResult(sender, "VineGrowth is now \u00A7c" + ConfigMain.VineGrowthEnabled);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@SubCommand(
|
||||
desc = "Disable/Enable the ice melting",
|
||||
usage = "[true/false]",
|
||||
@@ -127,7 +128,7 @@ public class ConfigCommand extends CommandKamkeelBase {
|
||||
sendResult(sender, "GunsEnabled is now \u00A7c" + ConfigMain.GunsEnabled);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@SubCommand(
|
||||
desc = "Freezes/Unfreezes npcs",
|
||||
usage = "[true/false]",
|
||||
@@ -142,7 +143,7 @@ public class ConfigCommand extends CommandKamkeelBase {
|
||||
sendResult(sender, "FrozenNPCs is now \u00A7c" + CustomNpcs.FreezeNPCs);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@SubCommand(
|
||||
desc = "Set number of active chunkloaders",
|
||||
usage = "<number>",
|
||||
@@ -220,7 +221,54 @@ public class ConfigCommand extends CommandKamkeelBase {
|
||||
PlayerDataController.Instance.convertPlayerFiles(send, convertToDat);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@SubCommand(
|
||||
desc = "Generate Market to JSON/DAT",
|
||||
usage = "[fileType] [convert]",
|
||||
permission = 4
|
||||
)
|
||||
public void market(ICommandSender sender, String[] args) throws CommandException{
|
||||
String fileType;
|
||||
if(ConfigMain.MarketDatFormat){
|
||||
fileType = "DAT";
|
||||
}
|
||||
else {
|
||||
fileType = "JSON";
|
||||
}
|
||||
if(args.length == 0){
|
||||
sendResult(sender, "Market Filetype: \u00A7c" + fileType);
|
||||
}
|
||||
else if(args.length == 1){
|
||||
sendResult(sender, "Please write the word 'convert' at the end to confirm. \u00A7c<dat/json> convert");
|
||||
}
|
||||
else{
|
||||
if(args.length != 2){
|
||||
sendError(sender, "Two many arguments");
|
||||
return;
|
||||
}
|
||||
String formatType = args[0].toLowerCase();
|
||||
if(!formatType.equals("dat") && !formatType.equals("json")){
|
||||
sendError(sender, "Invalid Format Type - Please use dat or json");
|
||||
return;
|
||||
}
|
||||
|
||||
String convert = args[1].toLowerCase();
|
||||
if(!convert.equals("convert")){
|
||||
sendError(sender, "Please enter the word 'convert' at the end");
|
||||
return;
|
||||
}
|
||||
|
||||
boolean convertToDat = formatType.equals("dat");
|
||||
EntityPlayerMP send = null;
|
||||
if(sender instanceof EntityPlayerMP){
|
||||
send = (EntityPlayerMP) sender;
|
||||
}
|
||||
|
||||
sendResult(sender, "Started Conversion Process for Market");
|
||||
Market.convertMarketFiles(send, convertToDat);
|
||||
}
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "Get/Set font",
|
||||
usage = "[type] [size]",
|
||||
@@ -236,7 +284,7 @@ public class ConfigCommand extends CommandKamkeelBase {
|
||||
args = Arrays.copyOfRange(args, 0, args.length - 1);
|
||||
}
|
||||
catch(Exception e){
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
String font = "";
|
||||
@@ -245,6 +293,6 @@ public class ConfigCommand extends CommandKamkeelBase {
|
||||
}
|
||||
Server.sendData((EntityPlayerMP)sender, EnumPacketClient.CONFIG, 0, font.trim(), size);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -13,11 +13,19 @@ import java.util.List;
|
||||
|
||||
|
||||
public class CustomNpcsPermissions{
|
||||
public static final Permission NPC_DELETE = new Permission("customnpcs.npc.delete");
|
||||
// Open GUI
|
||||
public static final Permission NPC_GUI = new Permission("customnpcs.npc.gui");
|
||||
|
||||
// Modify NPC
|
||||
public static final Permission NPC_DELETE = new Permission("customnpcs.npc.delete");
|
||||
public static final Permission NPC_CREATE = new Permission("customnpcs.npc.create");
|
||||
public static final Permission NPC_GUI = new Permission("customnpcs.npc.gui");
|
||||
public static final Permission NPC_FREEZE = new Permission("customnpcs.npc.freeze");
|
||||
public static final Permission NPC_RESET = new Permission("customnpcs.npc.reset");
|
||||
public static final Permission NPC_RESET = new Permission("customnpcs.npc.reset");
|
||||
|
||||
// Extra NPCs
|
||||
public static final Permission NPC_FREEZE = new Permission("customnpcs.npc.freeze");
|
||||
public static final Permission NPC_TELEPORT = new Permission("customnpcs.npc.teleport");
|
||||
|
||||
// Save NPC
|
||||
public static final Permission NPC_AI = new Permission("customnpcs.npc.ai");
|
||||
public static final Permission NPC_ADVANCED = new Permission("customnpcs.npc.advanced");
|
||||
public static final Permission NPC_DISPLAY = new Permission("customnpcs.npc.display");
|
||||
@@ -25,7 +33,10 @@ public class CustomNpcsPermissions{
|
||||
public static final Permission NPC_STATS = new Permission("customnpcs.npc.stats");
|
||||
public static final Permission NPC_CLONE = new Permission("customnpcs.npc.clone");
|
||||
|
||||
public static final Permission GLOBAL_LINKED = new Permission("customnpcs.global.linked");
|
||||
public static final Permission GLOBAL_REMOTE = new Permission("customnpcs.global.remote");
|
||||
|
||||
// Save Globel Preferences
|
||||
public static final Permission GLOBAL_LINKED = new Permission("customnpcs.global.linked");
|
||||
public static final Permission GLOBAL_PLAYERDATA = new Permission("customnpcs.global.playerdata");
|
||||
public static final Permission GLOBAL_BANK = new Permission("customnpcs.global.bank");
|
||||
public static final Permission GLOBAL_DIALOG = new Permission("customnpcs.global.dialog");
|
||||
@@ -35,24 +46,44 @@ public class CustomNpcsPermissions{
|
||||
public static final Permission GLOBAL_RECIPE = new Permission("customnpcs.global.recipe");
|
||||
public static final Permission GLOBAL_NATURALSPAWN = new Permission("customnpcs.global.naturalspawn");
|
||||
public static final Permission GLOBAL_TAG = new Permission("customnpcs.global.tag");
|
||||
public static final Permission GLOBAL_ANIMATION = new Permission("customnpcs.global.animation");
|
||||
|
||||
public static final Permission SPAWNER_MOB = new Permission("customnpcs.spawner.mob");
|
||||
public static final Permission SPAWNER_CREATE = new Permission("customnpcs.spawner.create");
|
||||
|
||||
|
||||
// Open / Use Wands
|
||||
public static final Permission TOOL_MOUNTER = new Permission("customnpcs.tool.mounter");
|
||||
public static final Permission TOOL_PATHER = new Permission("customnpcs.tool.pather");
|
||||
public static final Permission TOOL_SCRIPTER = new Permission("customnpcs.tool.scripter");
|
||||
public static final Permission TOOL_CLONER = new Permission("customnpcs.tool.cloner");
|
||||
public static final Permission TOOL_SCRIPTED_ITEM = new Permission("customnpcs.tool.scripteditem");
|
||||
public static final Permission TOOL_TELEPORTER = new Permission("customnpcs.tool.teleporter");
|
||||
|
||||
// Edit Villager
|
||||
public static final Permission EDIT_VILLAGER = new Permission("customnpcs.edit.villager");
|
||||
|
||||
public static final Permission EDIT_BLOCKS = new Permission("customnpcs.edit.blocks");
|
||||
public static final Permission EDIT_REDSTONE = new Permission("customnpcs.edit.redstone");
|
||||
public static final Permission EDIT_BOOK = new Permission("customnpcs.edit.book");
|
||||
public static final Permission EDIT_TOMBSTONE = new Permission("customnpcs.edit.tombsone");
|
||||
public static final Permission EDIT_WAYPOINT = new Permission("customnpcs.edit.waypoint");
|
||||
public static final Permission EDIT_BIGSIGN = new Permission("customnpcs.edit.bigsign");
|
||||
|
||||
public static final Permission SOULSTONE_ALL = new Permission("customnpcs.soulstone.all");
|
||||
|
||||
// Modify / Save Scripts
|
||||
public static final Permission SCRIPT_NPC = new Permission("customnpcs.script.npc");
|
||||
public static final Permission SCRIPT_FORGE = new Permission("customnpcs.script.forge");
|
||||
public static final Permission SCRIPT_PLAYER = new Permission("customnpcs.script.player");
|
||||
public static final Permission SCRIPT_GLOBAL = new Permission("customnpcs.script.global");
|
||||
public static final Permission SCRIPT_ITEM = new Permission("customnpcs.script.item");
|
||||
public static final Permission SCRIPT_BLOCK = new Permission("customnpcs.script.block");
|
||||
|
||||
public static final Permission EDIT_VILLAGER = new Permission("customnpcs.edit.villager");
|
||||
public static final Permission EDIT_BLOCKS = new Permission("customnpcs.edit.blocks");
|
||||
|
||||
public static final Permission SOULSTONE_ALL = new Permission("customnpcs.soulstone.all");
|
||||
|
||||
public static CustomNpcsPermissions Instance;
|
||||
private Class<?> bukkit;
|
||||
private Method getPlayer;
|
||||
private Method hasPermission;
|
||||
|
||||
|
||||
public CustomNpcsPermissions(){
|
||||
Instance = this;
|
||||
try {
|
||||
@@ -73,7 +104,7 @@ public class CustomNpcsPermissions{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static boolean hasPermission(EntityPlayer player, Permission permission){
|
||||
if(player != null){
|
||||
if(Developer.Instance.hasUniversal(player.getUniqueID())){
|
||||
|
||||
@@ -12,6 +12,7 @@ import net.minecraft.util.StringUtils;
|
||||
import noppes.npcs.config.ConfigMain;
|
||||
import noppes.npcs.controllers.data.AnimationData;
|
||||
import noppes.npcs.controllers.data.CustomHitboxData;
|
||||
import noppes.npcs.controllers.data.CustomTintData;
|
||||
import noppes.npcs.controllers.data.SkinOverlay;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import noppes.npcs.entity.data.DataSkinOverlays;
|
||||
@@ -61,8 +62,9 @@ public class DataDisplay {
|
||||
|
||||
//0 - Yes, 1 - No, 2 - Only NPCs, 3 - Only Players, 4 - NPCs and Players
|
||||
public int collidesWith = 1;
|
||||
|
||||
public CustomHitboxData customHitboxData;
|
||||
|
||||
public CustomHitboxData customHitboxData;
|
||||
public CustomTintData customTintData;
|
||||
|
||||
public DataDisplay(EntityNPCInterface npc){
|
||||
this.npc = npc;
|
||||
@@ -70,7 +72,8 @@ public class DataDisplay {
|
||||
skinOverlayData = new DataSkinOverlays(npc);
|
||||
name = getRandomName();
|
||||
animationData = new AnimationData(this);
|
||||
customHitboxData = new CustomHitboxData();
|
||||
customHitboxData = new CustomHitboxData();
|
||||
customTintData = new CustomTintData();
|
||||
}
|
||||
|
||||
public String getRandomName() {
|
||||
@@ -92,8 +95,8 @@ public class DataDisplay {
|
||||
nbttagcompound = skinOverlayData.writeToNBT(nbttagcompound);
|
||||
|
||||
nbttagcompound = animationData.writeToNBT(nbttagcompound);
|
||||
|
||||
nbttagcompound = customHitboxData.writeToNBT(nbttagcompound);
|
||||
nbttagcompound = customHitboxData.writeToNBT(nbttagcompound);
|
||||
nbttagcompound = customTintData.writeToNBT(nbttagcompound);
|
||||
|
||||
if (this.playerProfile != null)
|
||||
{
|
||||
@@ -170,9 +173,9 @@ public class DataDisplay {
|
||||
skinOverlayData.readFromNBT(nbttagcompound);
|
||||
|
||||
animationData.readFromNBT(nbttagcompound);
|
||||
|
||||
customHitboxData.readFromNBT(nbttagcompound);
|
||||
|
||||
customHitboxData.readFromNBT(nbttagcompound);
|
||||
customTintData.readFromNBT(nbttagcompound);
|
||||
|
||||
modelSize = ValueUtil.clamp(nbttagcompound.getInteger("Size"), 1, Integer.MAX_VALUE);
|
||||
if(modelSize > ConfigMain.NpcSizeLimit)
|
||||
modelSize = ConfigMain.NpcSizeLimit;
|
||||
|
||||
@@ -85,6 +85,11 @@ public class EventHooks {
|
||||
return NpcAPI.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
public static boolean onScriptItemRightClick(IItemCustom handler, noppes.npcs.scripted.event.ItemEvent.RightClickEvent event) {
|
||||
((ScriptCustomItem) handler).callScript(EnumScriptType.RIGHT_CLICK, event);
|
||||
return NpcAPI.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
public static boolean onScriptItemAttack(IItemCustom handler, noppes.npcs.scripted.event.ItemEvent.AttackEvent event) {
|
||||
((ScriptCustomItem) handler).callScript(EnumScriptType.ATTACK, event);
|
||||
return NpcAPI.EVENT_BUS.post(event);
|
||||
|
||||
@@ -23,6 +23,7 @@ import net.minecraft.util.ChatComponentTranslation;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import noppes.npcs.api.entity.IPlayer;
|
||||
import noppes.npcs.config.ConfigMain;
|
||||
import noppes.npcs.constants.EnumGuiType;
|
||||
@@ -40,6 +41,7 @@ import noppes.npcs.scripted.NpcAPI;
|
||||
import noppes.npcs.scripted.ScriptSound;
|
||||
import noppes.npcs.scripted.event.DialogEvent;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.File;
|
||||
@@ -75,7 +77,7 @@ public class NoppesUtilServer {
|
||||
NBTTagCompound comp = new NBTTagCompound();
|
||||
npc.roleInterface.writeToNBT(comp);
|
||||
comp.setInteger("EntityId", npc.getEntityId());
|
||||
comp.setInteger("Role", npc.advanced.role.ordinal());
|
||||
comp.setInteger("Role", npc.advanced.role.ordinal());
|
||||
Server.sendData((EntityPlayerMP)player, EnumPacketClient.ROLE, comp);
|
||||
}
|
||||
|
||||
@@ -102,7 +104,7 @@ public class NoppesUtilServer {
|
||||
}
|
||||
sendScrollData(player, map);
|
||||
}
|
||||
|
||||
|
||||
public static void sendBankDataAll(EntityPlayerMP player) {
|
||||
Map<String,Integer> map = new HashMap<String,Integer>();
|
||||
for(Bank bank : BankController.getInstance().banks.values()){
|
||||
@@ -110,7 +112,7 @@ public class NoppesUtilServer {
|
||||
}
|
||||
sendScrollData(player, map);
|
||||
}
|
||||
|
||||
|
||||
public static NBTTagCompound writeItem(ItemStack item, NBTTagCompound nbt){
|
||||
String resourcelocation = Item.itemRegistry.getNameForObject(item.getItem());
|
||||
nbt.setString("id", resourcelocation == null ? "minecraft:air" : resourcelocation.toString());
|
||||
@@ -148,7 +150,7 @@ public class NoppesUtilServer {
|
||||
}
|
||||
return itemstack;
|
||||
}
|
||||
|
||||
|
||||
public static Item getByNameOrId(String id)
|
||||
{
|
||||
Item item = (Item)Item.itemRegistry.getObject(id);
|
||||
@@ -167,7 +169,7 @@ public class NoppesUtilServer {
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
|
||||
public static void openDialog(EntityPlayer player, EntityNPCInterface npc, Dialog dia, int optionId){
|
||||
Dialog dialog = dia.copy(player);
|
||||
|
||||
@@ -189,7 +191,7 @@ public class NoppesUtilServer {
|
||||
dia.factionOptions.addPoints(player);
|
||||
if(dialog.hasQuest())
|
||||
PlayerQuestController.addActiveQuest(new QuestData(dialog.getQuest()),player);
|
||||
if(!dialog.command.isEmpty()){
|
||||
if(!dialog.command.isEmpty()){
|
||||
runCommand(player, npc.getCommandSenderName(), dialog.command);
|
||||
}
|
||||
if(dialog.mail.isValid())
|
||||
@@ -202,7 +204,7 @@ public class NoppesUtilServer {
|
||||
public static void runCommand(EntityPlayer player, String name, String command){
|
||||
runCommand(player, name, command, player);
|
||||
}
|
||||
|
||||
|
||||
public static void runCommand(EntityLivingBase executer, String name, String command, EntityPlayer player){
|
||||
if(player != null)
|
||||
command = command.replace("@dp", player.getCommandSenderName());
|
||||
@@ -212,7 +214,7 @@ public class NoppesUtilServer {
|
||||
tile.xCoord = MathHelper.floor_double(executer.posX);
|
||||
tile.yCoord = MathHelper.floor_double(executer.posY);
|
||||
tile.zCoord = MathHelper.floor_double(executer.posZ);
|
||||
|
||||
|
||||
CommandBlockLogic logic = tile.func_145993_a();
|
||||
logic.func_145752_a(command);
|
||||
logic.func_145754_b("@"+name);
|
||||
@@ -231,17 +233,17 @@ public class NoppesUtilServer {
|
||||
logic.func_145754_b("@"+name);
|
||||
logic.func_145755_a(world);
|
||||
}
|
||||
|
||||
|
||||
public static void consumeItemStack(int i, EntityPlayer player){
|
||||
ItemStack item = player.inventory.getCurrentItem();
|
||||
if(player.capabilities.isCreativeMode || item == null)
|
||||
return;
|
||||
|
||||
|
||||
--item.stackSize;
|
||||
if (item.stackSize <= 0)
|
||||
player.destroyCurrentEquippedItem();
|
||||
}
|
||||
|
||||
|
||||
public static DataOutputStream getDataOutputStream(ByteArrayOutputStream stream) throws IOException{
|
||||
return new DataOutputStream(new GZIPOutputStream(stream));
|
||||
}
|
||||
@@ -259,7 +261,7 @@ public class NoppesUtilServer {
|
||||
final EnumGuiType gui, final EntityNPCInterface npc, final int i, final int j, final int k) {
|
||||
if(!(player instanceof EntityPlayerMP))
|
||||
return;
|
||||
|
||||
|
||||
setEditingNpc(player, npc);
|
||||
sendExtraData(player, npc,gui, i, j, k);
|
||||
|
||||
@@ -398,11 +400,11 @@ public class NoppesUtilServer {
|
||||
player.addChatMessage(new ChatComponentTranslation("Currently you cant create horse spawner, its a minecraft bug"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
player.worldObj.setBlock(x, y, z, Blocks.mob_spawner); //setBlock
|
||||
TileEntityMobSpawner tile = (TileEntityMobSpawner) player.worldObj.getTileEntity(x, y, z);
|
||||
MobSpawnerBaseLogic logic = tile.func_145881_a();
|
||||
|
||||
|
||||
logic.setRandomEntity(logic.new WeightedRandomMinecart(comp, comp.getString("id")));
|
||||
}
|
||||
|
||||
@@ -416,7 +418,7 @@ public class NoppesUtilServer {
|
||||
|
||||
public static void sendPlayerData(EnumPlayerData type, EntityPlayerMP player, String name) throws IOException {
|
||||
Map<String,Integer> map = new HashMap<String,Integer>();
|
||||
|
||||
|
||||
if(type == EnumPlayerData.Players){
|
||||
for(String username : PlayerDataController.Instance.nameUUIDs.keySet()){
|
||||
map.put(username, 0);
|
||||
@@ -429,7 +431,7 @@ public class NoppesUtilServer {
|
||||
PlayerData playerdata = PlayerDataController.Instance.getDataFromUsername(name);
|
||||
if(type == EnumPlayerData.Dialog){
|
||||
PlayerDialogData data = playerdata.dialogData;
|
||||
|
||||
|
||||
for(int questId : data.dialogsRead){
|
||||
Dialog dialog = DialogController.Instance.dialogs.get(questId);
|
||||
if(dialog == null)
|
||||
@@ -439,7 +441,7 @@ public class NoppesUtilServer {
|
||||
}
|
||||
else if(type == EnumPlayerData.Quest){
|
||||
PlayerQuestData data = playerdata.questData;
|
||||
|
||||
|
||||
for(int questId : data.activeQuests.keySet()){
|
||||
Quest quest = QuestController.Instance.quests.get(questId);
|
||||
if(quest == null)
|
||||
@@ -455,7 +457,7 @@ public class NoppesUtilServer {
|
||||
}
|
||||
else if(type == EnumPlayerData.Transport){
|
||||
PlayerTransportData data = playerdata.transportData;
|
||||
|
||||
|
||||
for(int questId : data.transports){
|
||||
TransportLocation location = TransportController.getInstance().getTransport(questId);
|
||||
if(location == null)
|
||||
@@ -465,7 +467,7 @@ public class NoppesUtilServer {
|
||||
}
|
||||
else if(type == EnumPlayerData.Bank){
|
||||
PlayerBankData data = playerdata.bankData;
|
||||
|
||||
|
||||
for(int bankId : data.banks.keySet()){
|
||||
Bank bank = BankController.getInstance().banks.get(bankId);
|
||||
if(bank == null)
|
||||
@@ -483,10 +485,10 @@ public class NoppesUtilServer {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
NoppesUtilServer.sendScrollData(player, map);
|
||||
}
|
||||
|
||||
|
||||
public static void removePlayerData(ByteBuf buffer, EntityPlayerMP player) throws IOException {
|
||||
int id = buffer.readInt();
|
||||
if(EnumPlayerData.values().length <= id)
|
||||
@@ -554,7 +556,7 @@ public class NoppesUtilServer {
|
||||
public static void regenPlayerData(EntityPlayerMP player) throws IOException {
|
||||
PlayerDataController.Instance.generatePlayerMap(player);
|
||||
}
|
||||
|
||||
|
||||
public static void sendRecipeData(EntityPlayerMP player, int size) {
|
||||
HashMap<String,Integer> map = new HashMap<String,Integer>();
|
||||
if(size == 3){
|
||||
@@ -653,7 +655,7 @@ public class NoppesUtilServer {
|
||||
}
|
||||
sendScrollData(player, map);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static void sendNpcDialogs(EntityPlayer player) {
|
||||
EntityNPCInterface npc = getEditingNpc(player);
|
||||
@@ -663,11 +665,11 @@ public class NoppesUtilServer {
|
||||
DialogOption option = npc.dialogs.get(pos);
|
||||
if(option == null || !option.hasDialog())
|
||||
continue;
|
||||
|
||||
|
||||
NBTTagCompound compound = option.writeNBT();
|
||||
compound.setInteger("Position", pos);
|
||||
Server.sendData((EntityPlayerMP)player, EnumPacketClient.GUI_DATA, compound);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -693,22 +695,34 @@ public class NoppesUtilServer {
|
||||
int x = compound.getInteger("x");
|
||||
int y = compound.getInteger("y");
|
||||
int z = compound.getInteger("z");
|
||||
|
||||
|
||||
TileEntity tile = player.worldObj.getTileEntity(x, y, z);
|
||||
if(tile != null)
|
||||
tile.readFromNBT(compound);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static void setClonerGui(EntityPlayerMP player, int x, int y, int z){
|
||||
if(player == null)
|
||||
return;
|
||||
Server.sendData(player, EnumPacketClient.CLONER, x, y, z);
|
||||
}
|
||||
|
||||
public static void setTeleporterGUI(EntityPlayerMP player){
|
||||
if(player == null)
|
||||
return;
|
||||
Server.sendData(player, EnumPacketClient.TELEPORTER);
|
||||
}
|
||||
|
||||
public static void setRecipeGui(EntityPlayerMP player, RecipeCarpentry recipe){
|
||||
if(recipe == null)
|
||||
return;
|
||||
if(!(player.openContainer instanceof ContainerManageRecipes))
|
||||
return;
|
||||
|
||||
|
||||
ContainerManageRecipes container = (ContainerManageRecipes) player.openContainer;
|
||||
container.setRecipe(recipe);
|
||||
|
||||
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, recipe.writeNBT());
|
||||
}
|
||||
|
||||
@@ -850,6 +864,18 @@ public class NoppesUtilServer {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Entity getEntityFromUUID(World world, UUID uuid) {
|
||||
for (Object obj : world.loadedEntityList) {
|
||||
if (obj instanceof Entity) {
|
||||
Entity entity = (Entity) obj;
|
||||
if (entity.getUniqueID().equals(uuid)) {
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
static public EntityPlayer getPlayerByName(String playername){
|
||||
return MinecraftServer.getServer().getConfigurationManager().func_152612_a(playername);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,9 @@ package noppes.npcs;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.network.FMLNetworkEvent.ServerCustomPacketEvent;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemEditableBook;
|
||||
@@ -25,9 +28,10 @@ import noppes.npcs.roles.RoleCompanion;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Iterator;
|
||||
import java.util.UUID;
|
||||
|
||||
public class PacketHandlerPlayer{
|
||||
|
||||
|
||||
@SubscribeEvent
|
||||
public void onServerPacket(ServerCustomPacketEvent event) {
|
||||
EntityPlayerMP player = ((NetHandlerPlayServer)event.handler).playerEntity;
|
||||
@@ -40,7 +44,17 @@ public class PacketHandlerPlayer{
|
||||
}
|
||||
|
||||
private void player(ByteBuf buffer, EntityPlayerMP player, EnumPlayerPacket type) throws IOException {
|
||||
if(type == EnumPlayerPacket.CompanionTalentExp){
|
||||
if(type == EnumPlayerPacket.MarkData){
|
||||
String uuid = Server.readString(buffer);
|
||||
if(uuid == null)
|
||||
return;
|
||||
|
||||
Entity entity = NoppesUtilServer.getEntityFromUUID(player.worldObj, UUID.fromString(uuid));
|
||||
if(!(entity instanceof EntityNPCInterface))
|
||||
return;
|
||||
MarkData data = MarkData.get((EntityNPCInterface) entity);
|
||||
}
|
||||
else if(type == EnumPlayerPacket.CompanionTalentExp){
|
||||
EntityNPCInterface npc = NoppesUtilServer.getEditingNpc(player);
|
||||
if(npc == null || npc.advanced.role != EnumRoleType.Companion || player != npc.getOwner())
|
||||
return;
|
||||
@@ -202,7 +216,7 @@ public class PacketHandlerPlayer{
|
||||
long time = buffer.readLong();
|
||||
String username = Server.readString(buffer);
|
||||
PlayerMailData data = PlayerDataController.Instance.getPlayerData(player).mailData;
|
||||
|
||||
|
||||
Iterator<PlayerMail> it = data.playermail.iterator();
|
||||
while(it.hasNext()){
|
||||
PlayerMail mail = it.next();
|
||||
@@ -220,7 +234,7 @@ public class PacketHandlerPlayer{
|
||||
NoppesUtilServer.sendGuiError(player, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
PlayerMail mail = new PlayerMail();
|
||||
//String s = player.func_145748_c_().getFormattedText();
|
||||
String s = player.getDisplayName();
|
||||
@@ -235,7 +249,7 @@ public class PacketHandlerPlayer{
|
||||
return;
|
||||
}
|
||||
PlayerDataController.Instance.addPlayerMessage(username, mail);
|
||||
|
||||
|
||||
NBTTagCompound comp = new NBTTagCompound();
|
||||
comp.setString("username", username);
|
||||
NoppesUtilServer.sendGuiClose(player, 1,comp);
|
||||
@@ -245,7 +259,7 @@ public class PacketHandlerPlayer{
|
||||
String username = Server.readString(buffer);
|
||||
player.closeContainer();
|
||||
PlayerMailData data = PlayerDataController.Instance.getPlayerData(player).mailData;
|
||||
|
||||
|
||||
Iterator<PlayerMail> it = data.playermail.iterator();
|
||||
while(it.hasNext()){
|
||||
PlayerMail mail = it.next();
|
||||
@@ -260,7 +274,7 @@ public class PacketHandlerPlayer{
|
||||
long time = buffer.readLong();
|
||||
String username = Server.readString(buffer);
|
||||
PlayerMailData data = PlayerDataController.Instance.getPlayerData(player).mailData;
|
||||
|
||||
|
||||
Iterator<PlayerMail> it = data.playermail.iterator();
|
||||
while(it.hasNext()){
|
||||
PlayerMail mail = it.next();
|
||||
|
||||
@@ -260,7 +260,20 @@ public class PacketHandlerServer{
|
||||
|
||||
if (playerData.partyUUID != null) {
|
||||
Party party = PartyController.Instance().getParty(playerData.partyUUID);
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, party.writeToNBT());
|
||||
NBTTagCompound compound = party.writeToNBT();
|
||||
if (party.getQuest() != null) {
|
||||
Quest quest = (Quest) party.getQuest();
|
||||
Vector<String> vector = quest.questInterface.getQuestLogStatus(player);
|
||||
NBTTagList list = new NBTTagList();
|
||||
for (String s : vector) {
|
||||
list.appendTag(new NBTTagString(s));
|
||||
}
|
||||
compound.setTag("QuestProgress", list);
|
||||
if(quest.completion == EnumQuestCompletion.Npc && quest.questInterface.isCompleted(playerData)) {
|
||||
compound.setString("QuestCompleteWith", quest.completerNpc);
|
||||
}
|
||||
}
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
|
||||
} else {
|
||||
sendInviteData(player);
|
||||
}
|
||||
@@ -644,6 +657,12 @@ public class PacketHandlerServer{
|
||||
LogWriter.script(String.format("[%s] (Player) %s OPEN NPC %s (%s, %s, %s) [%s]", "WAND", player.getCommandSenderName(), ((EntityNPCInterface)entity).display.getName(), entity.posX, entity.posY, entity.posZ, entity.worldObj.getWorldInfo().getWorldName()));
|
||||
}
|
||||
}
|
||||
else if(type == EnumPacketServer.RemoteGlobalMenu){
|
||||
NoppesUtilServer.sendOpenGui(player, EnumGuiType.GlobalRemote, null);
|
||||
if(ConfigDebug.PlayerLogging && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER){
|
||||
LogWriter.script(String.format("[%s] (Player) %s OPEN GLOBAL MENU", "WAND", player.getCommandSenderName()));
|
||||
}
|
||||
}
|
||||
else if(type == EnumPacketServer.RemoteDelete){
|
||||
Entity entity = player.worldObj.getEntityByID(buffer.readInt());
|
||||
if(entity == null || !(entity instanceof EntityNPCInterface))
|
||||
@@ -658,7 +677,6 @@ public class PacketHandlerServer{
|
||||
}
|
||||
else if(type == EnumPacketServer.RemoteNpcsGet){
|
||||
NoppesUtilServer.sendNearbyNpcs(player);
|
||||
Server.sendData(player, EnumPacketClient.SCROLL_SELECTED, CustomNpcs.FreezeNPCs?"Unfreeze Npcs":"Freeze Npcs");
|
||||
}
|
||||
else if(type == EnumPacketServer.RemoteFreeze){
|
||||
CustomNpcs.FreezeNPCs = !CustomNpcs.FreezeNPCs;
|
||||
@@ -940,7 +958,7 @@ public class PacketHandlerServer{
|
||||
else if(type == EnumPacketServer.PlayerDataRemove){
|
||||
NoppesUtilServer.removePlayerData(buffer,player);
|
||||
}
|
||||
else if(type == EnumPacketServer.PlayerDataRegen){
|
||||
else if(type == EnumPacketServer.PlayerDataMapRegen){
|
||||
NoppesUtilServer.regenPlayerData(player);
|
||||
}
|
||||
else if(type == EnumPacketServer.MainmenuDisplayGet){
|
||||
@@ -982,6 +1000,11 @@ public class PacketHandlerServer{
|
||||
npc.updateAI = true;
|
||||
npc.updateClient = true;
|
||||
}
|
||||
else if(type == EnumPacketServer.MainmenuAdvancedMarkData){
|
||||
MarkData data = MarkData.get(npc);
|
||||
data.setNBT(Server.readNBT(buffer));
|
||||
data.syncClients();
|
||||
}
|
||||
else if(type == EnumPacketServer.JobSave){
|
||||
NBTTagCompound original = npc.jobInterface.writeToNBT(new NBTTagCompound());
|
||||
NBTTagCompound compound = Server.readNBT(buffer);
|
||||
@@ -1076,13 +1099,14 @@ public class PacketHandlerServer{
|
||||
}
|
||||
else if(type == EnumPacketServer.TraderMarketSave){
|
||||
String market = Server.readString(buffer);
|
||||
if(market == null)
|
||||
return;
|
||||
boolean bo = buffer.readBoolean();
|
||||
if(npc.roleInterface instanceof RoleTrader){
|
||||
if(bo)
|
||||
Market.setMarket(npc, market);
|
||||
else
|
||||
Market.save((RoleTrader)npc.roleInterface, market);
|
||||
//NoppesUtilServer.sendRoleData(player, npc);
|
||||
}
|
||||
}
|
||||
else if(type == EnumPacketServer.AnimationsGet){
|
||||
|
||||
@@ -10,10 +10,15 @@ import net.minecraftforge.event.entity.EntityJoinWorldEvent;
|
||||
import net.minecraftforge.event.entity.item.ItemTossEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingEvent;
|
||||
import net.minecraftforge.event.entity.player.EntityInteractEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerUseItemEvent;
|
||||
import noppes.npcs.api.IWorld;
|
||||
import noppes.npcs.api.entity.IPlayer;
|
||||
import noppes.npcs.api.item.IItemCustom;
|
||||
import noppes.npcs.api.item.IItemStack;
|
||||
import noppes.npcs.controllers.PlayerDataController;
|
||||
import noppes.npcs.controllers.data.PlayerData;
|
||||
import noppes.npcs.controllers.data.PlayerDataScript;
|
||||
import noppes.npcs.entity.EntityCustomNpc;
|
||||
import noppes.npcs.items.ItemScripted;
|
||||
import noppes.npcs.scripted.NpcAPI;
|
||||
@@ -103,11 +108,57 @@ public class ScriptItemEventHandler {
|
||||
IItemCustom isw = ItemScripted.GetWrapper(event.entityPlayer.getHeldItem());
|
||||
ItemEvent.InteractEvent eve = new ItemEvent.InteractEvent(isw, (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer), 2, NpcAPI.Instance().getIEntity(event.target));
|
||||
event.setCanceled(EventHooks.onScriptItemInteract(isw, eve));
|
||||
|
||||
ItemEvent.RightClickEvent rightClickEvent = new ItemEvent.RightClickEvent(isw, (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer), 1, NpcAPI.Instance().getIEntity(event.target));
|
||||
event.setCanceled(EventHooks.onScriptItemRightClick(isw, rightClickEvent));
|
||||
}
|
||||
} catch(Exception e) {}
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void invoke(PlayerInteractEvent event) {
|
||||
if(event.entityPlayer == null || event.entityPlayer.worldObj == null || event.action == null)
|
||||
return;
|
||||
|
||||
if(event.entityPlayer.worldObj.isRemote && event.entityPlayer.worldObj instanceof WorldServer)
|
||||
return;
|
||||
|
||||
if (PlayerDataController.Instance != null) {
|
||||
if(event.action == PlayerInteractEvent.Action.RIGHT_CLICK_AIR){
|
||||
PlayerData handler = PlayerDataController.Instance.getPlayerData(event.entityPlayer);
|
||||
if(handler == null)
|
||||
return;
|
||||
|
||||
if(handler.hadInteract) {
|
||||
handler.hadInteract = false;
|
||||
return;
|
||||
}
|
||||
try {
|
||||
if (event.entityPlayer.getHeldItem().getItem() == CustomItems.scripted_item && !event.isCanceled()) {
|
||||
IItemCustom isw = ItemScripted.GetWrapper(event.entityPlayer.getHeldItem());
|
||||
ItemEvent.RightClickEvent eve = new ItemEvent.RightClickEvent(isw, (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer), 0, null);
|
||||
event.setCanceled(EventHooks.onScriptItemRightClick(isw, eve));
|
||||
}
|
||||
} catch(Exception e) {}
|
||||
}
|
||||
else if(event.action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK){
|
||||
PlayerData handler = PlayerDataController.Instance.getPlayerData(event.entityPlayer);
|
||||
if(handler == null)
|
||||
return;
|
||||
|
||||
handler.hadInteract = true;
|
||||
try {
|
||||
if (event.entityPlayer.getHeldItem().getItem() == CustomItems.scripted_item && !event.isCanceled()) {
|
||||
IItemCustom isw = ItemScripted.GetWrapper(event.entityPlayer.getHeldItem());
|
||||
ItemEvent.RightClickEvent eve = new ItemEvent.RightClickEvent(isw, (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer), 2, NpcAPI.Instance().getIBlock((IWorld) NpcAPI.Instance().getIWorld(event.world), event.x, event.y, event.z));
|
||||
event.setCanceled(EventHooks.onScriptItemRightClick(isw, eve));
|
||||
}
|
||||
} catch(Exception e) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void invoke(PlayerUseItemEvent.Start event) {
|
||||
if(event.entityPlayer == null || event.entityPlayer.worldObj == null)
|
||||
|
||||
@@ -88,6 +88,8 @@ public class ServerEventsHandler {
|
||||
}
|
||||
}
|
||||
else if(item.getItem() == CustomItems.cloner && !isRemote && !(event.target instanceof EntityPlayer)){
|
||||
if(!CustomNpcsPermissions.Instance.hasPermission(event.entityPlayer, CustomNpcsPermissions.TOOL_CLONER))
|
||||
return;
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
if(!event.target.writeToNBTOptional(compound))
|
||||
return;
|
||||
@@ -102,7 +104,7 @@ public class ServerEventsHandler {
|
||||
event.setCanceled(true);
|
||||
}
|
||||
else if(item.getItem() == CustomItems.scripter && !isRemote && npcInteracted){
|
||||
if(!CustomNpcsPermissions.Instance.hasPermission(event.entityPlayer, CustomNpcsPermissions.NPC_GUI))
|
||||
if(!CustomNpcsPermissions.Instance.hasPermission(event.entityPlayer, CustomNpcsPermissions.TOOL_SCRIPTER))
|
||||
return;
|
||||
NoppesUtilServer.setEditingNpc(event.entityPlayer, (EntityNPCInterface)event.target);
|
||||
event.setCanceled(true);
|
||||
@@ -401,4 +403,15 @@ public class ServerEventsHandler {
|
||||
public void populateChunk(PopulateChunkEvent.Post event){
|
||||
NPCSpawning.performWorldGenSpawning(event.world, event.chunkX, event.chunkZ, event.rand);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void playerTracking(PlayerEvent.StartTracking event){
|
||||
if(!(event.target instanceof EntityNPCInterface) || event.target.worldObj.isRemote)
|
||||
return;
|
||||
|
||||
MarkData data = MarkData.get((EntityNPCInterface) event.target);
|
||||
if(data.marks.isEmpty())
|
||||
return;
|
||||
Server.sendData((EntityPlayerMP)event.entityPlayer, EnumPacketClient.MARK_DATA, event.target.getEntityId(), data.getNBT());
|
||||
}
|
||||
}
|
||||
@@ -24,27 +24,27 @@ import noppes.npcs.blocks.tiles.TileColorable;
|
||||
import noppes.npcs.constants.EnumGuiType;
|
||||
|
||||
public class BlockBigSign extends BlockContainer{
|
||||
|
||||
|
||||
public int renderId = -1;
|
||||
|
||||
public BlockBigSign() {
|
||||
super(Material.wood);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public int damageDropped(int par1){
|
||||
return par1;
|
||||
}
|
||||
|
||||
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_){
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
@Override
|
||||
public boolean onBlockActivated(World par1World, int i, int j, int k, EntityPlayer player, int par6, float par7, float par8, float par9){
|
||||
if(par1World.isRemote)
|
||||
return false;
|
||||
ItemStack currentItem = player.inventory.getCurrentItem();
|
||||
if (currentItem != null && currentItem.getItem() == CustomItems.wand && CustomNpcsPermissions.hasPermission(player, CustomNpcsPermissions.EDIT_BLOCKS)) {
|
||||
if (currentItem != null && currentItem.getItem() == CustomItems.wand && CustomNpcsPermissions.hasPermission(player, CustomNpcsPermissions.EDIT_BIGSIGN)) {
|
||||
TileBigSign tile = (TileBigSign) par1World.getTileEntity(i, j, k);
|
||||
tile.canEdit = true;
|
||||
NoppesUtilServer.sendOpenGui(player, EnumGuiType.BigSign, null, i, j, k);
|
||||
@@ -52,14 +52,14 @@ public class BlockBigSign extends BlockContainer{
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
@Override
|
||||
public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack){
|
||||
int l = MathHelper.floor_double((double)(par5EntityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
|
||||
l %= 4;
|
||||
|
||||
TileBigSign tile = (TileBigSign) par1World.getTileEntity(par2, par3, par4);
|
||||
tile.rotation = l;
|
||||
|
||||
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, par6ItemStack.getItemDamage() , 2);
|
||||
|
||||
if(par5EntityLivingBase instanceof EntityPlayer && par1World.isRemote){
|
||||
@@ -67,7 +67,7 @@ public class BlockBigSign extends BlockContainer{
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z){
|
||||
TileEntity tileentity = world.getTileEntity(x, y, z);
|
||||
if(!(tileentity instanceof TileColorable)){
|
||||
@@ -91,25 +91,25 @@ public class BlockBigSign extends BlockContainer{
|
||||
setBlockBounds(xStart, 0, zStart, xEnd, 1, zEnd);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public boolean isOpaqueCube(){
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public boolean renderAsNormalBlock(){
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
@Override
|
||||
public int getRenderType(){
|
||||
return renderId;
|
||||
return renderId;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister par1IconRegister)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
|
||||
@@ -20,8 +20,8 @@ public class BlockBook extends BlockRotated{
|
||||
super(Blocks.planks);
|
||||
setBlockBounds(0, 0, 0, 1, 0.2f, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World par1World, int i, int j, int k, EntityPlayer player, int par6, float par7, float par8, float par9){
|
||||
if(par1World.isRemote)
|
||||
return true;
|
||||
@@ -29,14 +29,14 @@ public class BlockBook extends BlockRotated{
|
||||
if(!(tile instanceof TileBook))
|
||||
return false;
|
||||
ItemStack currentItem = player.inventory.getCurrentItem();
|
||||
if (currentItem != null && currentItem.getItem() == CustomItems.wand && CustomNpcsPermissions.hasPermission(player, CustomNpcsPermissions.EDIT_BLOCKS)) {
|
||||
if (currentItem != null && currentItem.getItem() == CustomItems.wand && CustomNpcsPermissions.hasPermission(player, CustomNpcsPermissions.EDIT_BOOK)) {
|
||||
((TileBook)tile).book.func_150996_a(Items.writable_book);
|
||||
}
|
||||
Server.sendData((EntityPlayerMP)player, EnumPacketClient.OPEN_BOOK, i, j, k, ((TileBook)tile).book.writeToNBT(new NBTTagCompound()));
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(){
|
||||
return "item.book";
|
||||
}
|
||||
|
||||
@@ -23,12 +23,12 @@ public class BlockNpcRedstone extends BlockContainer{
|
||||
super(Material.rock);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public boolean onBlockActivated(World par1World, int i, int j, int k, EntityPlayer player, int par6, float par7, float par8, float par9){
|
||||
if(par1World.isRemote)
|
||||
return false;
|
||||
ItemStack currentItem = player.inventory.getCurrentItem();
|
||||
if (currentItem != null && currentItem.getItem() == CustomItems.wand && CustomNpcsPermissions.hasPermission(player, CustomNpcsPermissions.EDIT_BLOCKS)) {
|
||||
if (currentItem != null && currentItem.getItem() == CustomItems.wand && CustomNpcsPermissions.hasPermission(player, CustomNpcsPermissions.EDIT_REDSTONE)) {
|
||||
TileEntity tile = par1World.getTileEntity(i, j, k);
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
tile.writeToNBT(compound);
|
||||
@@ -37,7 +37,7 @@ public class BlockNpcRedstone extends BlockContainer{
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onBlockAdded(World par1World, int par2, int par3, int par4){
|
||||
par1World.notifyBlocksOfNeighborChange(par2, par3, par4, this);
|
||||
@@ -66,24 +66,24 @@ public class BlockNpcRedstone extends BlockContainer{
|
||||
if(isActivated(par1IBlockAccess, par2, par3, par4) > 0)
|
||||
return 0xFF6B68;
|
||||
else
|
||||
return super.colorMultiplier(par1IBlockAccess, par2, par3, par4);
|
||||
return super.colorMultiplier(par1IBlockAccess, par2, par3, par4);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int isProvidingWeakPower(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5){
|
||||
return isActivated(par1IBlockAccess, par2, par3, par4);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int isProvidingStrongPower(IBlockAccess par1World, int par2, int par3, int par4, int par5){
|
||||
return isActivated(par1World, par2, par3, par4);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean canProvidePower(){
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public int isActivated(IBlockAccess par1IBlockAccess, int par2, int par3, int par4){
|
||||
return par1IBlockAccess.getBlockMetadata(par2, par3, par4) == 1?15 : 0;
|
||||
}
|
||||
|
||||
@@ -29,25 +29,25 @@ import noppes.npcs.constants.EnumGuiType;
|
||||
import java.util.List;
|
||||
|
||||
public class BlockTombstone extends BlockContainer{
|
||||
|
||||
|
||||
public int renderId = -1;
|
||||
|
||||
public BlockTombstone() {
|
||||
super(Material.rock);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public int damageDropped(int par1){
|
||||
return par1;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World par1World, int i, int j, int k, EntityPlayer player, int par6, float par7, float par8, float par9){
|
||||
if(par1World.isRemote)
|
||||
return false;
|
||||
ItemStack currentItem = player.inventory.getCurrentItem();
|
||||
if (currentItem != null && currentItem.getItem() == CustomItems.wand && CustomNpcsPermissions.hasPermission(player, CustomNpcsPermissions.EDIT_BLOCKS)) {
|
||||
if (currentItem != null && currentItem.getItem() == CustomItems.wand && CustomNpcsPermissions.hasPermission(player, CustomNpcsPermissions.EDIT_TOMBSTONE)) {
|
||||
TileBigSign tile = (TileBigSign) par1World.getTileEntity(i, j, k);
|
||||
if(tile.getBlockMetadata() >= 2)
|
||||
return false;
|
||||
@@ -57,14 +57,14 @@ public class BlockTombstone extends BlockContainer{
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
@Override
|
||||
public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack){
|
||||
int l = MathHelper.floor_double((double)(par5EntityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
|
||||
l %= 4;
|
||||
|
||||
TileBigSign tile = (TileBigSign) par1World.getTileEntity(par2, par3, par4);
|
||||
tile.rotation = l;
|
||||
|
||||
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, par6ItemStack.getItemDamage() , 2);
|
||||
|
||||
if(par5EntityLivingBase instanceof EntityPlayer && par1World.isRemote && par6ItemStack.getItemDamage() < 2){
|
||||
@@ -76,7 +76,7 @@ public class BlockTombstone extends BlockContainer{
|
||||
return super.getCollisionBoundingBoxFromPool(world, x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z){
|
||||
TileEntity tileentity = world.getTileEntity(x, y, z);
|
||||
if(!(tileentity instanceof TileColorable)){
|
||||
@@ -86,36 +86,36 @@ public class BlockTombstone extends BlockContainer{
|
||||
TileColorable tile = (TileColorable) tileentity;
|
||||
if(tile.rotation % 2 == 0)
|
||||
setBlockBounds(0, 0, 0.3f, 1, 1, 0.7f);
|
||||
else
|
||||
else
|
||||
setBlockBounds(0.3f, 0, 0, 0.7f, 1, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@Override
|
||||
public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List){
|
||||
par3List.add(new ItemStack(par1, 1, 0));
|
||||
par3List.add(new ItemStack(par1, 1, 1));
|
||||
par3List.add(new ItemStack(par1, 1, 2));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public boolean isOpaqueCube(){
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public boolean renderAsNormalBlock(){
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
@Override
|
||||
public int getRenderType(){
|
||||
return renderId;
|
||||
return renderId;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister par1IconRegister)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
|
||||
@@ -24,13 +24,13 @@ public class BlockWaypoint extends BlockContainer{
|
||||
this.setCreativeTab(CustomItems.tab);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public boolean onBlockActivated(World par1World, int i, int j, int k, EntityPlayer player, int par6, float par7, float par8, float par9)
|
||||
{
|
||||
if(par1World.isRemote)
|
||||
return false;
|
||||
ItemStack currentItem = player.inventory.getCurrentItem();
|
||||
if (currentItem != null && currentItem.getItem() == CustomItems.wand && CustomNpcsPermissions.hasPermission(player, CustomNpcsPermissions.EDIT_BLOCKS)) {
|
||||
if (currentItem != null && currentItem.getItem() == CustomItems.wand && CustomNpcsPermissions.hasPermission(player, CustomNpcsPermissions.EDIT_WAYPOINT)) {
|
||||
TileEntity tile = par1World.getTileEntity(i, j, k);
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
tile.writeToNBT(compound);
|
||||
@@ -39,14 +39,14 @@ public class BlockWaypoint extends BlockContainer{
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy(World world, int i, int j, int k, EntityLivingBase entityliving, ItemStack item){
|
||||
if(entityliving instanceof EntityPlayer && world.isRemote){
|
||||
CustomNpcs.proxy.openGui(i, j, k, EnumGuiType.Waypoint, (EntityPlayer) entityliving);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World var1, int var2) {
|
||||
return new TileWaypoint();
|
||||
|
||||
@@ -3,29 +3,13 @@ package noppes.npcs.blocks.tiles;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public class TileBlockAnvil extends TileEntity {
|
||||
|
||||
|
||||
public TileBlockAnvil(){
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public boolean canUpdate(){
|
||||
return false;
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public void updateEntity(){
|
||||
//
|
||||
// }
|
||||
|
||||
// @Override
|
||||
// public void readFromNBT(NBTTagCompound par1NBTTagCompound)
|
||||
// {
|
||||
// super.readFromNBT(par1NBTTagCompound);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void writeToNBT(NBTTagCompound par1NBTTagCompound)
|
||||
// {
|
||||
// super.writeToNBT(par1NBTTagCompound);
|
||||
// }
|
||||
|
||||
}
|
||||
@@ -43,6 +43,12 @@ public class ClientCacheHandler {
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isCachedNPC(ResourceLocation resource) {
|
||||
synchronized (imageDataCache) {
|
||||
return imageDataCache.containsKey(resource.getResourcePath());
|
||||
}
|
||||
}
|
||||
|
||||
public static void clearCache() {
|
||||
ClientCacheHandler.imageDataCache.clear();
|
||||
ClientCacheHandler.animationCache.clear();
|
||||
|
||||
@@ -15,11 +15,14 @@ import net.minecraftforge.client.event.RenderLivingEvent;
|
||||
import net.minecraftforge.client.event.RenderPlayerEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingEvent;
|
||||
import noppes.npcs.client.gui.customoverlay.OverlayCustom;
|
||||
import noppes.npcs.client.renderer.MarkRenderer;
|
||||
import noppes.npcs.client.renderer.RenderCNPCPlayer;
|
||||
import noppes.npcs.constants.EnumAnimationPart;
|
||||
import noppes.npcs.constants.MarkType;
|
||||
import noppes.npcs.controllers.data.Animation;
|
||||
import noppes.npcs.controllers.data.AnimationData;
|
||||
import noppes.npcs.controllers.data.FramePart;
|
||||
import noppes.npcs.controllers.data.MarkData;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
@@ -93,6 +96,16 @@ public class ClientEventHandler {
|
||||
AnimationData data = null;
|
||||
if (event.entity instanceof EntityNPCInterface) {
|
||||
data = ClientEventHandler.renderingNpc.display.animationData;
|
||||
|
||||
MarkData markData = MarkData.get((EntityNPCInterface) event.entity);
|
||||
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
|
||||
for(MarkData.Mark m : markData.marks){
|
||||
if(m.getType() != MarkType.NONE && m.availability.isAvailable(player)){
|
||||
MarkRenderer.render(event.entity, event.x, event.y, event.z, m);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
} else if (event.entity instanceof EntityPlayer) {
|
||||
if (ClientCacheHandler.playerAnimations.containsKey(event.entity.getUniqueID())) {
|
||||
data = ClientCacheHandler.playerAnimations.get(event.entity.getUniqueID());
|
||||
@@ -118,6 +131,7 @@ public class ClientEventHandler {
|
||||
animation.increaseTime();
|
||||
}
|
||||
}
|
||||
|
||||
ClientEventHandler.renderingNpc = null;
|
||||
}
|
||||
|
||||
|
||||
@@ -382,6 +382,9 @@ public class ClientProxy extends CommonProxy {
|
||||
else if (gui == EnumGuiType.ScriptBlock)
|
||||
return new GuiScriptBlock(x,y,z);
|
||||
|
||||
else if (gui == EnumGuiType.GlobalRemote)
|
||||
return new GuiNPCGlobalMainMenu(null);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -124,13 +124,21 @@ public class ImageDownloadAlt extends SimpleTexture
|
||||
|
||||
try
|
||||
{
|
||||
connection = (HttpURLConnection)(new URL(ImageDownloadAlt.this.imageUrl)).openConnection(Minecraft.getMinecraft().getProxy());
|
||||
URL url = new URL(ImageDownloadAlt.this.imageUrl);
|
||||
connection = (HttpURLConnection)(url).openConnection(Minecraft.getMinecraft().getProxy());
|
||||
connection.setDoInput(true);
|
||||
connection.setDoOutput(false);
|
||||
connection.setRequestProperty("Content-Type", "image/png");
|
||||
connection.setRequestProperty("Expect", "100-continue");
|
||||
//connection.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 5.1; rv:19.0) Gecko/20100101 Firefox/19.0");
|
||||
connection.setRequestProperty("User-Agent", "Mozilla/5.0");
|
||||
|
||||
// Set user agent
|
||||
if (isImgurLink(url)) {
|
||||
connection.setRequestProperty("User-Agent", "Mozilla/5.0 (compatible; Yahoo! Slurp; http://help.yahoo.com/help/us/ysearch/slurp)");
|
||||
}
|
||||
else {
|
||||
connection.setRequestProperty("User-Agent", "Mozilla/5.0");
|
||||
}
|
||||
connection.connect();
|
||||
|
||||
if (connection.getResponseCode() / 100 != 2)
|
||||
@@ -175,4 +183,9 @@ public class ImageDownloadAlt extends SimpleTexture
|
||||
this.imageThread.setDaemon(true);
|
||||
this.imageThread.start();
|
||||
}
|
||||
|
||||
// Check if the URL is an Imgur link
|
||||
private static boolean isImgurLink(URL url) {
|
||||
return url.getHost().endsWith("imgur.com");
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.achievement.GuiAchievement;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -35,6 +36,7 @@ import noppes.npcs.constants.EnumPacketServer;
|
||||
import noppes.npcs.controllers.RecipeController;
|
||||
import noppes.npcs.controllers.data.Animation;
|
||||
import noppes.npcs.controllers.data.AnimationData;
|
||||
import noppes.npcs.controllers.data.MarkData;
|
||||
import noppes.npcs.controllers.data.RecipeCarpentry;
|
||||
import noppes.npcs.entity.EntityDialogNpc;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
@@ -103,6 +105,13 @@ public class PacketHandlerClient extends PacketHandlerServer{
|
||||
RecipeController.Instance.anvilRecipes = RecipeController.syncRecipes;
|
||||
RecipeController.syncRecipes = new HashMap<Integer, RecipeCarpentry>();
|
||||
}
|
||||
else if(type == EnumPacketClient.MARK_DATA){
|
||||
Entity entity = Minecraft.getMinecraft().theWorld.getEntityByID(buffer.readInt());
|
||||
if(!(entity instanceof EntityNPCInterface))
|
||||
return;
|
||||
MarkData data = MarkData.get((EntityNPCInterface) entity);
|
||||
data.setNBT(Server.readNBT(buffer));
|
||||
}
|
||||
else if(type == EnumPacketClient.DIALOG){
|
||||
Entity entity = Minecraft.getMinecraft().theWorld.getEntityByID(buffer.readInt());
|
||||
if(entity == null || !(entity instanceof EntityNPCInterface))
|
||||
@@ -195,6 +204,15 @@ public class PacketHandlerClient extends PacketHandlerServer{
|
||||
NBTTagCompound compound = Server.readNBT(buffer);
|
||||
NoppesUtil.openGUI(player, new GuiNpcMobSpawnerAdd(compound));
|
||||
}
|
||||
else if(type == EnumPacketClient.CLONER){
|
||||
int x = buffer.readInt();
|
||||
int y = buffer.readInt();
|
||||
int z = buffer.readInt();
|
||||
CustomNpcs.proxy.openGui(x, y, z, EnumGuiType.MobSpawner, player);
|
||||
}
|
||||
else if(type == EnumPacketClient.TELEPORTER){
|
||||
CustomNpcs.proxy.openGui((EntityNPCInterface)null,EnumGuiType.NpcDimensions);
|
||||
}
|
||||
else if(type == EnumPacketClient.GUI_DATA){
|
||||
GuiScreen gui = Minecraft.getMinecraft().currentScreen;
|
||||
if(gui == null)
|
||||
@@ -318,21 +336,19 @@ public class PacketHandlerClient extends PacketHandlerServer{
|
||||
}
|
||||
|
||||
if (animationData != null) {
|
||||
animationData.readFromNBT(compound);
|
||||
int animationId;
|
||||
if (compound.hasKey("AnimationID")) {
|
||||
animationId = compound.getInteger("AnimationID");
|
||||
} else {
|
||||
Animation animation = new Animation();
|
||||
animation.readFromNBT(compound.getCompoundTag("Animation"));
|
||||
ClientCacheHandler.animationCache.put(animation.getID(), animation);
|
||||
animationId = animation.getID();
|
||||
}
|
||||
int animationId;
|
||||
if (compound.hasKey("AnimationID")) {
|
||||
animationId = compound.getInteger("AnimationID");
|
||||
} else {
|
||||
Animation animation = new Animation();
|
||||
animation.readFromNBT(compound.getCompoundTag("Animation"));
|
||||
ClientCacheHandler.animationCache.put(animation.getID(), animation);
|
||||
animationId = animation.getID();
|
||||
}
|
||||
|
||||
if (animationData.allowAnimation) {
|
||||
animationData.setAnimation(ClientCacheHandler.animationCache.get(animationId));
|
||||
Client.sendData(EnumPacketServer.CacheAnimation, animationId);
|
||||
}
|
||||
animationData.setAnimation(ClientCacheHandler.animationCache.get(animationId));
|
||||
animationData.readFromNBT(compound);
|
||||
Client.sendData(EnumPacketServer.CacheAnimation, animationId);
|
||||
}
|
||||
}
|
||||
else if(type == EnumPacketClient.DISABLE_MOUSE_INPUT) {
|
||||
|
||||
@@ -1,28 +1,25 @@
|
||||
package noppes.npcs.client.controllers;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.audio.ISound;
|
||||
import net.minecraft.client.audio.PositionedSoundRecord;
|
||||
import net.minecraft.client.audio.SoundCategory;
|
||||
import net.minecraft.client.audio.SoundHandler;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
|
||||
public class MusicController {
|
||||
//public TreeSet<String> sounds = new TreeSet<String>();
|
||||
//public TreeSet<String> music = new TreeSet<String>();
|
||||
|
||||
|
||||
public static MusicController Instance;
|
||||
public PositionedSoundRecord playing;
|
||||
public ResourceLocation playingResource;
|
||||
public Entity playingEntity;
|
||||
|
||||
//private SoundPoolEntry musicPool;
|
||||
|
||||
public MusicController(){
|
||||
Instance = this;
|
||||
}
|
||||
|
||||
|
||||
public void stopMusic(){
|
||||
SoundHandler handler = Minecraft.getMinecraft().getSoundHandler();
|
||||
if(playing != null)
|
||||
@@ -32,9 +29,9 @@ public class MusicController {
|
||||
playingEntity = null;
|
||||
playing = null;
|
||||
}
|
||||
|
||||
|
||||
public void playStreaming(String music, Entity entity){
|
||||
if(isPlaying(music)){
|
||||
if(isPlaying(music)){
|
||||
return;
|
||||
}
|
||||
stopMusic();
|
||||
@@ -57,7 +54,7 @@ public class MusicController {
|
||||
playing = PositionedSoundRecord.func_147673_a(playingResource);
|
||||
handler.playSound(playing);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public boolean isPlaying(String music) {
|
||||
ResourceLocation resource = new ResourceLocation(music);
|
||||
@@ -66,7 +63,7 @@ public class MusicController {
|
||||
}
|
||||
return Minecraft.getMinecraft().getSoundHandler().isSoundPlaying(playing);
|
||||
}
|
||||
|
||||
|
||||
public void playSound(String music, float x, float y, float z) {
|
||||
Minecraft.getMinecraft().theWorld.playSound(x, y, z, music, 1, 1, false);
|
||||
}
|
||||
|
||||
@@ -26,15 +26,15 @@ public class GuiNPCDialogSelection extends GuiNPCInterface implements IScrollDat
|
||||
title = "Select Dialog Category";
|
||||
this.parent = parent;
|
||||
this.dialog = dialog;
|
||||
|
||||
|
||||
|
||||
|
||||
if(dialog >= 0){
|
||||
Client.sendData(EnumPacketServer.DialogsGetFromDialog, dialog);
|
||||
selectCategory = false;
|
||||
title = "Select Dialog";
|
||||
}else
|
||||
Client.sendData(EnumPacketServer.DialogCategoriesGet, dialog);
|
||||
|
||||
|
||||
if(parent instanceof GuiSelectionListener){
|
||||
listener = (GuiSelectionListener) parent;
|
||||
}
|
||||
@@ -48,7 +48,6 @@ public class GuiNPCDialogSelection extends GuiNPCInterface implements IScrollDat
|
||||
slot = new GuiNPCStringSlot(list,this,false,18);
|
||||
slot.registerScrollButtons(4, 5);
|
||||
|
||||
|
||||
this.addButton(new GuiNpcButton(2, width / 2 -100, height - 41,98, 20, "gui.back"));
|
||||
this.addButton(new GuiNpcButton(4, width / 2 + 2, height - 41,98, 20, "gui.select"));
|
||||
}
|
||||
@@ -92,7 +91,7 @@ public class GuiNPCDialogSelection extends GuiNPCInterface implements IScrollDat
|
||||
close();
|
||||
NoppesUtil.openGUI(player, parent);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
public void save() {
|
||||
if(dialog >= 0){
|
||||
@@ -113,7 +112,7 @@ public class GuiNPCDialogSelection extends GuiNPCInterface implements IScrollDat
|
||||
|
||||
@Override
|
||||
public void setSelected(String selected) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ import java.util.HashMap;
|
||||
import java.util.Vector;
|
||||
|
||||
public class GuiNpcRemoteEditor extends GuiNPCInterface implements IScrollData, GuiYesNoCallback{
|
||||
|
||||
|
||||
private GuiCustomScroll scroll;
|
||||
private HashMap<String, Integer> data = new HashMap<String, Integer>();
|
||||
public GuiNpcRemoteEditor() {
|
||||
@@ -35,10 +35,10 @@ public class GuiNpcRemoteEditor extends GuiNPCInterface implements IScrollData,
|
||||
scroll.guiLeft = guiLeft + 4;
|
||||
scroll.guiTop = guiTop + 4;
|
||||
addScroll(scroll);
|
||||
|
||||
|
||||
String title = StatCollector.translateToLocal("remote.title");
|
||||
int x = (xSize - this.fontRendererObj.getStringWidth(title)) / 2;
|
||||
|
||||
|
||||
this.addLabel(new GuiNpcLabel(0, title, guiLeft + x, guiTop - 8));
|
||||
|
||||
this.addButton(new GuiNpcButton(0, guiLeft + 170, guiTop + 6,82,20, "selectServer.edit"));
|
||||
@@ -73,12 +73,12 @@ public class GuiNpcRemoteEditor extends GuiNPCInterface implements IScrollData,
|
||||
}
|
||||
if(id == 6){
|
||||
NoppesUtil.setLastNpc(null);
|
||||
NoppesUtil.openGUI(player, new GuiNPCGlobalMainMenu(null));
|
||||
Client.sendData(EnumPacketServer.RemoteGlobalMenu);
|
||||
}
|
||||
|
||||
|
||||
if(!data.containsKey(scroll.getSelected()))
|
||||
return;
|
||||
|
||||
|
||||
if(id == 0){
|
||||
Client.sendData(EnumPacketServer.RemoteMainMenu,data.get(scroll.getSelected()));
|
||||
}
|
||||
@@ -97,7 +97,7 @@ public class GuiNpcRemoteEditor extends GuiNPCInterface implements IScrollData,
|
||||
close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void mouseClicked(int i, int j, int k)
|
||||
{
|
||||
@@ -115,7 +115,7 @@ public class GuiNpcRemoteEditor extends GuiNPCInterface implements IScrollData,
|
||||
@Override
|
||||
public void save() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
|
||||
}
|
||||
@Override
|
||||
public void setData(Vector<String> list, HashMap<String, Integer> data) {
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
package noppes.npcs.client.gui;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import noppes.npcs.client.gui.util.*;
|
||||
import noppes.npcs.controllers.data.CustomTintData;
|
||||
|
||||
public class SubGuiNpcTint extends SubGuiInterface implements ISubGuiListener, ITextfieldListener {
|
||||
private CustomTintData tintData;
|
||||
private int lastColorClicked = -1;
|
||||
|
||||
public SubGuiNpcTint(CustomTintData tintData) {
|
||||
this.tintData = tintData;
|
||||
setBackground("menubg.png");
|
||||
xSize = 256;
|
||||
ySize = 216;
|
||||
closeOnEsc = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
int y = 30;
|
||||
addLabel(new GuiNpcLabel(0, "tint.enable", guiLeft + 5, guiTop + y + 5));
|
||||
addButton(new GuiNpcButtonYesNo(0, guiLeft + 122, guiTop + y, 56, 20, tintData.isTintEnabled()));
|
||||
y+=22;
|
||||
if (tintData.isTintEnabled()) {
|
||||
addLabel(new GuiNpcLabel(1, "tint.enablegeneral", guiLeft + 5, guiTop + y + 5));
|
||||
addButton(new GuiNpcButtonYesNo(1, guiLeft + 122, guiTop + y, 56, 20, tintData.isGeneralTintEnabled()));
|
||||
y+=22;
|
||||
if(tintData.isGeneralTintEnabled()) {
|
||||
String color = Integer.toHexString(tintData.getGeneralTint());
|
||||
while (color.length() < 6) color = 0 + color;
|
||||
addLabel(new GuiNpcLabel(2, "tint.tint", guiLeft + 4, guiTop + y + 5));
|
||||
addButton(new GuiNpcButton(2, guiLeft + 122, guiTop + y, 60, 20, color));
|
||||
getButton(2).setTextColor(tintData.getGeneralTint());
|
||||
y+=22;
|
||||
addLabel(new GuiNpcLabel(3,"tint.alpha", guiLeft + 5, guiTop + y + 5));
|
||||
addTextField(new GuiNpcTextField(3,this, fontRendererObj, guiLeft + 122, guiTop + y, 60, 20, tintData.getGeneralAlpha() + ""));
|
||||
getTextField(3).integersOnly = true;
|
||||
getTextField(3).setMinMaxDefault(1, 100, 40);
|
||||
y+=22;
|
||||
}
|
||||
addLabel(new GuiNpcLabel(4, "tint.enablehurt", guiLeft + 5, guiTop + y + 5));
|
||||
addButton(new GuiNpcButtonYesNo(4, guiLeft + 122, guiTop + y, 56, 20, tintData.isHurtTintEnabled()));
|
||||
y+=22;
|
||||
if (tintData.isHurtTintEnabled()) {
|
||||
String color2 = Integer.toHexString(tintData.getHurtTint());
|
||||
while (color2.length() < 6) color2 = 0 + color2;
|
||||
addLabel(new GuiNpcLabel(5, "tint.hurt", guiLeft + 4, guiTop + y + 5));
|
||||
addButton(new GuiNpcButton(5, guiLeft + 122, guiTop + y, 60, 20, color2));
|
||||
getButton(5).setTextColor(tintData.getHurtTint());
|
||||
}
|
||||
}
|
||||
addButton(new GuiNpcButton(66, guiLeft + 82, guiTop + 190, 98, 20, "gui.done"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton guibutton) {
|
||||
int id = guibutton.id;
|
||||
GuiNpcButton button = (GuiNpcButton) guibutton;
|
||||
if (id == 0) {
|
||||
tintData.setTintEnabled(((GuiNpcButtonYesNo) button).getBoolean());
|
||||
initGui();
|
||||
}
|
||||
if (id == 1) {
|
||||
tintData.setGeneralTintEnabled(((GuiNpcButtonYesNo) button).getBoolean());
|
||||
initGui();
|
||||
}
|
||||
if (id == 4) {
|
||||
tintData.setHurtTintEnabled(((GuiNpcButtonYesNo) button).getBoolean());
|
||||
initGui();
|
||||
}
|
||||
if (button.id == 2) {
|
||||
setSubGui(new SubGuiColorSelector(tintData.getGeneralTint()));
|
||||
lastColorClicked = 0;
|
||||
}
|
||||
if (button.id == 5) {
|
||||
setSubGui(new SubGuiColorSelector(tintData.getHurtTint()));
|
||||
lastColorClicked = 1;
|
||||
}
|
||||
if (id == 66) {
|
||||
close();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void subGuiClosed(SubGuiInterface subgui) {
|
||||
if (lastColorClicked == 0) {
|
||||
tintData.setGeneralTint(((SubGuiColorSelector) subgui).color);
|
||||
} else if (lastColorClicked == 1) {
|
||||
tintData.setHurtTint(((SubGuiColorSelector) subgui).color);
|
||||
}
|
||||
initGui();
|
||||
save();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unFocused(GuiNpcTextField textfield) {
|
||||
if(textfield.id==3){
|
||||
tintData.setGeneralAlpha(textfield.getInteger());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
package noppes.npcs.client.gui.advanced;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import noppes.npcs.client.Client;
|
||||
import noppes.npcs.client.gui.SubGuiColorSelector;
|
||||
import noppes.npcs.client.gui.SubGuiNpcAvailability;
|
||||
import noppes.npcs.client.gui.util.*;
|
||||
import noppes.npcs.constants.EnumPacketServer;
|
||||
import noppes.npcs.constants.MarkType;
|
||||
import noppes.npcs.controllers.data.MarkData;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
public class GuiNPCMarks extends GuiNPCInterface2 implements ISubGuiListener {
|
||||
private final String[] marks = new String[]{"gui.none", "mark.question", "mark.exclamation", "mark.pointer", "mark.skull", "mark.cross", "mark.star"};
|
||||
private MarkData data;
|
||||
private MarkData.Mark selectedMark;
|
||||
|
||||
public GuiNPCMarks(EntityNPCInterface npc){
|
||||
super(npc);
|
||||
this.data = MarkData.get(npc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui(){
|
||||
super.initGui();
|
||||
int y = guiTop + 14;
|
||||
for(int i = 0; i < data.marks.size(); i++){
|
||||
MarkData.Mark mark = data.marks.get(i);
|
||||
this.addButton(new GuiButtonBiDirectional(1 + i * 10, guiLeft + 6, y, 120, 20, marks, mark.type));
|
||||
|
||||
String color = Integer.toHexString(mark.color);
|
||||
while(color.length() < 6)
|
||||
color = "0" + color;
|
||||
addButton(new GuiNpcButton(2 + i * 10, guiLeft + 128, y, 60, 20, color));
|
||||
getButton(2 + i * 10).setTextColor(mark.color);
|
||||
|
||||
this.addButton(new GuiNpcButton(3 + i * 10, guiLeft + 190, y, 120, 20, "availability.options"));
|
||||
this.addButton(new GuiNpcButton(4 + i * 10, guiLeft + 312, y, 40, 20, "X"));
|
||||
y += 22;
|
||||
}
|
||||
|
||||
if(data.marks.size() < 9){
|
||||
this.addButton(new GuiNpcButton(101 , guiLeft + 6, y + 2, 60, 20, "gui.add"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buttonEvent(GuiButton button){
|
||||
if(button.id < 90){
|
||||
selectedMark = data.marks.get(button.id / 10);
|
||||
if(button.id % 10 == 1){
|
||||
selectedMark.type = ((GuiNpcButton)button).getValue();
|
||||
}
|
||||
if(button.id % 10 == 2){
|
||||
this.setSubGui(new SubGuiColorSelector(selectedMark.color));
|
||||
}
|
||||
if(button.id % 10 == 3){
|
||||
setSubGui(new SubGuiNpcAvailability(selectedMark.availability));
|
||||
}
|
||||
if(button.id % 10 == 4){
|
||||
data.marks.remove(selectedMark);
|
||||
initGui();
|
||||
}
|
||||
}
|
||||
if(button.id == 101){
|
||||
data.addMark(MarkType.NONE);
|
||||
initGui();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void subGuiClosed(SubGuiInterface subgui) {
|
||||
if(subgui instanceof SubGuiColorSelector){
|
||||
selectedMark.color = ((SubGuiColorSelector)subgui).color;
|
||||
initGui();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
Client.sendData(EnumPacketServer.MainmenuAdvancedMarkData, data.getNBT());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -169,7 +169,7 @@ public class GuiNpcManagePlayerData extends GuiNPCInterface2 implements IScrollD
|
||||
@Override
|
||||
public void confirmClicked(boolean confirm, int id){
|
||||
if(confirm){
|
||||
Client.sendData(EnumPacketServer.PlayerDataRegen);
|
||||
Client.sendData(EnumPacketServer.PlayerDataMapRegen);
|
||||
close();
|
||||
}
|
||||
else
|
||||
|
||||
@@ -28,24 +28,26 @@ public class GuiNpcAdvanced extends GuiNPCInterface2 implements IGuiData
|
||||
public void initGui(){
|
||||
super.initGui();
|
||||
int y = guiTop + 10;
|
||||
int gap = 21;
|
||||
this.addButton(new GuiNpcButton(3, guiLeft + 85 + 160, y, 52, 20, "selectServer.edit"));
|
||||
this.addButton(new GuiNpcButton(8, guiLeft + 85, y,155,20, new String[]{"role.none","role.trader","role.follower","role.bank","role.transporter", "role.mailman", NoppesStringUtils.translate("role.companion", "(WIP)")},npc.advanced.role.ordinal()));
|
||||
getButton(3).setEnabled(npc.advanced.role != EnumRoleType.None && npc.advanced.role != EnumRoleType.Postman);
|
||||
|
||||
this.addButton(new GuiNpcButton(4, guiLeft + 85 + 160, y += gap, 52, 20, "selectServer.edit"));
|
||||
this.addButton(new GuiNpcButton(4, guiLeft + 85 + 160, y += 22, 52, 20, "selectServer.edit"));
|
||||
this.addButton(new GuiNpcButton(5, guiLeft + 85, y,155,20, new String[]{"job.none","job.bard","job.healer","job.guard","job.itemgiver","role.follower", "job.spawner", "job.conversation", "job.chunkloader"},npc.advanced.job.ordinal()));
|
||||
|
||||
getButton(4).setEnabled(npc.advanced.job != EnumJobType.None && npc.advanced.job != EnumJobType.ChunkLoader);
|
||||
|
||||
this.addButton(new GuiNpcButton(7, guiLeft + 85, y += gap, 214, 20, "advanced.lines"));
|
||||
this.addButton(new GuiNpcButton(9, guiLeft + 85, y += gap, 214, 20, "menu.factions"));
|
||||
this.addButton(new GuiNpcButton(10, guiLeft + 85, y += gap, 214, 20, "dialog.dialogs"));
|
||||
this.addButton(new GuiNpcButton(11, guiLeft + 85, y += gap, 214, 20, "advanced.sounds"));
|
||||
this.addButton(new GuiNpcButton(12, guiLeft + 85, y += gap, 214, 20, "advanced.night"));
|
||||
this.addButton(new GuiNpcButton(13, guiLeft + 85, y += gap, 214, 20, "global.linked"));
|
||||
this.addButton(new GuiNpcButton(14, guiLeft + 85, y += gap, 214, 20, "menu.tags"));
|
||||
|
||||
this.addButton(new GuiNpcButton(7, guiLeft + 15, y += 22, 190, 20, "advanced.lines"));
|
||||
this.addButton(new GuiNpcButton(9, guiLeft + 208, y, 190, 20, "menu.factions"));
|
||||
|
||||
this.addButton(new GuiNpcButton(10, guiLeft + 15, y += 22, 190, 20, "dialog.dialogs"));
|
||||
this.addButton(new GuiNpcButton(11, guiLeft + 208, y, 190, 20, "advanced.sounds"));
|
||||
|
||||
this.addButton(new GuiNpcButton(12, guiLeft + 15, y += 22, 190, 20, "advanced.night"));
|
||||
this.addButton(new GuiNpcButton(13, guiLeft + 208, y, 190, 20, "global.linked"));
|
||||
|
||||
this.addButton(new GuiNpcButton(14, guiLeft + 15, y += 22, 190, 20, "menu.tags"));
|
||||
this.addButton(new GuiNpcButton(15, guiLeft + 208, y, 190, 20, "advanced.marks"));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -68,7 +70,7 @@ public class GuiNpcAdvanced extends GuiNPCInterface2 implements IGuiData
|
||||
if(button.id == 5){
|
||||
hasChanges = true;
|
||||
npc.advanced.setJob(button.getValue());
|
||||
|
||||
|
||||
getButton(4).setEnabled(npc.advanced.job != EnumJobType.None && npc.advanced.job != EnumJobType.ChunkLoader);
|
||||
}
|
||||
if(button.id == 9){
|
||||
@@ -99,6 +101,10 @@ public class GuiNpcAdvanced extends GuiNPCInterface2 implements IGuiData
|
||||
save();
|
||||
NoppesUtil.openGUI(player, new GuiNPCTagSetup(npc));
|
||||
}
|
||||
if(button.id == 15){
|
||||
save();
|
||||
NoppesUtil.openGUI(player, new GuiNPCMarks(npc));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -106,7 +112,7 @@ public class GuiNpcAdvanced extends GuiNPCInterface2 implements IGuiData
|
||||
if(compound.hasKey("RoleData")){
|
||||
if(npc.roleInterface != null)
|
||||
npc.roleInterface.readFromNBT(compound);
|
||||
|
||||
|
||||
if(npc.advanced.role == EnumRoleType.Trader)
|
||||
NoppesUtil.requestOpenGUI(EnumGuiType.SetupTrader);
|
||||
else if(npc.advanced.role == EnumRoleType.Follower)
|
||||
@@ -121,7 +127,7 @@ public class GuiNpcAdvanced extends GuiNPCInterface2 implements IGuiData
|
||||
else if(compound.hasKey("JobData")){
|
||||
if(npc.jobInterface != null)
|
||||
npc.jobInterface.readFromNBT(compound);
|
||||
|
||||
|
||||
if(npc.advanced.job == EnumJobType.Bard)
|
||||
NoppesUtil.openGUI(player, new GuiNpcBard(npc));
|
||||
else if(npc.advanced.job == EnumJobType.Healer)
|
||||
@@ -142,7 +148,7 @@ public class GuiNpcAdvanced extends GuiNPCInterface2 implements IGuiData
|
||||
initGui();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
if(hasChanges){
|
||||
@@ -150,6 +156,6 @@ public class GuiNpcAdvanced extends GuiNPCInterface2 implements IGuiData
|
||||
hasChanges = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -80,19 +80,20 @@ public class GuiNpcDisplay extends GuiNPCInterface2 implements ITextfieldListene
|
||||
addLabel(new GuiNpcLabel(5,"display.livingAnimation", guiLeft + 5, y + 5));
|
||||
this.addButton(new GuiNpcButton(5, guiLeft + 120, y, 50, 20, new String[]{"gui.yes","gui.no"}, display.disableLivingAnimation?1:0));
|
||||
|
||||
addLabel(new GuiNpcLabel(6,"Collides With Entities", guiLeft + 185, y + 5));
|
||||
addLabel(new GuiNpcLabel(6,"display.collides", guiLeft + 185, y + 5));
|
||||
this.addButton(new GuiNpcButton(6, guiLeft + 300, y, 100, 20, new String[]{"gui.yes","gui.no","Only CNPCs","Only Players","CNPCs & Players"}, display.collidesWith));
|
||||
|
||||
y+=23;
|
||||
addLabel(new GuiNpcLabel(7,"display.visible", guiLeft + 5, y + 5));
|
||||
this.addButton(new GuiNpcButton(7, guiLeft + 120, y, 50, 20, new String[]{"gui.yes","gui.no","gui.partly"}, display.visible));
|
||||
this.addButton(new GuiNpcButton(13, guiLeft + 185, y , 100, 20, "display.tintsettings"));
|
||||
this.addButton(new GuiNpcButton(12,guiLeft + 300, y, 100, 20, "display.hitbox"));
|
||||
|
||||
y+=23;
|
||||
addLabel(new GuiNpcLabel(10,"display.bossbar", guiLeft + 5, y + 5));
|
||||
this.addButton(new GuiNpcButton(10, guiLeft + 120, y, 110, 20, new String[]{"display.hide","display.show","display.showAttacking"}, display.showBossBar));
|
||||
addButton(new GuiNpcButton(12,guiLeft + 290, y, 56, 20, "selectServer.edit"));
|
||||
addLabel(new GuiNpcLabel(12,"Hitbox", guiLeft + 240, y + 5));
|
||||
GeckoAddonClient.Instance.geckoNpcDisplayInitGui(this);
|
||||
this.addButton(new GuiNpcButton(10, guiLeft + 60, y, 110, 20, new String[]{"display.hide","display.show","display.showAttacking"}, display.showBossBar));
|
||||
|
||||
GeckoAddonClient.Instance.geckoNpcDisplayInitGui(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -182,9 +183,12 @@ public class GuiNpcDisplay extends GuiNPCInterface2 implements ITextfieldListene
|
||||
npc.display.skinOverlayData.overlayList.get(0).setBlend(button.getValue() == 0);
|
||||
initGui();
|
||||
}
|
||||
else if (button.id == 12){
|
||||
setSubGui(new SubGuiCustomHitbox(display.customHitboxData));
|
||||
}
|
||||
else if (button.id == 12){
|
||||
setSubGui(new SubGuiCustomHitbox(display.customHitboxData));
|
||||
}
|
||||
else if (button.id == 13){
|
||||
setSubGui(new SubGuiNpcTint(display.customTintData));
|
||||
}
|
||||
else if(button.id == 14){
|
||||
String name = display.getRandomName();
|
||||
display.setName(name);
|
||||
|
||||
@@ -26,9 +26,6 @@ public class GuiCNPCInventory extends GuiNPCInterface {
|
||||
super.initGui();
|
||||
guiTop +=10;
|
||||
|
||||
TabRegistry.addTabsToList(buttonList);
|
||||
TabRegistry.updateTabValues(guiLeft, guiTop, InventoryTabCustomNpc.class);
|
||||
|
||||
GuiMenuSideButton questsButton = new GuiMenuSideButton(100, guiLeft + xSize + 37, this.guiTop + 3, 22, 22, "");
|
||||
questsButton.rightSided = true;
|
||||
questsButton.active = activeTab == 0;
|
||||
@@ -40,7 +37,7 @@ public class GuiCNPCInventory extends GuiNPCInterface {
|
||||
partyButton.active = activeTab == 1;
|
||||
partyButton.renderStack = new ItemStack(CustomItems.bag);
|
||||
addButton(partyButton);
|
||||
|
||||
|
||||
if(ConfigClient.enableFactionTab){
|
||||
GuiMenuSideButton factionButton = new GuiMenuSideButton(102, guiLeft + xSize + 37, this.guiTop + 3 + 21*2, 22, 22, "");
|
||||
factionButton.rightSided = true;
|
||||
|
||||
@@ -22,7 +22,7 @@ import java.util.ArrayList;
|
||||
public class GuiFaction extends GuiCNPCInventory implements IGuiData{
|
||||
|
||||
private final ResourceLocation resource = new ResourceLocation("customnpcs","textures/gui/standardbg.png");
|
||||
|
||||
|
||||
private ArrayList<Faction> playerFactions = new ArrayList<Faction>();
|
||||
private Minecraft mc = Minecraft.getMinecraft();
|
||||
|
||||
@@ -46,8 +46,8 @@ public class GuiFaction extends GuiCNPCInventory implements IGuiData{
|
||||
public void initGui()
|
||||
{
|
||||
super.initGui();
|
||||
TabRegistry.addTabsToList(buttonList);
|
||||
TabRegistry.updateTabValues(guiLeft, guiTop, InventoryTabCustomNpc.class);
|
||||
TabRegistry.addTabsToList(buttonList);
|
||||
TabRegistry.updateTabValues(guiLeft, guiTop, InventoryTabCustomNpc.class);
|
||||
|
||||
this.buttonList.add(buttonNextPage = new GuiButtonNextPage(1, (guiLeft + (xSize + 35) / 2) + 25, guiTop + 170, true));
|
||||
this.buttonList.add(buttonPreviousPage = new GuiButtonNextPage(2, (guiLeft + (xSize + 35) / 2) - 40, guiTop + 170, false));
|
||||
@@ -62,16 +62,16 @@ public class GuiFaction extends GuiCNPCInventory implements IGuiData{
|
||||
mc.renderEngine.bindTexture(resource);
|
||||
drawTexturedModalRect(guiLeft, guiTop, 0, 0, 252, 195);
|
||||
drawTexturedModalRect(guiLeft + 252, guiTop, 188, 0, 67, 195);
|
||||
|
||||
|
||||
if(playerFactions.isEmpty()){
|
||||
String noFaction = StatCollector.translateToLocal("faction.nostanding");
|
||||
fontRendererObj.drawString(noFaction,guiLeft + (xSize - fontRendererObj.getStringWidth(noFaction)) / 2,guiTop + 80, CustomNpcResourceListener.DefaultTextColor);
|
||||
}
|
||||
else
|
||||
renderScreen();
|
||||
|
||||
|
||||
super.drawScreen(i, j, f);
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void renderScreen(){
|
||||
@@ -131,21 +131,21 @@ public class GuiFaction extends GuiCNPCInventory implements IGuiData{
|
||||
fontRendererObj.drawString(s, guiLeft + (xSize + 45 - fontRendererObj.getStringWidth(s)) / 2, guiTop + 175, CustomNpcResourceListener.DefaultTextColor);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton guibutton){
|
||||
if (guibutton.id >= 100) {
|
||||
if (guibutton.id == 100 && activeTab != 0) {
|
||||
activeTab = 0;
|
||||
mc.displayGuiScreen(new GuiQuestLog(mc.thePlayer));
|
||||
mc.displayGuiScreen(new GuiQuestLog(mc.thePlayer));
|
||||
}
|
||||
if (guibutton.id == 101 && activeTab != 1) {
|
||||
activeTab = 1;
|
||||
mc.displayGuiScreen(new GuiParty(mc.thePlayer));
|
||||
mc.displayGuiScreen(new GuiParty(mc.thePlayer));
|
||||
}
|
||||
if (guibutton.id == 102 && activeTab != 2) {
|
||||
activeTab = 2;
|
||||
mc.displayGuiScreen(new GuiFaction());
|
||||
mc.displayGuiScreen(new GuiFaction());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -166,9 +166,9 @@ public class GuiFaction extends GuiCNPCInventory implements IGuiData{
|
||||
}
|
||||
protected void drawGuiContainerBackgroundLayer(float f, int i, int j)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void keyTyped(char c, int i)
|
||||
{
|
||||
@@ -199,13 +199,13 @@ public class GuiFaction extends GuiCNPCInventory implements IGuiData{
|
||||
faction.defaultPoints = points;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
pages = (playerFactions.size() - 1) / 10 ;
|
||||
pages++;
|
||||
|
||||
|
||||
page = 1;
|
||||
|
||||
updateButtons();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -12,22 +12,21 @@ import net.minecraft.util.StatCollector;
|
||||
import noppes.npcs.client.Client;
|
||||
import noppes.npcs.client.ClientCacheHandler;
|
||||
import noppes.npcs.client.CustomNpcResourceListener;
|
||||
import noppes.npcs.client.TextBlockClient;
|
||||
import noppes.npcs.client.gui.util.*;
|
||||
import noppes.npcs.constants.EnumPacketServer;
|
||||
import noppes.npcs.controllers.data.Party;
|
||||
import noppes.npcs.controllers.data.Quest;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import tconstruct.client.tabs.InventoryTabCustomNpc;
|
||||
import tconstruct.client.tabs.TabRegistry;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
|
||||
public class GuiParty extends GuiCNPCInventory implements ITextfieldListener, ITopButtonListener,ICustomScrollListener, IGuiData, GuiYesNoCallback {
|
||||
private final ResourceLocation resource = new ResourceLocation("customnpcs","textures/gui/standardbg.png");
|
||||
private final EntityPlayer player;
|
||||
private Minecraft mc = Minecraft.getMinecraft();
|
||||
private final Minecraft mc = Minecraft.getMinecraft();
|
||||
|
||||
private boolean receivedData;
|
||||
private long renderTicks;
|
||||
@@ -40,6 +39,10 @@ public class GuiParty extends GuiCNPCInventory implements ITextfieldListener, IT
|
||||
|
||||
private final HashMap<String, String> invites = new HashMap<>();
|
||||
|
||||
private boolean showQuestText;
|
||||
private final Vector<String> questLogStatus = new Vector<>();
|
||||
private String questCompleteWith;
|
||||
|
||||
public GuiParty(EntityPlayer player) {
|
||||
super();
|
||||
this.player = player;
|
||||
@@ -52,46 +55,43 @@ public class GuiParty extends GuiCNPCInventory implements ITextfieldListener, IT
|
||||
|
||||
public void initGui(){
|
||||
super.initGui();
|
||||
this.selectedInvite = this.selectedPlayer = null;
|
||||
Party party = ClientCacheHandler.party;
|
||||
TabRegistry.addTabsToList(buttonList);
|
||||
TabRegistry.updateTabValues(guiLeft, guiTop, InventoryTabCustomNpc.class);
|
||||
|
||||
this.selectedInvite = this.selectedPlayer = null;
|
||||
Party party = ClientCacheHandler.party;
|
||||
|
||||
if (receivedData) {
|
||||
if (party == null) {
|
||||
//
|
||||
//create party button
|
||||
//
|
||||
GuiNpcButton createPartyButton = new GuiNpcButton(200, guiLeft + xSize/2 + 45, guiTop + ySize/2 + 20, "party.createParty");
|
||||
GuiNpcButton createPartyButton = new GuiNpcButton(200, guiLeft + xSize/2 + 40, guiTop + ySize/2 + 20, "party.createParty");
|
||||
createPartyButton.width = 100;
|
||||
this.addButton(createPartyButton);
|
||||
|
||||
this.addLabel(new GuiNpcLabel(201, "party.partyInfo1", guiLeft + xSize/2 + 30, guiTop + ySize/2 - 30));
|
||||
this.addLabel(new GuiNpcLabel(202, "party.partyInfo2", guiLeft + xSize/2 + 30, guiTop + ySize/2 - 20));
|
||||
this.addLabel(new GuiNpcLabel(203, "party.partyInfo3", guiLeft + xSize/2 + 30, guiTop + ySize/2 - 10));
|
||||
|
||||
//party invites list
|
||||
//
|
||||
GuiCustomScroll inviteScroll = new GuiCustomScroll(this, 210, false);
|
||||
inviteScroll.setSize(150, 160);
|
||||
inviteScroll.setSize(135, 165);
|
||||
inviteScroll.guiLeft = guiLeft + 5;
|
||||
inviteScroll.guiTop = guiTop + 5;
|
||||
inviteScroll.setList(new ArrayList<>(this.invites.keySet()));
|
||||
this.addScroll(inviteScroll);
|
||||
|
||||
GuiNpcButton acceptButton = new GuiNpcButton(215, guiLeft + 15, guiTop + ySize - 12, "party.accept");
|
||||
acceptButton.width = 60;
|
||||
GuiNpcButton acceptButton = new GuiNpcButton(215, guiLeft + 5, guiTop + ySize - 8, "party.accept");
|
||||
acceptButton.width = 65;
|
||||
this.addButton(acceptButton);
|
||||
|
||||
GuiNpcButton ignoreButton = new GuiNpcButton(220, guiLeft + 80, guiTop + ySize - 12, "party.ignore");
|
||||
ignoreButton.width = 60;
|
||||
GuiNpcButton ignoreButton = new GuiNpcButton(220, guiLeft + 75, guiTop + ySize - 8, "party.ignore");
|
||||
ignoreButton.width = 65;
|
||||
this.addButton(ignoreButton);
|
||||
} else {
|
||||
//
|
||||
//party player list
|
||||
//
|
||||
GuiCustomScroll playerScroll = new GuiCustomScroll(this, 300, false);
|
||||
playerScroll.setSize(150, 160);
|
||||
playerScroll.setSize(135, this.isLeader ? 145 : 165);
|
||||
playerScroll.guiLeft = guiLeft + 5;
|
||||
playerScroll.guiTop = guiTop + 5;
|
||||
|
||||
@@ -108,50 +108,69 @@ public class GuiParty extends GuiCNPCInventory implements ITextfieldListener, IT
|
||||
playerScroll.setList(arrayList);
|
||||
this.addScroll(playerScroll);
|
||||
|
||||
if (party.getIsLocked()) {
|
||||
int arrowButtonsY = guiTop + ySize - 8 - 20;
|
||||
|
||||
addButton(new GuiButtonNextPage(400, guiLeft + 144, arrowButtonsY, false));
|
||||
addLabel(new GuiNpcLabel(401, "quest.objectives", guiLeft + 168, getButton(400).yPosition + 3));
|
||||
getButton(400).visible = getLabel(401).enabled = this.showQuestText;
|
||||
|
||||
addButton(new GuiButtonNextPage(405, guiLeft + 286, arrowButtonsY, true));
|
||||
String textString = StatCollector.translateToLocal("gui.text");
|
||||
addLabel(new GuiNpcLabel(406, textString,
|
||||
guiLeft + 284 - fontRendererObj.getStringWidth(textString), getButton(405).yPosition + 3));
|
||||
getButton(405).visible = getLabel(406).enabled = !getButton(400).visible;
|
||||
|
||||
GuiNpcButton disbandButton = new GuiNpcButton(410, guiLeft + 164, arrowButtonsY + 19, "party.dropQuest");
|
||||
disbandButton.width = 135;
|
||||
this.addButton(disbandButton);
|
||||
}
|
||||
|
||||
//toggle friendly fire
|
||||
//
|
||||
GuiNpcLabel friendlyFireLabel = new GuiNpcLabel(321, StatCollector.translateToLocal("party.friendlyFire") + ":",
|
||||
guiLeft + xSize / 2 + 10, guiTop + ySize / 2 + 5);
|
||||
if (party.getIsLocked()) {
|
||||
friendlyFireLabel.x = guiLeft + 5;
|
||||
friendlyFireLabel.y = guiTop + ySize - 8 - 15;
|
||||
}
|
||||
this.addLabel(friendlyFireLabel);
|
||||
GuiNpcButton friendlyFireButton = new GuiNpcButton(320, friendlyFireLabel.x + 70, friendlyFireLabel.y - 6, new String[]{"gui.on", "gui.off"}, party.friendlyFire() ? 0 : 1);
|
||||
friendlyFireButton.width = 40;
|
||||
this.addButton(friendlyFireButton);
|
||||
|
||||
if (this.isLeader) {
|
||||
if (!party.getIsLocked()) {
|
||||
//set leader button
|
||||
//
|
||||
GuiNpcButton leaderButton = new GuiNpcButton(305, guiLeft + 5, guiTop + ySize - 12, "party.makeLeader");
|
||||
leaderButton.width = 70;
|
||||
GuiNpcButton leaderButton = new GuiNpcButton(305, guiLeft + 5, guiTop + ySize - 8 - 21, "party.makeLeader");
|
||||
leaderButton.width = 65;
|
||||
this.addButton(leaderButton);
|
||||
|
||||
//kick player button
|
||||
//
|
||||
GuiNpcButton kickButton = new GuiNpcButton(310, guiLeft + 85, guiTop + ySize - 12, "party.kick");
|
||||
kickButton.width = 70;
|
||||
GuiNpcButton kickButton = new GuiNpcButton(310, guiLeft + 75, guiTop + ySize - 8 - 21, "party.kick");
|
||||
kickButton.width = 65;
|
||||
this.addButton(kickButton);
|
||||
|
||||
//send invite button (opens subgui)
|
||||
//
|
||||
GuiNpcTextField playerTextField = new GuiNpcTextField(325, this, guiLeft + xSize / 2 + 20, guiTop + ySize / 2 + 40, 100, 20, "");
|
||||
GuiNpcTextField playerTextField = new GuiNpcTextField(325, this, friendlyFireLabel.x, guiTop + ySize / 2 + 25, 100, 20, "");
|
||||
this.addTextField(playerTextField);
|
||||
GuiNpcButton inviteButton = new GuiNpcButton(330, guiLeft + xSize / 2 + 125, guiTop + ySize / 2 + 40, "party.invite");
|
||||
GuiNpcButton inviteButton = new GuiNpcButton(330, playerTextField.xPosition + 105, playerTextField.yPosition, "party.invite");
|
||||
inviteButton.width = 50;
|
||||
this.addButton(inviteButton);
|
||||
}
|
||||
|
||||
//toggle friendly fire
|
||||
//
|
||||
GuiNpcButton friendlyFireButton = new GuiNpcButton(320, guiLeft + xSize / 2 + 95, guiTop + ySize / 2, new String[]{"gui.on", "gui.off"}, party.friendlyFire() ? 0 : 1);
|
||||
friendlyFireButton.width = 40;
|
||||
this.addButton(friendlyFireButton);
|
||||
GuiNpcLabel friendlyFireLabel = new GuiNpcLabel(321, StatCollector.translateToLocal("party.friendlyFire") + ":", guiLeft + xSize / 2 + 20, guiTop + ySize / 2 + 5);
|
||||
this.addLabel(friendlyFireLabel);
|
||||
|
||||
//disband party
|
||||
//
|
||||
GuiNpcButton disbandButton = new GuiNpcButton(335, guiLeft + xSize/2 + 45, guiTop + ySize/2 + 70, "party.disbandParty");
|
||||
disbandButton.width = party.getIsLocked() ? 150 : 100;
|
||||
if (party.getIsLocked()) {
|
||||
disbandButton.xPosition = guiLeft + 5;
|
||||
disbandButton.yPosition = guiTop + ySize - 12;
|
||||
}
|
||||
GuiNpcButton disbandButton = new GuiNpcButton(335, guiLeft + 5, guiTop + ySize - 9, "party.disbandParty");
|
||||
disbandButton.width = 135;
|
||||
this.addButton(disbandButton);
|
||||
} else {
|
||||
//leave party
|
||||
//
|
||||
GuiNpcButton leaveButton = new GuiNpcButton(335, guiLeft + xSize/2 + 45, guiTop + ySize/2 + 70, "party.leaveParty");
|
||||
GuiNpcButton leaveButton = new GuiNpcButton(335, guiLeft + 5, guiTop + ySize - 9, "party.leaveParty");
|
||||
leaveButton.width = 100;
|
||||
this.addButton(leaveButton);
|
||||
}
|
||||
@@ -239,6 +258,15 @@ public class GuiParty extends GuiCNPCInventory implements ITextfieldListener, IT
|
||||
displayGuiScreen(yesnoLeave);
|
||||
}
|
||||
break;
|
||||
case 400:
|
||||
this.showQuestText = false;
|
||||
break;
|
||||
case 405:
|
||||
this.showQuestText = true;
|
||||
break;
|
||||
case 410:
|
||||
Client.sendData(EnumPacketServer.SetPartyQuest, "", "");
|
||||
break;
|
||||
}
|
||||
initGui();
|
||||
if (guibutton.id == 100 && activeTab != 0) {
|
||||
@@ -272,6 +300,49 @@ public class GuiParty extends GuiCNPCInventory implements ITextfieldListener, IT
|
||||
periods += ".";
|
||||
}
|
||||
fontRendererObj.drawString(StatCollector.translateToLocal("gui.loading") + periods,guiLeft + xSize/2,guiTop + 80, CustomNpcResourceListener.DefaultTextColor);
|
||||
return;
|
||||
}
|
||||
|
||||
if (ClientCacheHandler.party == null) {
|
||||
drawTextBlock("party.messageNoParty", guiLeft + 155, guiTop + ySize/2 - 20, 160);
|
||||
} else if (ClientCacheHandler.party.getQuest() != null) {
|
||||
Quest quest = (Quest) ClientCacheHandler.party.getQuest();
|
||||
if (showQuestText) {
|
||||
drawTextBlock(quest.getLogText(), guiLeft + 142, guiTop + 20, 174);
|
||||
} else {
|
||||
drawProgress();
|
||||
}
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(guiLeft + 148, guiTop, 0);
|
||||
GL11.glScalef(1.24f, 1.24f, 1.24f);
|
||||
fontRendererObj.drawString(quest.getName(), (130 - fontRendererObj.getStringWidth(quest.getName())) / 2, 4, CustomNpcResourceListener.DefaultTextColor);
|
||||
GL11.glPopMatrix();
|
||||
drawHorizontalLine(guiLeft + 142, guiLeft + 312, guiTop + 17, +0xFF000000 + CustomNpcResourceListener.DefaultTextColor);
|
||||
}
|
||||
}
|
||||
|
||||
private void drawProgress() {
|
||||
String complete = this.questCompleteWith;
|
||||
if(complete != null && !complete.isEmpty())
|
||||
fontRendererObj.drawString(StatCollector.translateToLocalFormatted("quest.completewith", complete), guiLeft + 144, guiTop + 105, CustomNpcResourceListener.DefaultTextColor);
|
||||
|
||||
int yoffset = guiTop + 22;
|
||||
for(String process : this.questLogStatus){
|
||||
int index = process.lastIndexOf(":");
|
||||
if(index > 0){
|
||||
String name = process.substring(0, index);
|
||||
String trans = StatCollector.translateToLocal(name);
|
||||
if(!trans.equals(name))
|
||||
name = trans;
|
||||
trans = StatCollector.translateToLocal("entity." + name + ".name");
|
||||
if(!trans.equals("entity." + name + ".name")){
|
||||
name = trans;
|
||||
}
|
||||
process = name + process.substring(index);
|
||||
}
|
||||
fontRendererObj.drawString("- " + process, guiLeft + 144, yoffset , CustomNpcResourceListener.DefaultTextColor);
|
||||
yoffset += 10;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -304,6 +375,17 @@ public class GuiParty extends GuiCNPCInventory implements ITextfieldListener, IT
|
||||
ClientCacheHandler.party = new Party(uuid);
|
||||
Party party = ClientCacheHandler.party;
|
||||
party.readFromNBT(compound);
|
||||
this.questLogStatus.clear();
|
||||
this.questCompleteWith = "";
|
||||
if (compound.hasKey("QuestProgress")) {
|
||||
NBTTagList tagList = compound.getTagList("QuestProgress", 8);
|
||||
for (int i = 0; i < tagList.tagCount(); i++) {
|
||||
this.questLogStatus.add(tagList.getStringTagAt(i));
|
||||
}
|
||||
}
|
||||
if (compound.hasKey("QuestCompleteWith")) {
|
||||
this.questCompleteWith = compound.getString("QuestCompleteWith");
|
||||
}
|
||||
this.isLeader = ClientCacheHandler.party.getPartyLeaderName().equals(this.player.getCommandSenderName());
|
||||
} else if (compound.hasKey("Disband")) {
|
||||
this.isLeader = false;
|
||||
|
||||
@@ -53,8 +53,9 @@ public class GuiQuestLog extends GuiCNPCInventory implements ITopButtonListener,
|
||||
public void initGui(){
|
||||
super.initGui();
|
||||
sideButtons.clear();
|
||||
TabRegistry.addTabsToList(buttonList);
|
||||
TabRegistry.updateTabValues(guiLeft, guiTop, InventoryTabCustomNpc.class);
|
||||
|
||||
TabRegistry.addTabsToList(buttonList);
|
||||
TabRegistry.updateTabValues(guiLeft, guiTop, InventoryTabCustomNpc.class);
|
||||
|
||||
noQuests = false;
|
||||
|
||||
@@ -87,15 +88,16 @@ public class GuiQuestLog extends GuiCNPCInventory implements ITopButtonListener,
|
||||
addButton(new GuiButtonNextPage(1, guiLeft + 286, guiTop + 176, true));
|
||||
addButton(new GuiButtonNextPage(2, guiLeft + 144, guiTop + 176, false));
|
||||
|
||||
if (ClientCacheHandler.party != null && data.hasSelectedQuest()
|
||||
&& data.partyAbleQuests.contains(data.selectedCategory + ":" + data.selectedQuest)
|
||||
&& ClientCacheHandler.party.getPartyLeaderName().equals(this.player.getCommandSenderName())) {
|
||||
String questName = ClientCacheHandler.party.getCurrentQuestName();
|
||||
if (data.partyAbleQuests.contains(data.selectedCategory + ":" + data.selectedQuest)) {
|
||||
String questName = ClientCacheHandler.party != null ? ClientCacheHandler.party.getCurrentQuestName() : null;
|
||||
GuiNpcButton partyButton = new GuiNpcButton(3, guiLeft + 150, guiTop + 151, 50, 20, new String[]{"party.party", "party.partying"}, Objects.equals(questName, data.selectedQuest) ? 1 : 0);
|
||||
if (Objects.equals(questName, data.selectedQuest)) {
|
||||
addButton(partyButton);
|
||||
|
||||
partyButton.enabled = ClientCacheHandler.party != null && data.hasSelectedQuest()
|
||||
&& ClientCacheHandler.party.getPartyLeaderName().equals(this.player.getCommandSenderName());
|
||||
if (partyButton.enabled && Objects.equals(questName, data.selectedQuest)) {
|
||||
partyButton.packedFGColour = 0x32CD32;
|
||||
}
|
||||
addButton(partyButton);
|
||||
}
|
||||
|
||||
GuiNpcButton trackingButton = new GuiNpcButton(4, guiLeft + 260, guiTop + 151, 50, 20, new String[]{"quest.track", "quest.tracking"}, data.trackedQuestKey.equals(data.selectedCategory + ":" + data.selectedQuest) ? 1 : 0);
|
||||
@@ -111,6 +113,9 @@ public class GuiQuestLog extends GuiCNPCInventory implements ITopButtonListener,
|
||||
getButton(2).visible = !questDetails && data.hasSelectedQuest();
|
||||
getButton(4).visible = !data.selectedQuest.isEmpty() && getButton(1).visible;
|
||||
getButton(5).visible = getButton(4).visible;
|
||||
if (getButton(3) != null) {
|
||||
getButton(3).visible = getButton(4).visible;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton guibutton){
|
||||
@@ -317,5 +322,5 @@ public class GuiQuestLog extends GuiCNPCInventory implements ITopButtonListener,
|
||||
Client.sendData(EnumPacketServer.QuestLogToServer, compound, this.data.trackedQuestKey);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -20,25 +20,24 @@ import java.util.HashMap;
|
||||
public class GuiNpcQuestTypeDialog extends SubGuiInterface implements GuiSelectionListener, IGuiData
|
||||
{
|
||||
private GuiScreen parent;
|
||||
|
||||
private QuestDialog quest;
|
||||
|
||||
|
||||
private HashMap<Integer, String> data = new HashMap<Integer, String>();
|
||||
|
||||
public GuiNpcQuestTypeDialog(EntityNPCInterface npc, Quest q, GuiScreen parent) {
|
||||
this.npc = npc;
|
||||
this.parent = parent;
|
||||
title = "Quest Dialog Setup";
|
||||
|
||||
|
||||
quest = (QuestDialog) q.questInterface;
|
||||
|
||||
setBackground("menubg.png");
|
||||
xSize = 256;
|
||||
ySize = 216;
|
||||
closeOnEsc = true;
|
||||
Client.sendData(EnumPacketServer.QuestDialogGetTitle,
|
||||
quest.dialogs.containsKey(0)?quest.dialogs.get(0):-1,
|
||||
quest.dialogs.containsKey(1)?quest.dialogs.get(1):-1,
|
||||
Client.sendData(EnumPacketServer.QuestDialogGetTitle,
|
||||
quest.dialogs.containsKey(0)?quest.dialogs.get(0):-1,
|
||||
quest.dialogs.containsKey(1)?quest.dialogs.get(1):-1,
|
||||
quest.dialogs.containsKey(2)?quest.dialogs.get(2):-1);
|
||||
}
|
||||
|
||||
@@ -48,12 +47,12 @@ public class GuiNpcQuestTypeDialog extends SubGuiInterface implements GuiSelecti
|
||||
String title = "dialog.selectoption";
|
||||
if(data.containsKey(i))
|
||||
title = data.get(i);
|
||||
this.addButton(new GuiNpcButton(i + 9, guiLeft + 10, 55 + i * 22, 20, 20, "X"));
|
||||
this.addButton(new GuiNpcButton(i + 3, guiLeft + 34, 55 + i * 22, 210, 20, title));
|
||||
this.addButton(new GuiNpcButton(i + 9, guiLeft + 10, guiTop + 55 + i * 22, 20, 20, "X"));
|
||||
this.addButton(new GuiNpcButton(i + 3, guiLeft + 34, guiTop + 55 + i * 22, 210, 20, title));
|
||||
|
||||
}
|
||||
this.addButton(new GuiNpcButton(0, guiLeft + 150, guiTop + 190, 98, 20, "gui.back"));
|
||||
|
||||
|
||||
}
|
||||
|
||||
private int selectedSlot;
|
||||
@@ -67,9 +66,10 @@ public class GuiNpcQuestTypeDialog extends SubGuiInterface implements GuiSelecti
|
||||
int id = -1;
|
||||
if(quest.dialogs.containsKey(selectedSlot))
|
||||
id = quest.dialogs.get(selectedSlot);
|
||||
GuiNPCDialogSelection gui = new GuiNPCDialogSelection(npc, parent, id);
|
||||
gui.listener = this;
|
||||
NoppesUtil.openGUI(player, gui);
|
||||
|
||||
GuiNPCDialogSelection gui = new GuiNPCDialogSelection(npc, getParent(), id);
|
||||
gui.listener = this;
|
||||
NoppesUtil.openGUI(player, gui);
|
||||
}
|
||||
if (button.id >= 9 && button.id < 15) {
|
||||
int slot = button.id - 9;
|
||||
|
||||
@@ -14,17 +14,17 @@ import noppes.npcs.roles.RoleTrader;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class GuiNpcTraderSetup extends GuiContainerNPCInterface2 implements ITextfieldListener{
|
||||
|
||||
|
||||
private final ResourceLocation slot = new ResourceLocation("customnpcs","textures/gui/slot.png");
|
||||
private RoleTrader role;
|
||||
|
||||
|
||||
public GuiNpcTraderSetup(EntityNPCInterface npc, ContainerNPCTraderSetup container){
|
||||
super(npc, container);
|
||||
ySize = 220;
|
||||
menuYOffset = 10;
|
||||
role = container.role;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void initGui(){
|
||||
super.initGui();
|
||||
@@ -35,9 +35,12 @@ public class GuiNpcTraderSetup extends GuiContainerNPCInterface2 implements ITex
|
||||
|
||||
addLabel(new GuiNpcLabel(1, "gui.ignoreDamage", guiLeft + 260, guiTop + 29));
|
||||
addButton(new GuiNpcButtonYesNo(1, guiLeft + 340, guiTop + 24, role.ignoreDamage));
|
||||
|
||||
|
||||
addLabel(new GuiNpcLabel(2, "gui.ignoreNBT", guiLeft + 260, guiTop + 51));
|
||||
addButton(new GuiNpcButtonYesNo(2, guiLeft + 340, guiTop + 46, role.ignoreNBT));
|
||||
|
||||
addLabel(new GuiNpcLabel(3, "gui.recordHistory", guiLeft + 260, guiTop + 73));
|
||||
addButton(new GuiNpcButtonYesNo(3, guiLeft + 340, guiTop + 68, role.recordHistory));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -55,6 +58,9 @@ public class GuiNpcTraderSetup extends GuiContainerNPCInterface2 implements ITex
|
||||
if(guibutton.id == 2){
|
||||
role.ignoreNBT = ((GuiNpcButtonYesNo)guibutton).getBoolean();
|
||||
}
|
||||
if(guibutton.id == 3){
|
||||
role.recordHistory = ((GuiNpcButtonYesNo)guibutton).getBoolean();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -69,20 +75,20 @@ public class GuiNpcTraderSetup extends GuiContainerNPCInterface2 implements ITex
|
||||
GL11.glColor4f(1, 1, 1, 1);
|
||||
drawTexturedModalRect(x - 1, y, 0, 0, 18, 18);
|
||||
drawTexturedModalRect(x + 17, y, 0, 0, 18, 18);
|
||||
|
||||
|
||||
fontRendererObj.drawString("=", x + 36, y + 5, CustomNpcResourceListener.DefaultTextColor);
|
||||
mc.renderEngine.bindTexture(this.slot);
|
||||
GL11.glColor4f(1, 1, 1, 1);
|
||||
drawTexturedModalRect(x + 42, y, 0, 0, 18, 18);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
Client.sendData(EnumPacketServer.TraderMarketSave, role.marketName, false);
|
||||
Client.sendData(EnumPacketServer.RoleSave, role.writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void unFocused(GuiNpcTextField guiNpcTextField) {
|
||||
String name = guiNpcTextField.getText();
|
||||
@@ -90,6 +96,6 @@ public class GuiNpcTraderSetup extends GuiContainerNPCInterface2 implements ITex
|
||||
role.marketName = name;
|
||||
Client.sendData(EnumPacketServer.TraderMarketSave, role.marketName, true);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,7 @@ public class GuiScriptItem extends GuiScriptInterface {
|
||||
hookList.add("pickedUp");
|
||||
hookList.add("spawn");
|
||||
hookList.add("interact");
|
||||
hookList.add("rightClick");
|
||||
hookList.add("attack");
|
||||
hookList.add("startItem");
|
||||
hookList.add("usingItem");
|
||||
@@ -37,4 +38,4 @@ public class GuiScriptItem extends GuiScriptInterface {
|
||||
super.save();
|
||||
Client.sendData(EnumPacketServer.ScriptItemDataSave, new Object[]{this.item.getMCNbt()});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,9 @@ import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import noppes.npcs.client.CustomNpcResourceListener;
|
||||
import noppes.npcs.client.TextBlockClient;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.input.Mouse;
|
||||
@@ -250,6 +253,10 @@ public abstract class GuiNPCInterface extends GuiScreen
|
||||
if(scroll.hoverableText){
|
||||
scroll.drawHover(i, j, f, hasSubGui()?0:this.mouseWheel);
|
||||
}
|
||||
for(GuiNpcButton button : buttons.values())
|
||||
if(!button.hoverableText.isEmpty()){
|
||||
button.drawHover(i, j, hasSubGui());
|
||||
}
|
||||
if(subgui != null)
|
||||
subgui.drawScreen(i,j,f);
|
||||
}
|
||||
@@ -269,6 +276,14 @@ public abstract class GuiNPCInterface extends GuiScreen
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
protected void drawTextBlock(String text, int x, int y, int lineWidth) {
|
||||
TextBlockClient block = new TextBlockClient(StatCollector.translateToLocal(text), lineWidth, true, player);
|
||||
for(int line = 0; line < block.lines.size(); line++){
|
||||
String lineText = block.lines.get(line).getFormattedText();
|
||||
fontRendererObj.drawString(lineText, x, y + (line * fontRendererObj.FONT_HEIGHT), CustomNpcResourceListener.DefaultTextColor);
|
||||
}
|
||||
}
|
||||
|
||||
public FontRenderer getFontRenderer() {
|
||||
return this.fontRendererObj;
|
||||
}
|
||||
|
||||
@@ -1,16 +1,26 @@
|
||||
package noppes.npcs.client.gui.util;
|
||||
|
||||
import kamkeel.util.TextSplitter;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
public class GuiNpcButton extends GuiButton{
|
||||
|
||||
protected String[] display;
|
||||
private int displayValue = 0;
|
||||
public int id;
|
||||
public String hoverableText = "";
|
||||
public int oldHover;
|
||||
public int hoverCount = 0;
|
||||
|
||||
public GuiNpcButton(int i, int j, int k, String s) {
|
||||
super(i, j, k, StatCollector.translateToLocal(s));
|
||||
@@ -48,6 +58,9 @@ public class GuiNpcButton extends GuiButton{
|
||||
public void setDisplayText(String text){
|
||||
this.displayString = StatCollector.translateToLocal(text);
|
||||
}
|
||||
public void setHoverText(String text){
|
||||
this.hoverableText = StatCollector.translateToLocal(text);
|
||||
}
|
||||
public int getValue(){
|
||||
return displayValue;
|
||||
}
|
||||
@@ -85,4 +98,106 @@ public class GuiNpcButton extends GuiButton{
|
||||
public int getWidth() {
|
||||
return width;
|
||||
}
|
||||
|
||||
public void drawHover(int i, int j, boolean hasSubGui) {
|
||||
if (hasSubGui || !visible || hoverableText.isEmpty())
|
||||
return;
|
||||
|
||||
int hoverState = this.getHoverState(this.field_146123_n);
|
||||
if (oldHover != hoverState) {
|
||||
oldHover = hoverState;
|
||||
hoverCount = 0;
|
||||
} else {
|
||||
if (hoverCount < 110)
|
||||
hoverCount++;
|
||||
}
|
||||
|
||||
if (hoverState == 2 && hoverCount > 100) {
|
||||
GL11.glPushMatrix();
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
String displayString = StatCollector.translateToLocal(hoverableText);
|
||||
GL11.glColor4f(1, 1, 1, 1);
|
||||
List<String> lines = TextSplitter.splitText(displayString, 30);
|
||||
drawHoveringText(lines, i, j, mc);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
protected void drawHoveringText(List textLines, int x, int y, Minecraft mc) {
|
||||
if (mc.fontRenderer == null || textLines.isEmpty())
|
||||
return;
|
||||
|
||||
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glDisable(GL11.GL_DEPTH_TEST);
|
||||
|
||||
int maxWidth = 0;
|
||||
Iterator iterator = textLines.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
String s = (String) iterator.next();
|
||||
int lineWidth = mc.fontRenderer.getStringWidth(s);
|
||||
if (lineWidth > maxWidth) {
|
||||
maxWidth = lineWidth;
|
||||
}
|
||||
}
|
||||
|
||||
int j2 = x + 12;
|
||||
int k2 = y - 12;
|
||||
int maxHeight = 8;
|
||||
|
||||
if (textLines.size() > 1) {
|
||||
maxHeight += 2 + (textLines.size() - 1) * 10;
|
||||
}
|
||||
|
||||
// Calculate the maximum x-coordinate to ensure the tooltip stays within the game window
|
||||
int gameWidth = mc.displayWidth;
|
||||
int maxTooltipX = gameWidth - maxWidth - 4; // Subtract the tooltip width
|
||||
|
||||
// Adjust tooltip position if it goes off the screen to the right
|
||||
if (j2 > maxTooltipX) {
|
||||
int diff = j2 - maxTooltipX;
|
||||
j2 -= diff; // Shift tooltip to the left
|
||||
GL11.glTranslatef(-300, 0, 0); // Apply translation
|
||||
}
|
||||
|
||||
if (k2 + maxHeight + 6 > mc.displayHeight) {
|
||||
k2 = mc.displayHeight - maxHeight - 6;
|
||||
}
|
||||
|
||||
// Draw the tooltip
|
||||
this.zLevel = 300.0F;
|
||||
int j1 = -267386864;
|
||||
// Draw the gradient background
|
||||
// (Ensure to adjust the coordinates according to the translation)
|
||||
this.drawGradientRect(j2 - 3, k2 - 4, j2 + maxWidth + 3, k2 - 3, j1, j1);
|
||||
this.drawGradientRect(j2 - 3, k2 + maxHeight + 3, j2 + maxWidth + 3, k2 + maxHeight + 4, j1, j1);
|
||||
this.drawGradientRect(j2 - 3, k2 - 3, j2 + maxWidth + 3, k2 + maxHeight + 3, j1, j1);
|
||||
this.drawGradientRect(j2 - 4, k2 - 3, j2 - 3, k2 + maxHeight + 3, j1, j1);
|
||||
this.drawGradientRect(j2 + maxWidth + 3, k2 - 3, j2 + maxWidth + 4, k2 + maxHeight + 3, j1, j1);
|
||||
int k1 = 1347420415;
|
||||
int l1 = (k1 & 16711422) >> 1 | k1 & -16777216;
|
||||
this.drawGradientRect(j2 - 3, k2 - 3 + 1, j2 - 3 + 1, k2 + maxHeight + 3 - 1, k1, l1);
|
||||
this.drawGradientRect(j2 + maxWidth + 2, k2 - 3 + 1, j2 + maxWidth + 3, k2 + maxHeight + 3 - 1, k1, l1);
|
||||
this.drawGradientRect(j2 - 3, k2 - 3, j2 + maxWidth + 3, k2 - 3 + 1, k1, k1);
|
||||
this.drawGradientRect(j2 - 3, k2 + maxHeight + 2, j2 + maxWidth + 3, k2 + maxHeight + 3, l1, l1);
|
||||
|
||||
// Draw the text lines
|
||||
for (int i2 = 0; i2 < textLines.size(); ++i2) {
|
||||
String s1 = (String) textLines.get(i2);
|
||||
mc.fontRenderer.drawStringWithShadow(s1, j2, k2, -1);
|
||||
if (i2 == 0) {
|
||||
k2 += 2;
|
||||
}
|
||||
k2 += 10;
|
||||
}
|
||||
|
||||
this.zLevel = 0.0F;
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glEnable(GL11.GL_DEPTH_TEST);
|
||||
RenderHelper.enableStandardItemLighting();
|
||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,6 +11,7 @@ import noppes.npcs.client.model.part.legs.ModelMermaidLegs2;
|
||||
import noppes.npcs.client.model.part.legs.ModelNagaLegs;
|
||||
import noppes.npcs.client.model.util.ModelScaleRenderer;
|
||||
import noppes.npcs.constants.EnumAnimation;
|
||||
import noppes.npcs.controllers.data.CustomTintData;
|
||||
import noppes.npcs.entity.EntityCustomNpc;
|
||||
import noppes.npcs.entity.data.ModelPartData;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
@@ -386,7 +387,9 @@ public class ModelLegs extends ModelScaleRenderer{
|
||||
y *= 2f;
|
||||
}
|
||||
}
|
||||
boolean bo = entity.hurtTime <= 0 && entity.deathTime <= 0 && !base.isArmor;
|
||||
CustomTintData customTintData = entity.display.customTintData;
|
||||
boolean bo = entity.hurtTime <= 0 && entity.deathTime <= 0 && !base.isArmor &&
|
||||
!(customTintData.isTintEnabled() && customTintData.isGeneralTintEnabled());
|
||||
if(bo){
|
||||
float red = (entity.modelData.legParts.color >> 16 & 255) / 255f;
|
||||
float green = (entity.modelData.legParts.color >> 8 & 255) / 255f;
|
||||
|
||||
@@ -10,6 +10,7 @@ import noppes.npcs.client.model.ModelMPM;
|
||||
import noppes.npcs.client.model.part.tails.*;
|
||||
import noppes.npcs.client.model.util.ModelScaleRenderer;
|
||||
import noppes.npcs.constants.EnumAnimation;
|
||||
import noppes.npcs.controllers.data.CustomTintData;
|
||||
import noppes.npcs.entity.EntityCustomNpc;
|
||||
import noppes.npcs.entity.data.ModelPartData;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
@@ -150,7 +151,9 @@ public class ModelTail extends ModelScaleRenderer {
|
||||
base.currentlyPlayerTexture = true;
|
||||
}
|
||||
}
|
||||
boolean bo = entity.hurtTime <= 0 && entity.deathTime <= 0;
|
||||
CustomTintData customTintData = entity.display.customTintData;
|
||||
boolean bo = entity.hurtTime <= 0 && entity.deathTime <= 0 && !base.isArmor &&
|
||||
!(customTintData.isTintEnabled() && customTintData.isGeneralTintEnabled());
|
||||
if(bo){
|
||||
float red = (color >> 16 & 255) / 255f;
|
||||
float green = (color >> 8 & 255) / 255f;
|
||||
|
||||
@@ -88,4 +88,81 @@ public class Model2DRenderer extends ModelRenderer {
|
||||
GL11.glEndList();
|
||||
this.compiledModel = true;
|
||||
}
|
||||
|
||||
public static void renderItemIn2D(float p_78439_1_, float p_78439_2_, float p_78439_3_, float p_78439_4_, int p_78439_5_, int p_78439_6_, float p_78439_7_) {
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, 0.0F, 1.0F);
|
||||
tessellator.addVertexWithUV(0.0D, 0.0D, 0.0D, p_78439_1_, p_78439_4_);
|
||||
tessellator.addVertexWithUV(1.0D, 0.0D, 0.0D, p_78439_3_, p_78439_4_);
|
||||
tessellator.addVertexWithUV(1.0D, 1.0D, 0.0D, p_78439_3_, p_78439_2_);
|
||||
tessellator.addVertexWithUV(0.0D, 1.0D, 0.0D, p_78439_1_, p_78439_2_);
|
||||
tessellator.draw();
|
||||
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, 0.0F, -1.0F);
|
||||
tessellator.addVertexWithUV(0.0D, 1.0D, 0.0F - p_78439_7_, p_78439_1_, p_78439_2_);
|
||||
tessellator.addVertexWithUV(1.0D, 1.0D, 0.0F - p_78439_7_, p_78439_3_, p_78439_2_);
|
||||
tessellator.addVertexWithUV(1.0D, 0.0D, 0.0F - p_78439_7_, p_78439_3_, p_78439_4_);
|
||||
tessellator.addVertexWithUV(0.0D, 0.0D, 0.0F - p_78439_7_, p_78439_1_, p_78439_4_);
|
||||
tessellator.draw();
|
||||
|
||||
float f5 = 0.5F * (p_78439_1_ - p_78439_3_) / (float) p_78439_5_;
|
||||
float f6 = 0.5F * (p_78439_4_ - p_78439_2_) / (float) p_78439_6_;
|
||||
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(-1.0F, 0.0F, 0.0F);
|
||||
|
||||
for (int k = 0; k < p_78439_5_; ++k) {
|
||||
float f7 = (float) k / (float) p_78439_5_;
|
||||
float f8 = p_78439_1_ + (p_78439_3_ - p_78439_1_) * f7 - f5;
|
||||
tessellator.addVertexWithUV(f7, 0.0D, 0.0F - p_78439_7_, f8, p_78439_4_);
|
||||
tessellator.addVertexWithUV(f7, 0.0D, 0.0D, f8, p_78439_4_);
|
||||
tessellator.addVertexWithUV(f7, 1.0D, 0.0D, f8, p_78439_2_);
|
||||
tessellator.addVertexWithUV(f7, 1.0D, 0.0F - p_78439_7_, f8, p_78439_2_);
|
||||
}
|
||||
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(1.0F, 0.0F, 0.0F);
|
||||
|
||||
for (int k = 0; k < p_78439_5_; ++k) {
|
||||
float f7 = (float) k / (float) p_78439_5_;
|
||||
float f8 = p_78439_1_ + (p_78439_3_ - p_78439_1_) * f7 - f5;
|
||||
float f9 = f7 + 1.0F / (float) p_78439_5_;
|
||||
tessellator.addVertexWithUV(f9, 1.0D, 0.0F - p_78439_7_, f8, p_78439_2_);
|
||||
tessellator.addVertexWithUV(f9, 1.0D, 0.0D, f8, p_78439_2_);
|
||||
tessellator.addVertexWithUV(f9, 0.0D, 0.0D, f8, p_78439_4_);
|
||||
tessellator.addVertexWithUV(f9, 0.0D, 0.0F - p_78439_7_, f8, p_78439_4_);
|
||||
}
|
||||
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, 1.0F, 0.0F);
|
||||
|
||||
for (int k = 0; k < p_78439_6_; ++k) {
|
||||
float f7 = (float) k / (float) p_78439_6_;
|
||||
float f8 = p_78439_4_ + (p_78439_2_ - p_78439_4_) * f7 - f6;
|
||||
float f9 = f7 + 1.0F / (float) p_78439_6_;
|
||||
tessellator.addVertexWithUV(0.0D, f9, 0.0D, p_78439_1_, f8);
|
||||
tessellator.addVertexWithUV(1.0D, f9, 0.0D, p_78439_3_, f8);
|
||||
tessellator.addVertexWithUV(1.0D, f9, 0.0F - p_78439_7_, p_78439_3_, f8);
|
||||
tessellator.addVertexWithUV(0.0D, f9, 0.0F - p_78439_7_, p_78439_1_, f8);
|
||||
}
|
||||
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, -1.0F, 0.0F);
|
||||
|
||||
for (int k = 0; k < p_78439_6_; ++k) {
|
||||
float f7 = (float) k / (float) p_78439_6_;
|
||||
float f8 = p_78439_4_ + (p_78439_2_ - p_78439_4_) * f7 - f6;
|
||||
tessellator.addVertexWithUV(1.0D, f7, 0.0D, p_78439_3_, f8);
|
||||
tessellator.addVertexWithUV(0.0D, f7, 0.0D, p_78439_1_, f8);
|
||||
tessellator.addVertexWithUV(0.0D, f7, 0.0F - p_78439_7_, p_78439_1_, f8);
|
||||
tessellator.addVertexWithUV(1.0D, f7, 0.0F - p_78439_7_, p_78439_3_, f8);
|
||||
}
|
||||
|
||||
tessellator.draw();
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import noppes.npcs.client.ClientProxy;
|
||||
import noppes.npcs.client.model.ModelMPM;
|
||||
import noppes.npcs.controllers.data.CustomTintData;
|
||||
import noppes.npcs.entity.EntityCustomNpc;
|
||||
import noppes.npcs.entity.data.ModelData;
|
||||
import noppes.npcs.entity.data.ModelPartData;
|
||||
@@ -59,7 +60,9 @@ public abstract class ModelPartInterface extends ModelRenderer {
|
||||
base.currentlyPlayerTexture = true;
|
||||
}
|
||||
}
|
||||
boolean bo = entity.hurtTime <= 0 && entity.deathTime <= 0 && !base.isArmor;
|
||||
CustomTintData customTintData = entity.display.customTintData;
|
||||
boolean bo = entity.hurtTime <= 0 && entity.deathTime <= 0 && !base.isArmor &&
|
||||
!(customTintData.isTintEnabled() && customTintData.isGeneralTintEnabled());
|
||||
if(bo){
|
||||
float red = (color >> 16 & 255) / 255f;
|
||||
float green = (color >> 8 & 255) / 255f;
|
||||
|
||||
@@ -83,7 +83,7 @@ public class ImageData {
|
||||
}
|
||||
}
|
||||
|
||||
private ResourceLocation getLocation() {
|
||||
public ResourceLocation getLocation() {
|
||||
return this.isUrl && this.imageDownloadAlt.getBufferedImage() == null ? null : this.location;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
package noppes.npcs.client.renderer;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.GLAllocation;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import noppes.npcs.client.model.util.Model2DRenderer;
|
||||
import noppes.npcs.constants.MarkType;
|
||||
import noppes.npcs.controllers.data.MarkData;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class MarkRenderer {
|
||||
public static ResourceLocation markExclamation = new ResourceLocation("customnpcs", "textures/marks/exclamation.png");
|
||||
public static ResourceLocation markQuestion = new ResourceLocation("customnpcs", "textures/marks/question.png");
|
||||
public static ResourceLocation markPointer = new ResourceLocation("customnpcs", "textures/marks/pointer.png");
|
||||
public static ResourceLocation markCross = new ResourceLocation("customnpcs", "textures/marks/cross.png");
|
||||
public static ResourceLocation markSkull = new ResourceLocation("customnpcs", "textures/marks/skull.png");
|
||||
public static ResourceLocation markStar = new ResourceLocation("customnpcs", "textures/marks/star.png");
|
||||
|
||||
public static int displayList = -1;
|
||||
|
||||
public static void render(EntityLivingBase entity, double x, double y, double z, MarkData.Mark mark){
|
||||
GL11.glPushMatrix();
|
||||
int color = mark.color;
|
||||
float red = (float)(color >> 16 & 255) / 255.0F;
|
||||
float blue = (float)(color >> 8 & 255) / 255.0F;
|
||||
float green = (float)(color & 255) / 255.0F;
|
||||
GL11.glColor4f(red, blue, green, 1);
|
||||
GL11.glTranslatef((float) x, (float) (y + entity.height + 0.6), (float) z);
|
||||
GL11.glRotatef(-entity.rotationYawHead, 0, 1, 0);
|
||||
|
||||
if(mark.type == MarkType.EXCLAMATION)
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(markExclamation);
|
||||
else if(mark.type == MarkType.QUESTION)
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(markQuestion);
|
||||
else if(mark.type == MarkType.POINTER)
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(markPointer);
|
||||
else if(mark.type == MarkType.CROSS)
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(markCross);
|
||||
else if(mark.type == MarkType.SKULL)
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(markSkull);
|
||||
else if(mark.type == MarkType.STAR)
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(markStar);
|
||||
|
||||
if(displayList >= 0){
|
||||
GL11.glCallList(displayList);
|
||||
}
|
||||
else{
|
||||
displayList = GLAllocation.generateDisplayLists(1);
|
||||
GL11.glNewList(displayList, GL11.GL_COMPILE);
|
||||
GL11.glTranslatef((float) -0.5, 0, 0);
|
||||
Model2DRenderer.renderItemIn2D(0f, 0f, 1f, 1f, 32, 32, 0.0625F);
|
||||
GL11.glEndList();
|
||||
}
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
@@ -18,17 +18,22 @@ import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.boss.BossStatus;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.event.RenderLivingEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import noppes.npcs.api.ISkinOverlay;
|
||||
import noppes.npcs.client.ClientCacheHandler;
|
||||
import noppes.npcs.client.ImageDownloadAlt;
|
||||
import noppes.npcs.client.model.ModelMPM;
|
||||
import noppes.npcs.constants.EnumAnimation;
|
||||
import noppes.npcs.constants.EnumStandingType;
|
||||
import noppes.npcs.controllers.data.CustomTintData;
|
||||
import noppes.npcs.controllers.data.SkinOverlay;
|
||||
import noppes.npcs.entity.EntityCustomNpc;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.image.BufferedImage;
|
||||
@@ -213,9 +218,261 @@ public class RenderNPCInterface extends RenderLiving{
|
||||
}
|
||||
|
||||
staticRenderManager = this.renderManager;
|
||||
super.doRender(entityliving, d, d1, d2, f, f1);
|
||||
|
||||
doRenderLiving(npc, d, d1, d2, f, f1);
|
||||
}
|
||||
|
||||
public void doRenderLiving(EntityNPCInterface p_76986_1_, double p_76986_2_, double p_76986_4_, double p_76986_6_, float p_76986_8_, float p_76986_9_)
|
||||
{
|
||||
if (MinecraftForge.EVENT_BUS.post(new RenderLivingEvent.Pre(p_76986_1_, this, p_76986_2_, p_76986_4_, p_76986_6_))) return;
|
||||
GL11.glPushMatrix();
|
||||
GL11.glDisable(GL11.GL_CULL_FACE);
|
||||
this.mainModel.onGround = this.renderSwingProgress(p_76986_1_, p_76986_9_);
|
||||
|
||||
if (this.renderPassModel != null)
|
||||
{
|
||||
this.renderPassModel.onGround = this.mainModel.onGround;
|
||||
}
|
||||
|
||||
this.mainModel.isRiding = p_76986_1_.isRiding();
|
||||
|
||||
if (this.renderPassModel != null)
|
||||
{
|
||||
this.renderPassModel.isRiding = this.mainModel.isRiding;
|
||||
}
|
||||
|
||||
this.mainModel.isChild = p_76986_1_.isChild();
|
||||
|
||||
if (this.renderPassModel != null)
|
||||
{
|
||||
this.renderPassModel.isChild = this.mainModel.isChild;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
float f2 = this.interpolateRotation(p_76986_1_.prevRenderYawOffset, p_76986_1_.renderYawOffset, p_76986_9_);
|
||||
float f3 = this.interpolateRotation(p_76986_1_.prevRotationYawHead, p_76986_1_.rotationYawHead, p_76986_9_);
|
||||
float f4;
|
||||
|
||||
if (p_76986_1_.isRiding() && p_76986_1_.ridingEntity instanceof EntityLivingBase)
|
||||
{
|
||||
EntityLivingBase entitylivingbase1 = (EntityLivingBase)p_76986_1_.ridingEntity;
|
||||
f2 = this.interpolateRotation(entitylivingbase1.prevRenderYawOffset, entitylivingbase1.renderYawOffset, p_76986_9_);
|
||||
f4 = MathHelper.wrapAngleTo180_float(f3 - f2);
|
||||
|
||||
if (f4 < -85.0F)
|
||||
{
|
||||
f4 = -85.0F;
|
||||
}
|
||||
|
||||
if (f4 >= 85.0F)
|
||||
{
|
||||
f4 = 85.0F;
|
||||
}
|
||||
|
||||
f2 = f3 - f4;
|
||||
|
||||
if (f4 * f4 > 2500.0F)
|
||||
{
|
||||
f2 += f4 * 0.2F;
|
||||
}
|
||||
}
|
||||
|
||||
float f13 = p_76986_1_.prevRotationPitch + (p_76986_1_.rotationPitch - p_76986_1_.prevRotationPitch) * p_76986_9_;
|
||||
this.renderLivingAt(p_76986_1_, p_76986_2_, p_76986_4_, p_76986_6_);
|
||||
f4 = this.handleRotationFloat(p_76986_1_, p_76986_9_);
|
||||
this.rotateCorpse(p_76986_1_, f4, f2, p_76986_9_);
|
||||
float f5 = 0.0625F;
|
||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||
GL11.glScalef(-1.0F, -1.0F, 1.0F);
|
||||
this.preRenderCallback(p_76986_1_, p_76986_9_);
|
||||
GL11.glTranslatef(0.0F, -24.0F * f5 - 0.0078125F, 0.0F);
|
||||
float f6 = p_76986_1_.prevLimbSwingAmount + (p_76986_1_.limbSwingAmount - p_76986_1_.prevLimbSwingAmount) * p_76986_9_;
|
||||
float f7 = p_76986_1_.limbSwing - p_76986_1_.limbSwingAmount * (1.0F - p_76986_9_);
|
||||
|
||||
if (p_76986_1_.isChild())
|
||||
{
|
||||
f7 *= 3.0F;
|
||||
}
|
||||
|
||||
if (f6 > 1.0F)
|
||||
{
|
||||
f6 = 1.0F;
|
||||
}
|
||||
|
||||
GL11.glEnable(GL11.GL_ALPHA_TEST);
|
||||
this.mainModel.setLivingAnimations(p_76986_1_, f7, f6, p_76986_9_);
|
||||
this.renderModel(p_76986_1_, f7, f6, f4, f3 - f2, f13, f5);
|
||||
int j;
|
||||
float f8;
|
||||
float f9;
|
||||
float f10;
|
||||
|
||||
for (int i = 0; i < 4; ++i)
|
||||
{
|
||||
j = this.shouldRenderPass(p_76986_1_, i, p_76986_9_);
|
||||
|
||||
if (j > 0)
|
||||
{
|
||||
this.renderPassModel.setLivingAnimations(p_76986_1_, f7, f6, p_76986_9_);
|
||||
this.renderPassModel.render(p_76986_1_, f7, f6, f4, f3 - f2, f13, f5);
|
||||
|
||||
if ((j & 240) == 16)
|
||||
{
|
||||
this.func_82408_c(p_76986_1_, i, p_76986_9_);
|
||||
this.renderPassModel.render(p_76986_1_, f7, f6, f4, f3 - f2, f13, f5);
|
||||
}
|
||||
|
||||
if ((j & 15) == 15)
|
||||
{
|
||||
f8 = (float)p_76986_1_.ticksExisted + p_76986_9_;
|
||||
this.bindTexture(new ResourceLocation("textures/misc/enchanted_item_glint.png"));
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
f9 = 0.5F;
|
||||
GL11.glColor4f(f9, f9, f9, 1.0F);
|
||||
GL11.glDepthFunc(GL11.GL_EQUAL);
|
||||
GL11.glDepthMask(false);
|
||||
|
||||
for (int k = 0; k < 2; ++k)
|
||||
{
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
f10 = 0.76F;
|
||||
GL11.glColor4f(0.5F * f10, 0.25F * f10, 0.8F * f10, 1.0F);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE);
|
||||
GL11.glMatrixMode(GL11.GL_TEXTURE);
|
||||
GL11.glLoadIdentity();
|
||||
float f11 = f8 * (0.001F + (float)k * 0.003F) * 20.0F;
|
||||
float f12 = 0.33333334F;
|
||||
GL11.glScalef(f12, f12, f12);
|
||||
GL11.glRotatef(30.0F - (float)k * 60.0F, 0.0F, 0.0F, 1.0F);
|
||||
GL11.glTranslatef(0.0F, f11, 0.0F);
|
||||
GL11.glMatrixMode(GL11.GL_MODELVIEW);
|
||||
this.renderPassModel.render(p_76986_1_, f7, f6, f4, f3 - f2, f13, f5);
|
||||
}
|
||||
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
GL11.glMatrixMode(GL11.GL_TEXTURE);
|
||||
GL11.glDepthMask(true);
|
||||
GL11.glLoadIdentity();
|
||||
GL11.glMatrixMode(GL11.GL_MODELVIEW);
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
GL11.glDepthFunc(GL11.GL_LEQUAL);
|
||||
}
|
||||
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
GL11.glEnable(GL11.GL_ALPHA_TEST);
|
||||
}
|
||||
}
|
||||
|
||||
GL11.glDepthMask(true);
|
||||
this.renderEquippedItems(p_76986_1_, p_76986_9_);
|
||||
float f14 = p_76986_1_.getBrightness(p_76986_9_);
|
||||
j = this.getColorMultiplier(p_76986_1_, f14, p_76986_9_);
|
||||
OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit);
|
||||
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
||||
OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit);
|
||||
CustomTintData customTintData = p_76986_1_.display.customTintData;
|
||||
if ((j >> 24 & 255) > 0 || p_76986_1_.hurtTime > 0 || p_76986_1_.deathTime > 0 || (customTintData.isTintEnabled() && customTintData.isGeneralTintEnabled()))
|
||||
{
|
||||
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
||||
GL11.glDisable(GL11.GL_ALPHA_TEST);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
GL11.glDepthFunc(GL11.GL_EQUAL);
|
||||
|
||||
if ((p_76986_1_.hurtTime > 0 || p_76986_1_.deathTime > 0) && (!customTintData.isTintEnabled() || customTintData.isHurtTintEnabled()))
|
||||
{
|
||||
float r, g, b;
|
||||
if(customTintData.isTintEnabled()) {
|
||||
r = (float) (customTintData.getHurtTint() >> 16 & 255) / 255.0F * f14;
|
||||
g = (float) (customTintData.getHurtTint() >> 8 & 255) / 255.0F * f14;
|
||||
b = (float) (customTintData.getHurtTint() & 255) / 255.0F * f14;
|
||||
}else{
|
||||
r=f14;
|
||||
g=0;
|
||||
b=0;
|
||||
}
|
||||
GL11.glColor4f(r,g,b, 0.4F);
|
||||
this.mainModel.render(p_76986_1_, f7, f6, f4, f3 - f2, f13, f5);
|
||||
|
||||
for (int l = 0; l < 4; ++l)
|
||||
{
|
||||
if (this.inheritRenderPass(p_76986_1_, l, p_76986_9_) >= 0)
|
||||
{
|
||||
GL11.glColor4f(r,g,b, 0.4F);
|
||||
this.renderPassModel.render(p_76986_1_, f7, f6, f4, f3 - f2, f13, f5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((j >> 24 & 255) > 0)
|
||||
{
|
||||
f8 = (float)(j >> 16 & 255) / 255.0F;
|
||||
f9 = (float)(j >> 8 & 255) / 255.0F;
|
||||
float f15 = (float)(j & 255) / 255.0F;
|
||||
f10 = (float)(j >> 24 & 255) / 255.0F;
|
||||
GL11.glColor4f(f8, f9, f15, f10);
|
||||
this.mainModel.render(p_76986_1_, f7, f6, f4, f3 - f2, f13, f5);
|
||||
|
||||
for (int i1 = 0; i1 < 4; ++i1)
|
||||
{
|
||||
if (this.inheritRenderPass(p_76986_1_, i1, p_76986_9_) >= 0)
|
||||
{
|
||||
GL11.glColor4f(f8, f9, f15, f10);
|
||||
this.renderPassModel.render(p_76986_1_, f7, f6, f4, f3 - f2, f13, f5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GL11.glDepthFunc(GL11.GL_LEQUAL);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
GL11.glEnable(GL11.GL_ALPHA_TEST);
|
||||
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
||||
}
|
||||
|
||||
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit);
|
||||
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
||||
OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit);
|
||||
GL11.glEnable(GL11.GL_CULL_FACE);
|
||||
GL11.glPopMatrix();
|
||||
this.passSpecialRender(p_76986_1_, p_76986_2_, p_76986_4_, p_76986_6_);
|
||||
MinecraftForge.EVENT_BUS.post(new RenderLivingEvent.Post(p_76986_1_, this, p_76986_2_, p_76986_4_, p_76986_6_));
|
||||
this.func_110827_b(p_76986_1_, p_76986_2_, p_76986_4_, p_76986_6_, p_76986_8_, p_76986_9_);
|
||||
}
|
||||
|
||||
private float interpolateRotation(float p_77034_1_, float p_77034_2_, float p_77034_3_)
|
||||
{
|
||||
float f3;
|
||||
|
||||
for (f3 = p_77034_2_ - p_77034_1_; f3 < -180.0F; f3 += 360.0F)
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
while (f3 >= 180.0F)
|
||||
{
|
||||
f3 -= 360.0F;
|
||||
}
|
||||
|
||||
return p_77034_1_ + p_77034_3_ * f3;
|
||||
}
|
||||
|
||||
protected int getColorMultiplier(EntityLivingBase p_77030_1_, float p_77030_2_, float p_77030_3_)
|
||||
{
|
||||
EntityNPCInterface npc = (EntityNPCInterface) p_77030_1_;
|
||||
CustomTintData tintData = npc.display.customTintData;
|
||||
int alpha = (int) (0xff*((double)tintData.getGeneralAlpha()/100d)) << 24;
|
||||
return (tintData.isTintEnabled() && tintData.isGeneralTintEnabled())?tintData.getGeneralTint()+alpha:0;
|
||||
}
|
||||
|
||||
protected void renderModel(EntityLivingBase entityliving, float par2, float par3, float par4, float par5, float par6, float par7) {
|
||||
EntityNPCInterface npc = (EntityNPCInterface) entityliving;
|
||||
if(GeckoAddonClient.Instance.isGeckoModel(mainModel)){
|
||||
@@ -320,8 +577,6 @@ public class RenderNPCInterface extends RenderLiving{
|
||||
} else {
|
||||
npc.textureLocation = new ResourceLocation(npc.display.texture);
|
||||
}
|
||||
} else if(LastTextureTick < 5) { //fixes request flood somewhat
|
||||
return AbstractClientPlayer.locationStevePng;
|
||||
} else if(npc.display.skinType == 1 && npc.display.playerProfile != null) {
|
||||
Minecraft minecraft = Minecraft.getMinecraft();
|
||||
Map map = minecraft.func_152342_ad().func_152788_a(npc.display.playerProfile);
|
||||
@@ -330,22 +585,25 @@ public class RenderNPCInterface extends RenderLiving{
|
||||
}
|
||||
LastTextureTick = 0;
|
||||
} else if (npc.display.skinType == 2 || npc.display.skinType == 3) {
|
||||
try {
|
||||
MessageDigest digest = MessageDigest.getInstance("MD5");
|
||||
byte[] hash = digest.digest(npc.display.url.getBytes("UTF-8"));
|
||||
StringBuilder sb = new StringBuilder(2*hash.length);
|
||||
for (byte b : hash) {
|
||||
sb.append(String.format("%02x", b&0xff));
|
||||
}
|
||||
if (npc.display.skinType == 2) {
|
||||
npc.textureLocation = new ResourceLocation("skins/" + sb.toString());
|
||||
ClientCacheHandler.getNPCTexture(npc.display.url, false, npc.textureLocation);
|
||||
} else {
|
||||
npc.textureLocation = new ResourceLocation("skins64/" + sb.toString());
|
||||
ClientCacheHandler.getNPCTexture(npc.display.url, true, npc.textureLocation);
|
||||
}
|
||||
LastTextureTick = 0;
|
||||
} catch(Exception ignored){}
|
||||
ResourceLocation location = new ResourceLocation("skins/" + (npc.display.modelType + npc.display.url).hashCode());
|
||||
// If URL Empty Steve
|
||||
if(npc.display.url.isEmpty()){ return AbstractClientPlayer.locationStevePng; }
|
||||
// If URL Cached then grab it
|
||||
else if(ClientCacheHandler.isCachedNPC(location)){
|
||||
try {
|
||||
npc.textureLocation = ClientCacheHandler.getNPCTexture(npc.display.url, npc.display.modelType > 0, location).getLocation();
|
||||
} catch(Exception ignored){}
|
||||
}
|
||||
// For New URL Requests do not spam it
|
||||
else if(LastTextureTick < 5) { //fixes request flood somewhat
|
||||
return AbstractClientPlayer.locationStevePng;
|
||||
}
|
||||
else {
|
||||
try {
|
||||
npc.textureLocation = ClientCacheHandler.getNPCTexture(npc.display.url, npc.display.modelType > 0, location).getLocation();
|
||||
LastTextureTick = 0;
|
||||
} catch(Exception ignored){}
|
||||
}
|
||||
} else {
|
||||
return AbstractClientPlayer.locationStevePng;
|
||||
}
|
||||
|
||||
@@ -63,6 +63,10 @@ public class ConfigMain
|
||||
public static Property DatFormatProperty;
|
||||
public static boolean DatFormat = false;
|
||||
|
||||
public static Property MarketDatFormatProperty;
|
||||
public static boolean MarketDatFormat = false;
|
||||
|
||||
|
||||
public static Property DefaultMaxPartySizetProperty;
|
||||
public static int DefaultMaxPartySize = 4;
|
||||
|
||||
@@ -152,6 +156,9 @@ public class ConfigMain
|
||||
DatFormatProperty = config.get(GENERAL, "Dat Format for PlayerData", false, "You need to use '/kamkeel config playerdata' to convert existing playerdata to new format.");
|
||||
DatFormat = DatFormatProperty.getBoolean(false);
|
||||
|
||||
MarketDatFormatProperty = config.get(GENERAL, "Dat Format for Market", false, "You need to use '/kamkeel config market' to convert existing market to new format.");
|
||||
MarketDatFormat = MarketDatFormatProperty.getBoolean(false);
|
||||
|
||||
DefaultMaxPartySizetProperty = config.get(GENERAL, "Default Max Party Size", 4, "When creating a new Quest sets the default max party size");
|
||||
DefaultMaxPartySize = DefaultMaxPartySizetProperty.getInt(4);
|
||||
|
||||
@@ -280,4 +287,4 @@ public class ConfigMain
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,8 @@ import noppes.npcs.config.legacy.LegacyConfig;
|
||||
import org.apache.logging.log4j.Level;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.UUID;
|
||||
|
||||
public class ConfigScript
|
||||
@@ -50,6 +52,12 @@ public class ConfigScript
|
||||
public static Property ScriptDevIDsProperty;
|
||||
public static String ScriptDevIDs = "";
|
||||
|
||||
public static Property EnableBannedClassesProperty;
|
||||
public static boolean EnableBannedClasses = false;
|
||||
|
||||
public static Property BannedClassesProperty;
|
||||
public final static HashSet<String> BannedClasses = new HashSet<>();
|
||||
|
||||
public static void init(File configFile)
|
||||
{
|
||||
config = new Configuration(configFile);
|
||||
@@ -95,6 +103,14 @@ public class ConfigScript
|
||||
"If left empty and ScriptsOpsOnly is false, anyone can see and edit scripts with a scripter.");
|
||||
ScriptDevIDs = ScriptDevIDsProperty.getString();
|
||||
|
||||
EnableBannedClassesProperty = config.get(CUSTOMIZATION, "Enable Banned Classes", false, "Enables the Banned Classes Functionality");
|
||||
EnableBannedClasses = EnableBannedClassesProperty.getBoolean(false);
|
||||
|
||||
BannedClassesProperty = config.get(CUSTOMIZATION, "Banned Classes", "java.net.URL,java.net.URI",
|
||||
"Comma separated list of classes that cannot be used in scripts through Java.for().\n" +
|
||||
"Classes must be fully written out with library names preceding them.\n" +
|
||||
"This is a feature ONLY AVAILABLE ON NASHORN.");
|
||||
|
||||
// Convert to Legacy
|
||||
if(CustomNpcs.legacyExist){
|
||||
ScriptingEnabled = LegacyConfig.ScriptingEnabled;
|
||||
@@ -133,6 +149,11 @@ public class ConfigScript
|
||||
}
|
||||
} catch (Exception ignored) {}
|
||||
|
||||
String bannedClassesString = BannedClassesProperty.getString();
|
||||
try {
|
||||
BannedClasses.clear();
|
||||
BannedClasses.addAll(Arrays.asList(bannedClassesString.split(",")));
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -147,9 +168,8 @@ public class ConfigScript
|
||||
}
|
||||
|
||||
public static boolean isScriptDev(EntityPlayer player) {
|
||||
if(ScriptOpsOnly && !MinecraftServer.getServer().getConfigurationManager().func_152596_g(player.getGameProfile()) ||
|
||||
Developer.ScriptUser.contains(player.getUniqueID()) || Developer.Universal.contains(player.getUniqueID())){
|
||||
return true;
|
||||
} else return ScriptDevIDs.isEmpty();
|
||||
return ScriptOpsOnly && MinecraftServer.getServer().getConfigurationManager().func_152596_g(player.getGameProfile()) ||
|
||||
Developer.ScriptUser.contains(player.getUniqueID()) ||
|
||||
Developer.Universal.contains(player.getUniqueID());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -30,6 +30,7 @@ public enum EnumGuiType {
|
||||
ManageRecipes,
|
||||
QuestItem,
|
||||
NpcRemote,
|
||||
GlobalRemote,
|
||||
ScriptEvent,
|
||||
MoneyBag,
|
||||
MainMenuAI,
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package
|
||||
package
|
||||
noppes.npcs.constants;
|
||||
|
||||
public enum EnumPacketClient {
|
||||
CHAT,
|
||||
CHAT,
|
||||
MESSAGE,
|
||||
PARTY_MESSAGE,
|
||||
SYNCRECIPES_ADD,
|
||||
@@ -33,6 +33,8 @@ public enum EnumPacketClient {
|
||||
CHATBUBBLE,
|
||||
SYNCRECIPES_CARPENTRYBENCH,
|
||||
CLONE,
|
||||
CLONER,
|
||||
TELEPORTER,
|
||||
OPEN_BOOK,
|
||||
DIALOG_DUMMY,
|
||||
CONFIG,
|
||||
@@ -51,5 +53,6 @@ public enum EnumPacketClient {
|
||||
PAUSE_SOUNDS,
|
||||
CONTINUE_SOUNDS,
|
||||
STOP_SOUNDS,
|
||||
SYNC_WEAPON
|
||||
SYNC_WEAPON,
|
||||
MARK_DATA
|
||||
}
|
||||
@@ -4,26 +4,28 @@ import noppes.npcs.CustomNpcsPermissions;
|
||||
|
||||
public enum EnumPacketServer {
|
||||
Delete(CustomNpcsPermissions.NPC_DELETE, true),
|
||||
RemoteMainMenu(CustomNpcsPermissions.NPC_GUI),
|
||||
RemoteMainMenu(CustomNpcsPermissions.NPC_GUI),
|
||||
RemoteGlobalMenu(CustomNpcsPermissions.GLOBAL_REMOTE),
|
||||
NpcMenuClose(CustomNpcsPermissions.NPC_GUI, true),
|
||||
RemoteDelete(CustomNpcsPermissions.NPC_DELETE, true),
|
||||
RemoteFreeze(CustomNpcsPermissions.NPC_FREEZE),
|
||||
RemoteReset(CustomNpcsPermissions.NPC_RESET),
|
||||
SpawnMob(CustomNpcsPermissions.SPAWNER_MOB),
|
||||
RemoteDelete(CustomNpcsPermissions.NPC_DELETE, true),
|
||||
RemoteFreeze(CustomNpcsPermissions.NPC_FREEZE),
|
||||
RemoteReset(CustomNpcsPermissions.NPC_RESET),
|
||||
SpawnMob(CustomNpcsPermissions.SPAWNER_MOB),
|
||||
MobSpawner(CustomNpcsPermissions.SPAWNER_CREATE),
|
||||
MainmenuAISave(CustomNpcsPermissions.NPC_AI,true), MainmenuAIGet(true),
|
||||
|
||||
MainmenuAISave(CustomNpcsPermissions.NPC_AI,true), MainmenuAIGet(true),
|
||||
MainmenuInvSave(CustomNpcsPermissions.NPC_INVENTORY, true), MainmenuInvGet(true),
|
||||
MainmenuStatsSave(CustomNpcsPermissions.NPC_STATS, true), MainmenuStatsGet(true),
|
||||
|
||||
|
||||
MainmenuDisplaySave(CustomNpcsPermissions.NPC_DISPLAY, true), MainmenuDisplayGet(true),
|
||||
ModelDataSave(CustomNpcsPermissions.NPC_DISPLAY, true),
|
||||
|
||||
MainmenuAdvancedSave(CustomNpcsPermissions.NPC_ADVANCED,true), MainmenuAdvancedGet(true),
|
||||
DialogNpcSet(CustomNpcsPermissions.NPC_ADVANCED),
|
||||
ModelDataSave(CustomNpcsPermissions.NPC_DISPLAY, true),
|
||||
|
||||
MainmenuAdvancedSave(CustomNpcsPermissions.NPC_ADVANCED,true), MainmenuAdvancedGet(true), MainmenuAdvancedMarkData(CustomNpcsPermissions.NPC_ADVANCED,true),
|
||||
DialogNpcSet(CustomNpcsPermissions.NPC_ADVANCED),
|
||||
DialogNpcRemove(CustomNpcsPermissions.NPC_ADVANCED, true),
|
||||
FactionSet(CustomNpcsPermissions.NPC_ADVANCED, true),
|
||||
TagSet(CustomNpcsPermissions.NPC_ADVANCED, true),
|
||||
TransportSave(CustomNpcsPermissions.NPC_ADVANCED, true),
|
||||
TransportSave(CustomNpcsPermissions.NPC_ADVANCED, true),
|
||||
TransformSave(CustomNpcsPermissions.NPC_ADVANCED, true), TransformGet(true),
|
||||
TransformLoad(CustomNpcsPermissions.NPC_ADVANCED, true),
|
||||
TraderMarketSave(CustomNpcsPermissions.NPC_ADVANCED, true),
|
||||
@@ -32,40 +34,48 @@ public enum EnumPacketServer {
|
||||
JobSpawnerAdd(CustomNpcsPermissions.NPC_ADVANCED, true), JobSpawnerRemove(CustomNpcsPermissions.NPC_ADVANCED, true),
|
||||
RoleCompanionUpdate(CustomNpcsPermissions.NPC_ADVANCED, true),
|
||||
LinkedSet(CustomNpcsPermissions.NPC_ADVANCED, true),
|
||||
|
||||
|
||||
ClonePreSave(CustomNpcsPermissions.NPC_CLONE), CloneSave(CustomNpcsPermissions.NPC_CLONE), CloneRemove(CustomNpcsPermissions.NPC_CLONE), CloneList, CloneTagList, CloneAllTags, CloneAllTagsShort,
|
||||
|
||||
ScriptGlobalGuiDataSave(CustomNpcsPermissions.TOOL_SCRIPTER, false),
|
||||
ScriptGlobalGuiDataSave(CustomNpcsPermissions.SCRIPT_GLOBAL, false),
|
||||
ScriptGlobalGuiDataGet(false),
|
||||
|
||||
ScriptPlayerSave(CustomNpcsPermissions.TOOL_SCRIPTER, false),
|
||||
ScriptPlayerSave(CustomNpcsPermissions.SCRIPT_PLAYER, false),
|
||||
ScriptPlayerGet(false),
|
||||
|
||||
ScriptForgeSave(CustomNpcsPermissions.TOOL_SCRIPTER, false),
|
||||
ScriptForgeSave(CustomNpcsPermissions.SCRIPT_FORGE, false),
|
||||
ScriptForgeGet(false),
|
||||
|
||||
ScriptGlobalNPCSave(CustomNpcsPermissions.TOOL_SCRIPTER, false),
|
||||
ScriptGlobalNPCSave(CustomNpcsPermissions.SCRIPT_GLOBAL, false),
|
||||
ScriptGlobalNPCGet(false),
|
||||
|
||||
ScriptItemDataSave(CustomNpcsPermissions.TOOL_SCRIPTER, false),
|
||||
ScriptItemDataSave(CustomNpcsPermissions.SCRIPT_ITEM, false),
|
||||
ScriptItemDataGet(false),
|
||||
ScriptBlockDataSave(CustomNpcsPermissions.TOOL_SCRIPTER, false),
|
||||
|
||||
ScriptBlockDataSave(CustomNpcsPermissions.SCRIPT_BLOCK, false),
|
||||
ScriptBlockDataGet(false),
|
||||
|
||||
LinkedGetAll, LinkedRemove(CustomNpcsPermissions.GLOBAL_LINKED), LinkedAdd(CustomNpcsPermissions.GLOBAL_LINKED),
|
||||
ScriptDataSave(CustomNpcsPermissions.TOOL_SCRIPTER, true), ScriptDataGet(true),
|
||||
EventScriptDataSave(CustomNpcsPermissions.TOOL_SCRIPTER, true), EventScriptDataGet(true),
|
||||
PlayerDataRemove(CustomNpcsPermissions.GLOBAL_PLAYERDATA), PlayerDataRegen(CustomNpcsPermissions.GLOBAL_PLAYERDATA),
|
||||
BankSave(CustomNpcsPermissions.GLOBAL_BANK), BanksGet, BankGet,
|
||||
BankRemove(CustomNpcsPermissions.GLOBAL_BANK),
|
||||
DialogCategorySave(CustomNpcsPermissions.GLOBAL_DIALOG), DialogCategoriesGet, DialogsGetFromDialog,
|
||||
DialogCategoryRemove(CustomNpcsPermissions.GLOBAL_DIALOG), DialogCategoryGet,
|
||||
LinkedGetAll,
|
||||
LinkedRemove(CustomNpcsPermissions.GLOBAL_LINKED), LinkedAdd(CustomNpcsPermissions.GLOBAL_LINKED),
|
||||
|
||||
ScriptDataSave(CustomNpcsPermissions.SCRIPT_NPC, true), ScriptDataGet(true),
|
||||
EventScriptDataSave(CustomNpcsPermissions.SCRIPT_NPC, true), EventScriptDataGet(true),
|
||||
|
||||
PlayerDataRemove(CustomNpcsPermissions.GLOBAL_PLAYERDATA),
|
||||
PlayerDataMapRegen(CustomNpcsPermissions.GLOBAL_PLAYERDATA),
|
||||
|
||||
BankSave(CustomNpcsPermissions.GLOBAL_BANK), BanksGet, BankGet,
|
||||
BankRemove(CustomNpcsPermissions.GLOBAL_BANK),
|
||||
|
||||
DialogCategorySave(CustomNpcsPermissions.GLOBAL_DIALOG), DialogCategoriesGet, DialogsGetFromDialog,
|
||||
DialogCategoryRemove(CustomNpcsPermissions.GLOBAL_DIALOG), DialogCategoryGet,
|
||||
DialogSave(CustomNpcsPermissions.GLOBAL_DIALOG), DialogsGet, DialogGet,
|
||||
DialogRemove(CustomNpcsPermissions.GLOBAL_DIALOG),
|
||||
TransportCategoryRemove(CustomNpcsPermissions.GLOBAL_TRANSPORT), TransportGetLocation(true),
|
||||
DialogRemove(CustomNpcsPermissions.GLOBAL_DIALOG),
|
||||
|
||||
TransportCategoryRemove(CustomNpcsPermissions.GLOBAL_TRANSPORT), TransportGetLocation(true),
|
||||
TransportRemove(CustomNpcsPermissions.GLOBAL_TRANSPORT), TransportsGet,
|
||||
TransportCategorySave(CustomNpcsPermissions.GLOBAL_TRANSPORT), TransportCategoriesGet,
|
||||
FactionRemove(CustomNpcsPermissions.GLOBAL_FACTION),
|
||||
FactionRemove(CustomNpcsPermissions.GLOBAL_FACTION),
|
||||
FactionSave(CustomNpcsPermissions.GLOBAL_FACTION), FactionsGet, FactionGet,
|
||||
TagRemove(CustomNpcsPermissions.GLOBAL_TAG),
|
||||
TagSave(CustomNpcsPermissions.GLOBAL_TAG), TagsGet, TagGet, NpcTagsGet,
|
||||
@@ -73,24 +83,26 @@ public enum EnumPacketServer {
|
||||
QuestRemove(CustomNpcsPermissions.GLOBAL_QUEST),
|
||||
QuestCategoryRemove(CustomNpcsPermissions.GLOBAL_QUEST),
|
||||
QuestRewardSave(CustomNpcsPermissions.GLOBAL_QUEST),
|
||||
QuestSave(CustomNpcsPermissions.GLOBAL_QUEST), QuestsGetFromQuest, QuestsGet,
|
||||
QuestSave(CustomNpcsPermissions.GLOBAL_QUEST), QuestsGetFromQuest, QuestsGet,
|
||||
QuestDialogGetTitle(CustomNpcsPermissions.GLOBAL_QUEST),
|
||||
RecipeSave(CustomNpcsPermissions.GLOBAL_RECIPE),
|
||||
RecipeSave(CustomNpcsPermissions.GLOBAL_RECIPE),
|
||||
RecipeRemove(CustomNpcsPermissions.GLOBAL_RECIPE),
|
||||
NaturalSpawnSave(CustomNpcsPermissions.GLOBAL_NATURALSPAWN), NaturalSpawnGet,
|
||||
NaturalSpawnRemove(CustomNpcsPermissions.GLOBAL_NATURALSPAWN),
|
||||
MerchantUpdate(CustomNpcsPermissions.EDIT_VILLAGER),
|
||||
PlayerRider(CustomNpcsPermissions.TOOL_MOUNTER),
|
||||
PlayerRider(CustomNpcsPermissions.TOOL_MOUNTER),
|
||||
SpawnRider(CustomNpcsPermissions.TOOL_MOUNTER),
|
||||
MovingPathSave(CustomNpcsPermissions.TOOL_PATHER,true), MovingPathGet(true),
|
||||
MovingPathSave(CustomNpcsPermissions.TOOL_PATHER,true), MovingPathGet(true),
|
||||
DialogNpcGet,
|
||||
|
||||
AnimationsGet, AnimationGet, AnimationRemove, AnimationSave,
|
||||
AnimationsGet, AnimationGet,
|
||||
AnimationRemove(CustomNpcsPermissions.GLOBAL_ANIMATION), AnimationSave(CustomNpcsPermissions.GLOBAL_ANIMATION),
|
||||
|
||||
RecipesGet, RecipeGet, QuestOpenGui, PlayerDataGet, QuestLogToServer,
|
||||
|
||||
RemoteNpcsGet(CustomNpcsPermissions.NPC_GUI),
|
||||
RemoteTpToNpc,QuestGet, QuestCategoryGet,
|
||||
RemoteNpcsGet(CustomNpcsPermissions.NPC_GUI),
|
||||
RemoteTpToNpc(CustomNpcsPermissions.NPC_TELEPORT),
|
||||
QuestGet, QuestCategoryGet,
|
||||
SaveTileEntity,
|
||||
NaturalSpawnGetAll, MailOpenSetup,
|
||||
DimensionsGet, DimensionTeleport, GetTileEntity, Gui, IsGuiOpen, CacheAnimation,
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
package noppes.npcs.constants;
|
||||
|
||||
public enum EnumPlayerPacket {
|
||||
FollowerHire,FollowerExtend,Trader, FollowerState, Transport, BankUnlock, BankUpgrade, Dialog, QuestLog, CheckQuestCompletion, BankSlotOpen, FactionsGet, MailGet, MailDelete, MailSend, MailRead, MailboxOpenMail, SignSave, SaveBook, CompanionOpenInv, RoleGet, KeyPressed, MouseClicked, CompanionTalentExp, ScreenSize
|
||||
FollowerHire,FollowerExtend,Trader, FollowerState, Transport, BankUnlock, BankUpgrade,
|
||||
Dialog, QuestLog, CheckQuestCompletion, BankSlotOpen, FactionsGet,
|
||||
MailGet, MailDelete, MailSend, MailRead, MailboxOpenMail,
|
||||
SignSave, SaveBook, CompanionOpenInv, RoleGet, KeyPressed,
|
||||
MouseClicked, CompanionTalentExp, ScreenSize, MarkData
|
||||
}
|
||||
@@ -20,6 +20,7 @@ public enum EnumScriptType {
|
||||
ATTACKED("attacked"),
|
||||
ATTACK_MELEE("meleeAttack"),
|
||||
ATTACK_SWING("meleeSwing"),
|
||||
RIGHT_CLICK("rightClick"),
|
||||
ROLE("role"),
|
||||
RANGED_CHARGE("rangedCharge"),
|
||||
RANGED_LAUNCHED("rangedLaunched"),
|
||||
@@ -101,4 +102,4 @@ public enum EnumScriptType {
|
||||
private EnumScriptType(String function) {
|
||||
this.function = function;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package noppes.npcs.constants;
|
||||
|
||||
public class MarkType {
|
||||
public static final int NONE = 0;
|
||||
public static final int QUESTION = 1;
|
||||
public static final int EXCLAMATION = 2;
|
||||
public static final int POINTER = 3;
|
||||
public static final int SKULL = 4;
|
||||
public static final int CROSS = 5;
|
||||
public static final int STAR = 6;
|
||||
}
|
||||
@@ -12,10 +12,7 @@ import net.minecraft.util.ChatComponentText;
|
||||
import noppes.npcs.CustomNpcs;
|
||||
import noppes.npcs.LogWriter;
|
||||
import noppes.npcs.config.ConfigMain;
|
||||
import noppes.npcs.controllers.data.Bank;
|
||||
import noppes.npcs.controllers.data.PlayerBankData;
|
||||
import noppes.npcs.controllers.data.PlayerData;
|
||||
import noppes.npcs.controllers.data.PlayerMail;
|
||||
import noppes.npcs.controllers.data.*;
|
||||
import noppes.npcs.util.CacheHashMap;
|
||||
import noppes.npcs.util.NBTJsonUtil;
|
||||
|
||||
@@ -28,7 +25,7 @@ import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
|
||||
import static noppes.npcs.util.CustomNPCsThreader.playerDataThread;
|
||||
import static noppes.npcs.util.CustomNPCsThreader.customNPCThread;
|
||||
|
||||
public class PlayerDataController {
|
||||
public static PlayerDataController Instance;
|
||||
@@ -66,7 +63,7 @@ public class PlayerDataController {
|
||||
}
|
||||
}
|
||||
if(file.getName().endsWith(".dat")){
|
||||
NBTTagCompound compound = loadNBTData(file);
|
||||
NBTTagCompound compound = NBTJsonUtil.loadNBTData(file);
|
||||
if(compound.hasKey("PlayerName")){
|
||||
map.put(compound.getString("PlayerName"), file.getName().substring(0, file.getName().length() - 4));
|
||||
}
|
||||
@@ -128,7 +125,7 @@ public class PlayerDataController {
|
||||
}
|
||||
|
||||
public synchronized void savePlayerDataMap(){
|
||||
playerDataThread.execute(() -> {
|
||||
customNPCThread.execute(() -> {
|
||||
try {
|
||||
File saveDir = CustomNpcs.getWorldSaveDirectory();
|
||||
File file = new File(saveDir, "playerdatamap.dat_new");
|
||||
@@ -230,7 +227,7 @@ public class PlayerDataController {
|
||||
File file = new File(saveDir, filename);
|
||||
if(file.exists()){
|
||||
if(ConfigMain.DatFormat){
|
||||
return loadNBTData(file);
|
||||
return NBTJsonUtil.loadNBTData(file);
|
||||
} else {
|
||||
return NBTJsonUtil.LoadFile(file);
|
||||
}
|
||||
@@ -242,16 +239,7 @@ public class PlayerDataController {
|
||||
return new NBTTagCompound();
|
||||
}
|
||||
|
||||
public NBTTagCompound loadNBTData(File file){
|
||||
try {
|
||||
return CompressedStreamTools.readCompressed(new FileInputStream(file));
|
||||
} catch (Exception e) {
|
||||
LogWriter.error("Error loading: " + file.getName(), e);
|
||||
}
|
||||
return new NBTTagCompound();
|
||||
}
|
||||
|
||||
public void putPlayerDataCache(final String uuid, final PlayerData playerCompound) {
|
||||
public void putPlayerDataCache(final String uuid, final PlayerData playerCompound) {
|
||||
synchronized (playerDataCache) {
|
||||
playerDataCache.put(uuid, new CacheHashMap.CachedObject<>(playerCompound));
|
||||
}
|
||||
@@ -301,7 +289,9 @@ public class PlayerDataController {
|
||||
public PlayerData getPlayerData(EntityPlayer player){
|
||||
PlayerData data = getPlayerDataCache(player.getUniqueID().toString());
|
||||
if(data != null){
|
||||
data.player = player;
|
||||
if(data.player == null){
|
||||
data.player = player;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
@@ -311,7 +301,10 @@ public class PlayerDataController {
|
||||
data.player = player;
|
||||
data.load();
|
||||
}
|
||||
data.player = player;
|
||||
|
||||
if(data.player == null){
|
||||
data.player = player;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
@@ -453,7 +446,7 @@ public class PlayerDataController {
|
||||
}
|
||||
}
|
||||
if(file.getName().endsWith(".dat")){
|
||||
NBTTagCompound compound = loadNBTData(file);
|
||||
NBTTagCompound compound = NBTJsonUtil.loadNBTData(file);
|
||||
if(compound.hasKey("PlayerName")){
|
||||
map.put(compound.getString("PlayerName"), file.getName().substring(0, file.getName().length() - 4));
|
||||
}
|
||||
@@ -536,7 +529,7 @@ public class PlayerDataController {
|
||||
}
|
||||
} else {
|
||||
if(file.getName().endsWith(".dat")){
|
||||
compound = loadNBTData(file);
|
||||
compound = NBTJsonUtil.loadNBTData(file);
|
||||
if(compound.hasKey("PlayerName")){
|
||||
filename = file.getName().substring(0, file.getName().length() - 4);
|
||||
valid = true;
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package noppes.npcs.controllers;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import jdk.nashorn.api.scripting.ClassFilter;
|
||||
import jdk.nashorn.api.scripting.NashornScriptEngineFactory;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
@@ -248,7 +250,25 @@ public class ScriptController {
|
||||
private static final List<String> nashornNames = immutableList("nashorn", "Nashorn", "js", "JS", "JavaScript", "javascript", "ECMAScript", "ecmascript");
|
||||
public ScriptEngine getEngineByName(String language) {
|
||||
if (nashornNames.contains(language) && this.nashornFactory != null) {
|
||||
ScriptEngine scriptEngine = this.nashornFactory.getScriptEngine();
|
||||
ScriptEngine scriptEngine;
|
||||
if(ConfigScript.EnableBannedClasses){
|
||||
try {
|
||||
ClassFilter filter = s -> {
|
||||
for (String className : ConfigScript.BannedClasses) {
|
||||
if (s.compareTo(className) == 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
};
|
||||
NashornScriptEngineFactory nashornScriptEngineFactory = (NashornScriptEngineFactory) this.nashornFactory;
|
||||
scriptEngine = nashornScriptEngineFactory.getScriptEngine(filter);
|
||||
} catch (Exception e) {
|
||||
scriptEngine = this.nashornFactory.getScriptEngine();
|
||||
}
|
||||
} else {
|
||||
scriptEngine = this.nashornFactory.getScriptEngine();
|
||||
}
|
||||
scriptEngine.setBindings(this.manager.getBindings(), ScriptContext.GLOBAL_SCOPE);
|
||||
return scriptEngine;
|
||||
}
|
||||
@@ -300,4 +320,4 @@ public class ScriptController {
|
||||
|
||||
shouldSave = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -54,10 +54,9 @@ public class AnimationData implements IAnimationData {
|
||||
EntityLivingBase sendingEntity = parent instanceof PlayerData ? ((PlayerData) parent).player : parent instanceof DataDisplay ? ((DataDisplay) parent).npc : null;
|
||||
float range = parent instanceof PlayerData ? 160 : 60;
|
||||
if (sendingEntity != null) {
|
||||
|
||||
List<EntityPlayer> entities = sendingEntity.worldObj.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(
|
||||
sendingEntity.posX - range, sendingEntity.posY - range, sendingEntity.posZ - range,
|
||||
sendingEntity.posX + range, sendingEntity.posY + range, sendingEntity.posZ + range));
|
||||
sendingEntity.posX - range, sendingEntity.posY - range, sendingEntity.posZ - range,
|
||||
sendingEntity.posX + range, sendingEntity.posY + range, sendingEntity.posZ + range));
|
||||
|
||||
entities.removeIf(player -> Arrays.stream(excludedPlayers).anyMatch(exp -> player == exp));
|
||||
|
||||
@@ -153,7 +152,7 @@ public class AnimationData implements IAnimationData {
|
||||
} else {
|
||||
Animation newAnim = new Animation();
|
||||
newAnim.readFromNBT(((Animation) animation).writeToNBT());
|
||||
if (this.animation != null && newAnim.frames.size() > 0) {
|
||||
if (this.isActive() && !newAnim.frames.isEmpty()) {
|
||||
Frame frame = (Frame) this.animation.currentFrame();
|
||||
if (frame != null) {
|
||||
Frame firstFrame = newAnim.frames.get(0);
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
package noppes.npcs.controllers.data;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public class CustomTintData {
|
||||
private boolean tintEnabled = false;
|
||||
private boolean hurtTintEnabled = true;
|
||||
private boolean generalTintEnabled = false;
|
||||
private int hurtTint = 0xff0000;
|
||||
private int generalTint = 0x000000;
|
||||
private int generalAlpha = 40;
|
||||
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) {
|
||||
nbttagcompound.setBoolean("TintEnabled", tintEnabled);
|
||||
if(tintEnabled) {
|
||||
nbttagcompound.setBoolean("HurtTintEnabled", hurtTintEnabled);
|
||||
nbttagcompound.setBoolean("GeneralTintEnabled", generalTintEnabled);
|
||||
nbttagcompound.setInteger("HurtTint", hurtTint);
|
||||
nbttagcompound.setInteger("GeneralTint", generalTint);
|
||||
nbttagcompound.setInteger("GeneralAlpha", generalAlpha);
|
||||
}
|
||||
return nbttagcompound;
|
||||
}
|
||||
|
||||
public void readFromNBT(NBTTagCompound nbttagcompound) {
|
||||
tintEnabled = nbttagcompound.getBoolean("TintEnabled");
|
||||
if(tintEnabled) {
|
||||
hurtTintEnabled = nbttagcompound.getBoolean("HurtTintEnabled");
|
||||
generalTintEnabled = nbttagcompound.getBoolean("GeneralTintEnabled");
|
||||
hurtTint = nbttagcompound.getInteger("HurtTint");
|
||||
generalTint = nbttagcompound.getInteger("GeneralTint");
|
||||
generalAlpha = nbttagcompound.getInteger("GeneralAlpha");
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isHurtTintEnabled() {
|
||||
return hurtTintEnabled;
|
||||
}
|
||||
|
||||
public void setHurtTintEnabled(boolean hurtTintEnabled) {
|
||||
this.hurtTintEnabled = hurtTintEnabled;
|
||||
}
|
||||
|
||||
public int getHurtTint() {
|
||||
return hurtTint;
|
||||
}
|
||||
|
||||
public void setHurtTint(int colorHurtTint) {
|
||||
this.hurtTint = colorHurtTint;
|
||||
}
|
||||
|
||||
public int getGeneralTint() {
|
||||
return generalTint;
|
||||
}
|
||||
|
||||
public void setGeneralTint(int generalTint) {
|
||||
this.generalTint = generalTint;
|
||||
}
|
||||
|
||||
public boolean isTintEnabled() {
|
||||
return tintEnabled;
|
||||
}
|
||||
|
||||
public void setTintEnabled(boolean tintEnabled) {
|
||||
this.tintEnabled = tintEnabled;
|
||||
}
|
||||
|
||||
public boolean isGeneralTintEnabled() {
|
||||
return generalTintEnabled;
|
||||
}
|
||||
|
||||
public void setGeneralTintEnabled(boolean generalTintEnabled) {
|
||||
this.generalTintEnabled = generalTintEnabled;
|
||||
}
|
||||
|
||||
public int getGeneralAlpha() {
|
||||
return generalAlpha;
|
||||
}
|
||||
|
||||
public void setGeneralAlpha(int generalAlpha) {
|
||||
this.generalAlpha = generalAlpha;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
package noppes.npcs.controllers.data;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.IExtendedEntityProperties;
|
||||
import noppes.npcs.Server;
|
||||
import noppes.npcs.api.entity.data.IMark;
|
||||
import noppes.npcs.api.handler.data.IAvailability;
|
||||
import noppes.npcs.constants.EnumPacketClient;
|
||||
import noppes.npcs.constants.MarkType;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class MarkData implements IExtendedEntityProperties {
|
||||
|
||||
private static final String CNPCMARK = "cnpcmark";
|
||||
private EntityLivingBase entity;
|
||||
|
||||
public List<Mark> marks = new ArrayList<Mark>();
|
||||
|
||||
public void setNBT(NBTTagCompound compound){
|
||||
List<Mark> marks = new ArrayList<Mark>();
|
||||
NBTTagList list = compound.getTagList("marks", 10);
|
||||
for(int i = 0; i < list.tagCount(); i++){
|
||||
NBTTagCompound c = list.getCompoundTagAt(i);
|
||||
Mark m = new Mark();
|
||||
m.type = c.getInteger("type");
|
||||
m.color = c.getInteger("color");
|
||||
m.availability.readFromNBT(c.getCompoundTag("availability"));
|
||||
marks.add(m);
|
||||
}
|
||||
this.marks = marks;
|
||||
}
|
||||
|
||||
public NBTTagCompound getNBT() {
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
NBTTagList list = new NBTTagList();
|
||||
for(Mark m : marks){
|
||||
NBTTagCompound c = new NBTTagCompound();
|
||||
c.setInteger("type", m.type);
|
||||
c.setInteger("color", m.color);
|
||||
c.setTag("availability", m.availability.writeToNBT(new NBTTagCompound()));
|
||||
list.appendTag(c);
|
||||
}
|
||||
compound.setTag("marks", list);
|
||||
return compound;
|
||||
}
|
||||
|
||||
public static boolean has(EntityLivingBase entity) {
|
||||
return entity.getExtendedProperties(CNPCMARK) != null;
|
||||
}
|
||||
|
||||
public static MarkData get(EntityNPCInterface npc){
|
||||
if(!MarkData.has(npc)){
|
||||
npc.registerExtendedProperties(CNPCMARK, new MarkData());
|
||||
}
|
||||
|
||||
MarkData data = (MarkData) npc.getExtendedProperties(CNPCMARK);
|
||||
if(data.entity == null){
|
||||
data.entity = npc;
|
||||
data.setNBT(npc.getEntityData().getCompoundTag(CNPCMARK));
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
public IMark addMark(int type) {
|
||||
Mark m = new Mark();
|
||||
m.type = type;
|
||||
marks.add(m);
|
||||
if (!entity.worldObj.isRemote)
|
||||
syncClients();
|
||||
return m;
|
||||
}
|
||||
|
||||
public IMark addMark(int type, int color) {
|
||||
Mark m = new Mark();
|
||||
m.type = type;
|
||||
m.color = color;
|
||||
marks.add(m);
|
||||
if (!entity.worldObj.isRemote)
|
||||
syncClients();
|
||||
return m;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveNBTData(NBTTagCompound compound) {
|
||||
if (!(this.entity instanceof EntityNPCInterface)) {
|
||||
return;
|
||||
}
|
||||
this.entity.getEntityData().setTag(CNPCMARK, this.getNBT());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadNBTData(NBTTagCompound compound) {}
|
||||
|
||||
@Override
|
||||
public void init(Entity entity, World world) {}
|
||||
|
||||
public void syncClients() {
|
||||
Server.sendToAll(EnumPacketClient.MARK_DATA, entity.getEntityId(), getNBT());
|
||||
}
|
||||
|
||||
public class Mark implements IMark {
|
||||
public int type = MarkType.NONE;
|
||||
public Availability availability = new Availability();
|
||||
public int color = 0xFFED51;
|
||||
|
||||
@Override
|
||||
public IAvailability getAvailability() {
|
||||
return availability;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setColor(int color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setType(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
MarkData.this.syncClients();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -38,6 +38,7 @@ public class Party {
|
||||
|
||||
//Client-sided
|
||||
private String partyLeaderName;
|
||||
private Quest quest;
|
||||
|
||||
public Party() {
|
||||
this.partyUUID = UUID.randomUUID();
|
||||
@@ -68,7 +69,11 @@ public class Party {
|
||||
}
|
||||
|
||||
public IQuest getQuest() {
|
||||
return QuestController.Instance.get(this.currentQuestID);
|
||||
if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) {
|
||||
return QuestController.Instance.get(this.currentQuestID);
|
||||
} else {
|
||||
return this.quest;
|
||||
}
|
||||
}
|
||||
|
||||
public int getCurrentQuestID() {
|
||||
@@ -295,11 +300,16 @@ public class Party {
|
||||
|
||||
public void readFromNBT(NBTTagCompound compound) {
|
||||
this.partyLeaderName = compound.getString("PartyLeader");
|
||||
this.currentQuestID = compound.getInteger("PartyQuestID");
|
||||
this.currentQuestName = compound.getString("PartyQuestName");
|
||||
this.friendlyFire = compound.getBoolean("FriendlyFire");
|
||||
this.partyLocked = compound.getBoolean("PartyLocked");
|
||||
|
||||
this.currentQuestID = compound.getInteger("PartyQuestID");
|
||||
if (compound.hasKey("QuestNBT")) {
|
||||
this.quest = new Quest();
|
||||
this.quest.readNBT(compound.getCompoundTag("QuestNBT"));
|
||||
}
|
||||
|
||||
NBTTagList list = compound.getTagList("PartyMembers", 10);
|
||||
for (int i = 0; i < list.tagCount(); i++) {
|
||||
NBTTagCompound tagCompound = list.getCompoundTagAt(i);
|
||||
@@ -314,11 +324,16 @@ public class Party {
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
|
||||
compound.setString("PartyUUID", this.partyUUID.toString());
|
||||
compound.setInteger("PartyQuestID", this.currentQuestID);
|
||||
compound.setString("PartyQuestName", this.currentQuestName);
|
||||
compound.setBoolean("FriendlyFire", this.friendlyFire);
|
||||
compound.setBoolean("PartyLocked", this.partyLocked);
|
||||
|
||||
compound.setInteger("PartyQuestID", this.currentQuestID);
|
||||
if (this.getQuest() != null) {
|
||||
Quest quest = (Quest) this.getQuest();
|
||||
compound.setTag("QuestNBT", quest.writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
|
||||
NBTTagList list = new NBTTagList();
|
||||
for (UUID uuid : this.partyOrder) {
|
||||
NBTTagCompound uuidCompound = new NBTTagCompound();
|
||||
|
||||
@@ -60,8 +60,9 @@ public class PlayerData implements IExtendedEntityProperties, IPlayerData {
|
||||
public int companionID = 0;
|
||||
|
||||
public boolean isGUIOpen = false;
|
||||
public boolean hadInteract = true;
|
||||
|
||||
public ScreenSize screenSize = new ScreenSize(-1,-1);
|
||||
public ScreenSize screenSize = new ScreenSize(-1,-1);
|
||||
|
||||
public void onLogin() {
|
||||
|
||||
@@ -277,7 +278,7 @@ public class PlayerData implements IExtendedEntityProperties, IPlayerData {
|
||||
}
|
||||
PlayerDataController.Instance.putPlayerMap(playername, uuid);
|
||||
PlayerDataController.Instance.putPlayerDataCache(uuid, this);
|
||||
CustomNPCsThreader.playerDataThread.execute(() -> {
|
||||
CustomNPCsThreader.customNPCThread.execute(() -> {
|
||||
try {
|
||||
File saveDir = PlayerDataController.Instance.getSaveDir();
|
||||
File file = new File(saveDir, filename + "_new");
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
//
|
||||
// Source code recreated from a .class file by IntelliJ IDEA
|
||||
// (powered by Fernflower decompiler)
|
||||
//
|
||||
package noppes.npcs.controllers.data;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
@@ -320,4 +316,4 @@ public class PlayerDataScript implements INpcScriptHandler {
|
||||
public static PlayerDataScript.ToStringHelper toStringHelper(Object self) {
|
||||
return new PlayerDataScript.ToStringHelper(self.getClass().getSimpleName());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -394,7 +394,6 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
||||
updateClient = false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean interact(EntityPlayer player) {
|
||||
if(worldObj.isRemote)
|
||||
|
||||
@@ -5,16 +5,20 @@ import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ChatComponentTranslation;
|
||||
import net.minecraft.world.World;
|
||||
import noppes.npcs.CustomItems;
|
||||
import noppes.npcs.CustomNpcs;
|
||||
import noppes.npcs.CustomNpcsPermissions;
|
||||
import noppes.npcs.NoppesUtilServer;
|
||||
import noppes.npcs.constants.EnumGuiType;
|
||||
|
||||
public class ItemNpcCloner extends Item{
|
||||
|
||||
|
||||
public ItemNpcCloner(){
|
||||
maxStackSize = 1;
|
||||
setCreativeTab(CustomItems.tab);
|
||||
@@ -22,8 +26,10 @@ public class ItemNpcCloner extends Item{
|
||||
|
||||
@Override
|
||||
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10){
|
||||
if(par3World.isRemote)
|
||||
CustomNpcs.proxy.openGui(par4, par5, par6, EnumGuiType.MobSpawner, par2EntityPlayer);
|
||||
if(par3World.isRemote || !CustomNpcsPermissions.Instance.hasPermission(par2EntityPlayer, CustomNpcsPermissions.TOOL_CLONER))
|
||||
return true;
|
||||
|
||||
NoppesUtilServer.setClonerGui((EntityPlayerMP) par2EntityPlayer, par4, par5, par6);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -36,7 +42,7 @@ public class ItemNpcCloner extends Item{
|
||||
public boolean requiresMultipleRenderPasses(){
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void registerIcons(IIconRegister par1IconRegister){
|
||||
|
||||
@@ -12,6 +12,7 @@ import net.minecraft.util.ChatComponentTranslation;
|
||||
import net.minecraft.world.World;
|
||||
import noppes.npcs.CustomItems;
|
||||
import noppes.npcs.CustomNpcs;
|
||||
import noppes.npcs.CustomNpcsPermissions;
|
||||
import noppes.npcs.config.ConfigScript;
|
||||
import noppes.npcs.constants.EnumGuiType;
|
||||
|
||||
@@ -21,12 +22,12 @@ public class ItemNpcScripter extends Item{
|
||||
maxStackSize = 1;
|
||||
setCreativeTab(CustomItems.tab);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getColorFromItemStack(ItemStack par1ItemStack, int par2){
|
||||
return 0x8B4513;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean requiresMultipleRenderPasses(){
|
||||
return true;
|
||||
@@ -36,7 +37,7 @@ public class ItemNpcScripter extends Item{
|
||||
public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player){
|
||||
if(!world.isRemote)
|
||||
return itemStack;
|
||||
if(!ConfigScript.isScriptDev(player)){
|
||||
if(!ConfigScript.isScriptDev(player) && !CustomNpcsPermissions.hasPermission(player, CustomNpcsPermissions.TOOL_SCRIPTER)){
|
||||
player.addChatMessage(new ChatComponentTranslation("availability.permission"));
|
||||
} else {
|
||||
CustomNpcs.proxy.openGui(0, 0, 0, EnumGuiType.ScriptEvent, player);
|
||||
|
||||
@@ -20,17 +20,21 @@ import noppes.npcs.constants.EnumGuiType;
|
||||
import noppes.npcs.entity.EntityCustomNpc;
|
||||
|
||||
public class ItemNpcWand extends Item{
|
||||
|
||||
|
||||
public ItemNpcWand(){
|
||||
maxStackSize = 1;
|
||||
setCreativeTab(CustomItems.tab);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer){
|
||||
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer player){
|
||||
if(!par2World.isRemote)
|
||||
return par1ItemStack;
|
||||
CustomNpcs.proxy.openGui(0, 0, 0, EnumGuiType.NpcRemote, par3EntityPlayer);
|
||||
else if(CustomNpcsPermissions.hasPermission(player, CustomNpcsPermissions.NPC_GUI)){
|
||||
CustomNpcs.proxy.openGui(0, 0, 0, EnumGuiType.NpcRemote, player);
|
||||
}
|
||||
else
|
||||
player.addChatMessage(new ChatComponentTranslation("availability.permission"));
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
@@ -45,7 +49,7 @@ public class ItemNpcWand extends Item{
|
||||
else if(CustomNpcsPermissions.hasPermission(player, CustomNpcsPermissions.NPC_CREATE)){
|
||||
EntityCustomNpc npc = new EntityCustomNpc(par3World);
|
||||
npc.ai.startPos = new int[]{par4,par5,par6};
|
||||
|
||||
|
||||
npc.setLocationAndAngles((float)par4 + 0.5F, npc.getStartYPos(), (float)par6 + 0.5F, player.rotationYaw, player.rotationPitch);
|
||||
|
||||
par3World.spawnEntityInWorld(npc);
|
||||
@@ -57,7 +61,7 @@ public class ItemNpcWand extends Item{
|
||||
player.addChatMessage(new ChatComponentTranslation("availability.permission"));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getColorFromItemStack(ItemStack par1ItemStack, int par2){
|
||||
return 0x8B4513;
|
||||
@@ -66,7 +70,7 @@ public class ItemNpcWand extends Item{
|
||||
public boolean requiresMultipleRenderPasses(){
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void registerIcons(IIconRegister par1IconRegister){
|
||||
|
||||
@@ -16,6 +16,7 @@ import net.minecraft.util.ChatComponentTranslation;
|
||||
import net.minecraft.world.World;
|
||||
import noppes.npcs.CustomItems;
|
||||
import noppes.npcs.CustomNpcs;
|
||||
import noppes.npcs.CustomNpcsPermissions;
|
||||
import noppes.npcs.EventHooks;
|
||||
import noppes.npcs.api.item.IItemStack;
|
||||
import noppes.npcs.config.ConfigScript;
|
||||
@@ -58,7 +59,7 @@ public class ItemScripted extends Item implements ItemRenderInterface {
|
||||
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
|
||||
{
|
||||
if(player.isSneaking() && player.capabilities.isCreativeMode) {
|
||||
if(!ConfigScript.isScriptDev(player)){
|
||||
if(!ConfigScript.isScriptDev(player) && !CustomNpcsPermissions.Instance.hasPermission(player, CustomNpcsPermissions.TOOL_SCRIPTED_ITEM)){
|
||||
player.addChatMessage(new ChatComponentTranslation("availability.permission"));
|
||||
} else {
|
||||
CustomNpcs.proxy.openGui(0, 0, 0, EnumGuiType.ScriptItem, player);
|
||||
|
||||
@@ -7,6 +7,7 @@ import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
@@ -18,6 +19,8 @@ import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import noppes.npcs.CustomItems;
|
||||
import noppes.npcs.CustomNpcs;
|
||||
import noppes.npcs.CustomNpcsPermissions;
|
||||
import noppes.npcs.NoppesUtilServer;
|
||||
import noppes.npcs.constants.EnumGuiType;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
@@ -25,7 +28,7 @@ import java.util.List;
|
||||
|
||||
|
||||
public class ItemTeleporter extends Item{
|
||||
|
||||
|
||||
public ItemTeleporter(){
|
||||
maxStackSize = 1;
|
||||
setCreativeTab(CustomItems.tab);
|
||||
@@ -33,9 +36,10 @@ public class ItemTeleporter extends Item{
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer){
|
||||
if(!par2World.isRemote)
|
||||
return par1ItemStack;
|
||||
CustomNpcs.proxy.openGui((EntityNPCInterface)null,EnumGuiType.NpcDimensions);
|
||||
if(par2World.isRemote || !CustomNpcsPermissions.Instance.hasPermission(par3EntityPlayer, CustomNpcsPermissions.TOOL_TELEPORTER))
|
||||
return par1ItemStack;
|
||||
|
||||
NoppesUtilServer.setTeleporterGUI((EntityPlayerMP) par3EntityPlayer);
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
@@ -61,7 +65,7 @@ public class ItemTeleporter extends Item{
|
||||
MovingObjectPosition movingobjectposition = par3EntityPlayer.worldObj.rayTraceBlocks(vec3, vec31, true);
|
||||
if (movingobjectposition == null)
|
||||
return false;
|
||||
|
||||
|
||||
Vec3 vec32 = par3EntityPlayer.getLook(f);
|
||||
boolean flag = false;
|
||||
float f9 = 1.0F;
|
||||
@@ -82,88 +86,32 @@ public class ItemTeleporter extends Item{
|
||||
|
||||
if (flag)
|
||||
return false;
|
||||
|
||||
|
||||
if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK){
|
||||
int i = movingobjectposition.blockX;
|
||||
int j = movingobjectposition.blockY;
|
||||
int k = movingobjectposition.blockZ;
|
||||
|
||||
|
||||
while(par3EntityPlayer.worldObj.getBlock(i, j, k) != Blocks.air){
|
||||
j++;
|
||||
}
|
||||
par3EntityPlayer.setPositionAndUpdate(i + 0.5F, j + 1.0F, k + 0.5F);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
// protected static MovingObjectPosition rayTraceBlocks(EntityPlayer entityPlayer, int radius) {
|
||||
// Vec3 vec3 = Vec3.createVectorHelper(entityPlayer.posX, entityPlayer.height * 0.8 + entityPlayer.boundingBox.minY, entityPlayer.posZ);
|
||||
// Vec3 vec3a = entityPlayer.getLookVec();
|
||||
// Vec3 vec3b = vec3.addVector(vec3a.xCoord * radius, vec3a.yCoord * radius, vec3a.zCoord * radius);
|
||||
//
|
||||
// return entityPlayer.worldObj.func_147447_a(vec3, vec3b, false, false, true);
|
||||
// }
|
||||
//
|
||||
// protected static MovingObjectPosition getPointingEntity(EntityPlayer entityPlayer, int radius) {
|
||||
// MovingObjectPosition block = rayTraceBlocks(entityPlayer, radius);
|
||||
// Vec3 vec3 = Vec3.createVectorHelper(entityPlayer.posX, entityPlayer.height * 0.8 + entityPlayer.boundingBox.minY, entityPlayer.posZ);
|
||||
//
|
||||
// Vec3 vec31 = entityPlayer.getLookVec();
|
||||
// Vec3 vec32 = vec3.addVector(vec31.xCoord * radius, vec31.yCoord * radius, vec31.zCoord * radius);
|
||||
// Vec3 vec33 = null;
|
||||
// List<Entity> entities = entityPlayer.worldObj.getEntitiesWithinAABBExcludingEntity(entityPlayer, entityPlayer.boundingBox.addCoord(vec31.xCoord * radius, vec31.yCoord * radius, vec31.zCoord * radius).expand(1.0D, 1.0D, 1.0D));
|
||||
// Entity pointedEntity = null;
|
||||
// double d = radius;
|
||||
//
|
||||
// for (Entity entity : entities) {
|
||||
// if (entity.canBeCollidedWith()) {
|
||||
// float f = entity.getCollisionBorderSize();
|
||||
// AxisAlignedBB axisalignedbb = entity.boundingBox.expand((double)f, (double)f, (double)f);
|
||||
// MovingObjectPosition movingObjectPosition = axisalignedbb.calculateIntercept(vec3, vec32);
|
||||
//
|
||||
// if (axisalignedbb.isVecInside(vec3)) {
|
||||
// if (0.0D < radius || radius == 0.0D) {
|
||||
// pointedEntity = entity;
|
||||
// vec33 = movingObjectPosition == null ? vec3 : movingObjectPosition.hitVec;
|
||||
// d = 0.0D;
|
||||
// }
|
||||
// } else if (movingObjectPosition != null) {
|
||||
// double d2 = vec3.distanceTo(movingObjectPosition.hitVec);
|
||||
//
|
||||
// if (d2 < radius || radius == 0.0D) {
|
||||
// if (entity == entityPlayer.ridingEntity && !entity.canRiderInteract()) {
|
||||
// if (radius == 0.0D) {
|
||||
// pointedEntity = entity;
|
||||
// vec33 = movingObjectPosition.hitVec;
|
||||
// }
|
||||
// } else {
|
||||
// pointedEntity = entity;
|
||||
// vec33 = movingObjectPosition.hitVec;
|
||||
// d = d2;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (pointedEntity != null && (d < radius)) {
|
||||
// return new MovingObjectPosition(pointedEntity, vec33);
|
||||
// }
|
||||
//
|
||||
// return null;
|
||||
// }
|
||||
|
||||
|
||||
@Override
|
||||
public int getColorFromItemStack(ItemStack par1ItemStack, int par2){
|
||||
return 0x8B4513;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean requiresMultipleRenderPasses(){
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void registerIcons(IIconRegister par1IconRegister){
|
||||
|
||||
@@ -49,7 +49,7 @@ public class CustomNPCsMixinPlugin implements IMixinConfigPlugin {
|
||||
}
|
||||
if (ConfigMixin.AnimationMixin) {
|
||||
mixins.add("MixinModelRenderer");
|
||||
mixins.add("MixinRenderPlayer");
|
||||
mixins.add("MixinModelBase");
|
||||
}
|
||||
if (ConfigMixin.FirstPersonAnimationMixin) {
|
||||
mixins.add("MixinItemRenderer");
|
||||
|
||||
@@ -122,8 +122,16 @@ public abstract class MixinItemRenderer {
|
||||
float f4 = entityplayersp.prevRenderArmYaw + (entityplayersp.renderArmYaw - entityplayersp.prevRenderArmYaw) * partialRenderTick;
|
||||
GL11.glRotatef((entityclientplayermp.rotationPitch - f3) * 0.1F, 1.0F, 0.0F, 0.0F);
|
||||
GL11.glRotatef((entityclientplayermp.rotationYaw - f4) * 0.1F, 0.0F, 1.0F, 0.0F);
|
||||
ItemStack itemstack = itemRenderer.itemToRender;
|
||||
|
||||
if (animData != null && animData.isActive()) {
|
||||
if (frame.frameParts.containsKey(EnumAnimationPart.FULL_MODEL)) {
|
||||
FramePart part = frame.frameParts.get(EnumAnimationPart.FULL_MODEL);
|
||||
float pi = 180 / (float) Math.PI;
|
||||
GL11.glRotatef(-part.prevRotations[1] * pi, 0, 1, 0);
|
||||
}
|
||||
}
|
||||
|
||||
ItemStack itemstack = itemRenderer.itemToRender;
|
||||
int i = Minecraft.getMinecraft().theWorld.getLightBrightnessForSkyBlocks(MathHelper.floor_double(entityclientplayermp.posX), MathHelper.floor_double(entityclientplayermp.posY), MathHelper.floor_double(entityclientplayermp.posZ), 0);
|
||||
int j = i % 65536;
|
||||
int k = i / 65536;
|
||||
|
||||
+8
-8
@@ -2,8 +2,8 @@ package noppes.npcs.mixin;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.entity.AbstractClientPlayer;
|
||||
import net.minecraft.client.renderer.entity.RenderPlayer;
|
||||
import net.minecraft.client.model.ModelBase;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import noppes.npcs.client.ClientCacheHandler;
|
||||
import noppes.npcs.constants.EnumAnimationPart;
|
||||
import noppes.npcs.controllers.data.AnimationData;
|
||||
@@ -15,15 +15,15 @@ import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(value = RenderPlayer.class)
|
||||
public abstract class MixinRenderPlayer {
|
||||
@Mixin(value = ModelBase.class)
|
||||
public abstract class MixinModelBase {
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Inject(method = "rotateCorpse*", at = @At(value = "TAIL"))
|
||||
protected void modelDataRotations(AbstractClientPlayer p_77043_1_, float p_77043_2_, float p_77043_3_, float p_77043_4_, CallbackInfo callbackInfo)
|
||||
@Inject(method = "setLivingAnimations", at = @At(value = "TAIL"))
|
||||
public void setLivingAnimations(EntityLivingBase p_78086_1_, float p_78086_2_, float p_78086_3_, float p_78086_4_, CallbackInfo callbackInfo)
|
||||
{
|
||||
if (ClientCacheHandler.playerAnimations.containsKey(p_77043_1_.getUniqueID())) {
|
||||
AnimationData animData = ClientCacheHandler.playerAnimations.get(p_77043_1_.getUniqueID());
|
||||
if (ClientCacheHandler.playerAnimations.containsKey(p_78086_1_.getUniqueID())) {
|
||||
AnimationData animData = ClientCacheHandler.playerAnimations.get(p_78086_1_.getUniqueID());
|
||||
if (animData != null && animData.isActive()) {
|
||||
Frame frame = (Frame) animData.animation.currentFrame();
|
||||
if (frame.frameParts.containsKey(EnumAnimationPart.FULL_MODEL)) {
|
||||
@@ -5,10 +5,10 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.model.ModelBase;
|
||||
import net.minecraft.client.model.ModelBiped;
|
||||
import net.minecraft.client.model.ModelRenderer;
|
||||
import noppes.npcs.controllers.data.AnimationData;
|
||||
import noppes.npcs.client.ClientCacheHandler;
|
||||
import noppes.npcs.client.ClientEventHandler;
|
||||
import noppes.npcs.constants.EnumAnimationPart;
|
||||
import noppes.npcs.controllers.data.AnimationData;
|
||||
import noppes.npcs.controllers.data.Frame;
|
||||
import noppes.npcs.controllers.data.FramePart;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
@@ -81,7 +81,86 @@ public abstract class MixinModelRenderer {
|
||||
float prevAngleY = this.rotateAngleY;
|
||||
float prevAngleZ = this.rotateAngleZ;
|
||||
|
||||
this.setAnimationValues(p_78785_1_);
|
||||
FramePart currentPart = null;
|
||||
if (ClientEventHandler.renderingNpc != null && ClientEventHandler.renderingNpc.display.animationData.isActive()) {
|
||||
AnimationData animData = ClientEventHandler.renderingNpc.display.animationData;
|
||||
EnumAnimationPart partType = this.getPartType((ModelRenderer) (Object) this);
|
||||
|
||||
if (partType != null && animData != null) {
|
||||
Frame frame = (Frame) animData.animation.currentFrame();
|
||||
if (frame.frameParts.containsKey(partType)) {
|
||||
currentPart = frame.frameParts.get(partType);
|
||||
currentPart.interpolateOffset();
|
||||
currentPart.interpolateAngles();
|
||||
this.rotationPointX += currentPart.prevPivots[0];
|
||||
this.rotationPointY += currentPart.prevPivots[1];
|
||||
this.rotationPointZ += currentPart.prevPivots[2];
|
||||
this.rotateAngleX = currentPart.prevRotations[0];
|
||||
this.rotateAngleY = currentPart.prevRotations[1];
|
||||
this.rotateAngleZ = currentPart.prevRotations[2];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ClientEventHandler.renderingPlayer != null) {
|
||||
ClientEventHandler.playerModel = ((ModelRenderer) (Object) this).baseModel;
|
||||
}
|
||||
if (ClientEventHandler.renderingPlayer != null && ClientCacheHandler.playerAnimations.containsKey(ClientEventHandler.renderingPlayer.getUniqueID())) {
|
||||
ClientEventHandler.playerModel = ((ModelRenderer) (Object) this).baseModel;
|
||||
AnimationData animData = ClientCacheHandler.playerAnimations.get(ClientEventHandler.renderingPlayer.getUniqueID());
|
||||
|
||||
EnumAnimationPart mainPartType = this.getPlayerPartType((ModelRenderer) (Object) this);
|
||||
EnumAnimationPart partType = mainPartType != null ? mainPartType : this.pivotEqualPart((ModelRenderer) (Object) this);
|
||||
if (partType != null && animData != null && animData.animation != null) {
|
||||
boolean animDataActive = animData.isActive();
|
||||
|
||||
if (!ClientEventHandler.originalValues.containsKey((ModelRenderer) (Object) this)) {
|
||||
FramePart part = new FramePart();
|
||||
part.pivot = new float[]{prevPointX, prevPointY, prevPointZ};
|
||||
part.rotation = new float[]{prevAngleX, prevAngleY, prevAngleZ};
|
||||
ClientEventHandler.originalValues.put((ModelRenderer) (Object) this, part);
|
||||
}
|
||||
|
||||
FramePart originalPart = ClientEventHandler.originalValues.get((ModelRenderer) (Object) this);
|
||||
Frame frame = (Frame) animData.animation.currentFrame();
|
||||
if (!animDataActive && animData.finishedFrame >= 0 && animData.finishedFrame < animData.animation.frames.size()) {
|
||||
frame = animData.animation.frames.get(animData.finishedFrame);
|
||||
}
|
||||
|
||||
if (frame != null && frame.frameParts.containsKey(partType)) {
|
||||
FramePart part = frame.frameParts.get(partType);
|
||||
if (partType == mainPartType) {
|
||||
if (animDataActive) {
|
||||
part.interpolateAngles();
|
||||
part.interpolateOffset();
|
||||
} else {
|
||||
float speed = 0.4F;
|
||||
part.prevPivots[0] = part.prevPivots[0] * (1.0F - speed);
|
||||
part.prevPivots[1] = part.prevPivots[1] * (1.0F - speed);
|
||||
part.prevPivots[2] = part.prevPivots[2] * (1.0F - speed);
|
||||
part.prevRotations[0] = part.prevRotations[0] * (1.0F - speed) + (this.rotateAngleX * speed);
|
||||
part.prevRotations[1] = part.prevRotations[1] * (1.0F - speed) + (this.rotateAngleY * speed);
|
||||
part.prevRotations[2] = part.prevRotations[2] * (1.0F - speed) + (this.rotateAngleZ * speed);
|
||||
}
|
||||
|
||||
if (animDataActive ||
|
||||
ClientEventHandler.renderingPlayer.getAge() - animData.finishedTime < 20) {
|
||||
this.rotationPointX = originalPart.pivot[0] + part.prevPivots[0];
|
||||
this.rotationPointY = originalPart.pivot[1] + part.prevPivots[1];
|
||||
this.rotationPointZ = originalPart.pivot[2] + part.prevPivots[2];
|
||||
if (animDataActive || partType != EnumAnimationPart.HEAD) {
|
||||
this.rotateAngleX = part.prevRotations[0];
|
||||
this.rotateAngleY = part.prevRotations[1];
|
||||
this.rotateAngleZ = part.prevRotations[2];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
currentPart = part;
|
||||
this.rotateAngleZ += part.prevRotations[2];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GL11.glTranslatef(this.offsetX, this.offsetY, this.offsetZ);
|
||||
int i;
|
||||
@@ -154,96 +233,13 @@ public abstract class MixinModelRenderer {
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
this.rotationPointX = prevPointX;
|
||||
this.rotationPointY = prevPointY;
|
||||
this.rotationPointZ = prevPointZ;
|
||||
this.rotateAngleX = prevAngleX;
|
||||
this.rotateAngleY = prevAngleY;
|
||||
this.rotateAngleZ = prevAngleZ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void setAnimationValues(float p_78785_1_) {
|
||||
float prevPointX = this.rotationPointX;
|
||||
float prevPointY = this.rotationPointY;
|
||||
float prevPointZ = this.rotationPointZ;
|
||||
float prevAngleX = this.rotateAngleX;
|
||||
float prevAngleY = this.rotateAngleY;
|
||||
float prevAngleZ = this.rotateAngleZ;
|
||||
|
||||
if (ClientEventHandler.renderingNpc != null && ClientEventHandler.renderingNpc.display.animationData.isActive()) {
|
||||
AnimationData animData = ClientEventHandler.renderingNpc.display.animationData;
|
||||
EnumAnimationPart partType = this.getPartType((ModelRenderer) (Object) this);
|
||||
|
||||
if (partType != null && animData != null) {
|
||||
Frame frame = (Frame) animData.animation.currentFrame();
|
||||
if (frame.frameParts.containsKey(partType)) {
|
||||
FramePart currentPart = frame.frameParts.get(partType);
|
||||
currentPart.interpolateOffset();
|
||||
currentPart.interpolateAngles();
|
||||
|
||||
this.rotationPointX += currentPart.prevPivots[0];
|
||||
this.rotationPointY += currentPart.prevPivots[1];
|
||||
this.rotationPointZ += currentPart.prevPivots[2];
|
||||
this.rotateAngleX = currentPart.prevRotations[0];
|
||||
this.rotateAngleY = currentPart.prevRotations[1];
|
||||
this.rotateAngleZ = currentPart.prevRotations[2];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ClientEventHandler.renderingPlayer != null && ClientCacheHandler.playerAnimations.containsKey(ClientEventHandler.renderingPlayer.getUniqueID())) {
|
||||
ClientEventHandler.playerModel = ((ModelRenderer) (Object) this).baseModel;
|
||||
AnimationData animData = ClientCacheHandler.playerAnimations.get(ClientEventHandler.renderingPlayer.getUniqueID());
|
||||
|
||||
EnumAnimationPart mainPartType = this.getPlayerPartType((ModelRenderer) (Object) this);
|
||||
EnumAnimationPart partType = mainPartType != null ? mainPartType : this.pivotEqualPart((ModelRenderer) (Object) this);
|
||||
|
||||
if (partType != null && animData != null && animData.animation != null) {
|
||||
boolean animDataActive = animData.isActive();
|
||||
|
||||
if (!ClientEventHandler.originalValues.containsKey((ModelRenderer) (Object) this)) {
|
||||
FramePart part = new FramePart();
|
||||
part.pivot = new float[]{prevPointX, prevPointY, prevPointZ};
|
||||
part.rotation = new float[]{prevAngleX, prevAngleY, prevAngleZ};
|
||||
ClientEventHandler.originalValues.put((ModelRenderer) (Object) this, part);
|
||||
}
|
||||
|
||||
FramePart originalPart = ClientEventHandler.originalValues.get((ModelRenderer) (Object) this);
|
||||
Frame frame = (Frame) animData.animation.currentFrame();
|
||||
if (!animDataActive && animData.finishedFrame >= 0 && animData.finishedFrame < animData.animation.frames.size()) {
|
||||
frame = animData.animation.frames.get(animData.finishedFrame);
|
||||
}
|
||||
|
||||
if (frame != null && frame.frameParts.containsKey(partType)) {
|
||||
FramePart part = frame.frameParts.get(partType);
|
||||
if (partType == mainPartType) {
|
||||
if (animDataActive) {
|
||||
part.interpolateAngles();
|
||||
part.interpolateOffset();
|
||||
} else {
|
||||
float speed = 0.4F;
|
||||
part.prevPivots[0] = part.prevPivots[0] * (1.0F - speed);
|
||||
part.prevPivots[1] = part.prevPivots[1] * (1.0F - speed);
|
||||
part.prevPivots[2] = part.prevPivots[2] * (1.0F - speed);
|
||||
part.prevRotations[0] = part.prevRotations[0] * (1.0F - speed) + (this.rotateAngleX * speed);
|
||||
part.prevRotations[1] = part.prevRotations[1] * (1.0F - speed) + (this.rotateAngleY * speed);
|
||||
part.prevRotations[2] = part.prevRotations[2] * (1.0F - speed) + (this.rotateAngleZ * speed);
|
||||
}
|
||||
|
||||
if (animDataActive || (partType != EnumAnimationPart.HEAD
|
||||
&& ClientEventHandler.renderingPlayer.getAge() - animData.finishedTime < 20)) {
|
||||
this.rotationPointX = originalPart.pivot[0] + part.prevPivots[0];
|
||||
this.rotationPointY = originalPart.pivot[1] + part.prevPivots[1];
|
||||
this.rotationPointZ = originalPart.pivot[2] + part.prevPivots[2];
|
||||
this.rotateAngleX = part.prevRotations[0];
|
||||
this.rotateAngleY = part.prevRotations[1];
|
||||
this.rotateAngleZ = part.prevRotations[2];
|
||||
}
|
||||
} else {
|
||||
this.rotateAngleZ += part.prevRotations[2];
|
||||
}
|
||||
if (currentPart != null) {
|
||||
this.rotationPointX = prevPointX;
|
||||
this.rotationPointY = prevPointY;
|
||||
this.rotationPointZ = prevPointZ;
|
||||
this.rotateAngleX = prevAngleX;
|
||||
this.rotateAngleY = prevAngleY;
|
||||
this.rotateAngleZ = prevAngleZ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package noppes.npcs.roles;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -14,12 +15,12 @@ import java.util.List;
|
||||
public class JobBard extends JobInterface{
|
||||
public int minRange = 2;
|
||||
public int maxRange = 64;
|
||||
|
||||
|
||||
public boolean isStreamer = true;
|
||||
public boolean hasOffRange = true;
|
||||
|
||||
public String song = "";
|
||||
|
||||
|
||||
private EnumBardInstrument instrument = EnumBardInstrument.Banjo;
|
||||
|
||||
public JobBard(EntityNPCInterface npc) {
|
||||
@@ -38,7 +39,7 @@ public class JobBard extends JobInterface{
|
||||
nbttagcompound.setInteger("BardInstrument", instrument.ordinal());
|
||||
nbttagcompound.setBoolean("BardStreamer", isStreamer);
|
||||
nbttagcompound.setBoolean("BardHasOff", hasOffRange);
|
||||
|
||||
|
||||
return nbttagcompound;
|
||||
}
|
||||
|
||||
@@ -51,7 +52,7 @@ public class JobBard extends JobInterface{
|
||||
isStreamer = nbttagcompound.getBoolean("BardStreamer");
|
||||
hasOffRange = nbttagcompound.getBoolean("BardHasOff");
|
||||
}
|
||||
|
||||
|
||||
public void setInstrument(int i) {
|
||||
if(CustomItems.banjo == null)
|
||||
return;
|
||||
@@ -87,16 +88,11 @@ public class JobBard extends JobInterface{
|
||||
public EnumBardInstrument getInstrument(){
|
||||
return instrument;
|
||||
}
|
||||
private long ticks = 0;
|
||||
public void onLivingUpdate() {
|
||||
if(!npc.isRemote())
|
||||
if(!npc.isRemote() || song.isEmpty())
|
||||
return;
|
||||
ticks++;
|
||||
if(ticks % 10 != 0 )
|
||||
return;
|
||||
if(song.isEmpty())
|
||||
return;
|
||||
if(!MusicController.Instance.isPlaying(song)){
|
||||
|
||||
if(!MusicController.Instance.isPlaying(song)){
|
||||
List<EntityPlayer> list = npc.worldObj.getEntitiesWithinAABB(EntityPlayer.class, npc.boundingBox.expand(minRange, minRange/2, minRange));
|
||||
if(!list.contains(CustomNpcs.proxy.getPlayer()))
|
||||
return;
|
||||
@@ -104,18 +100,23 @@ public class JobBard extends JobInterface{
|
||||
MusicController.Instance.playStreaming(song, npc);
|
||||
else
|
||||
MusicController.Instance.playMusic(song, npc);
|
||||
}else if(MusicController.Instance.playingEntity != npc){
|
||||
}
|
||||
else if(MusicController.Instance.playingEntity != npc){
|
||||
EntityPlayer player = CustomNpcs.proxy.getPlayer();
|
||||
if(npc.getDistanceSqToEntity(player) < MusicController.Instance.playingEntity.getDistanceSqToEntity(player)){
|
||||
MusicController.Instance.playingEntity = npc;
|
||||
}
|
||||
|
||||
}else if(hasOffRange){
|
||||
|
||||
}
|
||||
else if(hasOffRange){
|
||||
List<EntityPlayer> list = npc.worldObj.getEntitiesWithinAABB(EntityPlayer.class, npc.boundingBox.expand(maxRange, maxRange/2, maxRange));
|
||||
if(!list.contains(CustomNpcs.proxy.getPlayer()))
|
||||
MusicController.Instance.stopMusic();
|
||||
}
|
||||
|
||||
|
||||
if(MusicController.Instance.isPlaying(song)) {
|
||||
Minecraft.getMinecraft().mcMusicTicker.field_147676_d = 12000;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -321,9 +321,25 @@ public class JobSpawner extends JobInterface{
|
||||
target = null;
|
||||
checkSpawns();
|
||||
}
|
||||
@Override
|
||||
|
||||
@Override
|
||||
public void delete() {
|
||||
if(spawnType == 3 && npc.stats.spawnCycle == 3){
|
||||
spawnEntity(compound1);
|
||||
spawnEntity(compound2);
|
||||
spawnEntity(compound3);
|
||||
spawnEntity(compound4);
|
||||
spawnEntity(compound5);
|
||||
spawnEntity(compound6);
|
||||
number = 6;
|
||||
}
|
||||
reset();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void killed() {
|
||||
if(spawnType == 3){
|
||||
if(spawnType == 3 && npc.stats.spawnCycle != 3){
|
||||
spawnEntity(compound1);
|
||||
spawnEntity(compound2);
|
||||
spawnEntity(compound3);
|
||||
|
||||
@@ -15,7 +15,7 @@ import java.util.HashMap;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class RoleTrader extends RoleInterface{
|
||||
public class RoleTrader extends RoleInterface {
|
||||
|
||||
public String marketName = "";
|
||||
public NpcMiscInventory inventoryCurrency;
|
||||
@@ -23,14 +23,13 @@ public class RoleTrader extends RoleInterface{
|
||||
|
||||
public boolean ignoreDamage = false;
|
||||
public boolean ignoreNBT = false;
|
||||
|
||||
public boolean toSave = false;
|
||||
|
||||
public boolean recordHistory = false;
|
||||
|
||||
public int[] purchases;
|
||||
public int[] disableSlot;
|
||||
public HashMap<String, int[]> playerPurchases;
|
||||
public HashMap<String, int[]> playerDisableSlot;
|
||||
|
||||
|
||||
public RoleTrader(EntityNPCInterface npc) {
|
||||
super(npc);
|
||||
inventoryCurrency = new NpcMiscInventory(36);
|
||||
@@ -45,10 +44,6 @@ public class RoleTrader extends RoleInterface{
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) {
|
||||
nbttagcompound.setString("TraderMarket", marketName);
|
||||
writeNBT(nbttagcompound);
|
||||
if (toSave && !npc.isRemote()) {
|
||||
Market.save(this, marketName);
|
||||
}
|
||||
toSave = false;
|
||||
return nbttagcompound;
|
||||
}
|
||||
|
||||
@@ -57,10 +52,13 @@ public class RoleTrader extends RoleInterface{
|
||||
nbttagcompound.setTag("TraderSold", inventorySold.getToNBT());
|
||||
nbttagcompound.setBoolean("TraderIgnoreDamage", ignoreDamage);
|
||||
nbttagcompound.setBoolean("TraderIgnoreNBT", ignoreNBT);
|
||||
nbttagcompound.setIntArray("Purchases", purchases);
|
||||
nbttagcompound.setBoolean("RecordHistory", recordHistory);
|
||||
nbttagcompound.setIntArray("DisableSlot", disableSlot);
|
||||
nbttagcompound.setTag("PlayerPurchases", NBTTags.nbtStringIntegerArrayMap(playerPurchases));
|
||||
nbttagcompound.setTag("PlayerDisableSlot", NBTTags.nbtStringIntegerArrayMap(playerDisableSlot));
|
||||
if(recordHistory){
|
||||
nbttagcompound.setIntArray("Purchases", purchases);
|
||||
nbttagcompound.setTag("PlayerPurchases", NBTTags.nbtStringIntegerArrayMap(playerPurchases));
|
||||
}
|
||||
return nbttagcompound;
|
||||
}
|
||||
|
||||
@@ -68,12 +66,11 @@ public class RoleTrader extends RoleInterface{
|
||||
public void readFromNBT(NBTTagCompound nbttagcompound) {
|
||||
marketName = nbttagcompound.getString("TraderMarket");
|
||||
readNBT(nbttagcompound);
|
||||
|
||||
|
||||
try {
|
||||
Market.load(this, marketName);
|
||||
Market.getMarket(this, marketName);
|
||||
} catch (Exception ex) {
|
||||
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,25 +79,28 @@ public class RoleTrader extends RoleInterface{
|
||||
inventorySold.setFromNBT(nbttagcompound.getCompoundTag("TraderSold"));
|
||||
ignoreDamage = nbttagcompound.getBoolean("TraderIgnoreDamage");
|
||||
ignoreNBT = nbttagcompound.getBoolean("TraderIgnoreNBT");
|
||||
purchases = nbttagcompound.getIntArray("Purchases");
|
||||
recordHistory = nbttagcompound.getBoolean("RecordHistory");
|
||||
disableSlot = nbttagcompound.getIntArray("DisableSlot");
|
||||
playerDisableSlot = NBTTags.getStringIntegerArrayMap(nbttagcompound.getTagList("PlayerDisableSlot", 10), 18);
|
||||
if(recordHistory){
|
||||
purchases = nbttagcompound.getIntArray("Purchases");
|
||||
playerPurchases = NBTTags.getStringIntegerArrayMap(nbttagcompound.getTagList("PlayerPurchases", 10), 18);
|
||||
}
|
||||
if (purchases == null || purchases.length != 18) {
|
||||
purchases = new int[18];
|
||||
for (int i = 0; i < purchases.length; ++i) purchases[i] = 0;
|
||||
}
|
||||
disableSlot = nbttagcompound.getIntArray("DisableSlot");
|
||||
if (disableSlot == null || disableSlot.length != 18) {
|
||||
disableSlot = new int[18];
|
||||
for (int i = 0; i < disableSlot.length; ++i) disableSlot[i] = 0;
|
||||
}
|
||||
playerPurchases = NBTTags.getStringIntegerArrayMap(nbttagcompound.getTagList("PlayerPurchases", 10), 18);
|
||||
playerDisableSlot = NBTTags.getStringIntegerArrayMap(nbttagcompound.getTagList("PlayerDisableSlot", 10), 18);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void interact(EntityPlayer player) {
|
||||
npc.say(player, npc.advanced.getInteractLine());
|
||||
try {
|
||||
Market.load(this, marketName);
|
||||
Market.getMarket(this, marketName);
|
||||
} catch (Exception ex) {
|
||||
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
@@ -117,19 +117,22 @@ public class RoleTrader extends RoleInterface{
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public void addPurchase(int slot, String playerName) {
|
||||
if(slot >= 18 || slot < 0) return;
|
||||
++purchases[slot];
|
||||
++getArrayByName(playerName, playerPurchases)[slot];
|
||||
|
||||
if(recordHistory)
|
||||
Market.save(this, marketName);
|
||||
}
|
||||
|
||||
|
||||
public boolean isSlotEnabled(int slot, String playerName) {
|
||||
if(slot >= 18 || slot < 0) return false;
|
||||
if (disableSlot[slot] > 0) return false;
|
||||
return getArrayByName(playerName, playerDisableSlot)[slot] <= 0;
|
||||
}
|
||||
|
||||
|
||||
public int[] getArrayByName(String name, HashMap<String, int[]> map) {
|
||||
map.computeIfAbsent(name, k -> new int[18]);
|
||||
return map.get(name);
|
||||
|
||||
@@ -13,6 +13,7 @@ import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.monster.EntityMob;
|
||||
import net.minecraft.entity.passive.EntityAnimal;
|
||||
import net.minecraft.entity.passive.EntityTameable;
|
||||
import net.minecraft.entity.passive.EntityVillager;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.inventory.Container;
|
||||
@@ -200,6 +201,8 @@ public class NpcAPI extends AbstractNpcAPI {
|
||||
data = new ScriptEntityData(new ScriptAnimal<>((EntityAnimal) entity));
|
||||
else if(entity instanceof EntityMob)
|
||||
data = new ScriptEntityData(new ScriptMonster<>((EntityMob) entity));
|
||||
else if(entity instanceof EntityVillager)
|
||||
data = new ScriptEntityData(new ScriptVillager<>((EntityVillager) entity));
|
||||
else if(entity instanceof EntityLiving)
|
||||
data = new ScriptEntityData(new ScriptLiving<>((EntityLiving) entity));
|
||||
else if(entity instanceof EntityLivingBase)
|
||||
|
||||
@@ -9,4 +9,6 @@ public class EntityType {
|
||||
public static final int LIVING = 5;
|
||||
public static final int ITEM = 6;
|
||||
public static final int PROJECTILE = 7;
|
||||
public static final int PIXELMON = 8;
|
||||
public static final int VILLAGER = 9;
|
||||
}
|
||||
@@ -8,10 +8,8 @@ import noppes.npcs.scripted.NpcAPI;
|
||||
|
||||
public class ScriptLiving<T extends EntityLiving> extends ScriptLivingBase<T> implements IEntityLiving {
|
||||
|
||||
private T entity;
|
||||
public ScriptLiving(T entity) {
|
||||
super(entity);
|
||||
this.entity = entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -33,7 +31,7 @@ public class ScriptLiving<T extends EntityLiving> extends ScriptLivingBase<T> im
|
||||
IEntityLivingBase base = (IEntityLivingBase) NpcAPI.Instance().getIEntity(entity.getAttackTarget());
|
||||
return (base != null)? base: super.getAttackTarget();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Start path finding toward this target
|
||||
* @param x Destination x position
|
||||
@@ -44,21 +42,21 @@ public class ScriptLiving<T extends EntityLiving> extends ScriptLivingBase<T> im
|
||||
public void navigateTo(double x, double y, double z, double speed){
|
||||
entity.getNavigator().tryMoveToXYZ(x, y, z, speed);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Stop navigating wherever this npc was walking to
|
||||
*/
|
||||
public void clearNavigation(){
|
||||
entity.getNavigator().clearPathEntity();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Whether or not this entity is navigating somewhere
|
||||
*/
|
||||
public boolean isNavigating(){
|
||||
return !entity.getNavigator().noPath();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean canSeeEntity(IEntity entity){
|
||||
return this.entity.getEntitySenses().canSee(entity.getMCEntity());
|
||||
|
||||
@@ -20,11 +20,9 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
||||
public class ScriptLivingBase<T extends EntityLivingBase> extends ScriptEntity<T> implements IEntityLivingBase {
|
||||
protected T entity;
|
||||
|
||||
public ScriptLivingBase(T entity){
|
||||
super(entity);
|
||||
this.entity = entity;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -4,6 +4,7 @@ import net.minecraft.entity.passive.EntityTameable;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.api.entity.IPixelmon;
|
||||
import noppes.npcs.compat.PixelmonHelper;
|
||||
import noppes.npcs.scripted.constants.EntityType;
|
||||
import noppes.npcs.util.ValueUtil;
|
||||
|
||||
public class ScriptPixelmon<T extends EntityTameable> extends ScriptAnimal<T> implements IPixelmon {
|
||||
@@ -19,25 +20,25 @@ public class ScriptPixelmon<T extends EntityTameable> extends ScriptAnimal<T> im
|
||||
this(pixelmon);
|
||||
this.compound = compound;
|
||||
}
|
||||
|
||||
|
||||
public boolean getIsShiny(){
|
||||
return compound.getBoolean("IsShiny");
|
||||
}
|
||||
|
||||
|
||||
public void setIsShiny(boolean bo){
|
||||
compound.setBoolean("IsShiny", bo);
|
||||
pixelmon.readEntityFromNBT(compound);
|
||||
}
|
||||
|
||||
|
||||
public int getLevel(){
|
||||
return compound.getInteger("Level");
|
||||
}
|
||||
|
||||
|
||||
public void setLevel(int level){
|
||||
compound.setInteger("Level", level);
|
||||
pixelmon.readEntityFromNBT(compound);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param type 0:HP, 1:Attack, 2:Defense, 3:SpAttack, 4:SpDefense, 5:Speed
|
||||
*/
|
||||
@@ -54,11 +55,11 @@ public class ScriptPixelmon<T extends EntityTameable> extends ScriptAnimal<T> im
|
||||
return compound.getInteger("IVSpDef");
|
||||
if(type == 5)
|
||||
return compound.getInteger("IVSpeed");
|
||||
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param type 0:HP, 1:Attack, 2:Defense, 3:SpAttack, 4:SpDefense, 5:Speed
|
||||
*/
|
||||
@@ -77,7 +78,7 @@ public class ScriptPixelmon<T extends EntityTameable> extends ScriptAnimal<T> im
|
||||
compound.setInteger("IVSpeed", value);
|
||||
pixelmon.readEntityFromNBT(compound);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param type 0:HP, 1:Attack, 2:Defense, 3:SpAttack, 4:SpDefense, 5:Speed
|
||||
*/
|
||||
@@ -94,11 +95,11 @@ public class ScriptPixelmon<T extends EntityTameable> extends ScriptAnimal<T> im
|
||||
return compound.getInteger("EVSpecialDefence");
|
||||
if(type == 5)
|
||||
return compound.getInteger("EVSpeed");
|
||||
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param type 0:HP, 1:Attack, 2:Defense, 3:SpAttack, 4:SpDefense, 5:Speed
|
||||
*/
|
||||
@@ -117,7 +118,7 @@ public class ScriptPixelmon<T extends EntityTameable> extends ScriptAnimal<T> im
|
||||
compound.setInteger("EVSpeed", value);
|
||||
pixelmon.readEntityFromNBT(compound);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param type 0:HP, 1:Attack, 2:Defense, 3:SpAttack, 4:SpDefense, 5:Speed
|
||||
*/
|
||||
@@ -134,11 +135,11 @@ public class ScriptPixelmon<T extends EntityTameable> extends ScriptAnimal<T> im
|
||||
return compound.getInteger("StatsSpecialDefence");
|
||||
if(type == 5)
|
||||
return compound.getInteger("StatsSpeed");
|
||||
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param type 0:HP, 1:Attack, 2:Defense, 3:SpAttack, 4:SpDefense, 5:Speed
|
||||
*/
|
||||
@@ -157,14 +158,14 @@ public class ScriptPixelmon<T extends EntityTameable> extends ScriptAnimal<T> im
|
||||
compound.setInteger("StatsSpeed", value);
|
||||
pixelmon.readEntityFromNBT(compound);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return type 0:Pygmy, 1:Runt, 2:Small, 3:Normal, 4:Huge, 5:Giant, 6:Enormous, 7:Ginormous, 8:Microscopic
|
||||
*/
|
||||
public int getSize(){
|
||||
return compound.getShort("Growth");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param type 0:Pygmy, 1:Runt, 2:Small, 3:Normal, 4:Huge, 5:Giant, 6:Enormous, 7:Ginormous, 8:Microscopic
|
||||
*/
|
||||
@@ -172,14 +173,14 @@ public class ScriptPixelmon<T extends EntityTameable> extends ScriptAnimal<T> im
|
||||
compound.setShort("Growth", (short) type);
|
||||
pixelmon.readEntityFromNBT(compound);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return 0-255
|
||||
*/
|
||||
public int getHapiness(){
|
||||
return compound.getInteger("Friendship");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param value 0-255
|
||||
*/
|
||||
@@ -188,14 +189,14 @@ public class ScriptPixelmon<T extends EntityTameable> extends ScriptAnimal<T> im
|
||||
compound.setInteger("Friendship", value);
|
||||
pixelmon.readEntityFromNBT(compound);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return 0:Hardy, 1:Serious, 2:Docile, 3:Bashful, 4:Quirky, 5:Lonely, 6:Brave, 7:Adamant, 8:Naughty, 9:Bold, 10:Relaxed, 11:Impish, 12:Lax, 13:Timid, 14:Hasty, 15:Jolly, 16:Naive, 17:Modest, 18:Mild, 19:Quiet, 20:Rash, 21:Calm, 22:Gentle, 23:Sassy, 24:Careful
|
||||
*/
|
||||
public int getNature(){
|
||||
return compound.getShort("Nature");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param type 0:Hardy, 1:Serious, 2:Docile, 3:Bashful, 4:Quirky, 5:Lonely, 6:Brave, 7:Adamant, 8:Naughty, 9:Bold, 10:Relaxed, 11:Impish, 12:Lax, 13:Timid, 14:Hasty, 15:Jolly, 16:Naive, 17:Modest, 18:Mild, 19:Quiet, 20:Rash, 21:Calm, 22:Gentle, 23:Sassy, 24:Careful
|
||||
*/
|
||||
@@ -203,7 +204,7 @@ public class ScriptPixelmon<T extends EntityTameable> extends ScriptAnimal<T> im
|
||||
compound.setShort("Nature", (short) type);
|
||||
pixelmon.readEntityFromNBT(compound);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return -1:Uncaught, 0:Pokeball, 1:GreatBall, 2:UltraBall, 3:MasterBall, 4:LevelBall, 5:MoonBall, 6:FriendBall, 7:LoveBall, 8:SafariBall, 9:HeavyBall, 10:FastBall, 11:RepeatBall, 12:TimerBall, 13:NestBall, 14:NetBall, 15:DiveBall, 16:LuxuryBall, 17:HealBall, 18:DuskBall, 19:PremierBall, 20:SportBall, 21:QuickBall, 22:ParkBall, 23:LureBall, 24:CherishBall, 25:GSBall
|
||||
*/
|
||||
@@ -220,26 +221,26 @@ public class ScriptPixelmon<T extends EntityTameable> extends ScriptAnimal<T> im
|
||||
compound.setInteger("CaughtBall", type);
|
||||
pixelmon.readEntityFromNBT(compound);
|
||||
}
|
||||
|
||||
|
||||
public String getNickname(){
|
||||
return compound.getString("Nickname");
|
||||
}
|
||||
|
||||
|
||||
public boolean hasNickname(){
|
||||
return !getNickname().isEmpty();
|
||||
}
|
||||
|
||||
|
||||
public void setNickname(String name){
|
||||
compound.setString("Nickname", name);
|
||||
pixelmon.readEntityFromNBT(compound);
|
||||
}
|
||||
|
||||
|
||||
public String getMove(int slot){
|
||||
if(!compound.hasKey("PixelmonMoveID" + slot))
|
||||
return null;
|
||||
return PixelmonHelper.getAttackName(compound.getInteger("PixelmonMoveID" + slot));
|
||||
}
|
||||
|
||||
|
||||
public void setMove(int slot, String move){
|
||||
slot = ValueUtil.clamp(slot, 0, 3);
|
||||
int id = PixelmonHelper.getAttackID(move);
|
||||
@@ -257,7 +258,17 @@ public class ScriptPixelmon<T extends EntityTameable> extends ScriptAnimal<T> im
|
||||
size++;
|
||||
}
|
||||
compound.setInteger("PixelmonNumberMoves", size);
|
||||
|
||||
|
||||
pixelmon.readEntityFromNBT(compound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType(){
|
||||
return EntityType.PIXELMON;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean typeOf(int type){
|
||||
return type == EntityType.PIXELMON || super.typeOf(type);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package noppes.npcs.scripted.entity;
|
||||
|
||||
import net.minecraft.entity.passive.EntityVillager;
|
||||
import noppes.npcs.api.entity.IEntityLivingBase;
|
||||
import noppes.npcs.api.entity.IVillager;
|
||||
import noppes.npcs.scripted.NpcAPI;
|
||||
import noppes.npcs.scripted.constants.EntityType;
|
||||
|
||||
public class ScriptVillager<T extends EntityVillager> extends ScriptLiving<T> implements IVillager {
|
||||
|
||||
public ScriptVillager(T entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getProfession() {
|
||||
return entity.getProfession();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsTrading() {
|
||||
return entity.isTrading();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IEntityLivingBase getCustomer()
|
||||
{
|
||||
return (IEntityLivingBase) NpcAPI.Instance().getPlayer(entity.getCustomer().getCommandSenderName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType(){
|
||||
return EntityType.VILLAGER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean typeOf(int type){
|
||||
return type == EntityType.VILLAGER || super.typeOf(type);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -138,6 +138,40 @@ public class ItemEvent extends CustomNPCsEvent implements IItemEvent {
|
||||
}
|
||||
}
|
||||
|
||||
@Cancelable
|
||||
public static class RightClickEvent extends ItemEvent implements IItemEvent.RightClickEvent {
|
||||
|
||||
/**
|
||||
* 0:air, 1:entity, 2:block
|
||||
*/
|
||||
public final int type;
|
||||
public final Object target;
|
||||
public final IPlayer player;
|
||||
|
||||
public RightClickEvent(IItemCustom item, IPlayer player, int type, Object target) {
|
||||
super(item);
|
||||
this.type = type;
|
||||
this.target = target;
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
public String getHookName() {
|
||||
return EnumScriptType.INTERACT.function;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public Object getTarget() {
|
||||
return target;
|
||||
}
|
||||
|
||||
public IPlayer getPlayer() {
|
||||
return player;
|
||||
}
|
||||
}
|
||||
|
||||
@Cancelable
|
||||
public static class AttackEvent extends ItemEvent implements IItemEvent.AttackEvent {
|
||||
public final int type;//1: Hit, 2: Whiff
|
||||
|
||||
@@ -30,7 +30,7 @@ public class ScriptRoleTrader extends ScriptRoleInterface implements IRoleTrader
|
||||
role.inventoryCurrency.items.put(slot + 18, currency2.getMCItemStack());
|
||||
else
|
||||
role.inventoryCurrency.items.remove(slot + 18);
|
||||
|
||||
|
||||
role.inventorySold.items.put(slot, sold.getMCItemStack());
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ public class ScriptRoleTrader extends ScriptRoleInterface implements IRoleTrader
|
||||
}
|
||||
return currency;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void removeSellOption(int slot){
|
||||
if(slot >= 18 || slot < 0) return;
|
||||
@@ -66,7 +66,7 @@ public class ScriptRoleTrader extends ScriptRoleInterface implements IRoleTrader
|
||||
|
||||
public void setMarket(String name){
|
||||
role.marketName = name;
|
||||
Market.load(role, name);
|
||||
Market.getMarket(role, name);
|
||||
}
|
||||
|
||||
public String getMarket(){
|
||||
|
||||
@@ -6,11 +6,17 @@ import java.util.Map;
|
||||
|
||||
public class CacheHashMap<K, V extends CacheHashMap.CachedObject<?>> extends HashMap<K, V> {
|
||||
private final long maxCacheTime;
|
||||
private long saveInterval;
|
||||
|
||||
public CacheHashMap(long maxCacheTime) {
|
||||
this.maxCacheTime = maxCacheTime;
|
||||
}
|
||||
|
||||
public CacheHashMap(long maxCacheTime, long saveInterval) {
|
||||
this.maxCacheTime = maxCacheTime;
|
||||
this.saveInterval = saveInterval;
|
||||
}
|
||||
|
||||
@Override
|
||||
public V get(Object key) {
|
||||
V object = super.get(key);
|
||||
@@ -19,9 +25,16 @@ public class CacheHashMap<K, V extends CacheHashMap.CachedObject<?>> extends Has
|
||||
Iterator<Map.Entry<K,V>> iterator = this.entrySet().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Map.Entry<K,V> entry = iterator.next();
|
||||
long timeDiff = entry.getValue().timeSinceAccessed();
|
||||
if (timeDiff > this.maxCacheTime) {
|
||||
long lifeTimeDiff = entry.getValue().timeSinceAccessed();
|
||||
if (lifeTimeDiff > this.maxCacheTime) {
|
||||
entry.getValue().save();
|
||||
iterator.remove();
|
||||
} else if (this.saveInterval > 0) {
|
||||
long saveTimeDiff = entry.getValue().timeSinceSaved();
|
||||
if (saveTimeDiff > this.saveInterval) {
|
||||
entry.getValue().save();
|
||||
entry.getValue().updateSaveTime();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,22 +42,34 @@ public class CacheHashMap<K, V extends CacheHashMap.CachedObject<?>> extends Has
|
||||
}
|
||||
|
||||
public static class CachedObject<T> {
|
||||
private long timeSaved;
|
||||
private long lastTimeAccessed;
|
||||
private final T object;
|
||||
|
||||
public CachedObject(T object) {
|
||||
this.object = object;
|
||||
this.lastTimeAccessed = System.currentTimeMillis();
|
||||
this.timeSaved = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public long timeSinceAccessed() {
|
||||
return System.currentTimeMillis() - this.lastTimeAccessed;
|
||||
}
|
||||
|
||||
public long timeSinceSaved() {
|
||||
return System.currentTimeMillis() - this.timeSaved;
|
||||
}
|
||||
|
||||
public void updateTimeAccessed() {
|
||||
this.lastTimeAccessed = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public void updateSaveTime() {
|
||||
this.timeSaved = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public void save(){}
|
||||
|
||||
public T getObject() {
|
||||
return this.object;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,8 @@ package noppes.npcs.util;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
|
||||
public class CustomNPCsThreader {
|
||||
public static final Executor playerDataThread = Executors.newSingleThreadExecutor();
|
||||
public static final Executor customNPCThread = Executors.newSingleThreadExecutor();
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package noppes.npcs.util;
|
||||
|
||||
import foxz.utils.Market;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public class MarketCachedObject extends CacheHashMap.CachedObject<NBTTagCompound> {
|
||||
public MarketCachedObject(NBTTagCompound object) {
|
||||
super(object);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
Market.saveFile(getObject());
|
||||
}
|
||||
}
|
||||
@@ -3,12 +3,10 @@ package noppes.npcs.util;
|
||||
import com.google.common.io.Files;
|
||||
import cpw.mods.fml.common.ObfuscationReflectionHelper;
|
||||
import net.minecraft.nbt.*;
|
||||
import noppes.npcs.LogWriter;
|
||||
import org.apache.commons.io.Charsets;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -211,7 +209,17 @@ public class NBTJsonUtil {
|
||||
}
|
||||
return json;
|
||||
}
|
||||
static class JsonLine{
|
||||
|
||||
public static NBTTagCompound loadNBTData(File file){
|
||||
try {
|
||||
return CompressedStreamTools.readCompressed(new FileInputStream(file));
|
||||
} catch (Exception e) {
|
||||
LogWriter.error("Error loading: " + file.getName(), e);
|
||||
}
|
||||
return new NBTTagCompound();
|
||||
}
|
||||
|
||||
static class JsonLine{
|
||||
private String line;
|
||||
public JsonLine(String line){
|
||||
this.line = line;
|
||||
|
||||
@@ -4,6 +4,7 @@ import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import noppes.npcs.CustomItems;
|
||||
import noppes.npcs.client.gui.player.inventory.GuiCNPCInventory;
|
||||
import noppes.npcs.client.gui.player.inventory.GuiQuestLog;
|
||||
|
||||
public class InventoryTabCustomNpc extends AbstractTab {
|
||||
@@ -16,6 +17,8 @@ public class InventoryTabCustomNpc extends AbstractTab {
|
||||
|
||||
@Override
|
||||
public void onTabClicked() {
|
||||
|
||||
|
||||
Thread t = new Thread(){
|
||||
@Override
|
||||
public void run(){
|
||||
@@ -25,6 +28,9 @@ public class InventoryTabCustomNpc extends AbstractTab {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
if(mc.currentScreen instanceof GuiCNPCInventory)
|
||||
return;
|
||||
|
||||
mc.displayGuiScreen(new GuiQuestLog(mc.thePlayer));
|
||||
}
|
||||
};
|
||||
@@ -35,4 +41,4 @@ public class InventoryTabCustomNpc extends AbstractTab {
|
||||
public boolean shouldAddToList() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,22 +10,11 @@ public class InventoryTabVanilla extends AbstractTab {
|
||||
|
||||
@Override
|
||||
public void onTabClicked() {
|
||||
Thread t = new Thread(){
|
||||
@Override
|
||||
public void run(){
|
||||
try {
|
||||
Thread.sleep(100);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
TabRegistry.openInventoryGui();
|
||||
}
|
||||
};
|
||||
t.start();
|
||||
TabRegistry.openInventoryGui();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldAddToList() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user