diff --git a/build.gradle b/build.gradle index e57af3300..789c700dd 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ plugins { id 'idea' } -version = "1.10-testingbeta4" +version = "1.10-testingbeta18" group= "kamkeel.customnpc-plus" archivesBaseName = "CustomNPC-Plus" diff --git a/src/api b/src/api index c81e84889..f6fac3836 160000 --- a/src/api +++ b/src/api @@ -1 +1 @@ -Subproject commit c81e8488950deafc0f3a08c3c82861e47a084094 +Subproject commit f6fac3836097f42c10a52588f6864c69c57110fe diff --git a/src/main/java/foxz/command/CmdClone.java b/src/main/java/foxz/command/CmdClone.java index 7e2fd6469..f585c886c 100644 --- a/src/main/java/foxz/command/CmdClone.java +++ b/src/main/java/foxz/command/CmdClone.java @@ -97,6 +97,7 @@ public class CmdClone extends ChMcLogger { sendmessage(String.format("Npc '%s' wasn't found", nametodel)); return false; } + ; return true; } diff --git a/src/main/java/foxz/command/CmdDialog.java b/src/main/java/foxz/command/CmdDialog.java index c0ddef93e..2bb2d1da3 100644 --- a/src/main/java/foxz/command/CmdDialog.java +++ b/src/main/java/foxz/command/CmdDialog.java @@ -35,7 +35,7 @@ public class CmdDialog extends ChMcLogger { usage = " ", permissions = {OpOnly.class, ParamCheck.class} ) - public boolean read(String[] args) { + public boolean read(String args[]) { String playername = args[0]; int diagid; try { @@ -62,7 +62,7 @@ public class CmdDialog extends ChMcLogger { usage = " ", permissions = {OpOnly.class, ParamCheck.class} ) - public boolean unread(String[] args) { + public boolean unread(String args[]) { String playername = args[0]; int diagid; try { @@ -88,7 +88,7 @@ public class CmdDialog extends ChMcLogger { desc = "reload dialogs from disk", permissions = {OpOnly.class} ) - public boolean reload(String[] args) { + public boolean reload(String args[]) { new DialogController().load(); SyncController.syncAllDialogs(); return true; @@ -100,7 +100,7 @@ public class CmdDialog extends ChMcLogger { usage = " ", permissions = {OpOnly.class} ) - public void show(String[] args) { + public void show(String args[]) { EntityPlayer player = CommandBase.getPlayer(pcParam, args[0]); if (player == null) { sendmessage(String.format("Unknow player '%s'", args[0])); diff --git a/src/main/java/foxz/command/CmdNoppes.java b/src/main/java/foxz/command/CmdNoppes.java index ef965b27c..a60d1dd8f 100644 --- a/src/main/java/foxz/command/CmdNoppes.java +++ b/src/main/java/foxz/command/CmdNoppes.java @@ -216,7 +216,7 @@ public class CmdNoppes extends ChMcLogger { return cmdnpc.addTabCompletion(par1, Arrays.copyOfRange(args, 1, args.length)); } if (args[0].equalsIgnoreCase("faction") && args.length == 4) { - return CommandBase.getListOfStringsMatchingLastWord(args, "add", "subtract", "set", "reset", "drop", "create"); + return CommandBase.getListOfStringsMatchingLastWord(args, new String[]{"add", "subtract", "set", "reset", "drop", "create"}); } return super.addTabCompletion(par1, args); } diff --git a/src/main/java/foxz/command/CmdNpc.java b/src/main/java/foxz/command/CmdNpc.java index 83000ab42..5bcbded53 100644 --- a/src/main/java/foxz/command/CmdNpc.java +++ b/src/main/java/foxz/command/CmdNpc.java @@ -152,7 +152,7 @@ public class CmdNpc extends ChMcLogger { @Override public List addTabCompletion(ICommandSender par1, String[] args) { if (args.length == 2) { - return CommandBase.getListOfStringsMatchingLastWord(args, "create", "home", "visible", "delete", "owner", "name"); + return CommandBase.getListOfStringsMatchingLastWord(args, new String[]{"create", "home", "visible", "delete", "owner", "name"}); } if (args.length == 3 && args[1].equalsIgnoreCase("owner")) { return CommandBase.getListOfStringsMatchingLastWord(args, MinecraftServer.getServer().getAllUsernames()); diff --git a/src/main/java/foxz/command/CmdQuest.java b/src/main/java/foxz/command/CmdQuest.java index 3ce273c4c..5f7a7f1f4 100644 --- a/src/main/java/foxz/command/CmdQuest.java +++ b/src/main/java/foxz/command/CmdQuest.java @@ -71,7 +71,7 @@ public class CmdQuest extends ChMcLogger { usage = " ", permissions = {OpOnly.class, ParamCheck.class} ) - public Boolean finish(String[] args) { + public Boolean finish(String args[]) { String playername = args[0]; int questid; try { @@ -168,7 +168,7 @@ public class CmdQuest extends ChMcLogger { desc = "reload quests from disk", permissions = {OpOnly.class} ) - public boolean reload(String[] args) { + public boolean reload(String args[]) { new QuestController().load(); SyncController.syncAllQuests(); return true; diff --git a/src/main/java/foxz/command/CmdScript.java b/src/main/java/foxz/command/CmdScript.java index a40683771..010e8d5c5 100644 --- a/src/main/java/foxz/command/CmdScript.java +++ b/src/main/java/foxz/command/CmdScript.java @@ -20,7 +20,7 @@ public class CmdScript extends ChMcLogger { desc = "Reload scripts and saved data from disks script folder.", permissions = {OpOnly.class} ) - public Boolean reload(String[] args) { + public Boolean reload(String args[]) { if (ScriptController.Instance.loadStoredData()) sendmessage("Reload succesful"); else diff --git a/src/main/java/foxz/commandhelper/AbstractCommandHelper.java b/src/main/java/foxz/commandhelper/AbstractCommandHelper.java index d866f55da..c2d62a229 100644 --- a/src/main/java/foxz/commandhelper/AbstractCommandHelper.java +++ b/src/main/java/foxz/commandhelper/AbstractCommandHelper.java @@ -37,16 +37,16 @@ public abstract class AbstractCommandHelper extends CommandHelper { } public void ctor() { - this.commandHelper.name = this.getClass().getAnnotation(Command.class).name(); - this.commandHelper.usage = this.getClass().getAnnotation(Command.class).usage(); - this.commandHelper.desc = this.getClass().getAnnotation(Command.class).desc(); + this.commandHelper.name = ((Command) this.getClass().getAnnotation(Command.class)).name(); + this.commandHelper.usage = ((Command) this.getClass().getAnnotation(Command.class)).usage(); + this.commandHelper.desc = ((Command) this.getClass().getAnnotation(Command.class)).desc(); // sub for (Class c : this.getClass().getAnnotation(Command.class).sub()) { try { String name = ((Command) c.getAnnotation(Command.class)).name().toUpperCase(); Constructor ctor = c.getConstructor(Object.class); ctor.setAccessible(true); - AbstractCommandHelper sc = ctor.newInstance(ctorParm); + AbstractCommandHelper sc = (AbstractCommandHelper) ctor.newInstance(ctorParm); commands.put(name, sc); } catch (Exception ex) { Logger.getLogger(AbstractCommandHelper.class.getName()).log(Level.SEVERE, null, ex); @@ -120,12 +120,12 @@ public abstract class AbstractCommandHelper extends CommandHelper { for (CommandHelper cur : commands.values()) { help(cur.commandHelper.name, cur.commandHelper.desc, ""); } - sendMsg("\u00A74noppes cmds are no longer supported |\u00A76 use /kamkeel"); - sendMsg("\u00A77All bugs and issues will not be patched or maintained"); + sendMsg(String.format("\u00A74noppes cmds are no longer supported |\u00A76 use /kamkeel")); + sendMsg(String.format("\u00A77All bugs and issues will not be patched or maintained")); } public void sendMsg(String msg) { - ICommandSender sender = pcParam; + ICommandSender sender = (ICommandSender) pcParam; sender.addChatMessage(new ChatComponentText(msg)); } @@ -191,7 +191,7 @@ public abstract class AbstractCommandHelper extends CommandHelper { if (ch instanceof AbstractCommandHelper) { ((AbstractCommandHelper) ch).pcParam = param; ((AbstractCommandHelper) ch).allHelp(); - } else if (ch instanceof MethodSubCmd && ch.commandHelper.usage.isEmpty()) + } else if (ch instanceof MethodSubCmd && ((MethodSubCmd) ch).commandHelper.usage.isEmpty()) return false; else help(ch.commandHelper.name, ch.commandHelper.desc, ch.commandHelper.usage); @@ -226,7 +226,7 @@ public abstract class AbstractCommandHelper extends CommandHelper { list.add(data); } else { for (EntityPlayer player : players) { - list.add(PlayerDataController.Instance.getPlayerData(player)); + list.add(PlayerData.get(player)); } } diff --git a/src/main/java/kamkeel/npcs/CustomAttributes.java b/src/main/java/kamkeel/npcs/CustomAttributes.java index 2caeee338..1bebbea91 100644 --- a/src/main/java/kamkeel/npcs/CustomAttributes.java +++ b/src/main/java/kamkeel/npcs/CustomAttributes.java @@ -4,14 +4,17 @@ import kamkeel.npcs.controllers.AttributeController; import kamkeel.npcs.controllers.data.attribute.AttributeDefinition; import kamkeel.npcs.controllers.data.attribute.AttributeValueType; import kamkeel.npcs.controllers.data.attribute.requirement.RequirementCheckerRegistry; +import kamkeel.npcs.controllers.data.attribute.requirement.types.ProfileSlotRequirement; import kamkeel.npcs.controllers.data.attribute.requirement.types.QuestActiveRequirement; import kamkeel.npcs.controllers.data.attribute.requirement.types.QuestCompletedRequirement; +import kamkeel.npcs.controllers.data.attribute.requirement.types.SoulbindRequirement; /** * ModAttributes registers the core attributes (both non–magic and magic–based). */ public class CustomAttributes { public static final String HEALTH_KEY = "health"; + public static final String HEALTH_BOOST_KEY = "health_boost"; public static final String MAIN_ATTACK_KEY = "main_attack"; public static final String MAIN_ATTACK_BOOST_KEY = "main_attack_boost"; public static final String NEUTRAL_KEY = "neutral"; @@ -22,24 +25,28 @@ public class CustomAttributes { public static final String MAGIC_BOOST_KEY = "magic_boost"; public static final String MAGIC_DEFENSE_KEY = "magic_defense"; public static final String MAGIC_RESISTANCE_KEY = "magic_resistance"; + public static final String MOVEMENT_SPEED_KEY = "movement_speed"; + public static final String KNOCKBACK_RES_KEY = "knockback_res"; - + public static AttributeDefinition HEALTH; + public static AttributeDefinition HEALTH_BOOST; public static AttributeDefinition MAIN_ATTACK; public static AttributeDefinition MAIN_BOOST; public static AttributeDefinition NEUTRAL_ATTACK; public static AttributeDefinition NEUTRAL_BOOST; - - public static AttributeDefinition HEALTH; public static AttributeDefinition CRITICAL_CHANCE; public static AttributeDefinition CRITICAL_DAMAGE; - public static AttributeDefinition MAGIC_DAMAGE; public static AttributeDefinition MAGIC_BOOST; public static AttributeDefinition MAGIC_DEFENSE; public static AttributeDefinition MAGIC_RESISTANCE; + public static AttributeDefinition MOVEMENT_SPEED; + public static AttributeDefinition KNOCKBACK_RES; public CustomAttributes() { HEALTH = AttributeController.registerAttribute(HEALTH_KEY, "Health", 'c', AttributeValueType.FLAT, AttributeDefinition.AttributeSection.BASE); + HEALTH_BOOST = AttributeController.registerAttribute(HEALTH_BOOST_KEY, "Health Boost", 'c', AttributeValueType.PERCENT, AttributeDefinition.AttributeSection.MODIFIER); + HEALTH_BOOST.setTranslationKey("attribute.name.generic.maxHealth"); MAIN_ATTACK = AttributeController.registerAttribute(MAIN_ATTACK_KEY, "Main Attack Damage", '4', AttributeValueType.FLAT, AttributeDefinition.AttributeSection.BASE); MAIN_BOOST = AttributeController.registerAttribute(MAIN_ATTACK_BOOST_KEY, "Main Attack Damage", '4', AttributeValueType.PERCENT, AttributeDefinition.AttributeSection.MODIFIER); @@ -56,6 +63,11 @@ public class CustomAttributes { MAGIC_DEFENSE = AttributeController.registerAttribute(MAGIC_DEFENSE_KEY, "Magic Defense", 'b', AttributeValueType.MAGIC, AttributeDefinition.AttributeSection.BASE); MAGIC_RESISTANCE = AttributeController.registerAttribute(MAGIC_RESISTANCE_KEY, "Magic Resistance", 'b', AttributeValueType.MAGIC, AttributeDefinition.AttributeSection.MODIFIER); + MOVEMENT_SPEED = AttributeController.registerAttribute(MOVEMENT_SPEED_KEY, "Movement Speed", 'a', AttributeValueType.PERCENT, AttributeDefinition.AttributeSection.MODIFIER); + MOVEMENT_SPEED.setTranslationKey("attribute.name.generic.movementSpeed"); + + KNOCKBACK_RES = AttributeController.registerAttribute(KNOCKBACK_RES_KEY, "Knockback Resistance", 'b', AttributeValueType.PERCENT, AttributeDefinition.AttributeSection.MODIFIER); + KNOCKBACK_RES.setTranslationKey("attribute.name.generic.knockbackResistance"); // TODO: Attributes // Durability Attribute @@ -64,9 +76,7 @@ public class CustomAttributes { // Requirement RequirementCheckerRegistry.registerChecker(new QuestCompletedRequirement()); RequirementCheckerRegistry.registerChecker(new QuestActiveRequirement()); - - // TODO: Requirements - // Player Requirement : Soulbound UUID - // Profile Requirement : Slot Number + RequirementCheckerRegistry.registerChecker(new ProfileSlotRequirement()); + RequirementCheckerRegistry.registerChecker(new SoulbindRequirement()); } } diff --git a/src/main/java/kamkeel/npcs/addon/client/DBCClient.java b/src/main/java/kamkeel/npcs/addon/client/DBCClient.java index 4bb807010..282fab2e1 100644 --- a/src/main/java/kamkeel/npcs/addon/client/DBCClient.java +++ b/src/main/java/kamkeel/npcs/addon/client/DBCClient.java @@ -1,6 +1,11 @@ package kamkeel.npcs.addon.client; +import net.minecraft.client.model.ModelBiped; +import net.minecraft.client.model.ModelRenderer; +import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.ResourceLocation; import noppes.npcs.client.gui.mainmenu.GuiNpcStats; import noppes.npcs.client.gui.util.GuiNPCInterface2; import noppes.npcs.client.gui.util.GuiNpcButton; @@ -42,4 +47,9 @@ public class DBCClient { public GuiNPCInterface2 manageCustomAuras(EntityNPCInterface npcInterface) { return null; } + + // Animation Render Helper + public boolean applyRenderModel(ModelRenderer renderer) { return false; } + public boolean firstPersonAnimation(float partialRenderTick, EntityPlayer player, ModelBiped model, RenderBlocks renderBlocksIr, ResourceLocation resItemGlint) { return false; } + } diff --git a/src/main/java/kamkeel/npcs/addon/client/DBCClientAnimations.java b/src/main/java/kamkeel/npcs/addon/client/DBCClientAnimations.java new file mode 100644 index 000000000..31a375ed3 --- /dev/null +++ b/src/main/java/kamkeel/npcs/addon/client/DBCClientAnimations.java @@ -0,0 +1,642 @@ +package kamkeel.npcs.addon.client; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.entity.EntityClientPlayerMP; +import net.minecraft.client.model.ModelBiped; +import net.minecraft.client.renderer.entity.RenderBiped; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.client.renderer.entity.RenderPlayer; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemArmor; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; +import noppes.npcs.AnimationMixinFunctions; +import noppes.npcs.client.ClientEventHandler; +import org.lwjgl.opengl.GL11; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + +public class DBCClientAnimations { + + public static void doDBCRender(EntityPlayer par1EntityPlayer) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException, NoSuchFieldException { + Minecraft mc = Minecraft.getMinecraft(); + + Class JBRAH = Class.forName("JinRyuu.JBRA.JBRAH"); + Class JRMCoreHDBC = Class.forName("JinRyuu.JRMCore.JRMCoreHDBC"); + Class JRMCoreH = Class.forName("JinRyuu.JRMCore.JRMCoreH"); + Class ExtendedPlayer = Class.forName("JinRyuu.JRMCore.i.ExtendedPlayer"); + Class JGConfigClientSettings = Class.forName("JinRyuu.JRMCore.client.config.jrmc.JGConfigClientSettings"); + Class RenderPlayerJBRA = Class.forName("JinRyuu.JBRA.RenderPlayerJBRA"); + Class JGConfigRaces = Class.forName("JinRyuu.JRMCore.server.config.dbc.JGConfigRaces"); + + Method func_aam = RenderPlayerJBRA.getDeclaredMethod("func_aam", int.class, boolean.class, boolean.class); + func_aam.setAccessible(true); + + boolean jhdsBool = (boolean) JBRAH.getMethod("JHDS").invoke(null); + boolean dbcBool = (boolean) JRMCoreH.getMethod("DBC").invoke(null); + + RenderPlayer renderPlayer = (RenderPlayer) RenderManager.instance.getEntityRenderObject(par1EntityPlayer); + ModelBiped modelMain = (ModelBiped) RenderPlayerJBRA.getField("modelMain").get(renderPlayer); + + EntityClientPlayerMP acp = mc.thePlayer; + + Object data = null; + if (jhdsBool) { + data = JBRAH.getMethod("skinData", EntityPlayer.class).invoke(null, acp); + } + + float f = 1.0F; + GL11.glColor3f(f + getR(), f + getG(), f + getB()); + GL11.glPushMatrix(); + //modelMain.field_78095_p = 0.0F; + modelMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, par1EntityPlayer); + String dns = (String) JRMCoreH.getField("dns").get(null); + if (dns.length() > 3) { + int State = (byte) JRMCoreH.getField("State").get(null); + int race = (int) JRMCoreH.getMethod("dnsRace", String.class).invoke(null, dns); + boolean saiOozar = (boolean) JRMCoreH.getMethod("rSai", int.class).invoke(null, race) && (State == 7 || State == 8); + int gen = (int) JRMCoreH.getMethod("dnsGender", String.class).invoke(null, dns); + int skintype = (int) JRMCoreH.getMethod("dnsSkinT", String.class).invoke(null, dns); + boolean lg = (boolean) JRMCoreH.getMethod("lgndb", EntityPlayer.class, int.class, int.class).invoke(null, par1EntityPlayer, race, State); + boolean iau = (boolean) JRMCoreH.getMethod("rc_arc", int.class).invoke(null, race) && State == 6; + String dnsau = (String) JRMCoreH.getMethod("data", int.class, String.class).invoke(null, 16, ""); + dnsau = dnsau.contains(";") ? dnsau.substring(1) : (par1EntityPlayer.getCommandSenderName().equals(mc.thePlayer.getCommandSenderName()) ? dnsau : ""); + int bodytype = skintype == 0 ? (int) JRMCoreH.getMethod("dnsBodyC1_0", String.class).invoke(null, dns) : (int) JRMCoreH.getMethod("dnsBodyT", String.class).invoke(null, dns); + int bodycm = skintype == 0 ? 0 : (iau ? (int) JRMCoreH.getMethod("dnsauCM", String.class).invoke(null, dns) : (int) JRMCoreH.getMethod("dnsBodyCM", String.class).invoke(null, dns)); + int bodyc1 = skintype == 0 ? 0 : (iau ? (int) JRMCoreH.getMethod("dnsauC1", String.class).invoke(null, dns) : (int) JRMCoreH.getMethod("dnsBodyC1", String.class).invoke(null, dns)); + int bodyc2 = skintype == 0 ? 0 : (iau ? (int) JRMCoreH.getMethod("dnsauC2", String.class).invoke(null, dns) : (int) JRMCoreH.getMethod("dnsBodyC2", String.class).invoke(null, dns)); + int bodyc3 = skintype == 0 ? 0 : (iau ? (int) JRMCoreH.getMethod("dnsauC3", String.class).invoke(null, dns) : (int) JRMCoreH.getMethod("dnsBodyC3", String.class).invoke(null, dns)); + + int plyrSpc = skintype == 0 ? 0 : (((int[]) JRMCoreH.getField("RaceCustomSkin").get(null))[race] == 0 ? 0 : (bodytype >= ((int[]) JRMCoreH.getField("Specials").get(null))[race] ? ((int[]) JRMCoreH.getField("Specials").get(null))[race] - 1 : bodytype)); + int[] an = new int[]{1, 0, 2, 0, 0, 3, 0, 1, 1}; + + Object ep = ExtendedPlayer.getMethod("get", EntityPlayer.class).invoke(null, acp); + int animKiShoot = (int) ExtendedPlayer.getMethod("getAnimKiShoot").invoke(ep); + int blocking = (int) ExtendedPlayer.getMethod("getBlocking").invoke(ep); + + boolean instantTransmission = blocking == 2; + int id = blocking != 0 ? (instantTransmission ? 6 : 0) : (animKiShoot != 0 ? an[animKiShoot - 1] + 2 : -1); + if (!(boolean) JGConfigClientSettings.getField("CLIENT_DA4").get(null)) { + id = -1; + } + + int tailCol; + + int jx; + int j; + if (dbcBool) { + String[] s = ((String) JRMCoreH.getMethod("data", String.class, int.class, String.class).invoke(null, acp.getCommandSenderName(), 1, "0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0")).split(";"); + tailCol = Integer.parseInt(s[2]); + if (tailCol == 1) { + String[] PlyrSkills = (String[]) JRMCoreH.getMethod("PlyrSkills", EntityPlayer.class).invoke(null, acp); + jx = (int) JRMCoreH.getMethod("SklLvl", int.class, String[].class).invoke(null, 12, PlyrSkills); + j = (int) JRMCoreH.getMethod("SklLvl", int.class, String[].class).invoke(null, 15, PlyrSkills); + String ss = s[17]; + boolean v = dbcBool && !ss.equals("-1"); + GL11.glPushMatrix(); + if (v && (jx > 0 || j > 0)) { + if (id > -1) { + func_aam.invoke(renderPlayer, id, false, true); + } + + GL11.glRotatef(6.0F, 0.0F, 0.0F, 1.0F); + GL11.glTranslatef(-0.29F, 0.15F, 0.0F); + RenderPlayerJBRA.getMethod("kss", Entity.class, boolean.class, int.class, int.class, int.class).invoke( + null, acp, false, Integer.parseInt(ss), jx, j); + } + + GL11.glPopMatrix(); + } + } + + float h1 = 1.0F; + ResourceLocation bdyskn; + boolean ssg; + boolean v; + if (race == 5 && dbcBool) { + v = State == 1; + ssg = State == 3 && (boolean) JGConfigRaces.getField("CONFIG_MAJIN_PURE_PINK_SKIN").get(null); + if (v) { + bodycm = 12561588; + } else if (ssg) { + bodycm = 16757199; + } + + bdyskn = new ResourceLocation("jinryuudragonbc:cc/majin/" + (gen == 1 ? "f" : "") + "majin.png"); + mc.getTextureManager().bindTexture(bdyskn); + glColor3f(bodycm); + modelMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, par1EntityPlayer); + AnimationMixinFunctions.renderLimbs(); + + String[] playerData13 = ((String) JRMCoreH.getMethod("data", String.class, int.class, String.class).invoke(null, + par1EntityPlayer.getCommandSenderName(), 13, "0;0;0;0,0,0+0")).split(";"); + String[] absorptionData; + if (playerData13.length > 3) { + absorptionData = playerData13[3].split(","); + } else { + absorptionData = "0;0;0;0,0,0+0".split(","); + } + + String[] absorptionVisuals = absorptionData[1].contains("+") ? absorptionData[1].split("\\+") : new String[]{absorptionData[1]}; + int absorbedRace = Integer.parseInt(absorptionVisuals[0]); + if ((boolean) JRMCoreH.getMethod("isRaceArcosian", int.class).invoke(null, absorbedRace) + || (boolean) JRMCoreH.getMethod("isRaceNamekian", int.class).invoke(null, absorbedRace)) { + bdyskn = new ResourceLocation("jinryuudragonbc:cc/majin/" + (gen == 1 ? "f" : "") + "majin_" + ((boolean) JRMCoreH.getMethod("isRaceArcosian", int.class).invoke(null, absorbedRace) ? "arco" : "namek") + ".png"); + mc.getTextureManager().bindTexture(bdyskn); + glColor3f(bodycm); + modelMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, par1EntityPlayer); + AnimationMixinFunctions.renderLimbs(); + } + + if (!saiOozar) { + if (skintype == 0) { + bdyskn = acp.getLocationSkin().equals(ClientEventHandler.steveTextures) ? (gen >= 1 ? ClientEventHandler.fem : ClientEventHandler.steveTextures) : acp.getLocationSkin(); + if (jhdsBool && (boolean) JBRAH.getMethod("getSkinHas", Object.class).invoke(null, data)) { + mc.getTextureManager().bindTexture((ResourceLocation) JBRAH.getMethod("getSkinLoc", Object.class).invoke(null, data)); + } else { + mc.getTextureManager().bindTexture(bdyskn); + } + + GL11.glColor3f(h1 + getR(), h1 + getG(), h1 + getB()); + modelMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, par1EntityPlayer); + AnimationMixinFunctions.renderLimbs(); + } else if (jhdsBool && (boolean) JBRAH.getMethod("getSkinHas", Object.class).invoke(null, data) && skintype == 0) { + GL11.glColor3f(h1 + getR(), h1 + getG(), h1 + getB()); + mc.getTextureManager().bindTexture((ResourceLocation) JBRAH.getMethod("getSkinLoc", Object.class).invoke(null, data)); + modelMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, par1EntityPlayer); + AnimationMixinFunctions.renderLimbs(); + } + } + } else if (race == 3 && dbcBool) { + v = (boolean) JRMCoreH.getMethod("StusEfctsMe", int.class).invoke(null, 17); + ssg = (boolean) JRMCoreHDBC.getMethod("godKiUserBase", int.class, int.class).invoke(null, race, State); + if (ssg && v) { + bodycm = 16744999; + bodyc1 = 15524763; + bodyc2 = 12854822; + bodyc3 = 0; + } + + bdyskn = new ResourceLocation("jinryuudragonbc:cc/nam/0nam" + plyrSpc + ".png"); + mc.getTextureManager().bindTexture(bdyskn); + glColor3f(bodycm); + modelMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, par1EntityPlayer); + AnimationMixinFunctions.renderLimbs(); + + bdyskn = new ResourceLocation("jinryuudragonbc:cc/nam/1nam" + plyrSpc + ".png"); + mc.getTextureManager().bindTexture(bdyskn); + glColor3f(bodyc1); + modelMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, par1EntityPlayer); + AnimationMixinFunctions.renderLimbs(); + + bdyskn = new ResourceLocation("jinryuudragonbc:cc/nam/2nam" + plyrSpc + ".png"); + mc.getTextureManager().bindTexture(bdyskn); + glColor3f(bodyc2); + modelMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, par1EntityPlayer); + AnimationMixinFunctions.renderLimbs(); + + bdyskn = new ResourceLocation("jinryuudragonbc:cc/nam/3nam" + plyrSpc + ".png"); + mc.getTextureManager().bindTexture(bdyskn); + GL11.glColor3f(h1 + getR(), h1 + getG(), h1 + getB()); + modelMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, par1EntityPlayer); + AnimationMixinFunctions.renderLimbs(); + } else if (race == 4 && dbcBool) { + v = (boolean) JRMCoreH.getMethod("StusEfctsMe", int.class).invoke(null, 17); + ssg = (boolean) JRMCoreHDBC.getMethod("godKiUserBase", int.class, int.class).invoke(null, race, State); + if (ssg && v) { + State = 6; + bodycm = 5526612; + bodyc1 = 12829635; + bodyc3 = 1513239; + } + + bdyskn = new ResourceLocation("jinryuudragonbc:cc/arc/" + (gen == 1 ? "f" : "m") + "/0A" + ((short[]) JRMCoreH.getField("TransFrSkn").get(null))[State] + plyrSpc + ".png"); + mc.getTextureManager().bindTexture(bdyskn); + glColor3f(bodycm); + modelMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, par1EntityPlayer); + AnimationMixinFunctions.renderLimbs(); + + bdyskn = new ResourceLocation("jinryuudragonbc:cc/arc/" + (gen == 1 ? "f" : "m") + "/1A" + ((short[]) JRMCoreH.getField("TransFrSkn").get(null))[State] + plyrSpc + ".png"); + mc.getTextureManager().bindTexture(bdyskn); + glColor3f(bodyc1); + modelMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, par1EntityPlayer); + AnimationMixinFunctions.renderLimbs(); + + bdyskn = new ResourceLocation("jinryuudragonbc:cc/arc/" + (gen == 1 ? "f" : "m") + "/2A" + ((short[]) JRMCoreH.getField("TransFrSkn").get(null))[State] + plyrSpc + ".png"); + mc.getTextureManager().bindTexture(bdyskn); + glColor3f(bodyc2); + modelMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, par1EntityPlayer); + AnimationMixinFunctions.renderLimbs(); + + bdyskn = new ResourceLocation("jinryuudragonbc:cc/arc/" + (gen == 1 ? "f" : "m") + "/3A" + ((short[]) JRMCoreH.getField("TransFrSkn").get(null))[State] + plyrSpc + ".png"); + mc.getTextureManager().bindTexture(bdyskn); + glColor3f(bodyc3); + modelMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, par1EntityPlayer); + AnimationMixinFunctions.renderLimbs(); + + bdyskn = new ResourceLocation("jinryuudragonbc:cc/arc/" + (gen == 1 ? "f" : "m") + "/4A" + ((short[]) JRMCoreH.getField("TransFrSkn").get(null))[State] + plyrSpc + ".png"); + mc.getTextureManager().bindTexture(bdyskn); + GL11.glColor3f(h1 + getR(), h1 + getG(), h1 + getB()); + modelMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, par1EntityPlayer); + AnimationMixinFunctions.renderLimbs(); + } else { + if (saiOozar) { + bdyskn = new ResourceLocation("jinryuudragonbc:cc/oozaru1.png"); + mc.getTextureManager().bindTexture(bdyskn); + glColor3f(skintype != 0 ? bodycm : 11374471); + modelMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, par1EntityPlayer); + AnimationMixinFunctions.renderLimbs(); + + tailCol = race != 2 && bodytype == 0 ? 6498048 : bodytype; + jx = State != 0 && State != 7 ? (lg ? 10092390 : 16574610) : (skintype == 1 ? bodyc1 : tailCol); + bdyskn = new ResourceLocation("jinryuudragonbc:cc/oozaru2.png"); + mc.getTextureManager().bindTexture(bdyskn); + glColor3f(jx); + modelMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, par1EntityPlayer); + AnimationMixinFunctions.renderLimbs(); + } else if (skintype != 0) { + bdyskn = new ResourceLocation("jinryuumodscore:cc/" + (gen == 1 ? "f" : "") + "hum.png"); + mc.getTextureManager().bindTexture(bdyskn); + glColor3f(bodycm); + modelMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, par1EntityPlayer); + AnimationMixinFunctions.renderLimbs(); + } + + if (!saiOozar) { + if (skintype == 0) { + bdyskn = acp.getLocationSkin().equals(ClientEventHandler.steveTextures) ? (gen >= 1 ? ClientEventHandler.fem : ClientEventHandler.steveTextures) : acp.getLocationSkin(); + if (jhdsBool && (boolean) JBRAH.getMethod("getSkinHas", Object.class).invoke(null, data)) { + mc.getTextureManager().bindTexture((ResourceLocation) JBRAH.getMethod("getSkinLoc", Object.class).invoke(null, data)); + } else { + mc.getTextureManager().bindTexture(bdyskn); + } + + GL11.glColor3f(h1 + getR(), h1 + getG(), h1 + getB()); + modelMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, par1EntityPlayer); + AnimationMixinFunctions.renderLimbs(); + } else if (jhdsBool && (boolean) JBRAH.getMethod("getSkinHas", Object.class).invoke(null, data) && skintype == 0) { + GL11.glColor3f(h1 + getR(), h1 + getG(), h1 + getB()); + mc.getTextureManager().bindTexture((ResourceLocation) JBRAH.getMethod("getSkinLoc", Object.class).invoke(null, data)); + modelMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, par1EntityPlayer); + AnimationMixinFunctions.renderLimbs(); + } + + if (State == 14) { + tailCol = race != 2 && bodytype == 0 ? 6498048 : bodytype; + tailCol = (boolean) JRMCoreH.getMethod("isAprilFoolsModeOn").invoke(null) ? 13292516 : tailCol; + tailCol = skintype == 1 ? bodyc1 : tailCol; + if ((boolean) JRMCoreH.getMethod("rSai", int.class).invoke(null, race) && tailCol == 6498048 && State == 14) { + if ((boolean) JRMCoreH.getMethod("isAprilFoolsModeOn").invoke(null)) { + tailCol = 13292516; + } else { + tailCol = 14292268; + } + } + + mc.getTextureManager().bindTexture(new ResourceLocation("jinryuudragonbc:cc/ss4" + (skintype == 0 ? "a" : "b") + ".png")); + glColor3f(tailCol); + modelMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, par1EntityPlayer); + AnimationMixinFunctions.renderLimbs(); + } + } + } + + if ((boolean) JGConfigClientSettings.getField("CLIENT_DA19").get(null) && (dbcBool || (boolean) JRMCoreH.getMethod("NC").invoke(null))) { + GL11.glPushMatrix(); + GL11.glEnable(3042); + GL11.glDisable(2896); + GL11.glBlendFunc(770, 771); + GL11.glAlphaFunc(516, 0.003921569F); + GL11.glDepthMask(false); + tailCol = Integer.parseInt((String) JRMCoreH.getMethod("data", String.class, int.class, String.class + ).invoke(null, par1EntityPlayer.getCommandSenderName(), 8, "200")); + float one = (float) tailCol / 100.0F; + j = (int) ((float) tailCol / one); + if (j < 70) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + mc.getTextureManager().bindTexture(new ResourceLocation("jinryuumodscore:cc/bruises1.png")); + AnimationMixinFunctions.renderLimbs(); + } + + if (j < 55) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + mc.getTextureManager().bindTexture(new ResourceLocation("jinryuumodscore:cc/bruises2.png")); + AnimationMixinFunctions.renderLimbs(); + } + + if (j < 35) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + mc.getTextureManager().bindTexture(new ResourceLocation("jinryuumodscore:cc/bruises3.png")); + AnimationMixinFunctions.renderLimbs(); + } + + if (j < 20) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + mc.getTextureManager().bindTexture(new ResourceLocation("jinryuumodscore:cc/bruises4.png")); + AnimationMixinFunctions.renderLimbs(); + } + + GL11.glDepthMask(true); + GL11.glEnable(2896); + GL11.glDisable(3042); + GL11.glPopMatrix(); + } + + ItemStack itemstack = par1EntityPlayer.inventory.armorItemInSlot(2); + String dbcarmor; + Item item; + ResourceLocation mcarmor; + ResourceLocation armor; + ItemArmor itemarmor; + if (itemstack != null) { + item = itemstack.getItem(); + if (item instanceof ItemArmor) { + itemarmor = (ItemArmor) item; + GL11.glPushMatrix(); + dbcarmor = itemarmor.getArmorTexture(itemstack, par1EntityPlayer, 2, null); + mcarmor = RenderBiped.getArmorResource(par1EntityPlayer, itemstack, 1, null); + if (dbcarmor != null) { + dbcarmor = dbcarmor.replace("jbra", "").replace("_dam", ""); + } + + armor = dbcarmor != null ? new ResourceLocation(dbcarmor) : mcarmor; + mc.getTextureManager().bindTexture(armor); + GL11.glPushMatrix(); + if (id > -1) { + func_aam.invoke(renderPlayer, id, false, true); + } + + GL11.glColor3f(1.0F + getR(), 1.0F + getG(), 1.0F + getB()); + GL11.glScalef(1.0001F, 1.0001F, 1.0001F); + if (dbcarmor != null) { + modelMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, par1EntityPlayer); + modelMain.textureHeight = 64; + modelMain.textureWidth = 128; + AnimationMixinFunctions.renderLimbs(); + } else { + modelMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, par1EntityPlayer); + AnimationMixinFunctions.renderLimbs(); + } + + GL11.glPopMatrix(); + GL11.glPopMatrix(); + } + } + + if (race == 3 && dbcBool) { + bdyskn = new ResourceLocation("jinryuudragonbc:cc/nam/0nam" + plyrSpc + ".png"); + mc.getTextureManager().bindTexture(bdyskn); + glColor3f(bodycm); + modelMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, par1EntityPlayer); + AnimationMixinFunctions.renderLimbs(); + + bdyskn = new ResourceLocation("jinryuudragonbc:cc/nam/1nam" + plyrSpc + ".png"); + mc.getTextureManager().bindTexture(bdyskn); + glColor3f(bodyc1); + modelMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, par1EntityPlayer); + AnimationMixinFunctions.renderLimbs(); + + bdyskn = new ResourceLocation("jinryuudragonbc:cc/nam/2nam" + plyrSpc + ".png"); + mc.getTextureManager().bindTexture(bdyskn); + glColor3f(bodyc2); + modelMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, par1EntityPlayer); + AnimationMixinFunctions.renderLimbs(); + + bdyskn = new ResourceLocation("jinryuudragonbc:cc/nam/3nam" + plyrSpc + ".png"); + mc.getTextureManager().bindTexture(bdyskn); + GL11.glColor3f(h1 + getR(), h1 + getG(), h1 + getB()); + modelMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, par1EntityPlayer); + AnimationMixinFunctions.renderLimbs(); + } else if (race == 4 && dbcBool) { + bdyskn = new ResourceLocation("jinryuudragonbc:cc/arc/" + (gen == 1 ? "f" : "m") + "/0A" + ((short[]) JRMCoreH.getField("TransFrSkn").get(null))[State] + plyrSpc + ".png"); + mc.getTextureManager().bindTexture(bdyskn); + glColor3f(bodycm); + modelMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, par1EntityPlayer); + AnimationMixinFunctions.renderLimbs(); + + bdyskn = new ResourceLocation("jinryuudragonbc:cc/arc/" + (gen == 1 ? "f" : "m") + "/1A" + ((short[]) JRMCoreH.getField("TransFrSkn").get(null))[State] + plyrSpc + ".png"); + mc.getTextureManager().bindTexture(bdyskn); + glColor3f(bodyc1); + modelMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, par1EntityPlayer); + AnimationMixinFunctions.renderLimbs(); + + bdyskn = new ResourceLocation("jinryuudragonbc:cc/arc/" + (gen == 1 ? "f" : "m") + "/2A" + ((short[]) JRMCoreH.getField("TransFrSkn").get(null))[State] + plyrSpc + ".png"); + mc.getTextureManager().bindTexture(bdyskn); + glColor3f(bodyc2); + modelMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, par1EntityPlayer); + AnimationMixinFunctions.renderLimbs(); + + bdyskn = new ResourceLocation("jinryuudragonbc:cc/arc/" + (gen == 1 ? "f" : "m") + "/3A" + ((short[]) JRMCoreH.getField("TransFrSkn").get(null))[State] + plyrSpc + ".png"); + mc.getTextureManager().bindTexture(bdyskn); + glColor3f(bodyc3); + modelMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, par1EntityPlayer); + AnimationMixinFunctions.renderLimbs(); + + bdyskn = new ResourceLocation("jinryuudragonbc:cc/arc/" + (gen == 1 ? "f" : "m") + "/4A" + ((short[]) JRMCoreH.getField("TransFrSkn").get(null))[State] + plyrSpc + ".png"); + mc.getTextureManager().bindTexture(bdyskn); + GL11.glColor3f(h1 + getR(), h1 + getG(), h1 + getB()); + modelMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, par1EntityPlayer); + AnimationMixinFunctions.renderLimbs(); + } else { + if (saiOozar) { + bdyskn = new ResourceLocation("jinryuudragonbc:cc/oozaru1.png"); + mc.getTextureManager().bindTexture(bdyskn); + glColor3f(skintype != 0 ? bodycm : 11374471); + modelMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, par1EntityPlayer); + AnimationMixinFunctions.renderLimbs(); + + jx = race != 2 && bodytype == 0 ? 6498048 : bodytype; + j = State != 0 && State != 7 ? (lg ? 10092390 : 16574610) : (skintype == 1 ? bodyc1 : jx); + bdyskn = new ResourceLocation("jinryuudragonbc:cc/oozaru2.png"); + mc.getTextureManager().bindTexture(bdyskn); + glColor3f(j); + modelMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, par1EntityPlayer); + AnimationMixinFunctions.renderLimbs(); + } else if (skintype != 0) { + bdyskn = new ResourceLocation("jinryuumodscore:cc/" + (gen == 1 ? "f" : "") + "hum.png"); + mc.getTextureManager().bindTexture(bdyskn); + glColor3f(bodycm); + modelMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, par1EntityPlayer); + AnimationMixinFunctions.renderLimbs(); + } + + if (!saiOozar) { + if (skintype == 0) { + bdyskn = acp.getLocationSkin().equals(ClientEventHandler.steveTextures) ? (gen >= 1 ? ClientEventHandler.fem : ClientEventHandler.steveTextures) : acp.getLocationSkin(); + if (jhdsBool && (boolean) JBRAH.getMethod("getSkinHas", Object.class).invoke(null, data)) { + mc.getTextureManager().bindTexture((ResourceLocation) JBRAH.getMethod("getSkinLoc", Object.class).invoke(null, data)); + } else { + mc.getTextureManager().bindTexture(bdyskn); + } + + GL11.glColor3f(h1 + getR(), h1 + getG(), h1 + getB()); + modelMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, par1EntityPlayer); + AnimationMixinFunctions.renderLimbs(); + } else if (jhdsBool && (boolean) JBRAH.getMethod("getSkinHas", Object.class).invoke(null, data) && skintype == 0) { + GL11.glColor3f(h1 + getR(), h1 + getG(), h1 + getB()); + mc.getTextureManager().bindTexture((ResourceLocation) JBRAH.getMethod("getSkinLoc", Object.class).invoke(null, data)); + + modelMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, par1EntityPlayer); + AnimationMixinFunctions.renderLimbs(); + } + + if (State == 14) { + tailCol = race != 2 && bodytype == 0 ? 6498048 : bodytype; + tailCol = (boolean) JRMCoreH.getMethod("isAprilFoolsModeOn").invoke(null) ? 13292516 : tailCol; + jx = skintype == 1 ? bodyc1 : tailCol; + if ((boolean) JRMCoreH.getMethod("rSai", int.class).invoke(null, race) && jx == 6498048 && State == 14) { + if ((boolean) JRMCoreH.getMethod("isAprilFoolsModeOn").invoke(null)) { + jx = 13292516; + } else { + jx = 14292268; + } + } + + mc.getTextureManager().bindTexture(new ResourceLocation("jinryuudragonbc:cc/ss4" + (skintype == 0 ? "a" : "b") + ".png")); + glColor3f(jx); + modelMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, par1EntityPlayer); + AnimationMixinFunctions.renderLimbs(); + } + } + } + + if ((boolean) JGConfigClientSettings.getField("CLIENT_DA19").get(null)) { + GL11.glPushMatrix(); + GL11.glEnable(3042); + GL11.glDisable(2896); + GL11.glBlendFunc(770, 771); + GL11.glAlphaFunc(516, 0.003921569F); + GL11.glDepthMask(false); + tailCol = (int) JRMCoreH.getMethod( + "stat", Entity.class, int.class, int.class, int.class, int.class, int.class, int.class, float.class).invoke(null, + par1EntityPlayer, 2, + JRMCoreH.getField("Pwrtyp").get(null), 2, + ((int[]) JRMCoreH.getField("PlyrAttrbts").get(null))[2], race, + JRMCoreH.getField("Class").get(null), 0.0F); + jx = Integer.parseInt((String) JRMCoreH.getMethod("data", String.class, int.class, String.class).invoke(null, par1EntityPlayer.getCommandSenderName(), 8, "200")); + float one = (float) tailCol / 100.0F; + int perc = (int) ((float) jx / one); + if (perc < 70) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + mc.getTextureManager().bindTexture(new ResourceLocation("jinryuumodscore:cc/bruises1.png")); + AnimationMixinFunctions.renderLimbs(); + } + + if (perc < 55) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + mc.getTextureManager().bindTexture(new ResourceLocation("jinryuumodscore:cc/bruises2.png")); + AnimationMixinFunctions.renderLimbs(); + } + + if (perc < 35) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + mc.getTextureManager().bindTexture(new ResourceLocation("jinryuumodscore:cc/bruises3.png")); + AnimationMixinFunctions.renderLimbs(); + } + + if (perc < 20) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + mc.getTextureManager().bindTexture(new ResourceLocation("jinryuumodscore:cc/bruises4.png")); + AnimationMixinFunctions.renderLimbs(); + } + + GL11.glDepthMask(true); + GL11.glEnable(2896); + GL11.glDisable(3042); + GL11.glPopMatrix(); + } + + if (itemstack != null) { + item = itemstack.getItem(); + if (item instanceof ItemArmor) { + itemarmor = (ItemArmor) item; + GL11.glPushMatrix(); + dbcarmor = itemarmor.getArmorTexture(itemstack, par1EntityPlayer, 2, null); + mcarmor = RenderBiped.getArmorResource(par1EntityPlayer, itemstack, 1, null); + if (dbcarmor != null) { + dbcarmor = dbcarmor.replace("jbra", "").replace("_dam", ""); + } + + armor = dbcarmor != null ? new ResourceLocation(dbcarmor) : mcarmor; + mc.getTextureManager().bindTexture(armor); + if (id == 0 || id == 3 || id == 5) { + if (id == 0) { + if ((boolean) JGConfigClientSettings.getField("CLIENT_DA18").get(null)) { + GL11.glPushMatrix(); + func_aam.invoke(renderPlayer, id, false, true); + GL11.glColor3f(1.0F + getR(), 1.0F + getG(), 1.0F + getB()); + GL11.glScalef(1.0001F, 1.0001F, 1.0001F); + if (dbcarmor != null) { + modelMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, par1EntityPlayer); + modelMain.textureHeight = 64; + modelMain.textureWidth = 128; + AnimationMixinFunctions.renderLimbs(); + } else { + modelMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, par1EntityPlayer); + AnimationMixinFunctions.renderLimbs(); + } + + GL11.glPopMatrix(); + } + } else { + GL11.glPushMatrix(); + func_aam.invoke(renderPlayer, id, false, true); + GL11.glColor3f(1.0F + getR(), 1.0F + getG(), 1.0F + getB()); + GL11.glScalef(1.0001F, 1.0001F, 1.0001F); + if (dbcarmor != null) { + modelMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, par1EntityPlayer); + modelMain.textureHeight = 64; + modelMain.textureWidth = 128; + AnimationMixinFunctions.renderLimbs(); + } else { + modelMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, par1EntityPlayer); + AnimationMixinFunctions.renderLimbs(); + } + + GL11.glPopMatrix(); + } + } + + GL11.glPopMatrix(); + } + } + } + + GL11.glPopMatrix(); + } + + private static float getR() throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException { + Class RenderPlayerJBRA = Class.forName("JinRyuu.JBRA.RenderPlayerJBRA"); + Method method = RenderPlayerJBRA.getDeclaredMethod("getR"); + method.setAccessible(true); + return (float) method.invoke(null); + } + + private static float getB() throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException { + Class RenderPlayerJBRA = Class.forName("JinRyuu.JBRA.RenderPlayerJBRA"); + Method method = RenderPlayerJBRA.getDeclaredMethod("getB"); + method.setAccessible(true); + return (float) method.invoke(null); + } + + private static float getG() throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException { + Class RenderPlayerJBRA = Class.forName("JinRyuu.JBRA.RenderPlayerJBRA"); + Method method = RenderPlayerJBRA.getDeclaredMethod("getG"); + method.setAccessible(true); + return (float) method.invoke(null); + } + + private static void glColor3f(int c) throws ClassNotFoundException, InvocationTargetException, NoSuchMethodException, IllegalAccessException { + float h2 = (float) (c >> 16 & 255) / 255.0F; + float h3 = (float) (c >> 8 & 255) / 255.0F; + float h4 = (float) (c & 255) / 255.0F; + float h1 = 1.0F; + float r = h1 * h2; + float g = h1 * h3; + float b = h1 * h4; + GL11.glColor3f(r + getR(), g + getG(), b + getB()); + } +} diff --git a/src/main/java/kamkeel/npcs/command/AnimationCommand.java b/src/main/java/kamkeel/npcs/command/AnimationCommand.java index ca9cfd0ab..99d3ba554 100644 --- a/src/main/java/kamkeel/npcs/command/AnimationCommand.java +++ b/src/main/java/kamkeel/npcs/command/AnimationCommand.java @@ -28,7 +28,7 @@ public class AnimationCommand extends CommandKamkeelBase { desc = "set an animation to a player", usage = " " ) - public void set(ICommandSender sender, String[] args) throws CommandException { + public void set(ICommandSender sender, String args[]) throws CommandException { String playername = args[0]; int animationId; try { @@ -63,7 +63,7 @@ public class AnimationCommand extends CommandKamkeelBase { desc = "clear an animation from a player", usage = "" ) - public void clear(ICommandSender sender, String[] args) throws CommandException { + public void clear(ICommandSender sender, String args[]) throws CommandException { String playername = args[0]; List data = PlayerDataController.Instance.getPlayersData(sender, playername); if (data.isEmpty()) { @@ -85,7 +85,7 @@ public class AnimationCommand extends CommandKamkeelBase { desc = "enable an animation on a player", usage = "" ) - public void enable(ICommandSender sender, String[] args) throws CommandException { + public void enable(ICommandSender sender, String args[]) throws CommandException { String playername = args[0]; List data = PlayerDataController.Instance.getPlayersData(sender, playername); if (data.isEmpty()) { @@ -111,7 +111,7 @@ public class AnimationCommand extends CommandKamkeelBase { desc = "disable an animation on a player", usage = "" ) - public void disable(ICommandSender sender, String[] args) throws CommandException { + public void disable(ICommandSender sender, String args[]) throws CommandException { String playername = args[0]; List data = PlayerDataController.Instance.getPlayersData(sender, playername); if (data.isEmpty()) { @@ -136,7 +136,7 @@ public class AnimationCommand extends CommandKamkeelBase { @SubCommand( desc = "reload animations" ) - public void reload(ICommandSender sender, String[] args) { + public void reload(ICommandSender sender, String args[]) { AnimationController.Instance.load(); sendResult(sender, "Animations Reloaded"); } diff --git a/src/main/java/kamkeel/npcs/command/CloneCommand.java b/src/main/java/kamkeel/npcs/command/CloneCommand.java index 106dd1bdf..ac3d29606 100644 --- a/src/main/java/kamkeel/npcs/command/CloneCommand.java +++ b/src/main/java/kamkeel/npcs/command/CloneCommand.java @@ -104,7 +104,7 @@ public class CloneCommand extends CommandKamkeelBase { try { tab = Integer.parseInt(args[1]); if (tab < 0 || tab > 15) { - sendError(sender, "Tab must be within 1-15"); + sendError(sender, String.format("Tab must be within 1-15")); return; } } catch (NumberFormatException ex) { @@ -138,7 +138,7 @@ public class CloneCommand extends CommandKamkeelBase { try { tab = Integer.parseInt(args[1]); if (tab < 0 || tab > 15) { - sendError(sender, "Tab must be within 1-15"); + sendError(sender, String.format("Tab must be within 1-15")); return; } } catch (NumberFormatException ex) { @@ -219,7 +219,7 @@ public class CloneCommand extends CommandKamkeelBase { try { tab = Integer.parseInt(args[1]); if (tab < 0 || tab > 15) { - sendError(sender, "Tab must be within 1-15"); + sendError(sender, String.format("Tab must be within 1-15")); return; } } catch (NumberFormatException ex) { @@ -312,6 +312,7 @@ public class CloneCommand extends CommandKamkeelBase { world.spawnEntityInWorld(entity); } } + return; } public World getWorld(String t) { diff --git a/src/main/java/kamkeel/npcs/command/CommandCommand.java b/src/main/java/kamkeel/npcs/command/CommandCommand.java index edc20b84d..f2a1db644 100644 --- a/src/main/java/kamkeel/npcs/command/CommandCommand.java +++ b/src/main/java/kamkeel/npcs/command/CommandCommand.java @@ -2,6 +2,8 @@ package kamkeel.npcs.command; import net.minecraft.command.CommandException; import net.minecraft.command.ICommandSender; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.util.ChunkCoordinates; import net.minecraft.util.math.BlockPos; import noppes.npcs.EventHooks; @@ -42,11 +44,13 @@ public class CommandCommand extends CommandKamkeelBase { ChunkCoordinates senderCoords = sender.getPlayerCoordinates(); IPos senderPos = NpcAPI.Instance().getIPos(new BlockPos(senderCoords.posX, senderCoords.posY, senderCoords.posZ)); - CustomNPCsEvent.ScriptedCommandEvent event = new CustomNPCsEvent.ScriptedCommandEvent(senderWorld, senderPos, sender.getCommandSenderName(), commandId, commandArgs); - EventHooks.onScriptedCommand(event); + if(sender instanceof EntityPlayer) { + CustomNPCsEvent.ScriptedCommandEvent event = new CustomNPCsEvent.ScriptedCommandEvent(senderWorld, senderPos, sender.getCommandSenderName(), commandId, commandArgs); + EventHooks.onScriptedCommand((EntityPlayer) sender, event); - if (!event.replyMessage.isEmpty()) { - sendMessage(sender, event.replyMessage); + if (!event.replyMessage.isEmpty()) { + sendMessage(sender, event.replyMessage); + } } } } diff --git a/src/main/java/kamkeel/npcs/command/DialogCategoryCommand.java b/src/main/java/kamkeel/npcs/command/DialogCategoryCommand.java index 0f47de46e..9f39ac06c 100644 --- a/src/main/java/kamkeel/npcs/command/DialogCategoryCommand.java +++ b/src/main/java/kamkeel/npcs/command/DialogCategoryCommand.java @@ -30,7 +30,7 @@ public class DialogCategoryCommand extends CommandKamkeelBase { desc = "Find dialog category id number by its name", usage = "" ) - public void id(ICommandSender sender, String[] args) throws CommandException { + public void id(ICommandSender sender, String args[]) throws CommandException { if (args.length == 0) { sendError(sender, "Please provide a name for the dialog category"); return; @@ -55,7 +55,7 @@ public class DialogCategoryCommand extends CommandKamkeelBase { desc = "Read a dialog category for a player", usage = " " ) - public void read(ICommandSender sender, String[] args) throws CommandException { + public void read(ICommandSender sender, String args[]) throws CommandException { String playername = args[0]; int dialogCatId; try { @@ -96,7 +96,7 @@ public class DialogCategoryCommand extends CommandKamkeelBase { desc = "Unread a dialog category for a player", usage = " " ) - public void unread(ICommandSender sender, String[] args) throws CommandException { + public void unread(ICommandSender sender, String args[]) throws CommandException { String playername = args[0]; int dialogCatId; try { diff --git a/src/main/java/kamkeel/npcs/command/DialogCommand.java b/src/main/java/kamkeel/npcs/command/DialogCommand.java index 4c29d7005..2392859a4 100644 --- a/src/main/java/kamkeel/npcs/command/DialogCommand.java +++ b/src/main/java/kamkeel/npcs/command/DialogCommand.java @@ -39,7 +39,7 @@ public class DialogCommand extends CommandKamkeelBase { desc = "force read", usage = " " ) - public void read(ICommandSender sender, String[] args) throws CommandException { + public void read(ICommandSender sender, String args[]) throws CommandException { String playername = args[0]; int diagid; try { @@ -65,7 +65,7 @@ public class DialogCommand extends CommandKamkeelBase { desc = "force unread dialog", usage = " " ) - public void unread(ICommandSender sender, String[] args) throws CommandException { + public void unread(ICommandSender sender, String args[]) throws CommandException { String playername = args[0]; int diagid; try { @@ -91,7 +91,7 @@ public class DialogCommand extends CommandKamkeelBase { desc = "reload dialogs from disk", permission = 4 ) - public void reload(ICommandSender sender, String[] args) { + public void reload(ICommandSender sender, String args[]) { new DialogController().load(); SyncController.syncAllDialogs(); sendResult(sender, "Dialogs Reloaded"); @@ -101,7 +101,7 @@ public class DialogCommand extends CommandKamkeelBase { desc = "show dialog", usage = " " ) - public void show(ICommandSender sender, String[] args) throws CommandException { + public void show(ICommandSender sender, String args[]) throws CommandException { EntityPlayer player = CommandBase.getPlayer(sender, args[0]); if (player == null) { sendError(sender, "Unknown player: " + args[0]); @@ -136,7 +136,7 @@ public class DialogCommand extends CommandKamkeelBase { desc = "Find dialog id number by its name", usage = "" ) - public void id(ICommandSender sender, String[] args) throws CommandException { + public void id(ICommandSender sender, String args[]) throws CommandException { if (args.length == 0) { sendError(sender, "Please provide a name for the dialog"); return; @@ -160,7 +160,7 @@ public class DialogCommand extends CommandKamkeelBase { desc = "List a dialogs availability options", usage = "" ) - public void availability(ICommandSender sender, String[] args) throws CommandException { + public void availability(ICommandSender sender, String args[]) throws CommandException { if (args.length == 0) { sendError(sender, "Please provide an id for the dialog"); return; @@ -234,7 +234,7 @@ public class DialogCommand extends CommandKamkeelBase { desc = "Quick info on a dialog", usage = "" ) - public void info(ICommandSender sender, String[] args) throws CommandException { + public void info(ICommandSender sender, String args[]) throws CommandException { if (args.length == 0) { sendError(sender, "Please provide an id for the quest"); return; diff --git a/src/main/java/kamkeel/npcs/command/EffectCommand.java b/src/main/java/kamkeel/npcs/command/EffectCommand.java index df25413ae..3cca5305e 100644 --- a/src/main/java/kamkeel/npcs/command/EffectCommand.java +++ b/src/main/java/kamkeel/npcs/command/EffectCommand.java @@ -6,7 +6,7 @@ import noppes.npcs.controllers.CustomEffectController; import noppes.npcs.controllers.PlayerDataController; import noppes.npcs.controllers.data.CustomEffect; import noppes.npcs.controllers.data.PlayerData; -import noppes.npcs.scripted.event.PlayerEvent.EffectEvent.ExpirationType; +import noppes.npcs.scripted.event.player.PlayerEvent.EffectEvent.ExpirationType; import java.util.*; diff --git a/src/main/java/kamkeel/npcs/command/FactionCommand.java b/src/main/java/kamkeel/npcs/command/FactionCommand.java index ade415da1..af615b9a7 100644 --- a/src/main/java/kamkeel/npcs/command/FactionCommand.java +++ b/src/main/java/kamkeel/npcs/command/FactionCommand.java @@ -154,7 +154,7 @@ public class FactionCommand extends CommandKamkeelBase { @Override public List addTabCompletionOptions(ICommandSender par1, String[] args) { if (args.length == 3) { - return getListOfStringsMatchingLastWord(args, "add", "subtract", "set", "reset", "drop", "create"); + return getListOfStringsMatchingLastWord(args, new String[]{"add", "subtract", "set", "reset", "drop", "create"}); } return null; } diff --git a/src/main/java/kamkeel/npcs/command/HelpCommand.java b/src/main/java/kamkeel/npcs/command/HelpCommand.java index 779c9de96..f1f335ec2 100644 --- a/src/main/java/kamkeel/npcs/command/HelpCommand.java +++ b/src/main/java/kamkeel/npcs/command/HelpCommand.java @@ -10,7 +10,7 @@ import static kamkeel.npcs.util.ColorUtil.sendError; import static kamkeel.npcs.util.ColorUtil.sendMessage; public class HelpCommand extends CommandKamkeelBase { - private final CommandKamkeel parent; + private CommandKamkeel parent; public HelpCommand(CommandKamkeel parent) { this.parent = parent; diff --git a/src/main/java/kamkeel/npcs/command/NpcCommand.java b/src/main/java/kamkeel/npcs/command/NpcCommand.java index bf5939847..556976ed0 100644 --- a/src/main/java/kamkeel/npcs/command/NpcCommand.java +++ b/src/main/java/kamkeel/npcs/command/NpcCommand.java @@ -210,7 +210,7 @@ public class NpcCommand extends CommandKamkeelBase { @Override public List addTabCompletionOptions(ICommandSender par1, String[] args) { if (args.length == 2) { - return CommandBase.getListOfStringsMatchingLastWord(args, "create", "home", "visible", "delete", "owner", "name"); + return CommandBase.getListOfStringsMatchingLastWord(args, new String[]{"create", "home", "visible", "delete", "owner", "name"}); } if (args.length == 3 && args[1].equalsIgnoreCase("owner")) { return CommandBase.getListOfStringsMatchingLastWord(args, MinecraftServer.getServer().getAllUsernames()); diff --git a/src/main/java/kamkeel/npcs/command/OverlayCommand.java b/src/main/java/kamkeel/npcs/command/OverlayCommand.java index f31cc9560..3ee948d50 100644 --- a/src/main/java/kamkeel/npcs/command/OverlayCommand.java +++ b/src/main/java/kamkeel/npcs/command/OverlayCommand.java @@ -28,7 +28,7 @@ public class OverlayCommand extends CommandKamkeelBase { desc = "set an overlay to a player", usage = " " ) - public void set(ICommandSender sender, String[] args) throws CommandException { + public void set(ICommandSender sender, String args[]) throws CommandException { String playername = args[0]; int overlayID; try { @@ -55,7 +55,7 @@ public class OverlayCommand extends CommandKamkeelBase { desc = "remove an overlay from a player", usage = " " ) - public void remove(ICommandSender sender, String[] args) throws CommandException { + public void remove(ICommandSender sender, String args[]) throws CommandException { String playername = args[0]; int overlayID; try { @@ -85,7 +85,7 @@ public class OverlayCommand extends CommandKamkeelBase { desc = "modify an overlay for a player", usage = " " ) - public void modify(ICommandSender sender, String[] args) throws CommandException { + public void modify(ICommandSender sender, String args[]) throws CommandException { String playername = args[0]; int overlayID; try { @@ -141,7 +141,7 @@ public class OverlayCommand extends CommandKamkeelBase { desc = "clears all overlays from a player", usage = "" ) - public void clear(ICommandSender sender, String[] args) throws CommandException { + public void clear(ICommandSender sender, String args[]) throws CommandException { String playername = args[0]; List data = PlayerDataController.Instance.getPlayersData(sender, playername); if (data.isEmpty()) { @@ -160,7 +160,7 @@ public class OverlayCommand extends CommandKamkeelBase { desc = "List all overlays on a player", usage = "" ) - public void info(ICommandSender sender, String[] args) throws CommandException { + public void info(ICommandSender sender, String args[]) throws CommandException { String playername = args[0]; List data = PlayerDataController.Instance.getPlayersData(sender, playername); diff --git a/src/main/java/kamkeel/npcs/command/QuestCategoryCommand.java b/src/main/java/kamkeel/npcs/command/QuestCategoryCommand.java index 2e8f71b3d..f33d3626b 100644 --- a/src/main/java/kamkeel/npcs/command/QuestCategoryCommand.java +++ b/src/main/java/kamkeel/npcs/command/QuestCategoryCommand.java @@ -38,7 +38,7 @@ public class QuestCategoryCommand extends CommandKamkeelBase { desc = "Find quest category id number by its name", usage = "" ) - public void id(ICommandSender sender, String[] args) throws CommandException { + public void id(ICommandSender sender, String args[]) throws CommandException { if (args.length == 0) { sendError(sender, "Please provide a name for the quest category"); return; @@ -63,7 +63,7 @@ public class QuestCategoryCommand extends CommandKamkeelBase { desc = "Finish a quest category for a player", usage = " " ) - public void finish(ICommandSender sender, String[] args) throws CommandException { + public void finish(ICommandSender sender, String args[]) throws CommandException { String playername = args[0]; int questcatid; try { @@ -101,6 +101,7 @@ public class QuestCategoryCommand extends CommandKamkeelBase { if (ConfigMain.ProfilesEnabled && playerdata.player != null && quest.profileOptions.enableOptions && quest.profileOptions.completeControl == EnumProfileSync.Shared) ProfileController.Instance.shareQuestCompletion(playerdata.player, quest.id, completeTime); + ; if (playerdata.player != null) { AchievementPacket.sendAchievement((EntityPlayerMP) playerdata.player, false, "quest.completed", quest.title); @@ -120,7 +121,7 @@ public class QuestCategoryCommand extends CommandKamkeelBase { desc = "Stop a quest category for a players active quests", usage = " " ) - public void stop(ICommandSender sender, String[] args) throws CommandException { + public void stop(ICommandSender sender, String args[]) throws CommandException { String playername = args[0]; int questcatid; try { @@ -162,7 +163,7 @@ public class QuestCategoryCommand extends CommandKamkeelBase { desc = "Start a quest category for a player", usage = " " ) - public void start(ICommandSender sender, String[] args) throws CommandException { + public void start(ICommandSender sender, String args[]) throws CommandException { String playername = args[0]; int questcatid; try { @@ -211,7 +212,7 @@ public class QuestCategoryCommand extends CommandKamkeelBase { desc = "Remove a quest cat from active/finished", usage = " " ) - public void remove(ICommandSender sender, String[] args) throws CommandException { + public void remove(ICommandSender sender, String args[]) throws CommandException { String playername = args[0]; int questcatid; try { diff --git a/src/main/java/kamkeel/npcs/command/QuestCommand.java b/src/main/java/kamkeel/npcs/command/QuestCommand.java index 3cb4c456e..0a6cb5edf 100644 --- a/src/main/java/kamkeel/npcs/command/QuestCommand.java +++ b/src/main/java/kamkeel/npcs/command/QuestCommand.java @@ -83,7 +83,7 @@ public class QuestCommand extends CommandKamkeelBase { desc = "Finish a quest", usage = " " ) - public void finish(ICommandSender sender, String[] args) throws CommandException { + public void finish(ICommandSender sender, String args[]) throws CommandException { String playername = args[0]; int questid; try { @@ -214,7 +214,7 @@ public class QuestCommand extends CommandKamkeelBase { return; } - PlayerData data = PlayerDataController.Instance.getPlayerData(player); + PlayerData data = PlayerData.get(player); if (data == null) { sendError(sender, "No PlayerData found for:" + player); return; @@ -286,7 +286,7 @@ public class QuestCommand extends CommandKamkeelBase { desc = "Find quest id number by its name", usage = "" ) - public void id(ICommandSender sender, String[] args) throws CommandException { + public void id(ICommandSender sender, String args[]) throws CommandException { if (args.length == 0) { sendError(sender, "Please provide a name for the quest"); return; @@ -310,7 +310,7 @@ public class QuestCommand extends CommandKamkeelBase { desc = "Find prerequisite quests for an id", usage = "" ) - public void prereq(ICommandSender sender, String[] args) throws CommandException { + public void prereq(ICommandSender sender, String args[]) throws CommandException { if (args.length == 0) { sendError(sender, "Please provide an id for the quest"); return; @@ -350,7 +350,7 @@ public class QuestCommand extends CommandKamkeelBase { desc = "Quick info on a quest", usage = "" ) - public void info(ICommandSender sender, String[] args) throws CommandException { + public void info(ICommandSender sender, String args[]) throws CommandException { if (args.length == 0) { sendError(sender, "Please provide an id for the quest"); return; @@ -389,7 +389,7 @@ public class QuestCommand extends CommandKamkeelBase { desc = "reload quests from disk", permission = 4 ) - public void reload(ICommandSender sender, String[] args) { + public void reload(ICommandSender sender, String args[]) { new QuestController().load(); SyncController.syncAllQuests(); sendResult(sender, "Quests Reloaded"); diff --git a/src/main/java/kamkeel/npcs/command/ScriptCommand.java b/src/main/java/kamkeel/npcs/command/ScriptCommand.java index 2e96149c9..41415cb81 100644 --- a/src/main/java/kamkeel/npcs/command/ScriptCommand.java +++ b/src/main/java/kamkeel/npcs/command/ScriptCommand.java @@ -10,7 +10,7 @@ import static kamkeel.npcs.util.ColorUtil.sendResult; public class ScriptCommand extends CommandKamkeelBase { @SubCommand(desc = "Reload scripts data and folders.") - public Boolean reload(ICommandSender sender, String[] args) { + public Boolean reload(ICommandSender sender, String args[]) { ScriptController.Instance.loadCategories(); if (ScriptController.Instance.loadPlayerScripts()) diff --git a/src/main/java/kamkeel/npcs/controllers/AttributeController.java b/src/main/java/kamkeel/npcs/controllers/AttributeController.java index 6eb28b513..3acb92cf5 100644 --- a/src/main/java/kamkeel/npcs/controllers/AttributeController.java +++ b/src/main/java/kamkeel/npcs/controllers/AttributeController.java @@ -5,6 +5,10 @@ import kamkeel.npcs.controllers.data.attribute.AttributeDefinition; import kamkeel.npcs.controllers.data.attribute.AttributeValueType; import kamkeel.npcs.controllers.data.attribute.tracker.PlayerAttributeTracker; import net.minecraft.entity.player.EntityPlayer; +import noppes.npcs.api.entity.IPlayer; +import noppes.npcs.api.handler.IAttributeHandler; +import noppes.npcs.api.handler.data.IAttributeDefinition; +import noppes.npcs.api.handler.data.IPlayerAttributes; import java.util.Collection; import java.util.HashMap; @@ -15,9 +19,9 @@ import java.util.UUID; * AttributeController is the central registry for attribute definitions. * It ensures that keys are unique. */ -public class AttributeController { +public class AttributeController implements IAttributeHandler { - public AttributeController Instance; + public static AttributeController Instance; public CustomAttributes attributes; // Tracking Player Attributes @@ -25,7 +29,7 @@ public class AttributeController { private static final Map definitions = new HashMap<>(); public AttributeController() { - this.Instance = this; + Instance = this; definitions.clear(); trackers.clear(); attributes = new CustomAttributes(); @@ -75,4 +79,20 @@ public class AttributeController { tracker.updateIfChanged(player); } } + + public IPlayerAttributes getPlayerAttributes(IPlayer player) { + if(player == null || player.getMCEntity() == null) + return null; + + EntityPlayer entityPlayer = (EntityPlayer) player.getMCEntity(); + return trackers.computeIfAbsent(entityPlayer.getUniqueID(), id -> new PlayerAttributeTracker(id)); + } + + public IAttributeDefinition getAttributeDefinition(String key) { + return definitions.get(key); + } + + public IAttributeDefinition[] getAllAttributesArray() { + return definitions.values().toArray(new AttributeDefinition[definitions.size()]); + } } diff --git a/src/main/java/kamkeel/npcs/controllers/ProfileController.java b/src/main/java/kamkeel/npcs/controllers/ProfileController.java index d3af2a7f6..7a3a7d8e4 100644 --- a/src/main/java/kamkeel/npcs/controllers/ProfileController.java +++ b/src/main/java/kamkeel/npcs/controllers/ProfileController.java @@ -221,8 +221,8 @@ public class ProfileController implements IProfileHandler { try (FileInputStream fis = new FileInputStream(backupFile)) { NBTTagCompound compound = CompressedStreamTools.readCompressed(fis); File saveDir = getProfileDir(); - File mainFile = new File(saveDir, uuid + ".dat"); - File fileNew = new File(saveDir, uuid + "_new"); + File mainFile = new File(saveDir, uuid.toString() + ".dat"); + File fileNew = new File(saveDir, uuid.toString() + "_new"); CompressedStreamTools.writeCompressed(compound, new FileOutputStream(fileNew)); if (mainFile.exists()) { mainFile.delete(); @@ -364,8 +364,8 @@ public class ProfileController implements IProfileHandler { return ProfileOperation.error(MSG_SLOT_NOT_EXIST); } - PlayerDataScript handler = ScriptController.Instance.playerScripts; if (profile.player != null) { + PlayerDataScript handler = ScriptController.Instance.getPlayerScripts(profile.player); IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(profile.player); if (EventHooks.onProfileRemove(handler, scriptPlayer, profile, slotId, false)) return ProfileOperation.error(MSG_CANCELLED); @@ -374,6 +374,7 @@ public class ProfileController implements IProfileHandler { profile.getSlots().remove(slotId); if (profile.player != null) { + PlayerDataScript handler = ScriptController.Instance.getPlayerScripts(profile.player); IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(profile.player); EventHooks.onProfileRemove(handler, scriptPlayer, profile, slotId, true); } @@ -402,8 +403,8 @@ public class ProfileController implements IProfileHandler { } } - PlayerDataScript handler = ScriptController.Instance.playerScripts; if (profile.player != null) { + PlayerDataScript handler = ScriptController.Instance.getPlayerScripts(profile.player); IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(profile.player); if (EventHooks.onProfileCreate(handler, scriptPlayer, profile, newSlotId, false)) return ProfileOperation.error(MSG_CANCELLED); @@ -413,6 +414,7 @@ public class ProfileController implements IProfileHandler { newSlot.setLastLoaded(System.currentTimeMillis()); profile.getSlots().put(newSlotId, newSlot); if (profile.player != null) { + PlayerDataScript handler = ScriptController.Instance.getPlayerScripts(profile.player); verifySlotQuests(profile.player); save(profile.player, profile); @@ -434,7 +436,7 @@ public class ProfileController implements IProfileHandler { } if (profile.player != null) { if (ConfigMain.RegionProfileSwitching) { - boolean allowed = hasPermission(profile.player, PROFILE_REGION_BYPASS); + boolean allowed = hasCustomPermission(profile.player, PROFILE_REGION_BYPASS.name); if (!allowed) { int playerDim = profile.player.dimension; int playerX = (int) profile.player.posX; @@ -474,7 +476,7 @@ public class ProfileController implements IProfileHandler { int prevSlot = profile.getCurrentSlotId(); - PlayerDataScript handler = ScriptController.Instance.playerScripts; + PlayerDataScript handler = ScriptController.Instance.getPlayerScripts(profile.player); IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(profile.player); if (EventHooks.onProfileChange(handler, scriptPlayer, profile, newSlotId, prevSlot, false)) return ProfileOperation.error(MSG_CANCELLED); @@ -676,8 +678,8 @@ public class ProfileController implements IProfileHandler { highestAllowed = i; } } - if (highestAllowed == 0) { - highestAllowed = 1; + if (highestAllowed == 0 || highestAllowed < ConfigMain.DefaultProfileSlots) { + highestAllowed = ConfigMain.DefaultProfileSlots; } return currentSlots < highestAllowed; } diff --git a/src/main/java/kamkeel/npcs/controllers/SyncController.java b/src/main/java/kamkeel/npcs/controllers/SyncController.java index 31014d8a1..03a923485 100644 --- a/src/main/java/kamkeel/npcs/controllers/SyncController.java +++ b/src/main/java/kamkeel/npcs/controllers/SyncController.java @@ -167,6 +167,7 @@ public class SyncController { NBTTagList categoryList = new NBTTagList(); for (QuestCategory category : QuestController.Instance.categories.values()) { NBTTagCompound questCompound = new NBTTagCompound(); + ; NBTTagList questList = new NBTTagList(); for (int questID : category.quests.keySet()) { Quest quest = category.quests.get(questID); diff --git a/src/main/java/kamkeel/npcs/controllers/data/attribute/AttributeDefinition.java b/src/main/java/kamkeel/npcs/controllers/data/attribute/AttributeDefinition.java index b3fd43d9e..5a3c94f74 100644 --- a/src/main/java/kamkeel/npcs/controllers/data/attribute/AttributeDefinition.java +++ b/src/main/java/kamkeel/npcs/controllers/data/attribute/AttributeDefinition.java @@ -1,6 +1,8 @@ package kamkeel.npcs.controllers.data.attribute; -public class AttributeDefinition { +import noppes.npcs.api.handler.data.IAttributeDefinition; + +public class AttributeDefinition implements IAttributeDefinition { private final String key; private String translationKey;// e.g., "main_attack_flat" private final String displayName; // Human‑readable name diff --git a/src/main/java/kamkeel/npcs/controllers/data/attribute/ICustomAttribute.java b/src/main/java/kamkeel/npcs/controllers/data/attribute/ICustomAttribute.java deleted file mode 100644 index 46b9ec2bc..000000000 --- a/src/main/java/kamkeel/npcs/controllers/data/attribute/ICustomAttribute.java +++ /dev/null @@ -1,12 +0,0 @@ -package kamkeel.npcs.controllers.data.attribute; - -/** - * IAttributeInstance represents an instance of an attribute (with a base value and applied modifiers). - */ -public interface ICustomAttribute { - AttributeDefinition getAttribute(); - - float getValue(); - - void setValue(float value); -} diff --git a/src/main/java/kamkeel/npcs/controllers/data/attribute/PlayerAttribute.java b/src/main/java/kamkeel/npcs/controllers/data/attribute/PlayerAttribute.java index dcd918225..4361a8fc9 100644 --- a/src/main/java/kamkeel/npcs/controllers/data/attribute/PlayerAttribute.java +++ b/src/main/java/kamkeel/npcs/controllers/data/attribute/PlayerAttribute.java @@ -1,13 +1,15 @@ package kamkeel.npcs.controllers.data.attribute; +import noppes.npcs.api.handler.data.ICustomAttribute; + public class PlayerAttribute implements ICustomAttribute { private final AttributeDefinition attribute; - private float baseValue; + public float value; - public PlayerAttribute(AttributeDefinition attribute, float baseValue) { + public PlayerAttribute(AttributeDefinition attribute, float value) { this.attribute = attribute; - this.baseValue = baseValue; + this.value = value; } @Override @@ -17,11 +19,6 @@ public class PlayerAttribute implements ICustomAttribute { @Override public float getValue() { - return baseValue; - } - - @Override - public void setValue(float value) { - this.baseValue = value; + return value; } } diff --git a/src/main/java/kamkeel/npcs/controllers/data/attribute/PlayerAttributeMap.java b/src/main/java/kamkeel/npcs/controllers/data/attribute/PlayerAttributeMap.java index b489cf192..8eec9414b 100644 --- a/src/main/java/kamkeel/npcs/controllers/data/attribute/PlayerAttributeMap.java +++ b/src/main/java/kamkeel/npcs/controllers/data/attribute/PlayerAttributeMap.java @@ -1,6 +1,5 @@ package kamkeel.npcs.controllers.data.attribute; -import java.util.Collection; import java.util.HashMap; import java.util.Map; @@ -8,22 +7,18 @@ import java.util.Map; * CustomAttributeMap holds a set of attribute instances for an entity (or item). */ public class PlayerAttributeMap { - private final Map map = new HashMap<>(); + public final Map map = new HashMap<>(); - public ICustomAttribute registerAttribute(AttributeDefinition attribute, float baseValue) { + public PlayerAttribute registerAttribute(AttributeDefinition attribute, float baseValue) { if (map.containsKey(attribute)) { throw new IllegalArgumentException("Attribute already registered: " + attribute.getKey()); } - ICustomAttribute instance = new PlayerAttribute(attribute, baseValue); + PlayerAttribute instance = new PlayerAttribute(attribute, baseValue); map.put(attribute, instance); return instance; } - public ICustomAttribute getAttributeInstance(AttributeDefinition attribute) { + public PlayerAttribute getAttributeInstance(AttributeDefinition attribute) { return map.get(attribute); } - - public Collection getAllAttributes() { - return map.values(); - } } diff --git a/src/main/java/kamkeel/npcs/controllers/data/attribute/requirement/IRequirementChecker.java b/src/main/java/kamkeel/npcs/controllers/data/attribute/requirement/IRequirementChecker.java index 925b5b638..e27c345da 100644 --- a/src/main/java/kamkeel/npcs/controllers/data/attribute/requirement/IRequirementChecker.java +++ b/src/main/java/kamkeel/npcs/controllers/data/attribute/requirement/IRequirementChecker.java @@ -11,6 +11,8 @@ public interface IRequirementChecker { String getTooltipValue(NBTTagCompound nbt); + Object getValue(NBTTagCompound nbt); + void apply(NBTTagCompound nbt, Object value); /** diff --git a/src/main/java/kamkeel/npcs/controllers/data/attribute/requirement/types/ProfileSlotRequirement.java b/src/main/java/kamkeel/npcs/controllers/data/attribute/requirement/types/ProfileSlotRequirement.java new file mode 100644 index 000000000..0621ad096 --- /dev/null +++ b/src/main/java/kamkeel/npcs/controllers/data/attribute/requirement/types/ProfileSlotRequirement.java @@ -0,0 +1,52 @@ +package kamkeel.npcs.controllers.data.attribute.requirement.types; + +import kamkeel.npcs.controllers.data.attribute.requirement.IRequirementChecker; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; +import noppes.npcs.controllers.data.PlayerData; + +public class ProfileSlotRequirement implements IRequirementChecker { + + @Override + public String getKey() { + return "cnpc_profile_slot"; + } + + @Override + public String getTranslation() { + return "profile.slot"; + } + + @Override + public String getTooltipValue(NBTTagCompound nbt) { + if (nbt.hasKey(getKey())) { + int profileSlot = nbt.getInteger(getKey()); + return String.valueOf(profileSlot); + } + return "null"; + } + + @Override + public void apply(NBTTagCompound nbt, Object value) { + if (value instanceof Integer) { + nbt.setInteger(getKey(), (Integer) value); + } + } + + @Override + public Object getValue(NBTTagCompound nbt) { + if (nbt.hasKey(getKey())) { + return nbt.getInteger(getKey()); + } + return null; + } + + @Override + public boolean check(EntityPlayer player, NBTTagCompound nbt) { + if (nbt.hasKey(getKey())) { + int profileSlot = nbt.getInteger(getKey()); + return PlayerData.get(player).profileSlot == profileSlot; + } + return true; + } +} diff --git a/src/main/java/kamkeel/npcs/controllers/data/attribute/requirement/types/QuestActiveRequirement.java b/src/main/java/kamkeel/npcs/controllers/data/attribute/requirement/types/QuestActiveRequirement.java index af286a56a..679d28add 100644 --- a/src/main/java/kamkeel/npcs/controllers/data/attribute/requirement/types/QuestActiveRequirement.java +++ b/src/main/java/kamkeel/npcs/controllers/data/attribute/requirement/types/QuestActiveRequirement.java @@ -29,6 +29,14 @@ public class QuestActiveRequirement implements IRequirementChecker { return "null"; } + @Override + public Object getValue(NBTTagCompound nbt) { + if (nbt.hasKey(getKey())) { + return nbt.getInteger(getKey()); + } + return null; + } + @Override public void apply(NBTTagCompound nbt, Object value) { if (value instanceof Integer) { diff --git a/src/main/java/kamkeel/npcs/controllers/data/attribute/requirement/types/QuestCompletedRequirement.java b/src/main/java/kamkeel/npcs/controllers/data/attribute/requirement/types/QuestCompletedRequirement.java index e2c887659..6befd0311 100644 --- a/src/main/java/kamkeel/npcs/controllers/data/attribute/requirement/types/QuestCompletedRequirement.java +++ b/src/main/java/kamkeel/npcs/controllers/data/attribute/requirement/types/QuestCompletedRequirement.java @@ -36,6 +36,14 @@ public class QuestCompletedRequirement implements IRequirementChecker { } } + @Override + public Object getValue(NBTTagCompound nbt) { + if (nbt.hasKey(getKey())) { + return nbt.getInteger(getKey()); + } + return null; + } + @Override public boolean check(EntityPlayer player, NBTTagCompound nbt) { if (nbt.hasKey(getKey())) { diff --git a/src/main/java/kamkeel/npcs/controllers/data/attribute/requirement/types/SoulbindRequirement.java b/src/main/java/kamkeel/npcs/controllers/data/attribute/requirement/types/SoulbindRequirement.java new file mode 100644 index 000000000..b74c69db7 --- /dev/null +++ b/src/main/java/kamkeel/npcs/controllers/data/attribute/requirement/types/SoulbindRequirement.java @@ -0,0 +1,106 @@ +package kamkeel.npcs.controllers.data.attribute.requirement.types; + +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import kamkeel.npcs.controllers.data.attribute.requirement.IRequirementChecker; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; + +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.HttpURLConnection; +import java.net.URL; +import java.util.HashMap; +import java.util.UUID; + +public class SoulbindRequirement implements IRequirementChecker { + + public static HashMap uuidToUsername = new HashMap<>(); + + @Override + public String getKey() { + return "cnpc_soulbind"; + } + + @Override + public String getTranslation() { + return "requirement.soulbind"; + } + + @Override + public String getTooltipValue(NBTTagCompound nbt) { + if (nbt.hasKey(getKey())) { + String uuid = nbt.getString(getKey()); + if (uuid != null && !uuid.isEmpty()) { + return getUsernameFromUUID(uuid); + } + } + return "null"; + } + + private String getUsernameFromUUID(String uuid) { + if(uuidToUsername.containsKey(uuid)){ + if(!uuidToUsername.get(uuid).equals("null")){ + return uuidToUsername.get(uuid); + } + } + try { + String strippedUUID = uuid.replace("-", ""); + String urlStr = "https://sessionserver.mojang.com/session/minecraft/profile/" + strippedUUID; + HttpURLConnection connection = (HttpURLConnection) new URL(urlStr).openConnection(); + connection.setConnectTimeout(5000); + connection.setReadTimeout(5000); + connection.setRequestMethod("GET"); + connection.connect(); + + InputStream stream = connection.getInputStream(); + InputStreamReader reader = new InputStreamReader(stream, "UTF-8"); + + JsonElement element = new JsonParser().parse(reader); + JsonObject jsonObj = element.getAsJsonObject(); + + if (jsonObj.has("name")) { + String name = jsonObj.get("name").getAsString(); + uuidToUsername.put(uuid, name); + return name; + } + } catch (Exception e) { + e.printStackTrace(); + } + return "null"; + } + + + @Override + public Object getValue(NBTTagCompound nbt) { + if (nbt.hasKey(getKey())) { + return nbt.getString(getKey()); + } + return null; + } + + @Override + public void apply(NBTTagCompound nbt, Object value) { + if (value instanceof String) { + nbt.setString(getKey(), (String) value); + } + } + + @Override + public boolean check(EntityPlayer player, NBTTagCompound nbt) { + if (nbt.hasKey(getKey())) { + String uuidString = nbt.getString(getKey()); + if(uuidString != null && !uuidString.isEmpty()){ + UUID convert = null; + try { + convert = UUID.fromString(uuidString); + } catch (Exception ignored){} + if(convert != null) + return player.getUniqueID().equals(convert); + } + return false; + } + return true; + } +} diff --git a/src/main/java/kamkeel/npcs/controllers/data/attribute/tracker/AttributeRecalcEvent.java b/src/main/java/kamkeel/npcs/controllers/data/attribute/tracker/AttributeRecalcEvent.java index d82b266a2..ac8e48da6 100644 --- a/src/main/java/kamkeel/npcs/controllers/data/attribute/tracker/AttributeRecalcEvent.java +++ b/src/main/java/kamkeel/npcs/controllers/data/attribute/tracker/AttributeRecalcEvent.java @@ -5,24 +5,32 @@ import net.minecraft.entity.player.EntityPlayer; import java.util.ArrayList; import java.util.List; -public class AttributeRecalcEvent { - private static final List listeners = new ArrayList<>(); - - /** - * Allows other mods to register a listener that is called after attribute recalculation. - */ - public static void registerListener(IAttributeRecalcListener listener) { - if (listener != null && !listeners.contains(listener)) { - listeners.add(listener); - } +public final class AttributeRecalcEvent { + @FunctionalInterface + public interface PreListener { + void onPre(EntityPlayer player, PlayerAttributeTracker tracker); } - /** - * Posts an event to all registered listeners. - */ + private static final List preListeners = new ArrayList<>(); + private static final List postListeners = new ArrayList<>(); + + public static void pre(EntityPlayer player, PlayerAttributeTracker tracker) { + for (PreListener l : preListeners) l.onPre(player, tracker); + } + + @FunctionalInterface + public interface Listener { + void onPost(EntityPlayer player, PlayerAttributeTracker tracker); + } + + public static void registerListener(Listener l) { + postListeners.add(l); + } public static void post(EntityPlayer player, PlayerAttributeTracker tracker) { - for (IAttributeRecalcListener listener : listeners) { - listener.onAttributesRecalculated(player, tracker); - } + for (Listener l : postListeners) l.onPost(player, tracker); + } + + public static void registerPreListener(PreListener l) { + preListeners.add(l); } } diff --git a/src/main/java/kamkeel/npcs/controllers/data/attribute/tracker/PlayerAttributeTracker.java b/src/main/java/kamkeel/npcs/controllers/data/attribute/tracker/PlayerAttributeTracker.java index 91244fb7f..279cf99c8 100644 --- a/src/main/java/kamkeel/npcs/controllers/data/attribute/tracker/PlayerAttributeTracker.java +++ b/src/main/java/kamkeel/npcs/controllers/data/attribute/tracker/PlayerAttributeTracker.java @@ -3,7 +3,7 @@ package kamkeel.npcs.controllers.data.attribute.tracker; import kamkeel.npcs.CustomAttributes; import kamkeel.npcs.controllers.AttributeController; import kamkeel.npcs.controllers.data.attribute.AttributeDefinition; -import kamkeel.npcs.controllers.data.attribute.ICustomAttribute; +import kamkeel.npcs.controllers.data.attribute.PlayerAttribute; import kamkeel.npcs.controllers.data.attribute.PlayerAttributeMap; import kamkeel.npcs.controllers.data.attribute.requirement.RequirementCheckerRegistry; import kamkeel.npcs.util.AttributeAttackUtil; @@ -14,21 +14,30 @@ import net.minecraft.entity.ai.attributes.IAttributeInstance; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import noppes.npcs.api.entity.IPlayer; +import noppes.npcs.api.handler.data.ICustomAttribute; +import noppes.npcs.api.handler.data.IPlayerAttributes; import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; import java.util.UUID; -public class PlayerAttributeTracker { +public class PlayerAttributeTracker implements IPlayerAttributes { public static UUID healthUUID = UUID.fromString("48a0ad75-2cf8-4838-ad2f-9a0aadc57dfe"); - + public static UUID healthBoostUUID = UUID.fromString("93cfba41-294a-4e6b-a98b-bee76a9f813b"); + public static UUID movementSpeedUUID = UUID.fromString("e7e0dd10-8ed5-42fb-8167-e71f8de4ea0c"); + public static UUID knockbackResUUID = UUID.fromString("b2f261e8-34f0-4140-9828-b56c1f6e0ff2"); private final UUID playerId; - private PlayerAttributeMap playerAttributes = new PlayerAttributeMap(); + public PlayerAttributeMap playerAttributes = new PlayerAttributeMap(); public float extraHealth = 0; + public float extraHealthBoost = 0; + public float movementSpeed = 0; + public float knockbackRes = 0; + public float gearOutput = 0.0f; public final Map magicDamage = new HashMap<>(); @@ -44,10 +53,6 @@ public class PlayerAttributeTracker { recalcAttributes(null); } - public PlayerAttributeMap getPlayerAttributes() { - return playerAttributes; - } - public void recalcAttributes(EntityPlayer player) { // Reset aggregated attributes and magic maps. playerAttributes = new PlayerAttributeMap(); @@ -56,6 +61,9 @@ public class PlayerAttributeTracker { magicDefense.clear(); magicResistance.clear(); if (player != null) { + // Pre Event Listener + AttributeRecalcEvent.pre(player, this); + // Update equipment tracker. PlayerEquipmentTracker currentEquip = new PlayerEquipmentTracker(); currentEquip.updateFrom(player); @@ -77,11 +85,11 @@ public class PlayerAttributeTracker { float value = entry.getValue(); AttributeDefinition def = AttributeController.getAttribute(key); if (def != null) { - ICustomAttribute inst = playerAttributes.getAttributeInstance(def); + PlayerAttribute inst = playerAttributes.getAttributeInstance(def); if (inst == null) { inst = playerAttributes.registerAttribute(def, 0.0f); } - inst.setValue(inst.getValue() + value); + inst.value = (inst.getValue() + value); } } // Process Magic @@ -117,9 +125,16 @@ public class PlayerAttributeTracker { } equipmentTracker = currentEquip; gearOutput = AttributeAttackUtil.calculateGearOutput(this); - extraHealth = getAttributeValue(CustomAttributes.HEALTH); + extraHealth = getAttributeValue(CustomAttributes.HEALTH); + extraHealthBoost = getAttributeValue(CustomAttributes.HEALTH_BOOST); + movementSpeed = getAttributeValue(CustomAttributes.MOVEMENT_SPEED); + knockbackRes = getAttributeValue(CustomAttributes.KNOCKBACK_RES); + + // Update vanilla attributes with our aggregated values. updatePlayerMaxHealth(player); + updatePlayerMovementSpeed(player); + updatePlayerKnockbackRes(player); // Post Recalculation Event to Listeners AttributeRecalcEvent.post(player, this); @@ -134,32 +149,70 @@ public class PlayerAttributeTracker { */ public void updatePlayerMaxHealth(EntityPlayer player) { float bonusHealth = extraHealth; + float healthBoostPercent = extraHealthBoost / 100; IAttributeInstance maxHealthAttr = player.getAttributeMap().getAttributeInstance(SharedMonsterAttributes.maxHealth); try { - AttributeModifier old = maxHealthAttr.getModifier(healthUUID); - if (old != null) { - maxHealthAttr.removeModifier(old); + AttributeModifier oldFlat = maxHealthAttr.getModifier(healthUUID); + if (oldFlat != null) { + maxHealthAttr.removeModifier(oldFlat); } - } catch (Exception ignored) { - } + AttributeModifier oldBoost = maxHealthAttr.getModifier(healthBoostUUID); + if (oldBoost != null) { + maxHealthAttr.removeModifier(oldBoost); + } + } catch (Exception ignored) { } + // Apply the flat bonus (operation 0) if (bonusHealth != 0) { maxHealthAttr.applyModifier(new AttributeModifier(healthUUID, "RPGCoreHealthBonus", bonusHealth, 0)); } - // Ensure the player's current health does not exceed the new maximum. + // Apply the percent boost (operation 1 multiplies the base health, here assumed to be 20) + if (healthBoostPercent != 0) { + maxHealthAttr.applyModifier(new AttributeModifier(healthBoostUUID, "RPGCoreHealthBoost", healthBoostPercent, 1)); + } + // Ensure current health is within the new maximum. float currentHealth = player.getHealth(); if (currentHealth > maxHealthAttr.getAttributeValue()) { player.setHealth((float) maxHealthAttr.getAttributeValue()); } } + public void updatePlayerMovementSpeed(EntityPlayer player) { + float extraSpeed = movementSpeed / 100; + IAttributeInstance speedAttr = player.getAttributeMap().getAttributeInstance(SharedMonsterAttributes.movementSpeed); + try { + AttributeModifier old = speedAttr.getModifier(movementSpeedUUID); + if (old != null) { + speedAttr.removeModifier(old); + } + } catch (Exception ignored) { } + if (extraSpeed != 0) { + speedAttr.applyModifier(new AttributeModifier(movementSpeedUUID, "RPGCoreMovementSpeed", extraSpeed, 1)); + } + } + + public void updatePlayerKnockbackRes(EntityPlayer player) { + float extraRes = knockbackRes / 100; + IAttributeInstance knockResAttr = player.getAttributeMap().getAttributeInstance(SharedMonsterAttributes.knockbackResistance); + try { + AttributeModifier old = knockResAttr.getModifier(knockbackResUUID); + if (old != null) { + knockResAttr.removeModifier(old); + } + } catch (Exception ignored) { } + if (extraRes != 0) { + knockResAttr.applyModifier(new AttributeModifier(knockbackResUUID, "RPGCoreKnockbackRes", extraRes, 1)); + } + } + /** * Checks if the player's equipment has changed and recalculates attributes if needed. */ public void updateIfChanged(EntityPlayer player) { - PlayerEquipmentTracker currentEquip = new PlayerEquipmentTracker(); - currentEquip.updateFrom(player); - if (!equipmentTracker.equals(player)) { + PlayerEquipmentTracker current = new PlayerEquipmentTracker(); + current.updateFrom(player); + if (!equipmentTracker.equals(current)) { recalcAttributes(player); + equipmentTracker = current; } } @@ -167,4 +220,43 @@ public class PlayerAttributeTracker { ICustomAttribute inst = playerAttributes.getAttributeInstance(def); return inst != null ? inst.getValue() : 0.0f; } + + public void recalculate(IPlayer player) { + if(player == null || player.getMCEntity() == null) + return; + + recalcAttributes((EntityPlayer) player.getMCEntity()); + } + + public ICustomAttribute[] getAttributes() { + return playerAttributes.map.values().toArray(new ICustomAttribute[playerAttributes.map.size()]); + } + + public float getAttributeValue(String key) { + for (ICustomAttribute inst : getAttributes()) { + if (inst.getAttribute().getKey().equalsIgnoreCase(key)) { + return inst.getValue(); + } + } + return 0.0f; + } + + + public boolean hasAttribute(String key) { + for (ICustomAttribute inst : getAttributes()) { + if (inst.getAttribute().getKey().equalsIgnoreCase(key)) { + return true; + } + } + return false; + } + + public ICustomAttribute getAttribute(String key) { + for (ICustomAttribute inst : getAttributes()) { + if (inst.getAttribute().getKey().equalsIgnoreCase(key)) { + return inst; + } + } + return null; + } } diff --git a/src/main/java/kamkeel/npcs/controllers/data/attribute/tracker/PlayerEquipmentTracker.java b/src/main/java/kamkeel/npcs/controllers/data/attribute/tracker/PlayerEquipmentTracker.java index de0194919..961fd1563 100644 --- a/src/main/java/kamkeel/npcs/controllers/data/attribute/tracker/PlayerEquipmentTracker.java +++ b/src/main/java/kamkeel/npcs/controllers/data/attribute/tracker/PlayerEquipmentTracker.java @@ -5,6 +5,10 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import java.util.Objects; + +import static kamkeel.npcs.util.AttributeItemUtil.TAG_RPGCORE; + public class PlayerEquipmentTracker { public ItemStack heldItem; public ItemStack helmet; @@ -25,18 +29,35 @@ public class PlayerEquipmentTracker { helmet = copyIfNotNull(armor[3]); } - /** - * Compares the stored equipment with the player's current equipment. - * Ignores changes like durability by comparing the item and the CNPCAttributes NBT only. - */ - public boolean equals(EntityPlayer player) { - if (player == null) return false; - if (!areItemStacksEquivalent(heldItem, player.getHeldItem())) return false; - ItemStack[] armor = player.inventory.armorInventory; - if (!areItemStacksEquivalent(boots, armor[0])) return false; - if (!areItemStacksEquivalent(leggings, armor[1])) return false; - if (!areItemStacksEquivalent(chestplate, armor[2])) return false; - return areItemStacksEquivalent(helmet, armor[3]); + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof PlayerEquipmentTracker)) return false; + PlayerEquipmentTracker other = (PlayerEquipmentTracker)o; + return areItemStacksEquivalent(heldItem, other.heldItem) + && areItemStacksEquivalent(boots, other.boots) + && areItemStacksEquivalent(leggings, other.leggings) + && areItemStacksEquivalent(chestplate, other.chestplate) + && areItemStacksEquivalent(helmet, other.helmet); + } + + @Override + public int hashCode() { + return Objects.hash( + itemHash(heldItem), + itemHash(boots), + itemHash(leggings), + itemHash(chestplate), + itemHash(helmet) + ); + } + + private int itemHash(ItemStack s) { + if (s == null) return 0; + NBTTagCompound root = s.stackTagCompound; + if (root == null || !root.hasKey(TAG_RPGCORE)) return 0; + NBTTagCompound tag = root.getCompoundTag(TAG_RPGCORE); + return Objects.hash(s.getItem(), tag); } /** @@ -54,12 +75,16 @@ public class PlayerEquipmentTracker { if (a == b) return true; if (a == null || b == null) return false; if (a.getItem() != b.getItem()) return false; - NBTTagCompound tagA = a.stackTagCompound; - NBTTagCompound tagB = b.stackTagCompound; - String attrA = (tagA != null && tagA.hasKey(AttributeItemUtil.TAG_RPGCORE)) - ? tagA.getCompoundTag(AttributeItemUtil.TAG_RPGCORE).toString() : ""; - String attrB = (tagB != null && tagB.hasKey(AttributeItemUtil.TAG_RPGCORE)) - ? tagB.getCompoundTag(AttributeItemUtil.TAG_RPGCORE).toString() : ""; - return attrA.equals(attrB); + + NBTTagCompound tagA = a.stackTagCompound != null + ? a.stackTagCompound.getCompoundTag(TAG_RPGCORE) + : null; + NBTTagCompound tagB = b.stackTagCompound != null + ? b.stackTagCompound.getCompoundTag(TAG_RPGCORE) + : null; + if (tagA == null ^ tagB == null) return false; + if (tagA != null && !tagA.equals(tagB)) return false; + + return true; } } diff --git a/src/main/java/kamkeel/npcs/network/PacketHandler.java b/src/main/java/kamkeel/npcs/network/PacketHandler.java index c0b9a9564..d1a5df29b 100644 --- a/src/main/java/kamkeel/npcs/network/PacketHandler.java +++ b/src/main/java/kamkeel/npcs/network/PacketHandler.java @@ -20,6 +20,9 @@ import kamkeel.npcs.network.packets.player.customgui.CustomGuiButtonPacket; import kamkeel.npcs.network.packets.player.customgui.CustomGuiClosePacket; import kamkeel.npcs.network.packets.player.customgui.CustomGuiUnfocusedPacket; import kamkeel.npcs.network.packets.player.customgui.CustomScrollClickPacket; +import kamkeel.npcs.network.packets.player.item.GuiMagicBookPacket; +import kamkeel.npcs.network.packets.player.item.GuiPaintbrushPacket; +import kamkeel.npcs.network.packets.player.item.MagicCyclesPacket; import kamkeel.npcs.network.packets.player.profile.*; import kamkeel.npcs.network.packets.request.*; import kamkeel.npcs.network.packets.request.animation.AnimationGetPacket; @@ -429,6 +432,11 @@ public class PacketHandler { PLAYER_PACKET.registerPacket(new CustomGuiUnfocusedPacket()); PLAYER_PACKET.registerPacket(new CustomScrollClickPacket()); + // Item Gui Packets + PLAYER_PACKET.registerPacket(new GuiPaintbrushPacket()); + PLAYER_PACKET.registerPacket(new GuiMagicBookPacket()); + PLAYER_PACKET.registerPacket(new MagicCyclesPacket()); + // Profile Packets PLAYER_PACKET.registerPacket(new ProfileCreatePacket()); PLAYER_PACKET.registerPacket(new ProfileRemovePacket()); diff --git a/src/main/java/kamkeel/npcs/network/PacketUtil.java b/src/main/java/kamkeel/npcs/network/PacketUtil.java index c9a40a434..2ca723b93 100644 --- a/src/main/java/kamkeel/npcs/network/PacketUtil.java +++ b/src/main/java/kamkeel/npcs/network/PacketUtil.java @@ -15,6 +15,7 @@ import noppes.npcs.NBTTags; import noppes.npcs.controllers.ScriptContainer; import noppes.npcs.controllers.ScriptController; import noppes.npcs.controllers.data.IScriptHandler; +import noppes.npcs.items.ItemNpcTool; import java.io.IOException; import java.util.LinkedHashSet; @@ -23,14 +24,14 @@ import java.util.Set; public class PacketUtil { - public static boolean verifyItemPacket(EnumItemPacketType type, EntityPlayer player) { + public static boolean verifyItemPacket(String name, EnumItemPacketType type, EntityPlayer player) { if (player == null) return false; ItemStack item = player.inventory.getCurrentItem(); if (item == null) { - LogWriter.error(String.format("%s attempted to utilize a %s Packet without an item, they could be a hacker", - player.getCommandSenderName(), type)); + LogWriter.error(String.format("%s attempted to utilize a %s %s Packet without an item, they could be a hacker", + player.getCommandSenderName(), type, name)); return false; } @@ -38,42 +39,42 @@ public class PacketUtil { case WAND: if (item.getItem() != CustomItems.wand) { LogWriter.error(String.format("%s attempted to utilize a %s Packet without a Wand, they could be a hacker", - player.getCommandSenderName(), type)); + player.getCommandSenderName(), type, name)); return false; } break; case MOUNTER: if (item.getItem() != CustomItems.mount) { LogWriter.error(String.format("%s attempted to utilize a %s Packet without a Mounter, they could be a hacker", - player.getCommandSenderName(), type)); + player.getCommandSenderName(), type, name)); return false; } break; case CLONER: if (item.getItem() != CustomItems.cloner) { - LogWriter.error(String.format("%s attempted to utilize a %s Packet without a Cloner, they could be a hacker", - player.getCommandSenderName(), type)); + LogWriter.error(String.format("%s attempted to utilize a %s %s Packet without a Cloner, they could be a hacker", + player.getCommandSenderName(), type, name)); return false; } break; case TELEPORTER: if (item.getItem() != CustomItems.teleporter) { - LogWriter.error(String.format("%s attempted to utilize a %s Packet without a Teleporter, they could be a hacker", - player.getCommandSenderName(), type)); + LogWriter.error(String.format("%s attempted to utilize a %s %s Packet without a Teleporter, they could be a hacker", + player.getCommandSenderName(), type, name)); return false; } break; case SCRIPTER: if (item.getItem() != CustomItems.scripter) { - LogWriter.error(String.format("%s attempted to utilize a %s Packet without a Scripter, they could be a hacker", - player.getCommandSenderName(), type)); + LogWriter.error(String.format("%s attempted to utilize a %s %s Packet without a Scripter, they could be a hacker", + player.getCommandSenderName(), type, name)); return false; } break; case PATHER: if (item.getItem() != CustomItems.moving) { - LogWriter.error(String.format("%s attempted to utilize a %s Packet without a Pather, they could be a hacker", - player.getCommandSenderName(), type)); + LogWriter.error(String.format("%s attempted to utilize a %s %s Packet without a Pather, they could be a hacker", + player.getCommandSenderName(), type, name)); return false; } break; @@ -81,22 +82,29 @@ public class PacketUtil { if (item.getItem() == Item.getItemFromBlock(CustomItems.waypoint) || item.getItem() == Item.getItemFromBlock(CustomItems.border) || item.getItem() == Item.getItemFromBlock(CustomItems.redstoneBlock)) { - LogWriter.error(String.format("%s attempted to utilize a %s Packet without a valid Block, they could be a hacker", - player.getCommandSenderName(), type)); + LogWriter.error(String.format("%s attempted to utilize a %s %s Packet without a valid Block, they could be a hacker", + player.getCommandSenderName(), type, name)); return false; } break; case BRUSH: if (item.getItem() != CustomItems.tool || item.getItemDamage() != 1) { - LogWriter.error(String.format("%s attempted to utilize a %s Packet without a Pather, they could be a hacker", - player.getCommandSenderName(), type)); + LogWriter.error(String.format("%s attempted to utilize a %s %s Packet without a Pather, they could be a hacker", + player.getCommandSenderName(), type, name)); return false; } break; case HAMMER: if (item.getItem() != CustomItems.tool || item.getItemDamage() != 0) { - LogWriter.error(String.format("%s attempted to utilize a %s Packet without a Pather, they could be a hacker", - player.getCommandSenderName(), type)); + LogWriter.error(String.format("%s attempted to utilize a %s %s Packet without a Hammer, they could be a hacker", + player.getCommandSenderName(), type, name)); + return false; + } + break; + case MAGIC_BOOK: + if (item.getItem() != CustomItems.tool || item.getItemDamage() != 2) { + LogWriter.error(String.format("%s attempted to utilize a %s %s Packet without a Magic Book, they could be a hacker", + player.getCommandSenderName(), type, name)); return false; } break; @@ -109,14 +117,14 @@ public class PacketUtil { * It returns true if any one of the provided types is valid. * If none are valid, a merged error message is logged. */ - public static boolean verifyItemPacket(EntityPlayer player, EnumItemPacketType... types) { + public static boolean verifyItemPacket(String name, EntityPlayer player, EnumItemPacketType... types) { if (player == null) return false; ItemStack item = player.inventory.getCurrentItem(); if (item == null) { - LogWriter.error(String.format("%s attempted to utilize a Packet without an item. Expected one of: %s, they could be a hacker", - player.getCommandSenderName(), getExpectedItemNames(types))); + LogWriter.error(String.format("%s attempted to utilize a %s without an item. Expected one of: %s, they could be a hacker", + player.getCommandSenderName(), name, getExpectedItemNames(types))); return false; } @@ -127,8 +135,8 @@ public class PacketUtil { } // None passed; log one merged error message listing all expected items. - LogWriter.error(String.format("%s attempted to utilize a Packet without a valid item. Expected one of: %s, they could be a hacker", - player.getCommandSenderName(), getExpectedItemNames(types))); + LogWriter.error(String.format("%s attempted to utilize a %s without a valid item. Expected one of: %s, they could be a hacker", + player.getCommandSenderName(), name, getExpectedItemNames(types))); return false; } @@ -155,9 +163,11 @@ public class PacketUtil { || item.getItem() == Item.getItemFromBlock(CustomItems.border) || item.getItem() == Item.getItemFromBlock(CustomItems.redstoneBlock)); case BRUSH: - return item.getItem() == CustomItems.tool && item.getItemDamage() == 1; + return item.getItem() instanceof ItemNpcTool && item.getItemDamage() == 1; case HAMMER: - return item.getItem() == CustomItems.tool && item.getItemDamage() == 0; + return item.getItem() instanceof ItemNpcTool && item.getItemDamage() == 0; + case MAGIC_BOOK: + return item.getItem() instanceof ItemNpcTool && item.getItemDamage() == 2; default: return false; } @@ -197,6 +207,8 @@ public class PacketUtil { return "Paintbrush"; case HAMMER: return "Hammer"; + case MAGIC_BOOK: + return "Magic Book"; default: return type.toString(); } diff --git a/src/main/java/kamkeel/npcs/network/enums/EnumItemPacketType.java b/src/main/java/kamkeel/npcs/network/enums/EnumItemPacketType.java index f4c25e7f0..0f23d1885 100644 --- a/src/main/java/kamkeel/npcs/network/enums/EnumItemPacketType.java +++ b/src/main/java/kamkeel/npcs/network/enums/EnumItemPacketType.java @@ -9,5 +9,6 @@ public enum EnumItemPacketType { PATHER, BLOCK, BRUSH, - HAMMER + HAMMER, + MAGIC_BOOK } diff --git a/src/main/java/kamkeel/npcs/network/enums/EnumPlayerPacket.java b/src/main/java/kamkeel/npcs/network/enums/EnumPlayerPacket.java index 31056b711..c5c912c79 100644 --- a/src/main/java/kamkeel/npcs/network/enums/EnumPlayerPacket.java +++ b/src/main/java/kamkeel/npcs/network/enums/EnumPlayerPacket.java @@ -1,5 +1,6 @@ package kamkeel.npcs.network.enums; + public enum EnumPlayerPacket { FollowerAction, Transport, @@ -14,12 +15,16 @@ public enum EnumPlayerPacket { GetRole, InputDevice, ScreenSize, + MagicCycles, CustomGuiButton, CustomGuiScrollClick, CustomGuiClose, CustomGuiUnfocused, + GuiPaintbrush, + GuiMagicBook, + ProfileCreate, ProfileRemove, ProfileRename, diff --git a/src/main/java/kamkeel/npcs/network/packets/data/large/SyncEffectPacket.java b/src/main/java/kamkeel/npcs/network/packets/data/large/SyncEffectPacket.java index 3453ef1d1..66d7a5756 100644 --- a/src/main/java/kamkeel/npcs/network/packets/data/large/SyncEffectPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/data/large/SyncEffectPacket.java @@ -56,7 +56,7 @@ public final class SyncEffectPacket extends LargeAbstractPacket { NBTTagCompound tag = ByteBufUtils.readBigNBT(data); SyncController.clientSyncEffects(tag); } catch (RuntimeException e) { - LogWriter.error("Attempted to Sync Effects but it was too big"); + LogWriter.error(String.format("Attempted to Sync Effects but it was too big")); } } } diff --git a/src/main/java/kamkeel/npcs/network/packets/player/CheckPlayerValue.java b/src/main/java/kamkeel/npcs/network/packets/player/CheckPlayerValue.java index 8e5eff27d..9549e2e36 100644 --- a/src/main/java/kamkeel/npcs/network/packets/player/CheckPlayerValue.java +++ b/src/main/java/kamkeel/npcs/network/packets/player/CheckPlayerValue.java @@ -12,7 +12,6 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import noppes.npcs.NoppesUtilPlayer; import noppes.npcs.controllers.PartyController; -import noppes.npcs.controllers.PlayerDataController; import noppes.npcs.controllers.data.Party; import noppes.npcs.controllers.data.PlayerData; import noppes.npcs.controllers.data.PlayerFactionData; @@ -56,7 +55,7 @@ public class CheckPlayerValue extends AbstractPacket { Type type = Type.values()[in.readInt()]; switch (type) { case Faction: - PlayerFactionData data = PlayerDataController.Instance.getPlayerData(playerMP).factionData; + PlayerFactionData data = PlayerData.get(playerMP).factionData; GuiDataPacket.sendGuiData(playerMP, data.getPlayerGuiData()); break; case QuestLog: @@ -66,8 +65,8 @@ public class CheckPlayerValue extends AbstractPacket { NoppesUtilPlayer.sendTrackedQuest(playerMP); break; case CheckQuestCompletion: - PlayerData playerData = PlayerDataController.Instance.getPlayerData(playerMP); - PlayerQuestData questData = PlayerDataController.Instance.getPlayerData(playerMP).questData; + PlayerData playerData = PlayerData.get(playerMP); + PlayerQuestData questData = PlayerData.get(playerMP).questData; Party playerParty = playerData.getPlayerParty(); if (playerParty != null) PartyController.Instance().checkQuestCompletion(playerParty, null); diff --git a/src/main/java/kamkeel/npcs/network/packets/player/MailActionPacket.java b/src/main/java/kamkeel/npcs/network/packets/player/MailActionPacket.java index 82062485f..eb5e12d97 100644 --- a/src/main/java/kamkeel/npcs/network/packets/player/MailActionPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/player/MailActionPacket.java @@ -17,6 +17,7 @@ import noppes.npcs.constants.EnumGuiType; import noppes.npcs.containers.ContainerMail; import noppes.npcs.controllers.PlayerDataController; import noppes.npcs.controllers.PlayerQuestController; +import noppes.npcs.controllers.data.PlayerData; import noppes.npcs.controllers.data.PlayerMail; import noppes.npcs.controllers.data.PlayerMailData; import noppes.npcs.controllers.data.QuestData; @@ -97,7 +98,7 @@ public class MailActionPacket extends AbstractPacket { if (!(player instanceof EntityPlayerMP)) return; EntityPlayerMP playerMP = (EntityPlayerMP) player; - PlayerMailData data = PlayerDataController.Instance.getPlayerData(playerMP).mailData; + PlayerMailData data = PlayerData.get(playerMP).mailData; if (type == Action.GET) { GuiDataPacket.sendGuiData(playerMP, data.saveNBTData(new NBTTagCompound())); diff --git a/src/main/java/kamkeel/npcs/network/packets/player/ScreenSizePacket.java b/src/main/java/kamkeel/npcs/network/packets/player/ScreenSizePacket.java index b03a80fd3..258c29a59 100644 --- a/src/main/java/kamkeel/npcs/network/packets/player/ScreenSizePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/player/ScreenSizePacket.java @@ -8,7 +8,7 @@ import kamkeel.npcs.network.PacketChannel; import kamkeel.npcs.network.PacketHandler; import kamkeel.npcs.network.enums.EnumPlayerPacket; import net.minecraft.entity.player.EntityPlayer; -import noppes.npcs.controllers.PlayerDataController; +import noppes.npcs.controllers.data.PlayerData; import java.io.IOException; @@ -44,6 +44,6 @@ public class ScreenSizePacket extends AbstractPacket { @Override public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { int width = in.readInt(), height = in.readInt(); - PlayerDataController.Instance.getPlayerData(player).screenSize.setSize(width, height); + PlayerData.get(player).screenSize.setSize(width, height); } } diff --git a/src/main/java/kamkeel/npcs/network/packets/player/item/GuiMagicBookPacket.java b/src/main/java/kamkeel/npcs/network/packets/player/item/GuiMagicBookPacket.java new file mode 100644 index 000000000..5b719ba13 --- /dev/null +++ b/src/main/java/kamkeel/npcs/network/packets/player/item/GuiMagicBookPacket.java @@ -0,0 +1,66 @@ +package kamkeel.npcs.network.packets.player.item; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import io.netty.buffer.ByteBuf; +import kamkeel.npcs.network.AbstractPacket; +import kamkeel.npcs.network.PacketChannel; +import kamkeel.npcs.network.PacketHandler; +import kamkeel.npcs.network.PacketUtil; +import kamkeel.npcs.network.enums.EnumItemPacketType; +import kamkeel.npcs.network.enums.EnumPlayerPacket; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import noppes.npcs.NoppesUtilServer; +import noppes.npcs.constants.EnumGuiType; + +import java.io.IOException; + +public class GuiMagicBookPacket extends AbstractPacket { + public static String packetName = "Player|GuiMagicBook"; + + private int guiIndex, posX, posY, posZ; + + public GuiMagicBookPacket(int guiIndex, int posX, int posY, int posZ) { + this.guiIndex = guiIndex; + this.posX = posX; + this.posY = posY; + this.posZ = posZ; + } + + public GuiMagicBookPacket() {} + + @Override + public Enum getType() { + return EnumPlayerPacket.GuiMagicBook; + } + + @Override + public PacketChannel getChannel() { + return PacketHandler.PLAYER_PACKET; + } + + @SideOnly(Side.CLIENT) + @Override + public void sendData(ByteBuf out) throws IOException { + out.writeInt(guiIndex); + out.writeInt(posX); + out.writeInt(posY); + out.writeInt(posZ); + } + + @Override + public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { + if (!(player instanceof EntityPlayerMP)) + return; + if (!PacketUtil.verifyItemPacket(packetName, player, EnumItemPacketType.MAGIC_BOOK)) + return; + + int index = in.readInt(); + int x = in.readInt(); + int y = in.readInt(); + int z = in.readInt(); + EnumGuiType gui = EnumGuiType.values()[index]; + NoppesUtilServer.sendOpenGui(player, gui, null, x, y, z); + } +} diff --git a/src/main/java/kamkeel/npcs/network/packets/player/item/GuiPaintbrushPacket.java b/src/main/java/kamkeel/npcs/network/packets/player/item/GuiPaintbrushPacket.java new file mode 100644 index 000000000..ebbd66eff --- /dev/null +++ b/src/main/java/kamkeel/npcs/network/packets/player/item/GuiPaintbrushPacket.java @@ -0,0 +1,66 @@ +package kamkeel.npcs.network.packets.player.item; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import io.netty.buffer.ByteBuf; +import kamkeel.npcs.network.AbstractPacket; +import kamkeel.npcs.network.PacketChannel; +import kamkeel.npcs.network.PacketHandler; +import kamkeel.npcs.network.PacketUtil; +import kamkeel.npcs.network.enums.EnumItemPacketType; +import kamkeel.npcs.network.enums.EnumPlayerPacket; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import noppes.npcs.NoppesUtilServer; +import noppes.npcs.constants.EnumGuiType; + +import java.io.IOException; + +public class GuiPaintbrushPacket extends AbstractPacket { + public static String packetName = "Player|GuiPaintbrush"; + + private int guiIndex, posX, posY, posZ; + + public GuiPaintbrushPacket(int guiIndex, int posX, int posY, int posZ) { + this.guiIndex = guiIndex; + this.posX = posX; + this.posY = posY; + this.posZ = posZ; + } + + public GuiPaintbrushPacket() {} + + @Override + public Enum getType() { + return EnumPlayerPacket.GuiPaintbrush; + } + + @Override + public PacketChannel getChannel() { + return PacketHandler.PLAYER_PACKET; + } + + @SideOnly(Side.CLIENT) + @Override + public void sendData(ByteBuf out) throws IOException { + out.writeInt(guiIndex); + out.writeInt(posX); + out.writeInt(posY); + out.writeInt(posZ); + } + + @Override + public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { + if (!(player instanceof EntityPlayerMP)) + return; + if (!PacketUtil.verifyItemPacket(packetName, player, EnumItemPacketType.BRUSH)) + return; + + int index = in.readInt(); + int x = in.readInt(); + int y = in.readInt(); + int z = in.readInt(); + EnumGuiType gui = EnumGuiType.values()[index]; + NoppesUtilServer.sendOpenGui(player, gui, null, x, y, z); + } +} diff --git a/src/main/java/kamkeel/npcs/network/packets/player/item/MagicCyclesPacket.java b/src/main/java/kamkeel/npcs/network/packets/player/item/MagicCyclesPacket.java new file mode 100644 index 000000000..d7ae3d7fd --- /dev/null +++ b/src/main/java/kamkeel/npcs/network/packets/player/item/MagicCyclesPacket.java @@ -0,0 +1,82 @@ +package kamkeel.npcs.network.packets.player.item; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import io.netty.buffer.ByteBuf; +import kamkeel.npcs.network.*; +import kamkeel.npcs.network.enums.EnumItemPacketType; +import kamkeel.npcs.network.enums.EnumPlayerPacket; +import kamkeel.npcs.network.packets.data.large.GuiDataPacket; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.nbt.NBTTagCompound; +import noppes.npcs.constants.EnumScrollData; +import noppes.npcs.controllers.MagicController; +import noppes.npcs.controllers.data.MagicCycle; + +import java.io.IOException; +import java.util.HashMap; + +import static kamkeel.npcs.network.packets.data.large.ScrollDataPacket.sendScrollData; + +public class MagicCyclesPacket extends AbstractPacket { + public static String packetName = "Player|MagicCycles"; + + private int id; + + public MagicCyclesPacket() {} + + public MagicCyclesPacket(int id) { + this.id = id; + } + + @Override + public Enum getType() { + return EnumPlayerPacket.MagicCycles; + } + + @Override + public PacketChannel getChannel() { + return PacketHandler.PLAYER_PACKET; + } + + @SideOnly(Side.CLIENT) + @Override + public void sendData(ByteBuf out) throws IOException { + out.writeInt(this.id); + } + + @Override + public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { + if (!(player instanceof EntityPlayerMP)) + return; + if (!PacketUtil.verifyItemPacket(packetName, player, EnumItemPacketType.MAGIC_BOOK)) + return; + + int id = in.readInt(); + if(id == -1){ + HashMap map = new HashMap<>(); + for (MagicCycle magicCycle : MagicController.getInstance().cycles.values()) { + map.put(magicCycle.displayName.replace("&", "\u00A7"), magicCycle.id); + } + sendScrollData((EntityPlayerMP) player, map, EnumScrollData.MAGIC_CYCLES); + } else { + MagicCycle cycle = MagicController.getInstance().getCycle(id); + if(cycle == null) + return; + NBTTagCompound compound = new NBTTagCompound(); + NBTTagCompound magicCompound = new NBTTagCompound(); + cycle.writeNBT(magicCompound); + compound.setTag("MagicCycle", magicCompound); + GuiDataPacket.sendGuiData((EntityPlayerMP) player, compound); + } + } + + public static void GetAll() { + PacketClient.sendClient(new MagicCyclesPacket(-1)); + } + + public static void GetCycle(int id) { + PacketClient.sendClient(new MagicCyclesPacket(id)); + } +} diff --git a/src/main/java/kamkeel/npcs/network/packets/request/GuiRequestPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/GuiRequestPacket.java index 7ff122b19..fbfae0a6e 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/GuiRequestPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/GuiRequestPacket.java @@ -54,7 +54,7 @@ public final class GuiRequestPacket extends AbstractPacket { public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(player, EnumItemPacketType.WAND, EnumItemPacketType.CLONER, EnumItemPacketType.BRUSH)) + if (!PacketUtil.verifyItemPacket(packetName, player, EnumItemPacketType.WAND, EnumItemPacketType.CLONER, EnumItemPacketType.BRUSH, EnumItemPacketType.MAGIC_BOOK)) return; int index = in.readInt(); int x = in.readInt(); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/IsGuiOpenInform.java b/src/main/java/kamkeel/npcs/network/packets/request/IsGuiOpenInform.java index 3aa839d51..cf6bc4988 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/IsGuiOpenInform.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/IsGuiOpenInform.java @@ -8,7 +8,6 @@ import kamkeel.npcs.network.PacketChannel; import kamkeel.npcs.network.PacketHandler; import kamkeel.npcs.network.enums.EnumRequestPacket; import net.minecraft.entity.player.EntityPlayer; -import noppes.npcs.controllers.PlayerDataController; import noppes.npcs.controllers.data.PlayerData; import java.io.IOException; @@ -44,7 +43,7 @@ public final class IsGuiOpenInform extends AbstractPacket { @Override public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { - PlayerData playerdata = PlayerDataController.Instance.getPlayerData(player); + PlayerData playerdata = PlayerData.get(player); boolean isGUIOpen = in.readBoolean(); playerdata.setGUIOpen(isGUIOpen); } diff --git a/src/main/java/kamkeel/npcs/network/packets/request/MailOpenSetupPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/MailOpenSetupPacket.java index 9d0ec6b4b..cd8dbd71a 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/MailOpenSetupPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/MailOpenSetupPacket.java @@ -53,7 +53,7 @@ public final class MailOpenSetupPacket extends AbstractPacket { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; PlayerMail mail = new PlayerMail(); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/MerchantUpdatePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/MerchantUpdatePacket.java index 8e297fa10..4c20a1012 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/MerchantUpdatePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/MerchantUpdatePacket.java @@ -60,7 +60,7 @@ public final class MerchantUpdatePacket extends AbstractPacket { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; int entityId = in.readInt(); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/MountPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/MountPacket.java index 5facb2c5d..0fa6fea87 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/MountPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/MountPacket.java @@ -61,7 +61,7 @@ public final class MountPacket extends AbstractPacket { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.MOUNTER, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.MOUNTER, player)) return; MountPacket.Action requestedAction = MountPacket.Action.values()[in.readInt()]; diff --git a/src/main/java/kamkeel/npcs/network/packets/request/TileEntityGetPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/TileEntityGetPacket.java index 511fea361..2ccb99189 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/TileEntityGetPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/TileEntityGetPacket.java @@ -57,7 +57,7 @@ public final class TileEntityGetPacket extends AbstractPacket { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(player, EnumItemPacketType.WAND, EnumItemPacketType.BLOCK)) + if (!PacketUtil.verifyItemPacket(packetName, player, EnumItemPacketType.WAND, EnumItemPacketType.BLOCK)) return; TileEntity tile = player.worldObj.getTileEntity(in.readInt(), in.readInt(), in.readInt()); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/TileEntitySavePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/TileEntitySavePacket.java index 5b2a9a902..c1fc4e5e3 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/TileEntitySavePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/TileEntitySavePacket.java @@ -50,7 +50,7 @@ public final class TileEntitySavePacket extends AbstractPacket { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(player, EnumItemPacketType.WAND, EnumItemPacketType.BLOCK)) + if (!PacketUtil.verifyItemPacket(packetName, player, EnumItemPacketType.WAND, EnumItemPacketType.BLOCK)) return; NoppesUtilServer.saveTileEntity((EntityPlayerMP) player, ByteBufUtils.readNBT(in)); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/TraderMarketSavePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/TraderMarketSavePacket.java index 6d338830b..3aa357314 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/TraderMarketSavePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/TraderMarketSavePacket.java @@ -44,7 +44,7 @@ public final class TraderMarketSavePacket extends AbstractPacket { @Override public CustomNpcsPermissions.Permission getPermission() { - return CustomNpcsPermissions.NPC_ADVANCED; + return CustomNpcsPermissions.NPC_ADVANCED_TRADER; } @Override @@ -64,7 +64,7 @@ public final class TraderMarketSavePacket extends AbstractPacket { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; String market = ByteBufUtils.readString(in); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/animation/AnimationGetPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/animation/AnimationGetPacket.java index a577891fe..0a7e32845 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/animation/AnimationGetPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/animation/AnimationGetPacket.java @@ -51,7 +51,7 @@ public final class AnimationGetPacket extends AbstractPacket { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; int id = in.readInt(); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/animation/AnimationRemovePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/animation/AnimationRemovePacket.java index 4aa8a4778..aa0bee42b 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/animation/AnimationRemovePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/animation/AnimationRemovePacket.java @@ -58,7 +58,7 @@ public final class AnimationRemovePacket extends AbstractPacket { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; int id = in.readInt(); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/animation/AnimationSavePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/animation/AnimationSavePacket.java index a34e82c1d..3f7dbb996 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/animation/AnimationSavePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/animation/AnimationSavePacket.java @@ -59,7 +59,7 @@ public final class AnimationSavePacket extends AbstractPacket { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; NBTTagCompound compound = ByteBufUtils.readNBT(in); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/animation/AnimationsGetPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/animation/AnimationsGetPacket.java index 83c5ef33e..a2bc51d0a 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/animation/AnimationsGetPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/animation/AnimationsGetPacket.java @@ -40,7 +40,7 @@ public final class AnimationsGetPacket extends AbstractPacket { public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; NoppesUtilServer.sendAnimationDataAll((EntityPlayerMP) player); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/bank/BankGetPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/bank/BankGetPacket.java index e49a50e39..ddee1a8b3 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/bank/BankGetPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/bank/BankGetPacket.java @@ -49,7 +49,7 @@ public final class BankGetPacket extends AbstractPacket { public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; int id = in.readInt(); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/bank/BankRemovePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/bank/BankRemovePacket.java index fb21141de..f83ca3db5 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/bank/BankRemovePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/bank/BankRemovePacket.java @@ -56,7 +56,7 @@ public final class BankRemovePacket extends AbstractPacket { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; int id = in.readInt(); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/bank/BankSavePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/bank/BankSavePacket.java index 42c29b719..63476dc2d 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/bank/BankSavePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/bank/BankSavePacket.java @@ -57,7 +57,7 @@ public final class BankSavePacket extends AbstractPacket { public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; NBTTagCompound compound = ByteBufUtils.readNBT(in); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/bank/BanksGetPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/bank/BanksGetPacket.java index 9c14168b1..3d5242f09 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/bank/BanksGetPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/bank/BanksGetPacket.java @@ -42,7 +42,7 @@ public final class BanksGetPacket extends AbstractPacket { public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; NoppesUtilServer.sendBankDataAll((EntityPlayerMP) player); } diff --git a/src/main/java/kamkeel/npcs/network/packets/request/clone/CloneAllTagsPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/clone/CloneAllTagsPacket.java index 2e17e72a0..bc4b360ec 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/clone/CloneAllTagsPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/clone/CloneAllTagsPacket.java @@ -45,7 +45,7 @@ public final class CloneAllTagsPacket extends AbstractPacket { public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(player, EnumItemPacketType.CLONER)) + if (!PacketUtil.verifyItemPacket(packetName, player, EnumItemPacketType.CLONER)) return; NBTTagCompound compound = new NBTTagCompound(); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/clone/CloneAllTagsShortPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/clone/CloneAllTagsShortPacket.java index ef3ec908c..349032e7d 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/clone/CloneAllTagsShortPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/clone/CloneAllTagsShortPacket.java @@ -45,7 +45,7 @@ public final class CloneAllTagsShortPacket extends AbstractPacket { public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(player, EnumItemPacketType.CLONER)) + if (!PacketUtil.verifyItemPacket(packetName, player, EnumItemPacketType.CLONER)) return; NBTTagCompound compound = new NBTTagCompound(); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/clone/CloneListPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/clone/CloneListPacket.java index 20013b469..87bac4a29 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/clone/CloneListPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/clone/CloneListPacket.java @@ -51,7 +51,7 @@ public final class CloneListPacket extends AbstractPacket { public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(player, EnumItemPacketType.MOUNTER, EnumItemPacketType.CLONER)) + if (!PacketUtil.verifyItemPacket(packetName, player, EnumItemPacketType.MOUNTER, EnumItemPacketType.CLONER)) return; NBTTagList list = new NBTTagList(); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/clone/ClonePreSavePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/clone/ClonePreSavePacket.java index cbcc6ecf5..378145ddb 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/clone/ClonePreSavePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/clone/ClonePreSavePacket.java @@ -59,7 +59,7 @@ public final class ClonePreSavePacket extends AbstractPacket { public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(player, EnumItemPacketType.CLONER)) + if (!PacketUtil.verifyItemPacket(packetName, player, EnumItemPacketType.CLONER)) return; boolean bo = ServerCloneController.Instance.getCloneData(null, ByteBufUtils.readString(in), in.readInt()) != null; diff --git a/src/main/java/kamkeel/npcs/network/packets/request/clone/CloneRemovePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/clone/CloneRemovePacket.java index 282aeac99..ce1fcb367 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/clone/CloneRemovePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/clone/CloneRemovePacket.java @@ -61,7 +61,7 @@ public final class CloneRemovePacket extends AbstractPacket { public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(player, EnumItemPacketType.CLONER)) + if (!PacketUtil.verifyItemPacket(packetName, player, EnumItemPacketType.CLONER)) return; int tab = in.readInt(); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/clone/CloneSavePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/clone/CloneSavePacket.java index 8b6fb39a1..3a8abd9c0 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/clone/CloneSavePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/clone/CloneSavePacket.java @@ -15,7 +15,6 @@ import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import noppes.npcs.CustomNpcsPermissions; -import noppes.npcs.controllers.PlayerDataController; import noppes.npcs.controllers.ServerCloneController; import noppes.npcs.controllers.data.PlayerData; @@ -67,10 +66,10 @@ public final class CloneSavePacket extends AbstractPacket { public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(player, EnumItemPacketType.CLONER)) + if (!PacketUtil.verifyItemPacket(packetName, player, EnumItemPacketType.CLONER)) return; - PlayerData data = PlayerDataController.Instance.getPlayerData(player); + PlayerData data = PlayerData.get(player); if (data.cloned == null) return; diff --git a/src/main/java/kamkeel/npcs/network/packets/request/clone/CloneTagListPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/clone/CloneTagListPacket.java index fe264d20a..4d7b21aac 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/clone/CloneTagListPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/clone/CloneTagListPacket.java @@ -50,7 +50,7 @@ public final class CloneTagListPacket extends AbstractPacket { public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(player, EnumItemPacketType.CLONER)) + if (!PacketUtil.verifyItemPacket(packetName, player, EnumItemPacketType.CLONER)) return; int tab = in.readInt(); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/clone/MobSpawnerPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/clone/MobSpawnerPacket.java index aacc85a20..d5440f82e 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/clone/MobSpawnerPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/clone/MobSpawnerPacket.java @@ -94,7 +94,7 @@ public class MobSpawnerPacket extends AbstractPacket { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(player, EnumItemPacketType.CLONER)) + if (!PacketUtil.verifyItemPacket(packetName, player, EnumItemPacketType.CLONER)) return; Action requestedAction = Action.values()[in.readInt()]; diff --git a/src/main/java/kamkeel/npcs/network/packets/request/clone/SpawnMobPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/clone/SpawnMobPacket.java index a8d2b6e33..7af87fd07 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/clone/SpawnMobPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/clone/SpawnMobPacket.java @@ -100,7 +100,7 @@ public class SpawnMobPacket extends AbstractPacket { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(player, EnumItemPacketType.CLONER)) + if (!PacketUtil.verifyItemPacket(packetName, player, EnumItemPacketType.CLONER)) return; Action requestedAction = Action.values()[in.readInt()]; diff --git a/src/main/java/kamkeel/npcs/network/packets/request/dialog/DialogCategoriesGetPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/dialog/DialogCategoriesGetPacket.java index e948fdda8..135b55d91 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/dialog/DialogCategoriesGetPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/dialog/DialogCategoriesGetPacket.java @@ -43,7 +43,7 @@ public final class DialogCategoriesGetPacket extends AbstractPacket { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(player, EnumItemPacketType.WAND, EnumItemPacketType.BLOCK)) + if (!PacketUtil.verifyItemPacket(packetName, player, EnumItemPacketType.WAND, EnumItemPacketType.BLOCK)) return; ScrollDataPacket.sendScrollData((EntityPlayerMP) player, DialogController.Instance.getScroll(), EnumScrollData.OPTIONAL); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/dialog/DialogCategoryGetPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/dialog/DialogCategoryGetPacket.java index 9ccad6677..902d5e5d0 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/dialog/DialogCategoryGetPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/dialog/DialogCategoryGetPacket.java @@ -49,7 +49,7 @@ public final class DialogCategoryGetPacket extends AbstractPacket { @Override public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) return; + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; int id = in.readInt(); DialogCategory category = DialogController.Instance.categories.get(id); if (category != null) { diff --git a/src/main/java/kamkeel/npcs/network/packets/request/dialog/DialogCategoryRemovePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/dialog/DialogCategoryRemovePacket.java index 6623c3af4..81d716032 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/dialog/DialogCategoryRemovePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/dialog/DialogCategoryRemovePacket.java @@ -56,7 +56,7 @@ public final class DialogCategoryRemovePacket extends AbstractPacket { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; int id = in.readInt(); DialogController.Instance.removeCategory(id); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/dialog/DialogCategorySavePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/dialog/DialogCategorySavePacket.java index ab3d87abe..adae2de93 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/dialog/DialogCategorySavePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/dialog/DialogCategorySavePacket.java @@ -57,7 +57,7 @@ public final class DialogCategorySavePacket extends AbstractPacket { @Override public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) return; + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; NBTTagCompound compound = ByteBufUtils.readNBT(in); DialogCategory category = new DialogCategory(); category.readNBT(compound); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/dialog/DialogGetPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/dialog/DialogGetPacket.java index 2a0aec2c2..44a59246f 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/dialog/DialogGetPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/dialog/DialogGetPacket.java @@ -50,7 +50,7 @@ public final class DialogGetPacket extends AbstractPacket { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(player, EnumItemPacketType.WAND, EnumItemPacketType.BLOCK)) + if (!PacketUtil.verifyItemPacket(packetName, player, EnumItemPacketType.WAND, EnumItemPacketType.BLOCK)) return; Dialog dialog = DialogController.Instance.dialogs.get(in.readInt()); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/dialog/DialogNpcGetPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/dialog/DialogNpcGetPacket.java index cae4b9c80..4679715c2 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/dialog/DialogNpcGetPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/dialog/DialogNpcGetPacket.java @@ -41,7 +41,7 @@ public final class DialogNpcGetPacket extends AbstractPacket { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; NoppesUtilServer.sendNpcDialogs(player); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/dialog/DialogNpcRemovePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/dialog/DialogNpcRemovePacket.java index 43769e16d..2637b2ef4 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/dialog/DialogNpcRemovePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/dialog/DialogNpcRemovePacket.java @@ -39,7 +39,7 @@ public final class DialogNpcRemovePacket extends AbstractPacket { @Override public CustomNpcsPermissions.Permission getPermission() { - return CustomNpcsPermissions.NPC_ADVANCED; + return CustomNpcsPermissions.NPC_ADVANCED_DIALOG; } @Override @@ -58,7 +58,7 @@ public final class DialogNpcRemovePacket extends AbstractPacket { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; int idx = in.readInt(); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/dialog/DialogNpcSetPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/dialog/DialogNpcSetPacket.java index a7db1b184..78a61d01d 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/dialog/DialogNpcSetPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/dialog/DialogNpcSetPacket.java @@ -45,7 +45,7 @@ public final class DialogNpcSetPacket extends AbstractPacket { @Override public CustomNpcsPermissions.Permission getPermission() { - return CustomNpcsPermissions.NPC_ADVANCED; + return CustomNpcsPermissions.NPC_ADVANCED_DIALOG; } @Override @@ -63,7 +63,7 @@ public final class DialogNpcSetPacket extends AbstractPacket { @Override public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) return; + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; int s = in.readInt(); int d = in.readInt(); DialogOption option = NoppesUtilServer.setNpcDialog(s, d, player); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/dialog/DialogRemovePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/dialog/DialogRemovePacket.java index 22a917eb9..629856f49 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/dialog/DialogRemovePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/dialog/DialogRemovePacket.java @@ -58,7 +58,7 @@ public final class DialogRemovePacket extends AbstractPacket { public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; int diagId = in.readInt(); boolean sendGroup = in.readBoolean(); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/dialog/DialogSavePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/dialog/DialogSavePacket.java index c221e043e..716a53feb 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/dialog/DialogSavePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/dialog/DialogSavePacket.java @@ -64,7 +64,7 @@ public final class DialogSavePacket extends AbstractPacket { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; int cat = in.readInt(); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/dialog/DialogsGetPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/dialog/DialogsGetPacket.java index 9ea47415a..03dc47b56 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/dialog/DialogsGetPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/dialog/DialogsGetPacket.java @@ -52,7 +52,7 @@ public final class DialogsGetPacket extends AbstractPacket { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(player, EnumItemPacketType.WAND, EnumItemPacketType.BLOCK)) + if (!PacketUtil.verifyItemPacket(packetName, player, EnumItemPacketType.WAND, EnumItemPacketType.BLOCK)) return; int catID = in.readInt(); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/effects/EffectGetPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/effects/EffectGetPacket.java index 43822b928..a82a2fd4c 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/effects/EffectGetPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/effects/EffectGetPacket.java @@ -46,7 +46,7 @@ public final class EffectGetPacket extends AbstractPacket { public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; int effectID = in.readInt(); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/effects/EffectRemovePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/effects/EffectRemovePacket.java index 3b80a3f43..6af210b64 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/effects/EffectRemovePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/effects/EffectRemovePacket.java @@ -54,7 +54,7 @@ public class EffectRemovePacket extends AbstractPacket { public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; int effectID = in.readInt(); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/effects/EffectSavePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/effects/EffectSavePacket.java index 1990fb205..785ccdf4f 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/effects/EffectSavePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/effects/EffectSavePacket.java @@ -57,7 +57,7 @@ public class EffectSavePacket extends AbstractPacket { public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; String prevName = ByteBufUtils.readString(in); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/effects/EffectsGetPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/effects/EffectsGetPacket.java index aa940c0ca..bfe2e446b 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/effects/EffectsGetPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/effects/EffectsGetPacket.java @@ -47,7 +47,7 @@ public final class EffectsGetPacket extends AbstractPacket { public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; int effectID = in.readInt(); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/faction/FactionGetPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/faction/FactionGetPacket.java index 9056337ec..d7bf394a7 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/faction/FactionGetPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/faction/FactionGetPacket.java @@ -48,7 +48,7 @@ public final class FactionGetPacket extends AbstractPacket { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(player, EnumItemPacketType.WAND, EnumItemPacketType.BLOCK)) + if (!PacketUtil.verifyItemPacket(packetName, player, EnumItemPacketType.WAND, EnumItemPacketType.BLOCK)) return; NBTTagCompound compound = new NBTTagCompound(); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/faction/FactionRemovePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/faction/FactionRemovePacket.java index cc0a0aa0d..8ae5788b6 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/faction/FactionRemovePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/faction/FactionRemovePacket.java @@ -48,10 +48,6 @@ public final class FactionRemovePacket extends AbstractPacket { return CustomNpcsPermissions.GLOBAL_FACTION; } - @Override - public boolean needsNPC() { - return true; - } @SideOnly(Side.CLIENT) @Override @@ -63,7 +59,7 @@ public final class FactionRemovePacket extends AbstractPacket { public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; int id = in.readInt(); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/faction/FactionSavePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/faction/FactionSavePacket.java index 892c31c6e..3aa620e41 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/faction/FactionSavePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/faction/FactionSavePacket.java @@ -48,11 +48,6 @@ public final class FactionSavePacket extends AbstractPacket { return CustomNpcsPermissions.GLOBAL_FACTION; } - @Override - public boolean needsNPC() { - return true; - } - @SideOnly(Side.CLIENT) @Override public void sendData(ByteBuf out) throws IOException { @@ -64,7 +59,7 @@ public final class FactionSavePacket extends AbstractPacket { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; NBTTagCompound compound = ByteBufUtils.readNBT(in); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/faction/FactionSetPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/faction/FactionSetPacket.java index 8dc667712..cb08c49e9 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/faction/FactionSetPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/faction/FactionSetPacket.java @@ -39,7 +39,7 @@ public final class FactionSetPacket extends AbstractPacket { @Override public CustomNpcsPermissions.Permission getPermission() { - return CustomNpcsPermissions.NPC_ADVANCED; + return CustomNpcsPermissions.NPC_ADVANCED_FACTION; } @Override @@ -58,7 +58,7 @@ public final class FactionSetPacket extends AbstractPacket { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; int factionId = in.readInt(); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/faction/FactionsGetPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/faction/FactionsGetPacket.java index 17431ae99..0e6fa761e 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/faction/FactionsGetPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/faction/FactionsGetPacket.java @@ -42,7 +42,7 @@ public final class FactionsGetPacket extends AbstractPacket { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(player, EnumItemPacketType.WAND, EnumItemPacketType.BLOCK)) + if (!PacketUtil.verifyItemPacket(packetName, player, EnumItemPacketType.WAND, EnumItemPacketType.BLOCK)) return; NoppesUtilServer.sendFactionDataAll((EntityPlayerMP) player); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/feather/DimensionTeleportPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/feather/DimensionTeleportPacket.java index 2c5c5fcdd..65f18be9f 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/feather/DimensionTeleportPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/feather/DimensionTeleportPacket.java @@ -51,7 +51,7 @@ public final class DimensionTeleportPacket extends AbstractPacket { public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(player, EnumItemPacketType.TELEPORTER)) + if (!PacketUtil.verifyItemPacket(packetName, player, EnumItemPacketType.TELEPORTER)) return; int dimension = in.readInt(); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/item/ColorBrushPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/item/ColorBrushPacket.java index 6da217d7e..0a9f755ae 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/item/ColorBrushPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/item/ColorBrushPacket.java @@ -56,7 +56,7 @@ public final class ColorBrushPacket extends AbstractPacket { public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.BRUSH, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.BRUSH, player)) return; int color = in.readInt(); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/item/ColorSetPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/item/ColorSetPacket.java index 3eef85569..5a1105b85 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/item/ColorSetPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/item/ColorSetPacket.java @@ -65,7 +65,7 @@ public final class ColorSetPacket extends AbstractPacket { public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.BRUSH, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.BRUSH, player)) return; int x = in.readInt(); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/item/HammerPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/item/HammerPacket.java index 8f42c100e..f050d0370 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/item/HammerPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/item/HammerPacket.java @@ -61,7 +61,7 @@ public final class HammerPacket extends AbstractPacket { public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.HAMMER, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.HAMMER, player)) return; int x = in.readInt(); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/jobs/JobGetPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/jobs/JobGetPacket.java index 39bfdbc22..b9b3924c1 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/jobs/JobGetPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/jobs/JobGetPacket.java @@ -37,7 +37,7 @@ public final class JobGetPacket extends AbstractPacket { @Override public CustomNpcsPermissions.Permission getPermission() { - return CustomNpcsPermissions.NPC_ADVANCED; + return CustomNpcsPermissions.NPC_ADVANCED_JOB; } @Override @@ -55,7 +55,7 @@ public final class JobGetPacket extends AbstractPacket { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; if (npc.jobInterface == null) diff --git a/src/main/java/kamkeel/npcs/network/packets/request/jobs/JobSavePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/jobs/JobSavePacket.java index d2f68bd23..88595b60b 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/jobs/JobSavePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/jobs/JobSavePacket.java @@ -40,7 +40,7 @@ public final class JobSavePacket extends AbstractPacket { @Override public CustomNpcsPermissions.Permission getPermission() { - return CustomNpcsPermissions.NPC_ADVANCED; + return CustomNpcsPermissions.NPC_ADVANCED_JOB; } @Override @@ -59,7 +59,7 @@ public final class JobSavePacket extends AbstractPacket { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; NBTTagCompound original = npc.jobInterface.writeToNBT(new NBTTagCompound()); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/jobs/JobSpawnerAddPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/jobs/JobSpawnerAddPacket.java index 6bd16d215..f6b7fa2dc 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/jobs/JobSpawnerAddPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/jobs/JobSpawnerAddPacket.java @@ -60,7 +60,7 @@ public final class JobSpawnerAddPacket extends AbstractPacket { @Override public CustomNpcsPermissions.Permission getPermission() { - return CustomNpcsPermissions.NPC_ADVANCED; + return CustomNpcsPermissions.NPC_ADVANCED_JOB; } @Override @@ -87,7 +87,7 @@ public final class JobSpawnerAddPacket extends AbstractPacket { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; if (npc.advanced.job != EnumJobType.Spawner) diff --git a/src/main/java/kamkeel/npcs/network/packets/request/jobs/JobSpawnerRemovePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/jobs/JobSpawnerRemovePacket.java index b70e85742..b9f7a55d3 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/jobs/JobSpawnerRemovePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/jobs/JobSpawnerRemovePacket.java @@ -42,7 +42,7 @@ public final class JobSpawnerRemovePacket extends AbstractPacket { @Override public CustomNpcsPermissions.Permission getPermission() { - return CustomNpcsPermissions.NPC_ADVANCED; + return CustomNpcsPermissions.NPC_ADVANCED_JOB; } @Override @@ -61,7 +61,7 @@ public final class JobSpawnerRemovePacket extends AbstractPacket { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; if (npc.advanced.job != EnumJobType.Spawner) diff --git a/src/main/java/kamkeel/npcs/network/packets/request/linked/LinkedGetAllPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/linked/LinkedGetAllPacket.java index 272eefbcd..3825f8c82 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/linked/LinkedGetAllPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/linked/LinkedGetAllPacket.java @@ -50,7 +50,7 @@ public final class LinkedGetAllPacket extends AbstractPacket { public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; Action action = Action.values()[in.readInt()]; diff --git a/src/main/java/kamkeel/npcs/network/packets/request/linked/LinkedGetPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/linked/LinkedGetPacket.java index 2752fdffc..40cad7db5 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/linked/LinkedGetPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/linked/LinkedGetPacket.java @@ -62,7 +62,7 @@ public final class LinkedGetPacket extends AbstractPacket { public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; Action action = Action.values()[in.readInt()]; diff --git a/src/main/java/kamkeel/npcs/network/packets/request/linked/LinkedItemBuildPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/linked/LinkedItemBuildPacket.java index a0ec9dabf..87bf75388 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/linked/LinkedItemBuildPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/linked/LinkedItemBuildPacket.java @@ -54,7 +54,7 @@ public final class LinkedItemBuildPacket extends AbstractPacket { public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; int id = in.readInt(); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/linked/LinkedItemRemovePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/linked/LinkedItemRemovePacket.java index fd45ff852..b6df011bd 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/linked/LinkedItemRemovePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/linked/LinkedItemRemovePacket.java @@ -54,7 +54,7 @@ public final class LinkedItemRemovePacket extends AbstractPacket { public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; int linkedID = in.readInt(); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/linked/LinkedItemSavePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/linked/LinkedItemSavePacket.java index 2c76c3a1f..d7fd58eeb 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/linked/LinkedItemSavePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/linked/LinkedItemSavePacket.java @@ -60,7 +60,7 @@ public final class LinkedItemSavePacket extends AbstractPacket { public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; String prevName = ByteBufUtils.readString(in); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/linked/LinkedNPCAddPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/linked/LinkedNPCAddPacket.java index 75fe6ed18..744a42269 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/linked/LinkedNPCAddPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/linked/LinkedNPCAddPacket.java @@ -59,7 +59,7 @@ public final class LinkedNPCAddPacket extends AbstractPacket { public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; String received = ByteBufUtils.readString(in); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/linked/LinkedNPCRemovePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/linked/LinkedNPCRemovePacket.java index 5c160b94f..a6a0cfaaf 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/linked/LinkedNPCRemovePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/linked/LinkedNPCRemovePacket.java @@ -58,7 +58,7 @@ public final class LinkedNPCRemovePacket extends AbstractPacket { public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; String received = ByteBufUtils.readString(in); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/linked/LinkedSetPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/linked/LinkedSetPacket.java index c0f8ca121..c9cb4836b 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/linked/LinkedSetPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/linked/LinkedSetPacket.java @@ -41,7 +41,7 @@ public final class LinkedSetPacket extends AbstractPacket { @Override public CustomNpcsPermissions.Permission getPermission() { - return CustomNpcsPermissions.NPC_ADVANCED; + return CustomNpcsPermissions.NPC_ADVANCED_LINKED; } @Override @@ -59,7 +59,7 @@ public final class LinkedSetPacket extends AbstractPacket { public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; npc.linkedName = ByteBufUtils.readString(in); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/magic/MagicGetPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/magic/MagicGetPacket.java index 576aeec9a..b2181c6ba 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/magic/MagicGetPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/magic/MagicGetPacket.java @@ -52,7 +52,7 @@ public final class MagicGetPacket extends AbstractPacket { public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) + if (!PacketUtil.verifyItemPacket(packetName, player, EnumItemPacketType.WAND)) return; Action action = Action.values()[in.readInt()]; diff --git a/src/main/java/kamkeel/npcs/network/packets/request/magic/MagicNpcGetPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/magic/MagicNpcGetPacket.java index f9b08b0e4..d3c5ef841 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/magic/MagicNpcGetPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/magic/MagicNpcGetPacket.java @@ -44,7 +44,7 @@ public final class MagicNpcGetPacket extends AbstractPacket { @Override public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { - if (!PacketUtil.verifyItemPacket(player, EnumItemPacketType.WAND)) + if (!PacketUtil.verifyItemPacket(packetName, player, EnumItemPacketType.WAND)) return; NBTTagCompound compound = new NBTTagCompound(); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/magic/MagicNpcSavePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/magic/MagicNpcSavePacket.java index cc1f5bcc3..7e5b0c765 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/magic/MagicNpcSavePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/magic/MagicNpcSavePacket.java @@ -46,7 +46,7 @@ public final class MagicNpcSavePacket extends AbstractPacket { @Override public CustomNpcsPermissions.Permission getPermission() { - return CustomNpcsPermissions.NPC_ADVANCED; + return CustomNpcsPermissions.NPC_ADVANCED_MAGIC; } @SideOnly(Side.CLIENT) @@ -61,7 +61,7 @@ public final class MagicNpcSavePacket extends AbstractPacket { @Override public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { - if (!PacketUtil.verifyItemPacket(player, EnumItemPacketType.WAND)) + if (!PacketUtil.verifyItemPacket(packetName, player, EnumItemPacketType.WAND)) return; NBTTagCompound compound = ByteBufUtils.readNBT(in); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/mainmenu/MainmenuAIGetPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/mainmenu/MainmenuAIGetPacket.java index bb5736c6d..08b621a98 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/mainmenu/MainmenuAIGetPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/mainmenu/MainmenuAIGetPacket.java @@ -47,7 +47,7 @@ public final class MainmenuAIGetPacket extends AbstractPacket { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; GuiDataPacket.sendGuiData((EntityPlayerMP) player, npc.ais.writeToNBT(new NBTTagCompound())); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/mainmenu/MainmenuAISavePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/mainmenu/MainmenuAISavePacket.java index 89bdd6ea5..f48421fd6 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/mainmenu/MainmenuAISavePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/mainmenu/MainmenuAISavePacket.java @@ -60,7 +60,7 @@ public final class MainmenuAISavePacket extends AbstractPacket { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; npc.ais.readToNBT(ByteBufUtils.readNBT(in)); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/mainmenu/MainmenuAdvancedGetPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/mainmenu/MainmenuAdvancedGetPacket.java index 659a26a41..f62a1498f 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/mainmenu/MainmenuAdvancedGetPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/mainmenu/MainmenuAdvancedGetPacket.java @@ -47,7 +47,7 @@ public final class MainmenuAdvancedGetPacket extends AbstractPacket { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; GuiDataPacket.sendGuiData((EntityPlayerMP) player, npc.advanced.writeToNBT(new NBTTagCompound())); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/mainmenu/MainmenuAdvancedMarkDataPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/mainmenu/MainmenuAdvancedMarkDataPacket.java index c1a5c8e84..6dbe9deea 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/mainmenu/MainmenuAdvancedMarkDataPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/mainmenu/MainmenuAdvancedMarkDataPacket.java @@ -61,7 +61,7 @@ public final class MainmenuAdvancedMarkDataPacket extends AbstractPacket { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; MarkData data = MarkData.get(npc); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/mainmenu/MainmenuAdvancedSavePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/mainmenu/MainmenuAdvancedSavePacket.java index 2fb0667a9..c5ff1694f 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/mainmenu/MainmenuAdvancedSavePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/mainmenu/MainmenuAdvancedSavePacket.java @@ -60,7 +60,7 @@ public final class MainmenuAdvancedSavePacket extends AbstractPacket { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; npc.advanced.readToNBT(ByteBufUtils.readNBT(in)); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/mainmenu/MainmenuDisplayGetPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/mainmenu/MainmenuDisplayGetPacket.java index c0e658dec..c2cb25525 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/mainmenu/MainmenuDisplayGetPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/mainmenu/MainmenuDisplayGetPacket.java @@ -47,7 +47,7 @@ public final class MainmenuDisplayGetPacket extends AbstractPacket { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; GuiDataPacket.sendGuiData((EntityPlayerMP) player, npc.display.writeToNBT(new NBTTagCompound())); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/mainmenu/MainmenuDisplaySavePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/mainmenu/MainmenuDisplaySavePacket.java index 0cea8d821..d9bf84489 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/mainmenu/MainmenuDisplaySavePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/mainmenu/MainmenuDisplaySavePacket.java @@ -60,7 +60,7 @@ public final class MainmenuDisplaySavePacket extends AbstractPacket { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; npc.display.readToNBT(ByteBufUtils.readNBT(in)); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/mainmenu/MainmenuInvGetPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/mainmenu/MainmenuInvGetPacket.java index 5e61a05e8..5ae278295 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/mainmenu/MainmenuInvGetPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/mainmenu/MainmenuInvGetPacket.java @@ -47,7 +47,7 @@ public final class MainmenuInvGetPacket extends AbstractPacket { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; GuiDataPacket.sendGuiData((EntityPlayerMP) player, npc.inventory.writeEntityToNBT(new NBTTagCompound())); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/mainmenu/MainmenuInvSavePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/mainmenu/MainmenuInvSavePacket.java index ee8b43ff8..28f9827ad 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/mainmenu/MainmenuInvSavePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/mainmenu/MainmenuInvSavePacket.java @@ -60,7 +60,7 @@ public final class MainmenuInvSavePacket extends AbstractPacket { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; npc.inventory.readEntityFromNBT(ByteBufUtils.readNBT(in)); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/mainmenu/MainmenuStatsGetPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/mainmenu/MainmenuStatsGetPacket.java index e987d6426..474b09da7 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/mainmenu/MainmenuStatsGetPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/mainmenu/MainmenuStatsGetPacket.java @@ -47,7 +47,7 @@ public final class MainmenuStatsGetPacket extends AbstractPacket { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; GuiDataPacket.sendGuiData((EntityPlayerMP) player, npc.stats.writeToNBT(new NBTTagCompound())); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/mainmenu/MainmenuStatsSavePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/mainmenu/MainmenuStatsSavePacket.java index f53a221b3..5637375b2 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/mainmenu/MainmenuStatsSavePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/mainmenu/MainmenuStatsSavePacket.java @@ -60,7 +60,7 @@ public final class MainmenuStatsSavePacket extends AbstractPacket { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; npc.stats.readToNBT(ByteBufUtils.readNBT(in)); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/naturalspawns/NaturalSpawnGetAllPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/naturalspawns/NaturalSpawnGetAllPacket.java index 4a0b504a5..64b7c026e 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/naturalspawns/NaturalSpawnGetAllPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/naturalspawns/NaturalSpawnGetAllPacket.java @@ -42,7 +42,7 @@ public final class NaturalSpawnGetAllPacket extends AbstractPacket { public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; ScrollDataPacket.sendScrollData((EntityPlayerMP) player, SpawnController.Instance.getScroll(), EnumScrollData.OPTIONAL); } diff --git a/src/main/java/kamkeel/npcs/network/packets/request/naturalspawns/NaturalSpawnGetPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/naturalspawns/NaturalSpawnGetPacket.java index 7294874f6..398c7b545 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/naturalspawns/NaturalSpawnGetPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/naturalspawns/NaturalSpawnGetPacket.java @@ -51,7 +51,7 @@ public final class NaturalSpawnGetPacket extends AbstractPacket { public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; int id = in.readInt(); SpawnData spawn = SpawnController.Instance.getSpawnData(id); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/naturalspawns/NaturalSpawnRemovePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/naturalspawns/NaturalSpawnRemovePacket.java index a4e0fa878..7448731ac 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/naturalspawns/NaturalSpawnRemovePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/naturalspawns/NaturalSpawnRemovePacket.java @@ -55,7 +55,7 @@ public final class NaturalSpawnRemovePacket extends AbstractPacket { public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; int id = in.readInt(); SpawnController.Instance.removeSpawnData(id); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/naturalspawns/NaturalSpawnSavePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/naturalspawns/NaturalSpawnSavePacket.java index ef465e493..2d042b462 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/naturalspawns/NaturalSpawnSavePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/naturalspawns/NaturalSpawnSavePacket.java @@ -58,7 +58,7 @@ public final class NaturalSpawnSavePacket extends AbstractPacket { public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; NBTTagCompound compound = ByteBufUtils.readNBT(in); SpawnData data = new SpawnData(); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/npc/ModelDataSavePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/npc/ModelDataSavePacket.java index 382042539..9f4825d82 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/npc/ModelDataSavePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/npc/ModelDataSavePacket.java @@ -61,7 +61,7 @@ public final class ModelDataSavePacket extends AbstractPacket { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; if (npc instanceof EntityCustomNpc) diff --git a/src/main/java/kamkeel/npcs/network/packets/request/npc/NpcClosePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/npc/NpcClosePacket.java index 53cbb4e2c..cdf0c3821 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/npc/NpcClosePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/npc/NpcClosePacket.java @@ -52,7 +52,7 @@ public final class NpcClosePacket extends AbstractPacket { @Override public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; npc.reset(); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/npc/NpcDeletePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/npc/NpcDeletePacket.java index 373b75823..62df0b948 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/npc/NpcDeletePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/npc/NpcDeletePacket.java @@ -52,7 +52,7 @@ public final class NpcDeletePacket extends AbstractPacket { @Override public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; if (ConfigDebug.PlayerLogging && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) { diff --git a/src/main/java/kamkeel/npcs/network/packets/request/npc/RemoteDeletePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/npc/RemoteDeletePacket.java index d77ae543d..c871e5d11 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/npc/RemoteDeletePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/npc/RemoteDeletePacket.java @@ -58,7 +58,7 @@ public final class RemoteDeletePacket extends AbstractPacket { public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { if (!(player instanceof net.minecraft.entity.player.EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; int id = in.readInt(); Entity entity = player.worldObj.getEntityByID(id); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/npc/RemoteFreezeGetPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/npc/RemoteFreezeGetPacket.java index 7eeede76c..dd9f621ae 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/npc/RemoteFreezeGetPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/npc/RemoteFreezeGetPacket.java @@ -41,7 +41,7 @@ public final class RemoteFreezeGetPacket extends AbstractPacket { public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; ScrollSelectedPacket.setSelectedList((EntityPlayerMP) player, CustomNpcs.FreezeNPCs ? "Unfreeze NPCs" : "Freeze NPCs"); } diff --git a/src/main/java/kamkeel/npcs/network/packets/request/npc/RemoteFreezePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/npc/RemoteFreezePacket.java index 0604bedae..f212f6102 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/npc/RemoteFreezePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/npc/RemoteFreezePacket.java @@ -47,7 +47,7 @@ public final class RemoteFreezePacket extends AbstractPacket { public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; CustomNpcs.FreezeNPCs = !CustomNpcs.FreezeNPCs; ScrollSelectedPacket.setSelectedList((EntityPlayerMP) player, CustomNpcs.FreezeNPCs ? "Unfreeze NPCs" : "Freeze NPCs"); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/npc/RemoteGlobalMenuPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/npc/RemoteGlobalMenuPacket.java index e2f4a2af2..89887815a 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/npc/RemoteGlobalMenuPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/npc/RemoteGlobalMenuPacket.java @@ -50,7 +50,7 @@ public final class RemoteGlobalMenuPacket extends AbstractPacket { public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; NoppesUtilServer.sendOpenGui(player, EnumGuiType.GlobalRemote, null); if (ConfigDebug.PlayerLogging && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) { diff --git a/src/main/java/kamkeel/npcs/network/packets/request/npc/RemoteMainMenuPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/npc/RemoteMainMenuPacket.java index 5f9d1480b..bd50e6deb 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/npc/RemoteMainMenuPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/npc/RemoteMainMenuPacket.java @@ -60,7 +60,7 @@ public final class RemoteMainMenuPacket extends AbstractPacket { public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; Entity entity = player.worldObj.getEntityByID(in.readInt()); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/npc/RemoteNpcsGetPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/npc/RemoteNpcsGetPacket.java index 6d4e84647..6cdb43e5e 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/npc/RemoteNpcsGetPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/npc/RemoteNpcsGetPacket.java @@ -46,7 +46,7 @@ public final class RemoteNpcsGetPacket extends AbstractPacket { public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; NoppesUtilServer.sendNearbyNpcs((EntityPlayerMP) player); } diff --git a/src/main/java/kamkeel/npcs/network/packets/request/npc/RemoteResetPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/npc/RemoteResetPacket.java index 15eb7945b..f90acfe2a 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/npc/RemoteResetPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/npc/RemoteResetPacket.java @@ -55,7 +55,7 @@ public final class RemoteResetPacket extends AbstractPacket { public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; Entity entity = player.worldObj.getEntityByID(in.readInt()); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/npc/RemoteTpToNpcPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/npc/RemoteTpToNpcPacket.java index 7b4ddf036..587832ad4 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/npc/RemoteTpToNpcPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/npc/RemoteTpToNpcPacket.java @@ -54,7 +54,7 @@ public final class RemoteTpToNpcPacket extends AbstractPacket { public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; Entity entity = player.worldObj.getEntityByID(in.readInt()); if (!(entity instanceof EntityNPCInterface)) diff --git a/src/main/java/kamkeel/npcs/network/packets/request/party/PartyAcceptInvitePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/party/PartyAcceptInvitePacket.java index be9bf04ba..8a0c3ee75 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/party/PartyAcceptInvitePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/party/PartyAcceptInvitePacket.java @@ -9,7 +9,6 @@ import kamkeel.npcs.network.PacketHandler; import kamkeel.npcs.network.enums.EnumRequestPacket; import kamkeel.npcs.util.ByteBufUtils; import net.minecraft.entity.player.EntityPlayer; -import noppes.npcs.controllers.PlayerDataController; import noppes.npcs.controllers.data.PlayerData; import java.io.IOException; @@ -46,7 +45,7 @@ public final class PartyAcceptInvitePacket extends AbstractPacket { @Override public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { - PlayerData playerData = PlayerDataController.Instance.getPlayerData(player); + PlayerData playerData = PlayerData.get(player); String uuidString = ByteBufUtils.readString(in); if (uuidString != null) { UUID uuid = UUID.fromString(uuidString); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/party/PartyDisbandPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/party/PartyDisbandPacket.java index e22f8f349..2fdc81257 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/party/PartyDisbandPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/party/PartyDisbandPacket.java @@ -12,7 +12,6 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.nbt.NBTTagCompound; import noppes.npcs.controllers.PartyController; -import noppes.npcs.controllers.PlayerDataController; import noppes.npcs.controllers.data.PlayerData; import java.io.IOException; @@ -42,7 +41,7 @@ public final class PartyDisbandPacket extends AbstractPacket { @Override public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { - PlayerData playerData = PlayerDataController.Instance.getPlayerData(player); + PlayerData playerData = PlayerData.get(player); if (playerData.partyUUID != null) { PartyController.Instance().disbandParty(playerData.partyUUID); } diff --git a/src/main/java/kamkeel/npcs/network/packets/request/party/PartyIgnoreInvitePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/party/PartyIgnoreInvitePacket.java index bc8c5733b..30dbd1fa2 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/party/PartyIgnoreInvitePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/party/PartyIgnoreInvitePacket.java @@ -9,7 +9,6 @@ import kamkeel.npcs.network.PacketHandler; import kamkeel.npcs.network.enums.EnumRequestPacket; import kamkeel.npcs.util.ByteBufUtils; import net.minecraft.entity.player.EntityPlayer; -import noppes.npcs.controllers.PlayerDataController; import noppes.npcs.controllers.data.PlayerData; import java.io.IOException; @@ -46,7 +45,7 @@ public final class PartyIgnoreInvitePacket extends AbstractPacket { @Override public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { - PlayerData playerData = PlayerDataController.Instance.getPlayerData(player); + PlayerData playerData = PlayerData.get(player); String uuidString = ByteBufUtils.readString(in); if (uuidString != null) { UUID uuid = UUID.fromString(uuidString); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/party/PartyInfoPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/party/PartyInfoPacket.java index db5c4e090..2b7def180 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/party/PartyInfoPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/party/PartyInfoPacket.java @@ -16,7 +16,6 @@ import net.minecraft.nbt.NBTTagString; import noppes.npcs.config.ConfigMain; import noppes.npcs.constants.EnumQuestCompletion; import noppes.npcs.controllers.PartyController; -import noppes.npcs.controllers.PlayerDataController; import noppes.npcs.controllers.data.Party; import noppes.npcs.controllers.data.PlayerData; import noppes.npcs.controllers.data.Quest; @@ -71,7 +70,7 @@ public final class PartyInfoPacket extends AbstractPacket { } public static void sendPartyData(EntityPlayerMP player) { - PlayerData playerData = PlayerDataController.Instance.getPlayerData(player); + PlayerData playerData = PlayerData.get(player); if (playerData.partyUUID != null) { Party party = PartyController.Instance().getParty(playerData.partyUUID); NBTTagCompound compound = party.writeToNBT(); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/party/PartyInvitePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/party/PartyInvitePacket.java index 1ae14a308..297e8757d 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/party/PartyInvitePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/party/PartyInvitePacket.java @@ -17,7 +17,6 @@ import noppes.npcs.EventHooks; import noppes.npcs.NoppesUtilServer; import noppes.npcs.api.entity.IPlayer; import noppes.npcs.controllers.PartyController; -import noppes.npcs.controllers.PlayerDataController; import noppes.npcs.controllers.data.Party; import noppes.npcs.controllers.data.PlayerData; import noppes.npcs.scripted.NpcAPI; @@ -60,13 +59,13 @@ public final class PartyInvitePacket extends AbstractPacket { public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { EntityPlayer invitedPlayer = NoppesUtilServer.getPlayerByName(ByteBufUtils.readString(in)); if (invitedPlayer != null) { - PlayerData senderData = PlayerDataController.Instance.getPlayerData(player); - PlayerData invitedData = PlayerDataController.Instance.getPlayerData(invitedPlayer); + PlayerData senderData = PlayerData.get(player); + PlayerData invitedData = PlayerData.get(invitedPlayer); if (senderData.partyUUID != null && invitedData.partyUUID == null) { Party party = PartyController.Instance().getParty(senderData.partyUUID); if (!party.getIsLocked()) { PartyEvent.PartyInviteEvent partyEvent = new PartyEvent.PartyInviteEvent(party, party.getQuest(), (IPlayer) NpcAPI.Instance().getIEntity(invitedPlayer)); - EventHooks.onPartyInvite(partyEvent); + EventHooks.onPartyInvite(party, partyEvent); if (!partyEvent.isCancelled()) { invitedData.inviteToParty(party); sendInviteData((EntityPlayerMP) invitedPlayer); @@ -77,7 +76,7 @@ public final class PartyInvitePacket extends AbstractPacket { } public static void sendInviteData(EntityPlayerMP player) { - PlayerData playerData = PlayerDataController.Instance.getPlayerData(player); + PlayerData playerData = PlayerData.get(player); if (playerData.partyUUID == null) { NBTTagCompound compound = new NBTTagCompound(); NBTTagList list = new NBTTagList(); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/party/PartyKickPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/party/PartyKickPacket.java index 0a0d3b97c..c81e87a4d 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/party/PartyKickPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/party/PartyKickPacket.java @@ -61,7 +61,7 @@ public final class PartyKickPacket extends AbstractPacket { PlayerData playerData = null; UUID playerUUID = null; if (kickPlayer != null) { - playerData = PlayerDataController.Instance.getPlayerData(player); + playerData = PlayerData.get(player); } else { String uuid = PlayerDataController.Instance.getPlayerUUIDFromName(kickPlayerName); if (!uuid.isEmpty()) { @@ -75,7 +75,7 @@ public final class PartyKickPacket extends AbstractPacket { Party party = PartyController.Instance().getParty(playerData.partyUUID); if (!party.getIsLocked()) { PartyEvent.PartyKickEvent partyEvent = new PartyEvent.PartyKickEvent(party, party.getQuest(), (IPlayer) NpcAPI.Instance().getIEntity(kickPlayer)); - EventHooks.onPartyKick(partyEvent); + EventHooks.onPartyKick(party, partyEvent); if (!partyEvent.isCancelled()) { boolean successful = party.removePlayer(kickPlayer); if (!successful) diff --git a/src/main/java/kamkeel/npcs/network/packets/request/party/PartyLeavePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/party/PartyLeavePacket.java index 1a55d008a..d4e0ccf52 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/party/PartyLeavePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/party/PartyLeavePacket.java @@ -14,7 +14,6 @@ import noppes.npcs.EventHooks; import noppes.npcs.NoppesUtilServer; import noppes.npcs.api.entity.IPlayer; import noppes.npcs.controllers.PartyController; -import noppes.npcs.controllers.PlayerDataController; import noppes.npcs.controllers.data.Party; import noppes.npcs.controllers.data.PlayerData; import noppes.npcs.scripted.NpcAPI; @@ -57,13 +56,13 @@ public final class PartyLeavePacket extends AbstractPacket { public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { EntityPlayer leavingPlayer = NoppesUtilServer.getPlayerByName(ByteBufUtils.readString(in)); if (leavingPlayer != null) { - PlayerData playerData = PlayerDataController.Instance.getPlayerData(player); + PlayerData playerData = PlayerData.get(player); if (playerData.partyUUID != null) { Party party = PartyController.Instance().getParty(playerData.partyUUID); boolean successful = party.removePlayer(leavingPlayer); if (successful) { PartyEvent.PartyLeaveEvent partyEvent = new PartyEvent.PartyLeaveEvent(party, party.getQuest(), (IPlayer) NpcAPI.Instance().getIEntity(leavingPlayer)); - EventHooks.onPartyLeave(partyEvent); + EventHooks.onPartyLeave(party, partyEvent); sendInviteData((EntityPlayerMP) leavingPlayer); PartyController.Instance().pingPartyUpdate(party); PartyController.Instance().sendLeavingMessages(party, leavingPlayer); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/party/PartySavePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/party/PartySavePacket.java index 7248b6f27..f4f0987fd 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/party/PartySavePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/party/PartySavePacket.java @@ -11,7 +11,6 @@ import kamkeel.npcs.util.ByteBufUtils; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import noppes.npcs.controllers.PartyController; -import noppes.npcs.controllers.PlayerDataController; import noppes.npcs.controllers.data.Party; import noppes.npcs.controllers.data.PlayerData; @@ -48,7 +47,7 @@ public final class PartySavePacket extends AbstractPacket { @Override public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { - PlayerData playerData = PlayerDataController.Instance.getPlayerData(player); + PlayerData playerData = PlayerData.get(player); if (playerData.partyUUID != null) { Party party = PartyController.Instance().getParty(playerData.partyUUID); party.readClientNBT(ByteBufUtils.readNBT(in)); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/party/PartySetLeaderPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/party/PartySetLeaderPacket.java index 2d90068c8..006d6dfcc 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/party/PartySetLeaderPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/party/PartySetLeaderPacket.java @@ -11,7 +11,6 @@ import kamkeel.npcs.util.ByteBufUtils; import net.minecraft.entity.player.EntityPlayer; import noppes.npcs.NoppesUtilServer; import noppes.npcs.controllers.PartyController; -import noppes.npcs.controllers.PlayerDataController; import noppes.npcs.controllers.data.Party; import noppes.npcs.controllers.data.PlayerData; @@ -48,7 +47,7 @@ public final class PartySetLeaderPacket extends AbstractPacket { @Override public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { - PlayerData playerData = PlayerDataController.Instance.getPlayerData(player); + PlayerData playerData = PlayerData.get(player); if (playerData.partyUUID != null) { Party party = PartyController.Instance().getParty(playerData.partyUUID); if (!party.getIsLocked()) { diff --git a/src/main/java/kamkeel/npcs/network/packets/request/party/PartySetQuestPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/party/PartySetQuestPacket.java index 932b852c2..b17bc9e96 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/party/PartySetQuestPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/party/PartySetQuestPacket.java @@ -10,7 +10,6 @@ import kamkeel.npcs.network.enums.EnumRequestPacket; import net.minecraft.entity.player.EntityPlayer; import noppes.npcs.EventHooks; import noppes.npcs.controllers.PartyController; -import noppes.npcs.controllers.PlayerDataController; import noppes.npcs.controllers.QuestController; import noppes.npcs.controllers.data.Party; import noppes.npcs.controllers.data.PlayerData; @@ -51,7 +50,7 @@ public final class PartySetQuestPacket extends AbstractPacket { @Override public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { - PlayerData playerData = PlayerDataController.Instance.getPlayerData(player); + PlayerData playerData = PlayerData.get(player); if (playerData.partyUUID != null) { Party party = PartyController.Instance().getParty(playerData.partyUUID); if (party != null) { @@ -64,7 +63,7 @@ public final class PartySetQuestPacket extends AbstractPacket { if (foundQuest.partyOptions.allowParty) { if (party.validateQuest(questID, true)) { PartyEvent.PartyQuestSetEvent partyEvent = new PartyEvent.PartyQuestSetEvent(party, foundQuest); - EventHooks.onPartyQuestSet(partyEvent); + EventHooks.onPartyQuestSet(party, partyEvent); if (!partyEvent.isCancelled()) { if (playerData.questData.hasActiveQuest(questID)) { QuestData questdata = new QuestData(foundQuest); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/pather/MovingPathGetPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/pather/MovingPathGetPacket.java index 6f5679e68..4a9f594c2 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/pather/MovingPathGetPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/pather/MovingPathGetPacket.java @@ -47,7 +47,7 @@ public final class MovingPathGetPacket extends AbstractPacket { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.PATHER, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.PATHER, player)) return; GuiDataPacket.sendGuiData((EntityPlayerMP) player, npc.ais.writeToNBT(new NBTTagCompound())); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/pather/MovingPathSavePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/pather/MovingPathSavePacket.java index 258e76e37..75bc71c28 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/pather/MovingPathSavePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/pather/MovingPathSavePacket.java @@ -61,7 +61,7 @@ public final class MovingPathSavePacket extends AbstractPacket { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.PATHER, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.PATHER, player)) return; npc.ais.setMovingPath(NBTTags.getIntegerArraySet(ByteBufUtils.readNBT(in).getTagList("MovingPathNew", 10))); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/playerdata/PlayerDataGetNamesPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/playerdata/PlayerDataGetNamesPacket.java index cc5431e4a..707452806 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/playerdata/PlayerDataGetNamesPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/playerdata/PlayerDataGetNamesPacket.java @@ -54,7 +54,7 @@ public final class PlayerDataGetNamesPacket extends AbstractPacket { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; int id = in.readInt(); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/playerdata/PlayerDataMapRegenPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/playerdata/PlayerDataMapRegenPacket.java index dec497e86..a05b527f3 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/playerdata/PlayerDataMapRegenPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/playerdata/PlayerDataMapRegenPacket.java @@ -47,7 +47,7 @@ public final class PlayerDataMapRegenPacket extends AbstractPacket { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; NoppesUtilServer.regenPlayerData((EntityPlayerMP) player); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/playerdata/PlayerDataRemovePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/playerdata/PlayerDataRemovePacket.java index 7002a7f06..fbe8c7991 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/playerdata/PlayerDataRemovePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/playerdata/PlayerDataRemovePacket.java @@ -74,7 +74,7 @@ public final class PlayerDataRemovePacket extends AbstractPacket { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; NoppesUtilServer.removePlayerData(in, (EntityPlayerMP) player); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/quest/QuestCategoriesGetPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/quest/QuestCategoriesGetPacket.java index 3448acf92..743c9a075 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/quest/QuestCategoriesGetPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/quest/QuestCategoriesGetPacket.java @@ -41,7 +41,7 @@ public final class QuestCategoriesGetPacket extends AbstractPacket { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(player, EnumItemPacketType.WAND, EnumItemPacketType.BLOCK)) + if (!PacketUtil.verifyItemPacket(packetName, player, EnumItemPacketType.WAND, EnumItemPacketType.BLOCK)) return; NoppesUtilServer.sendQuestCategoryData((EntityPlayerMP) player); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/quest/QuestCategoryGetPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/quest/QuestCategoryGetPacket.java index 0404a5ab8..5d8f8c571 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/quest/QuestCategoryGetPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/quest/QuestCategoryGetPacket.java @@ -51,7 +51,7 @@ public final class QuestCategoryGetPacket extends AbstractPacket { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; int id = in.readInt(); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/quest/QuestCategoryRemovePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/quest/QuestCategoryRemovePacket.java index bad9bfe95..333d77da4 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/quest/QuestCategoryRemovePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/quest/QuestCategoryRemovePacket.java @@ -55,7 +55,7 @@ public final class QuestCategoryRemovePacket extends AbstractPacket { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; int id = in.readInt(); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/quest/QuestCategorySavePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/quest/QuestCategorySavePacket.java index 76695d132..f4a28b443 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/quest/QuestCategorySavePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/quest/QuestCategorySavePacket.java @@ -58,7 +58,7 @@ public final class QuestCategorySavePacket extends AbstractPacket { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; NBTTagCompound compound = ByteBufUtils.readNBT(in); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/quest/QuestDialogGetTitlePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/quest/QuestDialogGetTitlePacket.java index e78955678..c3080f586 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/quest/QuestDialogGetTitlePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/quest/QuestDialogGetTitlePacket.java @@ -63,7 +63,7 @@ public final class QuestDialogGetTitlePacket extends AbstractPacket { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; Dialog quest = DialogController.Instance.dialogs.get(in.readInt()); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/quest/QuestGetPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/quest/QuestGetPacket.java index 4ccb34399..979f21f47 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/quest/QuestGetPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/quest/QuestGetPacket.java @@ -48,7 +48,7 @@ public final class QuestGetPacket extends AbstractPacket { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(player, EnumItemPacketType.WAND, EnumItemPacketType.BLOCK)) + if (!PacketUtil.verifyItemPacket(packetName, player, EnumItemPacketType.WAND, EnumItemPacketType.BLOCK)) return; Quest quest = QuestController.Instance.quests.get(in.readInt()); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/quest/QuestOpenGuiPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/quest/QuestOpenGuiPacket.java index 83d175d6d..e6673f877 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/quest/QuestOpenGuiPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/quest/QuestOpenGuiPacket.java @@ -56,7 +56,7 @@ public final class QuestOpenGuiPacket extends AbstractPacket { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; int gui = in.readInt(); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/quest/QuestRemovePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/quest/QuestRemovePacket.java index 176e63364..622f36375 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/quest/QuestRemovePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/quest/QuestRemovePacket.java @@ -58,7 +58,7 @@ public final class QuestRemovePacket extends AbstractPacket { public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; Quest quest = QuestController.Instance.quests.get(in.readInt()); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/quest/QuestSavePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/quest/QuestSavePacket.java index 7a5f6f65e..9fdfbb78e 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/quest/QuestSavePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/quest/QuestSavePacket.java @@ -64,7 +64,7 @@ public final class QuestSavePacket extends AbstractPacket { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; int cat = in.readInt(); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/quest/QuestsGetPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/quest/QuestsGetPacket.java index 206f7d375..fa0ba0c3d 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/quest/QuestsGetPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/quest/QuestsGetPacket.java @@ -53,7 +53,7 @@ public final class QuestsGetPacket extends AbstractPacket { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(player, EnumItemPacketType.WAND, EnumItemPacketType.BLOCK)) + if (!PacketUtil.verifyItemPacket(packetName, player, EnumItemPacketType.WAND, EnumItemPacketType.BLOCK)) return; QuestCategory category = QuestController.Instance.categories.get(in.readInt()); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/recipe/RecipeGetPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/recipe/RecipeGetPacket.java index 31b0223d9..34f41df20 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/recipe/RecipeGetPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/recipe/RecipeGetPacket.java @@ -54,7 +54,7 @@ public final class RecipeGetPacket extends AbstractPacket { public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; int id = in.readInt(); boolean anvil = in.readBoolean(); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/recipe/RecipeRemovePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/recipe/RecipeRemovePacket.java index b0bbbdf67..6616ce33a 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/recipe/RecipeRemovePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/recipe/RecipeRemovePacket.java @@ -59,7 +59,7 @@ public final class RecipeRemovePacket extends AbstractPacket { public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; int id = in.readInt(); boolean anvil = in.readBoolean(); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/recipe/RecipeSavePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/recipe/RecipeSavePacket.java index 59d4f8a57..428925691 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/recipe/RecipeSavePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/recipe/RecipeSavePacket.java @@ -58,7 +58,7 @@ public final class RecipeSavePacket extends AbstractPacket { public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; NBTTagCompound compound = ByteBufUtils.readNBT(in); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/recipe/RecipesGetPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/recipe/RecipesGetPacket.java index cf148693d..3172556c8 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/recipe/RecipesGetPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/recipe/RecipesGetPacket.java @@ -46,7 +46,7 @@ public final class RecipesGetPacket extends AbstractPacket { @Override public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) return; + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; int id = in.readInt(); NoppesUtilServer.sendRecipeData((EntityPlayerMP) player, id); } diff --git a/src/main/java/kamkeel/npcs/network/packets/request/role/RoleCompanionUpdatePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/role/RoleCompanionUpdatePacket.java index 2b448b7de..d64203eca 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/role/RoleCompanionUpdatePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/role/RoleCompanionUpdatePacket.java @@ -42,7 +42,7 @@ public final class RoleCompanionUpdatePacket extends AbstractPacket { @Override public CustomNpcsPermissions.Permission getPermission() { - return CustomNpcsPermissions.NPC_ADVANCED; + return CustomNpcsPermissions.NPC_ADVANCED_ROLE; } @Override @@ -61,7 +61,7 @@ public final class RoleCompanionUpdatePacket extends AbstractPacket { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; if (npc.advanced.role != EnumRoleType.Companion) diff --git a/src/main/java/kamkeel/npcs/network/packets/request/role/RoleGetPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/role/RoleGetPacket.java index 2bf45aa26..762a34ca4 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/role/RoleGetPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/role/RoleGetPacket.java @@ -47,7 +47,7 @@ public final class RoleGetPacket extends AbstractPacket { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; if (npc.roleInterface == null) diff --git a/src/main/java/kamkeel/npcs/network/packets/request/role/RoleSavePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/role/RoleSavePacket.java index 6f0180b2c..d63f2603c 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/role/RoleSavePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/role/RoleSavePacket.java @@ -41,7 +41,7 @@ public final class RoleSavePacket extends AbstractPacket { @Override public CustomNpcsPermissions.Permission getPermission() { - return CustomNpcsPermissions.NPC_ADVANCED; + return CustomNpcsPermissions.NPC_ADVANCED_ROLE; } @Override @@ -60,7 +60,7 @@ public final class RoleSavePacket extends AbstractPacket { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; npc.roleInterface.readFromNBT(ByteBufUtils.readNBT(in)); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/script/EffectScriptPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/script/EffectScriptPacket.java index d8330f8fe..66da65d8f 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/script/EffectScriptPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/script/EffectScriptPacket.java @@ -17,6 +17,7 @@ import noppes.npcs.config.ConfigScript; import noppes.npcs.controllers.CustomEffectController; import noppes.npcs.controllers.data.CustomEffect; import noppes.npcs.controllers.data.EffectScript; +import noppes.npcs.controllers.data.IScriptHandler; import java.io.IOException; @@ -83,7 +84,7 @@ public final class EffectScriptPacket extends AbstractPacket { EffectScript data = effect.getOrCreateScriptHandler(); if (requestedAction == Action.GET) { - PacketUtil.getScripts(data, (EntityPlayerMP) player); + PacketUtil.getScripts((IScriptHandler) data, (EntityPlayerMP) player); } else { data.saveScript(in); if (ConfigDebug.PlayerLogging && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) { diff --git a/src/main/java/kamkeel/npcs/network/packets/request/script/EventScriptPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/script/EventScriptPacket.java index b6a9553b1..72d3c66bc 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/script/EventScriptPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/script/EventScriptPacket.java @@ -77,7 +77,7 @@ public final class EventScriptPacket extends AbstractPacket { if (!ConfigScript.canScript(player, CustomNpcsPermissions.SCRIPT)) return; - if (!PacketUtil.verifyItemPacket(player, EnumItemPacketType.SCRIPTER)) + if (!PacketUtil.verifyItemPacket(packetName, player, EnumItemPacketType.SCRIPTER)) return; Action requestedAction = Action.values()[in.readInt()]; diff --git a/src/main/java/kamkeel/npcs/network/packets/request/script/ForgeScriptPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/script/ForgeScriptPacket.java index 774bff56f..11d625988 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/script/ForgeScriptPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/script/ForgeScriptPacket.java @@ -14,6 +14,7 @@ import noppes.npcs.CustomNpcsPermissions; import noppes.npcs.config.ConfigScript; import noppes.npcs.controllers.ScriptController; import noppes.npcs.controllers.data.ForgeDataScript; +import noppes.npcs.controllers.data.IScriptHandler; import java.io.IOException; @@ -70,13 +71,13 @@ public final class ForgeScriptPacket extends AbstractPacket { if (!ConfigScript.canScript(player, CustomNpcsPermissions.SCRIPT)) return; - if (!PacketUtil.verifyItemPacket(player, EnumItemPacketType.SCRIPTER)) + if (!PacketUtil.verifyItemPacket(packetName, player, EnumItemPacketType.SCRIPTER)) return; Action requestedAction = Action.values()[in.readInt()]; ForgeDataScript data = ScriptController.Instance.forgeScripts; if (requestedAction == Action.GET) { - PacketUtil.getScripts(data, (EntityPlayerMP) player); + PacketUtil.getScripts((IScriptHandler) data, (EntityPlayerMP) player); } else { int tab = in.getInt(in.readerIndex()); PacketUtil.saveScripts(data, in); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/script/GlobalNPCScriptPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/script/GlobalNPCScriptPacket.java index 5fbc1a014..bb07fac73 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/script/GlobalNPCScriptPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/script/GlobalNPCScriptPacket.java @@ -14,6 +14,7 @@ import noppes.npcs.CustomNpcsPermissions; import noppes.npcs.config.ConfigScript; import noppes.npcs.controllers.ScriptController; import noppes.npcs.controllers.data.GlobalNPCDataScript; +import noppes.npcs.controllers.data.IScriptHandler; import java.io.IOException; @@ -70,13 +71,13 @@ public final class GlobalNPCScriptPacket extends AbstractPacket { if (!ConfigScript.canScript(player, CustomNpcsPermissions.SCRIPT)) return; - if (!PacketUtil.verifyItemPacket(player, EnumItemPacketType.SCRIPTER)) + if (!PacketUtil.verifyItemPacket(packetName, player, EnumItemPacketType.SCRIPTER)) return; Action requestedAction = Action.values()[in.readInt()]; GlobalNPCDataScript data = ScriptController.Instance.globalNpcScripts; if (requestedAction == Action.GET) { - PacketUtil.getScripts(data, (EntityPlayerMP) player); + PacketUtil.getScripts((IScriptHandler) data, (EntityPlayerMP) player); } else { int tab = in.getInt(in.readerIndex()); PacketUtil.saveScripts(data, in); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/script/NPCScriptPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/script/NPCScriptPacket.java index 2a775ea30..c2dc13165 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/script/NPCScriptPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/script/NPCScriptPacket.java @@ -72,7 +72,7 @@ public final class NPCScriptPacket extends AbstractPacket { if (!ConfigScript.canScript(player, CustomNpcsPermissions.SCRIPT)) return; - if (!PacketUtil.verifyItemPacket(player, EnumItemPacketType.SCRIPTER)) + if (!PacketUtil.verifyItemPacket(packetName, player, EnumItemPacketType.SCRIPTER)) return; Action requestedAction = Action.values()[in.readInt()]; diff --git a/src/main/java/kamkeel/npcs/network/packets/request/script/PlayerScriptPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/script/PlayerScriptPacket.java index 3b71cfc28..93b7cc387 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/script/PlayerScriptPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/script/PlayerScriptPacket.java @@ -13,6 +13,7 @@ import net.minecraft.nbt.NBTTagCompound; import noppes.npcs.CustomNpcsPermissions; import noppes.npcs.config.ConfigScript; import noppes.npcs.controllers.ScriptController; +import noppes.npcs.controllers.data.IScriptHandler; import noppes.npcs.controllers.data.PlayerDataScript; import java.io.IOException; @@ -70,13 +71,13 @@ public final class PlayerScriptPacket extends AbstractPacket { if (!ConfigScript.canScript(player, CustomNpcsPermissions.SCRIPT)) return; - if (!PacketUtil.verifyItemPacket(player, EnumItemPacketType.SCRIPTER)) + if (!PacketUtil.verifyItemPacket(packetName, player, EnumItemPacketType.SCRIPTER)) return; Action requestedAction = Action.values()[in.readInt()]; PlayerDataScript data = ScriptController.Instance.playerScripts; if (requestedAction == Action.GET) { - PacketUtil.getScripts(data, (EntityPlayerMP) player); + PacketUtil.getScripts((IScriptHandler) data, (EntityPlayerMP) player); } else { int tab = in.getInt(in.readerIndex()); PacketUtil.saveScripts(data, in); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/script/ScriptInfoPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/script/ScriptInfoPacket.java index 7a8f5fe39..337522882 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/script/ScriptInfoPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/script/ScriptInfoPacket.java @@ -63,7 +63,7 @@ public final class ScriptInfoPacket extends AbstractPacket { if (!ConfigScript.canScript(player, CustomNpcsPermissions.SCRIPT)) return; - if (!PacketUtil.verifyItemPacket(player, EnumItemPacketType.SCRIPTER)) + if (!PacketUtil.verifyItemPacket(packetName, player, EnumItemPacketType.SCRIPTER)) return; Action requestedAction = Action.values()[in.readInt()]; diff --git a/src/main/java/kamkeel/npcs/network/packets/request/script/item/LinkedItemScriptPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/script/item/LinkedItemScriptPacket.java index fa3517529..8b5ec164f 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/script/item/LinkedItemScriptPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/script/item/LinkedItemScriptPacket.java @@ -15,6 +15,7 @@ import noppes.npcs.LogWriter; import noppes.npcs.config.ConfigDebug; import noppes.npcs.config.ConfigScript; import noppes.npcs.controllers.LinkedItemController; +import noppes.npcs.controllers.data.IScriptHandler; import noppes.npcs.controllers.data.LinkedItem; import noppes.npcs.controllers.data.LinkedItemScript; @@ -83,7 +84,7 @@ public final class LinkedItemScriptPacket extends AbstractPacket { LinkedItemScript data = linkedItem.getOrCreateScriptHandler(); if (requestedAction == Action.GET) { - PacketUtil.getScripts(data, (EntityPlayerMP) player); + PacketUtil.getScripts((IScriptHandler) data, (EntityPlayerMP) player); } else { data.saveScript(in); if (ConfigDebug.PlayerLogging && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) { diff --git a/src/main/java/kamkeel/npcs/network/packets/request/tags/TagGetPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/tags/TagGetPacket.java index 6438fd4b4..2a565c828 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/tags/TagGetPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/tags/TagGetPacket.java @@ -48,7 +48,7 @@ public final class TagGetPacket extends AbstractPacket { @Override public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { - if (!PacketUtil.verifyItemPacket(player, EnumItemPacketType.WAND, EnumItemPacketType.CLONER)) + if (!PacketUtil.verifyItemPacket(packetName, player, EnumItemPacketType.WAND, EnumItemPacketType.CLONER)) return; NBTTagCompound compound = new NBTTagCompound(); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/tags/TagRemovePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/tags/TagRemovePacket.java index 8d3d90a81..fb2207ec7 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/tags/TagRemovePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/tags/TagRemovePacket.java @@ -47,11 +47,6 @@ public final class TagRemovePacket extends AbstractPacket { return CustomNpcsPermissions.GLOBAL_TAG; } - @Override - public boolean needsNPC() { - return false; - } - @SideOnly(Side.CLIENT) @Override public void sendData(ByteBuf out) throws IOException { @@ -63,7 +58,7 @@ public final class TagRemovePacket extends AbstractPacket { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; int id = in.readInt(); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/tags/TagSavePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/tags/TagSavePacket.java index 6b79c5b8b..0577ba8d7 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/tags/TagSavePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/tags/TagSavePacket.java @@ -48,11 +48,6 @@ public final class TagSavePacket extends AbstractPacket { return CustomNpcsPermissions.GLOBAL_TAG; } - @Override - public boolean needsNPC() { - return false; - } - @SideOnly(Side.CLIENT) @Override public void sendData(ByteBuf out) throws IOException { @@ -64,7 +59,7 @@ public final class TagSavePacket extends AbstractPacket { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; Tag tag = new Tag(); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/tags/TagSetPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/tags/TagSetPacket.java index 271143276..93a26505e 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/tags/TagSetPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/tags/TagSetPacket.java @@ -44,7 +44,7 @@ public final class TagSetPacket extends AbstractPacket { @Override public CustomNpcsPermissions.Permission getPermission() { - return CustomNpcsPermissions.NPC_ADVANCED; + return CustomNpcsPermissions.NPC_ADVANCED_TAGS; } @Override @@ -62,7 +62,7 @@ public final class TagSetPacket extends AbstractPacket { public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(player, EnumItemPacketType.WAND, EnumItemPacketType.CLONER)) + if (!PacketUtil.verifyItemPacket(packetName, player, EnumItemPacketType.WAND, EnumItemPacketType.CLONER)) return; this.setTags(npc, in); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/tags/TagsGetPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/tags/TagsGetPacket.java index 4b303b65e..4414131f1 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/tags/TagsGetPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/tags/TagsGetPacket.java @@ -38,7 +38,7 @@ public final class TagsGetPacket extends AbstractPacket { @Override public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { - if (!PacketUtil.verifyItemPacket(player, EnumItemPacketType.WAND, EnumItemPacketType.CLONER)) + if (!PacketUtil.verifyItemPacket(packetName, player, EnumItemPacketType.WAND, EnumItemPacketType.CLONER)) return; NoppesUtilServer.sendTagDataAll((EntityPlayerMP) player); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/tags/TagsNpcGetPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/tags/TagsNpcGetPacket.java index cba3e9de9..305386fb9 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/tags/TagsNpcGetPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/tags/TagsNpcGetPacket.java @@ -49,7 +49,7 @@ public final class TagsNpcGetPacket extends AbstractPacket { @Override public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { - if (!PacketUtil.verifyItemPacket(player, EnumItemPacketType.WAND, EnumItemPacketType.CLONER)) + if (!PacketUtil.verifyItemPacket(packetName, player, EnumItemPacketType.WAND, EnumItemPacketType.CLONER)) return; NBTTagCompound compound = new NBTTagCompound(); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/transform/TransformGetPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/transform/TransformGetPacket.java index 0f2400af7..95a8d66d0 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/transform/TransformGetPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/transform/TransformGetPacket.java @@ -35,7 +35,7 @@ public final class TransformGetPacket extends AbstractPacket { @Override public CustomNpcsPermissions.Permission getPermission() { - return CustomNpcsPermissions.NPC_ADVANCED; + return CustomNpcsPermissions.NPC_ADVANCED_TRANSFORM; } @Override @@ -53,7 +53,7 @@ public final class TransformGetPacket extends AbstractPacket { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; GuiDataPacket.sendGuiData((EntityPlayerMP) player, npc.transform.writeOptions(new NBTTagCompound())); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/transform/TransformLoadPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/transform/TransformLoadPacket.java index 7d7c19876..bd651539e 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/transform/TransformLoadPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/transform/TransformLoadPacket.java @@ -39,7 +39,7 @@ public final class TransformLoadPacket extends AbstractPacket { @Override public CustomNpcsPermissions.Permission getPermission() { - return CustomNpcsPermissions.NPC_ADVANCED; + return CustomNpcsPermissions.NPC_ADVANCED_TRANSFORM; } @Override @@ -58,7 +58,7 @@ public final class TransformLoadPacket extends AbstractPacket { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; if (npc.transform.isValid()) diff --git a/src/main/java/kamkeel/npcs/network/packets/request/transform/TransformSavePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/transform/TransformSavePacket.java index 4f1e85ebd..2e8f82f34 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/transform/TransformSavePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/transform/TransformSavePacket.java @@ -41,7 +41,7 @@ public final class TransformSavePacket extends AbstractPacket { @Override public CustomNpcsPermissions.Permission getPermission() { - return CustomNpcsPermissions.NPC_ADVANCED; + return CustomNpcsPermissions.NPC_ADVANCED_TRANSFORM; } @Override @@ -60,7 +60,7 @@ public final class TransformSavePacket extends AbstractPacket { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; boolean isValid = npc.transform.isValid(); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/transport/TransportCategoriesGetPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/transport/TransportCategoriesGetPacket.java index 800befc48..c59e072ef 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/transport/TransportCategoriesGetPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/transport/TransportCategoriesGetPacket.java @@ -41,7 +41,7 @@ public final class TransportCategoriesGetPacket extends AbstractPacket { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; NoppesUtilServer.sendTransportCategoryData((EntityPlayerMP) player); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/transport/TransportCategoryRemovePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/transport/TransportCategoryRemovePacket.java index ca85a6f51..8cef5cf34 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/transport/TransportCategoryRemovePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/transport/TransportCategoryRemovePacket.java @@ -55,7 +55,7 @@ public final class TransportCategoryRemovePacket extends AbstractPacket { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; int id = in.readInt(); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/transport/TransportCategorySavePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/transport/TransportCategorySavePacket.java index d443c1c5c..86bec4b99 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/transport/TransportCategorySavePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/transport/TransportCategorySavePacket.java @@ -58,7 +58,7 @@ public final class TransportCategorySavePacket extends AbstractPacket { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; String name = ByteBufUtils.readString(in); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/transport/TransportGetLocationPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/transport/TransportGetLocationPacket.java index dbcbe2bd9..acbbe8016 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/transport/TransportGetLocationPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/transport/TransportGetLocationPacket.java @@ -49,7 +49,7 @@ public final class TransportGetLocationPacket extends AbstractPacket { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; if (npc.advanced.role != EnumRoleType.Transporter) diff --git a/src/main/java/kamkeel/npcs/network/packets/request/transport/TransportRemovePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/transport/TransportRemovePacket.java index fe9e12922..b309c0e16 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/transport/TransportRemovePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/transport/TransportRemovePacket.java @@ -56,7 +56,7 @@ public final class TransportRemovePacket extends AbstractPacket { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; int id = in.readInt(); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/transport/TransportSavePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/transport/TransportSavePacket.java index b4aad2e92..f31a3ab1b 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/transport/TransportSavePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/transport/TransportSavePacket.java @@ -47,7 +47,7 @@ public final class TransportSavePacket extends AbstractPacket { @Override public CustomNpcsPermissions.Permission getPermission() { - return CustomNpcsPermissions.NPC_ADVANCED; + return CustomNpcsPermissions.NPC_ADVANCED_TRANSPORT; } @Override @@ -67,7 +67,7 @@ public final class TransportSavePacket extends AbstractPacket { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; int cat = in.readInt(); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/transport/TransportsGetPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/transport/TransportsGetPacket.java index 4569b7a40..64c5d7b71 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/transport/TransportsGetPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/transport/TransportsGetPacket.java @@ -48,7 +48,7 @@ public final class TransportsGetPacket extends AbstractPacket { if (!(player instanceof EntityPlayerMP)) return; - if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) return; int id = in.readInt(); diff --git a/src/main/java/kamkeel/npcs/util/AttributeAttackUtil.java b/src/main/java/kamkeel/npcs/util/AttributeAttackUtil.java index 399d0457c..918d74157 100644 --- a/src/main/java/kamkeel/npcs/util/AttributeAttackUtil.java +++ b/src/main/java/kamkeel/npcs/util/AttributeAttackUtil.java @@ -36,12 +36,14 @@ public class AttributeAttackUtil { private static AllocationResult allocateMagicDamage(float physicalDamage, Map magicData) { Map allocation = new HashMap<>(); float totalSplit = 0f; - for (Map.Entry entry : magicData.entrySet()) { - int magicId = entry.getKey(); - float splitVal = entry.getValue().split; - float allocated = (physicalDamage * splitVal) + entry.getValue().damage; - allocation.put(magicId, allocated); - totalSplit += splitVal; + if(magicData != null){ + for (Map.Entry entry : magicData.entrySet()) { + int magicId = entry.getKey(); + float splitVal = entry.getValue().split; + float allocated = (physicalDamage * splitVal) + entry.getValue().damage; + allocation.put(magicId, allocated); + totalSplit += splitVal; + } } // Ensure double arithmetic for subtraction, then cast back to float. float leftover = physicalDamage * (float) Math.max(0d, 1d - totalSplit); @@ -59,7 +61,7 @@ public class AttributeAttackUtil { int magicId = entry.getKey(); float damage = entry.getValue(); float boost = magicBoost.getOrDefault(magicId, 0f); - damage *= (1 + (boost / 100)); + damage *= (1 + (boost / 100f)); allocation.put(magicId, allocation.getOrDefault(magicId, 0f) + damage); } } @@ -164,8 +166,8 @@ public class AttributeAttackUtil { if (ConfigMain.AttributesEnabled) { float critChance = tracker.getAttributeValue(CustomAttributes.CRITICAL_CHANCE); float critBonus = tracker.getAttributeValue(CustomAttributes.CRITICAL_DAMAGE); - if (random.nextFloat() < (critChance / 100)) - damage = (damage * (1 + (float) ConfigMain.AttributesCriticalBoost / 100)) + critBonus; + if (random.nextFloat() < (critChance / 100f)) + damage = (damage * (1 + (float) ConfigMain.AttributesCriticalBoost / 100f)) + critBonus; } return damage; } @@ -173,8 +175,8 @@ public class AttributeAttackUtil { public static float applyMainAttack(float damage, PlayerAttributeTracker tracker) { if (ConfigMain.AttributesEnabled) { float mainAttack = tracker.getAttributeValue(CustomAttributes.MAIN_ATTACK); - float mainBoost = tracker.getAttributeValue(CustomAttributes.MAIN_BOOST) + 1; - damage = (damage * mainBoost) + mainAttack; + float mainBoost = tracker.getAttributeValue(CustomAttributes.MAIN_BOOST) / 100f; + damage = (damage * (1 + mainBoost)) + mainAttack; } return damage; } @@ -183,7 +185,7 @@ public class AttributeAttackUtil { if (ConfigMain.AttributesEnabled) { float neutralDamage = tracker.getAttributeValue(CustomAttributes.NEUTRAL_ATTACK); float neutralBoost = tracker.getAttributeValue(CustomAttributes.NEUTRAL_BOOST); - leftover += neutralDamage * (1 + (neutralBoost / 100)); + leftover += neutralDamage * (1 + (neutralBoost / 100f)); } return leftover; } @@ -204,11 +206,7 @@ public class AttributeAttackUtil { MagicController magicController = MagicController.getInstance(); Set defenderMagicIDs = new HashSet<>(defenderData.magicData.getMagics().keySet()); applyMagicInteractions(result.allocation, defenderMagicIDs, magicController); - - float adjustedMagic = 0f; - for (float val : result.allocation.values()) - adjustedMagic += val; - + float adjustedMagic = applyDefenderMagicDefense(result.allocation, defender, magicController); return leftover + adjustedMagic; } @@ -217,7 +215,7 @@ public class AttributeAttackUtil { */ public static float calculateGearOutput(PlayerAttributeTracker attacker) { float neutralDamage = attacker.getAttributeValue(CustomAttributes.NEUTRAL_ATTACK); - float neutralBoost = attacker.getAttributeValue(CustomAttributes.NEUTRAL_BOOST) + 1; + float neutralBoost = 1 + (attacker.getAttributeValue(CustomAttributes.NEUTRAL_BOOST) / 100f); float neutralTotal = neutralDamage * neutralBoost; float magicTotal = 0f; @@ -227,22 +225,31 @@ public class AttributeAttackUtil { if (magicController.getMagic(magicId) != null) { float attackMagic = entry.getValue(); float boostMagic = attacker.magicBoost.getOrDefault(magicId, 0f); - magicTotal += Math.max(0, attackMagic * (boostMagic + 1)); + magicTotal += Math.max(0, attackMagic * ((boostMagic / 100f) + 1f)); } } return neutralTotal + magicTotal; } /** - * Calculates a player's outgoing damage based on base damage and main attack attributes. + * Calculates a player's outgoing damage based on weapon damage + main-attack attributes, + * plus all neutral/magic damage from gear. */ - public static float calculateOutgoing(EntityPlayer entityPlayer, float baseDamage) { - if (ConfigMain.AttributesEnabled) { - PlayerAttributeTracker attacker = getTracker(entityPlayer); - float mainAttack = attacker.getAttributeValue(CustomAttributes.MAIN_ATTACK); - float mainBoost = attacker.getAttributeValue(CustomAttributes.MAIN_BOOST) + 1; - return attacker.gearOutput + (baseDamage * mainBoost) + mainAttack; + public static float calculateOutgoing(EntityPlayer player, float baseDamage) { + if (!ConfigMain.AttributesEnabled) { + return baseDamage; } - return baseDamage; + + PlayerAttributeTracker tracker = getTracker(player); + + // 1) Main-attack component + float mainAttackFlat = tracker.getAttributeValue(CustomAttributes.MAIN_ATTACK); + float mainBoostPercent = tracker.getAttributeValue(CustomAttributes.MAIN_BOOST) / 100f; + float mainDamage = (baseDamage * (1 + mainBoostPercent)) + mainAttackFlat; + + // 2) Gear component (neutral + magic) – gearOutput must itself divide its boosts by 100 internally + float gearDamage = tracker.gearOutput; + + return mainDamage + gearDamage; } } diff --git a/src/main/java/kamkeel/npcs/util/AttributeItemUtil.java b/src/main/java/kamkeel/npcs/util/AttributeItemUtil.java index 3a51ba4a0..943821428 100644 --- a/src/main/java/kamkeel/npcs/util/AttributeItemUtil.java +++ b/src/main/java/kamkeel/npcs/util/AttributeItemUtil.java @@ -249,6 +249,9 @@ public class AttributeItemUtil { // For non–magic we include everything. Float value = attrTag.getFloat(key); AttributeDefinition def = AttributeController.getAttribute(key); + if(def == null) + continue; + AttributeDefinition.AttributeSection section = def != null ? def.getSection() : AttributeDefinition.AttributeSection.EXTRA; String plainName = getTranslatedAttributeName(key, def); // unformatted name String formattedLine = formatAttributeLine(def, section, value, plainName); @@ -281,10 +284,14 @@ public class AttributeItemUtil { baseOrder.put("Health", 1); baseOrder.put("Main Attack Damage", 2); baseOrder.put("Neutral Damage", 3); + // For Modifier: Main Attack Damage then Neutral Damage. Map modOrder = new HashMap<>(); - modOrder.put("Main Attack Damage", 1); - modOrder.put("Neutral Damage", 2); + modOrder.put("Health Boost", 1); + modOrder.put("Main Attack Damage", 2); + modOrder.put("Neutral Damage", 3); + modOrder.put("Movement Speed", 4); + modOrder.put("Knockback Resistance", 5); // Build sections using our custom sorting. newTooltips.addAll(buildSection(baseList, baseOrder)); diff --git a/src/main/java/nikedemos/markovnames/Main.java b/src/main/java/nikedemos/markovnames/Main.java index 354fff496..8fa76ec7b 100644 --- a/src/main/java/nikedemos/markovnames/Main.java +++ b/src/main/java/nikedemos/markovnames/Main.java @@ -31,7 +31,7 @@ public class Main { Iterator> g = GENERATORS.entrySet().iterator(); while (g.hasNext()) { - Entry pair = g.next(); + Entry pair = (Entry) g.next(); System.out.println("===" + pair.getKey() + "==="); diff --git a/src/main/java/nikedemos/markovnames/MarkovDictionary.java b/src/main/java/nikedemos/markovnames/MarkovDictionary.java index 0a1e1e452..efe3f2a56 100644 --- a/src/main/java/nikedemos/markovnames/MarkovDictionary.java +++ b/src/main/java/nikedemos/markovnames/MarkovDictionary.java @@ -17,10 +17,10 @@ import java.util.Map.Entry; import java.util.Random; public class MarkovDictionary { - private final Random rng; + private Random rng; private int sequenceLen = 3; - private final HashMap2D occurrences = new HashMap2D(); + private HashMap2D occurrences = new HashMap2D(); public MarkovDictionary(String dictionary, int seqlen, Random rng) { this.rng = rng; @@ -108,7 +108,7 @@ public class MarkovDictionary { Iterator>> i = occurrences.mMap.entrySet().iterator(); while (i.hasNext()) { - Entry> pair = i.next(); + Entry> pair = (Entry>) i.next(); String k = pair.getKey(); if (k.startsWith("_[") && k.endsWith("_")) // dealing with meta entry here @@ -131,10 +131,10 @@ public class MarkovDictionary { Iterator>> it = occurrences.mMap.entrySet().iterator(); - StringBuilder sequence = new StringBuilder(); + StringBuilder sequence = new StringBuilder(""); while (it.hasNext()) { - Entry> pair = it.next(); + Entry> pair = (Entry>) it.next(); String k = pair.getKey(); @@ -143,7 +143,7 @@ public class MarkovDictionary { topLevelEntries = occurrences.get(k, "_TOTAL_"); if (randomNumber < topLevelEntries) { - sequence.append(k, 1, sequenceLen + 1); // removing the underscores + sequence.append(k.substring(1, sequenceLen + 1)); // removing the underscores break; } else { // keep going @@ -154,7 +154,7 @@ public class MarkovDictionary { // great! now that we have the first element, time for some generic iterations. // in a very similar manner. Basically - perform this loop till you encounter // "]" at the end - StringBuilder word = new StringBuilder(); + StringBuilder word = new StringBuilder(""); word.append(sequence); // now we're gonna use firstElement to keep the sequence while (sequence.charAt(sequence.length() - 1) != ']') { @@ -215,7 +215,7 @@ public class MarkovDictionary { ResourceLocation resource = new ResourceLocation("customnpcs:markovnames/" + dictionaryFile); - BufferedReader readIn = new BufferedReader(new InputStreamReader(getResource(resource), StandardCharsets.UTF_8)); + BufferedReader readIn = new BufferedReader(new InputStreamReader(getResource(resource), "UTF-8")); // Thread.currentThread().getContextClassLoader().getResourceAsStream("path/to/resource/file.ext"); for (String line = readIn.readLine(); line != null; line = readIn.readLine()) { @@ -244,10 +244,10 @@ public class MarkovDictionary { incrementSafe(seqCurr, seqNext); // aux counters + StringBuilder meta = new StringBuilder("_").append(seqCurr).append("_"); + // String aux1="_"+seqCurr+"_"; - incrementSafe("_" + seqCurr + "_" - // String aux1="_"+seqCurr+"_"; - , "_TOTAL_"); + incrementSafe(meta.toString(), "_TOTAL_"); // String aux2="_"+seqNext+"_"; // incrementSafe(aux1, aux2); diff --git a/src/main/java/nikedemos/markovnames/MarkovDictionarySPA.java b/src/main/java/nikedemos/markovnames/MarkovDictionarySPA.java index 27a83958b..81b3adb10 100644 --- a/src/main/java/nikedemos/markovnames/MarkovDictionarySPA.java +++ b/src/main/java/nikedemos/markovnames/MarkovDictionarySPA.java @@ -19,7 +19,7 @@ public class MarkovDictionarySPA extends MarkovDictionary { String[] parts = str.split("#"); - StringBuilder build = new StringBuilder(); + StringBuilder build = new StringBuilder(""); for (int p = 0; p < parts.length; p++) { // capitalize this part, but only if it's not "de", "del", "la" or "los" diff --git a/src/main/java/nikedemos/markovnames/generators/MarkovAncientGreek.java b/src/main/java/nikedemos/markovnames/generators/MarkovAncientGreek.java index c741979c6..8d02601b9 100644 --- a/src/main/java/nikedemos/markovnames/generators/MarkovAncientGreek.java +++ b/src/main/java/nikedemos/markovnames/generators/MarkovAncientGreek.java @@ -34,7 +34,7 @@ public class MarkovAncientGreek extends MarkovGenerator { //now it's time to pick it at random // if (gender == 0) { - gender = rng.nextBoolean() ? 1 : 2; + gender = rng.nextBoolean() == true ? 1 : 2; } //now if it's 2 - a lady - feminize the 3 sequences diff --git a/src/main/java/nikedemos/markovnames/generators/MarkovJapanese.java b/src/main/java/nikedemos/markovnames/generators/MarkovJapanese.java index 86ea53af0..e92f541b2 100644 --- a/src/main/java/nikedemos/markovnames/generators/MarkovJapanese.java +++ b/src/main/java/nikedemos/markovnames/generators/MarkovJapanese.java @@ -36,7 +36,7 @@ public class MarkovJapanese extends MarkovGenerator { // now it's time to pick it at random // if (gender == 0) { - gender = rng.nextBoolean() ? 1 : 2; + gender = rng.nextBoolean() == true ? 1 : 2; } if (gender == 2) { diff --git a/src/main/java/nikedemos/markovnames/generators/MarkovRoman.java b/src/main/java/nikedemos/markovnames/generators/MarkovRoman.java index 418bd7e8e..8c537d026 100644 --- a/src/main/java/nikedemos/markovnames/generators/MarkovRoman.java +++ b/src/main/java/nikedemos/markovnames/generators/MarkovRoman.java @@ -49,7 +49,7 @@ public class MarkovRoman extends MarkovGenerator { // now it's time to pick it at random // if (gender == 0) { - gender = rng.nextBoolean() ? 1 : 2; + gender = rng.nextBoolean() == true ? 1 : 2; } // now if it's 2 - a lady - feminize the 3 sequences @@ -59,6 +59,6 @@ public class MarkovRoman extends MarkovGenerator { seq3 = feminize(seq3, true); } - return (seq1 + " " + seq2 + " " + seq3); + return (new StringBuilder(seq1).append(" ").append(seq2).append(" ").append(seq3).toString()); } } diff --git a/src/main/java/nikedemos/markovnames/generators/MarkovSlavic.java b/src/main/java/nikedemos/markovnames/generators/MarkovSlavic.java index d94fabc41..f0b348ea8 100644 --- a/src/main/java/nikedemos/markovnames/generators/MarkovSlavic.java +++ b/src/main/java/nikedemos/markovnames/generators/MarkovSlavic.java @@ -45,7 +45,7 @@ public class MarkovSlavic extends MarkovGenerator { // now it's time to pick it at random // if (gender == 0) { - gender = rng.nextBoolean() ? 1 : 2; + gender = rng.nextBoolean() == true ? 1 : 2; } // now if it's 2 - a lady - feminize the 3 sequences diff --git a/src/main/java/nikedemos/markovnames/generators/MarkovSpanish.java b/src/main/java/nikedemos/markovnames/generators/MarkovSpanish.java index 41cd83e81..39b99e48a 100644 --- a/src/main/java/nikedemos/markovnames/generators/MarkovSpanish.java +++ b/src/main/java/nikedemos/markovnames/generators/MarkovSpanish.java @@ -36,7 +36,7 @@ public class MarkovSpanish extends MarkovGenerator { // now it's time to pick it at random // if (gender == 0) { - gender = rng.nextBoolean() ? 1 : 2; + gender = rng.nextBoolean() == true ? 1 : 2; } if (gender == 1) { @@ -46,6 +46,6 @@ public class MarkovSpanish extends MarkovGenerator { } - return giv + " " + sur; + return new StringBuilder(giv).append(" ").append(sur).toString(); } } diff --git a/src/main/java/nikedemos/markovnames/generators/MarkovWelsh.java b/src/main/java/nikedemos/markovnames/generators/MarkovWelsh.java index 35172ab05..0153561dd 100644 --- a/src/main/java/nikedemos/markovnames/generators/MarkovWelsh.java +++ b/src/main/java/nikedemos/markovnames/generators/MarkovWelsh.java @@ -34,7 +34,7 @@ public class MarkovWelsh extends MarkovGenerator { // now it's time to pick it at random // if (gender == 0) { - gender = rng.nextBoolean() ? 1 : 2; + gender = rng.nextBoolean() == true ? 1 : 2; } // now if it's 2 - a lady - feminize the 3 sequences diff --git a/src/main/java/noppes/npcs/AnimationMixinFunctions.java b/src/main/java/noppes/npcs/AnimationMixinFunctions.java index ed23fd44d..e6966af16 100644 --- a/src/main/java/noppes/npcs/AnimationMixinFunctions.java +++ b/src/main/java/noppes/npcs/AnimationMixinFunctions.java @@ -1,15 +1,14 @@ package noppes.npcs; import kamkeel.npcs.addon.DBCAddon; +import kamkeel.npcs.addon.client.DBCClient; +import kamkeel.npcs.addon.client.DBCClientAnimations; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityClientPlayerMP; import net.minecraft.client.model.ModelBiped; import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.renderer.*; -import net.minecraft.client.renderer.entity.RenderBiped; -import net.minecraft.client.renderer.entity.RenderManager; -import net.minecraft.client.renderer.entity.RenderPlayer; import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.client.renderer.texture.TextureUtil; import net.minecraft.entity.Entity; @@ -17,7 +16,6 @@ import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; import net.minecraft.item.Item; -import net.minecraft.item.ItemArmor; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; @@ -38,8 +36,6 @@ import org.lwjgl.opengl.GL12; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; import java.util.Map; import java.util.Set; @@ -52,6 +48,14 @@ public class AnimationMixinFunctions { return false; } + if (DBCAddon.IsAvailable()) { + if (ClientEventHandler.renderingPlayer != null) { + return DBCClient.Instance.applyRenderModel(modelRenderer); + } else if (DBCClient.Instance.applyRenderModel(modelRenderer)) { + return false; + } + } + if (ClientEventHandler.renderingPlayer != null) { ClientEventHandler.playerModel = (modelRenderer).baseModel; if (ClientCacheHandler.playerAnimations.containsKey(ClientEventHandler.renderingPlayer.getUniqueID())) { @@ -211,7 +215,7 @@ public class AnimationMixinFunctions { part.interpolateOffset(); part.interpolateAngles(); float pi = 180 / (float) Math.PI; - GL11.glTranslatef(part.prevPivots[0], part.prevPivots[1], part.prevPivots[2]); + GL11.glTranslatef(part.prevPivots[0], -part.prevPivots[1], part.prevPivots[2]); GL11.glRotatef(part.prevRotations[0] * pi, 1, 0, 0); GL11.glRotatef(part.prevRotations[1] * pi, 0, 1, 0); GL11.glRotatef(part.prevRotations[2] * pi, 0, 0, 1); @@ -221,6 +225,10 @@ public class AnimationMixinFunctions { } public static boolean mixin_renderFirstPersonAnimation(float partialRenderTick, EntityPlayer player, ModelBiped model, RenderBlocks renderBlocksIr, ResourceLocation resItemGlint) { + if (DBCAddon.IsAvailable()) { + return DBCClient.Instance.firstPersonAnimation(partialRenderTick, player,model, renderBlocksIr, resItemGlint); + } + AnimationData animationData = ClientCacheHandler.playerAnimations.get(player.getUniqueID()); if (animationData != null && animationData.isActive()) { Frame frame = (Frame) animationData.animation.currentFrame(); @@ -277,7 +285,7 @@ public class AnimationMixinFunctions { GL11.glRotatef((entityclientplayermp.rotationYaw - f4) * 0.1F, 0.0F, 1.0F, 0.0F); try { - dbc_render(player); + DBCClientAnimations.doDBCRender(player); } catch (Exception e) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); Minecraft.getMinecraft().getTextureManager().bindTexture(entityclientplayermp.getLocationSkin()); @@ -350,681 +358,6 @@ public class AnimationMixinFunctions { return true; } - private static void renderLimbs() { - AnimationData animationData = ClientCacheHandler.playerAnimations.get(Minecraft.getMinecraft().thePlayer.getUniqueID()); - if (animationData != null && animationData.isActive() && animationData.getAnimation() != null && animationData.getAnimation().currentFrame() != null) { - Animation animation = (Animation) animationData.getAnimation(); - Frame frame = (Frame) animation.currentFrame(); - - ModelBiped model = ClientEventHandler.firstPersonModel; - - if (frame.frameParts.containsKey(EnumAnimationPart.RIGHT_ARM)) { - GL11.glPushMatrix(); - GL11.glTranslatef(0.1F, 0.4F + -0.75F * 0.8F, -0.3F); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - GL11.glRotatef(180.0F, 1.0F, 0.0F, 0.0F); - GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F); - GL11.glRotatef(0.0F, 0.0F, 0.0F, 1.0F); - model.bipedRightArm.render(0.0625F); - GL11.glPopMatrix(); - } - - - if (frame.frameParts.containsKey(EnumAnimationPart.LEFT_ARM)) { - GL11.glPushMatrix(); - GL11.glTranslatef(-0.1F, 0.4F + -0.75F * 0.8F, -0.3F); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - GL11.glRotatef(180.0F, 1.0F, 0.0F, 0.0F); - GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F); - GL11.glRotatef(0.0F, 0.0F, 0.0F, 1.0F); - model.bipedLeftArm.render(0.0625F); - GL11.glPopMatrix(); - } - - - if (frame.frameParts.containsKey(EnumAnimationPart.RIGHT_LEG)) { - GL11.glPushMatrix(); - GL11.glTranslatef(0.025F, 0.6F + -0.75F * 0.8F, -0.4F); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - GL11.glRotatef(180.0F, 1.0F, 0.0F, 0.0F); - GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F); - GL11.glRotatef(0.0F, 0.0F, 0.0F, 1.0F); - model.bipedRightLeg.render(0.0625F); - GL11.glPopMatrix(); - } - - if (frame.frameParts.containsKey(EnumAnimationPart.LEFT_LEG)) { - GL11.glPushMatrix(); - GL11.glTranslatef(-0.025F, 0.6F + -0.75F * 0.8F, -0.4F); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - GL11.glRotatef(180.0F, 1.0F, 0.0F, 0.0F); - GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F); - GL11.glRotatef(0.0F, 0.0F, 0.0F, 1.0F); - model.bipedLeftLeg.render(0.0625F); - GL11.glPopMatrix(); - } - } - } - - private static void dbc_render(EntityPlayer par1EntityPlayer) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException, NoSuchFieldException { - Minecraft mc = Minecraft.getMinecraft(); - - Class JBRAH = Class.forName("JinRyuu.JBRA.JBRAH"); - Class JRMCoreHDBC = Class.forName("JinRyuu.JRMCore.JRMCoreHDBC"); - Class JRMCoreH = Class.forName("JinRyuu.JRMCore.JRMCoreH"); - Class ExtendedPlayer = Class.forName("JinRyuu.JRMCore.i.ExtendedPlayer"); - Class JGConfigClientSettings = Class.forName("JinRyuu.JRMCore.client.config.jrmc.JGConfigClientSettings"); - Class RenderPlayerJBRA = Class.forName("JinRyuu.JBRA.RenderPlayerJBRA"); - Class JGConfigRaces = Class.forName("JinRyuu.JRMCore.server.config.dbc.JGConfigRaces"); - - Method func_aam = RenderPlayerJBRA.getDeclaredMethod("func_aam", int.class, boolean.class, boolean.class); - func_aam.setAccessible(true); - - boolean jhdsBool = (boolean) JBRAH.getMethod("JHDS").invoke(null); - boolean dbcBool = (boolean) JRMCoreH.getMethod("DBC").invoke(null); - - RenderPlayer renderPlayer = (RenderPlayer) RenderManager.instance.getEntityRenderObject(par1EntityPlayer); - ModelBiped modelMain = (ModelBiped) RenderPlayerJBRA.getField("modelMain").get(renderPlayer); - - EntityClientPlayerMP acp = mc.thePlayer; - - Object data = null; - if (jhdsBool) { - data = JBRAH.getMethod("skinData", EntityPlayer.class).invoke(null, acp); - } - - float f = 1.0F; - GL11.glColor3f(f + getR(), f + getG(), f + getB()); - GL11.glPushMatrix(); - //modelMain.field_78095_p = 0.0F; - modelMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, par1EntityPlayer); - String dns = (String) JRMCoreH.getField("dns").get(null); - if (dns.length() > 3) { - int State = (byte) JRMCoreH.getField("State").get(null); - int race = (int) JRMCoreH.getMethod("dnsRace", String.class).invoke(null, dns); - boolean saiOozar = (boolean) JRMCoreH.getMethod("rSai", int.class).invoke(null, race) && (State == 7 || State == 8); - int gen = (int) JRMCoreH.getMethod("dnsGender", String.class).invoke(null, dns); - int skintype = (int) JRMCoreH.getMethod("dnsSkinT", String.class).invoke(null, dns); - boolean lg = (boolean) JRMCoreH.getMethod("lgndb", EntityPlayer.class, int.class, int.class).invoke(null, par1EntityPlayer, race, State); - boolean iau = (boolean) JRMCoreH.getMethod("rc_arc", int.class).invoke(null, race) && State == 6; - String dnsau = (String) JRMCoreH.getMethod("data", int.class, String.class).invoke(null, 16, ""); - dnsau = dnsau.contains(";") ? dnsau.substring(1) : (par1EntityPlayer.getCommandSenderName().equals(mc.thePlayer.getCommandSenderName()) ? dnsau : ""); - int bodytype = skintype == 0 ? (int) JRMCoreH.getMethod("dnsBodyC1_0", String.class).invoke(null, dns) : (int) JRMCoreH.getMethod("dnsBodyT", String.class).invoke(null, dns); - int bodycm = skintype == 0 ? 0 : (iau ? (int) JRMCoreH.getMethod("dnsauCM", String.class).invoke(null, dns) : (int) JRMCoreH.getMethod("dnsBodyCM", String.class).invoke(null, dns)); - int bodyc1 = skintype == 0 ? 0 : (iau ? (int) JRMCoreH.getMethod("dnsauC1", String.class).invoke(null, dns) : (int) JRMCoreH.getMethod("dnsBodyC1", String.class).invoke(null, dns)); - int bodyc2 = skintype == 0 ? 0 : (iau ? (int) JRMCoreH.getMethod("dnsauC2", String.class).invoke(null, dns) : (int) JRMCoreH.getMethod("dnsBodyC2", String.class).invoke(null, dns)); - int bodyc3 = skintype == 0 ? 0 : (iau ? (int) JRMCoreH.getMethod("dnsauC3", String.class).invoke(null, dns) : (int) JRMCoreH.getMethod("dnsBodyC3", String.class).invoke(null, dns)); - - int plyrSpc = skintype == 0 ? 0 : (((int[]) JRMCoreH.getField("RaceCustomSkin").get(null))[race] == 0 ? 0 : (bodytype >= ((int[]) JRMCoreH.getField("Specials").get(null))[race] ? ((int[]) JRMCoreH.getField("Specials").get(null))[race] - 1 : bodytype)); - int[] an = new int[]{1, 0, 2, 0, 0, 3, 0, 1, 1}; - - Object ep = ExtendedPlayer.getMethod("get", EntityPlayer.class).invoke(null, acp); - int animKiShoot = (int) ExtendedPlayer.getMethod("getAnimKiShoot").invoke(ep); - int blocking = (int) ExtendedPlayer.getMethod("getBlocking").invoke(ep); - - boolean instantTransmission = blocking == 2; - int id = blocking != 0 ? (instantTransmission ? 6 : 0) : (animKiShoot != 0 ? an[animKiShoot - 1] + 2 : -1); - if (!(boolean) JGConfigClientSettings.getField("CLIENT_DA4").get(null)) { - id = -1; - } - - int tailCol; - - int jx; - int j; - if (dbcBool) { - String[] s = ((String) JRMCoreH.getMethod("data", String.class, int.class, String.class).invoke(null, acp.getCommandSenderName(), 1, "0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0")).split(";"); - tailCol = Integer.parseInt(s[2]); - if (tailCol == 1) { - String[] PlyrSkills = (String[]) JRMCoreH.getMethod("PlyrSkills", EntityPlayer.class).invoke(null, acp); - jx = (int) JRMCoreH.getMethod("SklLvl", int.class, String[].class).invoke(null, 12, PlyrSkills); - j = (int) JRMCoreH.getMethod("SklLvl", int.class, String[].class).invoke(null, 15, PlyrSkills); - String ss = s[17]; - boolean v = dbcBool && !ss.equals("-1"); - GL11.glPushMatrix(); - if (v && (jx > 0 || j > 0)) { - if (id > -1) { - func_aam.invoke(renderPlayer, id, false, true); - } - - GL11.glRotatef(6.0F, 0.0F, 0.0F, 1.0F); - GL11.glTranslatef(-0.29F, 0.15F, 0.0F); - RenderPlayerJBRA.getMethod("kss", Entity.class, boolean.class, int.class, int.class, int.class).invoke( - null, acp, false, Integer.parseInt(ss), jx, j); - } - - GL11.glPopMatrix(); - } - } - - float h1 = 1.0F; - ResourceLocation bdyskn; - boolean ssg; - boolean v; - if (race == 5 && dbcBool) { - v = State == 1; - ssg = State == 3 && (boolean) JGConfigRaces.getField("CONFIG_MAJIN_PURE_PINK_SKIN").get(null); - if (v) { - bodycm = 12561588; - } else if (ssg) { - bodycm = 16757199; - } - - bdyskn = new ResourceLocation("jinryuudragonbc:cc/majin/" + (gen == 1 ? "f" : "") + "majin.png"); - mc.getTextureManager().bindTexture(bdyskn); - glColor3f(bodycm); - modelMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, par1EntityPlayer); - renderLimbs(); - - String[] playerData13 = ((String) JRMCoreH.getMethod("data", String.class, int.class, String.class).invoke(null, - par1EntityPlayer.getCommandSenderName(), 13, "0;0;0;0,0,0+0")).split(";"); - String[] absorptionData; - if (playerData13.length > 3) { - absorptionData = playerData13[3].split(","); - } else { - absorptionData = "0;0;0;0,0,0+0".split(","); - } - - String[] absorptionVisuals = absorptionData[1].contains("+") ? absorptionData[1].split("\\+") : new String[]{absorptionData[1]}; - int absorbedRace = Integer.parseInt(absorptionVisuals[0]); - if ((boolean) JRMCoreH.getMethod("isRaceArcosian", int.class).invoke(null, absorbedRace) - || (boolean) JRMCoreH.getMethod("isRaceNamekian", int.class).invoke(null, absorbedRace)) { - bdyskn = new ResourceLocation("jinryuudragonbc:cc/majin/" + (gen == 1 ? "f" : "") + "majin_" + ((boolean) JRMCoreH.getMethod("isRaceArcosian", int.class).invoke(null, absorbedRace) ? "arco" : "namek") + ".png"); - mc.getTextureManager().bindTexture(bdyskn); - glColor3f(bodycm); - modelMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, par1EntityPlayer); - renderLimbs(); - } - - if (!saiOozar) { - if (skintype == 0) { - bdyskn = acp.getLocationSkin().equals(ClientEventHandler.steveTextures) ? (gen >= 1 ? ClientEventHandler.fem : ClientEventHandler.steveTextures) : acp.getLocationSkin(); - if (jhdsBool && (boolean) JBRAH.getMethod("getSkinHas", Object.class).invoke(null, data)) { - mc.getTextureManager().bindTexture((ResourceLocation) JBRAH.getMethod("getSkinLoc", Object.class).invoke(null, data)); - } else { - mc.getTextureManager().bindTexture(bdyskn); - } - - GL11.glColor3f(h1 + getR(), h1 + getG(), h1 + getB()); - modelMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, par1EntityPlayer); - renderLimbs(); - } else if (jhdsBool && (boolean) JBRAH.getMethod("getSkinHas", Object.class).invoke(null, data) && skintype == 0) { - GL11.glColor3f(h1 + getR(), h1 + getG(), h1 + getB()); - mc.getTextureManager().bindTexture((ResourceLocation) JBRAH.getMethod("getSkinLoc", Object.class).invoke(null, data)); - modelMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, par1EntityPlayer); - renderLimbs(); - } - } - } else if (race == 3 && dbcBool) { - v = (boolean) JRMCoreH.getMethod("StusEfctsMe", int.class).invoke(null, 17); - ssg = (boolean) JRMCoreHDBC.getMethod("godKiUserBase", int.class, int.class).invoke(null, race, State); - if (ssg && v) { - bodycm = 16744999; - bodyc1 = 15524763; - bodyc2 = 12854822; - bodyc3 = 0; - } - - bdyskn = new ResourceLocation("jinryuudragonbc:cc/nam/0nam" + plyrSpc + ".png"); - mc.getTextureManager().bindTexture(bdyskn); - glColor3f(bodycm); - modelMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, par1EntityPlayer); - renderLimbs(); - - bdyskn = new ResourceLocation("jinryuudragonbc:cc/nam/1nam" + plyrSpc + ".png"); - mc.getTextureManager().bindTexture(bdyskn); - glColor3f(bodyc1); - modelMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, par1EntityPlayer); - renderLimbs(); - - bdyskn = new ResourceLocation("jinryuudragonbc:cc/nam/2nam" + plyrSpc + ".png"); - mc.getTextureManager().bindTexture(bdyskn); - glColor3f(bodyc2); - modelMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, par1EntityPlayer); - renderLimbs(); - - bdyskn = new ResourceLocation("jinryuudragonbc:cc/nam/3nam" + plyrSpc + ".png"); - mc.getTextureManager().bindTexture(bdyskn); - GL11.glColor3f(h1 + getR(), h1 + getG(), h1 + getB()); - modelMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, par1EntityPlayer); - renderLimbs(); - } else if (race == 4 && dbcBool) { - v = (boolean) JRMCoreH.getMethod("StusEfctsMe", int.class).invoke(null, 17); - ssg = (boolean) JRMCoreHDBC.getMethod("godKiUserBase", int.class, int.class).invoke(null, race, State); - if (ssg && v) { - State = 6; - bodycm = 5526612; - bodyc1 = 12829635; - bodyc3 = 1513239; - } - - bdyskn = new ResourceLocation("jinryuudragonbc:cc/arc/" + (gen == 1 ? "f" : "m") + "/0A" + ((short[]) JRMCoreH.getField("TransFrSkn").get(null))[State] + plyrSpc + ".png"); - mc.getTextureManager().bindTexture(bdyskn); - glColor3f(bodycm); - modelMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, par1EntityPlayer); - renderLimbs(); - - bdyskn = new ResourceLocation("jinryuudragonbc:cc/arc/" + (gen == 1 ? "f" : "m") + "/1A" + ((short[]) JRMCoreH.getField("TransFrSkn").get(null))[State] + plyrSpc + ".png"); - mc.getTextureManager().bindTexture(bdyskn); - glColor3f(bodyc1); - modelMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, par1EntityPlayer); - renderLimbs(); - - bdyskn = new ResourceLocation("jinryuudragonbc:cc/arc/" + (gen == 1 ? "f" : "m") + "/2A" + ((short[]) JRMCoreH.getField("TransFrSkn").get(null))[State] + plyrSpc + ".png"); - mc.getTextureManager().bindTexture(bdyskn); - glColor3f(bodyc2); - modelMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, par1EntityPlayer); - renderLimbs(); - - bdyskn = new ResourceLocation("jinryuudragonbc:cc/arc/" + (gen == 1 ? "f" : "m") + "/3A" + ((short[]) JRMCoreH.getField("TransFrSkn").get(null))[State] + plyrSpc + ".png"); - mc.getTextureManager().bindTexture(bdyskn); - glColor3f(bodyc3); - modelMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, par1EntityPlayer); - renderLimbs(); - - bdyskn = new ResourceLocation("jinryuudragonbc:cc/arc/" + (gen == 1 ? "f" : "m") + "/4A" + ((short[]) JRMCoreH.getField("TransFrSkn").get(null))[State] + plyrSpc + ".png"); - mc.getTextureManager().bindTexture(bdyskn); - GL11.glColor3f(h1 + getR(), h1 + getG(), h1 + getB()); - modelMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, par1EntityPlayer); - renderLimbs(); - } else { - if (saiOozar) { - bdyskn = new ResourceLocation("jinryuudragonbc:cc/oozaru1.png"); - mc.getTextureManager().bindTexture(bdyskn); - glColor3f(skintype != 0 ? bodycm : 11374471); - modelMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, par1EntityPlayer); - renderLimbs(); - - tailCol = race != 2 && bodytype == 0 ? 6498048 : bodytype; - jx = State != 0 && State != 7 ? (lg ? 10092390 : 16574610) : (skintype == 1 ? bodyc1 : tailCol); - bdyskn = new ResourceLocation("jinryuudragonbc:cc/oozaru2.png"); - mc.getTextureManager().bindTexture(bdyskn); - glColor3f(jx); - modelMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, par1EntityPlayer); - renderLimbs(); - } else if (skintype != 0) { - bdyskn = new ResourceLocation("jinryuumodscore:cc/" + (gen == 1 ? "f" : "") + "hum.png"); - mc.getTextureManager().bindTexture(bdyskn); - glColor3f(bodycm); - modelMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, par1EntityPlayer); - renderLimbs(); - } - - if (!saiOozar) { - if (skintype == 0) { - bdyskn = acp.getLocationSkin().equals(ClientEventHandler.steveTextures) ? (gen >= 1 ? ClientEventHandler.fem : ClientEventHandler.steveTextures) : acp.getLocationSkin(); - if (jhdsBool && (boolean) JBRAH.getMethod("getSkinHas", Object.class).invoke(null, data)) { - mc.getTextureManager().bindTexture((ResourceLocation) JBRAH.getMethod("getSkinLoc", Object.class).invoke(null, data)); - } else { - mc.getTextureManager().bindTexture(bdyskn); - } - - GL11.glColor3f(h1 + getR(), h1 + getG(), h1 + getB()); - modelMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, par1EntityPlayer); - renderLimbs(); - } else if (jhdsBool && (boolean) JBRAH.getMethod("getSkinHas", Object.class).invoke(null, data) && skintype == 0) { - GL11.glColor3f(h1 + getR(), h1 + getG(), h1 + getB()); - mc.getTextureManager().bindTexture((ResourceLocation) JBRAH.getMethod("getSkinLoc", Object.class).invoke(null, data)); - modelMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, par1EntityPlayer); - renderLimbs(); - } - - if (State == 14) { - tailCol = race != 2 && bodytype == 0 ? 6498048 : bodytype; - tailCol = (boolean) JRMCoreH.getMethod("isAprilFoolsModeOn").invoke(null) ? 13292516 : tailCol; - tailCol = skintype == 1 ? bodyc1 : tailCol; - if ((boolean) JRMCoreH.getMethod("rSai", int.class).invoke(null, race) && tailCol == 6498048 && State == 14) { - if ((boolean) JRMCoreH.getMethod("isAprilFoolsModeOn").invoke(null)) { - tailCol = 13292516; - } else { - tailCol = 14292268; - } - } - - mc.getTextureManager().bindTexture(new ResourceLocation("jinryuudragonbc:cc/ss4" + (skintype == 0 ? "a" : "b") + ".png")); - glColor3f(tailCol); - modelMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, par1EntityPlayer); - renderLimbs(); - } - } - } - - if ((boolean) JGConfigClientSettings.getField("CLIENT_DA19").get(null) && (dbcBool || (boolean) JRMCoreH.getMethod("NC").invoke(null))) { - GL11.glPushMatrix(); - GL11.glEnable(3042); - GL11.glDisable(2896); - GL11.glBlendFunc(770, 771); - GL11.glAlphaFunc(516, 0.003921569F); - GL11.glDepthMask(false); - tailCol = Integer.parseInt((String) JRMCoreH.getMethod("data", String.class, int.class, String.class - ).invoke(null, par1EntityPlayer.getCommandSenderName(), 8, "200")); - float one = (float) tailCol / 100.0F; - j = (int) ((float) tailCol / one); - if (j < 70) { - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - mc.getTextureManager().bindTexture(new ResourceLocation("jinryuumodscore:cc/bruises1.png")); - renderLimbs(); - } - - if (j < 55) { - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - mc.getTextureManager().bindTexture(new ResourceLocation("jinryuumodscore:cc/bruises2.png")); - renderLimbs(); - } - - if (j < 35) { - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - mc.getTextureManager().bindTexture(new ResourceLocation("jinryuumodscore:cc/bruises3.png")); - renderLimbs(); - } - - if (j < 20) { - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - mc.getTextureManager().bindTexture(new ResourceLocation("jinryuumodscore:cc/bruises4.png")); - renderLimbs(); - } - - GL11.glDepthMask(true); - GL11.glEnable(2896); - GL11.glDisable(3042); - GL11.glPopMatrix(); - } - - ItemStack itemstack = par1EntityPlayer.inventory.armorItemInSlot(2); - String dbcarmor; - Item item; - ResourceLocation mcarmor; - ResourceLocation armor; - ItemArmor itemarmor; - if (itemstack != null) { - item = itemstack.getItem(); - if (item instanceof ItemArmor) { - itemarmor = (ItemArmor) item; - GL11.glPushMatrix(); - dbcarmor = itemarmor.getArmorTexture(itemstack, par1EntityPlayer, 2, null); - mcarmor = RenderBiped.getArmorResource(par1EntityPlayer, itemstack, 1, null); - if (dbcarmor != null) { - dbcarmor = dbcarmor.replace("jbra", "").replace("_dam", ""); - } - - armor = dbcarmor != null ? new ResourceLocation(dbcarmor) : mcarmor; - mc.getTextureManager().bindTexture(armor); - GL11.glPushMatrix(); - if (id > -1) { - func_aam.invoke(renderPlayer, id, false, true); - } - - GL11.glColor3f(1.0F + getR(), 1.0F + getG(), 1.0F + getB()); - GL11.glScalef(1.0001F, 1.0001F, 1.0001F); - if (dbcarmor != null) { - modelMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, par1EntityPlayer); - modelMain.textureHeight = 64; - modelMain.textureWidth = 128; - renderLimbs(); - } else { - modelMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, par1EntityPlayer); - renderLimbs(); - } - - GL11.glPopMatrix(); - GL11.glPopMatrix(); - } - } - - if (race == 3 && dbcBool) { - bdyskn = new ResourceLocation("jinryuudragonbc:cc/nam/0nam" + plyrSpc + ".png"); - mc.getTextureManager().bindTexture(bdyskn); - glColor3f(bodycm); - modelMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, par1EntityPlayer); - renderLimbs(); - - bdyskn = new ResourceLocation("jinryuudragonbc:cc/nam/1nam" + plyrSpc + ".png"); - mc.getTextureManager().bindTexture(bdyskn); - glColor3f(bodyc1); - modelMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, par1EntityPlayer); - renderLimbs(); - - bdyskn = new ResourceLocation("jinryuudragonbc:cc/nam/2nam" + plyrSpc + ".png"); - mc.getTextureManager().bindTexture(bdyskn); - glColor3f(bodyc2); - modelMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, par1EntityPlayer); - renderLimbs(); - - bdyskn = new ResourceLocation("jinryuudragonbc:cc/nam/3nam" + plyrSpc + ".png"); - mc.getTextureManager().bindTexture(bdyskn); - GL11.glColor3f(h1 + getR(), h1 + getG(), h1 + getB()); - modelMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, par1EntityPlayer); - renderLimbs(); - } else if (race == 4 && dbcBool) { - bdyskn = new ResourceLocation("jinryuudragonbc:cc/arc/" + (gen == 1 ? "f" : "m") + "/0A" + ((short[]) JRMCoreH.getField("TransFrSkn").get(null))[State] + plyrSpc + ".png"); - mc.getTextureManager().bindTexture(bdyskn); - glColor3f(bodycm); - modelMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, par1EntityPlayer); - renderLimbs(); - - bdyskn = new ResourceLocation("jinryuudragonbc:cc/arc/" + (gen == 1 ? "f" : "m") + "/1A" + ((short[]) JRMCoreH.getField("TransFrSkn").get(null))[State] + plyrSpc + ".png"); - mc.getTextureManager().bindTexture(bdyskn); - glColor3f(bodyc1); - modelMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, par1EntityPlayer); - renderLimbs(); - - bdyskn = new ResourceLocation("jinryuudragonbc:cc/arc/" + (gen == 1 ? "f" : "m") + "/2A" + ((short[]) JRMCoreH.getField("TransFrSkn").get(null))[State] + plyrSpc + ".png"); - mc.getTextureManager().bindTexture(bdyskn); - glColor3f(bodyc2); - modelMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, par1EntityPlayer); - renderLimbs(); - - bdyskn = new ResourceLocation("jinryuudragonbc:cc/arc/" + (gen == 1 ? "f" : "m") + "/3A" + ((short[]) JRMCoreH.getField("TransFrSkn").get(null))[State] + plyrSpc + ".png"); - mc.getTextureManager().bindTexture(bdyskn); - glColor3f(bodyc3); - modelMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, par1EntityPlayer); - renderLimbs(); - - bdyskn = new ResourceLocation("jinryuudragonbc:cc/arc/" + (gen == 1 ? "f" : "m") + "/4A" + ((short[]) JRMCoreH.getField("TransFrSkn").get(null))[State] + plyrSpc + ".png"); - mc.getTextureManager().bindTexture(bdyskn); - GL11.glColor3f(h1 + getR(), h1 + getG(), h1 + getB()); - modelMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, par1EntityPlayer); - renderLimbs(); - } else { - if (saiOozar) { - bdyskn = new ResourceLocation("jinryuudragonbc:cc/oozaru1.png"); - mc.getTextureManager().bindTexture(bdyskn); - glColor3f(skintype != 0 ? bodycm : 11374471); - modelMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, par1EntityPlayer); - renderLimbs(); - - jx = race != 2 && bodytype == 0 ? 6498048 : bodytype; - j = State != 0 && State != 7 ? (lg ? 10092390 : 16574610) : (skintype == 1 ? bodyc1 : jx); - bdyskn = new ResourceLocation("jinryuudragonbc:cc/oozaru2.png"); - mc.getTextureManager().bindTexture(bdyskn); - glColor3f(j); - modelMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, par1EntityPlayer); - renderLimbs(); - } else if (skintype != 0) { - bdyskn = new ResourceLocation("jinryuumodscore:cc/" + (gen == 1 ? "f" : "") + "hum.png"); - mc.getTextureManager().bindTexture(bdyskn); - glColor3f(bodycm); - modelMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, par1EntityPlayer); - renderLimbs(); - } - - if (!saiOozar) { - if (skintype == 0) { - bdyskn = acp.getLocationSkin().equals(ClientEventHandler.steveTextures) ? (gen >= 1 ? ClientEventHandler.fem : ClientEventHandler.steveTextures) : acp.getLocationSkin(); - if (jhdsBool && (boolean) JBRAH.getMethod("getSkinHas", Object.class).invoke(null, data)) { - mc.getTextureManager().bindTexture((ResourceLocation) JBRAH.getMethod("getSkinLoc", Object.class).invoke(null, data)); - } else { - mc.getTextureManager().bindTexture(bdyskn); - } - - GL11.glColor3f(h1 + getR(), h1 + getG(), h1 + getB()); - modelMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, par1EntityPlayer); - renderLimbs(); - } else if (jhdsBool && (boolean) JBRAH.getMethod("getSkinHas", Object.class).invoke(null, data) && skintype == 0) { - GL11.glColor3f(h1 + getR(), h1 + getG(), h1 + getB()); - mc.getTextureManager().bindTexture((ResourceLocation) JBRAH.getMethod("getSkinLoc", Object.class).invoke(null, data)); - - modelMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, par1EntityPlayer); - renderLimbs(); - } - - if (State == 14) { - tailCol = race != 2 && bodytype == 0 ? 6498048 : bodytype; - tailCol = (boolean) JRMCoreH.getMethod("isAprilFoolsModeOn").invoke(null) ? 13292516 : tailCol; - jx = skintype == 1 ? bodyc1 : tailCol; - if ((boolean) JRMCoreH.getMethod("rSai", int.class).invoke(null, race) && jx == 6498048 && State == 14) { - if ((boolean) JRMCoreH.getMethod("isAprilFoolsModeOn").invoke(null)) { - jx = 13292516; - } else { - jx = 14292268; - } - } - - mc.getTextureManager().bindTexture(new ResourceLocation("jinryuudragonbc:cc/ss4" + (skintype == 0 ? "a" : "b") + ".png")); - glColor3f(jx); - modelMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, par1EntityPlayer); - renderLimbs(); - } - } - } - - if ((boolean) JGConfigClientSettings.getField("CLIENT_DA19").get(null)) { - GL11.glPushMatrix(); - GL11.glEnable(3042); - GL11.glDisable(2896); - GL11.glBlendFunc(770, 771); - GL11.glAlphaFunc(516, 0.003921569F); - GL11.glDepthMask(false); - tailCol = (int) JRMCoreH.getMethod( - "stat", Entity.class, int.class, int.class, int.class, int.class, int.class, int.class, float.class).invoke(null, - par1EntityPlayer, 2, - JRMCoreH.getField("Pwrtyp").get(null), 2, - ((int[]) JRMCoreH.getField("PlyrAttrbts").get(null))[2], race, - JRMCoreH.getField("Class").get(null), 0.0F); - jx = Integer.parseInt((String) JRMCoreH.getMethod("data", String.class, int.class, String.class).invoke(null, par1EntityPlayer.getCommandSenderName(), 8, "200")); - float one = (float) tailCol / 100.0F; - int perc = (int) ((float) jx / one); - if (perc < 70) { - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - mc.getTextureManager().bindTexture(new ResourceLocation("jinryuumodscore:cc/bruises1.png")); - renderLimbs(); - } - - if (perc < 55) { - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - mc.getTextureManager().bindTexture(new ResourceLocation("jinryuumodscore:cc/bruises2.png")); - renderLimbs(); - } - - if (perc < 35) { - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - mc.getTextureManager().bindTexture(new ResourceLocation("jinryuumodscore:cc/bruises3.png")); - renderLimbs(); - } - - if (perc < 20) { - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - mc.getTextureManager().bindTexture(new ResourceLocation("jinryuumodscore:cc/bruises4.png")); - renderLimbs(); - } - - GL11.glDepthMask(true); - GL11.glEnable(2896); - GL11.glDisable(3042); - GL11.glPopMatrix(); - } - - if (itemstack != null) { - item = itemstack.getItem(); - if (item instanceof ItemArmor) { - itemarmor = (ItemArmor) item; - GL11.glPushMatrix(); - dbcarmor = itemarmor.getArmorTexture(itemstack, par1EntityPlayer, 2, null); - mcarmor = RenderBiped.getArmorResource(par1EntityPlayer, itemstack, 1, null); - if (dbcarmor != null) { - dbcarmor = dbcarmor.replace("jbra", "").replace("_dam", ""); - } - - armor = dbcarmor != null ? new ResourceLocation(dbcarmor) : mcarmor; - mc.getTextureManager().bindTexture(armor); - if (id == 0 || id == 3 || id == 5) { - if (id == 0) { - if ((boolean) JGConfigClientSettings.getField("CLIENT_DA18").get(null)) { - GL11.glPushMatrix(); - func_aam.invoke(renderPlayer, id, false, true); - GL11.glColor3f(1.0F + getR(), 1.0F + getG(), 1.0F + getB()); - GL11.glScalef(1.0001F, 1.0001F, 1.0001F); - if (dbcarmor != null) { - modelMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, par1EntityPlayer); - modelMain.textureHeight = 64; - modelMain.textureWidth = 128; - renderLimbs(); - } else { - modelMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, par1EntityPlayer); - renderLimbs(); - } - - GL11.glPopMatrix(); - } - } else { - GL11.glPushMatrix(); - func_aam.invoke(renderPlayer, id, false, true); - GL11.glColor3f(1.0F + getR(), 1.0F + getG(), 1.0F + getB()); - GL11.glScalef(1.0001F, 1.0001F, 1.0001F); - if (dbcarmor != null) { - modelMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, par1EntityPlayer); - modelMain.textureHeight = 64; - modelMain.textureWidth = 128; - renderLimbs(); - } else { - modelMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, par1EntityPlayer); - renderLimbs(); - } - - GL11.glPopMatrix(); - } - } - - GL11.glPopMatrix(); - } - } - } - - GL11.glPopMatrix(); - } - - private static float getR() throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException { - Class RenderPlayerJBRA = Class.forName("JinRyuu.JBRA.RenderPlayerJBRA"); - Method method = RenderPlayerJBRA.getDeclaredMethod("getR"); - method.setAccessible(true); - return (float) method.invoke(null); - } - - private static float getB() throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException { - Class RenderPlayerJBRA = Class.forName("JinRyuu.JBRA.RenderPlayerJBRA"); - Method method = RenderPlayerJBRA.getDeclaredMethod("getB"); - method.setAccessible(true); - return (float) method.invoke(null); - } - - private static float getG() throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException { - Class RenderPlayerJBRA = Class.forName("JinRyuu.JBRA.RenderPlayerJBRA"); - Method method = RenderPlayerJBRA.getDeclaredMethod("getG"); - method.setAccessible(true); - return (float) method.invoke(null); - } - - private static void glColor3f(int c) throws ClassNotFoundException, InvocationTargetException, NoSuchMethodException, IllegalAccessException { - float h2 = (float) (c >> 16 & 255) / 255.0F; - float h3 = (float) (c >> 8 & 255) / 255.0F; - float h4 = (float) (c & 255) / 255.0F; - float h1 = 1.0F; - float r = h1 * h2; - float g = h1 * h3; - float b = h1 * h4; - GL11.glColor3f(r + getR(), g + getG(), b + getB()); - } - private static void mixin_renderItem(EntityLivingBase p_78443_1_, ItemStack p_78443_2_, int p_78443_3_, IItemRenderer.ItemRenderType type, RenderBlocks renderBlocksIr, ResourceLocation resItemGlint) { GL11.glPushMatrix(); TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager(); @@ -1114,4 +447,60 @@ public class AnimationMixinFunctions { GL11.glPopMatrix(); } + + public static void renderLimbs() { + AnimationData animationData = ClientCacheHandler.playerAnimations.get(Minecraft.getMinecraft().thePlayer.getUniqueID()); + if (animationData != null && animationData.isActive() && animationData.getAnimation() != null && animationData.getAnimation().currentFrame() != null) { + Animation animation = (Animation) animationData.getAnimation(); + Frame frame = (Frame) animation.currentFrame(); + + ModelBiped model = ClientEventHandler.firstPersonModel; + + if (frame.frameParts.containsKey(EnumAnimationPart.RIGHT_ARM)) { + GL11.glPushMatrix(); + GL11.glTranslatef(0.1F, 0.4F + -0.75F * 0.8F, -0.3F); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glRotatef(180.0F, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(0.0F, 0.0F, 0.0F, 1.0F); + model.bipedRightArm.render(0.0625F); + GL11.glPopMatrix(); + } + + + if (frame.frameParts.containsKey(EnumAnimationPart.LEFT_ARM)) { + GL11.glPushMatrix(); + GL11.glTranslatef(-0.1F, 0.4F + -0.75F * 0.8F, -0.3F); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glRotatef(180.0F, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(0.0F, 0.0F, 0.0F, 1.0F); + model.bipedLeftArm.render(0.0625F); + GL11.glPopMatrix(); + } + + + if (frame.frameParts.containsKey(EnumAnimationPart.RIGHT_LEG)) { + GL11.glPushMatrix(); + GL11.glTranslatef(0.025F, 0.6F + -0.75F * 0.8F, -0.4F); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glRotatef(180.0F, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(0.0F, 0.0F, 0.0F, 1.0F); + model.bipedRightLeg.render(0.0625F); + GL11.glPopMatrix(); + } + + if (frame.frameParts.containsKey(EnumAnimationPart.LEFT_LEG)) { + GL11.glPushMatrix(); + GL11.glTranslatef(-0.025F, 0.6F + -0.75F * 0.8F, -0.4F); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glRotatef(180.0F, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(0.0F, 0.0F, 0.0F, 1.0F); + model.bipedLeftLeg.render(0.0625F); + GL11.glPopMatrix(); + } + } + } } diff --git a/src/main/java/noppes/npcs/CustomNpcs.java b/src/main/java/noppes/npcs/CustomNpcs.java index 5e9a988a5..0ba5bbaf0 100644 --- a/src/main/java/noppes/npcs/CustomNpcs.java +++ b/src/main/java/noppes/npcs/CustomNpcs.java @@ -41,7 +41,7 @@ import noppes.npcs.scripted.NpcAPI; import java.io.File; import java.util.Set; -@Mod(modid = "customnpcs", name = "CustomNPC+", version = "1.10-beta5") +@Mod(modid = "customnpcs", name = "CustomNPC+", version = "1.10-beta18") public class CustomNpcs { @SidedProxy(clientSide = "noppes.npcs.client.ClientProxy", serverSide = "noppes.npcs.CommonProxy") diff --git a/src/main/java/noppes/npcs/CustomNpcsPermissions.java b/src/main/java/noppes/npcs/CustomNpcsPermissions.java index 6d0cbc0c1..3363c0351 100644 --- a/src/main/java/noppes/npcs/CustomNpcsPermissions.java +++ b/src/main/java/noppes/npcs/CustomNpcsPermissions.java @@ -39,9 +39,20 @@ 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 NPC_ADVANCED_TRADER = new Permission("customnpcs.npc.advanced.trader"); + public static final Permission NPC_ADVANCED_DIALOG = new Permission("customnpcs.npc.advanced.dialog"); + public static final Permission NPC_ADVANCED_FACTION = new Permission("customnpcs.npc.advanced.faction"); + public static final Permission NPC_ADVANCED_JOB = new Permission("customnpcs.npc.advanced.job"); + public static final Permission NPC_ADVANCED_ROLE = new Permission("customnpcs.npc.advanced.role"); + public static final Permission NPC_ADVANCED_TRANSPORT = new Permission("customnpcs.npc.advanced.transport"); + public static final Permission NPC_ADVANCED_TRANSFORM = new Permission("customnpcs.npc.advanced.transform"); + public static final Permission NPC_ADVANCED_LINKED = new Permission("customnpcs.npc.advanced.linked"); + public static final Permission NPC_ADVANCED_MAGIC = new Permission("customnpcs.npc.advanced.linked"); + public static final Permission NPC_ADVANCED_TAGS = new Permission("customnpcs.npc.advanced.tags"); + public static final Permission GLOBAL_REMOTE = new Permission("customnpcs.global.remote"); - // Save Globel Preferences + // Save Global 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"); @@ -139,11 +150,14 @@ public class CustomNpcsPermissions { } public static boolean hasCustomPermission(EntityPlayer player, String permission) { - if (Developer.Instance.hasUniversal(player.getUniqueID())) { - return true; - } - if (Instance.bukkit != null) { - return Instance.bukkitPermission(player.getCommandSenderName(), permission); + if (player != null) { + if (FMLCommonHandler.instance().getSide() == Side.SERVER && NoppesUtilServer.isOp(player)) + return true; + if (Developer.Instance.hasUniversal(player.getUniqueID())) + return true; + if (Instance.bukkit != null) { + return Instance.bukkitPermission(player.getCommandSenderName(), permission); + } } return false; } diff --git a/src/main/java/noppes/npcs/DataInventory.java b/src/main/java/noppes/npcs/DataInventory.java index c85bf3f32..49877fb37 100644 --- a/src/main/java/noppes/npcs/DataInventory.java +++ b/src/main/java/noppes/npcs/DataInventory.java @@ -30,7 +30,7 @@ public class DataInventory implements IInventory { public int lootMode = 0; - private final EntityNPCInterface npc; + private EntityNPCInterface npc; public DataInventory(EntityNPCInterface npc) { this.npc = npc; @@ -278,6 +278,7 @@ public class DataInventory implements IInventory { public ItemStack getStackInSlotOnClosing(int par1) { int i = 0; HashMap var2; + ; if (par1 >= 7) { var2 = items; diff --git a/src/main/java/noppes/npcs/DataStats.java b/src/main/java/noppes/npcs/DataStats.java index 0dcda48a1..e860694ea 100644 --- a/src/main/java/noppes/npcs/DataStats.java +++ b/src/main/java/noppes/npcs/DataStats.java @@ -7,6 +7,7 @@ import noppes.npcs.constants.EnumParticleType; import noppes.npcs.constants.EnumPotionType; import noppes.npcs.controllers.data.MagicData; import noppes.npcs.entity.EntityNPCInterface; +import noppes.npcs.scripted.ScriptParticle; import noppes.npcs.util.ValueUtil; public class DataStats { @@ -42,17 +43,21 @@ public class DataStats { public float pDamage = 4; public int pImpact = 0, pSize = 5, pSpeed = 10, pArea = 0, pDur = 5; public boolean pPhysics = true, pXlr8 = false, pGlows = false, pExplode = false; - public boolean pRender3D = false, pSpin = false, pStick = false; + public boolean pRender3D = false, pSpin = false, pStick = false, pBurnItem = false; public EnumPotionType pEffect = EnumPotionType.None; public EnumParticleType pTrail = EnumParticleType.None; + public ScriptParticle pCustom = new ScriptParticle(""); public int pEffAmp = 0; public String fireSound = "random.bow"; - public boolean aimWhileShooting = false; + public boolean onSoundBegin = false; + public boolean playBurstSound = true; // Internal Only + public byte aimType = 0; public boolean projectilesKeepTerrain = false; + public EnumCreatureAttribute creatureType = EnumCreatureAttribute.UNDEFINED; - private final EntityNPCInterface npc; + private EntityNPCInterface npc; public boolean attackInvisible = false; // 0 - Yes, 1 - No, 2 - Only NPCs, 3 - Only Players, 4 - NPCs and Players @@ -108,8 +113,13 @@ public class DataStats { compound.setInteger("pTrail", pTrail.ordinal()); compound.setInteger("pEffAmp", pEffAmp); compound.setString("FiringSound", fireSound); - compound.setBoolean("AimWhileShooting", aimWhileShooting); + compound.setBoolean("FiringSoundBegin", onSoundBegin); + compound.setByte("AimType", aimType); compound.setBoolean("ProjectilesKeepTerrain", projectilesKeepTerrain); + if(pTrail == EnumParticleType.Custom) + compound.setTag("pCustom", pCustom.writeToNBT()); + if(pEffect == EnumPotionType.Fire) + compound.setBoolean("pBurnItem", pBurnItem); compound.setBoolean("ImmuneToFire", immuneToFire); compound.setBoolean("PotionImmune", potionImmune); @@ -172,8 +182,13 @@ public class DataStats { pTrail = EnumParticleType.values()[compound.getInteger("pTrail") % EnumParticleType.values().length]; pEffAmp = compound.getInteger("pEffAmp"); fireSound = compound.getString("FiringSound"); - aimWhileShooting = compound.getBoolean("AimWhileShooting"); + onSoundBegin = compound.getBoolean("FiringSoundBegin"); + aimType = compound.getByte("AimType"); projectilesKeepTerrain = compound.getBoolean("ProjectilesKeepTerrain"); + if(pTrail == EnumParticleType.Custom) + pCustom = ScriptParticle.fromNBT(compound.getCompoundTag("pCustom")); + if(pEffect == EnumPotionType.Fire) + pBurnItem = compound.getBoolean("pBurnItem"); immuneToFire = compound.getBoolean("ImmuneToFire"); potionImmune = compound.getBoolean("PotionImmune"); diff --git a/src/main/java/noppes/npcs/EventHooks.java b/src/main/java/noppes/npcs/EventHooks.java index 4137c25d1..18931ac86 100644 --- a/src/main/java/noppes/npcs/EventHooks.java +++ b/src/main/java/noppes/npcs/EventHooks.java @@ -11,6 +11,7 @@ import net.minecraft.inventory.Container; import net.minecraft.item.ItemStack; import net.minecraft.util.DamageSource; import net.minecraft.world.World; +import net.minecraft.world.WorldServer; import net.minecraftforge.event.entity.EntityEvent; import net.minecraftforge.event.world.WorldEvent; import noppes.npcs.api.IWorld; @@ -20,6 +21,7 @@ import noppes.npcs.api.gui.ICustomGui; import noppes.npcs.api.gui.IItemSlot; import noppes.npcs.api.handler.data.IAnimation; import noppes.npcs.api.handler.data.IFrame; +import noppes.npcs.api.handler.data.IPlayerEffect; import noppes.npcs.api.handler.data.IProfile; import noppes.npcs.api.item.IItemCustomizable; import noppes.npcs.api.item.IItemLinked; @@ -33,7 +35,8 @@ import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.entity.EntityProjectile; import noppes.npcs.scripted.NpcAPI; import noppes.npcs.scripted.event.*; -import noppes.npcs.scripted.event.PlayerEvent.*; +import noppes.npcs.scripted.event.player.*; +import noppes.npcs.scripted.event.player.PlayerEvent.*; import org.apache.commons.lang3.StringUtils; import java.util.ArrayList; @@ -371,18 +374,18 @@ public class EventHooks { } public static void onPlayerInit(PlayerDataScript handler, IPlayer player) { - noppes.npcs.scripted.event.PlayerEvent.InitEvent event = new noppes.npcs.scripted.event.PlayerEvent.InitEvent(player); + PlayerEvent.InitEvent event = new PlayerEvent.InitEvent(player); handler.callScript(EnumScriptType.INIT, event); NpcAPI.EVENT_BUS.post(event); } public static void onPlayerTick(PlayerDataScript handler, IPlayer player) { - noppes.npcs.scripted.event.PlayerEvent.UpdateEvent event = new noppes.npcs.scripted.event.PlayerEvent.UpdateEvent(player); + PlayerEvent.UpdateEvent event = new PlayerEvent.UpdateEvent(player); handler.callScript(EnumScriptType.TICK, event); NpcAPI.EVENT_BUS.post(event); } - public static boolean onPlayerInteract(PlayerDataScript handler, noppes.npcs.scripted.event.PlayerEvent.InteractEvent event) { + public static boolean onPlayerInteract(PlayerDataScript handler, PlayerEvent.InteractEvent event) { handler.callScript(EnumScriptType.INTERACT, event); return NpcAPI.EVENT_BUS.post(event); } @@ -405,6 +408,27 @@ public class EventHooks { return NpcAPI.EVENT_BUS.post(event); } + public static boolean onEffectAdded(IPlayer player, IPlayerEffect effect) { + PlayerDataScript handler = ScriptController.Instance.getPlayerScripts(player); + PlayerEvent.EffectEvent.Added event = new PlayerEvent.EffectEvent.Added(player, effect); + handler.callScript(EffectScript.ScriptType.OnEffectAdd.function, event); + return NpcAPI.EVENT_BUS.post(event); + } + + public static boolean onEffectTick(IPlayer player, IPlayerEffect effect) { + PlayerDataScript handler = ScriptController.Instance.getPlayerScripts(player); + PlayerEvent.EffectEvent.Ticked event = new PlayerEvent.EffectEvent.Ticked(player, effect); + handler.callScript(EffectScript.ScriptType.OnEffectTick.function, event); + return NpcAPI.EVENT_BUS.post(event); + } + + public static boolean onEffectRemove(IPlayer player, IPlayerEffect effect, EffectEvent.ExpirationType type) { + PlayerDataScript handler = ScriptController.Instance.getPlayerScripts(player); + PlayerEvent.EffectEvent.Removed event = new PlayerEvent.EffectEvent.Removed(player, effect, type); + handler.callScript(EffectScript.ScriptType.OnEffectRemove.function, event); + return NpcAPI.EVENT_BUS.post(event); + } + public static boolean onStartUsingItem(PlayerDataScript handler, IPlayer player, int duration, ItemStack item) { PlayerEvent.StartUsingItem event = new PlayerEvent.StartUsingItem(player, item, duration); handler.callScript(EnumScriptType.START_USING_ITEM, event); @@ -465,41 +489,41 @@ public class EventHooks { } public static void onPlayerUseHoe(PlayerDataScript handler, IPlayer player, ItemStack hoe, int x, int y, int z) { - noppes.npcs.scripted.event.PlayerEvent.UseHoe event = new noppes.npcs.scripted.event.PlayerEvent.UseHoe(player, hoe, x, y, z); + PlayerEvent.UseHoe event = new PlayerEvent.UseHoe(player, hoe, x, y, z); handler.callScript(EnumScriptType.USE_HOE, event); NpcAPI.EVENT_BUS.post(event); } public static void onPlayerSleep(PlayerDataScript handler, IPlayer player, int x, int y, int z) { - noppes.npcs.scripted.event.PlayerEvent.Sleep event = new noppes.npcs.scripted.event.PlayerEvent.Sleep(player, x, y, z); + PlayerEvent.Sleep event = new PlayerEvent.Sleep(player, x, y, z); handler.callScript(EnumScriptType.SLEEP, event); NpcAPI.EVENT_BUS.post(event); } public static void onPlayerWakeUp(PlayerDataScript handler, IPlayer player, boolean setSpawn) { - noppes.npcs.scripted.event.PlayerEvent.WakeUp event = new noppes.npcs.scripted.event.PlayerEvent.WakeUp(player, setSpawn); + PlayerEvent.WakeUp event = new PlayerEvent.WakeUp(player, setSpawn); handler.callScript(EnumScriptType.WAKE_UP, event); NpcAPI.EVENT_BUS.post(event); } public static void onPlayerDeath(PlayerDataScript handler, IPlayer player, DamageSource source, Entity entity) { - noppes.npcs.scripted.event.PlayerEvent.DiedEvent event = new noppes.npcs.scripted.event.PlayerEvent.DiedEvent(player, source, entity); + PlayerEvent.DiedEvent event = new PlayerEvent.DiedEvent(player, source, entity); handler.callScript(EnumScriptType.KILLED, event); NpcAPI.EVENT_BUS.post(event); } public static void onPlayerKills(PlayerDataScript handler, IPlayer player, EntityLivingBase entityLiving) { - noppes.npcs.scripted.event.PlayerEvent.KilledEntityEvent event = new noppes.npcs.scripted.event.PlayerEvent.KilledEntityEvent(player, entityLiving); + PlayerEvent.KilledEntityEvent event = new PlayerEvent.KilledEntityEvent(player, entityLiving); handler.callScript(EnumScriptType.KILLS, event); NpcAPI.EVENT_BUS.post(event); } - public static boolean onPlayerAttacked(PlayerDataScript handler, noppes.npcs.scripted.event.PlayerEvent.AttackedEvent event) { + public static boolean onPlayerAttacked(PlayerDataScript handler, PlayerEvent.AttackedEvent event) { handler.callScript(EnumScriptType.ATTACKED, event); return NpcAPI.EVENT_BUS.post(event); } - public static boolean onPlayerDamaged(PlayerDataScript handler, noppes.npcs.scripted.event.PlayerEvent.DamagedEvent event) { + public static boolean onPlayerDamaged(PlayerDataScript handler, PlayerEvent.DamagedEvent event) { handler.callScript(EnumScriptType.DAMAGED, event); return NpcAPI.EVENT_BUS.post(event); } @@ -569,12 +593,12 @@ public class EventHooks { NpcAPI.EVENT_BUS.post(event); } - public static boolean onPlayerBowCharge(PlayerDataScript handler, noppes.npcs.scripted.event.PlayerEvent.RangedChargeEvent event) { + public static boolean onPlayerBowCharge(PlayerDataScript handler, PlayerEvent.RangedChargeEvent event) { handler.callScript(EnumScriptType.RANGED_CHARGE, event); return NpcAPI.EVENT_BUS.post(event); } - public static boolean onPlayerRanged(PlayerDataScript handler, noppes.npcs.scripted.event.PlayerEvent.RangedLaunchedEvent event) { + public static boolean onPlayerRanged(PlayerDataScript handler, PlayerEvent.RangedLaunchedEvent event) { handler.callScript(EnumScriptType.RANGED_LAUNCHED, event); return NpcAPI.EVENT_BUS.post(event); } @@ -596,22 +620,22 @@ public class EventHooks { } public static void onPlayerMouseClicked(EntityPlayerMP player, int button, int mouseWheel, boolean buttonDown, boolean isCtrlPressed, boolean isShiftPressed, boolean isAltPressed, boolean isMetaPressed, int[] heldKeys) { - PlayerDataScript handler = ScriptController.Instance.playerScripts; + PlayerDataScript handler = ScriptController.Instance.getPlayerScripts(player); PlayerEvent.MouseClickedEvent event = new PlayerEvent.MouseClickedEvent((IPlayer) NpcAPI.Instance().getIEntity(player), button, mouseWheel, buttonDown, isCtrlPressed, isAltPressed, isShiftPressed, isMetaPressed, heldKeys); handler.callScript(EnumScriptType.MOUSE_CLICKED, event); NpcAPI.EVENT_BUS.post(event); } public static void onPlayerKeyPressed(EntityPlayerMP player, int button, boolean isCtrlPressed, boolean isShiftPressed, boolean isAltPressed, boolean isMetaPressed, boolean buttonDown, int[] heldKeys) { - PlayerDataScript handler = ScriptController.Instance.playerScripts; + PlayerDataScript handler = ScriptController.Instance.getPlayerScripts(player); KeyPressedEvent event = new KeyPressedEvent((IPlayer) NpcAPI.Instance().getIEntity(player), button, isCtrlPressed, isAltPressed, isShiftPressed, isMetaPressed, buttonDown, heldKeys); handler.callScript(EnumScriptType.KEY_PRESSED, event); NpcAPI.EVENT_BUS.post(event); } public static void onPlayerTimer(PlayerData data, int id) { - PlayerDataScript handler = ScriptController.Instance.playerScripts; - noppes.npcs.scripted.event.PlayerEvent.TimerEvent event = new noppes.npcs.scripted.event.PlayerEvent.TimerEvent((IPlayer) NpcAPI.Instance().getIEntity(data.player), id); + PlayerDataScript handler = ScriptController.Instance.getPlayerScripts(data.player); + PlayerEvent.TimerEvent event = new PlayerEvent.TimerEvent((IPlayer) NpcAPI.Instance().getIEntity(data.player), id); handler.callScript(EnumScriptType.TIMER, event); NpcAPI.EVENT_BUS.post(event); } @@ -628,7 +652,7 @@ public class EventHooks { public static void onForgeWorldEvent(WorldEvent event) { if (ScriptController.Instance.forgeScripts.isEnabled()) { - IWorld e = NpcAPI.Instance().getIWorld(event.world); + IWorld e = NpcAPI.Instance().getIWorld((WorldServer) event.world); onForgeEvent(new noppes.npcs.scripted.event.ForgeEvent.WorldEvent(event, e), event); } } @@ -667,8 +691,8 @@ public class EventHooks { return false; } - public static boolean onScriptedCommand(CustomNPCsEvent.ScriptedCommandEvent event) { - ScriptController.Instance.playerScripts.callScript(EnumScriptType.SCRIPT_COMMAND, event); + public static boolean onScriptedCommand(EntityPlayer player, CustomNPCsEvent.ScriptedCommandEvent event) { + ScriptController.Instance.getPlayerScripts(player).callScript(EnumScriptType.SCRIPT_COMMAND, event); return NpcAPI.EVENT_BUS.post(event); } @@ -698,50 +722,50 @@ public class EventHooks { } public static void onCustomGuiClose(IPlayer player, ICustomGui gui) { - noppes.npcs.scripted.event.CustomGuiEvent.CloseEvent event = new noppes.npcs.scripted.event.CustomGuiEvent.CloseEvent(player, gui); + CustomGuiEvent.CloseEvent event = new CustomGuiEvent.CloseEvent(player, gui); CustomGuiController.onClose(event); } public static void onQuestFinished(EntityPlayer player, Quest quest) { - PlayerDataScript handler = ScriptController.Instance.playerScripts; - QuestEvent.QuestCompletedEvent event = new QuestEvent.QuestCompletedEvent((IPlayer) NpcAPI.Instance().getIEntity(player), quest); + PlayerDataScript handler = ScriptController.Instance.getPlayerScripts(player); + QuestEvent.QuestCompletedEvent event = new QuestEvent.QuestCompletedEvent((IPlayer) NpcAPI.Instance().getIEntity((EntityPlayerMP) player), quest); handler.callScript(EnumScriptType.QUEST_COMPLETED, event); NpcAPI.EVENT_BUS.post(event); } public static boolean onQuestStarted(EntityPlayer player, Quest quest) { - PlayerDataScript handler = ScriptController.Instance.playerScripts; - QuestEvent.QuestStartEvent event = new QuestEvent.QuestStartEvent((IPlayer) NpcAPI.Instance().getIEntity(player), quest); + PlayerDataScript handler = ScriptController.Instance.getPlayerScripts(player); + QuestEvent.QuestStartEvent event = new QuestEvent.QuestStartEvent((IPlayer) NpcAPI.Instance().getIEntity((EntityPlayerMP) player), quest); handler.callScript(EnumScriptType.QUEST_START, event); return NpcAPI.EVENT_BUS.post(event); } - public static void onQuestTurnedIn(QuestEvent.QuestTurnedInEvent event) { - PlayerDataScript handler = ScriptController.Instance.playerScripts; + public static void onQuestTurnedIn(EntityPlayer player, QuestEvent.QuestTurnedInEvent event) { + PlayerDataScript handler = ScriptController.Instance.getPlayerScripts(player); handler.callScript(EnumScriptType.QUEST_TURNIN, event); NpcAPI.EVENT_BUS.post(event); } - public static boolean onFactionPoints(FactionEvent.FactionPoints event) { - PlayerDataScript handler = ScriptController.Instance.playerScripts; + public static boolean onFactionPoints(EntityPlayer player, FactionEvent.FactionPoints event) { + PlayerDataScript handler = ScriptController.Instance.getPlayerScripts(player); handler.callScript(EnumScriptType.FACTION_POINTS, event); return NpcAPI.EVENT_BUS.post(event); } - public static boolean onDialogOpen(DialogEvent.DialogOpen event) { - PlayerDataScript handler = ScriptController.Instance.playerScripts; + public static boolean onDialogOpen(EntityPlayer player, DialogEvent.DialogOpen event) { + PlayerDataScript handler = ScriptController.Instance.getPlayerScripts(player); handler.callScript(EnumScriptType.DIALOG_OPEN, event); return NpcAPI.EVENT_BUS.post(event); } - public static boolean onDialogOption(DialogEvent.DialogOption event) { - PlayerDataScript handler = ScriptController.Instance.playerScripts; + public static boolean onDialogOption(EntityPlayer player, DialogEvent.DialogOption event) { + PlayerDataScript handler = ScriptController.Instance.getPlayerScripts(player); handler.callScript(EnumScriptType.DIALOG_OPTION, event); return NpcAPI.EVENT_BUS.post(event); } - public static void onDialogClosed(DialogEvent.DialogClosed event) { - PlayerDataScript handler = ScriptController.Instance.playerScripts; + public static void onDialogClosed(EntityPlayer player, DialogEvent.DialogClosed event) { + PlayerDataScript handler = ScriptController.Instance.getPlayerScripts(player); handler.callScript(EnumScriptType.DIALOG_CLOSE, event); NpcAPI.EVENT_BUS.post(event); } @@ -851,46 +875,67 @@ public class EventHooks { } public static void onPartyFinished(Party party, Quest quest) { - PlayerDataScript handler = ScriptController.Instance.playerScripts; - PartyEvent.PartyQuestCompletedEvent event = new PartyEvent.PartyQuestCompletedEvent(party, quest); - handler.callScript(EnumScriptType.PARTY_QUEST_COMPLETED, event); - NpcAPI.EVENT_BUS.post(event); + EntityPlayer player = party.getPartyLeader(); + if(player != null){ + PlayerDataScript handler = ScriptController.Instance.getPlayerScripts(player); + PartyEvent.PartyQuestCompletedEvent event = new PartyEvent.PartyQuestCompletedEvent(party, quest); + handler.callScript(EnumScriptType.PARTY_QUEST_COMPLETED, event); + NpcAPI.EVENT_BUS.post(event); + } } - public static void onPartyQuestSet(PartyEvent.PartyQuestSetEvent event) { - PlayerDataScript handler = ScriptController.Instance.playerScripts; - handler.callScript(EnumScriptType.PARTY_QUEST_SET, event); - NpcAPI.EVENT_BUS.post(event); + public static void onPartyQuestSet(Party party, PartyEvent.PartyQuestSetEvent event) { + EntityPlayer player = party.getPartyLeader(); + if(player != null){ + PlayerDataScript handler = ScriptController.Instance.getPlayerScripts(player); + handler.callScript(EnumScriptType.PARTY_QUEST_SET, event); + NpcAPI.EVENT_BUS.post(event); + } } - public static void onPartyTurnIn(PartyEvent.PartyQuestTurnedInEvent event) { - PlayerDataScript handler = ScriptController.Instance.playerScripts; - handler.callScript(EnumScriptType.PARTY_QUEST_TURNED_IN, event); - NpcAPI.EVENT_BUS.post(event); + public static void onPartyTurnIn(Party party, PartyEvent.PartyQuestTurnedInEvent event) { + EntityPlayer player = party.getPartyLeader(); + if(player != null){ + PlayerDataScript handler = ScriptController.Instance.getPlayerScripts(player); + handler.callScript(EnumScriptType.PARTY_QUEST_TURNED_IN, event); + NpcAPI.EVENT_BUS.post(event); + } } - public static void onPartyInvite(PartyEvent.PartyInviteEvent event) { - PlayerDataScript handler = ScriptController.Instance.playerScripts; - handler.callScript(EnumScriptType.PARTY_INVITE, event); - NpcAPI.EVENT_BUS.post(event); + public static void onPartyInvite(Party party, PartyEvent.PartyInviteEvent event) { + EntityPlayer player = party.getPartyLeader(); + if(player != null){ + PlayerDataScript handler = ScriptController.Instance.getPlayerScripts(player); + handler.callScript(EnumScriptType.PARTY_INVITE, event); + NpcAPI.EVENT_BUS.post(event); + } } - public static void onPartyKick(PartyEvent.PartyKickEvent event) { - PlayerDataScript handler = ScriptController.Instance.playerScripts; - handler.callScript(EnumScriptType.PARTY_KICK, event); - NpcAPI.EVENT_BUS.post(event); + public static void onPartyKick(Party party, PartyEvent.PartyKickEvent event) { + EntityPlayer player = party.getPartyLeader(); + if(player != null){ + PlayerDataScript handler = ScriptController.Instance.getPlayerScripts(player); + handler.callScript(EnumScriptType.PARTY_KICK, event); + NpcAPI.EVENT_BUS.post(event); + } } - public static void onPartyLeave(PartyEvent.PartyLeaveEvent event) { - PlayerDataScript handler = ScriptController.Instance.playerScripts; - handler.callScript(EnumScriptType.PARTY_LEAVE, event); - NpcAPI.EVENT_BUS.post(event); + public static void onPartyLeave(Party party, PartyEvent.PartyLeaveEvent event) { + EntityPlayer player = party.getPartyLeader(); + if(player != null){ + PlayerDataScript handler = ScriptController.Instance.getPlayerScripts(player); + handler.callScript(EnumScriptType.PARTY_LEAVE, event); + NpcAPI.EVENT_BUS.post(event); + } } - public static void onPartyDisband(PartyEvent.PartyDisbandEvent event) { - PlayerDataScript handler = ScriptController.Instance.playerScripts; - handler.callScript(EnumScriptType.PARTY_DISBAND, event); - NpcAPI.EVENT_BUS.post(event); + public static void onPartyDisband(Party party, PartyEvent.PartyDisbandEvent event) { + EntityPlayer player = party.getPartyLeader(); + if(player != null){ + PlayerDataScript handler = ScriptController.Instance.getPlayerScripts(player); + handler.callScript(EnumScriptType.PARTY_DISBAND, event); + NpcAPI.EVENT_BUS.post(event); + } } private static boolean postAnimationEvent(IAnimationEvent event) { @@ -900,7 +945,7 @@ public class EventHooks { EntityNPCInterface npc = (EntityNPCInterface) ((ICustomNpc) animatable).getMCEntity(); handler = npc.script; } else { - handler = ScriptController.Instance.playerScripts; + handler = ScriptController.Instance.getPlayerScripts((IPlayer) animatable); } if (handler.isClient()) diff --git a/src/main/java/noppes/npcs/IChatMessages.java b/src/main/java/noppes/npcs/IChatMessages.java index 19f9a66c3..387f809c2 100644 --- a/src/main/java/noppes/npcs/IChatMessages.java +++ b/src/main/java/noppes/npcs/IChatMessages.java @@ -4,8 +4,8 @@ import noppes.npcs.entity.EntityNPCInterface; public interface IChatMessages { - void addMessage(String message, EntityNPCInterface npc); + public void addMessage(String message, EntityNPCInterface npc); - void renderMessages(double par3, double par5, double par7, float scale, boolean inRange); + public void renderMessages(double par3, double par5, double par7, float scale, boolean inRange); } diff --git a/src/main/java/noppes/npcs/ICompatibilty.java b/src/main/java/noppes/npcs/ICompatibilty.java index a6e2a8bd8..e552cca13 100644 --- a/src/main/java/noppes/npcs/ICompatibilty.java +++ b/src/main/java/noppes/npcs/ICompatibilty.java @@ -3,9 +3,9 @@ package noppes.npcs; import net.minecraft.nbt.NBTTagCompound; public interface ICompatibilty { - int getVersion(); + public int getVersion(); - void setVersion(int version); + public void setVersion(int version); - NBTTagCompound writeToNBT(NBTTagCompound compound); + public NBTTagCompound writeToNBT(NBTTagCompound compound); } diff --git a/src/main/java/noppes/npcs/LogWriter.java b/src/main/java/noppes/npcs/LogWriter.java index 854712b4c..2c14af3a6 100644 --- a/src/main/java/noppes/npcs/LogWriter.java +++ b/src/main/java/noppes/npcs/LogWriter.java @@ -67,7 +67,7 @@ public class LogWriter { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); record.getThrown().printStackTrace(pw); - return time + sw; + return time + sw.toString(); } return time + record.getMessage() + System.getProperty("line.separator"); } @@ -222,4 +222,4 @@ class NPCStamp { public Date makeDate = new Date(); public Date recentDate = new Date(); public int counter = 1; -} +}; diff --git a/src/main/java/noppes/npcs/NBTTags.java b/src/main/java/noppes/npcs/NBTTags.java index 5ea564fba..d8771caf5 100644 --- a/src/main/java/noppes/npcs/NBTTags.java +++ b/src/main/java/noppes/npcs/NBTTags.java @@ -520,7 +520,7 @@ public class NBTTags { long slot = ((Long) var2.next()).longValue(); NBTTagCompound nbttagcompound = new NBTTagCompound(); nbttagcompound.setLong("Long", slot); - nbttagcompound.setString("String", map.get(Long.valueOf(slot))); + nbttagcompound.setString("String", (String) map.get(Long.valueOf(slot))); nbttaglist.appendTag(nbttagcompound); } diff --git a/src/main/java/noppes/npcs/NPCSpawning.java b/src/main/java/noppes/npcs/NPCSpawning.java index a5a69d51b..28b8c320c 100644 --- a/src/main/java/noppes/npcs/NPCSpawning.java +++ b/src/main/java/noppes/npcs/NPCSpawning.java @@ -29,7 +29,7 @@ import noppes.npcs.scripted.event.CustomNPCsEvent; import java.util.*; public class NPCSpawning { - private static final Set eligibleChunksForSpawning = Sets.newHashSet(); + private static Set eligibleChunksForSpawning = Sets.newHashSet(); private static boolean animalSpawn; private static boolean monsterSpawn; @@ -49,7 +49,9 @@ public class NPCSpawning { for (int x = -size; x <= size; ++x) { for (int z = -size; z <= size; ++z) { ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(x + j, z + k); - eligibleChunksForSpawning.add(chunkcoordintpair); + if (!eligibleChunksForSpawning.contains(chunkcoordintpair)) { + eligibleChunksForSpawning.add(chunkcoordintpair); + } } } } diff --git a/src/main/java/noppes/npcs/NoppesStringUtils.java b/src/main/java/noppes/npcs/NoppesStringUtils.java index 61f5b71e8..f0e2a76f9 100644 --- a/src/main/java/noppes/npcs/NoppesStringUtils.java +++ b/src/main/java/noppes/npcs/NoppesStringUtils.java @@ -20,7 +20,7 @@ public class NoppesStringUtils { public static String cleanFileName(String badFileName) { StringBuilder cleanName = new StringBuilder(); for (int i = 0; i < badFileName.length(); i++) { - int c = badFileName.charAt(i); + int c = (int) badFileName.charAt(i); if (Arrays.binarySearch(illegalChars, c) < 0) { cleanName.append((char) c); } diff --git a/src/main/java/noppes/npcs/NoppesUtilPlayer.java b/src/main/java/noppes/npcs/NoppesUtilPlayer.java index f78d27770..bbfda9523 100644 --- a/src/main/java/noppes/npcs/NoppesUtilPlayer.java +++ b/src/main/java/noppes/npcs/NoppesUtilPlayer.java @@ -34,9 +34,9 @@ import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.roles.RoleFollower; import noppes.npcs.scripted.NpcAPI; import noppes.npcs.scripted.ScriptSound; -import noppes.npcs.scripted.event.DialogEvent; import noppes.npcs.scripted.event.PartyEvent; -import noppes.npcs.scripted.event.QuestEvent; +import noppes.npcs.scripted.event.player.DialogEvent; +import noppes.npcs.scripted.event.player.QuestEvent; import java.io.IOException; import java.util.*; @@ -81,7 +81,7 @@ public class NoppesUtilPlayer { public static void transport(EntityPlayerMP player, EntityNPCInterface npc, String location) { TransportLocation loc = TransportController.getInstance().getTransport(location); - PlayerTransportData playerdata = PlayerDataController.Instance.getPlayerData(player).transportData; + PlayerTransportData playerdata = PlayerData.get(player).transportData; if (loc == null || !loc.isDefault() && !playerdata.transports.contains(loc.id)) return; @@ -265,18 +265,18 @@ public class NoppesUtilPlayer { if (dialog == null) return; DialogOption option = dialog.options.get(optionId); - if (EventHooks.onDialogOption(new DialogEvent.DialogOption((IPlayer) NpcAPI.Instance().getIEntity(player), dialog))) + if (EventHooks.onDialogOption(player, new DialogEvent.DialogOption((IPlayer) NpcAPI.Instance().getIEntity(player), dialog))) return; if (!npc.isRemote()) { EventHooks.onNPCDialogClosed(npc, player, dialogId, optionId + 1, dialog); if (!dialog.hasDialogs(player) && !dialog.hasOtherOptions()) { - EventHooks.onDialogClosed(new DialogEvent.DialogClosed((IPlayer) NpcAPI.Instance().getIEntity(player), dialog)); + EventHooks.onDialogClosed(player, new DialogEvent.DialogClosed((IPlayer) NpcAPI.Instance().getIEntity(player), dialog)); return; } if (option == null || option.optionType == EnumOptionType.DialogOption && (!option.isAvailable(player) || !option.hasDialog()) || option.optionType == EnumOptionType.Disabled || option.optionType == EnumOptionType.QuitOption) { - EventHooks.onDialogClosed(new DialogEvent.DialogClosed((IPlayer) NpcAPI.Instance().getIEntity(player), dialog)); + EventHooks.onDialogClosed(player, new DialogEvent.DialogClosed((IPlayer) NpcAPI.Instance().getIEntity(player), dialog)); return; } } @@ -295,7 +295,7 @@ public class NoppesUtilPlayer { } public static void updateQuestLogData(ByteBuf buffer, EntityPlayerMP player) throws IOException { - PlayerData playerData = PlayerDataController.Instance.getPlayerData(player); + PlayerData playerData = PlayerData.get(player); NBTTagCompound compound = ByteBufUtils.readNBT(buffer); HashMap questAlerts = NBTTags.getStringStringMap(compound.getTagList("Alerts", 10)); @@ -316,13 +316,13 @@ public class NoppesUtilPlayer { } public static void clearTrackQuest(EntityPlayerMP player) throws IOException { - PlayerData playerData = PlayerDataController.Instance.getPlayerData(player); + PlayerData playerData = PlayerData.get(player); playerData.questData.untrackQuest(); } public static void updatePartyQuestLogData(ByteBuf buffer, EntityPlayerMP player) throws IOException { - PlayerData playerData = PlayerDataController.Instance.getPlayerData(player); + PlayerData playerData = PlayerData.get(player); String trackedQuestString = ByteBufUtils.readString(buffer); Quest trackedQuest = getQuestFromStringKey(trackedQuestString); if (trackedQuest != null) { @@ -362,7 +362,7 @@ public class NoppesUtilPlayer { } public static void sendTrackedQuestData(EntityPlayerMP player) { - Quest trackedQuest = (Quest) PlayerDataController.Instance.getPlayerData(player).questData.getTrackedQuest(); + Quest trackedQuest = (Quest) PlayerData.get(player).questData.getTrackedQuest(); if (trackedQuest != null) { NBTTagCompound compound = new NBTTagCompound(); compound.setTag("Quest", trackedQuest.writeToNBT(new NBTTagCompound())); @@ -383,7 +383,7 @@ public class NoppesUtilPlayer { } public static void sendPartyTrackedQuestData(EntityPlayerMP player, Party party) { - Quest trackedQuest = (Quest) PlayerDataController.Instance.getPlayerData(player).questData.getTrackedQuest(); + Quest trackedQuest = (Quest) PlayerData.get(player).questData.getTrackedQuest(); if (trackedQuest != null) { NBTTagCompound compound = new NBTTagCompound(); compound.setTag("Quest", trackedQuest.writeToNBT(new NBTTagCompound())); @@ -424,7 +424,7 @@ public class NoppesUtilPlayer { if (player == null) return false; - PlayerData playerData = PlayerDataController.Instance.getPlayerData(player); + PlayerData playerData = PlayerData.get(player); PlayerQuestData questData = playerData.questData; QuestData data = questData.activeQuests.get(questId); @@ -455,12 +455,12 @@ public class NoppesUtilPlayer { } if (!data.quest.randomReward) { - event.itemRewards = list.toArray(new IItemStack[list.size()]); + event.itemRewards = (IItemStack[]) list.toArray(new IItemStack[list.size()]); } else if (!list.isEmpty()) { - event.itemRewards = new IItemStack[]{list.get(player.getRNG().nextInt(list.size()))}; + event.itemRewards = new IItemStack[]{(IItemStack) list.get(player.getRNG().nextInt(list.size()))}; } - EventHooks.onQuestTurnedIn(event); + EventHooks.onQuestTurnedIn(player, event); if (event.isCancelled()) return false; @@ -521,7 +521,7 @@ public class NoppesUtilPlayer { EventHooks.onPartyFinished(party, data.quest); PartyEvent.PartyQuestTurnedInEvent partyEv = new PartyEvent.PartyQuestTurnedInEvent(party, data.quest); - EventHooks.onPartyTurnIn(partyEv); + EventHooks.onPartyTurnIn(party, partyEv); if (partyEv.isCancelled()) return false; @@ -535,7 +535,7 @@ public class NoppesUtilPlayer { if (player == null) continue; - PlayerData playerData = PlayerDataController.Instance.getPlayerData(player); + PlayerData playerData = PlayerData.get(player); if (playerData == null) continue; @@ -571,12 +571,12 @@ public class NoppesUtilPlayer { } if (!data.quest.randomReward) { - event.itemRewards = list.toArray(new IItemStack[list.size()]); + event.itemRewards = (IItemStack[]) list.toArray(new IItemStack[list.size()]); } else if (!list.isEmpty()) { - event.itemRewards = new IItemStack[]{list.get(player.getRNG().nextInt(list.size()))}; + event.itemRewards = new IItemStack[]{(IItemStack) list.get(player.getRNG().nextInt(list.size()))}; } - EventHooks.onQuestTurnedIn(event); + EventHooks.onQuestTurnedIn(player, event); if (event.isCancelled()) continue; @@ -634,7 +634,7 @@ public class NoppesUtilPlayer { if (player == null) continue; - PlayerData playerData = PlayerDataController.Instance.getPlayerData(player); + PlayerData playerData = PlayerData.get(player); if (playerData == null) continue; @@ -673,18 +673,20 @@ public class NoppesUtilPlayer { boolean oreMatched = false; OreDictionary.itemMatches(item, item2, false); int[] ids = OreDictionary.getOreIDs(item); - for (int id : ids) { - boolean match1 = false, match2 = false; - for (ItemStack is : OreDictionary.getOres(id)) { - if (compareItemDetails(item, is, ignoreDamage, ignoreNBT)) { - match1 = true; - } - if (compareItemDetails(item2, is, ignoreDamage, ignoreNBT)) { - match2 = true; + if (ids.length > 0) { + for (int id : ids) { + boolean match1 = false, match2 = false; + for (ItemStack is : OreDictionary.getOres(id)) { + if (compareItemDetails(item, is, ignoreDamage, ignoreNBT)) { + match1 = true; + } + if (compareItemDetails(item2, is, ignoreDamage, ignoreNBT)) { + match2 = true; + } } + if (match1 && match2) + return true; } - if (match1 && match2) - return true; } return compareItemDetails(item, item2, ignoreDamage, ignoreNBT); } @@ -699,13 +701,16 @@ public class NoppesUtilPlayer { if (!ignoreNBT && item.stackTagCompound != null && (item2.stackTagCompound == null || !item.stackTagCompound.equals(item2.stackTagCompound))) { return false; } - return ignoreNBT || item2.stackTagCompound == null || item.stackTagCompound != null; + if (!ignoreNBT && item2.stackTagCompound != null && item.stackTagCompound == null) { + return false; + } + return true; } public static boolean compareItems(EntityPlayer player, ItemStack item, boolean ignoreDamage, boolean ignoreNBT) { int size = 0; for (ItemStack is : player.inventory.mainInventory) { - if (compareItems(item, is, ignoreDamage, ignoreNBT)) + if (is != null && compareItems(item, is, ignoreDamage, ignoreNBT)) size += is.stackSize; } return size >= item.stackSize; @@ -717,7 +722,7 @@ public class NoppesUtilPlayer { int size = item.stackSize; for (int i = 0; i < player.inventory.mainInventory.length; i++) { ItemStack is = player.inventory.mainInventory[i]; - if (!compareItems(item, is, ignoreDamage, ignoreNBT)) + if (is == null || !compareItems(item, is, ignoreDamage, ignoreNBT)) continue; if (size >= is.stackSize) { size -= is.stackSize; diff --git a/src/main/java/noppes/npcs/NoppesUtilServer.java b/src/main/java/noppes/npcs/NoppesUtilServer.java index 6131b0a24..98c01d373 100644 --- a/src/main/java/noppes/npcs/NoppesUtilServer.java +++ b/src/main/java/noppes/npcs/NoppesUtilServer.java @@ -55,7 +55,7 @@ import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.roles.RoleTransporter; import noppes.npcs.scripted.NpcAPI; import noppes.npcs.scripted.ScriptSound; -import noppes.npcs.scripted.event.DialogEvent; +import noppes.npcs.scripted.event.player.DialogEvent; import java.io.File; import java.io.IOException; @@ -65,7 +65,7 @@ import java.util.*; import static kamkeel.npcs.network.packets.data.large.ScrollDataPacket.sendScrollData; public class NoppesUtilServer { - private static final HashMap editingQuests = new HashMap(); + private static HashMap editingQuests = new HashMap(); public static IPlayer getIPlayer(EntityPlayer p) { return (IPlayer) NpcAPI.Instance().getIEntity(p); @@ -80,14 +80,14 @@ public class NoppesUtilServer { } public static void setEditingNpc(EntityPlayer player, EntityNPCInterface npc) { - PlayerData data = PlayerDataController.Instance.getPlayerData(player); + PlayerData data = PlayerData.get(player); data.editingNpc = npc; if (npc != null) PacketHandler.Instance.sendToPlayer(new EditNpcPacket(npc.getEntityId()), (EntityPlayerMP) player); } public static EntityNPCInterface getEditingNpc(EntityPlayer player) { - PlayerData data = PlayerDataController.Instance.getPlayerData(player); + PlayerData data = PlayerData.get(player); return data.editingNpc; } @@ -143,7 +143,7 @@ public class NoppesUtilServer { public static NBTTagCompound writeItem(ItemStack item, NBTTagCompound nbt) { String resourcelocation = Item.itemRegistry.getNameForObject(item.getItem()); - nbt.setString("id", resourcelocation == null ? "minecraft:air" : resourcelocation); + nbt.setString("id", resourcelocation == null ? "minecraft:air" : resourcelocation.toString()); nbt.setByte("Count", (byte) item.stackSize); nbt.setShort("Damage", (short) item.getItemDamage()); @@ -185,6 +185,7 @@ public class NoppesUtilServer { try { return Item.getItemById(Integer.parseInt(id)); } catch (NumberFormatException numberformatexception) { + ; } } @@ -199,7 +200,7 @@ public class NoppesUtilServer { if (EventHooks.onNPCDialog(npc, player, dialog.id, optionId, dialog)) { return; } - if (EventHooks.onDialogOpen(new DialogEvent.DialogOpen((IPlayer) NpcAPI.Instance().getIEntity(player), dialog))) { + if (EventHooks.onDialogOpen(player, new DialogEvent.DialogOpen((IPlayer) NpcAPI.Instance().getIEntity(player), dialog))) { return; } } @@ -218,7 +219,7 @@ public class NoppesUtilServer { } if (dialog.mail.isValid()) PlayerDataController.Instance.addPlayerMessage(player.getCommandSenderName(), dialog.mail); - PlayerDialogData data = PlayerDataController.Instance.getPlayerData(player).dialogData; + PlayerDialogData data = PlayerData.get(player).dialogData; if (!data.dialogsRead.contains(dialog.id) && dialog.id >= 0) { data.dialogsRead.add(dialog.id); playerdata.updateClient = true; @@ -355,7 +356,7 @@ public class NoppesUtilServer { list.add(loc.name); } } - PlayerTransportData playerdata = PlayerDataController.Instance.getPlayerData(player).transportData; + PlayerTransportData playerdata = PlayerData.get(player).transportData; for (int i : playerdata.transports) { TransportLocation loc = TransportController.getInstance().getTransport(i); if (loc != null && location.category.locations.containsKey(loc.id)) { @@ -527,7 +528,7 @@ public class NoppesUtilServer { if (pl == null) playerdata = PlayerDataController.Instance.getDataFromUsername(name); else - playerdata = PlayerDataController.Instance.getPlayerData(pl); + playerdata = PlayerData.get(pl); if (type == EnumPlayerData.Players) { String fileType = ".json"; @@ -705,15 +706,15 @@ public class NoppesUtilServer { public static void sendMagicInfo(EntityPlayerMP player, boolean cycles) { HashMap map = new HashMap(); if (cycles) { - for (Magic magic : MagicController.getInstance().magics.values()) { - map.put(magic.name, magic.id); - } - sendScrollData(player, map, EnumScrollData.MAGIC); - } else { for (MagicCycle magicCycle : MagicController.getInstance().cycles.values()) { map.put(magicCycle.name, magicCycle.id); } sendScrollData(player, map, EnumScrollData.MAGIC_CYCLES); + } else { + for (Magic magic : MagicController.getInstance().magics.values()) { + map.put(magic.name, magic.id); + } + sendScrollData(player, map, EnumScrollData.MAGIC); } } @@ -766,7 +767,7 @@ public class NoppesUtilServer { ContainerManageRecipes container = (ContainerManageRecipes) player.openContainer; container.setRecipe(recipe); - GuiDataPacket.sendGuiData(player, recipe.writeNBT()); + GuiDataPacket.sendGuiData((EntityPlayerMP) player, recipe.writeNBT()); } public static void setRecipeAnvilGui(EntityPlayerMP player, RecipeAnvil recipe) { @@ -777,13 +778,13 @@ public class NoppesUtilServer { ContainerManageRecipes container = (ContainerManageRecipes) player.openContainer; container.setRecipe(recipe); - GuiDataPacket.sendGuiData(player, recipe.writeNBT()); + GuiDataPacket.sendGuiData((EntityPlayerMP) player, recipe.writeNBT()); } public static void sendBank(EntityPlayerMP player, Bank bank) { NBTTagCompound compound = new NBTTagCompound(); bank.writeEntityToNBT(compound); - GuiDataPacket.sendGuiData(player, compound); + GuiDataPacket.sendGuiData((EntityPlayerMP) player, compound); if (player.openContainer instanceof ContainerManageBanks) { ((ContainerManageBanks) player.openContainer).setBank(bank); @@ -827,7 +828,7 @@ public class NoppesUtilServer { if (entity == null) { return null; } - entity.setPosition((double) x + 0.5, y, (double) z + 0.5); + entity.setPosition((double) x + 0.5, (double) y, (double) z + 0.5); if (entity instanceof EntityNPCInterface) { EntityNPCInterface npc = (EntityNPCInterface) entity; npc.ais.startPos = new int[]{MathHelper.floor_double(npc.posX), MathHelper.floor_double(npc.posY), MathHelper.floor_double(npc.posZ)}; @@ -950,7 +951,7 @@ public class NoppesUtilServer { } public static void isGUIOpen(ByteBuf buffer, EntityPlayer player) throws IOException { - PlayerData playerdata = PlayerDataController.Instance.getPlayerData(player); + PlayerData playerdata = PlayerData.get(player); boolean isGUIOpen = buffer.readBoolean(); playerdata.setGUIOpen(isGUIOpen); } @@ -992,7 +993,7 @@ public class NoppesUtilServer { if (pl == null) playerdata = PlayerDataController.Instance.getDataFromUsername(playerName); else - playerdata = PlayerDataController.Instance.getPlayerData(pl); + playerdata = PlayerData.get(pl); // Assemble quest maps: Map questActiveMap = new HashMap<>(); @@ -1096,7 +1097,7 @@ public class NoppesUtilServer { if (pl == null) playerdata = PlayerDataController.Instance.getDataFromUsername(playerName); else - playerdata = PlayerDataController.Instance.getPlayerData(pl); + playerdata = PlayerData.get(pl); if (enumPlayerData == EnumPlayerData.Quest) { // Quest removal playerdata.questData.activeQuests.remove(value); @@ -1144,7 +1145,7 @@ public class NoppesUtilServer { if (pl == null) playerdata = PlayerDataController.Instance.getDataFromUsername(playerName); else - playerdata = PlayerDataController.Instance.getPlayerData(pl); + playerdata = PlayerData.get(pl); if (enumPlayerData == EnumPlayerData.Magic) { // Quest removal playerdata.magicData.readToNBT(compound); diff --git a/src/main/java/noppes/npcs/QuestLogData.java b/src/main/java/noppes/npcs/QuestLogData.java index ad41ccd0b..50eec29c9 100644 --- a/src/main/java/noppes/npcs/QuestLogData.java +++ b/src/main/java/noppes/npcs/QuestLogData.java @@ -4,7 +4,6 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import noppes.npcs.api.handler.data.IQuest; import noppes.npcs.constants.EnumQuestCompletion; -import noppes.npcs.controllers.PlayerDataController; import noppes.npcs.controllers.PlayerQuestController; import noppes.npcs.controllers.data.Party; import noppes.npcs.controllers.data.PlayerData; @@ -60,7 +59,7 @@ public class QuestLogData { } public void setData(EntityPlayer player) { - PlayerData playerData = PlayerDataController.Instance.getPlayerData(player); + PlayerData playerData = PlayerData.get(player); for (Quest quest : PlayerQuestController.getActiveQuests(player)) { String category = quest.category.title; @@ -99,7 +98,7 @@ public class QuestLogData { } public void setTrackedQuestKey(EntityPlayer player) { - PlayerData playerData = PlayerDataController.Instance.getPlayerData(player); + PlayerData playerData = PlayerData.get(player); Party party = playerData.getPlayerParty(); if (party != null && party.getQuest() != null) { diff --git a/src/main/java/noppes/npcs/ScriptForgeEventHandler.java b/src/main/java/noppes/npcs/ScriptForgeEventHandler.java index eef8121fd..649557b43 100644 --- a/src/main/java/noppes/npcs/ScriptForgeEventHandler.java +++ b/src/main/java/noppes/npcs/ScriptForgeEventHandler.java @@ -65,8 +65,8 @@ public class ScriptForgeEventHandler { public ScriptForgeEventHandler registerForgeEvents() { try { - Method e = this.getClass().getMethod("forgeEntity", Event.class); - Method register = FMLCommonHandler.instance().bus().getClass().getDeclaredMethod("register", Class.class, Object.class, Method.class, ModContainer.class); + Method e = this.getClass().getMethod("forgeEntity", new Class[]{Event.class}); + Method register = FMLCommonHandler.instance().bus().getClass().getDeclaredMethod("register", new Class[]{Class.class, Object.class, Method.class, ModContainer.class}); register.setAccessible(true); ArrayList list = new ArrayList(); list.addAll(ClassPath.from(this.getClass().getClassLoader()).getTopLevelClassesRecursive("cpw.mods.fml.common.gameevent")); @@ -114,7 +114,7 @@ public class ScriptForgeEventHandler { while (var10.hasNext()) { Class c1 = (Class) var10.next(); if (!EntityEvent.EntityConstructing.class.isAssignableFrom(c1) && !WorldEvent.PotentialSpawns.class.isAssignableFrom(c1) && !TickEvent.RenderTickEvent.class.isAssignableFrom(c1) && !TickEvent.ClientTickEvent.class.isAssignableFrom(c1) && !FMLNetworkEvent.ClientCustomPacketEvent.class.isAssignableFrom(c1) && !ItemTooltipEvent.class.isAssignableFrom(c1) && Event.class.isAssignableFrom(c1) && !Modifier.isAbstract(c1.getModifiers()) && Modifier.isPublic(c1.getModifiers()) && !ChunkEvent.class.isAssignableFrom(c1) && !ChunkWatchEvent.class.isAssignableFrom(c1) && !ChunkDataEvent.class.isAssignableFrom(c1)) { - register.invoke(FMLCommonHandler.instance().bus(), c1, this, e, Loader.instance().activeModContainer()); + register.invoke(FMLCommonHandler.instance().bus(), new Object[]{c1, this, e, Loader.instance().activeModContainer()}); } } } diff --git a/src/main/java/noppes/npcs/ScriptItemEventHandler.java b/src/main/java/noppes/npcs/ScriptItemEventHandler.java index fed6c5cf7..7f0e5aa21 100644 --- a/src/main/java/noppes/npcs/ScriptItemEventHandler.java +++ b/src/main/java/noppes/npcs/ScriptItemEventHandler.java @@ -10,6 +10,7 @@ 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.*; +import noppes.npcs.api.IWorld; import noppes.npcs.api.entity.IPlayer; import noppes.npcs.api.item.IItemCustomizable; import noppes.npcs.api.item.IItemStack; @@ -135,7 +136,7 @@ public class ScriptItemEventHandler { if (PlayerDataController.Instance != null) { if (event.action == PlayerInteractEvent.Action.RIGHT_CLICK_AIR) { - PlayerData handler = PlayerDataController.Instance.getPlayerData(event.entityPlayer); + PlayerData handler = PlayerData.get(event.entityPlayer); if (handler == null) return; @@ -154,7 +155,7 @@ public class ScriptItemEventHandler { } catch (Exception e) { } } else if (event.action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK) { - PlayerData handler = PlayerDataController.Instance.getPlayerData(event.entityPlayer); + PlayerData handler = PlayerData.get(event.entityPlayer); if (handler == null) return; @@ -163,7 +164,7 @@ public class ScriptItemEventHandler { if (NoppesUtilServer.isScriptableItem(event.entityPlayer.getHeldItem().getItem()) && !event.isCanceled()) { IItemStack isw = NpcAPI.Instance().getIItemStack(event.entityPlayer.getHeldItem()); if (isw instanceof IItemCustomizable) { - ItemEvent.RightClickEvent eve = new ItemEvent.RightClickEvent((IItemCustomizable) isw, (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer), 2, NpcAPI.Instance().getIBlock(NpcAPI.Instance().getIWorld(event.world), event.x, event.y, event.z)); + ItemEvent.RightClickEvent eve = new ItemEvent.RightClickEvent((IItemCustomizable) 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((IItemCustomizable) isw, eve)); } } diff --git a/src/main/java/noppes/npcs/ScriptPlayerEventHandler.java b/src/main/java/noppes/npcs/ScriptPlayerEventHandler.java index ca02da399..66ad79468 100644 --- a/src/main/java/noppes/npcs/ScriptPlayerEventHandler.java +++ b/src/main/java/noppes/npcs/ScriptPlayerEventHandler.java @@ -52,7 +52,7 @@ public class ScriptPlayerEventHandler { EntityPlayer player = event.player; if (player.ticksExisted % 10 == 0) { - PlayerDataScript handler = ScriptController.Instance.playerScripts; + PlayerDataScript handler = ScriptController.Instance.getPlayerScripts(player); IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(player); EventHooks.onPlayerTick(handler, scriptPlayer); @@ -69,7 +69,8 @@ public class ScriptPlayerEventHandler { } if (PlayerDataController.Instance != null) { - PlayerData playerData = PlayerDataController.Instance.getPlayerData(player); + PlayerData playerData = PlayerData.get(player); + playerData.actionManager.tick(player.ticksExisted); if (playerData.updateClient) { SyncController.syncPlayerData((EntityPlayerMP) player, true); @@ -92,11 +93,11 @@ public class ScriptPlayerEventHandler { Party party = playerData.getPlayerParty(); boolean trackingPartyQuest = playerData.questData.getTrackedQuest() != null && party != null && party.getQuest() != null && party.getQuest().getId() == playerData.questData.getTrackedQuest().getId(); if (playerData.questData.getTrackedQuest() != null && !playerData.questData.activeQuests.containsKey(playerData.questData.getTrackedQuest().getId()) && !trackingPartyQuest) { - PlayerDataController.Instance.getPlayerData(player).questData.untrackQuest(); + PlayerData.get(player).questData.untrackQuest(); } - if (player.ticksExisted % 20 == 0 && !PlayerDataController.Instance.getPlayerData(player).skinOverlays.overlayList.isEmpty()) { - PlayerDataController.Instance.getPlayerData(player).skinOverlays.updateClient(); + if (player.ticksExisted % 20 == 0 && !PlayerData.get(player).skinOverlays.overlayList.isEmpty()) { + PlayerData.get(player).skinOverlays.updateClient(); } if (player.ticksExisted % (TrackedQuestUpdateFrequency * 20) == 0) { @@ -120,10 +121,10 @@ public class ScriptPlayerEventHandler { if (event.entityPlayer == null || event.entityPlayer.worldObj == null) return; - if (!event.entityPlayer.worldObj.isRemote && event.entityPlayer.worldObj instanceof WorldServer) { - PlayerDataScript handler = ScriptController.Instance.playerScripts; + if (!event.entityPlayer.worldObj.isRemote && event.entityPlayer.worldObj instanceof WorldServer && event.entityPlayer instanceof EntityPlayerMP) { + PlayerDataScript handler = ScriptController.Instance.getPlayerScripts(event.entityPlayer); IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer); - noppes.npcs.scripted.event.PlayerEvent.InteractEvent ev = new noppes.npcs.scripted.event.PlayerEvent.InteractEvent(scriptPlayer, 1, NpcAPI.Instance().getIEntity(event.target)); + noppes.npcs.scripted.event.player.PlayerEvent.InteractEvent ev = new noppes.npcs.scripted.event.player.PlayerEvent.InteractEvent(scriptPlayer, 1, NpcAPI.Instance().getIEntity(event.target)); event.setCanceled(EventHooks.onPlayerInteract(handler, ev)); } } @@ -133,10 +134,10 @@ public class ScriptPlayerEventHandler { if (event.entityPlayer == null || event.entityPlayer.worldObj == null) return; - if (!event.entityPlayer.worldObj.isRemote && event.entityPlayer.worldObj instanceof WorldServer) { - PlayerDataScript handler = ScriptController.Instance.playerScripts; + if (!event.entityPlayer.worldObj.isRemote && event.entityPlayer.worldObj instanceof WorldServer && event.entityPlayer instanceof EntityPlayerMP) { + PlayerDataScript handler = ScriptController.Instance.getPlayerScripts(event.entityPlayer); IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer); - noppes.npcs.scripted.event.PlayerEvent.RangedChargeEvent ev = new noppes.npcs.scripted.event.PlayerEvent.RangedChargeEvent(scriptPlayer); + noppes.npcs.scripted.event.player.PlayerEvent.RangedChargeEvent ev = new noppes.npcs.scripted.event.player.PlayerEvent.RangedChargeEvent(scriptPlayer); EventHooks.onPlayerBowCharge(handler, ev); } } @@ -146,10 +147,10 @@ public class ScriptPlayerEventHandler { if (event.entityPlayer == null || event.entityPlayer.worldObj == null) return; - if (!event.entityPlayer.worldObj.isRemote && event.entityPlayer.worldObj instanceof WorldServer) { - PlayerDataScript handler = ScriptController.Instance.playerScripts; + if (!event.entityPlayer.worldObj.isRemote && event.entityPlayer.worldObj instanceof WorldServer && event.entityPlayer instanceof EntityPlayerMP) { + PlayerDataScript handler = ScriptController.Instance.getPlayerScripts(event.entityPlayer); IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer); - noppes.npcs.scripted.event.PlayerEvent.RangedLaunchedEvent ev = new noppes.npcs.scripted.event.PlayerEvent.RangedLaunchedEvent(scriptPlayer, event.bow, event.charge); + noppes.npcs.scripted.event.player.PlayerEvent.RangedLaunchedEvent ev = new noppes.npcs.scripted.event.player.PlayerEvent.RangedLaunchedEvent(scriptPlayer, event.bow, event.charge); EventHooks.onPlayerRanged(handler, ev); } } @@ -164,10 +165,10 @@ public class ScriptPlayerEventHandler { return; } - if (!event.getPlayer().worldObj.isRemote && event.world instanceof WorldServer) { - PlayerDataScript handler = ScriptController.Instance.playerScripts; + if (!event.getPlayer().worldObj.isRemote && event.world instanceof WorldServer && event.getPlayer() instanceof EntityPlayerMP) { + PlayerDataScript handler = ScriptController.Instance.getPlayerScripts(event.getPlayer()); IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.getPlayer()); - noppes.npcs.scripted.event.PlayerEvent.BreakEvent ev = new noppes.npcs.scripted.event.PlayerEvent.BreakEvent(scriptPlayer, NpcAPI.Instance().getIBlock(NpcAPI.Instance().getIWorld(event.world), NpcAPI.Instance().getIPos(event.x, event.y, event.z)), event.getExpToDrop()); + noppes.npcs.scripted.event.player.PlayerEvent.BreakEvent ev = new noppes.npcs.scripted.event.player.PlayerEvent.BreakEvent(scriptPlayer, NpcAPI.Instance().getIBlock(NpcAPI.Instance().getIWorld(event.world), NpcAPI.Instance().getIPos(event.x, event.y, event.z)), event.getExpToDrop()); event.setCanceled(EventHooks.onPlayerBreak(handler, ev)); event.setExpToDrop(ev.exp); } @@ -178,8 +179,8 @@ public class ScriptPlayerEventHandler { if (event.entityPlayer == null || event.entityPlayer.worldObj == null) return; - if (event.entityPlayer.worldObj instanceof WorldServer) { - PlayerDataScript handler = ScriptController.Instance.playerScripts; + if (event.entityPlayer.worldObj instanceof WorldServer && event.entityPlayer instanceof EntityPlayerMP) { + PlayerDataScript handler = ScriptController.Instance.getPlayerScripts(event.entityPlayer); IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer); event.setCanceled(EventHooks.onStartUsingItem(handler, scriptPlayer, event.duration, event.item)); } @@ -190,8 +191,8 @@ public class ScriptPlayerEventHandler { if (event.entityPlayer == null || event.entityPlayer.worldObj == null) return; - if (event.entityPlayer.worldObj instanceof WorldServer) { - PlayerDataScript handler = ScriptController.Instance.playerScripts; + if (event.entityPlayer.worldObj instanceof WorldServer && event.entityPlayer instanceof EntityPlayerMP) { + PlayerDataScript handler = ScriptController.Instance.getPlayerScripts(event.entityPlayer); IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer); event.setCanceled(EventHooks.onUsingItem(handler, scriptPlayer, event.duration, event.item)); } @@ -202,8 +203,8 @@ public class ScriptPlayerEventHandler { if (event.entityPlayer == null || event.entityPlayer.worldObj == null) return; - if (event.entityPlayer.worldObj instanceof WorldServer) { - PlayerDataScript handler = ScriptController.Instance.playerScripts; + if (event.entityPlayer.worldObj instanceof WorldServer && event.entityPlayer instanceof EntityPlayerMP) { + PlayerDataScript handler = ScriptController.Instance.getPlayerScripts(event.entityPlayer); IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer); event.setCanceled(EventHooks.onStopUsingItem(handler, scriptPlayer, event.duration, event.item)); } @@ -214,8 +215,8 @@ public class ScriptPlayerEventHandler { if (event.entityPlayer == null || event.entityPlayer.worldObj == null) return; - if (event.entityPlayer.worldObj instanceof WorldServer) { - PlayerDataScript handler = ScriptController.Instance.playerScripts; + if (event.entityPlayer.worldObj instanceof WorldServer && event.entityPlayer instanceof EntityPlayerMP) { + PlayerDataScript handler = ScriptController.Instance.getPlayerScripts(event.entityPlayer); IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer); EventHooks.onFinishUsingItem(handler, scriptPlayer, event.duration, event.item); } @@ -226,8 +227,8 @@ public class ScriptPlayerEventHandler { if (event.entityPlayer == null || event.entityPlayer.worldObj == null) return; - if (event.entityPlayer.worldObj instanceof WorldServer) { - PlayerDataScript handler = ScriptController.Instance.playerScripts; + if (event.entityPlayer.worldObj instanceof WorldServer && event.entityPlayer instanceof EntityPlayerMP) { + PlayerDataScript handler = ScriptController.Instance.getPlayerScripts(event.entityPlayer); IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer); event.setCanceled(EventHooks.onPlayerDropItems(handler, scriptPlayer, event.drops)); } @@ -238,8 +239,8 @@ public class ScriptPlayerEventHandler { if (event.entityPlayer == null || event.entityPlayer.worldObj == null) return; - if (event.entityPlayer.worldObj instanceof WorldServer) { - PlayerDataScript handler = ScriptController.Instance.playerScripts; + if (event.entityPlayer.worldObj instanceof WorldServer && event.entityPlayer instanceof EntityPlayerMP) { + PlayerDataScript handler = ScriptController.Instance.getPlayerScripts(event.entityPlayer); IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer); EventHooks.onPlayerPickupXP(handler, scriptPlayer, event.orb); } @@ -250,8 +251,8 @@ public class ScriptPlayerEventHandler { if (event.player == null || event.player.worldObj == null) return; - if (event.player.worldObj instanceof WorldServer) { - PlayerDataScript handler = ScriptController.Instance.playerScripts; + if (event.player.worldObj instanceof WorldServer && event.player instanceof EntityPlayerMP) { + PlayerDataScript handler = ScriptController.Instance.getPlayerScripts(event.player); IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.player); EventHooks.onPlayerChangeDim(handler, scriptPlayer, event.fromDim, event.toDim); } @@ -263,7 +264,7 @@ public class ScriptPlayerEventHandler { return; if (!event.player.worldObj.isRemote && !(event.player instanceof FakePlayer)) { - PlayerData playerData = PlayerDataController.Instance.getPlayerData(event.player); + PlayerData playerData = PlayerData.get(event.player); PlayerQuestData questData = playerData.questData; QuestItem.pickedUp = event.pickedUp.getEntityItem(); @@ -277,8 +278,8 @@ public class ScriptPlayerEventHandler { questData.checkQuestCompletion(playerData, EnumQuestType.Item); } - if (event.player.worldObj instanceof WorldServer && event.player instanceof EntityPlayer) { - PlayerDataScript handler = ScriptController.Instance.playerScripts; + if (event.player.worldObj instanceof WorldServer && event.player instanceof EntityPlayerMP) { + PlayerDataScript handler = ScriptController.Instance.getPlayerScripts(event.player); IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.player); EventHooks.onPlayerPickUp(handler, scriptPlayer, event.pickedUp); } @@ -289,8 +290,8 @@ public class ScriptPlayerEventHandler { if (event.entityPlayer == null || event.entityPlayer.worldObj == null) return; - if (event.entityPlayer.worldObj instanceof WorldServer && !(event.entityPlayer.openContainer instanceof ContainerPlayer)) { - PlayerDataScript handler = ScriptController.Instance.playerScripts; + if (event.entityPlayer.worldObj instanceof WorldServer && !(event.entityPlayer.openContainer instanceof ContainerPlayer) && event.entityPlayer instanceof EntityPlayerMP) { + PlayerDataScript handler = ScriptController.Instance.getPlayerScripts(event.entityPlayer); IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer); EventHooks.onPlayerContainerOpen(handler, scriptPlayer, event.entityPlayer.openContainer); } @@ -301,8 +302,8 @@ public class ScriptPlayerEventHandler { if (event.entityPlayer == null || event.entityPlayer.worldObj == null) return; - if (event.entityPlayer.worldObj instanceof WorldServer) { - PlayerDataScript handler = ScriptController.Instance.playerScripts; + if (event.entityPlayer.worldObj instanceof WorldServer && event.entityPlayer instanceof EntityPlayerMP) { + PlayerDataScript handler = ScriptController.Instance.getPlayerScripts(event.entityPlayer); IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer); EventHooks.onPlayerUseHoe(handler, scriptPlayer, event.current, event.x, event.y, event.z); } @@ -313,8 +314,8 @@ public class ScriptPlayerEventHandler { if (event.entityPlayer == null || event.entityPlayer.worldObj == null) return; - if (event.entityPlayer.worldObj instanceof WorldServer) { - PlayerDataScript handler = ScriptController.Instance.playerScripts; + if (event.entityPlayer.worldObj instanceof WorldServer && event.entityPlayer instanceof EntityPlayerMP) { + PlayerDataScript handler = ScriptController.Instance.getPlayerScripts(event.entityPlayer); IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer); EventHooks.onPlayerSleep(handler, scriptPlayer, event.x, event.y, event.z); } @@ -325,8 +326,8 @@ public class ScriptPlayerEventHandler { if (event.entityPlayer == null || event.entityPlayer.worldObj == null) return; - if (event.entityPlayer.worldObj instanceof WorldServer) { - PlayerDataScript handler = ScriptController.Instance.playerScripts; + if (event.entityPlayer.worldObj instanceof WorldServer && event.entityPlayer instanceof EntityPlayerMP) { + PlayerDataScript handler = ScriptController.Instance.getPlayerScripts(event.entityPlayer); IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer); EventHooks.onPlayerWakeUp(handler, scriptPlayer, event.setSpawn); } @@ -337,8 +338,8 @@ public class ScriptPlayerEventHandler { if (event.entityPlayer == null || event.entityPlayer.worldObj == null) return; - if (event.entityPlayer.worldObj instanceof WorldServer) { - PlayerDataScript handler = ScriptController.Instance.playerScripts; + if (event.entityPlayer.worldObj instanceof WorldServer && event.entityPlayer instanceof EntityPlayerMP) { + PlayerDataScript handler = ScriptController.Instance.getPlayerScripts(event.entityPlayer); IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer); EventHooks.onPlayerFillBucket(handler, scriptPlayer, event.current, event.result); } @@ -349,8 +350,8 @@ public class ScriptPlayerEventHandler { if (event.entityPlayer == null || event.entityPlayer.worldObj == null) return; - if (event.entityPlayer.worldObj instanceof WorldServer) { - PlayerDataScript handler = ScriptController.Instance.playerScripts; + if (event.entityPlayer.worldObj instanceof WorldServer && event.entityPlayer instanceof EntityPlayerMP) { + PlayerDataScript handler = ScriptController.Instance.getPlayerScripts(event.entityPlayer); IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer); EventHooks.onPlayerBonemeal(handler, scriptPlayer, event.x, event.y, event.z, event.world); } @@ -361,8 +362,8 @@ public class ScriptPlayerEventHandler { if (event.entityPlayer == null || event.entityPlayer.worldObj == null) return; - if (event.entityPlayer.worldObj instanceof WorldServer) { - PlayerDataScript handler = ScriptController.Instance.playerScripts; + if (event.entityPlayer.worldObj instanceof WorldServer && event.entityPlayer instanceof EntityPlayerMP) { + PlayerDataScript handler = ScriptController.Instance.getPlayerScripts(event.entityPlayer); IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer); EventHooks.onPlayerAchievement(handler, scriptPlayer, CustomNpcs.proxy.getAchievementDesc(event.achievement)); } @@ -373,8 +374,8 @@ public class ScriptPlayerEventHandler { if (event.player == null || event.player.worldObj == null) return; - if (event.player.worldObj instanceof WorldServer) { - PlayerDataScript handler = ScriptController.Instance.playerScripts; + if (event.player.worldObj instanceof WorldServer && event.player instanceof EntityPlayerMP) { + PlayerDataScript handler = ScriptController.Instance.getPlayerScripts(event.player); IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.player); event.setCanceled(EventHooks.onPlayerToss(handler, scriptPlayer, event.entityItem)); } @@ -386,8 +387,8 @@ public class ScriptPlayerEventHandler { return; if (event.entityLiving.worldObj instanceof WorldServer) { - if (event.entityLiving instanceof EntityPlayer) { - PlayerDataScript handler = ScriptController.Instance.playerScripts; + if (event.entityLiving instanceof EntityPlayerMP) { + PlayerDataScript handler = ScriptController.Instance.getPlayerScripts((EntityPlayer) event.entityLiving); IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityLiving); event.setCanceled(EventHooks.onPlayerFall(handler, scriptPlayer, event.distance)); } @@ -400,8 +401,8 @@ public class ScriptPlayerEventHandler { return; if (event.entityLiving.worldObj instanceof WorldServer) { - if (event.entityLiving instanceof EntityPlayer) { - PlayerDataScript handler = ScriptController.Instance.playerScripts; + if (event.entityLiving instanceof EntityPlayerMP) { + PlayerDataScript handler = ScriptController.Instance.getPlayerScripts((EntityPlayer) event.entityLiving); IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityLiving); EventHooks.onPlayerJump(handler, scriptPlayer); } @@ -414,8 +415,8 @@ public class ScriptPlayerEventHandler { return; if (event.entity.worldObj instanceof WorldServer) { - if (event.entity instanceof EntityPlayer) { - PlayerDataScript handler = ScriptController.Instance.playerScripts; + if (event.entity instanceof EntityPlayerMP) { + PlayerDataScript handler = ScriptController.Instance.getPlayerScripts((EntityPlayer) event.entity); IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entity); EventHooks.onPlayerLightning(handler, scriptPlayer); } @@ -428,8 +429,8 @@ public class ScriptPlayerEventHandler { return; if (event.entity.worldObj instanceof WorldServer) { - if (event.entity instanceof EntityPlayer) { - PlayerDataScript handler = ScriptController.Instance.playerScripts; + if (event.entity instanceof EntityPlayerMP) { + PlayerDataScript handler = ScriptController.Instance.getPlayerScripts((EntityPlayer) event.entity); IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entity); EventHooks.onPlayerSound(handler, scriptPlayer, event.name, event.pitch, event.volume); } @@ -443,8 +444,8 @@ public class ScriptPlayerEventHandler { if (event.entityLiving.worldObj instanceof WorldServer) { Entity source = NoppesUtilServer.GetDamageSource(event.source); - PlayerDataScript handler = ScriptController.Instance.playerScripts; - if (event.entityLiving instanceof EntityPlayer) { + if (event.entityLiving instanceof EntityPlayerMP) { + PlayerDataScript handler = ScriptController.Instance.getPlayerScripts((EntityPlayer) event.entityLiving); try { CustomEffectController.getInstance().killEffects((EntityPlayer) event.entityLiving); @@ -452,9 +453,14 @@ public class ScriptPlayerEventHandler { EventHooks.onPlayerDeath(handler, scriptPlayer, event.source, source); } catch (Exception ignored) { } + + EntityPlayer player = (EntityPlayer) event.entityLiving; + PlayerData playerData = PlayerData.get(player); + playerData.actionManager.clear(); } - if (event.source.getEntity() instanceof EntityPlayer) { + if (event.source.getEntity() instanceof EntityPlayerMP) { + PlayerDataScript handler = ScriptController.Instance.getPlayerScripts((EntityPlayer) event.source.getEntity()); IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.source.getEntity()); EventHooks.onPlayerKills(handler, scriptPlayer, event.entityLiving); } @@ -470,18 +476,19 @@ public class ScriptPlayerEventHandler { if (event.entityLiving.worldObj instanceof WorldServer) { boolean cancel = event.isCanceled(); Entity source = NoppesUtilServer.GetDamageSource(event.source); - PlayerDataScript handler = ScriptController.Instance.playerScripts; - if (event.entityLiving instanceof EntityPlayer) { - noppes.npcs.scripted.event.PlayerEvent.AttackedEvent pevent = new noppes.npcs.scripted.event.PlayerEvent.AttackedEvent((IPlayer) NpcAPI.Instance().getIEntity(event.entityLiving), source, event.ammount, event.source); + if (event.entityLiving instanceof EntityPlayerMP) { + PlayerDataScript handler = ScriptController.Instance.getPlayerScripts((EntityPlayer) event.entityLiving); + noppes.npcs.scripted.event.player.PlayerEvent.AttackedEvent pevent = new noppes.npcs.scripted.event.player.PlayerEvent.AttackedEvent((IPlayer) NpcAPI.Instance().getIEntity((EntityPlayer) event.entityLiving), source, event.ammount, event.source); cancel = EventHooks.onPlayerAttacked(handler, pevent); } - if (event.source.getEntity() instanceof EntityPlayer) { + if (event.source.getEntity() instanceof EntityPlayerMP) { + PlayerDataScript handler = ScriptController.Instance.getPlayerScripts((EntityPlayer) event.source.getEntity()); float attackAmount = event.ammount; if (ConfigMain.AttributesEnabled) attackAmount = AttributeAttackUtil.calculateOutgoing((EntityPlayer) event.source.getEntity(), attackAmount); - noppes.npcs.scripted.event.PlayerEvent.AttackEvent pevent1 = new noppes.npcs.scripted.event.PlayerEvent.AttackEvent((IPlayer) NpcAPI.Instance().getIEntity(event.source.getEntity()), event.entityLiving, attackAmount, event.source); + noppes.npcs.scripted.event.player.PlayerEvent.AttackEvent pevent1 = new noppes.npcs.scripted.event.player.PlayerEvent.AttackEvent((IPlayer) NpcAPI.Instance().getIEntity((EntityPlayer) event.source.getEntity()), event.entityLiving, attackAmount, event.source); cancel = cancel || EventHooks.onPlayerAttack(handler, pevent1); } event.setCanceled(cancel); @@ -496,25 +503,25 @@ public class ScriptPlayerEventHandler { if (event.entityLiving.worldObj instanceof WorldServer) { boolean cancel = event.isCanceled(); Entity source = NoppesUtilServer.GetDamageSource(event.source); - PlayerDataScript handler = ScriptController.Instance.playerScripts; - // Player to Player Interaction if (ConfigMain.AttributesEnabled) { - if (event.entityLiving instanceof EntityPlayer && source instanceof EntityPlayer) { - event.ammount = AttributeAttackUtil.calculateDamagePlayerToPlayer((EntityPlayer) event.entityLiving, (EntityPlayer) source, event.ammount); + if (event.entityLiving instanceof EntityPlayerMP && source instanceof EntityPlayerMP) { + event.ammount = AttributeAttackUtil.calculateDamagePlayerToPlayer((EntityPlayer) source, (EntityPlayer) event.entityLiving, event.ammount); } else if (!(event.entityLiving instanceof EntityNPCInterface) && source instanceof EntityPlayer) { event.ammount = AttributeAttackUtil.calculateOutgoing((EntityPlayer) source, event.ammount); } } - if (event.entityLiving instanceof EntityPlayer) { - noppes.npcs.scripted.event.PlayerEvent.DamagedEvent pevent = new noppes.npcs.scripted.event.PlayerEvent.DamagedEvent((IPlayer) NpcAPI.Instance().getIEntity(event.entityLiving), source, event.ammount, event.source); + if (event.entityLiving instanceof EntityPlayerMP) { + PlayerDataScript handler = ScriptController.Instance.getPlayerScripts((EntityPlayer) event.entityLiving); + noppes.npcs.scripted.event.player.PlayerEvent.DamagedEvent pevent = new noppes.npcs.scripted.event.player.PlayerEvent.DamagedEvent((IPlayer) NpcAPI.Instance().getIEntity((EntityPlayer) event.entityLiving), source, event.ammount, event.source); cancel = EventHooks.onPlayerDamaged(handler, pevent); event.ammount = pevent.damage; } - if (source instanceof EntityPlayer) { - noppes.npcs.scripted.event.PlayerEvent.DamagedEntityEvent pevent1 = new noppes.npcs.scripted.event.PlayerEvent.DamagedEntityEvent((IPlayer) NpcAPI.Instance().getIEntity(source), event.entityLiving, event.ammount, event.source); + if (source instanceof EntityPlayerMP) { + PlayerDataScript handler = ScriptController.Instance.getPlayerScripts((EntityPlayer) source); + noppes.npcs.scripted.event.player.PlayerEvent.DamagedEntityEvent pevent1 = new noppes.npcs.scripted.event.player.PlayerEvent.DamagedEntityEvent((IPlayer) NpcAPI.Instance().getIEntity(source), event.entityLiving, event.ammount, event.source); cancel = cancel || EventHooks.onPlayerDamagedEntity(handler, pevent1); event.ammount = pevent1.damage; } @@ -528,8 +535,8 @@ public class ScriptPlayerEventHandler { if (event.player == null || event.player.worldObj == null) return; - if (event.player.worldObj instanceof WorldServer) { - PlayerDataScript handler = ScriptController.Instance.playerScripts; + if (event.player.worldObj instanceof WorldServer && event.player instanceof EntityPlayerMP) { + PlayerDataScript handler = ScriptController.Instance.getPlayerScripts(event.player); IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.player); EventHooks.onPlayerRespawn(handler, scriptPlayer); } @@ -540,12 +547,12 @@ public class ScriptPlayerEventHandler { if (event.player == null || event.player.worldObj == null) return; - if (event.player.worldObj instanceof WorldServer) { - PlayerDataScript handler = ScriptController.Instance.playerScripts; + if (event.player.worldObj instanceof WorldServer && event.player instanceof EntityPlayerMP) { + PlayerDataScript handler = ScriptController.Instance.getPlayerScripts(event.player); IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.player); EventHooks.onPlayerLogin(handler, scriptPlayer); - PlayerData playerData = PlayerDataController.Instance.getPlayerData(event.player); + PlayerData playerData = PlayerData.get(event.player); Quest quest = (Quest) playerData.questData.getTrackedQuest(); if (quest != null) { Party party = playerData.getPlayerParty(); @@ -556,7 +563,7 @@ public class ScriptPlayerEventHandler { } } - PlayerDataController.Instance.getPlayerData(event.player).skinOverlays.updateClient(); + PlayerData.get(event.player).skinOverlays.updateClient(); } } @@ -565,9 +572,10 @@ public class ScriptPlayerEventHandler { if (event.player == null || event.player.worldObj == null) return; - if (event.player.worldObj instanceof WorldServer) { - PlayerDataScript handler = ScriptController.Instance.playerScripts; + if (event.player.worldObj instanceof WorldServer&& event.player instanceof EntityPlayerMP) { + PlayerDataScript handler = ScriptController.Instance.getPlayerScripts(event.player); IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.player); + AttributeController.removeTracker(event.player.getUniqueID()); EventHooks.onPlayerLogout(handler, scriptPlayer); } } @@ -580,14 +588,14 @@ public class ScriptPlayerEventHandler { return; if (event.player.worldObj instanceof WorldServer && !event.player.equals(EntityNPCInterface.chateventPlayer)) { - PlayerDataScript handler = ScriptController.Instance.playerScripts; + PlayerDataScript handler = ScriptController.Instance.getPlayerScripts(event.player); IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.player); String message = event.message; - noppes.npcs.scripted.event.PlayerEvent.ChatEvent ev = new noppes.npcs.scripted.event.PlayerEvent.ChatEvent(scriptPlayer, event.message); + noppes.npcs.scripted.event.player.PlayerEvent.ChatEvent ev = new noppes.npcs.scripted.event.player.PlayerEvent.ChatEvent(scriptPlayer, event.message); EventHooks.onPlayerChat(handler, ev); event.setCanceled(ev.isCanceled()); if (!message.equals(ev.message)) { - ChatComponentTranslation chat = new ChatComponentTranslation(""); + ChatComponentTranslation chat = new ChatComponentTranslation("", new Object[0]); chat.appendSibling(ForgeHooks.newChatWithLinks(ev.message)); event.component = chat; } diff --git a/src/main/java/noppes/npcs/ServerEventsHandler.java b/src/main/java/noppes/npcs/ServerEventsHandler.java index 5a8c05874..f8333cc2b 100644 --- a/src/main/java/noppes/npcs/ServerEventsHandler.java +++ b/src/main/java/noppes/npcs/ServerEventsHandler.java @@ -47,7 +47,6 @@ import noppes.npcs.constants.EnumPartyObjectives; import noppes.npcs.constants.EnumQuestType; import noppes.npcs.constants.EnumRoleType; import noppes.npcs.controllers.PartyController; -import noppes.npcs.controllers.PlayerDataController; import noppes.npcs.controllers.ServerCloneController; import noppes.npcs.controllers.data.*; import noppes.npcs.entity.EntityNPCInterface; @@ -102,7 +101,7 @@ public class ServerEventsHandler { NBTTagCompound compound = new NBTTagCompound(); if (!event.target.writeToNBTOptional(compound)) return; - PlayerData data = PlayerDataController.Instance.getPlayerData(event.entityPlayer); + PlayerData data = PlayerData.get(event.entityPlayer); ServerCloneController.Instance.cleanTags(compound); PacketHandler.Instance.sendToPlayer(new ClonerPacket(compound), (EntityPlayerMP) event.entityPlayer); data.cloned = compound; @@ -152,8 +151,8 @@ public class ServerEventsHandler { // Check for Friendly Fire if (ConfigMain.PartyFriendlyFireEnabled) { EntityPlayer sourcePlayer = (EntityPlayer) event.source.getEntity(); - PlayerData playerData = PlayerDataController.Instance.getPlayerData(sourcePlayer); - PlayerData targetData = PlayerDataController.Instance.getPlayerData((EntityPlayer) event.entityLiving); + PlayerData playerData = PlayerData.get(sourcePlayer); + PlayerData targetData = PlayerData.get((EntityPlayer) event.entityLiving); if (playerData.partyUUID != null && playerData.partyUUID.equals(targetData.partyUUID)) { Party party = PartyController.Instance().getParty(playerData.partyUUID); if (party != null && !party.friendlyFire()) @@ -270,7 +269,7 @@ public class ServerEventsHandler { } } if (event.entityLiving instanceof EntityPlayer) { - PlayerData data = PlayerDataController.Instance.getPlayerData((EntityPlayer) event.entityLiving); + PlayerData data = PlayerData.get((EntityPlayer) event.entityLiving); data.save(); } } @@ -447,7 +446,7 @@ public class ServerEventsHandler { @SubscribeEvent public void world(PlayerEvent.SaveToFile event) { - PlayerData data = PlayerDataController.Instance.getPlayerData((EntityPlayer) event.entity); + PlayerData data = PlayerData.get((EntityPlayer) event.entity); data.save(); } @@ -455,7 +454,7 @@ public class ServerEventsHandler { public void world(EntityJoinWorldEvent event) { if (event.world.isRemote || !(event.entity instanceof EntityPlayer)) return; - PlayerData data = PlayerDataController.Instance.getPlayerData((EntityPlayer) event.entity); + PlayerData data = PlayerData.get((EntityPlayer) event.entity); data.updateCompanion(event.world); } diff --git a/src/main/java/noppes/npcs/ServerTickHandler.java b/src/main/java/noppes/npcs/ServerTickHandler.java index 6f05146a8..c73874df5 100644 --- a/src/main/java/noppes/npcs/ServerTickHandler.java +++ b/src/main/java/noppes/npcs/ServerTickHandler.java @@ -10,7 +10,6 @@ import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.server.MinecraftServer; import net.minecraft.world.WorldServer; import noppes.npcs.client.AnalyticsTracking; -import noppes.npcs.controllers.PlayerDataController; import noppes.npcs.controllers.data.PlayerData; import java.net.InetAddress; @@ -47,7 +46,7 @@ public class ServerTickHandler { } AnalyticsTracking.sendData(event.player, "join", serverName); - PlayerData playerData = PlayerDataController.Instance.getPlayerData(event.player); + PlayerData playerData = PlayerData.get(event.player); if (playerData != null) { playerData.onLogin(); } @@ -59,7 +58,7 @@ public class ServerTickHandler { @SubscribeEvent public void playerLogout(PlayerEvent.PlayerLoggedOutEvent event) { - PlayerData playerData = PlayerDataController.Instance.getPlayerData(event.player); + PlayerData playerData = PlayerData.get(event.player); if (playerData != null) { playerData.onLogout(); } diff --git a/src/main/java/noppes/npcs/VersionCompatibility.java b/src/main/java/noppes/npcs/VersionCompatibility.java index 94a1b28d9..98dd6c20e 100644 --- a/src/main/java/noppes/npcs/VersionCompatibility.java +++ b/src/main/java/noppes/npcs/VersionCompatibility.java @@ -13,11 +13,17 @@ import java.util.Collection; import java.util.List; public class VersionCompatibility { - public static int ModRev = 22; + public static int ModRev = 23; public static void CheckNpcCompatibility(EntityNPCInterface npc, NBTTagCompound compound) { if (npc.npcVersion == ModRev) return; + if (npc.npcVersion < 23) { + if (compound.hasKey("AimWhileShooting")) { + boolean aimShot = compound.getBoolean("AimWhileShooting"); + compound.setInteger("AimType", !aimShot ? 0 : 1); + } + } if (npc.npcVersion < 22) { if (compound.hasKey("CanLeap")) { boolean canLeap = compound.getBoolean("CanLeap"); diff --git a/src/main/java/noppes/npcs/ai/CombatHandler.java b/src/main/java/noppes/npcs/ai/CombatHandler.java index ede3239d0..2a2319c4f 100644 --- a/src/main/java/noppes/npcs/ai/CombatHandler.java +++ b/src/main/java/noppes/npcs/ai/CombatHandler.java @@ -14,9 +14,9 @@ import java.util.Map; public class CombatHandler { - private final Map aggressors = new HashMap(); - private final Map> recentDamages = new HashMap<>(); - private final EntityNPCInterface npc; + private Map aggressors = new HashMap(); + private Map> recentDamages = new HashMap<>(); + private EntityNPCInterface npc; private long startTime = 0; private int combatResetTimer = 0; diff --git a/src/main/java/noppes/npcs/ai/EntityAIAmbushTarget.java b/src/main/java/noppes/npcs/ai/EntityAIAmbushTarget.java index fe835f16c..4ee229b0e 100644 --- a/src/main/java/noppes/npcs/ai/EntityAIAmbushTarget.java +++ b/src/main/java/noppes/npcs/ai/EntityAIAmbushTarget.java @@ -12,17 +12,17 @@ import noppes.npcs.entity.EntityNPCInterface; import java.util.Random; public class EntityAIAmbushTarget extends EntityAIBase { - private final EntityNPCInterface theEntity; + private EntityNPCInterface theEntity; private EntityLivingBase targetEntity; private double shelterX; private double shelterY; private double shelterZ; - private final double movementSpeed; - private final double distance; + private double movementSpeed; + private double distance; private int delay = 0; - private final World theWorld; + private World theWorld; private int tick; - private final boolean attackFromBehind; + private boolean attackFromBehind; public EntityAIAmbushTarget(EntityNPCInterface par1EntityCreature, double par2, double par3, boolean par4) { this.theEntity = par1EntityCreature; diff --git a/src/main/java/noppes/npcs/ai/EntityAIAnimation.java b/src/main/java/noppes/npcs/ai/EntityAIAnimation.java index 094962f9f..e2f34b449 100644 --- a/src/main/java/noppes/npcs/ai/EntityAIAnimation.java +++ b/src/main/java/noppes/npcs/ai/EntityAIAnimation.java @@ -6,13 +6,13 @@ import noppes.npcs.constants.EnumMovingType; import noppes.npcs.entity.EntityNPCInterface; public class EntityAIAnimation extends EntityAIBase { - private final EntityNPCInterface npc; + private EntityNPCInterface npc; private boolean isAttacking = false; private boolean isDead = false; private boolean isAtStartpoint = false; private boolean hasPath = false; - private final int tick = 4; + private int tick = 4; public EntityAIAnimation(EntityNPCInterface npc) { this.npc = npc; @@ -24,8 +24,12 @@ public class EntityAIAnimation extends EntityAIBase { if (isDead) return npc.currentAnimation != EnumAnimation.LYING; - if (npc.stats.aimWhileShooting && npc.isAttacking()) + if (npc.stats.aimType == 1 && npc.isAttacking()) return npc.currentAnimation != EnumAnimation.AIMING; + + if(npc.stats.aimType == 2 && npc.isAttacking() && npc.getRangedTask() != null && npc.getRangedTask().isShooting()) + return npc.currentAnimation != EnumAnimation.AIMING; + if (npc.ais.animationType == EnumAnimation.NONE) return npc.currentAnimation != EnumAnimation.NONE; isAttacking = npc.isAttacking(); @@ -42,10 +46,15 @@ public class EntityAIAnimation extends EntityAIBase { @Override public void updateTask() { - if (npc.stats.aimWhileShooting && npc.isAttacking()) { + if (npc.stats.aimType == 1 && npc.isAttacking()) { setAnimation(EnumAnimation.AIMING); return; } + if (npc.stats.aimType == 2 && npc.isAttacking() && npc.getRangedTask() != null && npc.getRangedTask().isShooting()) { + setAnimation(EnumAnimation.AIMING); + return; + } + EnumAnimation type = npc.ais.animationType; if (isDead) type = EnumAnimation.LYING; diff --git a/src/main/java/noppes/npcs/ai/EntityAIAttackTarget.java b/src/main/java/noppes/npcs/ai/EntityAIAttackTarget.java index b3adca3a0..967c3cf73 100644 --- a/src/main/java/noppes/npcs/ai/EntityAIAttackTarget.java +++ b/src/main/java/noppes/npcs/ai/EntityAIAttackTarget.java @@ -13,8 +13,8 @@ import noppes.npcs.constants.AiMutex; import noppes.npcs.entity.EntityNPCInterface; public class EntityAIAttackTarget extends EntityAIBase { - private final World world; - private final EntityNPCInterface npc; + private World world; + private EntityNPCInterface npc; private EntityLivingBase entityTarget; /** @@ -57,7 +57,7 @@ public class EntityAIAttackTarget extends EntityAIBase { return false; } else { this.entityTarget = entitylivingbase; - this.npc.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(this.npc.stats.aggroRange); + this.npc.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(((EntityNPCInterface) this.npc).stats.aggroRange); this.entityPathEntity = this.npc.getNavigator().getPathToEntityLiving(entitylivingbase); this.npc.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(ConfigMain.NpcNavRange); return this.entityPathEntity != null; diff --git a/src/main/java/noppes/npcs/ai/EntityAIAvoidTarget.java b/src/main/java/noppes/npcs/ai/EntityAIAvoidTarget.java index 65088139c..a845d2488 100644 --- a/src/main/java/noppes/npcs/ai/EntityAIAvoidTarget.java +++ b/src/main/java/noppes/npcs/ai/EntityAIAvoidTarget.java @@ -17,9 +17,9 @@ public class EntityAIAvoidTarget extends EntityAIBase { /** * The entity we are attached to */ - private final EntityNPCInterface theEntity; + private EntityNPCInterface theEntity; private Entity closestLivingEntity; - private final float distanceFromEntity; + private float distanceFromEntity; private float health; @@ -31,7 +31,7 @@ public class EntityAIAvoidTarget extends EntityAIBase { /** * The PathNavigate of our entity */ - private final PathNavigate entityPathNavigate; + private PathNavigate entityPathNavigate; /** * The class of the entity we should avoid @@ -59,13 +59,13 @@ public class EntityAIAvoidTarget extends EntityAIBase { targetEntityClass = target.getClass(); if (this.targetEntityClass == EntityPlayer.class) { - this.closestLivingEntity = this.theEntity.worldObj.getClosestPlayerToEntity(this.theEntity, this.distanceFromEntity); + this.closestLivingEntity = this.theEntity.worldObj.getClosestPlayerToEntity(this.theEntity, (double) this.distanceFromEntity); if (this.closestLivingEntity == null) { return false; } } else { - List var1 = this.theEntity.worldObj.getEntitiesWithinAABB(this.targetEntityClass, this.theEntity.boundingBox.expand(this.distanceFromEntity, 3.0D, this.distanceFromEntity)); + List var1 = this.theEntity.worldObj.getEntitiesWithinAABB(this.targetEntityClass, this.theEntity.boundingBox.expand((double) this.distanceFromEntity, 3.0D, (double) this.distanceFromEntity)); if (var1.isEmpty()) { return false; @@ -91,7 +91,7 @@ public class EntityAIAvoidTarget extends EntityAIBase { return false; } else { this.entityPathEntity = this.entityPathNavigate.getPathToXYZ(var2.xCoord, var2.yCoord, var2.zCoord); - return this.entityPathEntity != null && this.entityPathEntity.isDestinationSame(var2); + return this.entityPathEntity == null ? false : this.entityPathEntity.isDestinationSame(var2); } } } diff --git a/src/main/java/noppes/npcs/ai/EntityAIBustDoor.java b/src/main/java/noppes/npcs/ai/EntityAIBustDoor.java index bafec0416..63b61d9cd 100644 --- a/src/main/java/noppes/npcs/ai/EntityAIBustDoor.java +++ b/src/main/java/noppes/npcs/ai/EntityAIBustDoor.java @@ -17,7 +17,7 @@ public class EntityAIBustDoor extends EntityAIDoorInteract { * Returns whether the EntityAIBase should begin execution. */ public boolean shouldExecute() { - return super.shouldExecute() && (this.theEntity.worldObj.getGameRules().getGameRuleBooleanValue("mobGriefing") && !this.field_151504_e.func_150015_f(this.theEntity.worldObj, this.entityPosX, this.entityPosY, this.entityPosZ)); + return !super.shouldExecute() ? false : (!this.theEntity.worldObj.getGameRules().getGameRuleBooleanValue("mobGriefing") ? false : !this.field_151504_e.func_150015_f(this.theEntity.worldObj, this.entityPosX, this.entityPosY, this.entityPosZ)); } /** @@ -32,7 +32,7 @@ public class EntityAIBustDoor extends EntityAIDoorInteract { * Returns whether an in-progress EntityAIBase should continue executing */ public boolean continueExecuting() { - double var1 = this.theEntity.getDistanceSq(this.entityPosX, this.entityPosY, this.entityPosZ); + double var1 = this.theEntity.getDistanceSq((double) this.entityPosX, (double) this.entityPosY, (double) this.entityPosZ); return this.breakingTime <= 240 && !this.field_151504_e.func_150015_f(this.theEntity.worldObj, this.entityPosX, this.entityPosY, this.entityPosZ) && var1 < 4.0D; } diff --git a/src/main/java/noppes/npcs/ai/EntityAIDodgeShoot.java b/src/main/java/noppes/npcs/ai/EntityAIDodgeShoot.java index 6f070fccf..ef7b3f5ac 100644 --- a/src/main/java/noppes/npcs/ai/EntityAIDodgeShoot.java +++ b/src/main/java/noppes/npcs/ai/EntityAIDodgeShoot.java @@ -7,7 +7,7 @@ import noppes.npcs.constants.AiMutex; import noppes.npcs.entity.EntityNPCInterface; public class EntityAIDodgeShoot extends EntityAIBase { - private final EntityNPCInterface entity; + private EntityNPCInterface entity; private double xPosition; private double yPosition; private double zPosition; diff --git a/src/main/java/noppes/npcs/ai/EntityAIFindShade.java b/src/main/java/noppes/npcs/ai/EntityAIFindShade.java index d811def23..265b3c6ba 100644 --- a/src/main/java/noppes/npcs/ai/EntityAIFindShade.java +++ b/src/main/java/noppes/npcs/ai/EntityAIFindShade.java @@ -10,11 +10,11 @@ import noppes.npcs.constants.AiMutex; import java.util.Random; public class EntityAIFindShade extends EntityAIBase { - private final EntityCreature theCreature; + private EntityCreature theCreature; private double shelterX; private double shelterY; private double shelterZ; - private final World theWorld; + private World theWorld; public EntityAIFindShade(EntityCreature par1EntityCreature) { this.theCreature = par1EntityCreature; @@ -68,7 +68,7 @@ public class EntityAIFindShade extends EntityAIBase { float light = this.theWorld.getLightBrightness(var3, var4, var5) - 0.5F; if (!this.theWorld.canBlockSeeTheSky(var3, var4, var5) && light < 0.0F) { - return Vec3.createVectorHelper(var3, var4, var5); + return Vec3.createVectorHelper((double) var3, (double) var4, (double) var5); } } diff --git a/src/main/java/noppes/npcs/ai/EntityAIFollow.java b/src/main/java/noppes/npcs/ai/EntityAIFollow.java index c0d6cb679..61cabd38f 100644 --- a/src/main/java/noppes/npcs/ai/EntityAIFollow.java +++ b/src/main/java/noppes/npcs/ai/EntityAIFollow.java @@ -9,7 +9,7 @@ import noppes.npcs.constants.EnumAnimation; import noppes.npcs.entity.EntityNPCInterface; public class EntityAIFollow extends EntityAIBase { - private final EntityNPCInterface npc; + private EntityNPCInterface npc; private EntityLivingBase owner; private double distance; public int updateTick = 0; @@ -70,7 +70,7 @@ public class EntityAIFollow extends EntityAIBase { for (int l = 0; l <= 4; ++l) { for (int i1 = 0; i1 <= 4; ++i1) { if ((l < 1 || i1 < 1 || l > 3 || i1 > 3) && World.doesBlockHaveSolidTopSurface(npc.worldObj, i + l, k - 1, j + i1) && !npc.worldObj.getBlock(i + l, k, j + i1).isNormalCube() && !npc.worldObj.getBlock(i + l, k + 1, j + i1).isNormalCube()) { - this.npc.setLocationAndAngles((float) (i + l) + 0.5F, k, (float) (j + i1) + 0.5F, this.npc.rotationYaw, this.npc.rotationPitch); + this.npc.setLocationAndAngles((double) ((float) (i + l) + 0.5F), (double) k, (double) ((float) (j + i1) + 0.5F), this.npc.rotationYaw, this.npc.rotationPitch); this.npc.getNavigator().clearPathEntity(); return; } diff --git a/src/main/java/noppes/npcs/ai/EntityAIJob.java b/src/main/java/noppes/npcs/ai/EntityAIJob.java index ba74301da..b51fc3f23 100644 --- a/src/main/java/noppes/npcs/ai/EntityAIJob.java +++ b/src/main/java/noppes/npcs/ai/EntityAIJob.java @@ -5,7 +5,7 @@ import noppes.npcs.entity.EntityNPCInterface; public class EntityAIJob extends EntityAIBase { - private final EntityNPCInterface npc; + private EntityNPCInterface npc; public EntityAIJob(EntityNPCInterface npc) { this.npc = npc; diff --git a/src/main/java/noppes/npcs/ai/EntityAIMoveIndoors.java b/src/main/java/noppes/npcs/ai/EntityAIMoveIndoors.java index 1d8b44a97..45f4057af 100644 --- a/src/main/java/noppes/npcs/ai/EntityAIMoveIndoors.java +++ b/src/main/java/noppes/npcs/ai/EntityAIMoveIndoors.java @@ -10,11 +10,11 @@ import noppes.npcs.constants.AiMutex; import java.util.Random; public class EntityAIMoveIndoors extends EntityAIBase { - private final EntityCreature theCreature; + private EntityCreature theCreature; private double shelterX; private double shelterY; private double shelterZ; - private final World theWorld; + private World theWorld; public EntityAIMoveIndoors(EntityCreature par1EntityCreature) { this.theCreature = par1EntityCreature; @@ -73,7 +73,7 @@ public class EntityAIMoveIndoors extends EntityAIBase { int var5 = MathHelper.floor_double(this.theCreature.posZ + (double) var1.nextInt(20) - 10.0D); if (!this.theWorld.canBlockSeeTheSky(var3, var4, var5) && this.theWorld.getFullBlockLightValue(var3, var4, var5) > 8) { - return Vec3.createVectorHelper(var3, var4, var5); + return Vec3.createVectorHelper((double) var3, (double) var4, (double) var5); } } diff --git a/src/main/java/noppes/npcs/ai/EntityAIMovingPath.java b/src/main/java/noppes/npcs/ai/EntityAIMovingPath.java index 2332e8013..7b8422a29 100644 --- a/src/main/java/noppes/npcs/ai/EntityAIMovingPath.java +++ b/src/main/java/noppes/npcs/ai/EntityAIMovingPath.java @@ -7,7 +7,7 @@ import noppes.npcs.entity.EntityNPCInterface; import java.util.List; public class EntityAIMovingPath extends EntityAIBase { - private final EntityNPCInterface npc; + private EntityNPCInterface npc; private int[] pos; public EntityAIMovingPath(EntityNPCInterface par1EntityNPCInterface) { diff --git a/src/main/java/noppes/npcs/ai/EntityAIOrbitTarget.java b/src/main/java/noppes/npcs/ai/EntityAIOrbitTarget.java index 68ccabfa6..4c72ec278 100644 --- a/src/main/java/noppes/npcs/ai/EntityAIOrbitTarget.java +++ b/src/main/java/noppes/npcs/ai/EntityAIOrbitTarget.java @@ -9,18 +9,18 @@ import noppes.npcs.entity.EntityNPCInterface; import java.util.Random; public class EntityAIOrbitTarget extends EntityAIBase { - private final EntityNPCInterface theEntity; + private EntityNPCInterface theEntity; private EntityLivingBase targetEntity; private double movePosX; private double movePosY; private double movePosZ; - private final double speed; - private final float distance; + private double speed; + private float distance; private int delay = 0; private float angle = 0; private int direction = 1; private float targetDistance; - private final boolean decay; + private boolean decay; private boolean canNavigate = true; private float decayRate = 1.0F; private int tick = 0; @@ -47,7 +47,7 @@ public class EntityAIOrbitTarget extends EntityAIBase { return false; } else { double d0 = this.theEntity.getDistanceToEntity(this.targetEntity); - return d0 >= this.distance / 2.0F && (this.theEntity.inventory.getProjectile() != null || d0 <= this.distance); + return d0 >= this.distance / 2.0F && (this.theEntity.inventory.getProjectile() == null ? d0 <= this.distance : true); } } diff --git a/src/main/java/noppes/npcs/ai/EntityAIPanic.java b/src/main/java/noppes/npcs/ai/EntityAIPanic.java index a0fa7b38f..34de1eb75 100644 --- a/src/main/java/noppes/npcs/ai/EntityAIPanic.java +++ b/src/main/java/noppes/npcs/ai/EntityAIPanic.java @@ -6,8 +6,8 @@ import net.minecraft.util.Vec3; import noppes.npcs.constants.AiMutex; public class EntityAIPanic extends EntityAIBase { - private final EntityCreature theEntityCreature; - private final float speed; + private EntityCreature theEntityCreature; + private float speed; private double randPosX; private double randPosY; private double randPosZ; diff --git a/src/main/java/noppes/npcs/ai/EntityAIPounceTarget.java b/src/main/java/noppes/npcs/ai/EntityAIPounceTarget.java index 4e6e4659f..5dbe5f233 100644 --- a/src/main/java/noppes/npcs/ai/EntityAIPounceTarget.java +++ b/src/main/java/noppes/npcs/ai/EntityAIPounceTarget.java @@ -6,9 +6,9 @@ import net.minecraft.util.MathHelper; import noppes.npcs.entity.EntityNPCInterface; public class EntityAIPounceTarget extends EntityAIBase { - private final EntityNPCInterface npc; + private EntityNPCInterface npc; private EntityLivingBase leapTarget; - private final float leapSpeed = 1.2F; + private float leapSpeed = 1.2F; public EntityAIPounceTarget(EntityNPCInterface leapingEntity) { this.npc = leapingEntity; @@ -41,9 +41,9 @@ public class EntityAIPounceTarget extends EntityAIBase { float varF = MathHelper.sqrt_double(varX * varX + varZ * varZ); float angle = this.getAngleForXYZ(varX, varY, varZ, varF); float yaw = (float) (Math.atan2(varX, varZ) * 180.0D / Math.PI); - this.npc.motionX = MathHelper.sin(yaw / 180.0F * (float) Math.PI) * MathHelper.cos(angle / 180.0F * (float) Math.PI); - this.npc.motionZ = MathHelper.cos(yaw / 180.0F * (float) Math.PI) * MathHelper.cos(angle / 180.0F * (float) Math.PI); - this.npc.motionY = MathHelper.sin((angle + 1.0F) / 180.0F * (float) Math.PI); + this.npc.motionX = (double) (MathHelper.sin(yaw / 180.0F * (float) Math.PI) * MathHelper.cos(angle / 180.0F * (float) Math.PI)); + this.npc.motionZ = (double) (MathHelper.cos(yaw / 180.0F * (float) Math.PI) * MathHelper.cos(angle / 180.0F * (float) Math.PI)); + this.npc.motionY = (double) (MathHelper.sin((angle + 1.0F) / 180.0F * (float) Math.PI)); this.npc.motionX *= this.leapSpeed; this.npc.motionZ *= this.leapSpeed; this.npc.motionY *= this.leapSpeed; diff --git a/src/main/java/noppes/npcs/ai/EntityAIRangedAttack.java b/src/main/java/noppes/npcs/ai/EntityAIRangedAttack.java index 739c1898d..717c3be8a 100644 --- a/src/main/java/noppes/npcs/ai/EntityAIRangedAttack.java +++ b/src/main/java/noppes/npcs/ai/EntityAIRangedAttack.java @@ -28,9 +28,10 @@ public class EntityAIRangedAttack extends EntityAIBase { private int rangedAttackTime = 0; private int field_75318_f = 0; private int field_70846_g = 0; - private final int attackTick = 0; + private int attackTick = 0; private boolean hasFired = false; private boolean navOverride = false; + private boolean isShooting = false; public EntityAIRangedAttack(IRangedAttackMob par1IRangedAttackMob) { if (!(par1IRangedAttackMob instanceof EntityLivingBase)) { @@ -49,16 +50,28 @@ public class EntityAIRangedAttack extends EntityAIBase { public boolean shouldExecute() { EntityLivingBase var1 = this.entityHost.getAttackTarget(); - if (var1 == null || !var1.isEntityAlive()) return false; + if (var1 == null || !var1.isEntityAlive()){ + isShooting = false; + return false; + } - if (entityHost.getDistanceToEntity(var1) > entityHost.stats.aggroRange) return false; + if (entityHost.getDistanceToEntity(var1) > entityHost.stats.aggroRange){ + isShooting = false; + return false; + } - if (this.entityHost.inventory.getProjectile() == null) return false; + if (this.entityHost.inventory.getProjectile() == null){ + isShooting = false; + return false; + } double var2 = this.entityHost.getDistanceSq(var1.posX, var1.boundingBox.minY, var1.posZ); double var3 = this.entityHost.ais.distanceToMelee * this.entityHost.ais.distanceToMelee; - if (this.entityHost.ais.useRangeMelee >= 1 && var2 <= var3) return false; + if (this.entityHost.ais.useRangeMelee >= 1 && var2 <= var3){ + isShooting = false; + return false; + } else { this.attackTarget = var1; @@ -111,12 +124,17 @@ public class EntityAIRangedAttack extends EntityAIBase { if (this.rangedAttackTime <= 0) { if (var1 <= (double) field_82642_h && (this.entityHost.getEntitySenses().canSee(this.attackTarget) || this.entityHost.ais.canFireIndirect == 2)) { + if (this.field_70846_g == 0) { + this.entityHost.stats.playBurstSound = true; + } if (this.field_70846_g++ <= this.entityHost.stats.burstCount) { this.rangedAttackTime = this.entityHost.stats.fireRate; + this.isShooting = true; } else { this.field_70846_g = 0; this.hasFired = true; this.rangedAttackTime = (this.entityHost.stats.maxDelay - MathHelper.floor_float(this.entityHost.getRNG().nextFloat() * (this.entityHost.stats.maxDelay - this.entityHost.stats.minDelay))); + this.isShooting = false; } if (this.field_70846_g > 1) { @@ -143,6 +161,10 @@ public class EntityAIRangedAttack extends EntityAIBase { return this.hasFired; } + public boolean isShooting() { + return this.isShooting; + } + public void navOverride(boolean nav) { this.navOverride = nav; this.setMutexBits(this.navOverride ? AiMutex.PATHING : AiMutex.LOOK + AiMutex.PASSIVE); diff --git a/src/main/java/noppes/npcs/ai/EntityAIRole.java b/src/main/java/noppes/npcs/ai/EntityAIRole.java index b5a61392b..cfff7ff32 100644 --- a/src/main/java/noppes/npcs/ai/EntityAIRole.java +++ b/src/main/java/noppes/npcs/ai/EntityAIRole.java @@ -5,7 +5,7 @@ import noppes.npcs.entity.EntityNPCInterface; public class EntityAIRole extends EntityAIBase { - private final EntityNPCInterface npc; + private EntityNPCInterface npc; public EntityAIRole(EntityNPCInterface npc) { this.npc = npc; diff --git a/src/main/java/noppes/npcs/ai/EntityAISprintToTarget.java b/src/main/java/noppes/npcs/ai/EntityAISprintToTarget.java index 8161dc0e7..0d8d100c2 100644 --- a/src/main/java/noppes/npcs/ai/EntityAISprintToTarget.java +++ b/src/main/java/noppes/npcs/ai/EntityAISprintToTarget.java @@ -6,7 +6,7 @@ import noppes.npcs.constants.AiMutex; import noppes.npcs.entity.EntityNPCInterface; public class EntityAISprintToTarget extends EntityAIBase { - private final EntityNPCInterface npc; + private EntityNPCInterface npc; public EntityAISprintToTarget(EntityNPCInterface par1EntityLiving) { this.npc = par1EntityLiving; @@ -23,9 +23,9 @@ public class EntityAISprintToTarget extends EntityAIBase { switch (this.npc.ais.onAttack) { case 0: - return !this.npc.isInRange(runTarget, 8) && (this.npc.onGround); + return !this.npc.isInRange(runTarget, 8) ? (!this.npc.onGround ? false : true) : false; case 2: - return this.npc.isInRange(runTarget, 7) && (this.npc.onGround); + return this.npc.isInRange(runTarget, 7) ? (!this.npc.onGround ? false : true) : false; default: return false; } diff --git a/src/main/java/noppes/npcs/ai/EntityAIStalkTarget.java b/src/main/java/noppes/npcs/ai/EntityAIStalkTarget.java index e33b8a517..1b64a12b7 100644 --- a/src/main/java/noppes/npcs/ai/EntityAIStalkTarget.java +++ b/src/main/java/noppes/npcs/ai/EntityAIStalkTarget.java @@ -10,12 +10,12 @@ import noppes.npcs.constants.AiMutex; import noppes.npcs.entity.EntityNPCInterface; public class EntityAIStalkTarget extends EntityAIBase { - private final EntityNPCInterface theEntity; + private EntityNPCInterface theEntity; private EntityLivingBase targetEntity; private Vec3 movePosition; - private final double distance; + private double distance; private boolean overRide; - private final World theWorld; + private World theWorld; private int delay; private int tick = 0; @@ -146,7 +146,7 @@ public class EntityAIStalkTarget extends EntityAIBase { Vec3 vec2 = Vec3.createVectorHelper(j, k + (double) this.theEntity.getEyeHeight(), l); MovingObjectPosition movingobjectposition = this.theWorld.rayTraceBlocks(vec1, vec2); if (movingobjectposition != null) { - weight = !nearest || this.targetEntity.getDistanceSq(j, k, l) <= dist; + weight = nearest ? this.targetEntity.getDistanceSq(j, k, l) <= dist : true; if (weight && (j != u || k != v || l != w)) { idealPos = Vec3.createVectorHelper(j, k, l); if (nearest) dist = this.targetEntity.getDistanceSq(j, k, l); diff --git a/src/main/java/noppes/npcs/ai/EntityAITransform.java b/src/main/java/noppes/npcs/ai/EntityAITransform.java index e8572aba5..9f565bccc 100644 --- a/src/main/java/noppes/npcs/ai/EntityAITransform.java +++ b/src/main/java/noppes/npcs/ai/EntityAITransform.java @@ -6,7 +6,7 @@ import noppes.npcs.entity.EntityNPCInterface; public class EntityAITransform extends EntityAIBase { - private final EntityNPCInterface npc; + private EntityNPCInterface npc; public EntityAITransform(EntityNPCInterface npc) { this.npc = npc; @@ -18,7 +18,7 @@ public class EntityAITransform extends EntityAIBase { if (npc.isKilled() || npc.isAttacking() || npc.transform.editingModus) return false; - return (npc.worldObj.getWorldTime() % 24000 < 12000) == npc.transform.isActive; + return npc.worldObj.getWorldTime() % 24000 < 12000 ? npc.transform.isActive : !npc.transform.isActive; } public void startExecuting() { diff --git a/src/main/java/noppes/npcs/ai/EntityAIWander.java b/src/main/java/noppes/npcs/ai/EntityAIWander.java index adef27169..0092338c7 100644 --- a/src/main/java/noppes/npcs/ai/EntityAIWander.java +++ b/src/main/java/noppes/npcs/ai/EntityAIWander.java @@ -14,7 +14,7 @@ import java.util.Iterator; import java.util.List; public class EntityAIWander extends EntityAIBase { - private final EntityNPCInterface entity; + private EntityNPCInterface entity; public final IEntitySelector selector; private double xPosition; private double yPosition; diff --git a/src/main/java/noppes/npcs/ai/EntityAIWatchClosest.java b/src/main/java/noppes/npcs/ai/EntityAIWatchClosest.java index 89bfe5cd7..d30ae3183 100644 --- a/src/main/java/noppes/npcs/ai/EntityAIWatchClosest.java +++ b/src/main/java/noppes/npcs/ai/EntityAIWatchClosest.java @@ -7,16 +7,16 @@ import noppes.npcs.constants.AiMutex; import noppes.npcs.entity.EntityNPCInterface; public class EntityAIWatchClosest extends EntityAIBase { - private final EntityNPCInterface theWatcher; + private EntityNPCInterface theWatcher; /** * The closest entity which is being watched by this one. */ protected Entity closestEntity; - private final float field_75333_c; + private float field_75333_c; private int lookTime; - private final float field_75331_e; - private final Class watchedClass; + private float field_75331_e; + private Class watchedClass; public EntityAIWatchClosest(EntityNPCInterface par1EntityLiving, Class par2Class, float par3) { this.theWatcher = par1EntityLiving; @@ -39,9 +39,9 @@ public class EntityAIWatchClosest extends EntityAIBase { } if (this.watchedClass == EntityPlayer.class) { - this.closestEntity = this.theWatcher.worldObj.getClosestPlayerToEntity(this.theWatcher, this.field_75333_c); + this.closestEntity = this.theWatcher.worldObj.getClosestPlayerToEntity(this.theWatcher, (double) this.field_75333_c); } else { - this.closestEntity = this.theWatcher.worldObj.findNearestEntityWithinAABB(this.watchedClass, this.theWatcher.boundingBox.expand(this.field_75333_c, 3.0D, this.field_75333_c), this.theWatcher); + this.closestEntity = this.theWatcher.worldObj.findNearestEntityWithinAABB(this.watchedClass, this.theWatcher.boundingBox.expand((double) this.field_75333_c, 3.0D, (double) this.field_75333_c), this.theWatcher); if (this.closestEntity != null) { return this.theWatcher.canSee(this.closestEntity); } @@ -58,7 +58,7 @@ public class EntityAIWatchClosest extends EntityAIBase { public boolean continueExecuting() { if (theWatcher.isInteracting() || theWatcher.isAttacking() || !this.closestEntity.isEntityAlive() || !theWatcher.isEntityAlive()) return false; - return !(this.theWatcher.getDistanceSqToEntity(this.closestEntity) > (double) (this.field_75333_c * this.field_75333_c)) && this.lookTime > 0; + return this.theWatcher.getDistanceSqToEntity(this.closestEntity) > (double) (this.field_75333_c * this.field_75333_c) ? false : this.lookTime > 0; } /** diff --git a/src/main/java/noppes/npcs/ai/EntityAIWaterNav.java b/src/main/java/noppes/npcs/ai/EntityAIWaterNav.java index ecf4aed09..4e74356e0 100644 --- a/src/main/java/noppes/npcs/ai/EntityAIWaterNav.java +++ b/src/main/java/noppes/npcs/ai/EntityAIWaterNav.java @@ -4,7 +4,7 @@ import net.minecraft.entity.ai.EntityAIBase; import noppes.npcs.entity.EntityNPCInterface; public class EntityAIWaterNav extends EntityAIBase { - private final EntityNPCInterface theEntity; + private EntityNPCInterface theEntity; public EntityAIWaterNav(EntityNPCInterface par1EntityNPCInterface) { this.theEntity = par1EntityNPCInterface; @@ -18,7 +18,9 @@ public class EntityAIWaterNav extends EntityAIBase { if (this.theEntity.isInWater() || this.theEntity.handleLavaMovement()) { if (this.theEntity.ais.canSwim) { return true; - } else return this.theEntity.isCollidedHorizontally; + } else if (this.theEntity.isCollidedHorizontally) { + return true; + } } return false; diff --git a/src/main/java/noppes/npcs/ai/EntityAIZigZagTarget.java b/src/main/java/noppes/npcs/ai/EntityAIZigZagTarget.java index e76f63018..3e91cc84b 100644 --- a/src/main/java/noppes/npcs/ai/EntityAIZigZagTarget.java +++ b/src/main/java/noppes/npcs/ai/EntityAIZigZagTarget.java @@ -10,7 +10,7 @@ import net.minecraft.util.Vec3; import noppes.npcs.constants.AiMutex; public class EntityAIZigZagTarget extends EntityAIBase { - private final EntityCreature theEntity; + private EntityCreature theEntity; private EntityLivingBase targetEntity; private double movePosX; private double movePosY; @@ -18,8 +18,8 @@ public class EntityAIZigZagTarget extends EntityAIBase { private int entityPosX; private int entityPosY; private int entityPosZ; - private final double speed; - private final float tacticalRange; + private double speed; + private float tacticalRange; public EntityAIZigZagTarget(EntityCreature par1EntityCreature, double par2, float par4) { this.theEntity = par1EntityCreature; diff --git a/src/main/java/noppes/npcs/ai/RandomPositionGeneratorAlt.java b/src/main/java/noppes/npcs/ai/RandomPositionGeneratorAlt.java index 9fb235129..e07e60d9e 100644 --- a/src/main/java/noppes/npcs/ai/RandomPositionGeneratorAlt.java +++ b/src/main/java/noppes/npcs/ai/RandomPositionGeneratorAlt.java @@ -11,7 +11,7 @@ public class RandomPositionGeneratorAlt { * used to store a driection when the user passes a point to move towards or away from. WARNING: NEVER THREAD SAFE. * MULTIPLE findTowards and findAway calls, will share this var */ - private static final Vec3 staticVector = Vec3.createVectorHelper(0.0D, 0.0D, 0.0D); + private static Vec3 staticVector = Vec3.createVectorHelper(0.0D, 0.0D, 0.0D); /** * finds a random target within par1(x,z) and par2 (y) blocks @@ -21,7 +21,7 @@ public class RandomPositionGeneratorAlt { * searches 10 blocks at random in a within par1(x,z) and par2 (y) distance, ignores those not in the direction * of par3Vec3, then points to the tile for which creature.getBlockPathWeight returns the highest number */ - return findRandomTargetBlock(par0EntityCreature, par1, par2, null); + return findRandomTargetBlock(par0EntityCreature, par1, par2, (Vec3) null); } /** @@ -70,8 +70,8 @@ public class RandomPositionGeneratorAlt { boolean flag1; if (par0EntityCreature.hasHome()) { - double d0 = par0EntityCreature.getHomePosition().getDistanceSquared(MathHelper.floor_double(par0EntityCreature.posX), MathHelper.floor_double(par0EntityCreature.posY), MathHelper.floor_double(par0EntityCreature.posZ)) + 4.0F; - double d1 = par0EntityCreature.func_110174_bM() + (float) par1; + double d0 = (double) (par0EntityCreature.getHomePosition().getDistanceSquared(MathHelper.floor_double(par0EntityCreature.posX), MathHelper.floor_double(par0EntityCreature.posY), MathHelper.floor_double(par0EntityCreature.posZ)) + 4.0F); + double d1 = (double) (par0EntityCreature.func_110174_bM() + (float) par1); flag1 = d0 < d1 * d1; } else { flag1 = false; @@ -107,7 +107,7 @@ public class RandomPositionGeneratorAlt { } if (flag) { - return Vec3.createVectorHelper(k, l, i1); + return Vec3.createVectorHelper((double) k, (double) l, (double) i1); } else { return null; } diff --git a/src/main/java/noppes/npcs/ai/pathfinder/FlyPathFinder.java b/src/main/java/noppes/npcs/ai/pathfinder/FlyPathFinder.java index 4d7345a80..090986165 100644 --- a/src/main/java/noppes/npcs/ai/pathfinder/FlyPathFinder.java +++ b/src/main/java/noppes/npcs/ai/pathfinder/FlyPathFinder.java @@ -23,11 +23,11 @@ public class FlyPathFinder extends PathFinder { /** * Used to find obstacles */ - private final IBlockAccess worldMap; + private IBlockAccess worldMap; /** * The path being generated */ - private final PathHeap path = new PathHeap(); + private PathHeap path = new PathHeap(); /** * The points in the path */ @@ -35,15 +35,15 @@ public class FlyPathFinder extends PathFinder { /** * Selection of path points to add to the path */ - private final NPCPathPoint[] pathOptions = new NPCPathPoint[32]; - private final Entity theEntity; + private NPCPathPoint[] pathOptions = new NPCPathPoint[32]; + private Entity theEntity; private final Map mapPathPriority = Maps.newEnumMap(PathNodeType.class); - private final boolean isPathingInWater; - private final boolean isMovementBlockAllowed; - private final boolean isWoodenDoorAllowed; - private final boolean canEntityDrown; + private boolean isPathingInWater; + private boolean isMovementBlockAllowed; + private boolean isWoodenDoorAllowed; + private boolean canEntityDrown; private int drowningType; private boolean immuneToFire; @@ -70,7 +70,7 @@ public class FlyPathFinder extends PathFinder { * Creates a path from an entity to a specified location within a minimum distance */ public NPCPath createEntityPathTo(Entity entityFrom, int xTo, int yTo, int zTo, float distance) { - return this.createEntityPathTo(entityFrom, (float) xTo + 0.5F, (float) yTo + 0.5F, (float) zTo + 0.5F, distance); + return this.createEntityPathTo(entityFrom, (double) ((float) xTo + 0.5F), (double) ((float) yTo + 0.5F), (double) ((float) zTo + 0.5F), distance); } /** @@ -110,11 +110,11 @@ public class FlyPathFinder extends PathFinder { PathNodeType pathnodetype1 = this.getPathNodeType((EntityLiving) this.theEntity, blockpos1.getX(), i, blockpos1.getZ()); if (this.getPathPriority(pathnodetype1) < 0.0F) { - Set set = Sets.newHashSet(); - set.add(new BlockPos(this.theEntity.boundingBox.minX, i, this.theEntity.boundingBox.minZ)); - set.add(new BlockPos(this.theEntity.boundingBox.minX, i, this.theEntity.boundingBox.maxZ)); - set.add(new BlockPos(this.theEntity.boundingBox.maxX, i, this.theEntity.boundingBox.minZ)); - set.add(new BlockPos(this.theEntity.boundingBox.maxX, i, this.theEntity.boundingBox.maxZ)); + Set set = Sets.newHashSet(); + set.add(new BlockPos(this.theEntity.boundingBox.minX, (double) i, this.theEntity.boundingBox.minZ)); + set.add(new BlockPos(this.theEntity.boundingBox.minX, (double) i, this.theEntity.boundingBox.maxZ)); + set.add(new BlockPos(this.theEntity.boundingBox.maxX, (double) i, this.theEntity.boundingBox.minZ)); + set.add(new BlockPos(this.theEntity.boundingBox.maxX, (double) i, this.theEntity.boundingBox.maxZ)); for (BlockPos blockpos : set) { PathNodeType pathnodetype = this.getPathNodeType((EntityLiving) this.theEntity, blockpos); @@ -473,7 +473,7 @@ public class FlyPathFinder extends PathFinder { public PathNodeType getPathNodeType(IBlockAccess blockaccessIn, int x, int y, int z, EntityLiving entitylivingIn, int xSize, int ySize, int zSize, boolean canBreakDoorsIn, boolean canEnterDoorsIn) { - EnumSet enumset = EnumSet.noneOf(PathNodeType.class); + EnumSet enumset = EnumSet.noneOf(PathNodeType.class); PathNodeType pathnodetype = PathNodeType.BLOCKED; BlockPos blockpos = new BlockPos(entitylivingIn); pathnodetype = this.getPathNodeType(blockaccessIn, x, y, z, xSize, ySize, zSize, canBreakDoorsIn, canEnterDoorsIn, enumset, pathnodetype, blockpos); @@ -602,11 +602,11 @@ public class FlyPathFinder extends PathFinder { return immuneToFire ? PathNodeType.OPEN : PathNodeType.DAMAGE_FIRE; } else if (block == Blocks.cactus) { return PathNodeType.DAMAGE_CACTUS; - } else if (block instanceof BlockDoor && material == Material.wood && !block.getBlocksMovement(this.worldMap, p_189553_2_, p_189553_3_, p_189553_4_)) { + } else if (block instanceof BlockDoor && material == Material.wood && !((BlockDoor) block).getBlocksMovement(this.worldMap, p_189553_2_, p_189553_3_, p_189553_4_)) { return PathNodeType.DOOR_WOOD_CLOSED; - } else if (block instanceof BlockDoor && material == Material.wood && !block.getBlocksMovement(this.worldMap, p_189553_2_, p_189553_3_, p_189553_4_)) { + } else if (block instanceof BlockDoor && material == Material.wood && !((BlockDoor) block).getBlocksMovement(this.worldMap, p_189553_2_, p_189553_3_, p_189553_4_)) { return PathNodeType.DOOR_IRON_CLOSED; - } else if (block instanceof BlockDoor && block.getBlocksMovement(this.worldMap, p_189553_2_, p_189553_3_, p_189553_4_)) { + } else if (block instanceof BlockDoor && ((BlockDoor) block).getBlocksMovement(this.worldMap, p_189553_2_, p_189553_3_, p_189553_4_)) { return PathNodeType.DOOR_OPEN; } else if (block instanceof BlockRailBase) { return PathNodeType.RAIL; diff --git a/src/main/java/noppes/npcs/ai/pathfinder/NPCPath.java b/src/main/java/noppes/npcs/ai/pathfinder/NPCPath.java index 0cc66729e..b19b271f8 100644 --- a/src/main/java/noppes/npcs/ai/pathfinder/NPCPath.java +++ b/src/main/java/noppes/npcs/ai/pathfinder/NPCPath.java @@ -84,7 +84,7 @@ public class NPCPath extends PathEntity { public Vec3 getCurrentPos() { NPCPathPoint pathpoint = this.points[this.currentPathIndex]; - return Vec3.createVectorHelper(pathpoint.xCoord, pathpoint.yCoord, pathpoint.zCoord); + return Vec3.createVectorHelper((double) pathpoint.xCoord, (double) pathpoint.yCoord, (double) pathpoint.zCoord); } /** @@ -112,6 +112,6 @@ public class NPCPath extends PathEntity { */ public boolean isDestinationSame(Vec3 vec3) { NPCPathPoint pathpoint = this.getFinalPathPoint(); - return pathpoint != null && pathpoint.xCoord == (int) vec3.xCoord && pathpoint.zCoord == (int) vec3.zCoord; + return pathpoint == null ? false : pathpoint.xCoord == (int) vec3.xCoord && pathpoint.zCoord == (int) vec3.zCoord; } } diff --git a/src/main/java/noppes/npcs/ai/pathfinder/PathNavigateFlying.java b/src/main/java/noppes/npcs/ai/pathfinder/PathNavigateFlying.java index 35359d813..df2e4c868 100644 --- a/src/main/java/noppes/npcs/ai/pathfinder/PathNavigateFlying.java +++ b/src/main/java/noppes/npcs/ai/pathfinder/PathNavigateFlying.java @@ -22,8 +22,8 @@ import javax.annotation.Nullable; public class PathNavigateFlying extends PathNavigate { - private final EntityNPCInterface theEntity; - private final World worldObj; + private EntityNPCInterface theEntity; + private World worldObj; /** * The PathEntity being followed. */ @@ -32,7 +32,7 @@ public class PathNavigateFlying extends PathNavigate { /** * The number of blocks (extra) +/- in each axis that get pulled out as cache for the pathfinder's search space */ - private final IAttributeInstance pathSearchRange; + private IAttributeInstance pathSearchRange; protected float maxDistanceToWaypoint = 0.5F; private boolean noSunPathfind; /** @@ -168,7 +168,7 @@ public class PathNavigateFlying extends PathNavigate { * Try to find and set a path to XYZ. Returns true if successful. */ public boolean tryMoveToXYZ(double p_75492_1_, double p_75492_3_, double p_75492_5_, double p_75492_7_) { - NPCPath pathentity = this.getPathToXYZ(MathHelper.floor_double(p_75492_1_), (int) p_75492_3_, MathHelper.floor_double(p_75492_5_)); + NPCPath pathentity = this.getPathToXYZ((double) MathHelper.floor_double(p_75492_1_), (double) ((int) p_75492_3_), (double) MathHelper.floor_double(p_75492_5_)); return this.setPath(pathentity, p_75492_7_); } @@ -252,7 +252,7 @@ public class PathNavigateFlying extends PathNavigate { if (!this.noPath()) { if (this.canNavigate()) { - if (this.theEntity.display.modelSize >= 5) + if (((EntityNPCInterface) this.theEntity).display.modelSize >= 5) this.pathFollowBig(); else this.pathFollowSmall(); @@ -384,7 +384,10 @@ public class PathNavigateFlying extends PathNavigate { private boolean isDirectPathBetweenPoints(Vec3 startPos, Vec3 endPos, int width, int height) { Vec3 pos17 = Vec3.createVectorHelper(startPos.xCoord, startPos.yCoord, startPos.zCoord); Vec3 pos18 = Vec3.createVectorHelper(endPos.xCoord, endPos.yCoord, endPos.zCoord); - return !this.rayTraceBlocks(pos17, pos18, true, false, false, width, height); + if (this.rayTraceBlocks(pos17, pos18, true, false, false, width, height)) + return false; + + return true; } public boolean rayTraceBlocks(Vec3 p_147447_1_, Vec3 p_147447_2_, boolean p_147447_3_, boolean p_147447_4_, boolean p_147447_5_, int width, int height) { @@ -508,21 +511,21 @@ public class PathNavigateFlying extends PathNavigate { } Vec3 vec32 = Vec3.createVectorHelper(p_147447_1_.xCoord, p_147447_1_.yCoord, p_147447_1_.zCoord); - l = (int) (vec32.xCoord = MathHelper.floor_double(p_147447_1_.xCoord)); + l = (int) (vec32.xCoord = (double) MathHelper.floor_double(p_147447_1_.xCoord)); if (b0 == 5) { --l; ++vec32.xCoord; } - i1 = (int) (vec32.yCoord = MathHelper.floor_double(p_147447_1_.yCoord)); + i1 = (int) (vec32.yCoord = (double) MathHelper.floor_double(p_147447_1_.yCoord)); if (b0 == 1) { --i1; ++vec32.yCoord; } - j1 = (int) (vec32.zCoord = MathHelper.floor_double(p_147447_1_.zCoord)); + j1 = (int) (vec32.zCoord = (double) MathHelper.floor_double(p_147447_1_.zCoord)); if (b0 == 3) { --j1; @@ -621,6 +624,7 @@ public class PathNavigateFlying extends PathNavigate { if (this.timeoutLimit > 0.0D && (double) this.timeoutTimer > this.timeoutLimit * 3.0D) { this.timeoutCachedNode = Vec3.createVectorHelper(0.0D, 0.0D, 0.0D); + ; this.timeoutTimer = 0L; this.timeoutLimit = 0.0D; this.clearPathEntity(); diff --git a/src/main/java/noppes/npcs/ai/pathfinder/PathNodeType.java b/src/main/java/noppes/npcs/ai/pathfinder/PathNodeType.java index 009f2ede6..a7eed5618 100644 --- a/src/main/java/noppes/npcs/ai/pathfinder/PathNodeType.java +++ b/src/main/java/noppes/npcs/ai/pathfinder/PathNodeType.java @@ -21,7 +21,7 @@ public enum PathNodeType { private final float priority; - PathNodeType(float priorityIn) { + private PathNodeType(float priorityIn) { this.priority = priorityIn; } diff --git a/src/main/java/noppes/npcs/ai/selector/NPCAttackSelector.java b/src/main/java/noppes/npcs/ai/selector/NPCAttackSelector.java index c2db3cfd8..4041977d9 100644 --- a/src/main/java/noppes/npcs/ai/selector/NPCAttackSelector.java +++ b/src/main/java/noppes/npcs/ai/selector/NPCAttackSelector.java @@ -18,7 +18,7 @@ import noppes.npcs.roles.RoleCompanion; import noppes.npcs.roles.companion.CompanionGuard; public class NPCAttackSelector implements IEntitySelector { - private final EntityNPCInterface npc; + private EntityNPCInterface npc; public NPCAttackSelector(EntityNPCInterface npc) { this.npc = npc; @@ -34,7 +34,7 @@ public class NPCAttackSelector implements IEntitySelector { if (this.npc.ais.directLOS && !this.npc.getEntitySenses().canSee(entity)) return false; - if (!npc.stats.attackInvisible && ((EntityLivingBase) entity).isPotionActive(Potion.invisibility) && npc.getDistanceSqToEntity(entity) < 9) + if (!npc.stats.attackInvisible && ((EntityLivingBase) entity).isPotionActive(Potion.invisibility) && !npc.isInRange(entity, 3.0)) return false; //prevent the npc from going on an endless killing spree diff --git a/src/main/java/noppes/npcs/ai/selector/NPCInteractSelector.java b/src/main/java/noppes/npcs/ai/selector/NPCInteractSelector.java index eb9331a50..b0a536dcc 100644 --- a/src/main/java/noppes/npcs/ai/selector/NPCInteractSelector.java +++ b/src/main/java/noppes/npcs/ai/selector/NPCInteractSelector.java @@ -5,7 +5,7 @@ import net.minecraft.entity.Entity; import noppes.npcs.entity.EntityNPCInterface; public class NPCInteractSelector implements IEntitySelector { - private final EntityNPCInterface npc; + private EntityNPCInterface npc; public NPCInteractSelector(EntityNPCInterface npc) { this.npc = npc; @@ -16,7 +16,9 @@ public class NPCInteractSelector implements IEntitySelector { if (entity == npc || !(entity instanceof EntityNPCInterface) || !npc.isEntityAlive()) return false; EntityNPCInterface selected = (EntityNPCInterface) entity; - return !selected.isAttacking() && !npc.getFaction().isAggressiveToNpc(selected) && npc.ais.stopAndInteract; + if (selected.isAttacking() || npc.getFaction().isAggressiveToNpc(selected) || !npc.ais.stopAndInteract) + return false; + return true; } } diff --git a/src/main/java/noppes/npcs/ai/target/EntityAIClearTarget.java b/src/main/java/noppes/npcs/ai/target/EntityAIClearTarget.java index e8c131817..1ac4fd45b 100644 --- a/src/main/java/noppes/npcs/ai/target/EntityAIClearTarget.java +++ b/src/main/java/noppes/npcs/ai/target/EntityAIClearTarget.java @@ -5,7 +5,7 @@ import net.minecraft.entity.ai.EntityAITarget; import noppes.npcs.entity.EntityNPCInterface; public class EntityAIClearTarget extends EntityAITarget { - private final EntityNPCInterface npc; + private EntityNPCInterface npc; private EntityLivingBase target; public EntityAIClearTarget(EntityNPCInterface npc) { diff --git a/src/main/java/noppes/npcs/ai/target/EntityAIClosestTarget.java b/src/main/java/noppes/npcs/ai/target/EntityAIClosestTarget.java index a257faf02..b6f83ac44 100644 --- a/src/main/java/noppes/npcs/ai/target/EntityAIClosestTarget.java +++ b/src/main/java/noppes/npcs/ai/target/EntityAIClosestTarget.java @@ -30,7 +30,7 @@ public class EntityAIClosestTarget extends EntityAITarget { } public EntityAIClosestTarget(EntityCreature par1EntityCreature, Class par2Class, int par3, boolean par4, boolean par5) { - this(par1EntityCreature, par2Class, par3, par4, par5, null); + this(par1EntityCreature, par2Class, par3, par4, par5, (IEntitySelector) null); } public EntityAIClosestTarget(EntityCreature par1EntityCreature, Class par2Class, int par3, boolean par4, boolean par5, IEntitySelector par6IEntitySelector) { diff --git a/src/main/java/noppes/npcs/blocks/BlockCampfire.java b/src/main/java/noppes/npcs/blocks/BlockCampfire.java index 18d888819..11b520b2e 100644 --- a/src/main/java/noppes/npcs/blocks/BlockCampfire.java +++ b/src/main/java/noppes/npcs/blocks/BlockCampfire.java @@ -92,9 +92,9 @@ public class BlockCampfire extends BlockLightable { float xOffset = 0.5f, yOffset = 0.7f, zOffset = 0.5f; - double d0 = (float) x + xOffset; - double d1 = (float) y + yOffset; - double d2 = (float) z + zOffset; + double d0 = (double) ((float) x + xOffset); + double d1 = (double) ((float) y + yOffset); + double d2 = (double) ((float) z + zOffset); GL11.glPushMatrix(); diff --git a/src/main/java/noppes/npcs/blocks/BlockCandle.java b/src/main/java/noppes/npcs/blocks/BlockCandle.java index ce0238ba2..401b36897 100644 --- a/src/main/java/noppes/npcs/blocks/BlockCandle.java +++ b/src/main/java/noppes/npcs/blocks/BlockCandle.java @@ -146,9 +146,9 @@ public class BlockCandle extends BlockLightable { if (tile.rotation == 2) xOffset -= 0.12f; } - double d0 = (float) x + xOffset; - double d1 = (float) y + yOffset; - double d2 = (float) z + zOffset; + double d0 = (double) ((float) x + xOffset); + double d1 = (double) ((float) y + yOffset); + double d2 = (double) ((float) z + zOffset); world.spawnParticle("smoke", d0, d1, d2, 0.0D, 0.0D, 0.0D); world.spawnParticle("flame", d0, d1, d2, 0.0D, 0.0D, 0.0D); diff --git a/src/main/java/noppes/npcs/blocks/BlockPlaceholder.java b/src/main/java/noppes/npcs/blocks/BlockPlaceholder.java index 1de4b1953..e0141e680 100644 --- a/src/main/java/noppes/npcs/blocks/BlockPlaceholder.java +++ b/src/main/java/noppes/npcs/blocks/BlockPlaceholder.java @@ -16,7 +16,7 @@ import java.util.List; public class BlockPlaceholder extends Block { - private final IIcon[] icons = new IIcon[16]; + private IIcon[] icons = new IIcon[16]; public BlockPlaceholder() { super(Material.rock); diff --git a/src/main/java/noppes/npcs/blocks/BlockRotated.java b/src/main/java/noppes/npcs/blocks/BlockRotated.java index 753b2ede9..735e088eb 100644 --- a/src/main/java/noppes/npcs/blocks/BlockRotated.java +++ b/src/main/java/noppes/npcs/blocks/BlockRotated.java @@ -16,7 +16,7 @@ import net.minecraftforge.common.util.ForgeDirection; import noppes.npcs.blocks.tiles.TileVariant; public abstract class BlockRotated extends BlockContainer { - private final Block block; + private Block block; protected BlockRotated(Block block) { super(block.getMaterial()); diff --git a/src/main/java/noppes/npcs/blocks/tiles/TileNpcContainer.java b/src/main/java/noppes/npcs/blocks/tiles/TileNpcContainer.java index ed05fb453..3373fbae9 100644 --- a/src/main/java/noppes/npcs/blocks/tiles/TileNpcContainer.java +++ b/src/main/java/noppes/npcs/blocks/tiles/TileNpcContainer.java @@ -144,7 +144,7 @@ public abstract class TileNpcContainer extends TileVariant implements IInventory @Override public boolean isUseableByPlayer(EntityPlayer player) { - return !player.isDead && this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord) == this && player.getDistanceSq((double) this.xCoord + 0.5D, (double) this.yCoord + 0.5D, (double) this.zCoord + 0.5D) <= 64.0D; + return player.isDead || this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : player.getDistanceSq((double) this.xCoord + 0.5D, (double) this.yCoord + 0.5D, (double) this.zCoord + 0.5D) <= 64.0D; } @Override @@ -180,11 +180,11 @@ public abstract class TileNpcContainer extends TileVariant implements IInventory } itemstack.stackSize -= j1; - entityitem = new EntityItem(world, (float) x + f, (float) y + f1, (float) z + f2, new ItemStack(itemstack.getItem(), j1, itemstack.getItemDamage())); + entityitem = new EntityItem(world, (double) ((float) x + f), (double) ((float) y + f1), (double) ((float) z + f2), new ItemStack(itemstack.getItem(), j1, itemstack.getItemDamage())); float f3 = 0.05F; - entityitem.motionX = (float) world.rand.nextGaussian() * f3; - entityitem.motionY = (float) world.rand.nextGaussian() * f3 + 0.2F; - entityitem.motionZ = (float) world.rand.nextGaussian() * f3; + entityitem.motionX = (double) ((float) world.rand.nextGaussian() * f3); + entityitem.motionY = (double) ((float) world.rand.nextGaussian() * f3 + 0.2F); + entityitem.motionZ = (double) ((float) world.rand.nextGaussian() * f3); if (itemstack.hasTagCompound()) { entityitem.getEntityItem().setTagCompound((NBTTagCompound) itemstack.getTagCompound().copy()); diff --git a/src/main/java/noppes/npcs/blocks/tiles/TileRedstoneBlock.java b/src/main/java/noppes/npcs/blocks/tiles/TileRedstoneBlock.java index aabe5e5b4..630e30143 100644 --- a/src/main/java/noppes/npcs/blocks/tiles/TileRedstoneBlock.java +++ b/src/main/java/noppes/npcs/blocks/tiles/TileRedstoneBlock.java @@ -40,7 +40,7 @@ public class TileRedstoneBlock extends TileEntity { return; ticks = 20; Block block = worldObj.getBlock(this.xCoord, this.yCoord, this.zCoord); - if (block == null || !(block instanceof BlockNpcRedstone)) { + if (block == null || block instanceof BlockNpcRedstone == false) { return; } diff --git a/src/main/java/noppes/npcs/blocks/tiles/TileWaypoint.java b/src/main/java/noppes/npcs/blocks/tiles/TileWaypoint.java index 1faf4f657..20f2326ff 100644 --- a/src/main/java/noppes/npcs/blocks/tiles/TileWaypoint.java +++ b/src/main/java/noppes/npcs/blocks/tiles/TileWaypoint.java @@ -8,7 +8,6 @@ import net.minecraft.util.ChatComponentTranslation; import net.minecraft.util.StatCollector; import noppes.npcs.constants.EnumQuestType; import noppes.npcs.controllers.PartyController; -import noppes.npcs.controllers.PlayerDataController; import noppes.npcs.controllers.data.*; import noppes.npcs.quests.QuestLocation; @@ -20,7 +19,7 @@ public class TileWaypoint extends TileEntity { public String name = ""; private int ticks = 10; - private final List recentlyChecked = new ArrayList(); + private List recentlyChecked = new ArrayList(); private List toCheck; public int range = 10; @@ -43,7 +42,7 @@ public class TileWaypoint extends TileEntity { if (toCheck.isEmpty()) return; for (EntityPlayer player : toCheck) { - PlayerData playerData = PlayerDataController.Instance.getPlayerData(player); + PlayerData playerData = PlayerData.get(player); PlayerQuestData questData = playerData.questData; Party party = playerData.getPlayerParty(); Quest partyQuest = null; diff --git a/src/main/java/noppes/npcs/client/AssetsBrowser.java b/src/main/java/noppes/npcs/client/AssetsBrowser.java index bd40e1b15..1fc83c868 100644 --- a/src/main/java/noppes/npcs/client/AssetsBrowser.java +++ b/src/main/java/noppes/npcs/client/AssetsBrowser.java @@ -21,7 +21,7 @@ public class AssetsBrowser { private String folder; public HashSet folders = new HashSet(); public HashSet files = new HashSet(); - private final String[] extensions; + private String[] extensions; public AssetsBrowser(String folder, String[] extensions) { this.extensions = extensions; diff --git a/src/main/java/noppes/npcs/client/ClientEventHandler.java b/src/main/java/noppes/npcs/client/ClientEventHandler.java index 838227abb..1d24d2692 100644 --- a/src/main/java/noppes/npcs/client/ClientEventHandler.java +++ b/src/main/java/noppes/npcs/client/ClientEventHandler.java @@ -106,6 +106,7 @@ public class ClientEventHandler { @SubscribeEvent public void onRenderEntity(RenderLivingEvent.Pre event) { if (event.entity instanceof EntityNPCInterface) { + ClientEventHandler.renderingPlayer = null; ClientEventHandler.renderingNpc = (EntityNPCInterface) event.entity; } ClientEventHandler.renderer = event.renderer; @@ -170,13 +171,14 @@ public class ClientEventHandler { @SubscribeEvent public void onRenderPlayer(RenderPlayerEvent.Pre event) { + ClientEventHandler.renderingNpc = null; ClientEventHandler.renderingPlayer = event.entityPlayer; } @SubscribeEvent(priority = EventPriority.LOWEST) public void pre(RenderPlayerEvent.Pre event) { - if (!(event.entity instanceof AbstractClientPlayer)) { - } + if (!(event.entity instanceof AbstractClientPlayer)) + return; } @SubscribeEvent @@ -184,8 +186,8 @@ public class ClientEventHandler { EntityPlayer player = event.entityPlayer; ClientEventHandler.renderingPlayer = null; - if (renderPlayerJBRA != null && hasOverlays(player)) { - if (renderPlayerJBRA.isInstance(event.renderer)) + if (hasOverlays(player)) { + if (renderPlayerJBRA != null && renderPlayerJBRA.isInstance(event.renderer)) return; if (!(event.renderer instanceof RenderCNPCPlayer)) { @@ -219,11 +221,11 @@ public class ClientEventHandler { @SubscribeEvent public void tryRenderDBC(RenderPlayerEvent.Specials.Post event) { - if (renderPlayerJBRA == null || !hasOverlays(event.entityPlayer)) { + if (!hasOverlays(event.entityPlayer)) { return; } - if (!renderPlayerJBRA.isInstance(event.renderer)) { + if (renderPlayerJBRA == null || !renderPlayerJBRA.isInstance(event.renderer)) { return; } diff --git a/src/main/java/noppes/npcs/client/ClientProxy.java b/src/main/java/noppes/npcs/client/ClientProxy.java index aa934bc18..f93153c48 100644 --- a/src/main/java/noppes/npcs/client/ClientProxy.java +++ b/src/main/java/noppes/npcs/client/ClientProxy.java @@ -43,12 +43,14 @@ import noppes.npcs.client.fx.EntityRainbowFX; import noppes.npcs.client.gui.*; import noppes.npcs.client.gui.custom.GuiCustom; import noppes.npcs.client.gui.global.*; +import noppes.npcs.client.gui.item.GuiNpcMagicBook; import noppes.npcs.client.gui.item.GuiNpcPaintbrush; import noppes.npcs.client.gui.mainmenu.*; import noppes.npcs.client.gui.player.*; import noppes.npcs.client.gui.player.companion.GuiNpcCompanionInv; import noppes.npcs.client.gui.player.companion.GuiNpcCompanionStats; import noppes.npcs.client.gui.player.companion.GuiNpcCompanionTalents; +import noppes.npcs.client.gui.player.modern.BlurEventHandler; import noppes.npcs.client.gui.questtypes.GuiNpcQuestTypeItem; import noppes.npcs.client.gui.roles.*; import noppes.npcs.client.gui.script.GuiScriptBlock; @@ -112,6 +114,10 @@ public class ClientProxy extends CommonProxy { MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(CustomItems.scripted), new ScriptedBlockItemRenderer()); RenderingRegistry.registerBlockHandler(new BlockBorderRenderer()); + BlurEventHandler blurEventHandler = new BlurEventHandler(); + MinecraftForge.EVENT_BUS.register(blurEventHandler); + FMLCommonHandler.instance().bus().register(blurEventHandler); + if (!ConfigItem.DisableExtraBlock) { ClientRegistry.bindTileEntitySpecialRenderer(TileBanner.class, new BlockBannerRenderer()); ClientRegistry.bindTileEntitySpecialRenderer(TileWallBanner.class, new BlockWallBannerRenderer()); @@ -422,6 +428,9 @@ public class ClientProxy extends CommonProxy { else if (gui == EnumGuiType.Paintbrush) return new GuiNpcPaintbrush(); + else if (gui == EnumGuiType.MagicBook) + return new GuiNpcMagicBook(); + else if (gui == EnumGuiType.GlobalRemote) return new GuiNPCGlobalMainMenu(null); @@ -516,7 +525,7 @@ public class ClientProxy extends CommonProxy { } } - private final ModelSkirtArmor model = new ModelSkirtArmor(); + private ModelSkirtArmor model = new ModelSkirtArmor(); public ModelBiped getSkirtModel() { return model; @@ -548,7 +557,7 @@ public class ClientProxy extends CommonProxy { return; TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager(); if (location != null) - texturemanager.bindTexture(location); + texturemanager.bindTexture((ResourceLocation) location); } catch (NullPointerException ex) { } catch (ReportedException ex) { diff --git a/src/main/java/noppes/npcs/client/ClientTickHandler.java b/src/main/java/noppes/npcs/client/ClientTickHandler.java index 394732f8b..46af7df1a 100644 --- a/src/main/java/noppes/npcs/client/ClientTickHandler.java +++ b/src/main/java/noppes/npcs/client/ClientTickHandler.java @@ -39,8 +39,8 @@ public class ClientTickHandler { private int prevWidth = 0; private int prevHeight = 0; private boolean otherContainer = false; - private final int buttonPressed = -1; - private final long buttonTime = 0L; + private int buttonPressed = -1; + private long buttonTime = 0L; private final int[] ignoreKeys = new int[]{157, 29, 54, 42, 184, 56, 220, 219}; @SubscribeEvent(priority = EventPriority.LOWEST) diff --git a/src/main/java/noppes/npcs/client/ImageDownloadAlt.java b/src/main/java/noppes/npcs/client/ImageDownloadAlt.java index a8e857630..c53706b9d 100644 --- a/src/main/java/noppes/npcs/client/ImageDownloadAlt.java +++ b/src/main/java/noppes/npcs/client/ImageDownloadAlt.java @@ -76,7 +76,7 @@ public class ImageDownloadAlt extends SimpleTexture { if (this.imageThread == null) { if (this.cacheFile != null && this.cacheFile.isFile()) { - logger.debug("Loading http texture from local cache ({})", this.cacheFile); + logger.debug("Loading http texture from local cache ({})", new Object[]{this.cacheFile}); try { this.bufferedImage = ImageIO.read(this.cacheFile); @@ -85,7 +85,7 @@ public class ImageDownloadAlt extends SimpleTexture { this.setBufferedImage(this.imageBuffer.parseUserSkin(this.bufferedImage)); } } catch (IOException ioexception) { - logger.error("Couldn't load skin " + this.cacheFile, ioexception); + logger.error("Couldn\'t load skin " + this.cacheFile, ioexception); this.loadTextureFromServer(); } } else { @@ -98,7 +98,7 @@ public class ImageDownloadAlt extends SimpleTexture { this.imageThread = new Thread("Texture Downloader #" + threadDownloadCounter.incrementAndGet()) { public void run() { HttpURLConnection connection = null; - ImageDownloadAlt.logger.debug("Downloading http texture from {} to {}", ImageDownloadAlt.this.imageUrl, ImageDownloadAlt.this.cacheFile); + ImageDownloadAlt.logger.debug("Downloading http texture from {} to {}", new Object[]{ImageDownloadAlt.this.imageUrl, ImageDownloadAlt.this.cacheFile}); try { URL url = new URL(ImageDownloadAlt.this.imageUrl); @@ -137,7 +137,7 @@ public class ImageDownloadAlt extends SimpleTexture { ImageDownloadAlt.this.setBufferedImage(bufferedimage); } catch (MalformedURLException ignored) { } catch (Exception exception) { - ImageDownloadAlt.logger.error("Couldn't download http texture", exception); + ImageDownloadAlt.logger.error("Couldn\'t download http texture", exception); } finally { if (connection != null) { connection.disconnect(); diff --git a/src/main/java/noppes/npcs/client/MessageAchievement.java b/src/main/java/noppes/npcs/client/MessageAchievement.java index 33f64f370..1b4f1a848 100644 --- a/src/main/java/noppes/npcs/client/MessageAchievement.java +++ b/src/main/java/noppes/npcs/client/MessageAchievement.java @@ -9,8 +9,8 @@ import noppes.npcs.CustomItems; public class MessageAchievement extends Achievement { - private final String description; - private final String message; + private String description; + private String message; public MessageAchievement(Item item, String message, String description) { super("", message, 0, 0, item, null); diff --git a/src/main/java/noppes/npcs/client/NoppesUtil.java b/src/main/java/noppes/npcs/client/NoppesUtil.java index 440a4a83a..ede0e0df9 100644 --- a/src/main/java/noppes/npcs/client/NoppesUtil.java +++ b/src/main/java/noppes/npcs/client/NoppesUtil.java @@ -17,10 +17,13 @@ import net.minecraft.util.Util; import noppes.npcs.CustomNpcs; import noppes.npcs.client.gui.player.GuiDialogInteract; import noppes.npcs.client.gui.player.GuiQuestCompletion; +import noppes.npcs.client.gui.player.modern.GuiModernDialogInteract; +import noppes.npcs.client.gui.player.modern.GuiModernQuestDialog; import noppes.npcs.client.gui.util.GuiContainerNPCInterface; import noppes.npcs.client.gui.util.GuiNPCInterface; import noppes.npcs.client.gui.util.IPlayerDataInfo; import noppes.npcs.client.gui.util.IScrollData; +import noppes.npcs.config.ConfigExperimental; import noppes.npcs.constants.EnumGuiType; import noppes.npcs.constants.EnumScrollData; import noppes.npcs.controllers.data.Dialog; @@ -101,7 +104,7 @@ public class NoppesUtil { //logger.error("Couldn\'t open file", ioexception1); } } else if (Util.getOSType() == Util.EnumOS.WINDOWS) { - String s1 = String.format("cmd.exe /C start \"Open file\" \"%s\"", s); + String s1 = String.format("cmd.exe /C start \"Open file\" \"%s\"", new Object[]{s}); try { Runtime.getRuntime().exec(s1); @@ -115,8 +118,8 @@ public class NoppesUtil { try { Class oclass = Class.forName("java.awt.Desktop"); - Object object = oclass.getMethod("getDesktop", new Class[0]).invoke(null); - oclass.getMethod("browse", new Class[]{URI.class}).invoke(object, dir.toURI()); + Object object = oclass.getMethod("getDesktop", new Class[0]).invoke((Object) null, new Object[0]); + oclass.getMethod("browse", new Class[]{URI.class}).invoke(object, new Object[]{dir.toURI()}); } catch (Throwable throwable) { //logger.error("Couldn\'t open link", throwable); flag = true; @@ -169,10 +172,10 @@ public class NoppesUtil { } catch (Exception e) { } if (gui instanceof GuiNPCInterface && ((GuiNPCInterface) gui).hasSubGui()) { - gui = ((GuiNPCInterface) gui).getSubGui(); + gui = (GuiScreen) ((GuiNPCInterface) gui).getSubGui(); } if (gui instanceof GuiContainerNPCInterface && ((GuiContainerNPCInterface) gui).hasSubGui()) { - gui = ((GuiContainerNPCInterface) gui).getSubGui(); + gui = (GuiScreen) ((GuiContainerNPCInterface) gui).getSubGui(); } if (gui instanceof IScrollData) ((IScrollData) gui).setData(new Vector(data.keySet()), data, dataType); @@ -191,8 +194,17 @@ public class NoppesUtil { Dialog dialog = new Dialog(); dialog.readNBT(compound); GuiScreen gui = Minecraft.getMinecraft().currentScreen; - if (gui == null || !(gui instanceof GuiDialogInteract)) - CustomNpcs.proxy.openGui(player, new GuiDialogInteract(npc, dialog)); + if(!(gui instanceof GuiDialogInteract)) { + if (ConfigExperimental.ModernGuiSystem) { + if (dialog.hasQuest()) { + CustomNpcs.proxy.openGui(player, new GuiModernQuestDialog(npc, dialog.getQuest(), dialog, -2)); + } else { + CustomNpcs.proxy.openGui(player, new GuiModernDialogInteract(npc, dialog)); + } + } else { + CustomNpcs.proxy.openGui(player, new GuiDialogInteract(npc, dialog)); + } + } else { GuiDialogInteract dia = (GuiDialogInteract) gui; dia.appendDialog(dialog); @@ -255,11 +267,11 @@ public class NoppesUtil { if (gui == null) return; if (gui instanceof GuiNPCInterface && ((GuiNPCInterface) gui).hasSubGui()) { - gui = ((GuiNPCInterface) gui).getSubGui(); + gui = (GuiScreen) ((GuiNPCInterface) gui).getSubGui(); } if (gui instanceof GuiContainerNPCInterface && ((GuiContainerNPCInterface) gui).hasSubGui()) { - gui = ((GuiContainerNPCInterface) gui).getSubGui(); + gui = (GuiScreen) ((GuiContainerNPCInterface) gui).getSubGui(); } if (gui instanceof IPlayerDataInfo) { IPlayerDataInfo info = (IPlayerDataInfo) gui; diff --git a/src/main/java/noppes/npcs/client/RenderChatMessages.java b/src/main/java/noppes/npcs/client/RenderChatMessages.java index 911714c34..b1ac5f0dc 100644 --- a/src/main/java/noppes/npcs/client/RenderChatMessages.java +++ b/src/main/java/noppes/npcs/client/RenderChatMessages.java @@ -18,8 +18,8 @@ import java.util.TreeMap; public class RenderChatMessages implements IChatMessages { private Map messages = new TreeMap(); - private final int boxLength = 46; - private final float scale = 0.5f; + private int boxLength = 46; + private float scale = 0.5f; private String lastMessage = ""; private long lastMessageTime = 0; @@ -33,7 +33,7 @@ public class RenderChatMessages implements IChatMessages { return; } Map messages = new TreeMap(this.messages); - messages.put(time, new TextBlockClient(message, boxLength * 4, true, Minecraft.getMinecraft().thePlayer, npc)); + messages.put(time, new TextBlockClient(message, (int) (boxLength * 4), true, Minecraft.getMinecraft().thePlayer, npc)); if (messages.size() > 3) { messages.remove(messages.keySet().iterator().next()); @@ -166,10 +166,10 @@ public class RenderChatMessages implements IChatMessages { Tessellator tessellator = Tessellator.instance; GL11.glColor4f(f1, f2, f3, f); tessellator.startDrawingQuads(); - tessellator.addVertex(par0, par3, par5); - tessellator.addVertex(par2, par3, par5); - tessellator.addVertex(par2, par1, par5); - tessellator.addVertex(par0, par1, par5); + tessellator.addVertex((double) par0, (double) par3, par5); + tessellator.addVertex((double) par2, (double) par3, par5); + tessellator.addVertex((double) par2, (double) par1, par5); + tessellator.addVertex((double) par0, (double) par1, par5); tessellator.draw(); } diff --git a/src/main/java/noppes/npcs/client/TextBlockClient.java b/src/main/java/noppes/npcs/client/TextBlockClient.java index b7f1c4a7b..05c4e8126 100644 --- a/src/main/java/noppes/npcs/client/TextBlockClient.java +++ b/src/main/java/noppes/npcs/client/TextBlockClient.java @@ -10,7 +10,7 @@ import noppes.npcs.TextBlock; import noppes.npcs.controllers.data.Dialog; public class TextBlockClient extends TextBlock { - private final ChatStyle style; + private ChatStyle style; public int color = 0xe0e0e0; public int titleColor = 0xe0e0e0; public int titlePos = 0; diff --git a/src/main/java/noppes/npcs/client/TranslateUtil.java b/src/main/java/noppes/npcs/client/TranslateUtil.java index 043061289..1383fe39d 100644 --- a/src/main/java/noppes/npcs/client/TranslateUtil.java +++ b/src/main/java/noppes/npcs/client/TranslateUtil.java @@ -12,7 +12,6 @@ import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.URL; import java.net.URLEncoder; -import java.nio.charset.StandardCharsets; public class TranslateUtil { private static final String TranslateUrl = "http://translate.google.com/translate_a/t?client=t&text=%s&hl=en&sl=%s&tl=%s&ie=UTF-8&oe=UTF-8&multires=1&otf=1&pc=1&trs=1&ssel=3&tsel=6&sc=1"; @@ -21,7 +20,7 @@ public class TranslateUtil { public static String Translate(String text) { try { - String urlStr = String.format(TranslateUrl, URLEncoder.encode(text, StandardCharsets.UTF_8.name()), "auto", "nl"); + String urlStr = String.format(TranslateUrl, URLEncoder.encode(text, "utf8"), "auto", "nl"); URL url = new URL(urlStr); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); diff --git a/src/main/java/noppes/npcs/client/VersionChecker.java b/src/main/java/noppes/npcs/client/VersionChecker.java index 65aad9799..6164f336d 100644 --- a/src/main/java/noppes/npcs/client/VersionChecker.java +++ b/src/main/java/noppes/npcs/client/VersionChecker.java @@ -7,7 +7,7 @@ import net.minecraft.event.ClickEvent.Action; import net.minecraft.util.ChatComponentTranslation; public class VersionChecker extends Thread { - private final int revision = 15; + private int revision = 15; public VersionChecker() { diff --git a/src/main/java/noppes/npcs/client/controllers/PresetController.java b/src/main/java/noppes/npcs/client/controllers/PresetController.java index ebb3388e2..2e9d8605e 100644 --- a/src/main/java/noppes/npcs/client/controllers/PresetController.java +++ b/src/main/java/noppes/npcs/client/controllers/PresetController.java @@ -14,7 +14,7 @@ public class PresetController { public HashMap presets = new HashMap(); - private final File dir; + private File dir; public static PresetController instance; public PresetController(File dir) { diff --git a/src/main/java/noppes/npcs/client/fx/EntityRainbowFX.java b/src/main/java/noppes/npcs/client/fx/EntityRainbowFX.java index a159ce383..4da90572f 100644 --- a/src/main/java/noppes/npcs/client/fx/EntityRainbowFX.java +++ b/src/main/java/noppes/npcs/client/fx/EntityRainbowFX.java @@ -7,7 +7,7 @@ import net.minecraft.world.World; public class EntityRainbowFX extends EntityFX { - public static float[][] colorTable = { + public static float colorTable[][] = { { 1.0F, 0, 0 }, diff --git a/src/main/java/noppes/npcs/client/gui/GuiBorderBlock.java b/src/main/java/noppes/npcs/client/gui/GuiBorderBlock.java index baa87eaa2..cf5549c70 100644 --- a/src/main/java/noppes/npcs/client/gui/GuiBorderBlock.java +++ b/src/main/java/noppes/npcs/client/gui/GuiBorderBlock.java @@ -10,7 +10,7 @@ import noppes.npcs.client.gui.util.*; public class GuiBorderBlock extends GuiNPCInterface implements IGuiData { - private final TileBorder tile; + private TileBorder tile; public GuiBorderBlock(int x, int y, int z) { super(); diff --git a/src/main/java/noppes/npcs/client/gui/GuiMagicCycleMap.java b/src/main/java/noppes/npcs/client/gui/GuiMagicCycleMap.java index 48edc0014..7a7c6a929 100644 --- a/src/main/java/noppes/npcs/client/gui/GuiMagicCycleMap.java +++ b/src/main/java/noppes/npcs/client/gui/GuiMagicCycleMap.java @@ -23,8 +23,8 @@ import java.util.Map; public class GuiMagicCycleMap extends GuiDiagram { - private final List cycleMagics; - private final MagicCycle cycle; + private List cycleMagics; + private MagicCycle cycle; /** * Constructor using a MagicCycle object. @@ -36,7 +36,8 @@ public class GuiMagicCycleMap extends GuiDiagram { // If cycle is null, leave cycleMagics empty. if (this.cycle == null) { setLayout(EnumDiagramLayout.CIRCULAR_MANUAL); - setCurvedArrows(false); + setCurvedArrows(true); + setCurveAngle(-20); invalidateCache(); return; } @@ -54,9 +55,10 @@ public class GuiMagicCycleMap extends GuiDiagram { // Use the cycle's layout if set; otherwise default to CIRCULAR_MANUAL. setLayout(cycle.layout != null ? cycle.layout : EnumDiagramLayout.CIRCULAR_MANUAL); setCurvedArrows(true); - setCurveAngle(30); + setCurveAngle(-25); invalidateCache(); + this.allowTwoWay = true; this.iconSize = 20; this.slotSize = iconSize + slotPadding; } @@ -108,7 +110,10 @@ public class GuiMagicCycleMap extends GuiDiagram { int targetId = entry.getKey(); if (!orderMap.containsKey(targetId)) continue; float percent = entry.getValue(); - String hover = "+" + (int) (percent * 100) + "%"; + String modifier = ""; + if(percent > 0.0) + modifier += "+"; + String hover = modifier + (int) (percent * 100) + "%"; conns.add(new DiagramConnection(m.id, targetId, percent, hover)); } } @@ -169,7 +174,7 @@ public class GuiMagicCycleMap extends GuiDiagram { protected List getIconTooltip(DiagramIcon icon) { Magic magic = ((MagicIcon) icon).magic; List tooltip = new ArrayList<>(); - tooltip.add(magic.getDisplayName().replace("&", "\u00A7")); + tooltip.add(magic.getDisplayName()); return tooltip; } diff --git a/src/main/java/noppes/npcs/client/gui/GuiMerchantAdd.java b/src/main/java/noppes/npcs/client/gui/GuiMerchantAdd.java index 0d6e43c02..1d1cfa1ad 100644 --- a/src/main/java/noppes/npcs/client/gui/GuiMerchantAdd.java +++ b/src/main/java/noppes/npcs/client/gui/GuiMerchantAdd.java @@ -31,11 +31,11 @@ public class GuiMerchantAdd extends GuiContainer { /** * Instance of IMerchant interface. */ - private final IMerchant theIMerchant; + private IMerchant theIMerchant; private MerchantButton nextRecipeButtonIndex; private MerchantButton previousRecipeButtonIndex; private int currentRecipeIndex; - private final String field_94082_v; + private String field_94082_v; public GuiMerchantAdd() { super(new ContainerMerchantAdd(Minecraft.getMinecraft().thePlayer, ServerEventsHandler.Merchant, Minecraft.getMinecraft().theWorld)); diff --git a/src/main/java/noppes/npcs/client/gui/GuiNPCFactionSelection.java b/src/main/java/noppes/npcs/client/gui/GuiNPCFactionSelection.java index a8afe6361..45b402e72 100644 --- a/src/main/java/noppes/npcs/client/gui/GuiNPCFactionSelection.java +++ b/src/main/java/noppes/npcs/client/gui/GuiNPCFactionSelection.java @@ -15,7 +15,7 @@ import java.util.Vector; public class GuiNPCFactionSelection extends GuiNPCInterface implements IScrollData { private GuiNPCStringSlot slot; - private final GuiScreen parent; + private GuiScreen parent; private HashMap data = new HashMap(); private int factionId; public GuiSelectionListener listener; diff --git a/src/main/java/noppes/npcs/client/gui/GuiNPCLinesEdit.java b/src/main/java/noppes/npcs/client/gui/GuiNPCLinesEdit.java index 321ae1ced..e140434a0 100644 --- a/src/main/java/noppes/npcs/client/gui/GuiNPCLinesEdit.java +++ b/src/main/java/noppes/npcs/client/gui/GuiNPCLinesEdit.java @@ -14,7 +14,7 @@ import noppes.npcs.entity.EntityNPCInterface; import java.util.HashMap; public class GuiNPCLinesEdit extends GuiNPCInterface2 implements IGuiData, ISubGuiListener, ITextfieldListener { - private final Lines lines; + private Lines lines; private int selectedId = -1; private GuiSoundSelection gui; diff --git a/src/main/java/noppes/npcs/client/gui/GuiNPCTransportCategoryEdit.java b/src/main/java/noppes/npcs/client/gui/GuiNPCTransportCategoryEdit.java index fb380eee6..aac0f10fe 100644 --- a/src/main/java/noppes/npcs/client/gui/GuiNPCTransportCategoryEdit.java +++ b/src/main/java/noppes/npcs/client/gui/GuiNPCTransportCategoryEdit.java @@ -13,9 +13,9 @@ import noppes.npcs.client.gui.util.GuiNpcTextField; import noppes.npcs.entity.EntityNPCInterface; public class GuiNPCTransportCategoryEdit extends GuiNPCInterface { - private final GuiScreen parent; - private final String name; - private final int id; + private GuiScreen parent; + private String name; + private int id; public GuiNPCTransportCategoryEdit(EntityNPCInterface npc, GuiScreen parent, String name, int id) { super(npc); diff --git a/src/main/java/noppes/npcs/client/gui/GuiNpcMobSpawner.java b/src/main/java/noppes/npcs/client/gui/GuiNpcMobSpawner.java index d52cd2f15..8c07cb55a 100644 --- a/src/main/java/noppes/npcs/client/gui/GuiNpcMobSpawner.java +++ b/src/main/java/noppes/npcs/client/gui/GuiNpcMobSpawner.java @@ -39,9 +39,7 @@ public class GuiNpcMobSpawner extends GuiNPCInterface implements IGuiData { private final GuiCustomScrollCloner scroll = new GuiCustomScrollCloner(this, 0); private final GuiCustomScroll filterScroll = new GuiCustomScroll(this, 1); - private final int posX; - private final int posY; - private final int posZ; + private int posX, posY, posZ; private List list; private List rawList; @@ -177,7 +175,7 @@ public class GuiNpcMobSpawner extends GuiNPCInterface implements IGuiData { for (Object name : data.keySet()) { Class c = (Class) data.get(name); try { - if (EntityLiving.class.isAssignableFrom(c) && c.getConstructor(World.class) != null && !Modifier.isAbstract(c.getModifiers())) + if (EntityLiving.class.isAssignableFrom(c) && c.getConstructor(new Class[]{World.class}) != null && !Modifier.isAbstract(c.getModifiers())) list.add(name.toString()); } catch (SecurityException e) { e.printStackTrace(); diff --git a/src/main/java/noppes/npcs/client/gui/GuiNpcMobSpawnerAdd.java b/src/main/java/noppes/npcs/client/gui/GuiNpcMobSpawnerAdd.java index 9445f6797..3dc90d15f 100644 --- a/src/main/java/noppes/npcs/client/gui/GuiNpcMobSpawnerAdd.java +++ b/src/main/java/noppes/npcs/client/gui/GuiNpcMobSpawnerAdd.java @@ -25,8 +25,8 @@ import java.util.UUID; public class GuiNpcMobSpawnerAdd extends GuiNPCInterface implements GuiYesNoCallback, IGuiData, ISubGuiListener { - private final Entity toClone; - private final NBTTagCompound compound; + private Entity toClone; + private NBTTagCompound compound; private static boolean serverSide = false; private static int tab = 1; public boolean isNPC = false; diff --git a/src/main/java/noppes/npcs/client/gui/GuiNpcMobSpawnerMounter.java b/src/main/java/noppes/npcs/client/gui/GuiNpcMobSpawnerMounter.java index c45ae20e2..6b7ef382a 100644 --- a/src/main/java/noppes/npcs/client/gui/GuiNpcMobSpawnerMounter.java +++ b/src/main/java/noppes/npcs/client/gui/GuiNpcMobSpawnerMounter.java @@ -24,9 +24,7 @@ public class GuiNpcMobSpawnerMounter extends GuiNPCInterface implements IGuiData private GuiCustomScroll scroll; - private final int posX; - private final int posY; - private final int posZ; + private int posX, posY, posZ; private List list; @@ -105,7 +103,7 @@ public class GuiNpcMobSpawnerMounter extends GuiNPCInterface implements IGuiData for (Object name : data.keySet()) { Class c = (Class) data.get(name); try { - if (EntityLiving.class.isAssignableFrom(c) && c.getConstructor(World.class) != null && !Modifier.isAbstract(c.getModifiers())) + if (EntityLiving.class.isAssignableFrom(c) && c.getConstructor(new Class[]{World.class}) != null && !Modifier.isAbstract(c.getModifiers())) list.add(name.toString()); } catch (SecurityException e) { e.printStackTrace(); @@ -174,7 +172,7 @@ public class GuiNpcMobSpawnerMounter extends GuiNPCInterface implements IGuiData if (id == 1) { NBTTagCompound compound = getCompound(); if (compound != null) { - compound.setTag("Pos", this.newDoubleNBTList(this.posX + 0.5, this.posY + 1, this.posZ + 0.5)); + compound.setTag("Pos", this.newDoubleNBTList(new double[]{this.posX + 0.5, this.posY + 1, this.posZ + 0.5})); MountPacket.Spawn(compound); close(); } diff --git a/src/main/java/noppes/npcs/client/gui/GuiNpcRedstoneBlock.java b/src/main/java/noppes/npcs/client/gui/GuiNpcRedstoneBlock.java index ec3e34a51..1f4abf0c7 100644 --- a/src/main/java/noppes/npcs/client/gui/GuiNpcRedstoneBlock.java +++ b/src/main/java/noppes/npcs/client/gui/GuiNpcRedstoneBlock.java @@ -14,7 +14,7 @@ import noppes.npcs.client.gui.util.GuiNpcTextField; public class GuiNpcRedstoneBlock extends GuiNPCInterface { - private final TileRedstoneBlock tile; + private TileRedstoneBlock tile; public GuiNpcRedstoneBlock(int x, int y, int z) { super(); diff --git a/src/main/java/noppes/npcs/client/gui/GuiNpcSelectionInterface.java b/src/main/java/noppes/npcs/client/gui/GuiNpcSelectionInterface.java index 1e472f52d..aeb2346be 100644 --- a/src/main/java/noppes/npcs/client/gui/GuiNpcSelectionInterface.java +++ b/src/main/java/noppes/npcs/client/gui/GuiNpcSelectionInterface.java @@ -16,11 +16,11 @@ public abstract class GuiNpcSelectionInterface extends GuiNPCInterface { public GuiNPCStringSlot slot; public GuiScreen parent; - private final String up = "..<" + StatCollector.translateToLocal("gui.up") + ">.."; + private String up = "..<" + StatCollector.translateToLocal("gui.up") + ">.."; private String root = ""; public AssetsBrowser assets; - private final HashSet dataFolder = new HashSet(); + private HashSet dataFolder = new HashSet(); protected HashSet dataTextures = new HashSet(); public GuiNpcSelectionInterface(EntityNPCInterface npc, GuiScreen parent, String sound) { diff --git a/src/main/java/noppes/npcs/client/gui/GuiNpcWaypoint.java b/src/main/java/noppes/npcs/client/gui/GuiNpcWaypoint.java index 12f7308a6..f73f6de6b 100644 --- a/src/main/java/noppes/npcs/client/gui/GuiNpcWaypoint.java +++ b/src/main/java/noppes/npcs/client/gui/GuiNpcWaypoint.java @@ -13,7 +13,7 @@ import noppes.npcs.client.gui.util.GuiNpcTextField; public class GuiNpcWaypoint extends GuiNPCInterface { - private final TileWaypoint tile; + private TileWaypoint tile; public GuiNpcWaypoint(int x, int y, int z) { super(); diff --git a/src/main/java/noppes/npcs/client/gui/GuiScript.java b/src/main/java/noppes/npcs/client/gui/GuiScript.java index 7a89a00bf..761354dd3 100644 --- a/src/main/java/noppes/npcs/client/gui/GuiScript.java +++ b/src/main/java/noppes/npcs/client/gui/GuiScript.java @@ -140,7 +140,7 @@ public class GuiScript extends GuiNPCInterface implements IGuiData, GuiYesNoCall while (var3.hasNext()) { Map.Entry entry = (Map.Entry) var3.next(); - builder.insert(0, new Date(entry.getKey()) + entry.getValue() + "\n"); + builder.insert(0, new Date((Long) entry.getKey()) + (String) entry.getValue() + "\n"); } return builder.toString(); @@ -210,7 +210,7 @@ public class GuiScript extends GuiNPCInterface implements IGuiData, GuiYesNoCall displayGuiScreen(guiyesno); } if (guibutton.id == 103) { - script.scriptLanguage = guibutton.displayString; + script.scriptLanguage = ((GuiNpcButton) guibutton).displayString; } if (guibutton.id == 104) { script.enabled = ((GuiNpcButton) guibutton).getValue() == 1; diff --git a/src/main/java/noppes/npcs/client/gui/GuiScriptList.java b/src/main/java/noppes/npcs/client/gui/GuiScriptList.java index edf19c546..0d03d13cd 100644 --- a/src/main/java/noppes/npcs/client/gui/GuiScriptList.java +++ b/src/main/java/noppes/npcs/client/gui/GuiScriptList.java @@ -13,8 +13,8 @@ import java.util.List; public class GuiScriptList extends SubGuiInterface { private GuiCustomScroll scroll1; private GuiCustomScroll scroll2; - private final ScriptContainer container; - private final List scripts; + private ScriptContainer container; + private List scripts; public GuiScriptList(List scripts, ScriptContainer container) { this.container = container; diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiClonerQuickTags.java b/src/main/java/noppes/npcs/client/gui/SubGuiClonerQuickTags.java index d1e59966a..996259b25 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiClonerQuickTags.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiClonerQuickTags.java @@ -56,7 +56,7 @@ public class SubGuiClonerQuickTags extends SubGuiInterface implements IScrollDat protected void actionPerformed(GuiButton guibutton) { if (guibutton.id == 10) { - GuiNpcMobSpawnerAdd.addTags = new HashSet<>(GuiNpcMobSpawnerAdd.allTags); + GuiNpcMobSpawnerAdd.addTags = new HashSet<>(parent.allTags); quickScroll.setSelectedList(GuiNpcMobSpawnerAdd.addTags); refreshSelected(); } @@ -98,10 +98,10 @@ public class SubGuiClonerQuickTags extends SubGuiInterface implements IScrollDat private List getQuickTags() { if (quickSearch.isEmpty()) { - return new ArrayList(GuiNpcMobSpawnerAdd.allTags); + return new ArrayList(parent.allTags); } List list = new ArrayList(); - for (String name : GuiNpcMobSpawnerAdd.allTags) { + for (String name : this.parent.allTags) { if (name.toLowerCase().contains(quickSearch)) list.add(name); } diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiMagic.java b/src/main/java/noppes/npcs/client/gui/SubGuiMagic.java index 31d4ec539..c60f851a4 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiMagic.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiMagic.java @@ -18,14 +18,14 @@ public class SubGuiMagic extends SubGuiInterface implements ITextfieldListener, public GuiNpcManageMagic parent; private GuiCustomScroll allMagic; private GuiCustomScroll interactionsScroll; - private final Magic magic; + private Magic magic; private String search = ""; private GuiNpcTextField interactionField; private String selectedInteraction; - private final HashMap interactionNames = new HashMap<>(); - private final HashMap interactionValues = new HashMap<>(); + private HashMap interactionNames = new HashMap<>(); + private HashMap interactionValues = new HashMap<>(); public SubGuiMagic(GuiNpcManageMagic parent, Magic magic) { this.magic = magic; @@ -165,14 +165,14 @@ public class SubGuiMagic extends SubGuiInterface implements ITextfieldListener, guiNpcTextField.setText(""); else { String name = guiNpcTextField.getText(); - if (name.isEmpty() || this.parent.magicData.containsKey(name)) { + if (name.isEmpty() || ((GuiNpcManageMagic) this.parent).magicData.containsKey(name)) { guiNpcTextField.setText(magic.name); } else if (magic.id >= 0) { String old = magic.name; - this.parent.magicData.remove(old); + ((GuiNpcManageMagic) this.parent).magicData.remove(old); magic.name = name; - this.parent.magicData.put(magic.name, magic.id); - this.parent.rightScroll.replace(old, magic.name); + ((GuiNpcManageMagic) this.parent).magicData.put(magic.name, magic.id); + ((GuiNpcManageMagic) this.parent).rightScroll.replace(old, magic.name); } } } diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiMagicCycle.java b/src/main/java/noppes/npcs/client/gui/SubGuiMagicCycle.java index 11b20f06a..1ffbd9b07 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiMagicCycle.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiMagicCycle.java @@ -24,7 +24,7 @@ public class SubGuiMagicCycle extends SubGuiInterface implements ITextfieldListe private GuiCustomScroll associationScroll; // The MagicCycle we are editing - private final MagicCycle cycle; + private MagicCycle cycle; // Search string for available magics private String search = ""; @@ -39,7 +39,7 @@ public class SubGuiMagicCycle extends SubGuiInterface implements ITextfieldListe // The currently selected associated magic (by its name) private String selectedAssociation; // A mapping of magic names (from parent.magicData) to their MagicAssociation objects. - private final HashMap associationMap = new HashMap<>(); + private HashMap associationMap = new HashMap<>(); public SubGuiMagicCycle(GuiNpcManageMagic parent, MagicCycle cycle) { this.parent = parent; @@ -76,13 +76,22 @@ public class SubGuiMagicCycle extends SubGuiInterface implements ITextfieldListe y += 27; - // Labels and text fields for editing the selected association's ordering data. - addLabel(new GuiNpcLabel(50, "magic.index", guiLeft + 5, y + 5)); + String index = "gui.unused"; + String priority = "gui.unused"; + if(cycle.layout == EnumDiagramLayout.MANUAL) { + index = "X"; + priority = "Y"; + } else if(cycle.layout.isManual()) { + index = "magic.index"; + priority = "magic.priority"; + } + + addLabel(new GuiNpcLabel(50, index, guiLeft + 5, y + 5)); indexField = new GuiNpcTextField(91, this, fontRendererObj, guiLeft + 100, y, 45, 20, ""); indexField.setIntegersOnly(); addTextField(indexField); - addLabel(new GuiNpcLabel(51, "magic.priority", guiLeft + 150, y + 5)); + addLabel(new GuiNpcLabel(51, priority, guiLeft + 150, y + 5)); priorityField = new GuiNpcTextField(92, this, fontRendererObj, guiLeft + 250, y, 45, 20, ""); priorityField.setIntegersOnly(); addTextField(priorityField); @@ -90,6 +99,13 @@ public class SubGuiMagicCycle extends SubGuiInterface implements ITextfieldListe indexField.enabled = false; priorityField.enabled = false; + if (selectedAssociation != null && associationMap.containsKey(selectedAssociation)) { + indexField.enabled = true; + priorityField.enabled = true; + indexField.setText(associationMap.get(selectedAssociation).index + ""); + priorityField.setText(associationMap.get(selectedAssociation).priority + ""); + } + y += 27; // --- Association Management --- @@ -133,6 +149,7 @@ public class SubGuiMagicCycle extends SubGuiInterface implements ITextfieldListe // Layout button: update cycle layout. if (button.id == 13) { cycle.layout = EnumDiagramLayout.values()[((GuiNpcButton) button).getValue()]; + initGui(); } // Add single association if (button.id == 60 && allMagic.hasSelected() && !associationMap.containsKey(allMagic.getSelected()) diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiMailmanSendSetup.java b/src/main/java/noppes/npcs/client/gui/SubGuiMailmanSendSetup.java index fe7f9d393..849f0edad 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiMailmanSendSetup.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiMailmanSendSetup.java @@ -13,7 +13,7 @@ import noppes.npcs.controllers.data.PlayerMail; public class SubGuiMailmanSendSetup extends SubGuiInterface implements ITextfieldListener, GuiSelectionListener { - private final PlayerMail mail; + private PlayerMail mail; public SubGuiMailmanSendSetup(PlayerMail mail, GuiScreen parent) { this.parent = parent; diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiNpcAvailability.java b/src/main/java/noppes/npcs/client/gui/SubGuiNpcAvailability.java index 3f0bd566c..2d3cf7edf 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiNpcAvailability.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiNpcAvailability.java @@ -11,7 +11,7 @@ import noppes.npcs.controllers.data.Availability; import noppes.npcs.controllers.data.Faction; public class SubGuiNpcAvailability extends SubGuiInterface implements ITextfieldListener, GuiSelectionListener, IGuiData { - private final Availability availabitily; + private Availability availabitily; private int slot = 0; public SubGuiNpcAvailability(Availability availabitily) { diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiNpcAvailabilityDialog.java b/src/main/java/noppes/npcs/client/gui/SubGuiNpcAvailabilityDialog.java index 2bf5cf854..cee94a3f5 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiNpcAvailabilityDialog.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiNpcAvailabilityDialog.java @@ -10,7 +10,7 @@ import noppes.npcs.controllers.data.Availability; import noppes.npcs.controllers.data.Dialog; public class SubGuiNpcAvailabilityDialog extends SubGuiInterface implements GuiSelectionListener, IGuiData { - private final Availability availabitily; + private Availability availabitily; private int slot = 0; public SubGuiNpcAvailabilityDialog(Availability availabitily) { diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiNpcAvailabilityQuest.java b/src/main/java/noppes/npcs/client/gui/SubGuiNpcAvailabilityQuest.java index a0d49f2cf..f4098c445 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiNpcAvailabilityQuest.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiNpcAvailabilityQuest.java @@ -10,7 +10,7 @@ import noppes.npcs.controllers.data.Availability; import noppes.npcs.controllers.data.Quest; public class SubGuiNpcAvailabilityQuest extends SubGuiInterface implements GuiSelectionListener, IGuiData { - private final Availability availabitily; + private Availability availabitily; private int slot = 0; public SubGuiNpcAvailabilityQuest(Availability availabitily) { diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiNpcBiomes.java b/src/main/java/noppes/npcs/client/gui/SubGuiNpcBiomes.java index 36ae663e6..76b5d8150 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiNpcBiomes.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiNpcBiomes.java @@ -12,7 +12,7 @@ import java.util.ArrayList; import java.util.List; public class SubGuiNpcBiomes extends SubGuiInterface { - private final SpawnData data; + private SpawnData data; private GuiCustomScroll scroll1; private GuiCustomScroll scroll2; diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiNpcDialogOption.java b/src/main/java/noppes/npcs/client/gui/SubGuiNpcDialogOption.java index 6f74df668..6a7accc98 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiNpcDialogOption.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiNpcDialogOption.java @@ -10,7 +10,7 @@ import noppes.npcs.controllers.data.Dialog; import noppes.npcs.controllers.data.DialogOption; public class SubGuiNpcDialogOption extends SubGuiInterface implements IGuiData, ITextfieldListener, GuiSelectionListener, ISubGuiListener { - private final DialogOption option; + private DialogOption option; public static int LastColor = 0xe0e0e0; public SubGuiNpcDialogOption(DialogOption option) { diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiNpcDialogOptions.java b/src/main/java/noppes/npcs/client/gui/SubGuiNpcDialogOptions.java index aa90cb81a..242a2ba22 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiNpcDialogOptions.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiNpcDialogOptions.java @@ -9,7 +9,7 @@ import noppes.npcs.controllers.data.Dialog; import noppes.npcs.controllers.data.DialogOption; public class SubGuiNpcDialogOptions extends SubGuiInterface { - private final Dialog dialog; + private Dialog dialog; public SubGuiNpcDialogOptions(Dialog dialog) { this.dialog = dialog; diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiNpcDialogVisual.java b/src/main/java/noppes/npcs/client/gui/SubGuiNpcDialogVisual.java index 81892873c..4e32baa4f 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiNpcDialogVisual.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiNpcDialogVisual.java @@ -8,6 +8,7 @@ import noppes.npcs.client.NoppesUtil; import noppes.npcs.client.gui.util.*; import noppes.npcs.config.ConfigMain; import noppes.npcs.controllers.data.Dialog; +import noppes.npcs.controllers.data.DialogColorData; import noppes.npcs.controllers.data.DialogImage; import java.util.ArrayList; @@ -40,7 +41,9 @@ public class SubGuiNpcDialogVisual extends SubGuiInterface implements ISubGuiLis GuiMenuTopButton general = new GuiMenuTopButton(1, guiLeft + 4, guiTop - 17, "General"); GuiMenuTopButton spacing = new GuiMenuTopButton(2, general.xPosition + general.getWidth(), guiTop - 17, "Spacing"); GuiMenuTopButton images = new GuiMenuTopButton(3, spacing.xPosition + spacing.getWidth(), guiTop - 17, "Images"); - topButtons = new GuiMenuTopButton[]{general, images, spacing, close}; + GuiMenuTopButton colours = new GuiMenuTopButton(5, images.xPosition + images.getWidth(), guiTop - 17, "Colors"); + + topButtons = new GuiMenuTopButton[]{general,images,spacing,close,colours}; for (GuiMenuTopButton button : topButtons) { button.active = button.id == activeMenu; addButton(button); @@ -241,6 +244,53 @@ public class SubGuiNpcDialogVisual extends SubGuiInterface implements ISubGuiLis getLabel(21).enabled = dialogImage.imageType == 0; } } + else if (activeMenu == 5) { + addButton(new GuiNpcButtonYesNo(10, guiLeft + 180, y += 22, 60, 20, dialog.colorData.getEnableColorSettings())); + addLabel(new GuiNpcLabel(10, "dialog.enableColorSettings", guiLeft + 4, y + 5)); + if (dialog.colorData.getEnableColorSettings()) { + String color = Integer.toHexString(dialog.colorData.getLineColor1()); + while (color.length() < 6) + color = 0 + color; + addButton(new GuiNpcButton(11, guiLeft + 180, y += 25, 60, 20, color)); + addLabel(new GuiNpcLabel(11, "gui.lineColor1", guiLeft + 4, y + 5)); + getButton(11).setTextColor(dialog.colorData.getLineColor1()); + + color = Integer.toHexString(dialog.colorData.getLineColor2()); + while (color.length() < 6) + color = 0 + color; + addButton(new GuiNpcButton(12, guiLeft + 180, y += 25, 60, 20, color)); + addLabel(new GuiNpcLabel(12, "gui.lineColor2", guiLeft + 4, y + 5)); + getButton(12).setTextColor(dialog.colorData.getLineColor2()); + + color = Integer.toHexString(dialog.colorData.getLineColor3()); + while (color.length() < 6) + color = 0 + color; + addButton(new GuiNpcButton(13, guiLeft + 180, y += 25, 60, 20, color)); + addLabel(new GuiNpcLabel(13, "gui.lineColor3", guiLeft + 4, y + 5)); + getButton(13).setTextColor(dialog.colorData.getLineColor3()); + + color = Integer.toHexString(dialog.colorData.getSlotColor()); + while (color.length() < 6) + color = 0 + color; + addButton(new GuiNpcButton(14, guiLeft + 180, y += 25, 60, 20, color)); + addLabel(new GuiNpcLabel(14, "gui.slotColor", guiLeft + 4, y + 5)); + getButton(14).setTextColor(dialog.colorData.getSlotColor()); + + color = Integer.toHexString(dialog.colorData.getButtonAcceptColor()); + while (color.length() < 6) + color = 0 + color; + addButton(new GuiNpcButton(15, guiLeft + 180, y += 25, 60, 20, color)); + addLabel(new GuiNpcLabel(15, "gui.buttonAcceptColor", guiLeft + 4, y + 5)); + getButton(15).setTextColor(dialog.colorData.getButtonAcceptColor()); + + color = Integer.toHexString(dialog.colorData.getButtonRejectColor()); + while (color.length() < 6) + color = 0 + color; + addButton(new GuiNpcButton(16, guiLeft + 180, y += 25, 60, 20, color)); + addLabel(new GuiNpcLabel(16, "gui.buttonRejectColor", guiLeft + 4, y + 5)); + getButton(16).setTextColor(dialog.colorData.getButtonRejectColor()); + } + } } public void updateScrollData() { @@ -379,7 +429,36 @@ public class SubGuiNpcDialogVisual extends SubGuiInterface implements ISubGuiLis } } } - + if (activeMenu == 5) { + DialogColorData colData = dialog.colorData; + if (button.id == 10) { + colData.setEnableColorSettings(button.getValue()==1); + } + if (button.id == 11) { + setSubGui(new SubGuiColorSelector(colData.getLineColor1())); + lastColorClicked = 2; + } + if (button.id == 12) { + setSubGui(new SubGuiColorSelector(colData.getLineColor2())); + lastColorClicked = 3; + } + if (button.id == 13) { + setSubGui(new SubGuiColorSelector(colData.getLineColor3())); + lastColorClicked = 4; + } + if (button.id == 14) { + setSubGui(new SubGuiColorSelector(colData.getSlotColor())); + lastColorClicked = 5; + } + if (button.id == 15) { + setSubGui(new SubGuiColorSelector(colData.getButtonAcceptColor())); + lastColorClicked = 6; + } + if (button.id == 16) { + setSubGui(new SubGuiColorSelector(colData.getButtonRejectColor())); + lastColorClicked = 7; + } + } initGui(); } @@ -412,6 +491,23 @@ public class SubGuiNpcDialogVisual extends SubGuiInterface implements ISubGuiLis initGui(); } } + if (activeMenu == 5) { + DialogColorData colData = dialog.colorData; + if (lastColorClicked == 2) { + colData.setLineColor1(((SubGuiColorSelector) subgui).color); + } else if (lastColorClicked == 3) { + colData.setLineColor2(((SubGuiColorSelector) subgui).color); + }else if (lastColorClicked == 4) { + colData.setLineColor3(((SubGuiColorSelector) subgui).color); + }else if (lastColorClicked == 5) { + colData.setSlotColor(((SubGuiColorSelector) subgui).color); + }else if (lastColorClicked == 6) { + colData.setButtonAcceptColor(((SubGuiColorSelector) subgui).color); + }else if (lastColorClicked == 7) { + colData.setButtonRejectColor(((SubGuiColorSelector) subgui).color); + } + initGui(); + } save(); } diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiNpcFactionOptions.java b/src/main/java/noppes/npcs/client/gui/SubGuiNpcFactionOptions.java index c2d3fbb78..b2ece2a5d 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiNpcFactionOptions.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiNpcFactionOptions.java @@ -12,7 +12,7 @@ import java.util.HashMap; import java.util.Vector; public class SubGuiNpcFactionOptions extends SubGuiInterface implements IScrollData, ICustomScrollListener { - private final FactionOptions options; + private FactionOptions options; private HashMap data = new HashMap(); private GuiCustomScroll scrollFactions; diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiNpcFactionPoints.java b/src/main/java/noppes/npcs/client/gui/SubGuiNpcFactionPoints.java index 9e5e99f1a..074464d74 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiNpcFactionPoints.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiNpcFactionPoints.java @@ -6,7 +6,7 @@ import noppes.npcs.client.gui.util.*; import noppes.npcs.controllers.data.Faction; public class SubGuiNpcFactionPoints extends SubGuiInterface implements ITextfieldListener { - private final Faction faction; + private Faction faction; public SubGuiNpcFactionPoints(Faction faction) { this.faction = faction; diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiNpcMeleeProperties.java b/src/main/java/noppes/npcs/client/gui/SubGuiNpcMeleeProperties.java index 42276111b..c9d451c1b 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiNpcMeleeProperties.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiNpcMeleeProperties.java @@ -6,8 +6,8 @@ import noppes.npcs.client.gui.util.*; import noppes.npcs.constants.EnumPotionType; public class SubGuiNpcMeleeProperties extends SubGuiInterface implements ITextfieldListener { - private final DataStats stats; - private final String[] potionNames = new String[]{"gui.none", "tile.fire.name", "potion.poison", "potion.hunger", "potion.weakness", "potion.moveSlowdown", "potion.confusion", "potion.blindness", "potion.wither"}; + private DataStats stats; + private String[] potionNames = new String[]{"gui.none", "tile.fire.name", "potion.poison", "potion.hunger", "potion.weakness", "potion.moveSlowdown", "potion.confusion", "potion.blindness", "potion.wither"}; public SubGuiNpcMeleeProperties(DataStats stats) { this.stats = stats; @@ -20,7 +20,7 @@ public class SubGuiNpcMeleeProperties extends SubGuiInterface implements ITextfi public void initGui() { super.initGui(); addLabel(new GuiNpcLabel(1, "stats.meleestrength", guiLeft + 5, guiTop + 15)); - addTextField(new GuiNpcTextField(1, this, fontRendererObj, guiLeft + 85, guiTop + 10, 160, 18, String.format("%.0f", stats.getAttackStrength()))); + addTextField(new GuiNpcTextField(1, this, fontRendererObj, guiLeft + 85, guiTop + 10, 160, 18, String.format("%.0f", stats.getAttackStrength()) + "")); getTextField(1).floatsOnly = true; getTextField(1).setMinMaxDefaultFloat(0, Float.MAX_VALUE, 5); addLabel(new GuiNpcLabel(2, "stats.meleerange", guiLeft + 5, guiTop + 45)); diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiNpcMovement.java b/src/main/java/noppes/npcs/client/gui/SubGuiNpcMovement.java index 146de99d0..39c712771 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiNpcMovement.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiNpcMovement.java @@ -8,7 +8,7 @@ import noppes.npcs.constants.EnumMovingType; import noppes.npcs.constants.EnumStandingType; public class SubGuiNpcMovement extends SubGuiInterface implements ITextfieldListener { - private final DataAI ai; + private DataAI ai; public SubGuiNpcMovement(DataAI ai) { this.ai = ai; diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiNpcName.java b/src/main/java/noppes/npcs/client/gui/SubGuiNpcName.java index e295e0fdb..a31a4dea4 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiNpcName.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiNpcName.java @@ -6,7 +6,7 @@ import noppes.npcs.client.gui.mainmenu.GuiNpcDisplay; import noppes.npcs.client.gui.util.*; public class SubGuiNpcName extends SubGuiInterface implements ITextfieldListener { - private final DataDisplay display; + private DataDisplay display; public SubGuiNpcName(DataDisplay display) { this.display = display; diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiNpcProjectiles.java b/src/main/java/noppes/npcs/client/gui/SubGuiNpcProjectiles.java index 8111a251a..554aa1032 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiNpcProjectiles.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiNpcProjectiles.java @@ -6,15 +6,19 @@ import noppes.npcs.client.gui.util.*; import noppes.npcs.constants.EnumParticleType; import noppes.npcs.constants.EnumPotionType; -public class SubGuiNpcProjectiles extends SubGuiInterface implements ITextfieldListener { - private final DataStats stats; - private final String[] potionNames = new String[]{"gui.none", "tile.fire.name", "potion.poison", "potion.hunger", "potion.weakness", "potion.moveSlowdown", "potion.confusion", "potion.blindness", "potion.wither"}; - private final String[] trailNames = new String[]{"gui.none", "Smoke", "Portal", "Redstone", "Lightning", "LargeSmoke", "Magic", "Enchant"}; +public class SubGuiNpcProjectiles extends SubGuiInterface implements ITextfieldListener, ISubGuiListener { + private DataStats stats; + private String[] potionNames = new String[]{"gui.none", "tile.fire.name", "potion.poison", "potion.hunger", "potion.weakness", "potion.moveSlowdown", "potion.confusion", "potion.blindness", "potion.wither"}; + private String[] trailNames = new String[]{ "gui.none", "trail.smoke", "trail.portal", "trail.redstone", + "trail.lightning", "trail.largesmoke", "trail.magic", "trail.enchant", "trail.crit", + "trail.explode", "trail.music", "trail.flame", "trail.lava", "trail.splash", + "trail.slime", "trail.heart", "trail.angryvillager", "trail.happyvillager", "trail.custom" + }; public SubGuiNpcProjectiles(DataStats stats) { this.stats = stats; setBackground("menubg.png"); - xSize = 256; + xSize = 390; ySize = 216; closeOnEsc = true; } @@ -22,55 +26,86 @@ public class SubGuiNpcProjectiles extends SubGuiInterface implements ITextfieldL public void initGui() { super.initGui(); addLabel(new GuiNpcLabel(1, "enchantment.arrowDamage", guiLeft + 5, guiTop + 15)); - addTextField(new GuiNpcTextField(1, this, fontRendererObj, guiLeft + 45, guiTop + 10, 50, 18, String.format("%.0f", stats.pDamage))); + addTextField(new GuiNpcTextField(1, this, fontRendererObj, guiLeft + 45, guiTop + 10, 50, 20, String.format("%.0f", stats.pDamage) + "")); getTextField(1).setFloatsOnly(); getTextField(1).setMinMaxDefaultFloat(0, Float.MAX_VALUE, 5); - addLabel(new GuiNpcLabel(2, "enchantment.arrowKnockback", guiLeft + 110, guiTop + 15)); - addTextField(new GuiNpcTextField(2, this, fontRendererObj, guiLeft + 150, guiTop + 10, 50, 18, stats.pImpact + "")); + + int y = guiTop + 10; + int second = guiLeft + 110; + + addLabel(new GuiNpcLabel(2, "enchantment.arrowKnockback", second, y + 5)); + addTextField(new GuiNpcTextField(2, this, fontRendererObj, second + 40, y, 50, 20, stats.pImpact + "")); getTextField(2).integersOnly = true; getTextField(2).setMinMaxDefault(0, Integer.MAX_VALUE, 0); - addLabel(new GuiNpcLabel(3, "stats.size", guiLeft + 5, guiTop + 45)); - addTextField(new GuiNpcTextField(3, this, fontRendererObj, guiLeft + 45, guiTop + 40, 50, 18, stats.pSize + "")); + + addButton(new GuiNpcButton(6, guiLeft + 220, guiTop + 10, 60, 20, new String[]{"stats.noglow", "stats.glows"}, stats.pGlows ? 1 : 0)); + + y += 30; + + addLabel(new GuiNpcLabel(3, "stats.size", guiLeft + 5, y + 5)); + addTextField(new GuiNpcTextField(3, this, fontRendererObj, guiLeft + 45, y, 50, 20, stats.pSize + "")); getTextField(3).integersOnly = true; getTextField(3).setMinMaxDefault(1, Integer.MAX_VALUE, 10); - addLabel(new GuiNpcLabel(4, "stats.speed", guiLeft + 5, guiTop + 75)); - addTextField(new GuiNpcTextField(4, this, fontRendererObj, guiLeft + 45, guiTop + 70, 50, 18, stats.pSpeed + "")); + + addLabel(new GuiNpcLabel(4, "stats.speed", second, y + 5)); + addTextField(new GuiNpcTextField(4, this, fontRendererObj, second + 40, y, 50, 20, stats.pSpeed + "")); getTextField(4).integersOnly = true; getTextField(4).setMinMaxDefault(1, Integer.MAX_VALUE, 10); - addLabel(new GuiNpcLabel(5, "stats.hasgravity", guiLeft + 5, guiTop + 105)); - addButton(new GuiNpcButton(0, guiLeft + 60, guiTop + 100, 60, 20, new String[]{"gui.no", "gui.yes"}, stats.pPhysics ? 1 : 0)); + y += 30; + + addLabel(new GuiNpcLabel(5, "stats.hasgravity", guiLeft + 5, y + 5)); + addButton(new GuiNpcButton(0, guiLeft + 80, y, 40, 20, new String[]{"gui.no", "gui.yes"}, stats.pPhysics ? 1 : 0)); if (!stats.pPhysics) { - addButton(new GuiNpcButton(1, guiLeft + 140, guiTop + 100, 60, 20, new String[]{"gui.constant", "gui.accelerate"}, stats.pXlr8 ? 1 : 0)); + addButton(new GuiNpcButton(1, guiLeft + 125, y, 60, 20, new String[]{"gui.constant", "gui.accelerate"}, stats.pXlr8 ? 1 : 0)); } - addLabel(new GuiNpcLabel(6, "stats.explosive", guiLeft + 5, guiTop + 135)); - addButton(new GuiNpcButton(2, guiLeft + 60, guiTop + 130, 60, 20, new String[]{"gui.no", "gui.yes"}, stats.pExplode ? 1 : 0)); + + y += 30; + + addLabel(new GuiNpcLabel(6, "stats.explosive", guiLeft + 5, y + 5)); + addButton(new GuiNpcButton(2, guiLeft + 80, y, 40, 20, new String[]{"gui.no", "gui.yes"}, stats.pExplode ? 1 : 0)); if (stats.pExplode) { - addButton(new GuiNpcButton(3, guiLeft + 140, guiTop + 130, 60, 20, new String[]{"gui.none", "gui.small", "gui.medium", "gui.large"}, stats.pArea)); + addButton(new GuiNpcButton(3, guiLeft + 125, y, 60, 20, new String[]{"gui.none", "gui.small", "gui.medium", "gui.large"}, stats.pArea)); } - addLabel(new GuiNpcLabel(7, "stats.rangedeffect", guiLeft + 5, guiTop + 165)); - addButton(new GuiNpcButton(4, guiLeft + 60, guiTop + 160, 60, 20, potionNames, stats.pEffect.ordinal())); + + addLabel(new GuiNpcLabel(7, "stats.rangedeffect", guiLeft + 210, y + 5)); + addButton(new GuiButtonBiDirectional(4, guiLeft + 280, y, 100, 20, potionNames, stats.pEffect.ordinal())); + if (stats.pEffect != EnumPotionType.None) { - addTextField(new GuiNpcTextField(5, this, fontRendererObj, guiLeft + 140, guiTop + 160, 60, 18, stats.pDur + "")); + int internalY = y + 30; + addLabel(new GuiNpcLabel(50, "gui.time", guiLeft + 210, internalY + 5)); + addTextField(new GuiNpcTextField(5, this, fontRendererObj, guiLeft + 330, internalY, 52, 20, stats.pDur + "")); getTextField(5).integersOnly = true; getTextField(5).setMinMaxDefault(1, Integer.MAX_VALUE, 5); if (stats.pEffect != EnumPotionType.Fire) { - addButton(new GuiNpcButton(10, guiLeft + 210, guiTop + 160, 40, 20, new String[]{"stats.regular", "stats.amplified"}, stats.pEffAmp)); + internalY += 30; + addLabel(new GuiNpcLabel(70, "stats.amplify", guiLeft + 210, internalY + 5)); + addButton(new GuiButtonBiDirectional(10, guiLeft + 280, internalY, 52, 20, new String[]{"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10"}, stats.pEffAmp)); + } else { + internalY += 30; + addLabel(new GuiNpcLabel(100, "stats.burnItem", guiLeft + 210, internalY + 5)); + addButton(new GuiNpcButtonYesNo(100, guiLeft + 330, internalY, 52, 20, stats.pBurnItem)); } } - addLabel(new GuiNpcLabel(8, "stats.trail", guiLeft + 5, guiTop + 195)); - addButton(new GuiNpcButton(5, guiLeft + 60, guiTop + 190, 60, 20, trailNames, stats.pTrail.ordinal())); + y += 30; - addButton(new GuiNpcButton(7, guiLeft + 220, guiTop + 10, 30, 20, new String[]{"2D", "3D"}, stats.pRender3D ? 1 : 0)); - if (stats.pRender3D) { - addLabel(new GuiNpcLabel(10, "stats.spin", guiLeft + 160, guiTop + 45)); - addButton(new GuiNpcButton(8, guiLeft + 220, guiTop + 40, 30, 20, new String[]{"gui.no", "gui.yes"}, stats.pSpin ? 1 : 0)); - addLabel(new GuiNpcLabel(11, "stats.stick", guiLeft + 160, guiTop + 75)); - addButton(new GuiNpcButton(9, guiLeft + 220, guiTop + 70, 30, 20, new String[]{"gui.no", "gui.yes"}, stats.pStick ? 1 : 0)); + addLabel(new GuiNpcLabel(8, "stats.trail", guiLeft + 5, y + 5)); + addButton(new GuiNpcButton(5, guiLeft + 80, y, 75, 20, trailNames, stats.pTrail.ordinal())); + if(stats.pTrail == EnumParticleType.Custom){ + int internalY = y + 30; + addLabel(new GuiNpcLabel(90, "trail.custom", guiLeft + 5, internalY + 5)); + addButton(new GuiNpcButton(90, guiLeft + 80, internalY, 75, 20, "gui.edit")); } - addButton(new GuiNpcButton(6, guiLeft + 140, guiTop + 190, 60, 20, new String[]{"stats.noglow", "stats.glows"}, stats.pGlows ? 1 : 0)); - addButton(new GuiNpcButton(66, guiLeft + 210, guiTop + 190, 40, 20, "gui.done")); + + addButton(new GuiNpcButton(7, guiLeft + xSize - 40, guiTop + 10, 30, 20, new String[]{"2D", "3D"}, stats.pRender3D ? 1 : 0)); + if (stats.pRender3D) { + addLabel(new GuiNpcLabel(10, "stats.spin", guiLeft + xSize - 80, guiTop + 45)); + addButton(new GuiNpcButton(8, guiLeft + xSize - 40, guiTop + 40, 30, 20, new String[]{"gui.no", "gui.yes"}, stats.pSpin ? 1 : 0)); + addLabel(new GuiNpcLabel(11, "stats.stick", guiLeft + xSize - 80, guiTop + 75)); + addButton(new GuiNpcButton(9, guiLeft + xSize - 40, guiTop + 70, 30, 20, new String[]{"gui.no", "gui.yes"}, stats.pStick ? 1 : 0)); + } + addButton(new GuiNpcButton(66, guiLeft + xSize - 50, guiTop + 190, 40, 20, "gui.done")); } public void unFocused(GuiNpcTextField textfield) { @@ -109,6 +144,10 @@ public class SubGuiNpcProjectiles extends SubGuiInterface implements ITextfieldL } if (button.id == 5) { stats.pTrail = EnumParticleType.values()[button.getValue()]; + initGui(); + } + if (button.id == 90) { + setSubGui(new SubGuiScriptParticle(stats.pCustom)); } if (button.id == 6) { stats.pGlows = (button.getValue() == 1); @@ -126,8 +165,17 @@ public class SubGuiNpcProjectiles extends SubGuiInterface implements ITextfieldL if (button.id == 10) { stats.pEffAmp = button.getValue(); } + if (button.id == 100) { + stats.pBurnItem = (button.getValue() == 1); + initGui(); + } if (button.id == 66) { close(); } } + + @Override + public void subGuiClosed(SubGuiInterface subgui) { + + } } diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiNpcRangeProperties.java b/src/main/java/noppes/npcs/client/gui/SubGuiNpcRangeProperties.java index cdb404c8f..52bcda535 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiNpcRangeProperties.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiNpcRangeProperties.java @@ -6,7 +6,7 @@ import noppes.npcs.client.gui.select.GuiSoundSelection; import noppes.npcs.client.gui.util.*; public class SubGuiNpcRangeProperties extends SubGuiInterface implements ITextfieldListener, ISubGuiListener { - private final DataStats stats; + private DataStats stats; private GuiNpcTextField soundSelected = null; public SubGuiNpcRangeProperties(DataStats stats) { @@ -61,7 +61,10 @@ public class SubGuiNpcRangeProperties extends SubGuiInterface implements ITextfi addLabel(new GuiNpcLabel(7, "stats.firesound:", guiLeft + 5, y + 5)); addButton(new GuiNpcButton(7, guiLeft + 187, y, 60, 20, "gui.select")); - addButton(new GuiNpcButtonYesNo(9, guiLeft + 100, y += 22, stats.aimWhileShooting)); + addButton(new GuiNpcButton(10, guiLeft + 100, y += 22, 70, 20, new String[]{"stats.onShot", "stats.onStart"}, stats.onSoundBegin ? 1 : 0)); + addLabel(new GuiNpcLabel(10, "stats.firesound:", guiLeft + 5, y + 5)); + + addButton(new GuiNpcButton(9, guiLeft + 100, y += 22, 70, 20, new String[]{"gui.no", "gui.yes", "stats.onShot"}, stats.aimType)); addLabel(new GuiNpcLabel(9, "stats.aimWhileShooting", guiLeft + 5, y + 5)); addButton(new GuiNpcButton(66, guiLeft + 190, guiTop + 190, 60, 20, "gui.done")); @@ -104,10 +107,13 @@ public class SubGuiNpcRangeProperties extends SubGuiInterface implements ITextfi soundSelected = getTextField(7); setSubGui(new GuiSoundSelection(soundSelected.getText())); } + if(id == 10){ + stats.onSoundBegin = ((GuiNpcButton) guibutton).getValue() == 1; + } if (id == 66) { close(); } else if (id == 9) { - stats.aimWhileShooting = ((GuiNpcButtonYesNo) guibutton).getBoolean(); + stats.aimType = (byte) ((GuiNpcButton) guibutton).getValue(); } } diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiNpcResistanceProperties.java b/src/main/java/noppes/npcs/client/gui/SubGuiNpcResistanceProperties.java index 9e7c7369a..ddcf0239b 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiNpcResistanceProperties.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiNpcResistanceProperties.java @@ -5,7 +5,7 @@ import noppes.npcs.Resistances; import noppes.npcs.client.gui.util.*; public class SubGuiNpcResistanceProperties extends SubGuiInterface implements ISliderListener { - private final Resistances resistances; + private Resistances resistances; public SubGuiNpcResistanceProperties(Resistances resistances) { this.resistances = resistances; diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiNpcRespawn.java b/src/main/java/noppes/npcs/client/gui/SubGuiNpcRespawn.java index 7c0c81ee1..ea70f7cf2 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiNpcRespawn.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiNpcRespawn.java @@ -5,7 +5,7 @@ import noppes.npcs.DataStats; import noppes.npcs.client.gui.util.*; public class SubGuiNpcRespawn extends SubGuiInterface implements ITextfieldListener { - private final DataStats stats; + private DataStats stats; public SubGuiNpcRespawn(DataStats stats) { this.stats = stats; diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiPlayerData.java b/src/main/java/noppes/npcs/client/gui/SubGuiPlayerData.java index a4402f7dc..a91946b2a 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiPlayerData.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiPlayerData.java @@ -452,7 +452,7 @@ public class SubGuiPlayerData extends SubGuiInterface implements IPlayerDataInfo splitField.setFloatsOnly(); damageField.setFloatsOnly(); - splitField.setMinMaxDefaultFloat(0, 1000000000, 0); + splitField.setMinMaxDefaultFloat(-100000, 1000000000, 0); damageField.setMinMaxDefaultFloat(0, 1000000000, 0); splitField.enabled = false; damageField.enabled = false; diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiScriptParticle.java b/src/main/java/noppes/npcs/client/gui/SubGuiScriptParticle.java new file mode 100644 index 000000000..d28977979 --- /dev/null +++ b/src/main/java/noppes/npcs/client/gui/SubGuiScriptParticle.java @@ -0,0 +1,112 @@ +package noppes.npcs.client.gui; + +import net.minecraft.client.gui.GuiButton; +import noppes.npcs.client.gui.util.*; +import noppes.npcs.scripted.ScriptParticle; + +public class SubGuiScriptParticle extends SubGuiInterface implements ITextfieldListener { + + private ScriptParticle particle; + + public SubGuiScriptParticle(ScriptParticle particle) { + this.particle = particle; + setBackground("menubg.png"); + xSize = 350; + ySize = 216; + closeOnEsc = true; + } + + @Override + public void initGui() { + super.initGui(); + int y = guiTop + 10; + addLabel(new GuiNpcLabel(1, "display.texture", guiLeft + 5, y)); + addTextField(new GuiNpcTextField(1, this, fontRendererObj, guiLeft + 70, y - 5, 260, 20, particle.directory)); + + y += 30; + // maxAge (small int textfield) + addLabel(new GuiNpcLabel(2, "particle.maxAge", guiLeft + 5, y)); + addTextField(new GuiNpcTextField(2, this, fontRendererObj, guiLeft + 70, y - 5, 50, 20, particle.maxAge + "")); + getTextField(2).integersOnly = true; + getTextField(2).setMinMaxDefault(1, Integer.MAX_VALUE, particle.maxAge); + + y += 30; + // Width and Height (small int textfields) + addLabel(new GuiNpcLabel(3, "effect.editor.width", guiLeft + 5, y)); + addTextField(new GuiNpcTextField(3, this, fontRendererObj, guiLeft + 70, y - 5, 50, 20, particle.width + "")); + getTextField(3).integersOnly = true; + getTextField(3).setMinMaxDefault(-1, Integer.MAX_VALUE, particle.width); + + addLabel(new GuiNpcLabel(4, "effect.editor.height", guiLeft + 140, y)); + addTextField(new GuiNpcTextField(4, this, fontRendererObj, guiLeft + 190, y - 5, 50, 20, particle.height + "")); + getTextField(4).integersOnly = true; + getTextField(4).setMinMaxDefault(-1, Integer.MAX_VALUE, particle.height); + + y += 30; + // FacePlayer, Glows, noClip buttons (Yes/No) with width 40 + addLabel(new GuiNpcLabel(5, "particle.facePlayer", guiLeft + 5, y + 5)); + addButton(new GuiNpcButton(5, guiLeft + 70, y, 40, 20, new String[]{"gui.no", "gui.yes"}, particle.facePlayer ? 1 : 0)); + + addLabel(new GuiNpcLabel(6, "display.glow", guiLeft + 120, y + 5)); + addButton(new GuiNpcButton(6, guiLeft + 170, y, 40, 20, new String[]{"gui.no", "gui.yes"}, particle.glows ? 1 : 0)); + + addLabel(new GuiNpcLabel(7, "particle.noClip", guiLeft + 220, y + 5)); + addButton(new GuiNpcButton(7, guiLeft + 280, y, 40, 20, new String[]{"gui.no", "gui.yes"}, particle.noClip ? 1 : 0)); + + y += 30; + // Scale row: label "model.scale", then "X:" and "Y:" textfields. + addLabel(new GuiNpcLabel(8, "model.scale", guiLeft + 5, y + 5)); + addLabel(new GuiNpcLabel(9, "X:", guiLeft + 100, y + 5)); + addTextField(new GuiNpcTextField(8, this, fontRendererObj, guiLeft + 120, y - 5, 40, 20, particle.scaleX1 + "")); + addLabel(new GuiNpcLabel(10, "Y:", guiLeft + 170, y + 5)); + addTextField(new GuiNpcTextField(9, this, fontRendererObj, guiLeft + 190, y - 5, 40, 20, particle.scaleY1 + "")); + + // Done button at bottom right + addButton(new GuiNpcButton(66, guiLeft + xSize - 50, guiTop + ySize - 30, 45, 20, "gui.done")); + } + + @Override + public void unFocused(GuiNpcTextField textfield) { + if (textfield.id == 1) { + particle.directory = textfield.getText(); + } else if (textfield.id == 2) { + particle.maxAge = textfield.getInteger(); + } else if (textfield.id == 3) { + particle.width = textfield.getInteger(); + } else if (textfield.id == 4) { + particle.height = textfield.getInteger(); + } else if (textfield.id == 8) { + // When scaleX1 is modified, update both scaleX1 and scaleX2. + float value = Float.parseFloat(textfield.getText()); + particle.scaleX1 = value; + particle.scaleX2 = value; + } else if (textfield.id == 9) { + // Update scaleY1 and scaleY2. + float value = Float.parseFloat(textfield.getText()); + particle.scaleY1 = value; + particle.scaleY2 = value; + } + } + + @Override + protected void actionPerformed(GuiButton guibutton) { + if (guibutton.id == 5) { + particle.facePlayer = (((GuiNpcButton) guibutton).getValue() == 1); + } + if (guibutton.id == 6) { + particle.glows = (((GuiNpcButton) guibutton).getValue() == 1); + } + if (guibutton.id == 7) { + particle.noClip = (((GuiNpcButton) guibutton).getValue() == 1); + } + if (guibutton.id == 66) { + close(); + } + } + + @Override + public void close(){ + GuiNpcTextField.unfocus(); + super.close(); + } +} diff --git a/src/main/java/noppes/npcs/client/gui/advanced/GuiNPCDialogNpcOptions.java b/src/main/java/noppes/npcs/client/gui/advanced/GuiNPCDialogNpcOptions.java index 1cc112f39..084c11e1a 100644 --- a/src/main/java/noppes/npcs/client/gui/advanced/GuiNPCDialogNpcOptions.java +++ b/src/main/java/noppes/npcs/client/gui/advanced/GuiNPCDialogNpcOptions.java @@ -16,8 +16,8 @@ import java.util.HashMap; public class GuiNPCDialogNpcOptions extends GuiNPCInterface2 implements GuiSelectionListener, IGuiData { - private final GuiScreen parent; - private final HashMap data = new HashMap(); + private GuiScreen parent; + private HashMap data = new HashMap(); public GuiNPCDialogNpcOptions(EntityNPCInterface npc, GuiScreen parent) { super(npc); @@ -65,6 +65,7 @@ public class GuiNPCDialogNpcOptions extends GuiNPCInterface2 implements GuiSelec } public void save() { + return; } @Override diff --git a/src/main/java/noppes/npcs/client/gui/advanced/GuiNPCMagic.java b/src/main/java/noppes/npcs/client/gui/advanced/GuiNPCMagic.java index e912bba6d..86eb1fbb2 100644 --- a/src/main/java/noppes/npcs/client/gui/advanced/GuiNPCMagic.java +++ b/src/main/java/noppes/npcs/client/gui/advanced/GuiNPCMagic.java @@ -80,7 +80,7 @@ public class GuiNPCMagic extends GuiNPCInterface2 implements IScrollData, ICusto addLabel(new GuiNpcLabel(5002, "magic.split", guiLeft + 193, tfY + 5)); splitField = new GuiNpcTextField(73, this, fontRendererObj, guiLeft + 250, tfY, 45, 20, ""); splitField.setFloatsOnly(); - splitField.setMinMaxDefaultFloat(0, 1000000000, 0); + splitField.setMinMaxDefaultFloat(-1000000, 1000000000, 0); splitField.enabled = false; addTextField(splitField); diff --git a/src/main/java/noppes/npcs/client/gui/advanced/GuiNPCMarks.java b/src/main/java/noppes/npcs/client/gui/advanced/GuiNPCMarks.java index fa22e5c67..bc22bcde2 100644 --- a/src/main/java/noppes/npcs/client/gui/advanced/GuiNPCMarks.java +++ b/src/main/java/noppes/npcs/client/gui/advanced/GuiNPCMarks.java @@ -12,7 +12,7 @@ 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 final MarkData data; + private MarkData data; private MarkData.Mark selectedMark; public GuiNPCMarks(EntityNPCInterface npc) { diff --git a/src/main/java/noppes/npcs/client/gui/advanced/GuiNPCNightSetup.java b/src/main/java/noppes/npcs/client/gui/advanced/GuiNPCNightSetup.java index 0bef8bc48..c0999471e 100644 --- a/src/main/java/noppes/npcs/client/gui/advanced/GuiNPCNightSetup.java +++ b/src/main/java/noppes/npcs/client/gui/advanced/GuiNPCNightSetup.java @@ -14,7 +14,7 @@ import noppes.npcs.controllers.data.DataTransform; import noppes.npcs.entity.EntityNPCInterface; public class GuiNPCNightSetup extends GuiNPCInterface2 implements IGuiData { - private final DataTransform data; + private DataTransform data; public GuiNPCNightSetup(EntityNPCInterface npc) { super(npc); diff --git a/src/main/java/noppes/npcs/client/gui/advanced/GuiNPCTagSetup.java b/src/main/java/noppes/npcs/client/gui/advanced/GuiNPCTagSetup.java index 45f6735a4..f32aeab39 100644 --- a/src/main/java/noppes/npcs/client/gui/advanced/GuiNPCTagSetup.java +++ b/src/main/java/noppes/npcs/client/gui/advanced/GuiNPCTagSetup.java @@ -22,7 +22,7 @@ public class GuiNPCTagSetup extends GuiNPCInterface2 implements IScrollData, ICu private GuiCustomScroll scrollTags; private GuiCustomScroll npcTags; private final ArrayList allTags = new ArrayList<>(); - private final ArrayList tagNames = new ArrayList<>(); + private ArrayList tagNames = new ArrayList<>(); private String search = ""; public GuiNPCTagSetup(EntityNPCInterface npc) { diff --git a/src/main/java/noppes/npcs/client/gui/custom/GuiCustom.java b/src/main/java/noppes/npcs/client/gui/custom/GuiCustom.java index 32127ccdc..de8304c75 100644 --- a/src/main/java/noppes/npcs/client/gui/custom/GuiCustom.java +++ b/src/main/java/noppes/npcs/client/gui/custom/GuiCustom.java @@ -154,8 +154,8 @@ public class GuiCustom extends GuiScreen implements ICustomScrollListener, IGuiD public void drawScreenSuper(int mouseX, int mouseY, float partialTicks) { //this.drawDefaultBackground(); - int k = guiLeft; - int l = guiTop; + int k = this.guiLeft; + int l = this.guiTop; //this.drawGuiContainerBackgroundLayer(partialTicks, mouseX, mouseY); GL11.glDisable(GL12.GL_RESCALE_NORMAL); RenderHelper.disableStandardItemLighting(); @@ -170,7 +170,7 @@ public class GuiCustom extends GuiScreen implements ICustomScrollListener, IGuiD this.theSlot = null; short short1 = 240; short short2 = 240; - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float) short1, (float) short2); + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float) short1 / 1.0F, (float) short2 / 1.0F); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); int k1; @@ -213,7 +213,7 @@ public class GuiCustom extends GuiScreen implements ICustomScrollListener, IGuiD itemstack.stackSize = this.field_146996_I; if (itemstack.stackSize == 0) { - s = EnumChatFormatting.YELLOW + "0"; + s = "" + EnumChatFormatting.YELLOW + "0"; } } @@ -232,7 +232,7 @@ public class GuiCustom extends GuiScreen implements ICustomScrollListener, IGuiD int j2 = this.returningStackDestSlot.yDisplayPosition - this.field_147010_z; int l1 = this.field_147011_y + (int) ((float) k1 * f1); int i2 = this.field_147010_z + (int) ((float) j2 * f1); - this.drawItemStack(this.returningStack, l1, i2, null); + this.drawItemStack(this.returningStack, l1, i2, (String) null); } GL11.glPopMatrix(); @@ -265,8 +265,8 @@ public class GuiCustom extends GuiScreen implements ICustomScrollListener, IGuiD } protected boolean isPointInRegion(int slotDisplayX, int slotDisplayY, int slotSizeX, int slotSizeY, int posX, int posY) { - int k1 = guiLeft; - int l1 = guiTop; + int k1 = this.guiLeft; + int l1 = this.guiTop; posX -= k1; posY -= l1; return posX >= slotDisplayX - 1 && posX < slotDisplayX + slotSizeX + 1 && posY >= slotDisplayY - 1 && posY < slotDisplayY + slotSizeY + 1; @@ -523,7 +523,6 @@ public class GuiCustom extends GuiScreen implements ICustomScrollListener, IGuiD if (invSlot.equals(slot)) { flag1 = false; - break; } } @@ -536,7 +535,7 @@ public class GuiCustom extends GuiScreen implements ICustomScrollListener, IGuiD } if (this.mc.gameSettings.touchscreen && flag1 && this.mc.thePlayer.inventory.getItemStack() == null) { - this.mc.displayGuiScreen(null); + this.mc.displayGuiScreen((GuiScreen) null); return; } @@ -654,8 +653,8 @@ public class GuiCustom extends GuiScreen implements ICustomScrollListener, IGuiD protected void mouseMovedOrUp(int p_146286_1_, int p_146286_2_, int p_146286_3_) { super.mouseMovedOrUp(p_146286_1_, p_146286_2_, p_146286_3_); //Forge, Call parent to release buttons Slot slot = this.getSlotAtPosition(p_146286_1_, p_146286_2_); - int l = guiLeft; - int i1 = guiTop; + int l = this.guiLeft; + int i1 = this.guiTop; boolean flag = p_146286_1_ < l || p_146286_2_ < i1 || p_146286_1_ >= l + this.xSize || p_146286_2_ >= i1 + this.ySize; int j1 = -1; @@ -670,7 +669,7 @@ public class GuiCustom extends GuiScreen implements ICustomScrollListener, IGuiD Slot slot1; Iterator iterator; - if (this.field_146993_M && slot != null && p_146286_3_ == 0 && this.inventorySlots.func_94530_a(null, slot)) { + if (this.field_146993_M && slot != null && p_146286_3_ == 0 && this.inventorySlots.func_94530_a((ItemStack) null, slot)) { if (isShiftKeyDown()) { if (slot != null && slot.inventory != null && this.field_146994_N != null) { iterator = this.inventorySlots.inventorySlots.iterator(); @@ -738,7 +737,7 @@ public class GuiCustom extends GuiScreen implements ICustomScrollListener, IGuiD this.clickedSlot = null; } } else if (this.field_147007_t && !this.field_147008_s.isEmpty()) { - this.handleMouseClick(null, -999, Container.func_94534_d(0, this.field_146987_F), 5); + this.handleMouseClick((Slot) null, -999, Container.func_94534_d(0, this.field_146987_F), 5); iterator = this.field_147008_s.iterator(); while (iterator.hasNext()) { @@ -746,7 +745,7 @@ public class GuiCustom extends GuiScreen implements ICustomScrollListener, IGuiD this.handleMouseClick(slot1, slot1.slotNumber, Container.func_94534_d(1, this.field_146987_F), 5); } - this.handleMouseClick(null, -999, Container.func_94534_d(2, this.field_146987_F), 5); + this.handleMouseClick((Slot) null, -999, Container.func_94534_d(2, this.field_146987_F), 5); } else if (this.mc.thePlayer.inventory.getItemStack() != null) { if (p_146286_3_ == this.mc.gameSettings.keyBindPickBlock.getKeyCode() + 100) { this.handleMouseClick(slot, j1, p_146286_3_, 3); diff --git a/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiLabel.java b/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiLabel.java index 76e450dc6..daa1a98e0 100644 --- a/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiLabel.java +++ b/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiLabel.java @@ -44,8 +44,8 @@ public class CustomGuiLabel extends Gui implements IGuiComponent { private boolean italicStyle = false; private boolean underlineStyle = false; private boolean strikethroughStyle = false; - private final boolean bidiFlag = false; - private final boolean unicodeFlag = false; + private boolean bidiFlag = false; + private boolean unicodeFlag = false; private static final ResourceLocation[] unicodePageLocations = new ResourceLocation[256]; protected final ResourceLocation locationFontTexture; @@ -299,7 +299,7 @@ public class CustomGuiLabel extends Gui implements IGuiComponent { ++i; } else { - j = "\u00c0\u00c1\u00c2\u00c8\u00ca\u00cb\u00cd\u00d3\u00d4\u00d5\u00da\u00df\u00e3\u00f5\u011f\u0130\u0131\u0152\u0153\u015e\u015f\u0174\u0175\u017e\u0207\u0000\u0000\u0000\u0000\u0000\u0000\u0000 !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u0000\u00c7\u00fc\u00e9\u00e2\u00e4\u00e0\u00e5\u00e7\u00ea\u00eb\u00e8\u00ef\u00ee\u00ec\u00c4\u00c5\u00c9\u00e6\u00c6\u00f4\u00f6\u00f2\u00fb\u00f9\u00ff\u00d6\u00dc\u00f8\u00a3\u00d8\u00d7\u0192\u00e1\u00ed\u00f3\u00fa\u00f1\u00d1\u00aa\u00ba\u00bf\u00ae\u00ac\u00bd\u00bc\u00a1\u00ab\u00bb\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255d\u255c\u255b\u2510\u2514\u2534\u252c\u251c\u2500\u253c\u255e\u255f\u255a\u2554\u2569\u2566\u2560\u2550\u256c\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256b\u256a\u2518\u250c\u2588\u2584\u258c\u2590\u2580\u03b1\u03b2\u0393\u03c0\u03a3\u03c3\u03bc\u03c4\u03a6\u0398\u03a9\u03b4\u221e\u2205\u2208\u2229\u2261\u00b1\u2265\u2264\u2320\u2321\u00f7\u2248\u00b0\u2219\u00b7\u221a\u207f\u00b2\u25a0\u0000".indexOf(c0); + j = "\u00c0\u00c1\u00c2\u00c8\u00ca\u00cb\u00cd\u00d3\u00d4\u00d5\u00da\u00df\u00e3\u00f5\u011f\u0130\u0131\u0152\u0153\u015e\u015f\u0174\u0175\u017e\u0207\u0000\u0000\u0000\u0000\u0000\u0000\u0000 !\"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u0000\u00c7\u00fc\u00e9\u00e2\u00e4\u00e0\u00e5\u00e7\u00ea\u00eb\u00e8\u00ef\u00ee\u00ec\u00c4\u00c5\u00c9\u00e6\u00c6\u00f4\u00f6\u00f2\u00fb\u00f9\u00ff\u00d6\u00dc\u00f8\u00a3\u00d8\u00d7\u0192\u00e1\u00ed\u00f3\u00fa\u00f1\u00d1\u00aa\u00ba\u00bf\u00ae\u00ac\u00bd\u00bc\u00a1\u00ab\u00bb\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255d\u255c\u255b\u2510\u2514\u2534\u252c\u251c\u2500\u253c\u255e\u255f\u255a\u2554\u2569\u2566\u2560\u2550\u256c\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256b\u256a\u2518\u250c\u2588\u2584\u258c\u2590\u2580\u03b1\u03b2\u0393\u03c0\u03a3\u03c3\u03bc\u03c4\u03a6\u0398\u03a9\u03b4\u221e\u2205\u2208\u2229\u2261\u00b1\u2265\u2264\u2320\u2321\u00f7\u2248\u00b0\u2219\u00b7\u221a\u207f\u00b2\u25a0\u0000".indexOf(c0); if (this.randomStyle && j != -1) { do { @@ -358,10 +358,10 @@ public class CustomGuiLabel extends Gui implements IGuiComponent { tessellator = Tessellator.instance; GL11.glDisable(GL11.GL_TEXTURE_2D); tessellator.startDrawingQuads(); - tessellator.addVertex(this.posX, this.posY + (float) (Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT / 2), 0.0D); - tessellator.addVertex(this.posX + f, this.posY + (float) (Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT / 2), 0.0D); - tessellator.addVertex(this.posX + f, this.posY + (float) (Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT / 2) - 1.0F, 0.0D); - tessellator.addVertex(this.posX, this.posY + (float) (Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT / 2) - 1.0F, 0.0D); + tessellator.addVertex((double) this.posX, (double) (this.posY + (float) (Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT / 2)), 0.0D); + tessellator.addVertex((double) (this.posX + f), (double) (this.posY + (float) (Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT / 2)), 0.0D); + tessellator.addVertex((double) (this.posX + f), (double) (this.posY + (float) (Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT / 2) - 1.0F), 0.0D); + tessellator.addVertex((double) this.posX, (double) (this.posY + (float) (Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT / 2) - 1.0F), 0.0D); tessellator.draw(); GL11.glEnable(GL11.GL_TEXTURE_2D); } @@ -371,10 +371,10 @@ public class CustomGuiLabel extends Gui implements IGuiComponent { GL11.glDisable(GL11.GL_TEXTURE_2D); tessellator.startDrawingQuads(); int l = this.underlineStyle ? -1 : 0; - tessellator.addVertex(this.posX + (float) l, this.posY + (float) Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT, 0.0D); - tessellator.addVertex(this.posX + f, this.posY + (float) Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT, 0.0D); - tessellator.addVertex(this.posX + f, this.posY + (float) Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT - 1.0F, 0.0D); - tessellator.addVertex(this.posX + (float) l, this.posY + (float) Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT - 1.0F, 0.0D); + tessellator.addVertex((double) (this.posX + (float) l), (double) (this.posY + (float) Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT), 0.0D); + tessellator.addVertex((double) (this.posX + f), (double) (this.posY + (float) Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT), 0.0D); + tessellator.addVertex((double) (this.posX + f), (double) (this.posY + (float) Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT - 1.0F), 0.0D); + tessellator.addVertex((double) (this.posX + (float) l), (double) (this.posY + (float) Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT - 1.0F), 0.0D); tessellator.draw(); GL11.glEnable(GL11.GL_TEXTURE_2D); } @@ -385,7 +385,7 @@ public class CustomGuiLabel extends Gui implements IGuiComponent { } private float renderCharAtPos(int p_78278_1_, char p_78278_2_, boolean p_78278_3_) { - return p_78278_2_ == 32 ? 4.0F : ("\u00c0\u00c1\u00c2\u00c8\u00ca\u00cb\u00cd\u00d3\u00d4\u00d5\u00da\u00df\u00e3\u00f5\u011f\u0130\u0131\u0152\u0153\u015e\u015f\u0174\u0175\u017e\u0207\u0000\u0000\u0000\u0000\u0000\u0000\u0000 !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u0000\u00c7\u00fc\u00e9\u00e2\u00e4\u00e0\u00e5\u00e7\u00ea\u00eb\u00e8\u00ef\u00ee\u00ec\u00c4\u00c5\u00c9\u00e6\u00c6\u00f4\u00f6\u00f2\u00fb\u00f9\u00ff\u00d6\u00dc\u00f8\u00a3\u00d8\u00d7\u0192\u00e1\u00ed\u00f3\u00fa\u00f1\u00d1\u00aa\u00ba\u00bf\u00ae\u00ac\u00bd\u00bc\u00a1\u00ab\u00bb\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255d\u255c\u255b\u2510\u2514\u2534\u252c\u251c\u2500\u253c\u255e\u255f\u255a\u2554\u2569\u2566\u2560\u2550\u256c\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256b\u256a\u2518\u250c\u2588\u2584\u258c\u2590\u2580\u03b1\u03b2\u0393\u03c0\u03a3\u03c3\u03bc\u03c4\u03a6\u0398\u03a9\u03b4\u221e\u2205\u2208\u2229\u2261\u00b1\u2265\u2264\u2320\u2321\u00f7\u2248\u00b0\u2219\u00b7\u221a\u207f\u00b2\u25a0\u0000".indexOf(p_78278_2_) != -1 && !this.unicodeFlag ? this.renderDefaultChar(p_78278_1_, p_78278_3_) : this.renderUnicodeChar(p_78278_2_, p_78278_3_)); + return p_78278_2_ == 32 ? 4.0F : ("\u00c0\u00c1\u00c2\u00c8\u00ca\u00cb\u00cd\u00d3\u00d4\u00d5\u00da\u00df\u00e3\u00f5\u011f\u0130\u0131\u0152\u0153\u015e\u015f\u0174\u0175\u017e\u0207\u0000\u0000\u0000\u0000\u0000\u0000\u0000 !\"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u0000\u00c7\u00fc\u00e9\u00e2\u00e4\u00e0\u00e5\u00e7\u00ea\u00eb\u00e8\u00ef\u00ee\u00ec\u00c4\u00c5\u00c9\u00e6\u00c6\u00f4\u00f6\u00f2\u00fb\u00f9\u00ff\u00d6\u00dc\u00f8\u00a3\u00d8\u00d7\u0192\u00e1\u00ed\u00f3\u00fa\u00f1\u00d1\u00aa\u00ba\u00bf\u00ae\u00ac\u00bd\u00bc\u00a1\u00ab\u00bb\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255d\u255c\u255b\u2510\u2514\u2534\u252c\u251c\u2500\u253c\u255e\u255f\u255a\u2554\u2569\u2566\u2560\u2550\u256c\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256b\u256a\u2518\u250c\u2588\u2584\u258c\u2590\u2580\u03b1\u03b2\u0393\u03c0\u03a3\u03c3\u03bc\u03c4\u03a6\u0398\u03a9\u03b4\u221e\u2205\u2208\u2229\u2261\u00b1\u2265\u2264\u2320\u2321\u00f7\u2248\u00b0\u2219\u00b7\u221a\u207f\u00b2\u25a0\u0000".indexOf(p_78278_2_) != -1 && !this.unicodeFlag ? this.renderDefaultChar(p_78278_1_, p_78278_3_) : this.renderUnicodeChar(p_78278_2_, p_78278_3_)); } protected float renderDefaultChar(int p_78266_1_, boolean p_78266_2_) { @@ -409,7 +409,7 @@ public class CustomGuiLabel extends Gui implements IGuiComponent { private ResourceLocation getUnicodePageLocation(int p_111271_1_) { if (unicodePageLocations[p_111271_1_] == null) { - unicodePageLocations[p_111271_1_] = new ResourceLocation(String.format("textures/font/unicode_page_%02x.png", Integer.valueOf(p_111271_1_))); + unicodePageLocations[p_111271_1_] = new ResourceLocation(String.format("textures/font/unicode_page_%02x.png", new Object[]{Integer.valueOf(p_111271_1_)})); } return unicodePageLocations[p_111271_1_]; @@ -497,7 +497,6 @@ public class CustomGuiLabel extends Gui implements IGuiComponent { if ((aint[i2 + k2] >> 24 & 255) != 0) { flag = false; - break; } } diff --git a/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiScrollComponent.java b/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiScrollComponent.java index 85895648e..976496b81 100644 --- a/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiScrollComponent.java +++ b/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiScrollComponent.java @@ -80,7 +80,7 @@ public class CustomGuiScrollComponent extends GuiCustomScroll implements IDataHo } public ICustomGuiComponent toComponent() { - ScriptGuiScroll component = new ScriptGuiScroll(this.id, this.guiLeft - GuiCustom.guiLeft, this.guiTop - GuiCustom.guiTop, this.xSize, this.ySize, this.getList().toArray(new String[0])); + ScriptGuiScroll component = new ScriptGuiScroll(this.id, this.guiLeft - GuiCustom.guiLeft, this.guiTop - GuiCustom.guiTop, this.xSize, this.ySize, (String[]) this.getList().toArray(new String[0])); component.setHoverText(this.hoverText); component.setColor(color); component.setAlpha(alpha); diff --git a/src/main/java/noppes/npcs/client/gui/customoverlay/components/CustomOverlayLabel.java b/src/main/java/noppes/npcs/client/gui/customoverlay/components/CustomOverlayLabel.java index 9f9b94b89..f5b97457b 100644 --- a/src/main/java/noppes/npcs/client/gui/customoverlay/components/CustomOverlayLabel.java +++ b/src/main/java/noppes/npcs/client/gui/customoverlay/components/CustomOverlayLabel.java @@ -42,8 +42,8 @@ public class CustomOverlayLabel extends Gui implements IOverlayComponent { private boolean italicStyle = false; private boolean underlineStyle = false; private boolean strikethroughStyle = false; - private final boolean bidiFlag = false; - private final boolean unicodeFlag = false; + private boolean bidiFlag = false; + private boolean unicodeFlag = false; private static final ResourceLocation[] unicodePageLocations = new ResourceLocation[256]; protected final ResourceLocation locationFontTexture; @@ -238,7 +238,7 @@ public class CustomOverlayLabel extends Gui implements IOverlayComponent { ++i; } else { - j = "\u00c0\u00c1\u00c2\u00c8\u00ca\u00cb\u00cd\u00d3\u00d4\u00d5\u00da\u00df\u00e3\u00f5\u011f\u0130\u0131\u0152\u0153\u015e\u015f\u0174\u0175\u017e\u0207\u0000\u0000\u0000\u0000\u0000\u0000\u0000 !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u0000\u00c7\u00fc\u00e9\u00e2\u00e4\u00e0\u00e5\u00e7\u00ea\u00eb\u00e8\u00ef\u00ee\u00ec\u00c4\u00c5\u00c9\u00e6\u00c6\u00f4\u00f6\u00f2\u00fb\u00f9\u00ff\u00d6\u00dc\u00f8\u00a3\u00d8\u00d7\u0192\u00e1\u00ed\u00f3\u00fa\u00f1\u00d1\u00aa\u00ba\u00bf\u00ae\u00ac\u00bd\u00bc\u00a1\u00ab\u00bb\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255d\u255c\u255b\u2510\u2514\u2534\u252c\u251c\u2500\u253c\u255e\u255f\u255a\u2554\u2569\u2566\u2560\u2550\u256c\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256b\u256a\u2518\u250c\u2588\u2584\u258c\u2590\u2580\u03b1\u03b2\u0393\u03c0\u03a3\u03c3\u03bc\u03c4\u03a6\u0398\u03a9\u03b4\u221e\u2205\u2208\u2229\u2261\u00b1\u2265\u2264\u2320\u2321\u00f7\u2248\u00b0\u2219\u00b7\u221a\u207f\u00b2\u25a0\u0000".indexOf(c0); + j = "\u00c0\u00c1\u00c2\u00c8\u00ca\u00cb\u00cd\u00d3\u00d4\u00d5\u00da\u00df\u00e3\u00f5\u011f\u0130\u0131\u0152\u0153\u015e\u015f\u0174\u0175\u017e\u0207\u0000\u0000\u0000\u0000\u0000\u0000\u0000 !\"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u0000\u00c7\u00fc\u00e9\u00e2\u00e4\u00e0\u00e5\u00e7\u00ea\u00eb\u00e8\u00ef\u00ee\u00ec\u00c4\u00c5\u00c9\u00e6\u00c6\u00f4\u00f6\u00f2\u00fb\u00f9\u00ff\u00d6\u00dc\u00f8\u00a3\u00d8\u00d7\u0192\u00e1\u00ed\u00f3\u00fa\u00f1\u00d1\u00aa\u00ba\u00bf\u00ae\u00ac\u00bd\u00bc\u00a1\u00ab\u00bb\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255d\u255c\u255b\u2510\u2514\u2534\u252c\u251c\u2500\u253c\u255e\u255f\u255a\u2554\u2569\u2566\u2560\u2550\u256c\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256b\u256a\u2518\u250c\u2588\u2584\u258c\u2590\u2580\u03b1\u03b2\u0393\u03c0\u03a3\u03c3\u03bc\u03c4\u03a6\u0398\u03a9\u03b4\u221e\u2205\u2208\u2229\u2261\u00b1\u2265\u2264\u2320\u2321\u00f7\u2248\u00b0\u2219\u00b7\u221a\u207f\u00b2\u25a0\u0000".indexOf(c0); if (this.randomStyle && j != -1) { do { @@ -297,10 +297,10 @@ public class CustomOverlayLabel extends Gui implements IOverlayComponent { tessellator = Tessellator.instance; GL11.glDisable(GL11.GL_TEXTURE_2D); tessellator.startDrawingQuads(); - tessellator.addVertex(this.posX, this.posY + (float) (Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT / 2), 0.0D); - tessellator.addVertex(this.posX + f, this.posY + (float) (Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT / 2), 0.0D); - tessellator.addVertex(this.posX + f, this.posY + (float) (Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT / 2) - 1.0F, 0.0D); - tessellator.addVertex(this.posX, this.posY + (float) (Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT / 2) - 1.0F, 0.0D); + tessellator.addVertex((double) this.posX, (double) (this.posY + (float) (Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT / 2)), 0.0D); + tessellator.addVertex((double) (this.posX + f), (double) (this.posY + (float) (Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT / 2)), 0.0D); + tessellator.addVertex((double) (this.posX + f), (double) (this.posY + (float) (Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT / 2) - 1.0F), 0.0D); + tessellator.addVertex((double) this.posX, (double) (this.posY + (float) (Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT / 2) - 1.0F), 0.0D); tessellator.draw(); GL11.glEnable(GL11.GL_TEXTURE_2D); } @@ -310,10 +310,10 @@ public class CustomOverlayLabel extends Gui implements IOverlayComponent { GL11.glDisable(GL11.GL_TEXTURE_2D); tessellator.startDrawingQuads(); int l = this.underlineStyle ? -1 : 0; - tessellator.addVertex(this.posX + (float) l, this.posY + (float) Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT, 0.0D); - tessellator.addVertex(this.posX + f, this.posY + (float) Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT, 0.0D); - tessellator.addVertex(this.posX + f, this.posY + (float) Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT - 1.0F, 0.0D); - tessellator.addVertex(this.posX + (float) l, this.posY + (float) Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT - 1.0F, 0.0D); + tessellator.addVertex((double) (this.posX + (float) l), (double) (this.posY + (float) Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT), 0.0D); + tessellator.addVertex((double) (this.posX + f), (double) (this.posY + (float) Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT), 0.0D); + tessellator.addVertex((double) (this.posX + f), (double) (this.posY + (float) Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT - 1.0F), 0.0D); + tessellator.addVertex((double) (this.posX + (float) l), (double) (this.posY + (float) Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT - 1.0F), 0.0D); tessellator.draw(); GL11.glEnable(GL11.GL_TEXTURE_2D); } @@ -324,7 +324,7 @@ public class CustomOverlayLabel extends Gui implements IOverlayComponent { } private float renderCharAtPos(int p_78278_1_, char p_78278_2_, boolean p_78278_3_) { - return p_78278_2_ == 32 ? 4.0F : ("\u00c0\u00c1\u00c2\u00c8\u00ca\u00cb\u00cd\u00d3\u00d4\u00d5\u00da\u00df\u00e3\u00f5\u011f\u0130\u0131\u0152\u0153\u015e\u015f\u0174\u0175\u017e\u0207\u0000\u0000\u0000\u0000\u0000\u0000\u0000 !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u0000\u00c7\u00fc\u00e9\u00e2\u00e4\u00e0\u00e5\u00e7\u00ea\u00eb\u00e8\u00ef\u00ee\u00ec\u00c4\u00c5\u00c9\u00e6\u00c6\u00f4\u00f6\u00f2\u00fb\u00f9\u00ff\u00d6\u00dc\u00f8\u00a3\u00d8\u00d7\u0192\u00e1\u00ed\u00f3\u00fa\u00f1\u00d1\u00aa\u00ba\u00bf\u00ae\u00ac\u00bd\u00bc\u00a1\u00ab\u00bb\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255d\u255c\u255b\u2510\u2514\u2534\u252c\u251c\u2500\u253c\u255e\u255f\u255a\u2554\u2569\u2566\u2560\u2550\u256c\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256b\u256a\u2518\u250c\u2588\u2584\u258c\u2590\u2580\u03b1\u03b2\u0393\u03c0\u03a3\u03c3\u03bc\u03c4\u03a6\u0398\u03a9\u03b4\u221e\u2205\u2208\u2229\u2261\u00b1\u2265\u2264\u2320\u2321\u00f7\u2248\u00b0\u2219\u00b7\u221a\u207f\u00b2\u25a0\u0000".indexOf(p_78278_2_) != -1 && !this.unicodeFlag ? this.renderDefaultChar(p_78278_1_, p_78278_3_) : this.renderUnicodeChar(p_78278_2_, p_78278_3_)); + return p_78278_2_ == 32 ? 4.0F : ("\u00c0\u00c1\u00c2\u00c8\u00ca\u00cb\u00cd\u00d3\u00d4\u00d5\u00da\u00df\u00e3\u00f5\u011f\u0130\u0131\u0152\u0153\u015e\u015f\u0174\u0175\u017e\u0207\u0000\u0000\u0000\u0000\u0000\u0000\u0000 !\"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u0000\u00c7\u00fc\u00e9\u00e2\u00e4\u00e0\u00e5\u00e7\u00ea\u00eb\u00e8\u00ef\u00ee\u00ec\u00c4\u00c5\u00c9\u00e6\u00c6\u00f4\u00f6\u00f2\u00fb\u00f9\u00ff\u00d6\u00dc\u00f8\u00a3\u00d8\u00d7\u0192\u00e1\u00ed\u00f3\u00fa\u00f1\u00d1\u00aa\u00ba\u00bf\u00ae\u00ac\u00bd\u00bc\u00a1\u00ab\u00bb\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255d\u255c\u255b\u2510\u2514\u2534\u252c\u251c\u2500\u253c\u255e\u255f\u255a\u2554\u2569\u2566\u2560\u2550\u256c\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256b\u256a\u2518\u250c\u2588\u2584\u258c\u2590\u2580\u03b1\u03b2\u0393\u03c0\u03a3\u03c3\u03bc\u03c4\u03a6\u0398\u03a9\u03b4\u221e\u2205\u2208\u2229\u2261\u00b1\u2265\u2264\u2320\u2321\u00f7\u2248\u00b0\u2219\u00b7\u221a\u207f\u00b2\u25a0\u0000".indexOf(p_78278_2_) != -1 && !this.unicodeFlag ? this.renderDefaultChar(p_78278_1_, p_78278_3_) : this.renderUnicodeChar(p_78278_2_, p_78278_3_)); } protected float renderDefaultChar(int p_78266_1_, boolean p_78266_2_) { @@ -348,7 +348,7 @@ public class CustomOverlayLabel extends Gui implements IOverlayComponent { private ResourceLocation getUnicodePageLocation(int p_111271_1_) { if (unicodePageLocations[p_111271_1_] == null) { - unicodePageLocations[p_111271_1_] = new ResourceLocation(String.format("textures/font/unicode_page_%02x.png", Integer.valueOf(p_111271_1_))); + unicodePageLocations[p_111271_1_] = new ResourceLocation(String.format("textures/font/unicode_page_%02x.png", new Object[]{Integer.valueOf(p_111271_1_)})); } return unicodePageLocations[p_111271_1_]; @@ -436,7 +436,6 @@ public class CustomOverlayLabel extends Gui implements IOverlayComponent { if ((aint[i2 + k2] >> 24 & 255) != 0) { flag = false; - break; } } diff --git a/src/main/java/noppes/npcs/client/gui/customoverlay/components/CustomOverlayLine.java b/src/main/java/noppes/npcs/client/gui/customoverlay/components/CustomOverlayLine.java index cadae32c9..999a41495 100644 --- a/src/main/java/noppes/npcs/client/gui/customoverlay/components/CustomOverlayLine.java +++ b/src/main/java/noppes/npcs/client/gui/customoverlay/components/CustomOverlayLine.java @@ -71,10 +71,10 @@ public class CustomOverlayLine extends Gui implements IOverlayComponent { tessellator.startDrawingQuads(); tessellator.setColorOpaque_F(1, 1, 1); tessellator.setColorRGBA_F(red, green, blue, alpha); - tessellator.addVertexWithUV(p_73729_1_, p_73729_2_ + p_73729_6_, this.zLevel, (float) (p_73729_3_) * f, (float) (p_73729_4_ + p_73729_6_) * f1); - tessellator.addVertexWithUV(p_73729_1_ + p_73729_5_, p_73729_2_ + p_73729_6_, this.zLevel, (float) (p_73729_3_ + p_73729_5_) * f, (float) (p_73729_4_ + p_73729_6_) * f1); - tessellator.addVertexWithUV(p_73729_1_ + p_73729_5_, p_73729_2_, this.zLevel, (float) (p_73729_3_ + p_73729_5_) * f, (float) (p_73729_4_) * f1); - tessellator.addVertexWithUV(p_73729_1_, p_73729_2_, this.zLevel, (float) (p_73729_3_) * f, (float) (p_73729_4_) * f1); + tessellator.addVertexWithUV((double) (p_73729_1_ + 0), (double) (p_73729_2_ + p_73729_6_), (double) this.zLevel, (double) ((float) (p_73729_3_ + 0) * f), (double) ((float) (p_73729_4_ + p_73729_6_) * f1)); + tessellator.addVertexWithUV((double) (p_73729_1_ + p_73729_5_), (double) (p_73729_2_ + p_73729_6_), (double) this.zLevel, (double) ((float) (p_73729_3_ + p_73729_5_) * f), (double) ((float) (p_73729_4_ + p_73729_6_) * f1)); + tessellator.addVertexWithUV((double) (p_73729_1_ + p_73729_5_), (double) (p_73729_2_ + 0), (double) this.zLevel, (double) ((float) (p_73729_3_ + p_73729_5_) * f), (double) ((float) (p_73729_4_ + 0) * f1)); + tessellator.addVertexWithUV((double) (p_73729_1_ + 0), (double) (p_73729_2_ + 0), (double) this.zLevel, (double) ((float) (p_73729_3_ + 0) * f), (double) ((float) (p_73729_4_ + 0) * f1)); tessellator.draw(); GL11.glPopMatrix(); } diff --git a/src/main/java/noppes/npcs/client/gui/global/GuiNPCEditAnimation.java b/src/main/java/noppes/npcs/client/gui/global/GuiNPCEditAnimation.java index ea7343682..4b5997b7f 100644 --- a/src/main/java/noppes/npcs/client/gui/global/GuiNPCEditAnimation.java +++ b/src/main/java/noppes/npcs/client/gui/global/GuiNPCEditAnimation.java @@ -486,7 +486,9 @@ public class GuiNPCEditAnimation extends GuiModelInterface implements ITextfield if (guibutton.id >= 300 && guibutton.id < 325) { int frameClicked = guibutton.id - 300; if (frameClicked < this.animation.frames.size()) { - this.frameIndex = frameClicked + this.frameOffset; + Animation playingAnim = data.animation != null && this.playingAnimation ? data.animation : this.animation; + int frameOffset = this.playingAnimation ? playingAnim.currentFrame - 24 : this.frameOffset; + this.frameIndex = frameClicked + Math.max(0, frameOffset); overrideFrame = true; } } @@ -510,7 +512,6 @@ public class GuiNPCEditAnimation extends GuiModelInterface implements ITextfield @Override public void drawScreen(int par1, int par2, float par3) { - super.drawScreen(par1, par2, par3); AnimationData data = npc.display.animationData; if (!data.isActive() && this.playingAnimation) { this.playingAnimation = false; @@ -518,6 +519,7 @@ public class GuiNPCEditAnimation extends GuiModelInterface implements ITextfield } else if (data.isActive()) { long time = mc.theWorld.getTotalWorldTime(); if (time != prevTick) { + npc.display.animationData.increaseTime(); GuiNpcLabel label = this.getLabel(213); if (label != null) { label.label += "."; @@ -529,18 +531,22 @@ public class GuiNPCEditAnimation extends GuiModelInterface implements ITextfield prevTick = time; } + super.drawScreen(par1, par2, par3); + + Animation playingAnim = data.animation != null && this.playingAnimation ? data.animation : this.animation; for (int i = 0; i < this.visibleFrames; i++) { if (getButton(300 + i) != null) { GuiTexturedButton button = (GuiTexturedButton) getButton(300 + i); - int sliderFrame = i + this.frameOffset; - if (sliderFrame >= this.animation.frames.size()) { + int frameOffset = this.playingAnimation ? playingAnim.currentFrame - 24 : this.frameOffset; + int sliderFrame = i + Math.max(0, frameOffset); + if (sliderFrame >= playingAnim.frames.size()) { button.color = 0x0; button.alpha = 0.3F; } else { - button.color = this.animation.frames.get(sliderFrame).getColorMarker(); - if ((sliderFrame == this.animation.currentFrame && this.playingAnimation) || sliderFrame == this.frameIndex) { - if ((sliderFrame == this.animation.currentFrame && this.playingAnimation)) { + button.color = playingAnim.frames.get(sliderFrame).getColorMarker(); + if ((sliderFrame == playingAnim.currentFrame && this.playingAnimation) || sliderFrame == this.frameIndex) { + if ((sliderFrame == playingAnim.currentFrame && this.playingAnimation)) { button.color = 0xfcf232; } else { button.color = 0x32a852; diff --git a/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageAnimations.java b/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageAnimations.java index 381c12f8a..6ab69d319 100644 --- a/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageAnimations.java +++ b/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageAnimations.java @@ -104,8 +104,7 @@ public class GuiNPCManageAnimations extends GuiModelInterface2 implements IScrol } @Override - public void drawScreen(int par1, int par2, float par3) { - super.drawScreen(par1, par2, par3); + public void drawScreen(int par1, int par2, float partialTicks) { AnimationData data = npc.display.animationData; if (!data.isActive() && this.playingAnimation) { this.playingAnimation = false; @@ -113,6 +112,7 @@ public class GuiNPCManageAnimations extends GuiModelInterface2 implements IScrol } else if (data.isActive()) { long time = mc.theWorld.getTotalWorldTime(); if (time != prevTick) { + npc.display.animationData.increaseTime(); GuiNpcLabel label = this.getLabel(94); if (label != null) { label.label += "."; @@ -123,6 +123,7 @@ public class GuiNPCManageAnimations extends GuiModelInterface2 implements IScrol } prevTick = time; } + super.drawScreen(par1, par2, partialTicks); } @Override diff --git a/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageBanks.java b/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageBanks.java index 328ffb823..ee3cf3f35 100644 --- a/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageBanks.java +++ b/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageBanks.java @@ -22,7 +22,7 @@ import java.util.Vector; public class GuiNPCManageBanks extends GuiContainerNPCInterface2 implements IScrollData, ICustomScrollListener, ITextfieldListener, IGuiData { private GuiCustomScroll scroll; private HashMap data = new HashMap(); - private final ContainerManageBanks container; + private ContainerManageBanks container; private Bank bank = new Bank(); private String selected = null; private String search = ""; diff --git a/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageLinked.java b/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageLinked.java index 9fa08ba1b..5d7434794 100644 --- a/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageLinked.java +++ b/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageLinked.java @@ -428,7 +428,8 @@ public class GuiNPCManageLinked extends GuiNPCInterface2 implements IScrollData, StatCollector.translateToLocal("use_action.none"), StatCollector.translateToLocal("use_action.block"), StatCollector.translateToLocal("use_action.eat"), - StatCollector.translateToLocal("use_action.drink") + StatCollector.translateToLocal("use_action.drink"), + StatCollector.translateToLocal("use_action.bow") }; int useActionIndex; switch (linkedItem.itemUseAction) { @@ -438,6 +439,9 @@ public class GuiNPCManageLinked extends GuiNPCInterface2 implements IScrollData, case 1: useActionIndex = 1; break; + case 2: + useActionIndex = 4; + break; case 3: useActionIndex = 2; break; diff --git a/src/main/java/noppes/npcs/client/gui/global/GuiNpcManageMagic.java b/src/main/java/noppes/npcs/client/gui/global/GuiNpcManageMagic.java index 095de3232..fbdc8be21 100644 --- a/src/main/java/noppes/npcs/client/gui/global/GuiNpcManageMagic.java +++ b/src/main/java/noppes/npcs/client/gui/global/GuiNpcManageMagic.java @@ -407,10 +407,18 @@ public class GuiNpcManageMagic extends GuiNPCInterface2 implements ISubGuiListen NBTTagCompound compound = new NBTTagCompound(); magic.writeNBT(compound); PacketClient.sendClient(new MagicSavePacket(compound)); + if (selectedMagic != null) { + selectedMagic = null; + if (rightScroll != null) + rightScroll.selected = -1; + } break; case 1: // Remove Magic. if (selectedMagic != null) { PacketClient.sendClient(new MagicRemovePacket(selectedMagic.id)); + selectedMagic = null; + if (rightScroll != null) + rightScroll.selected = -1; } break; case 2: // Edit Magic. diff --git a/src/main/java/noppes/npcs/client/gui/global/GuiNpcManagePlayerData.java b/src/main/java/noppes/npcs/client/gui/global/GuiNpcManagePlayerData.java index f84c72e0e..e66019bbd 100644 --- a/src/main/java/noppes/npcs/client/gui/global/GuiNpcManagePlayerData.java +++ b/src/main/java/noppes/npcs/client/gui/global/GuiNpcManagePlayerData.java @@ -23,7 +23,7 @@ public class GuiNpcManagePlayerData extends GuiNPCInterface2 implements GuiYesNo private GuiCustomScroll playerScroll; private String selectedPlayer = null; - private final HashMap playerData = new HashMap<>(); + private HashMap playerData = new HashMap<>(); private String search = ""; public GuiNpcManagePlayerData(EntityNPCInterface npcInterface) { @@ -62,6 +62,7 @@ public class GuiNpcManagePlayerData extends GuiNPCInterface2 implements GuiYesNo @Override public void mouseClicked(int i, int j, int k) { + ; super.mouseClicked(i, j, k); if (k == 0 && playerScroll != null) playerScroll.mouseClicked(i, j, k); diff --git a/src/main/java/noppes/npcs/client/gui/global/GuiNpcManageRecipes.java b/src/main/java/noppes/npcs/client/gui/global/GuiNpcManageRecipes.java index b6dbd7ad2..4fa1dd407 100644 --- a/src/main/java/noppes/npcs/client/gui/global/GuiNpcManageRecipes.java +++ b/src/main/java/noppes/npcs/client/gui/global/GuiNpcManageRecipes.java @@ -30,9 +30,9 @@ public class GuiNpcManageRecipes extends GuiContainerNPCInterface2 implements IS public static int tab = 1; public GuiCustomScroll scroll; public HashMap data = new HashMap(); - private final ContainerManageRecipes container; + private ContainerManageRecipes container; private String selected = null; - private final ResourceLocation slot; + private ResourceLocation slot; private String search = ""; public GuiNpcManageRecipes(EntityNPCInterface npc, ContainerManageRecipes container) { diff --git a/src/main/java/noppes/npcs/client/gui/global/GuiNpcQuestReward.java b/src/main/java/noppes/npcs/client/gui/global/GuiNpcQuestReward.java index 03969f7d3..6692f5b98 100644 --- a/src/main/java/noppes/npcs/client/gui/global/GuiNpcQuestReward.java +++ b/src/main/java/noppes/npcs/client/gui/global/GuiNpcQuestReward.java @@ -10,8 +10,8 @@ import noppes.npcs.entity.EntityNPCInterface; import org.lwjgl.opengl.GL11; public class GuiNpcQuestReward extends GuiContainerNPCInterface implements ITextfieldListener { - private final Quest quest; - private final ResourceLocation resource; + private Quest quest; + private ResourceLocation resource; public GuiNpcQuestReward(EntityNPCInterface npc, ContainerNpcQuestReward container) { super(npc, container); diff --git a/src/main/java/noppes/npcs/client/gui/item/GuiNpcMagicBook.java b/src/main/java/noppes/npcs/client/gui/item/GuiNpcMagicBook.java new file mode 100644 index 000000000..c5f64dbc2 --- /dev/null +++ b/src/main/java/noppes/npcs/client/gui/item/GuiNpcMagicBook.java @@ -0,0 +1,170 @@ +package noppes.npcs.client.gui.item; + +import kamkeel.npcs.network.packets.player.item.MagicCyclesPacket; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.nbt.NBTTagCompound; +import noppes.npcs.client.CustomNpcResourceListener; +import noppes.npcs.client.gui.GuiMagicCycleMap; +import noppes.npcs.client.gui.util.*; +import noppes.npcs.constants.EnumScrollData; +import noppes.npcs.controllers.data.MagicCycle; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Vector; + +public class GuiNpcMagicBook extends GuiNPCInterface implements ICustomScrollListener, IScrollData, IGuiData { + + private MagicCycle magicCycle; + private GuiMagicCycleMap magicMap; + private GuiCustomScroll leftScroll; + public HashMap cycleData = new HashMap<>(); + + public GuiNpcMagicBook() { + super(); + xSize = 350; + setBackground("menubg.png"); + closeOnEsc = true; + MagicCyclesPacket.GetAll(); + } + + @Override + public void initGui() { + super.initGui(); + + int spacing = 10; + int scrollWidth = 120; + + addLabel(new GuiNpcLabel(0, "menu.cycles", guiLeft + 14, guiTop + 10, 0xFFFFFF)); + + // --- Left Scroll List --- + leftScroll = new GuiCustomScroll(this, 0, 0); + leftScroll.guiLeft = guiLeft + spacing; + leftScroll.guiTop = guiTop + 22; + leftScroll.setSize(scrollWidth, ySize - 32); + leftScroll.setList(new ArrayList<>(cycleData.keySet())); + addScroll(leftScroll); + + // --- Magic Map (Diagram) on the Right --- + if(magicCycle == null) + return; + + String displayName = magicCycle.getDisplayName().replace("&", "\u00A7"); + leftScroll.setSelected(displayName); + + + int mapX = guiLeft + scrollWidth + 2 * spacing; + int mapY = guiTop + 22; + int mapWidth = xSize - (scrollWidth + 3 * spacing); + int mapHeight = ySize - 32; + magicMap = new GuiMagicCycleMap(this, mapX, mapY, mapWidth, mapHeight, magicCycle); + addDiagram(0, magicMap); + + int labelY = guiTop + 10; + int textWidth = fontRendererObj.getStringWidth(displayName); + int labelX = mapX + (mapWidth / 2) - (textWidth / 2); + GuiNpcLabel magicLabel = new GuiNpcLabel(1, displayName, labelX, labelY, CustomNpcResourceListener.DefaultTextColor); + addLabel(magicLabel); + } + + @Override + public void keyTyped(char c, int i) { + super.keyTyped(c, i); + if (i == 1) { + close(); + } + } + + @Override + public void actionPerformed(GuiButton guibutton) {} + + @Override + public void drawScreen(int i, int j, float f) { + super.drawScreen(i, j, f); + } + + @Override + protected void drawBackground(){ + super.drawBackground(); + + int spacing = 10; + int scrollWidth = 120; + int barHeight = 16; // Same height as the magic map bar + int barY = guiTop + 22 - barHeight - 1; + + // Draw dark rectangle above the left scroll (same width as left scroll) + if (leftScroll != null) { + int leftRectX = guiLeft + spacing; + drawRect(leftRectX, barY, leftRectX + scrollWidth, barY + barHeight, 0xFF333333); + } + + // Draw dark rectangle above the magic map + if (magicMap != null) { + int mapX = guiLeft + scrollWidth + 2 * spacing; + int mapWidth = xSize - (scrollWidth + 3 * spacing); + drawRect(mapX, barY, mapX + mapWidth, barY + barHeight, 0xFF333333); + } + } + + + @Override + public void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) { + if (magicMap != null) { + magicMap.mouseClickMove(mouseX, mouseY, clickedMouseButton, timeSinceLastClick); + } + super.mouseClickMove(mouseX, mouseY, clickedMouseButton, timeSinceLastClick); + } + + @Override + protected void mouseMovedOrUp(int mouseX, int mouseY, int state) { + if (magicMap != null) { + magicMap.mouseReleased(mouseX, mouseY, state); + } + super.mouseMovedOrUp(mouseX, mouseY, state); + } + + @Override + public void save() { + // Implement save logic if needed. + } + + // --- ICustomScrollListener Methods --- + @Override + public void customScrollClicked(int id, int index, int clickType, GuiCustomScroll scroll) { + if (scroll == leftScroll) { + String selectedName = scroll.getSelected(); + MagicCyclesPacket.GetCycle(cycleData.get(selectedName)); + } + } + + @Override + public void customScrollDoubleClicked(String selection, GuiCustomScroll scroll) { + // Handle double-click if necessary. + } + + @Override + public void setData(Vector list, HashMap data, EnumScrollData type) { + if(type == EnumScrollData.MAGIC_CYCLES){ + cycleData.clear(); + cycleData.putAll(data); + if (leftScroll != null) { + leftScroll.setList(new ArrayList<>(cycleData.keySet())); + } + initGui(); + } + } + + @Override + public void setSelected(String selected) { + + } + + @Override + public void setGuiData(NBTTagCompound compound) { + if (compound.hasKey("MagicCycle")) { + magicCycle = new MagicCycle(); + magicCycle.readNBT(compound.getCompoundTag("MagicCycle")); + initGui(); + } + } +} diff --git a/src/main/java/noppes/npcs/client/gui/item/SubGuiLinkedItem.java b/src/main/java/noppes/npcs/client/gui/item/SubGuiLinkedItem.java index 648738639..dd0dc1c64 100644 --- a/src/main/java/noppes/npcs/client/gui/item/SubGuiLinkedItem.java +++ b/src/main/java/noppes/npcs/client/gui/item/SubGuiLinkedItem.java @@ -121,7 +121,7 @@ public class SubGuiLinkedItem extends SubGuiInterface implements ITextfieldListe // Item Use Action: BiDirectional button (None, Block, Eat, Drink) addLabel(new GuiNpcLabel(5, "display.useAction", x, y + 5, CustomNpcResourceListener.DefaultTextColor)); - String[] useActions = {"use_action.none", "use_action.block", "use_action.eat", "use_action.drink"}; + String[] useActions = {"use_action.none", "use_action.block", "use_action.eat", "use_action.drink", "use_action.bow"}; int useActionIndex = 0; switch (linkedItem.itemUseAction) { case 0: @@ -130,6 +130,9 @@ public class SubGuiLinkedItem extends SubGuiInterface implements ITextfieldListe case 1: useActionIndex = 1; break; + case 2: + useActionIndex = 4; + break; case 3: useActionIndex = 2; break; @@ -281,25 +284,31 @@ public class SubGuiLinkedItem extends SubGuiInterface implements ITextfieldListe int id = guibutton.id; if (id == -5) { close(); + return; } else if (id == -1 && tab != -1) { tab = -1; initGui(); + return; } else if (id == -2 && tab != -2) { tab = -2; initGui(); + return; } else if (id == -3) { PacketClient.sendClient(new LinkedItemSavePacket(linkedItem.writeToNBT(false), originalName)); GuiScriptLinkedItem scriptGUI = new GuiScriptLinkedItem((GuiNPCManageLinked) this.parent, linkedItem); scriptGUI.setWorldAndResolution(mc, width, height); scriptGUI.initGui(); mc.currentScreen = scriptGUI; + return; } else if (id == 20) { // Open confirmation for version bump. GuiYesNo guiyesno = new GuiYesNo(this, "Confirm", "Bump version and update all linked items?", 20); displayGuiScreen(guiyesno); + return; } else if (id == 24) { setSubGui(new SubGuiColorSelector(linkedItem.display.itemColor)); colorPicked = 1; + return; } else if (id == 25) { // Clear color: set to 0xFFFFFF. linkedItem.display.itemColor = 0xFFFFFF; @@ -327,6 +336,9 @@ public class SubGuiLinkedItem extends SubGuiInterface implements ITextfieldListe case 3: linkedItem.itemUseAction = 4; break; + case 4: + linkedItem.itemUseAction = 2; + break; } } else if (id == 8) { // Armor Type button. diff --git a/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNPCInv.java b/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNPCInv.java index a3e21cd5b..6c3669814 100644 --- a/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNPCInv.java +++ b/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNPCInv.java @@ -18,9 +18,9 @@ import org.lwjgl.opengl.GL11; import java.util.HashMap; public class GuiNPCInv extends GuiContainerNPCInterface2 implements IGuiData, ITextfieldListener { - private final HashMap chances = new HashMap(); - private final ContainerNPCInv container; - private final ResourceLocation slot; + private HashMap chances = new HashMap(); + private ContainerNPCInv container; + private ResourceLocation slot; private int inventoryTab = 0; public GuiNPCInv(EntityNPCInterface npc, ContainerNPCInv container) { diff --git a/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcAI.java b/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcAI.java index 21eb794a3..895866a55 100644 --- a/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcAI.java +++ b/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcAI.java @@ -13,7 +13,7 @@ import noppes.npcs.constants.EnumNavType; import noppes.npcs.entity.EntityNPCInterface; public class GuiNpcAI extends GuiNPCInterface2 implements ITextfieldListener, IGuiData { - private final DataAI ai; + private DataAI ai; public GuiNpcAI(EntityNPCInterface npc) { super(npc, 6); diff --git a/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcStats.java b/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcStats.java index dcba4cefd..f3833477c 100644 --- a/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcStats.java +++ b/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcStats.java @@ -13,7 +13,7 @@ import noppes.npcs.client.gui.util.*; import noppes.npcs.entity.EntityNPCInterface; public class GuiNpcStats extends GuiNPCInterface2 implements ITextfieldListener, IGuiData { - private final DataStats stats; + private DataStats stats; public GuiNpcStats(EntityNPCInterface npc) { super(npc, 2); @@ -27,7 +27,7 @@ public class GuiNpcStats extends GuiNPCInterface2 implements ITextfieldListener, super.initGui(); int y = guiTop + 10; addLabel(new GuiNpcLabel(0, "stats.health", guiLeft + 5, y + 5)); - addTextField(new GuiNpcTextField(0, this, guiLeft + 82, y, 185, 18, String.format("%.0f", stats.maxHealth))); + addTextField(new GuiNpcTextField(0, this, guiLeft + 82, y, 185, 18, String.format("%.0f", stats.maxHealth) + "")); getTextField(0).doublesOnly = true; getTextField(0).setMinMaxDefaultDouble(0, Double.MAX_VALUE, 20); @@ -46,14 +46,14 @@ public class GuiNpcStats extends GuiNPCInterface2 implements ITextfieldListener, addLabel(new GuiNpcLabel(6, "stats.rangedproperties", guiLeft + 5, y + 5)); this.addButton(new GuiNpcButton(9, guiLeft + 217, y, 56, 20, "selectServer.edit")); addLabel(new GuiNpcLabel(7, "stats.projectileproperties", guiLeft + 140, y + 5)); - addTextField(new GuiNpcTextField(14, this, guiLeft + 355, y, 56, 20, String.format("%.0f", stats.healthRegen)).setFloatsOnly()); + addTextField(new GuiNpcTextField(14, this, guiLeft + 355, y, 56, 20, String.format("%.0f", stats.healthRegen) + "").setFloatsOnly()); addLabel(new GuiNpcLabel(14, "stats.regenhealth", guiLeft + 275, y + 5)); this.addButton(new GuiNpcButton(15, guiLeft + 82, y += 34, 56, 20, "selectServer.edit")); addLabel(new GuiNpcLabel(15, "potion.resistance", guiLeft + 5, y + 5)); this.addButton(new GuiNpcButton(21, guiLeft + 217, y, 56, 20, new String[]{"gui.no", "gui.yes"}, this.stats.resistances.disableDamage ? 1 : 0)); addLabel(new GuiNpcLabel(21, "stats.disabledamage", guiLeft + 140, y + 5)); - addTextField(new GuiNpcTextField(16, this, guiLeft + 355, y, 56, 20, String.format("%.0f", stats.combatRegen)).setFloatsOnly()); + addTextField(new GuiNpcTextField(16, this, guiLeft + 355, y, 56, 20, String.format("%.0f", stats.combatRegen) + "").setFloatsOnly()); addLabel(new GuiNpcLabel(16, "stats.combatregen", guiLeft + 275, y + 5)); addButton(new GuiNpcButton(4, guiLeft + 82, y += 34, 56, 20, new String[]{"gui.no", "gui.yes"}, npc.isImmuneToFire() ? 1 : 0)); @@ -120,7 +120,7 @@ public class GuiNpcStats extends GuiNPCInterface2 implements ITextfieldListener, } else if (button.id == 17) { stats.potionImmune = ((GuiNpcButtonYesNo) guibutton).getBoolean(); } else if (button.id == 18) { - stats.potionImmune = ((GuiNpcButtonYesNo) guibutton).getBoolean(); + stats.attackInvisible = ((GuiNpcButtonYesNo) guibutton).getBoolean(); } else if (button.id == 21) { // Magic Button stats.resistances.disableDamage = ((GuiNpcButton) guibutton).getValue() == 1; diff --git a/src/main/java/noppes/npcs/client/gui/model/GuiCreationScreen.java b/src/main/java/noppes/npcs/client/gui/model/GuiCreationScreen.java index fa8570880..722d9ff86 100644 --- a/src/main/java/noppes/npcs/client/gui/model/GuiCreationScreen.java +++ b/src/main/java/noppes/npcs/client/gui/model/GuiCreationScreen.java @@ -27,14 +27,14 @@ import java.util.*; public class GuiCreationScreen extends GuiModelInterface implements ICustomScrollListener { public HashMap> data = new HashMap>(); - private final List list; + private List list; private final String[] ignoredTags = {"CanBreakDoors", "Bred", "PlayerCreated", "Tame", "HasReproduced"}; private GuiNpcButton prev, next; - private final GuiScreen parent; + private GuiScreen parent; - private final HashMap mapped = new HashMap(); + private HashMap mapped = new HashMap(); public GuiCreationScreen(GuiScreen parent, EntityCustomNpc npc) { super(npc); @@ -77,7 +77,7 @@ public class GuiCreationScreen extends GuiModelInterface implements ICustomScrol @Override public void initGui() { - EntityLivingBase entity = playerdata.getEntity(npc); + EntityLivingBase entity = (EntityLivingBase) playerdata.getEntity(npc); xOffset = entity == null ? 0 : 50; super.initGui(); @@ -321,7 +321,7 @@ public class GuiCreationScreen extends GuiModelInterface implements ICustomScrol try { EntityLivingBase entity = playerdata.getEntity(npc); Method method = entity.getClass().getMethod("setBreedID", int.class); - method.invoke(entity, button.getValue()); + method.invoke(entity, ((GuiNpcButton) button).getValue()); NBTTagCompound comp = new NBTTagCompound(); entity.writeEntityToNBT(comp); playerdata.extra.setString("EntityData21", comp.getString("EntityData21")); diff --git a/src/main/java/noppes/npcs/client/gui/model/GuiEntitySelection.java b/src/main/java/noppes/npcs/client/gui/model/GuiEntitySelection.java index 2c8ba47fd..1689893d3 100644 --- a/src/main/java/noppes/npcs/client/gui/model/GuiEntitySelection.java +++ b/src/main/java/noppes/npcs/client/gui/model/GuiEntitySelection.java @@ -21,10 +21,10 @@ import java.util.Vector; public class GuiEntitySelection extends GuiNPCInterface { private GuiNPCStringSlot slot; - private final GuiCreationScreen parent; - private final Class prevModel; - private final ModelData playerdata; - private final EntityCustomNpc npc; + private GuiCreationScreen parent; + private Class prevModel; + private ModelData playerdata; + private EntityCustomNpc npc; public GuiEntitySelection(GuiCreationScreen parent, ModelData playerdata, EntityCustomNpc npc) { this.parent = parent; diff --git a/src/main/java/noppes/npcs/client/gui/model/GuiModelArms.java b/src/main/java/noppes/npcs/client/gui/model/GuiModelArms.java index 1dc9f8185..7c9d27487 100644 --- a/src/main/java/noppes/npcs/client/gui/model/GuiModelArms.java +++ b/src/main/java/noppes/npcs/client/gui/model/GuiModelArms.java @@ -15,7 +15,7 @@ public class GuiModelArms extends GuiModelInterface { private final String[] arrSolidArmwear = new String[]{"gui.no", "Both", "Left", "Right"}; private final String[] arrClaws = new String[]{"gui.no", "Both", "Left", "Right"}; - private final GuiScreen parent; + private GuiScreen parent; public GuiModelArms(GuiScreen parent, EntityCustomNpc npc) { super(npc); diff --git a/src/main/java/noppes/npcs/client/gui/model/GuiModelBody.java b/src/main/java/noppes/npcs/client/gui/model/GuiModelBody.java index 0d5a9afdd..6ba3adc2f 100644 --- a/src/main/java/noppes/npcs/client/gui/model/GuiModelBody.java +++ b/src/main/java/noppes/npcs/client/gui/model/GuiModelBody.java @@ -10,7 +10,7 @@ import noppes.npcs.entity.data.ModelPartData; public class GuiModelBody extends GuiModelInterface { - private final GuiScreen parent; + private GuiScreen parent; private final String[] arrBody = new String[]{"gui.no", "gui.yes"}; private final String[] arrBodywear = new String[]{"gui.no", "gui.yes", "Solid"}; private final String[] arrWing = new String[]{"gui.no", "Player", "Type1", "Type2", "Type3", "Type4", "Type5", "Type6", "Type7", "Type8", "Type9", diff --git a/src/main/java/noppes/npcs/client/gui/model/GuiModelColor.java b/src/main/java/noppes/npcs/client/gui/model/GuiModelColor.java index c5b602c4e..70d532aaf 100644 --- a/src/main/java/noppes/npcs/client/gui/model/GuiModelColor.java +++ b/src/main/java/noppes/npcs/client/gui/model/GuiModelColor.java @@ -18,14 +18,14 @@ import java.io.InputStream; public class GuiModelColor extends GuiModelInterface implements ITextfieldListener { - private final GuiScreen parent; + private GuiScreen parent; private final static ResourceLocation color = new ResourceLocation("customnpcs:textures/gui/color.png"); private int colorX, colorY; private GuiNpcTextField textfield; - private final ModelPartData data; + private ModelPartData data; public GuiModelColor(GuiScreen parent, ModelPartData data, EntityCustomNpc npc) { super(npc); diff --git a/src/main/java/noppes/npcs/client/gui/model/GuiModelHead.java b/src/main/java/noppes/npcs/client/gui/model/GuiModelHead.java index 40c5c472a..98052c3c5 100644 --- a/src/main/java/noppes/npcs/client/gui/model/GuiModelHead.java +++ b/src/main/java/noppes/npcs/client/gui/model/GuiModelHead.java @@ -10,7 +10,7 @@ import noppes.npcs.entity.data.ModelPartData; public class GuiModelHead extends GuiModelInterface { - private final GuiScreen parent; + private GuiScreen parent; private final String[] arrHead = new String[]{"gui.no", "gui.yes"}; private final String[] arrHeadwear = new String[]{"gui.no", "gui.yes", "Solid"}; diff --git a/src/main/java/noppes/npcs/client/gui/model/GuiModelLegs.java b/src/main/java/noppes/npcs/client/gui/model/GuiModelLegs.java index 66e7b50d5..66c4fa0f9 100644 --- a/src/main/java/noppes/npcs/client/gui/model/GuiModelLegs.java +++ b/src/main/java/noppes/npcs/client/gui/model/GuiModelLegs.java @@ -11,7 +11,7 @@ import noppes.npcs.entity.data.ModelPartData; public class GuiModelLegs extends GuiModelInterface { - private final GuiScreen parent; + private GuiScreen parent; private final String[] arrLeg = new String[]{"gui.no", "Both", "Right", "Left"}; private final String[] arrLegwear = new String[]{"gui.no", "Both", "Left", "Right"}; private final String[] arrSolidLegwear = new String[]{"gui.no", "Both", "Left", "Right"}; diff --git a/src/main/java/noppes/npcs/client/gui/model/GuiModelRotate.java b/src/main/java/noppes/npcs/client/gui/model/GuiModelRotate.java index 9399f7023..743de0945 100644 --- a/src/main/java/noppes/npcs/client/gui/model/GuiModelRotate.java +++ b/src/main/java/noppes/npcs/client/gui/model/GuiModelRotate.java @@ -9,7 +9,7 @@ import noppes.npcs.entity.data.ModelRotatePart; public class GuiModelRotate extends GuiModelInterface implements ISliderListener { - private final GuiScreen parent; + private GuiScreen parent; private int type = 6; private ModelRotatePart part; diff --git a/src/main/java/noppes/npcs/client/gui/model/GuiModelScale.java b/src/main/java/noppes/npcs/client/gui/model/GuiModelScale.java index 997d90ace..e00af5683 100644 --- a/src/main/java/noppes/npcs/client/gui/model/GuiModelScale.java +++ b/src/main/java/noppes/npcs/client/gui/model/GuiModelScale.java @@ -9,9 +9,9 @@ import noppes.npcs.entity.data.ModelScalePart; public class GuiModelScale extends GuiModelInterface implements ISliderListener { - private final GuiScreen parent; + private GuiScreen parent; private int type = 0; - private final int offset = 10; + private int offset = 10; private GuiNpcSlider scaleWidth; private GuiNpcSlider scaleHeight; diff --git a/src/main/java/noppes/npcs/client/gui/model/GuiPresetSave.java b/src/main/java/noppes/npcs/client/gui/model/GuiPresetSave.java index 061e10a2e..ccc1c4485 100644 --- a/src/main/java/noppes/npcs/client/gui/model/GuiPresetSave.java +++ b/src/main/java/noppes/npcs/client/gui/model/GuiPresetSave.java @@ -10,8 +10,8 @@ import noppes.npcs.client.gui.util.GuiNpcTextField; import noppes.npcs.entity.data.ModelData; public class GuiPresetSave extends GuiNPCInterface { - private final ModelData data; - private final GuiScreen parent; + private ModelData data; + private GuiScreen parent; public GuiPresetSave(GuiScreen parent, ModelData data) { this.data = data; diff --git a/src/main/java/noppes/npcs/client/gui/model/GuiPresetSelection.java b/src/main/java/noppes/npcs/client/gui/model/GuiPresetSelection.java index 1c969687e..06c21a732 100644 --- a/src/main/java/noppes/npcs/client/gui/model/GuiPresetSelection.java +++ b/src/main/java/noppes/npcs/client/gui/model/GuiPresetSelection.java @@ -23,10 +23,10 @@ import java.util.Vector; public class GuiPresetSelection extends GuiNPCInterface { private GuiNPCStringSlot slot; - private final GuiCreationScreen parent; - private final NBTTagCompound prevData; - private final ModelData playerdata; - private final EntityCustomNpc npc; + private GuiCreationScreen parent; + private NBTTagCompound prevData; + private ModelData playerdata; + private EntityCustomNpc npc; public GuiPresetSelection(GuiCreationScreen parent, ModelData playerdata) { this.parent = parent; diff --git a/src/main/java/noppes/npcs/client/gui/player/GuiBook.java b/src/main/java/noppes/npcs/client/gui/player/GuiBook.java index d250664c9..e7fa742c1 100644 --- a/src/main/java/noppes/npcs/client/gui/player/GuiBook.java +++ b/src/main/java/noppes/npcs/client/gui/player/GuiBook.java @@ -41,8 +41,8 @@ public class GuiBook extends GuiScreen { * Update ticks since the gui was opened */ private int updateCount; - private final int bookImageWidth = 192; - private final int bookImageHeight = 192; + private int bookImageWidth = 192; + private int bookImageHeight = 192; private int bookTotalPages = 1; private int currPage; private NBTTagList bookPages; @@ -57,9 +57,7 @@ public class GuiBook extends GuiScreen { private GuiButton buttonFinalize; private GuiButton buttonCancel; - private final int x; - private final int y; - private final int z; + private int x, y, z; public GuiBook(EntityPlayer par1EntityPlayer, ItemStack item, int x, int y, int z) { this.x = x; @@ -111,12 +109,12 @@ public class GuiBook extends GuiScreen { Keyboard.enableRepeatEvents(true); if (this.bookIsUnsigned) { - this.buttonList.add(this.buttonSign = new GuiButton(3, this.width / 2 - 100, 4 + this.bookImageHeight, 98, 20, I18n.format("book.signButton"))); - this.buttonList.add(this.buttonDone = new GuiButton(0, this.width / 2 + 2, 4 + this.bookImageHeight, 98, 20, I18n.format("gui.done"))); - this.buttonList.add(this.buttonFinalize = new GuiButton(5, this.width / 2 - 100, 4 + this.bookImageHeight, 98, 20, I18n.format("book.finalizeButton"))); - this.buttonList.add(this.buttonCancel = new GuiButton(4, this.width / 2 + 2, 4 + this.bookImageHeight, 98, 20, I18n.format("gui.cancel"))); + this.buttonList.add(this.buttonSign = new GuiButton(3, this.width / 2 - 100, 4 + this.bookImageHeight, 98, 20, I18n.format("book.signButton", new Object[0]))); + this.buttonList.add(this.buttonDone = new GuiButton(0, this.width / 2 + 2, 4 + this.bookImageHeight, 98, 20, I18n.format("gui.done", new Object[0]))); + this.buttonList.add(this.buttonFinalize = new GuiButton(5, this.width / 2 - 100, 4 + this.bookImageHeight, 98, 20, I18n.format("book.finalizeButton", new Object[0]))); + this.buttonList.add(this.buttonCancel = new GuiButton(4, this.width / 2 + 2, 4 + this.bookImageHeight, 98, 20, I18n.format("gui.cancel", new Object[0]))); } else { - this.buttonList.add(this.buttonDone = new GuiButton(0, this.width / 2 - 100, 4 + this.bookImageHeight, 200, 20, I18n.format("gui.done"))); + this.buttonList.add(this.buttonDone = new GuiButton(0, this.width / 2 - 100, 4 + this.bookImageHeight, 200, 20, I18n.format("gui.done", new Object[0]))); } int i = (this.width - this.bookImageWidth) / 2; @@ -181,7 +179,7 @@ public class GuiBook extends GuiScreen { protected void actionPerformed(GuiButton p_146284_1_) { if (p_146284_1_.enabled) { if (p_146284_1_.id == 0) { - this.mc.displayGuiScreen(null); + this.mc.displayGuiScreen((GuiScreen) null); this.sendBookToServer(false); } else if (p_146284_1_.id == 3 && this.bookIsUnsigned) { this.field_146480_s = true; @@ -201,7 +199,7 @@ public class GuiBook extends GuiScreen { } } else if (p_146284_1_.id == 5 && this.field_146480_s) { this.sendBookToServer(true); - this.mc.displayGuiScreen(null); + this.mc.displayGuiScreen((GuiScreen) null); } else if (p_146284_1_.id == 4 && this.field_146480_s) { this.field_146480_s = false; } @@ -276,13 +274,13 @@ public class GuiBook extends GuiScreen { case 156: if (!this.bookTitle.isEmpty()) { this.sendBookToServer(true); - this.mc.displayGuiScreen(null); + this.mc.displayGuiScreen((GuiScreen) null); } return; default: if (this.bookTitle.length() < 16 && ChatAllowedCharacters.isAllowedCharacter(p_146460_1_)) { - this.bookTitle = this.bookTitle + p_146460_1_; + this.bookTitle = this.bookTitle + Character.toString(p_146460_1_); this.updateButtons(); this.field_146481_r = true; } @@ -303,7 +301,7 @@ public class GuiBook extends GuiScreen { private void func_146459_b(String p_146459_1_) { String s1 = this.func_146456_p(); String s2 = s1 + p_146459_1_; - int i = this.fontRendererObj.splitStringWidth(s2 + EnumChatFormatting.BLACK + "_", 118); + int i = this.fontRendererObj.splitStringWidth(s2 + "" + EnumChatFormatting.BLACK + "_", 118); if (i <= 118 && s2.length() < 256) { this.func_146457_a(s2); @@ -328,24 +326,24 @@ public class GuiBook extends GuiScreen { if (this.bookIsUnsigned) { if (this.updateCount / 6 % 2 == 0) { - s = s + EnumChatFormatting.BLACK + "_"; + s = s + "" + EnumChatFormatting.BLACK + "_"; } else { - s = s + EnumChatFormatting.GRAY + "_"; + s = s + "" + EnumChatFormatting.GRAY + "_"; } } - s1 = I18n.format("book.editTitle"); + s1 = I18n.format("book.editTitle", new Object[0]); l = this.fontRendererObj.getStringWidth(s1); this.fontRendererObj.drawString(s1, k + 36 + (116 - l) / 2, b0 + 16 + 16, 0); int i1 = this.fontRendererObj.getStringWidth(s); this.fontRendererObj.drawString(s, k + 36 + (116 - i1) / 2, b0 + 48, 0); - String s2 = I18n.format("book.byAuthor", this.editingPlayer.getCommandSenderName()); + String s2 = I18n.format("book.byAuthor", new Object[]{this.editingPlayer.getCommandSenderName()}); int j1 = this.fontRendererObj.getStringWidth(s2); this.fontRendererObj.drawString(EnumChatFormatting.DARK_GRAY + s2, k + 36 + (116 - j1) / 2, b0 + 48 + 10, 0); - String s3 = I18n.format("book.finalizeWarning"); + String s3 = I18n.format("book.finalizeWarning", new Object[0]); this.fontRendererObj.drawSplitString(s3, k + 36, b0 + 80, 116, 0); } else { - s = I18n.format("book.pageIndicator", Integer.valueOf(this.currPage + 1), Integer.valueOf(this.bookTotalPages)); + s = I18n.format("book.pageIndicator", new Object[]{Integer.valueOf(this.currPage + 1), Integer.valueOf(this.bookTotalPages)}); s1 = ""; if (this.bookPages != null && this.currPage >= 0 && this.currPage < this.bookPages.tagCount()) { @@ -356,9 +354,9 @@ public class GuiBook extends GuiScreen { if (this.fontRendererObj.getBidiFlag()) { s1 = s1 + "_"; } else if (this.updateCount / 6 % 2 == 0) { - s1 = s1 + EnumChatFormatting.BLACK + "_"; + s1 = s1 + "" + EnumChatFormatting.BLACK + "_"; } else { - s1 = s1 + EnumChatFormatting.GRAY + "_"; + s1 = s1 + "" + EnumChatFormatting.GRAY + "_"; } } diff --git a/src/main/java/noppes/npcs/client/gui/player/GuiCrate.java b/src/main/java/noppes/npcs/client/gui/player/GuiCrate.java index 579ac87c4..4cd8ebbbf 100644 --- a/src/main/java/noppes/npcs/client/gui/player/GuiCrate.java +++ b/src/main/java/noppes/npcs/client/gui/player/GuiCrate.java @@ -13,12 +13,12 @@ import org.lwjgl.opengl.GL11; @SideOnly(Side.CLIENT) public class GuiCrate extends GuiContainer { private static final ResourceLocation field_147017_u = new ResourceLocation("textures/gui/container/generic_54.png"); - private final IInventory upperChestInventory; - private final IInventory lowerChestInventory; + private IInventory upperChestInventory; + private IInventory lowerChestInventory; /** * window height is calculated with these values; the more rows, the heigher */ - private final int inventoryRows; + private int inventoryRows; public GuiCrate(ContainerCrate container) { super(container); @@ -35,8 +35,8 @@ public class GuiCrate extends GuiContainer { * Draw the foreground layer for the GuiContainer (everything in front of the items) */ protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) { - this.fontRendererObj.drawString(this.lowerChestInventory.hasCustomInventoryName() ? this.lowerChestInventory.getInventoryName() : I18n.format(this.lowerChestInventory.getInventoryName()), 8, 6, CustomNpcResourceListener.DefaultTextColor); - this.fontRendererObj.drawString(this.upperChestInventory.hasCustomInventoryName() ? this.upperChestInventory.getInventoryName() : I18n.format(this.upperChestInventory.getInventoryName()), 8, this.ySize - 96 + 2, CustomNpcResourceListener.DefaultTextColor); + this.fontRendererObj.drawString(this.lowerChestInventory.hasCustomInventoryName() ? this.lowerChestInventory.getInventoryName() : I18n.format(this.lowerChestInventory.getInventoryName(), new Object[0]), 8, 6, CustomNpcResourceListener.DefaultTextColor); + this.fontRendererObj.drawString(this.upperChestInventory.hasCustomInventoryName() ? this.upperChestInventory.getInventoryName() : I18n.format(this.upperChestInventory.getInventoryName(), new Object[0]), 8, this.ySize - 96 + 2, CustomNpcResourceListener.DefaultTextColor); } protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) { diff --git a/src/main/java/noppes/npcs/client/gui/player/GuiDialogInteract.java b/src/main/java/noppes/npcs/client/gui/player/GuiDialogInteract.java index e59b66a81..1287000e1 100644 --- a/src/main/java/noppes/npcs/client/gui/player/GuiDialogInteract.java +++ b/src/main/java/noppes/npcs/client/gui/player/GuiDialogInteract.java @@ -41,7 +41,7 @@ public class GuiDialogInteract extends GuiNPCInterface implements IGuiClose { private GuiScreen parent; private Dialog dialog; private int selected = 0; - private final List lineBlocks = new ArrayList(); + private List lineBlocks = new ArrayList(); private List options = new ArrayList(); private int totalRows = 0; @@ -58,15 +58,15 @@ public class GuiDialogInteract extends GuiNPCInterface implements IGuiClose { private int prevPausePos = -1; private int scrollY; - private final ResourceLocation wheel; - private final ResourceLocation[] wheelparts; - private final ResourceLocation indicator; + private ResourceLocation wheel; + private ResourceLocation[] wheelparts; + private ResourceLocation indicator; private boolean isGrabbed = false; private int textSoundTime = 0; private int textPauseTime = 0; - private final HashMap dialogImages = new HashMap<>(); + private HashMap dialogImages = new HashMap<>(); public GuiDialogInteract(EntityNPCInterface npc, Dialog dialog) { super(npc); @@ -131,8 +131,8 @@ public class GuiDialogInteract extends GuiNPCInterface implements IGuiClose { float f3 = npc.rotationYaw; float f4 = npc.rotationPitch; float f7 = npc.rotationYawHead; - float f5 = l - i; - float f6 = i1 - 50 - j; + float f5 = (float) (l) - i; + float f6 = (float) (i1 - 50) - j; int rotation = npc.ais.orientation; npc.ais.orientation = 0; GL11.glRotatef(135F, 0.0F, 1.0F, 0.0F); diff --git a/src/main/java/noppes/npcs/client/gui/player/GuiMailmanWrite.java b/src/main/java/noppes/npcs/client/gui/player/GuiMailmanWrite.java index f4396ae28..d80138a5b 100644 --- a/src/main/java/noppes/npcs/client/gui/player/GuiMailmanWrite.java +++ b/src/main/java/noppes/npcs/client/gui/player/GuiMailmanWrite.java @@ -31,16 +31,16 @@ public class GuiMailmanWrite extends GuiContainerNPCInterface implements ITextfi * Update ticks since the gui was opened */ private int updateCount; - private final int bookImageWidth = 192; - private final int bookImageHeight = 192; + private int bookImageWidth = 192; + private int bookImageHeight = 192; private int bookTotalPages = 1; private int currPage; private NBTTagList bookPages; private GuiButtonNextPage buttonNextPage; private GuiButtonNextPage buttonPreviousPage; - private final boolean canEdit; - private final boolean canSend; + private boolean canEdit; + private boolean canSend; /** * The GuiButton to sign this book. @@ -49,7 +49,7 @@ public class GuiMailmanWrite extends GuiContainerNPCInterface implements ITextfi public static GuiScreen parent; public static PlayerMail mail = new PlayerMail(); - private final Minecraft mc = Minecraft.getMinecraft(); + private Minecraft mc = Minecraft.getMinecraft(); private String username = ""; private GuiNpcLabel error; @@ -256,7 +256,7 @@ public class GuiMailmanWrite extends GuiContainerNPCInterface implements ITextfi private void func_74160_b(String par1Str) { String s1 = this.func_74158_i(); String s2 = s1 + par1Str; - int i = mc.fontRenderer.splitStringWidth(s2 + EnumChatFormatting.BLACK + "_", 118); + int i = mc.fontRenderer.splitStringWidth(s2 + "" + EnumChatFormatting.BLACK + "_", 118); if (i <= 118 && s2.length() < 256) { this.func_74159_a(s2); @@ -282,7 +282,7 @@ public class GuiMailmanWrite extends GuiContainerNPCInterface implements ITextfi String s1; int l; - s = I18n.format("book.pageIndicator", Integer.valueOf(this.currPage + 1), Integer.valueOf(this.bookTotalPages)); + s = I18n.format("book.pageIndicator", new Object[]{Integer.valueOf(this.currPage + 1), Integer.valueOf(this.bookTotalPages)}); s1 = ""; if (this.bookPages != null && this.currPage >= 0 && this.currPage < this.bookPages.tagCount()) { @@ -293,9 +293,9 @@ public class GuiMailmanWrite extends GuiContainerNPCInterface implements ITextfi if (mc.fontRenderer.getBidiFlag()) { s1 = s1 + "_"; } else if (this.updateCount / 6 % 2 == 0) { - s1 = s1 + EnumChatFormatting.BLACK + "_"; + s1 = s1 + "" + EnumChatFormatting.BLACK + "_"; } else { - s1 = s1 + EnumChatFormatting.GRAY + "_"; + s1 = s1 + "" + EnumChatFormatting.GRAY + "_"; } } diff --git a/src/main/java/noppes/npcs/client/gui/player/GuiNPCBankChest.java b/src/main/java/noppes/npcs/client/gui/player/GuiNPCBankChest.java index b3813736b..e13fb9a68 100644 --- a/src/main/java/noppes/npcs/client/gui/player/GuiNPCBankChest.java +++ b/src/main/java/noppes/npcs/client/gui/player/GuiNPCBankChest.java @@ -19,7 +19,7 @@ import org.lwjgl.opengl.GL12; public class GuiNPCBankChest extends GuiContainerNPCInterface implements IGuiData { private final ResourceLocation resource = new ResourceLocation("customnpcs", "textures/gui/bankchest.png"); - private final ContainerNPCBankInterface container; + private ContainerNPCBankInterface container; private int availableSlots = 0; private int maxSlots = 1; private int unlockedSlots = 1; @@ -135,6 +135,7 @@ public class GuiNPCBankChest extends GuiContainerNPCInterface implements IGuiDat @Override public void save() { + return; } @Override diff --git a/src/main/java/noppes/npcs/client/gui/player/GuiNPCTrader.java b/src/main/java/noppes/npcs/client/gui/player/GuiNPCTrader.java index 37abceb37..d23b15398 100644 --- a/src/main/java/noppes/npcs/client/gui/player/GuiNPCTrader.java +++ b/src/main/java/noppes/npcs/client/gui/player/GuiNPCTrader.java @@ -16,8 +16,8 @@ import org.lwjgl.opengl.GL12; public class GuiNPCTrader extends GuiContainerNPCInterface { private final ResourceLocation resource = new ResourceLocation("customnpcs", "textures/gui/trader.png"); private final ResourceLocation slot = new ResourceLocation("customnpcs", "textures/gui/slot.png"); - private final RoleTrader role; - private final ContainerNPCTrader container; + private RoleTrader role; + private ContainerNPCTrader container; public GuiNPCTrader(EntityNPCInterface npc, ContainerNPCTrader container) { super(npc, container); diff --git a/src/main/java/noppes/npcs/client/gui/player/GuiNpcCarpentryBench.java b/src/main/java/noppes/npcs/client/gui/player/GuiNpcCarpentryBench.java index 4792003d0..6c59de3ca 100644 --- a/src/main/java/noppes/npcs/client/gui/player/GuiNpcCarpentryBench.java +++ b/src/main/java/noppes/npcs/client/gui/player/GuiNpcCarpentryBench.java @@ -12,7 +12,7 @@ import org.lwjgl.opengl.GL11; public class GuiNpcCarpentryBench extends GuiContainerNPCInterface { private final ResourceLocation resource = new ResourceLocation("customnpcs", "textures/gui/carpentry.png"); - private final ContainerCarpentryBench container; + private ContainerCarpentryBench container; private GuiNpcButton button; public GuiNpcCarpentryBench(ContainerCarpentryBench container) { @@ -52,5 +52,6 @@ public class GuiNpcCarpentryBench extends GuiContainerNPCInterface { @Override public void save() { + return; } } diff --git a/src/main/java/noppes/npcs/client/gui/player/GuiNpcFollower.java b/src/main/java/noppes/npcs/client/gui/player/GuiNpcFollower.java index 1de203b1c..d23975a4a 100644 --- a/src/main/java/noppes/npcs/client/gui/player/GuiNpcFollower.java +++ b/src/main/java/noppes/npcs/client/gui/player/GuiNpcFollower.java @@ -21,8 +21,8 @@ import org.lwjgl.opengl.GL12; public class GuiNpcFollower extends GuiContainerNPCInterface implements IGuiData { private final ResourceLocation resource = new ResourceLocation("customnpcs", "textures/gui/follower.png"); - private final EntityNPCInterface npc; - private final RoleFollower role; + private EntityNPCInterface npc; + private RoleFollower role; public GuiNpcFollower(EntityNPCInterface npc, ContainerNPCFollower container) { super(npc, container); diff --git a/src/main/java/noppes/npcs/client/gui/player/GuiNpcFollowerHire.java b/src/main/java/noppes/npcs/client/gui/player/GuiNpcFollowerHire.java index 339bd99f3..5858cda26 100644 --- a/src/main/java/noppes/npcs/client/gui/player/GuiNpcFollowerHire.java +++ b/src/main/java/noppes/npcs/client/gui/player/GuiNpcFollowerHire.java @@ -17,9 +17,9 @@ import org.lwjgl.opengl.GL11; public class GuiNpcFollowerHire extends GuiContainerNPCInterface { private final ResourceLocation resource = new ResourceLocation("customnpcs", "textures/gui/followerhire.png"); - private final EntityNPCInterface npc; - private final ContainerNPCFollowerHire container; - private final RoleFollower role; + private EntityNPCInterface npc; + private ContainerNPCFollowerHire container; + private RoleFollower role; public GuiNpcFollowerHire(EntityNPCInterface npc, ContainerNPCFollowerHire container) { super(npc, container); @@ -91,5 +91,6 @@ public class GuiNpcFollowerHire extends GuiContainerNPCInterface { @Override public void save() { + return; } } diff --git a/src/main/java/noppes/npcs/client/gui/player/GuiQuestCompletion.java b/src/main/java/noppes/npcs/client/gui/player/GuiQuestCompletion.java index 18e04c727..66767e7cf 100644 --- a/src/main/java/noppes/npcs/client/gui/player/GuiQuestCompletion.java +++ b/src/main/java/noppes/npcs/client/gui/player/GuiQuestCompletion.java @@ -14,7 +14,7 @@ import org.lwjgl.opengl.GL11; public class GuiQuestCompletion extends GuiNPCInterface implements ITopButtonListener { - private final Quest quest; + private Quest quest; private final ResourceLocation resource = new ResourceLocation("customnpcs", "textures/gui/smallbg.png"); public GuiQuestCompletion(Quest quest) { diff --git a/src/main/java/noppes/npcs/client/gui/player/companion/GuiNpcCompanionInv.java b/src/main/java/noppes/npcs/client/gui/player/companion/GuiNpcCompanionInv.java index 5f4811a86..1bee093bf 100644 --- a/src/main/java/noppes/npcs/client/gui/player/companion/GuiNpcCompanionInv.java +++ b/src/main/java/noppes/npcs/client/gui/player/companion/GuiNpcCompanionInv.java @@ -14,8 +14,8 @@ import org.lwjgl.opengl.GL11; public class GuiNpcCompanionInv extends GuiContainerNPCInterface { private final ResourceLocation resource = new ResourceLocation("customnpcs", "textures/gui/companioninv.png"); private final ResourceLocation slot = new ResourceLocation("customnpcs", "textures/gui/slot.png"); - private final EntityNPCInterface npc; - private final RoleCompanion role; + private EntityNPCInterface npc; + private RoleCompanion role; public GuiNpcCompanionInv(EntityNPCInterface npc, ContainerNPCCompanion container) { diff --git a/src/main/java/noppes/npcs/client/gui/player/companion/GuiNpcCompanionStats.java b/src/main/java/noppes/npcs/client/gui/player/companion/GuiNpcCompanionStats.java index a902f4388..591fe8f82 100644 --- a/src/main/java/noppes/npcs/client/gui/player/companion/GuiNpcCompanionStats.java +++ b/src/main/java/noppes/npcs/client/gui/player/companion/GuiNpcCompanionStats.java @@ -19,7 +19,7 @@ import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.roles.RoleCompanion; public class GuiNpcCompanionStats extends GuiNPCInterface implements IGuiData { - private final RoleCompanion role; + private RoleCompanion role; private boolean isEating = false; public GuiNpcCompanionStats(EntityNPCInterface npc) { diff --git a/src/main/java/noppes/npcs/client/gui/player/companion/GuiNpcCompanionTalents.java b/src/main/java/noppes/npcs/client/gui/player/companion/GuiNpcCompanionTalents.java index d64cd53b7..37f7f9570 100644 --- a/src/main/java/noppes/npcs/client/gui/player/companion/GuiNpcCompanionTalents.java +++ b/src/main/java/noppes/npcs/client/gui/player/companion/GuiNpcCompanionTalents.java @@ -27,8 +27,8 @@ import java.util.HashMap; import java.util.Map; public class GuiNpcCompanionTalents extends GuiNPCInterface { - private final RoleCompanion role; - private final Map talents = new HashMap(); + private RoleCompanion role; + private Map talents = new HashMap(); private GuiNpcButton selected; public GuiNpcCompanionTalents(EntityNPCInterface npc) { @@ -145,10 +145,9 @@ public class GuiNpcCompanionTalents extends GuiNPCInterface { } public static class GuiTalent extends GuiScreen { - private final EnumCompanionTalent talent; - private final int x; - private final int y; - private final RoleCompanion role; + private EnumCompanionTalent talent; + private int x, y; + private RoleCompanion role; private static final ResourceLocation resource = new ResourceLocation("customnpcs:textures/gui/talent.png"); public GuiTalent(RoleCompanion role, EnumCompanionTalent talent, int x, int y) { diff --git a/src/main/java/noppes/npcs/client/gui/player/inventory/GuiQuestLog.java b/src/main/java/noppes/npcs/client/gui/player/inventory/GuiQuestLog.java index 1b7b3b9e0..0b65ec305 100644 --- a/src/main/java/noppes/npcs/client/gui/player/inventory/GuiQuestLog.java +++ b/src/main/java/noppes/npcs/client/gui/player/inventory/GuiQuestLog.java @@ -30,9 +30,9 @@ public class GuiQuestLog extends GuiCNPCInventory implements ICustomScrollListen private final ResourceLocation resource = new ResourceLocation("customnpcs", "textures/gui/standardbg.png"); - private final EntityPlayer player; + private EntityPlayer player; private GuiCustomScroll scroll; - private final HashMap sideButtons = new HashMap(); + private HashMap sideButtons = new HashMap(); private QuestLogData data = new QuestLogData(); private boolean noQuests = false; private byte questPages = 1; diff --git a/src/main/java/noppes/npcs/client/gui/player/modern/BlurEventHandler.java b/src/main/java/noppes/npcs/client/gui/player/modern/BlurEventHandler.java new file mode 100644 index 000000000..7726d9a3b --- /dev/null +++ b/src/main/java/noppes/npcs/client/gui/player/modern/BlurEventHandler.java @@ -0,0 +1,37 @@ +package noppes.npcs.client.gui.player.modern; + +import com.google.gson.JsonSyntaxException; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.EntityRenderer; +import net.minecraft.client.shader.ShaderGroup; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.client.event.GuiOpenEvent; + +import java.io.IOException; + +public class BlurEventHandler { + @SubscribeEvent + public void onGuiChange(GuiOpenEvent event) { + if (Minecraft.getMinecraft().theWorld != null) { + EntityRenderer er = Minecraft.getMinecraft().entityRenderer; + if (er.getShaderGroup() == null && (event.gui instanceof GuiModernDialogInteract) || (event.gui instanceof GuiModernQuestDialog)) { + loadEffect(er,new ResourceLocation("customnpcs", "shaders/post/blur.json")); + } else if (er.getShaderGroup()!=null && !(event.gui instanceof GuiModernDialogInteract)) { + er.deactivateShader(); + } + } + } + public static void loadEffect(EntityRenderer er, ResourceLocation p_175069_1_) { + if (er.theShaderGroup != null) { + er.theShaderGroup.deleteShaderGroup(); + } + Minecraft mc = Minecraft.getMinecraft(); + try { + er.theShaderGroup = new ShaderGroup(mc.getTextureManager(), mc.getResourceManager(), mc.getFramebuffer(), p_175069_1_); + er.theShaderGroup.createBindFramebuffers(mc.displayWidth, mc.displayHeight); + } catch (IOException | JsonSyntaxException ignored) { + + } + } +} diff --git a/src/main/java/noppes/npcs/client/gui/player/modern/GuiModernDialogInteract.java b/src/main/java/noppes/npcs/client/gui/player/modern/GuiModernDialogInteract.java new file mode 100644 index 000000000..eb9dbb62e --- /dev/null +++ b/src/main/java/noppes/npcs/client/gui/player/modern/GuiModernDialogInteract.java @@ -0,0 +1,426 @@ +package noppes.npcs.client.gui.player.modern; + +import kamkeel.npcs.network.PacketClient; +import kamkeel.npcs.network.packets.player.CheckPlayerValue; +import kamkeel.npcs.network.packets.player.DialogSelectPacket; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.IChatComponent; +import net.minecraft.util.ResourceLocation; +import noppes.npcs.CustomNpcs; +import noppes.npcs.api.handler.data.IDialogImage; +import noppes.npcs.client.ClientProxy; +import noppes.npcs.client.NoppesUtil; +import noppes.npcs.client.TextBlockClient; +import noppes.npcs.client.controllers.MusicController; +import noppes.npcs.client.gui.player.GuiDialogImage; +import noppes.npcs.client.gui.util.GuiNPCInterface; +import noppes.npcs.client.gui.util.IGuiClose; +import noppes.npcs.constants.EnumOptionType; +import noppes.npcs.controllers.data.Dialog; +import noppes.npcs.controllers.data.DialogImage; +import noppes.npcs.controllers.data.DialogOption; +import noppes.npcs.controllers.data.Quest; +import noppes.npcs.entity.EntityNPCInterface; +import org.lwjgl.input.Keyboard; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; + +public class GuiModernDialogInteract extends GuiNPCInterface implements IGuiClose { + private Dialog dialog; + private int selected = 0; + private List lineBlocks = new ArrayList(); + private List options = new ArrayList(); + private int totalRows = 0; + + private ScaledResolution scaledResolution; + + private int optionStart = 0; + + private static int textSpeed = 10; + private static boolean textSoundEnabled = true; + + private int scrollY; + private final ResourceLocation decomposed = new ResourceLocation("customnpcs", "textures/gui/dialog_menu_decomposed.png"); + + private boolean isGrabbed = false; + + private final HashMap dialogImages = new HashMap<>(); + + public GuiModernDialogInteract(EntityNPCInterface npc, Dialog dialog) { + super(npc); + this.dialog = dialog; + + appendDialog(dialog); + ySize = 238; + } + + public void initGui() { + super.initGui(); + isGrabbed = false; + grabMouse(dialog.showWheel); + guiTop = (height - ySize); + calculateRowHeight(); + this.scaledResolution = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight); + this.drawDefaultBackground = dialog.darkenScreen; + setOptionOffset(); + } + + public void setOptionOffset() { + optionStart = scaledResolution.getScaledHeight() - (options.size()) * (ClientProxy.Font.height() + dialog.optionSpaceY) - 20; + } + + public void grabMouse(boolean grab) { + if (grab && !isGrabbed) { + Minecraft.getMinecraft().mouseHelper.grabMouseCursor(); + isGrabbed = true; + } else if (!grab && isGrabbed) { + Minecraft.getMinecraft().mouseHelper.ungrabMouseCursor(); + isGrabbed = false; + } + } + + public void drawLine(int x, int y, int width) { + drawRect(x, y, width, y + 1,0xff000000+ dialog.colorData.getLineColor1()); + drawRect(x, y + 1, width, y + 2, 0xff000000+ dialog.colorData.getLineColor2()); + drawRect(x, y + 2, width, y + 3, 0xff000000+ dialog.colorData.getLineColor3()); + } + + public void drawScreen(int mouseX, int mouseY, float partialTicks) { + GL11.glColor4f(1, 1, 1, 1); + this.drawGradientRect(0, 0, this.width, this.height, 0x66000000, 0x66000000); + super.drawScreen(mouseX, mouseY, partialTicks); + setOptionOffset(); + + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + GL11.glEnable(GL11.GL_ALPHA_TEST); + + GL11.glPushMatrix(); + GL11.glTranslatef(0.0F, 0.5f, 100.065F); + + for (IDialogImage dialogImage : dialog.dialogImages.values()) { + if (dialogImage.getImageType() != 0) + continue; + + GuiDialogImage image; + if (dialogImages.containsKey(dialogImage.getId())) { + image = dialogImages.get(dialogImage.getId()); + } else { + image = new GuiDialogImage((DialogImage) dialogImage); + dialogImages.put(dialogImage.getId(), image); + } + + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0); + GL11.glDisable(GL11.GL_ALPHA_TEST); + + GL11.glTranslatef(image.x,image.y,0.0f); + GL11.glTranslatef(image.alignment % 3 * ((float) (scaledResolution.getScaledWidth()) / 2), (float) (Math.floor((float) (image.alignment / 3)) * ((float) (scaledResolution.getScaledHeight()) / 2)), 0.0F); + image.onRender(mc); + + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_ALPHA_TEST); + } + + GL11.glPushMatrix(); + for (IDialogImage dialogImage : dialog.dialogImages.values()) { + if (dialogImage.getImageType() != 1) + continue; + + GuiDialogImage image; + if (dialogImages.containsKey(dialogImage.getId())) { + image = dialogImages.get(dialogImage.getId()); + } else { + image = new GuiDialogImage((DialogImage) dialogImage); + dialogImages.put(dialogImage.getId(), image); + } + + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0); + GL11.glDisable(GL11.GL_ALPHA_TEST); + + GL11.glTranslatef(image.x,image.y,0.0f); + GL11.glTranslatef(guiLeft + dialog.textOffsetX, optionStart + dialog.textOffsetY - image.height * image.scale, 0.0F); + image.onRender(mc); + + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_ALPHA_TEST); + } + GL11.glPopMatrix(); + if (!dialog.hideNPC) { + float scaleHeight = height / 509f; + float scaleWidth = width / 960f; + drawNpc(npc, -210 + dialog.npcOffsetX + (int) (300 * (1 - scaleWidth)), 350 + dialog.npcOffsetY - (int) (100 * (1 - scaleHeight)), 9.5F * dialog.npcScale * scaleHeight, -20); + } + int textBlockWidth = 700; + int lineCount = getLineCount(dialog.text, textBlockWidth); + int gap = Math.max(16, Math.min((int) (2.6f * (float) lineCount), 32)); + int textPartHeight = 23 + 3 + lineCount * ClientProxy.Font.height() + 2 * gap; + GL11.glPushMatrix(); + GL11.glTranslated(0.0, 0.5, 200.06500244140625); + drawGradientRect(0, height - textPartHeight, this.width, this.height, 0x99000000, 0x99000000); + drawLine(23, height - textPartHeight + 23, width - 23); + GL11.glScalef(1.5f, 1.5f, 1); + drawString(fontRendererObj, npc.getCommandSenderName(), (int) (47 / 1.5), (int) ((height - textPartHeight + 5) / 1.5), dialog.titleColor); + GL11.glScalef(1 / 1.5f, 1 / 1.5f, 1); + drawTextBlock(dialog.text, (width - textBlockWidth) / 2, height - textPartHeight + 23 + 3 + gap, textBlockWidth); + selected = -1; + for (int i = 0; i < this.options.size(); i++) { + int optionHeight = height/2-30 + i * (13 + 6); + int optionNum = options.get(i); + DialogOption option = dialog.options.get(optionNum); + if (mouseX >= width-237 && mouseX <= width-14 && mouseY >= optionHeight && mouseY <= optionHeight + 13) { + selected = i; + } + GL11.glEnable(GL11.GL_BLEND); + Minecraft.getMinecraft().getTextureManager().bindTexture(decomposed); + drawTexturedModalRect(width-233, optionHeight, 0, i == selected ? 13 : 0, 223, 13); + GL11.glDisable(GL11.GL_BLEND); + if (getQuestByOptionId(optionNum) != null) { + drawString(fontRendererObj, "!", width-229, optionHeight + 3, 0x76e85b); + } else { + drawString(fontRendererObj, ">", width-229, optionHeight + 3, -1); + } + drawString(fontRendererObj, option.title, width-221, optionHeight + 3, option.optionColor); + } + GL11.glPopMatrix(); + GL11.glPopMatrix(); + } + + public Quest getQuestByOptionId(int id) { + DialogOption option = dialog.options.get(id); + if (option != null && option.getDialog() != null && option.getDialog().hasQuest()) { + return option.getDialog().getQuest(); + } + return null; + } + + public void drawNpc(EntityNPCInterface entity, int x, int y, float zoomed, int rotation) { + EntityNPCInterface npc = entity; + + float f2 = entity.renderYawOffset; + float f3 = entity.rotationYaw; + float f4 = entity.rotationPitch; + float f5 = entity.prevRotationYawHead; + float f6 = entity.rotationYawHead; + float scale = 1.0F; + if ((double) entity.height > 2.4) { + scale = 2.0F / entity.height; + } + float f7 = (float) (guiLeft + x); + entity.renderYawOffset = 0.0F; + entity.rotationYaw = (float) Math.atan((f7 / 80.0F)) * 40.0F + (float) rotation; + entity.rotationPitch = 0; + entity.rotationYawHead = 0.0F; + entity.prevRotationYawHead = 0.0F; + int orientation = 0; + orientation = npc.ais.orientation; + npc.ais.orientation = rotation; + int visibleName = npc.display.showName; + npc.display.showName = 1; + GL11.glPushMatrix(); + GL11.glTranslatef((float) guiLeft + (float) x, (float) (guiTop + y), 1050.0F); + GL11.glScalef(1.0F, 1.0F, -1.0F); + GL11.glTranslated(0.0, 0.0, 1000.0); + GL11.glScalef(30.0F * scale * zoomed, 30.0F * scale * zoomed, 30.0F * scale * zoomed); + GL11.glRotatef(180.0F, 0, 1, 0); + GL11.glRotatef(180.0F, 0, 0, 1); + GL11.glRotatef(-(float) rotation, 0, 1, 0); + RenderHelper.enableStandardItemLighting(); + RenderManager.instance.playerViewY = 180F; + GL11.glEnable(GL11.GL_DEPTH_TEST); + RenderManager.instance.renderEntityWithPosYaw(npc, 0.0, 0.0, 0.0, 0.0F, 1.0F); + GL11.glPopMatrix(); + entity.renderYawOffset = f2; + entity.rotationYaw = f3; + entity.rotationPitch = f4; + entity.prevRotationYawHead = f5; + entity.rotationYawHead = f6; + npc.ais.orientation = orientation; + npc.display.showName=visibleName; + RenderHelper.disableStandardItemLighting(); + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit); + GL11.glDisable(GL11.GL_TEXTURE_2D); + OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit); + } + + public void drawWorldBackground(int p_238651_2_) { + } + + public void drawString(FontRenderer fontRendererIn, String text, int x, int y, int color) { + ClientProxy.Font.drawString(text, x, y, color); + } + + @Override + public void keyTyped(char c, int i) { + if (i == mc.gameSettings.keyBindForward.getKeyCode() || i == Keyboard.KEY_UP) { + if (dialog.showWheel) { + selected--; + } else { + selected++; + } + } + if (i == mc.gameSettings.keyBindBack.getKeyCode() || i == Keyboard.KEY_DOWN) { + if (dialog.showWheel) { + selected++; + } else { + selected--; + } + } + + if (i == mc.gameSettings.keyBindForward.getKeyCode() || i == Keyboard.KEY_LEFT) { + textSpeed--; + if (textSpeed < 1) { + textSpeed = 1; + } + } + if (i == mc.gameSettings.keyBindBack.getKeyCode() || i == Keyboard.KEY_RIGHT) { + textSpeed++; + } + + if (i == mc.gameSettings.keyBindJump.getKeyCode() || i == Keyboard.KEY_SPACE) { + textSoundEnabled = !textSoundEnabled; + } + + if (i == mc.gameSettings.keyBindBack.getKeyCode() || i == 201 && scrollY < (totalRows - 2) * ClientProxy.Font.height()) {//Page up + scrollY += ClientProxy.Font.height() * 2; + } + if (i == mc.gameSettings.keyBindBack.getKeyCode() || i == 209 && scrollY > 0) {//Page down + scrollY -= ClientProxy.Font.height() * 2; + } + + if (i == 28) { + handleDialogSelection(); + } + if (closeOnEsc && (i == 1 || isInventoryKey(i))) { + PacketClient.sendClient(new DialogSelectPacket(dialog.id, -1)); + closed(); + close(); + } + super.keyTyped(c, i); + } + + @Override + public void mouseClicked(int i, int j, int k) { + if (selected == -1 && options.isEmpty() || selected >= 0) { + scrollY = 0; + handleDialogSelection(); + } + } + + private void handleDialogSelection() { + int optionId = -1; + if (dialog.showWheel) + optionId = selected; + else if (!options.isEmpty()) + optionId = options.get(selected); + if(getQuestByOptionId(optionId) == null){ + PacketClient.sendClient(new DialogSelectPacket(dialog.id, optionId)); + }else{ + CustomNpcs.proxy.openGui(player, new GuiModernQuestDialog(npc,getQuestByOptionId(optionId),dialog,optionId)); + } + + if (dialog == null || !dialog.hasOtherOptions() || options.isEmpty()) { + closed(); + close(); + return; + } + DialogOption option = dialog.options.get(optionId); + if (option == null || option.optionType != EnumOptionType.DialogOption) { + closed(); + close(); + return; + } + + if (!dialog.showPreviousBlocks) { + lineBlocks.clear(); + } + lineBlocks.add(new TextBlockClient(player.getDisplayName(), option.title, dialog.textWidth, option.optionColor, player, npc)); + + calculateRowHeight(); + + NoppesUtil.clickSound(); + } + + private void closed() { + grabMouse(false); + PacketClient.sendClient(new CheckPlayerValue(CheckPlayerValue.Type.CheckQuestCompletion)); + } + + public void save() { + + } + + public void appendDialog(Dialog dialog) { + closeOnEsc = !dialog.disableEsc; + this.dialogImages.clear(); + this.dialog = dialog; + this.options = new ArrayList(); + + if (dialog.sound != null && !dialog.sound.isEmpty()) { + MusicController.Instance.stopMusic(); + MusicController.Instance.playSound(dialog.sound, (float) npc.posX, (float) npc.posY, (float) npc.posZ); + } + + if (!dialog.showPreviousBlocks) { + lineBlocks.clear(); + } + lineBlocks.add(new TextBlockClient(npc, dialog, player, npc)); + + for (int slot : dialog.options.keySet()) { + DialogOption option = dialog.options.get(slot); + if (option == null || option.optionType == EnumOptionType.Disabled) + continue; + options.add(slot); + } + calculateRowHeight(); + + grabMouse(dialog.showWheel); + } + + private void calculateRowHeight() { + totalRows = 0; + for (TextBlockClient block : lineBlocks) { + totalRows += block.lines.size() + 1; + } + } + + public void drawTextBlock(String text, int x, int y, int width) { + TextBlockClient block = new TextBlockClient("", text, width, -1, player, npc); + + int count = 0; + for (Iterator var9 = block.lines.iterator(); var9.hasNext(); count++) { + IChatComponent line = (IChatComponent) var9.next(); + int height = y + count * ClientProxy.Font.height(); + drawCenteredString(fontRendererObj, line.getFormattedText(), x + width / 2, height, dialog.color); + } + } + + public void drawCenteredString(FontRenderer p_73732_1_, String p_73732_2_, int p_73732_3_, int p_73732_4_, int p_73732_5_) { + ClientProxy.Font.drawString(p_73732_2_, p_73732_3_ - ClientProxy.Font.width(p_73732_2_) / 2, p_73732_4_, p_73732_5_); + } + + public int getLineCount(String text, int width) { + TextBlockClient block = new TextBlockClient("", text, width, -1, player, npc); + return block.lines.size(); + } + + @Override + public void setClose(int i, NBTTagCompound data) { + grabMouse(false); + } +} diff --git a/src/main/java/noppes/npcs/client/gui/player/modern/GuiModernQuestDialog.java b/src/main/java/noppes/npcs/client/gui/player/modern/GuiModernQuestDialog.java new file mode 100644 index 000000000..7d89fd8e9 --- /dev/null +++ b/src/main/java/noppes/npcs/client/gui/player/modern/GuiModernQuestDialog.java @@ -0,0 +1,405 @@ +package noppes.npcs.client.gui.player.modern; + +import kamkeel.npcs.network.PacketClient; +import kamkeel.npcs.network.packets.player.CheckPlayerValue; +import kamkeel.npcs.network.packets.player.DialogSelectPacket; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.IChatComponent; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; +import noppes.npcs.CustomNpcs; +import noppes.npcs.api.handler.data.IDialogImage; +import noppes.npcs.api.handler.data.IQuestObjective; +import noppes.npcs.api.item.IItemStack; +import noppes.npcs.client.ClientProxy; +import noppes.npcs.client.TextBlockClient; +import noppes.npcs.client.gui.player.GuiDialogImage; +import noppes.npcs.client.gui.player.GuiDialogInteract; +import noppes.npcs.client.gui.util.GuiNPCInterface; +import noppes.npcs.client.gui.util.GuiNpcButton; +import noppes.npcs.client.gui.util.GuiTexturedButton; +import noppes.npcs.client.gui.util.IGuiClose; +import noppes.npcs.config.ConfigExperimental; +import noppes.npcs.controllers.FactionController; +import noppes.npcs.controllers.data.*; +import noppes.npcs.entity.EntityNPCInterface; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; + +import java.util.*; + +public class GuiModernQuestDialog extends GuiNPCInterface implements IGuiClose { + private int selected = 0; + private List lineBlocks = new ArrayList(); + private List options = new ArrayList(); + private int totalRows = 0; + + private ScaledResolution scaledResolution; + + private int optionStart = 0; + + private static int textSpeed = 10; + private static boolean textSoundEnabled = true; + + private int scrollY; + private final ResourceLocation decomposed = new ResourceLocation("customnpcs", "textures/gui/dialog_menu_decomposed.png"); + + private boolean isGrabbed = false; + + private final HashMap dialogImages = new HashMap<>(); + private Dialog prevDialog; + private int optionId; + private Quest quest; + + public GuiModernQuestDialog(EntityNPCInterface npc, Quest quest, Dialog prevDialog, int optionId) { + super(npc); + ySize = 238; + this.prevDialog = prevDialog; + this.quest = quest; + this.optionId = optionId; + } + + public void initGui() { + super.initGui(); + isGrabbed = false; + guiTop = (height - ySize); + calculateRowHeight(); + this.scaledResolution = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight); + this.drawDefaultBackground = prevDialog.darkenScreen; + setOptionOffset(); + addButton(new GuiTexturedButton(0,"questgui.reject",720,326,156,40,decomposed.toString(),72,15)); + addButton(new GuiTexturedButton(1,"questgui.accept",812,326,156,40,decomposed.toString(),72,15)); + } + + public void setOptionOffset() { + optionStart = scaledResolution.getScaledHeight() - (options.size()) * (ClientProxy.Font.height() + prevDialog.optionSpaceY) - 20; + } + + public void grabMouse(boolean grab) { + if (grab && !isGrabbed) { + Minecraft.getMinecraft().mouseHelper.grabMouseCursor(); + isGrabbed = true; + } else if (!grab && isGrabbed) { + Minecraft.getMinecraft().mouseHelper.ungrabMouseCursor(); + isGrabbed = false; + } + } + + public void drawLine(int x, int y, int width) { + drawRect(x, y, width, y + 1,0xff000000+ prevDialog.colorData.getLineColor1());//0xff8d3800);// + drawRect(x, y + 1, width, y + 2, 0xff000000+ prevDialog.colorData.getLineColor2()); //0xfffea53b);// + drawRect(x, y + 2, width, y + 3, 0xff000000+ prevDialog.colorData.getLineColor3()); //0xff8d3800); + } + + public void drawScreen(int mouseX, int mouseY, float partialTicks) { + GL11.glColor4f(1, 1, 1, 1); + this.drawGradientRect(0, 0, this.width, this.height, 0x66000000, 0x66000000); + if (!prevDialog.hideNPC) { + float scaleHeight = height/509f; + float scaleWidth = width/960f; + drawNpc(npc, -210+prevDialog.npcOffsetX+(int)(300*(1-scaleWidth)), 350+prevDialog.npcOffsetY-(int)(100*(1-scaleHeight)), 9.5F*prevDialog.npcScale*scaleHeight, -20); + } + setOptionOffset(); + + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + GL11.glEnable(GL11.GL_ALPHA_TEST); + + GL11.glPushMatrix(); + GL11.glTranslatef(0.0F, 0.5f, 100.065F); + + for (IDialogImage dialogImage : prevDialog.dialogImages.values()) { + if (dialogImage.getImageType() != 0) + continue; + + GuiDialogImage image; + if (dialogImages.containsKey(dialogImage.getId())) { + image = dialogImages.get(dialogImage.getId()); + } else { + image = new GuiDialogImage((DialogImage) dialogImage); + dialogImages.put(dialogImage.getId(), image); + } + + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0); + GL11.glDisable(GL11.GL_ALPHA_TEST); + + GL11.glTranslatef(image.alignment % 3 * ((float) (scaledResolution.getScaledWidth()) / 2), (float) (Math.floor((float) (image.alignment / 3)) * ((float) (scaledResolution.getScaledHeight()) / 2)), 0.0F); + image.onRender(mc); + + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_ALPHA_TEST); + } + + GL11.glPushMatrix(); + for (IDialogImage dialogImage : prevDialog.dialogImages.values()) { + if (dialogImage.getImageType() != 1) + continue; + + GuiDialogImage image; + if (dialogImages.containsKey(dialogImage.getId())) { + image = dialogImages.get(dialogImage.getId()); + } else { + image = new GuiDialogImage((DialogImage) dialogImage); + dialogImages.put(dialogImage.getId(), image); + } + + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0); + GL11.glDisable(GL11.GL_ALPHA_TEST); + + GL11.glTranslatef(guiLeft + prevDialog.textOffsetX, optionStart + prevDialog.textOffsetY - image.height * image.scale, 0.0F); + image.onRender(mc); + + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_ALPHA_TEST); + } + GL11.glPopMatrix(); + int textBlockWidth = 700; + String takeQuestString=translate("questgui.doyouaccept"); + int lineCount = getLineCount(takeQuestString, textBlockWidth); + int gap = Math.max(16, Math.min((int) (2.6f * (float) lineCount), 32)); + int textPartHeight = 23 + 3 + lineCount * ClientProxy.Font.height() + 2 * gap; + GL11.glPushMatrix(); + GL11.glTranslated(0.0, 0.5, 200.06500244140625); + drawGradientRect(0, height - textPartHeight, this.width, this.height, 0x99000000, 0x99000000); + drawLine(23, height - textPartHeight + 23, width - 23); + GL11.glScalef(1.5f, 1.5f, 1); + drawString(fontRendererObj, npc.getCommandSenderName(), (int) (47 / 1.5), (int) ((height - textPartHeight + 5) / 1.5), prevDialog.titleColor); + GL11.glScalef(1 / 1.5f, 1 / 1.5f, 1); + drawTextBlock(takeQuestString, (width - textBlockWidth) / 2, height - textPartHeight + 23 + 3 + gap, textBlockWidth,-1); + + Map activeQuests = PlayerData.get(this.player).questData.activeQuests; + boolean hadQuest = activeQuests.containsKey(quest.id); + activeQuests.put(quest.id,new QuestData(quest)); + StringBuilder objectiveString = new StringBuilder(); + String[] questType = {translate("questgui.bringitems"), translate("questgui.readdialog"), + translate("questgui.killmobs"), translate("questgui.findlocation"), translate("questgui.defeat")}; + for (IQuestObjective objective : quest.questInterface.getObjectives(this.player)) { + if(objective!=null) + objectiveString.append("- " + questType[quest.getType()] + ": ").append(objective.getText()).append("\n"); + } + if(!hadQuest) + activeQuests.remove(quest.id); + int questLineCount = getLineCount(quest.logText, 180); + int objectivesLineCount = getLineCount(objectiveString.toString(),180); + int topToTextBottom = (int)(height*0.08) + 38+questLineCount*ClientProxy.Font.height()+20; + int topToObjectivesBottom = topToTextBottom+19+objectivesLineCount*ClientProxy.Font.height()+14; + int rewardCount = 0; + + List facIDs = new ArrayList(); + for (Integer facID : new Integer[]{quest.factionOptions.factionId, quest.factionOptions.faction2Id}) { + if (facID != -1) facIDs.add(facID); + } + for (IItemStack reward : quest.getRewards().getItems()) { + if (reward!=null && !(reward.getMCItemStack()==null)) rewardCount++; + } + int topToRewardsBottom = topToObjectivesBottom+(rewardCount==0?0:(36+13)); + int topToExpBottom = topToRewardsBottom+(quest.rewardExp==0?0:(12)); + int topToFactionBottom = topToExpBottom + (facIDs.size() * 15); + int questBlockHeight = topToFactionBottom+28; + drawGradientRect( width-285, (int)(height*0.08), width-285+260, questBlockHeight, 0x99000000, 0x99000000); + GL11.glScalef(1.5f, 1.5f, 1); + drawString(fontRendererObj, quest.getName(), (int) ((width-268) / 1.5), (int) ((height*0.095) / 1.5), -1); + GL11.glScalef(1 / 1.5f, 1 / 1.5f, 1); + drawLine(width-274,(int)(height*0.13),width-285+260-11); + drawTextBlock(quest.logText, width-245, (int)(height*0.157), 180,0xb8b8b8); + drawString(fontRendererObj, translate("questgui.objectives"),width-270, topToTextBottom, -1); + drawLeftAllignedTextBlock(objectiveString.toString(), width-255, topToTextBottom+12, 180,0xb8b8b8); + if(rewardCount!=0) + drawString(fontRendererObj, translate("questgui.rewards"),width-270, topToObjectivesBottom, -1); + for(int i=0;i> 16 & 0xff) / 255f, (color >> 8 & 0xff) / 255f, (color & 0xff) / 255f, 1); + drawTexturedModalRect(width-270+26*i, topToObjectivesBottom+16, 0, 27, 24, 24); + + itemRender.renderItemAndEffectIntoGUI(fontRendererObj,Minecraft.getMinecraft().renderEngine, rewardStack, width-266+26*i, topToObjectivesBottom+20); + itemRender.renderItemOverlayIntoGUI(fontRendererObj,Minecraft.getMinecraft().renderEngine, rewardStack, width-266+26*i, topToObjectivesBottom+20, ""+rewardStack.stackSize); + } + GL11.glDisable(GL11.GL_LIGHTING); + if(quest.rewardExp!=0) { + drawString(fontRendererObj, translate("questgui.experience"), width-270, topToRewardsBottom, 0xb8b8b8); + int expPosX = width-270+ClientProxy.Font.width(translate("questgui.experience")); + drawString(fontRendererObj, ""+quest.rewardExp, expPosX, topToRewardsBottom, -1); + int expSymbolPosX = expPosX+ClientProxy.Font.width(""+quest.rewardExp+" "); + Minecraft.getMinecraft().getTextureManager().bindTexture(decomposed); + drawTexturedModalRect(expSymbolPosX, topToRewardsBottom, 26, 27, 8, 8); + } + int fac1ID = quest.factionOptions.factionId; + if (fac1ID != -1) { + String fac1Name = FactionController.getInstance().getFaction(fac1ID).getName(); + String fac1Color = (quest.factionOptions.decreaseFactionPoints) ? "§c-" : "§a+"; + int fac1Point = quest.factionOptions.factionPoints; + int facIDIndex = facIDs.indexOf(fac1ID); + drawString(fontRendererObj, fac1Name + " " + fac1Color + fac1Point, width-270, topToExpBottom + (facIDIndex * 12), 0xb8b8b8); + } + int fac2ID = quest.factionOptions.faction2Id; + if (fac2ID != -1) { + String fac2Name = FactionController.getInstance().getFaction(fac2ID).getName(); + String fac2Color = (quest.factionOptions.decreaseFaction2Points) ? "§c-" : "§a+"; + int fac2Point = quest.factionOptions.faction2Points; + int facIDIndex = facIDs.indexOf(fac2ID); + drawString(fontRendererObj, fac2Name + " " + fac2Color + fac2Point, width-270, topToExpBottom + (facIDIndex * 12), 0xb8b8b8); + } + this.buttons.get(0).xPosition=width-240; + this.buttons.get(1).xPosition=width-148; + this.buttons.get(0).yPosition=topToFactionBottom; + this.buttons.get(1).yPosition=topToFactionBottom; + ((GuiTexturedButton)this.buttons.get(0)).scale=0.5f; + ((GuiTexturedButton)this.buttons.get(1)).scale=0.5f; + ((GuiTexturedButton)this.buttons.get(0)).color=prevDialog.colorData.getButtonRejectColor(); + ((GuiTexturedButton)this.buttons.get(1)).color=prevDialog.colorData.getButtonAcceptColor(); + super.drawScreen(mouseX, mouseY, partialTicks); + GL11.glColor4f(1,1,1,1); + GL11.glPopMatrix(); + GL11.glPopMatrix(); + } + + public String translate(String key){ + return StatCollector.translateToLocal(key); + } + + public void drawNpc(EntityNPCInterface entity, int x, int y, float zoomed, int rotation) { + EntityNPCInterface npc = entity; + + float f2 = entity.renderYawOffset; + float f3 = entity.rotationYaw; + float f4 = entity.rotationPitch; + float f5 = entity.prevRotationYawHead; + float f6 = entity.rotationYawHead; + float scale = 1.0F; + if ((double) entity.height > 2.4) { + scale = 2.0F / entity.height; + } + float f7 = (float) (guiLeft + x); + float f8 = (float) (guiTop + y) - 50.0F * scale * zoomed; + entity.renderYawOffset = 0.0F; + entity.rotationYaw = (float) Math.atan((double) (f7 / 80.0F)) * 40.0F + (float) rotation; + entity.rotationPitch = 0; + entity.rotationYawHead = 0.0F; + entity.prevRotationYawHead = 0.0F; + int orientation = 0; + orientation = npc.ais.orientation; + npc.ais.orientation = rotation; + int visibleName = npc.display.showName; + npc.display.showName = 1; + GL11.glPushMatrix(); + GL11.glTranslatef((float) guiLeft + (float) x, (float) (guiTop + y), 1050.0F); + GL11.glScalef(1.0F, 1.0F, -1.0F); + GL11.glTranslated(0.0, 0.0, 1000.0); + GL11.glScalef(30.0F * scale * zoomed, 30.0F * scale * zoomed, 30.0F * scale * zoomed); + GL11.glRotatef(180.0F, 0, 1, 0); + GL11.glRotatef(180.0F, 0, 0, 1); + GL11.glRotatef(-(float) rotation, 0, 1, 0); + RenderHelper.enableStandardItemLighting(); + RenderManager.instance.playerViewY = 180F; + GL11.glEnable(GL11.GL_DEPTH_TEST); + RenderManager.instance.renderEntityWithPosYaw(npc, 0.0, 0.0, 0.0, 0.0F, 1.0F); + GL11.glPopMatrix(); + entity.renderYawOffset = f2; + entity.rotationYaw = f3; + entity.rotationPitch = f4; + entity.prevRotationYawHead = f5; + entity.rotationYawHead = f6; + npc.ais.orientation = orientation; + npc.display.showName=visibleName; + RenderHelper.disableStandardItemLighting(); + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit); + GL11.glDisable(GL11.GL_TEXTURE_2D); + OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit); + } + + public void drawWorldBackground(int p_238651_2_) { + } + + public void drawString(FontRenderer fontRendererIn, String text, int x, int y, int color) { + ClientProxy.Font.drawString(text, x, y, color); + } + @Override + protected void actionPerformed(GuiButton guibutton) { + GuiNpcButton button = (GuiNpcButton) guibutton; + if(button.id==0){ + PacketClient.sendClient(new DialogSelectPacket(prevDialog.id, -1)); + closed(); + close(); + }else if(button.id==1){ + if(optionId!=-2){ + PacketClient.sendClient(new DialogSelectPacket(prevDialog.id, optionId)); + }else{ + if(ConfigExperimental.ModernGuiSystem) { + CustomNpcs.proxy.openGui(player, new GuiModernDialogInteract(npc, prevDialog)); + } + else { + CustomNpcs.proxy.openGui(player, new GuiDialogInteract(npc, prevDialog)); + } + } + + } + } + + private void closed() { + grabMouse(false); + PacketClient.sendClient(new CheckPlayerValue(CheckPlayerValue.Type.CheckQuestCompletion)); + } + + public void save() { + + } + + private void calculateRowHeight() { + totalRows = 0; + for (TextBlockClient block : lineBlocks) { + totalRows += block.lines.size() + 1; + } + } + + public void drawTextBlock(String text, int x, int y, int width, int color) { + TextBlockClient block = new TextBlockClient("", text, width, -1, player, npc); + + int count = 0; + for (Iterator var9 = block.lines.iterator(); var9.hasNext(); count++) { + IChatComponent line = (IChatComponent) var9.next(); + int height = y + count * ClientProxy.Font.height(); + drawCenteredString(fontRendererObj, line.getFormattedText(), x + width / 2, height, color); + } + } + public void drawLeftAllignedTextBlock(String text, int x, int y, int width, int color) { + TextBlockClient block = new TextBlockClient("", text, width, -1, player, npc); + + int count = 0; + for (Iterator var9 = block.lines.iterator(); var9.hasNext(); count++) { + IChatComponent line = (IChatComponent) var9.next(); + int height = y + count * ClientProxy.Font.height(); + drawString(fontRendererObj, line.getFormattedText(), x, height, color); + } + } + + public void drawCenteredString(FontRenderer p_73732_1_, String p_73732_2_, int p_73732_3_, int p_73732_4_, int p_73732_5_) { + ClientProxy.Font.drawString(p_73732_2_, p_73732_3_ - ClientProxy.Font.width(p_73732_2_) / 2, p_73732_4_, p_73732_5_); + } + + public int getLineCount(String text, int width) { + TextBlockClient block = new TextBlockClient("", text, width, -1, player, npc); + return block.lines.size(); + } + + @Override + public void setClose(int i, NBTTagCompound data) { + grabMouse(false); + } +} diff --git a/src/main/java/noppes/npcs/client/gui/questtypes/GuiNpcQuestTypeDialog.java b/src/main/java/noppes/npcs/client/gui/questtypes/GuiNpcQuestTypeDialog.java index a5d5cc487..1c8f2dcb9 100644 --- a/src/main/java/noppes/npcs/client/gui/questtypes/GuiNpcQuestTypeDialog.java +++ b/src/main/java/noppes/npcs/client/gui/questtypes/GuiNpcQuestTypeDialog.java @@ -17,10 +17,10 @@ import noppes.npcs.quests.QuestDialog; import java.util.HashMap; public class GuiNpcQuestTypeDialog extends SubGuiInterface implements GuiSelectionListener, IGuiData { - private final GuiScreen parent; - private final QuestDialog quest; + private GuiScreen parent; + private QuestDialog quest; - private final HashMap data = new HashMap(); + private HashMap data = new HashMap(); public GuiNpcQuestTypeDialog(EntityNPCInterface npc, Quest q, GuiScreen parent) { this.npc = npc; diff --git a/src/main/java/noppes/npcs/client/gui/questtypes/GuiNpcQuestTypeItem.java b/src/main/java/noppes/npcs/client/gui/questtypes/GuiNpcQuestTypeItem.java index 5be5e7c03..d57f6f12d 100644 --- a/src/main/java/noppes/npcs/client/gui/questtypes/GuiNpcQuestTypeItem.java +++ b/src/main/java/noppes/npcs/client/gui/questtypes/GuiNpcQuestTypeItem.java @@ -12,7 +12,7 @@ import noppes.npcs.quests.QuestItem; import org.lwjgl.opengl.GL11; public class GuiNpcQuestTypeItem extends GuiContainerNPCInterface implements ITextfieldListener { - private final Quest quest; + private Quest quest; private static final ResourceLocation field_110422_t = new ResourceLocation("customnpcs", "textures/gui/followersetup.png"); public GuiNpcQuestTypeItem(EntityNPCInterface npc, ContainerNpcQuestTypeItem container) { diff --git a/src/main/java/noppes/npcs/client/gui/questtypes/GuiNpcQuestTypeKill.java b/src/main/java/noppes/npcs/client/gui/questtypes/GuiNpcQuestTypeKill.java index 3493d94b1..bf4829130 100644 --- a/src/main/java/noppes/npcs/client/gui/questtypes/GuiNpcQuestTypeKill.java +++ b/src/main/java/noppes/npcs/client/gui/questtypes/GuiNpcQuestTypeKill.java @@ -16,10 +16,10 @@ import java.util.Map; import java.util.TreeMap; public class GuiNpcQuestTypeKill extends SubGuiInterface implements ITextfieldListener, ICustomScrollListener { - private final GuiScreen parent; + private GuiScreen parent; private GuiCustomScroll scroll; - private final QuestKill quest; + private QuestKill quest; private GuiNpcTextField lastSelected; @@ -65,7 +65,7 @@ public class GuiNpcQuestTypeKill extends SubGuiInterface implements ITextfieldLi for (Object name : data.keySet()) { Class c = (Class) data.get(name); try { - if (EntityLivingBase.class.isAssignableFrom(c) && !EntityNPCInterface.class.isAssignableFrom(c) && c.getConstructor(World.class) != null && !Modifier.isAbstract(c.getModifiers())) + if (EntityLivingBase.class.isAssignableFrom(c) && !EntityNPCInterface.class.isAssignableFrom(c) && c.getConstructor(new Class[]{World.class}) != null && !Modifier.isAbstract(c.getModifiers())) list.add(name.toString()); } catch (SecurityException e) { e.printStackTrace(); diff --git a/src/main/java/noppes/npcs/client/gui/questtypes/GuiNpcQuestTypeLocation.java b/src/main/java/noppes/npcs/client/gui/questtypes/GuiNpcQuestTypeLocation.java index 998059bcc..4afbc1040 100644 --- a/src/main/java/noppes/npcs/client/gui/questtypes/GuiNpcQuestTypeLocation.java +++ b/src/main/java/noppes/npcs/client/gui/questtypes/GuiNpcQuestTypeLocation.java @@ -8,9 +8,9 @@ import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.quests.QuestLocation; public class GuiNpcQuestTypeLocation extends SubGuiInterface implements ITextfieldListener { - private final GuiScreen parent; + private GuiScreen parent; - private final QuestLocation quest; + private QuestLocation quest; public GuiNpcQuestTypeLocation(EntityNPCInterface npc, Quest q, GuiScreen parent) { diff --git a/src/main/java/noppes/npcs/client/gui/questtypes/GuiNpcQuestTypeManual.java b/src/main/java/noppes/npcs/client/gui/questtypes/GuiNpcQuestTypeManual.java index 089da723d..4c4730888 100644 --- a/src/main/java/noppes/npcs/client/gui/questtypes/GuiNpcQuestTypeManual.java +++ b/src/main/java/noppes/npcs/client/gui/questtypes/GuiNpcQuestTypeManual.java @@ -10,9 +10,9 @@ import noppes.npcs.quests.QuestManual; import java.util.TreeMap; public class GuiNpcQuestTypeManual extends SubGuiInterface implements ITextfieldListener { - private final GuiScreen parent; + private GuiScreen parent; - private final QuestManual quest; + private QuestManual quest; private GuiNpcTextField lastSelected; diff --git a/src/main/java/noppes/npcs/client/gui/roles/GuiNpcBankSetup.java b/src/main/java/noppes/npcs/client/gui/roles/GuiNpcBankSetup.java index 85fea3bb6..db909ba52 100644 --- a/src/main/java/noppes/npcs/client/gui/roles/GuiNpcBankSetup.java +++ b/src/main/java/noppes/npcs/client/gui/roles/GuiNpcBankSetup.java @@ -21,7 +21,7 @@ import java.util.Vector; public class GuiNpcBankSetup extends GuiNPCInterface2 implements IScrollData, ICustomScrollListener { private GuiCustomScroll scroll; private HashMap data = new HashMap(); - private final RoleBank role; + private RoleBank role; public GuiNpcBankSetup(EntityNPCInterface npc) { super(npc); diff --git a/src/main/java/noppes/npcs/client/gui/roles/GuiNpcBard.java b/src/main/java/noppes/npcs/client/gui/roles/GuiNpcBard.java index 3d23b6247..1a44021cc 100644 --- a/src/main/java/noppes/npcs/client/gui/roles/GuiNpcBard.java +++ b/src/main/java/noppes/npcs/client/gui/roles/GuiNpcBard.java @@ -9,7 +9,7 @@ import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.roles.JobBard; public class GuiNpcBard extends GuiNPCInterface2 implements ISubGuiListener { - private final JobBard job; + private JobBard job; public GuiNpcBard(EntityNPCInterface npc) { super(npc); diff --git a/src/main/java/noppes/npcs/client/gui/roles/GuiNpcCompanion.java b/src/main/java/noppes/npcs/client/gui/roles/GuiNpcCompanion.java index e40e95e9b..f35532ec3 100644 --- a/src/main/java/noppes/npcs/client/gui/roles/GuiNpcCompanion.java +++ b/src/main/java/noppes/npcs/client/gui/roles/GuiNpcCompanion.java @@ -16,8 +16,8 @@ import java.util.ArrayList; import java.util.List; public class GuiNpcCompanion extends GuiNPCInterface2 implements ITextfieldListener, ISliderListener { - private final RoleCompanion role; - private final List talents = new ArrayList(); + private RoleCompanion role; + private List talents = new ArrayList(); public GuiNpcCompanion(EntityNPCInterface npc) { super(npc); diff --git a/src/main/java/noppes/npcs/client/gui/roles/GuiNpcConversation.java b/src/main/java/noppes/npcs/client/gui/roles/GuiNpcConversation.java index 486590691..546125193 100644 --- a/src/main/java/noppes/npcs/client/gui/roles/GuiNpcConversation.java +++ b/src/main/java/noppes/npcs/client/gui/roles/GuiNpcConversation.java @@ -10,7 +10,7 @@ import noppes.npcs.roles.JobConversation; import noppes.npcs.roles.JobConversation.ConversationLine; public class GuiNpcConversation extends GuiNPCInterface2 implements ITextfieldListener, GuiSelectionListener { - private final JobConversation job; + private JobConversation job; private int slot = -1; diff --git a/src/main/java/noppes/npcs/client/gui/roles/GuiNpcFollowerJob.java b/src/main/java/noppes/npcs/client/gui/roles/GuiNpcFollowerJob.java index 83eae0076..c41b728c4 100644 --- a/src/main/java/noppes/npcs/client/gui/roles/GuiNpcFollowerJob.java +++ b/src/main/java/noppes/npcs/client/gui/roles/GuiNpcFollowerJob.java @@ -9,7 +9,7 @@ import java.util.ArrayList; import java.util.List; public class GuiNpcFollowerJob extends GuiNPCInterface2 implements ICustomScrollListener { - private final JobFollower job; + private JobFollower job; private GuiCustomScroll scroll; public GuiNpcFollowerJob(EntityNPCInterface npc) { diff --git a/src/main/java/noppes/npcs/client/gui/roles/GuiNpcFollowerSetup.java b/src/main/java/noppes/npcs/client/gui/roles/GuiNpcFollowerSetup.java index da198d72b..2f18bdbff 100644 --- a/src/main/java/noppes/npcs/client/gui/roles/GuiNpcFollowerSetup.java +++ b/src/main/java/noppes/npcs/client/gui/roles/GuiNpcFollowerSetup.java @@ -15,7 +15,7 @@ import java.util.HashMap; public class GuiNpcFollowerSetup extends GuiContainerNPCInterface2 { - private final RoleFollower role; + private RoleFollower role; private static final ResourceLocation field_110422_t = new ResourceLocation("textures/gui/followersetup.png"); public GuiNpcFollowerSetup(EntityNPCInterface npc, ContainerNPCFollowerSetup container) { diff --git a/src/main/java/noppes/npcs/client/gui/roles/GuiNpcGuard.java b/src/main/java/noppes/npcs/client/gui/roles/GuiNpcGuard.java index a5579a2fc..215d4ae77 100644 --- a/src/main/java/noppes/npcs/client/gui/roles/GuiNpcGuard.java +++ b/src/main/java/noppes/npcs/client/gui/roles/GuiNpcGuard.java @@ -15,7 +15,7 @@ import java.util.ArrayList; import java.util.List; public class GuiNpcGuard extends GuiNPCInterface2 { - private final JobGuard role; + private JobGuard role; private GuiCustomScroll scroll1; private GuiCustomScroll scroll2; diff --git a/src/main/java/noppes/npcs/client/gui/roles/GuiNpcHealer.java b/src/main/java/noppes/npcs/client/gui/roles/GuiNpcHealer.java index 3c6637250..1ea3d5ad6 100644 --- a/src/main/java/noppes/npcs/client/gui/roles/GuiNpcHealer.java +++ b/src/main/java/noppes/npcs/client/gui/roles/GuiNpcHealer.java @@ -8,7 +8,7 @@ import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.roles.JobHealer; public class GuiNpcHealer extends GuiNPCInterface2 { - private final JobHealer job; + private JobHealer job; public GuiNpcHealer(EntityNPCInterface npc) { super(npc); diff --git a/src/main/java/noppes/npcs/client/gui/roles/GuiNpcItemGiver.java b/src/main/java/noppes/npcs/client/gui/roles/GuiNpcItemGiver.java index 6ef35229e..11ae9440e 100644 --- a/src/main/java/noppes/npcs/client/gui/roles/GuiNpcItemGiver.java +++ b/src/main/java/noppes/npcs/client/gui/roles/GuiNpcItemGiver.java @@ -15,7 +15,7 @@ import java.util.ArrayList; import java.util.List; public class GuiNpcItemGiver extends GuiContainerNPCInterface2 { - private final JobItemGiver role; + private JobItemGiver role; public GuiNpcItemGiver(EntityNPCInterface npc, ContainerNpcItemGiver container) { super(npc, container); diff --git a/src/main/java/noppes/npcs/client/gui/roles/GuiNpcSpawner.java b/src/main/java/noppes/npcs/client/gui/roles/GuiNpcSpawner.java index bf13321de..0901b38b2 100644 --- a/src/main/java/noppes/npcs/client/gui/roles/GuiNpcSpawner.java +++ b/src/main/java/noppes/npcs/client/gui/roles/GuiNpcSpawner.java @@ -14,7 +14,7 @@ import noppes.npcs.roles.JobSpawner; public class GuiNpcSpawner extends GuiNPCInterface2 implements ITextfieldListener, IGuiData { - private final JobSpawner job; + private JobSpawner job; private int slot = -1; diff --git a/src/main/java/noppes/npcs/client/gui/roles/GuiNpcTraderSetup.java b/src/main/java/noppes/npcs/client/gui/roles/GuiNpcTraderSetup.java index 64ec5fc88..4d9729982 100644 --- a/src/main/java/noppes/npcs/client/gui/roles/GuiNpcTraderSetup.java +++ b/src/main/java/noppes/npcs/client/gui/roles/GuiNpcTraderSetup.java @@ -16,7 +16,7 @@ import org.lwjgl.opengl.GL11; public class GuiNpcTraderSetup extends GuiContainerNPCInterface2 implements ITextfieldListener { private final ResourceLocation slot = new ResourceLocation("customnpcs", "textures/gui/slot.png"); - private final RoleTrader role; + private RoleTrader role; public GuiNpcTraderSetup(EntityNPCInterface npc, ContainerNPCTraderSetup container) { super(npc, container); diff --git a/src/main/java/noppes/npcs/client/gui/script/EventGuiScriptList.java b/src/main/java/noppes/npcs/client/gui/script/EventGuiScriptList.java index 61930aa5a..530a3a2be 100644 --- a/src/main/java/noppes/npcs/client/gui/script/EventGuiScriptList.java +++ b/src/main/java/noppes/npcs/client/gui/script/EventGuiScriptList.java @@ -14,8 +14,8 @@ import java.util.List; public class EventGuiScriptList extends SubGuiInterface { private GuiCustomScroll scroll1; private GuiCustomScroll scroll2; - private final ScriptContainer container; - private final List scripts; + private ScriptContainer container; + private List scripts; public EventGuiScriptList(List scripts, ScriptContainer container) { this.container = container; @@ -26,7 +26,7 @@ public class EventGuiScriptList extends SubGuiInterface { scripts = new ArrayList(); } - this.scripts = scripts; + this.scripts = (List) scripts; } public void initGui() { diff --git a/src/main/java/noppes/npcs/client/gui/script/GuiScriptEffect.java b/src/main/java/noppes/npcs/client/gui/script/GuiScriptEffect.java index 54b1c6f4e..7cc692a8e 100644 --- a/src/main/java/noppes/npcs/client/gui/script/GuiScriptEffect.java +++ b/src/main/java/noppes/npcs/client/gui/script/GuiScriptEffect.java @@ -164,7 +164,7 @@ public class GuiScriptEffect extends GuiNPCInterface implements GuiYesNoCallback while (var3.hasNext()) { Map.Entry entry = (Map.Entry) var3.next(); - builder.insert(0, new Date(entry.getKey()) + entry.getValue() + "\n"); + builder.insert(0, new Date((Long) entry.getKey()) + (String) entry.getValue() + "\n"); } return builder.toString(); @@ -282,7 +282,7 @@ public class GuiScriptEffect extends GuiNPCInterface implements GuiYesNoCallback } if (guibutton.id == 105) { - container1 = new GuiYesNo(this, "", guibutton.displayString, 10); + container1 = new GuiYesNo(this, "", ((GuiNpcButton) guibutton).displayString, 10); this.displayGuiScreen(container1); } diff --git a/src/main/java/noppes/npcs/client/gui/script/GuiScriptGlobal.java b/src/main/java/noppes/npcs/client/gui/script/GuiScriptGlobal.java index 3ee428f70..15aec96dd 100644 --- a/src/main/java/noppes/npcs/client/gui/script/GuiScriptGlobal.java +++ b/src/main/java/noppes/npcs/client/gui/script/GuiScriptGlobal.java @@ -14,7 +14,7 @@ import java.util.HashMap; public class GuiScriptGlobal extends GuiNPCInterface implements IGuiData { private final ResourceLocation resource = new ResourceLocation("customnpcs", "textures/gui/smallbg.png"); - private final HashMap> scriptGuiClasses = new HashMap<>(); + private HashMap> scriptGuiClasses = new HashMap<>(); public GuiScriptGlobal() { this.xSize = 176; diff --git a/src/main/java/noppes/npcs/client/gui/script/GuiScriptInterface.java b/src/main/java/noppes/npcs/client/gui/script/GuiScriptInterface.java index 8916b826e..a0f1d3f1a 100644 --- a/src/main/java/noppes/npcs/client/gui/script/GuiScriptInterface.java +++ b/src/main/java/noppes/npcs/client/gui/script/GuiScriptInterface.java @@ -89,7 +89,7 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb hookLabel.color = 0xaaaaaa; addLabel(hookLabel); - ScriptContainer container = this.handler.getScripts().get(this.activeTab - 1); + ScriptContainer container = (ScriptContainer) this.handler.getScripts().get(this.activeTab - 1); GuiScriptTextArea ta = new GuiScriptTextArea(this, 2, guiLeft + 1 + yoffset, guiTop + yoffset, xSize - 108 - yoffset, (int) (ySize * 0.96) - yoffset * 2, container == null ? "" : container.script); ta.enableCodeHighlighting(); ta.setListener(this); @@ -120,7 +120,7 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb this.addButton(new GuiNpcButton(100, var9, this.guiTop + 125, 60, 20, "gui.copy")); this.addButton(new GuiNpcButton(102, var9, this.guiTop + 146, 60, 20, "gui.clear")); this.addLabel(new GuiNpcLabel(1, "script.language", var9, this.guiTop + 15)); - this.addButton(new GuiNpcButton(103, var9 + 60, this.guiTop + 10, 80, 20, this.languages.keySet().toArray(new String[this.languages.keySet().size()]), this.getScriptIndex())); + this.addButton(new GuiNpcButton(103, var9 + 60, this.guiTop + 10, 80, 20, (String[]) this.languages.keySet().toArray(new String[this.languages.keySet().size()]), this.getScriptIndex())); this.getButton(103).enabled = this.languages.size() > 0; this.addLabel(new GuiNpcLabel(2, "gui.enabled", var9, this.guiTop + 36)); this.addButton(new GuiNpcButton(104, var9 + 60, this.guiTop + 31, 50, 20, new String[]{"gui.no", "gui.yes"}, this.handler.getEnabled() ? 1 : 0)); @@ -168,7 +168,7 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb while (var3.hasNext()) { Entry entry = (Entry) var3.next(); - builder.insert(0, new Date(entry.getKey()) + entry.getValue() + "\n"); + builder.insert(0, new Date((Long) entry.getKey()) + (String) entry.getValue() + "\n"); } return builder.toString(); @@ -215,7 +215,7 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb if (i == 102) { ScriptContainer container; if (this.activeTab > 0) { - container = this.handler.getScripts().get(this.activeTab - 1); + container = (ScriptContainer) this.handler.getScripts().get(this.activeTab - 1); container.script = ""; } else { this.handler.clearConsole(); @@ -276,7 +276,7 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb } if (guibutton.id == 103) { - this.handler.setLanguage(guibutton.displayString); + this.handler.setLanguage(((GuiNpcButton) guibutton).displayString); } if (guibutton.id == 104) { @@ -284,7 +284,7 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb } if (guibutton.id == 105) { - GuiYesNo container1 = new GuiYesNo(this, "", guibutton.displayString, 10); + GuiYesNo container1 = new GuiYesNo(this, "", ((GuiNpcButton) guibutton).displayString, 10); this.displayGuiScreen(container1); } @@ -293,18 +293,18 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb } if (guibutton.id == 107) { - container = this.handler.getScripts().get(this.activeTab - 1); + container = (ScriptContainer) this.handler.getScripts().get(this.activeTab - 1); if (container == null) { this.handler.getScripts().add(container = new ScriptContainer(this.handler)); } - this.setSubGui(new EventGuiScriptList(this.languages.get(this.handler.getLanguage()), container)); + this.setSubGui(new EventGuiScriptList((List) this.languages.get(this.handler.getLanguage()), container)); } } private void setScript() { if (this.activeTab > 0) { - ScriptContainer container = this.handler.getScripts().get(this.activeTab - 1); + ScriptContainer container = (ScriptContainer) this.handler.getScripts().get(this.activeTab - 1); if (container == null) { this.handler.getScripts().add(container = new ScriptContainer(this.handler)); } @@ -342,7 +342,7 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb } public void textUpdate(String text) { - ScriptContainer container = this.handler.getScripts().get(this.activeTab - 1); + ScriptContainer container = (ScriptContainer) this.handler.getScripts().get(this.activeTab - 1); if (container != null) { container.script = text; } diff --git a/src/main/java/noppes/npcs/client/gui/script/GuiScriptItem.java b/src/main/java/noppes/npcs/client/gui/script/GuiScriptItem.java index 0f00b17bc..6f3ad27ea 100644 --- a/src/main/java/noppes/npcs/client/gui/script/GuiScriptItem.java +++ b/src/main/java/noppes/npcs/client/gui/script/GuiScriptItem.java @@ -14,7 +14,7 @@ import java.util.Iterator; import java.util.Map; public class GuiScriptItem extends GuiScriptInterface { - private final ScriptCustomItem item; + private ScriptCustomItem item; public static Map consoleText = new HashMap<>(); public GuiScriptItem() { @@ -59,7 +59,7 @@ public class GuiScriptItem extends GuiScriptInterface { while (var3.hasNext()) { Map.Entry entry = (Map.Entry) var3.next(); - builder.insert(0, new Date(entry.getKey()) + entry.getValue() + "\n"); + builder.insert(0, new Date((Long) entry.getKey()) + (String) entry.getValue() + "\n"); } return builder.toString(); diff --git a/src/main/java/noppes/npcs/client/gui/script/GuiScriptLinkedItem.java b/src/main/java/noppes/npcs/client/gui/script/GuiScriptLinkedItem.java index 25b04ea9d..5e99de749 100644 --- a/src/main/java/noppes/npcs/client/gui/script/GuiScriptLinkedItem.java +++ b/src/main/java/noppes/npcs/client/gui/script/GuiScriptLinkedItem.java @@ -175,7 +175,7 @@ public class GuiScriptLinkedItem extends GuiNPCInterface implements GuiYesNoCall while (var3.hasNext()) { Map.Entry entry = (Map.Entry) var3.next(); - builder.insert(0, new Date(entry.getKey()) + entry.getValue() + "\n"); + builder.insert(0, new Date((Long) entry.getKey()) + (String) entry.getValue() + "\n"); } return builder.toString(); @@ -293,7 +293,7 @@ public class GuiScriptLinkedItem extends GuiNPCInterface implements GuiYesNoCall } if (guibutton.id == 105) { - container1 = new GuiYesNo(this, "", guibutton.displayString, 10); + container1 = new GuiYesNo(this, "", ((GuiNpcButton) guibutton).displayString, 10); this.displayGuiScreen(container1); } diff --git a/src/main/java/noppes/npcs/client/gui/script/GuiScriptPlayers.java b/src/main/java/noppes/npcs/client/gui/script/GuiScriptPlayers.java index 48b03d6d1..f9b25f61e 100644 --- a/src/main/java/noppes/npcs/client/gui/script/GuiScriptPlayers.java +++ b/src/main/java/noppes/npcs/client/gui/script/GuiScriptPlayers.java @@ -1,16 +1,18 @@ package noppes.npcs.client.gui.script; import kamkeel.npcs.network.packets.request.script.PlayerScriptPacket; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import noppes.npcs.NBTTags; import noppes.npcs.constants.EnumScriptType; import noppes.npcs.controllers.ScriptContainer; +import noppes.npcs.controllers.data.EffectScript; import noppes.npcs.controllers.data.PlayerDataScript; import java.util.List; public class GuiScriptPlayers extends GuiScriptInterface { - private final PlayerDataScript script = new PlayerDataScript(null); + private PlayerDataScript script = new PlayerDataScript((EntityPlayer) null); public GuiScriptPlayers() { hookList.add(EnumScriptType.INIT.function); @@ -79,6 +81,9 @@ public class GuiScriptPlayers extends GuiScriptInterface { hookList.add(EnumScriptType.PROFILE_CHANGE.function); hookList.add(EnumScriptType.PROFILE_REMOVE.function); hookList.add(EnumScriptType.PROFILE_CREATE.function); + hookList.add(EffectScript.ScriptType.OnEffectAdd.function); + hookList.add(EffectScript.ScriptType.OnEffectTick.function); + hookList.add(EffectScript.ScriptType.OnEffectRemove.function); this.handler = this.script; PlayerScriptPacket.Get(); diff --git a/src/main/java/noppes/npcs/client/gui/select/GuiTextureSelection.java b/src/main/java/noppes/npcs/client/gui/select/GuiTextureSelection.java index dd0b232c2..c258c8b24 100644 --- a/src/main/java/noppes/npcs/client/gui/select/GuiTextureSelection.java +++ b/src/main/java/noppes/npcs/client/gui/select/GuiTextureSelection.java @@ -68,7 +68,7 @@ public class GuiTextureSelection extends SubGuiInterface implements ICustomScrol for (String name : map.keySet()) { if (!(map.get(name) instanceof FallbackResourceManager)) continue; - FallbackResourceManager manager = map.get(name); + FallbackResourceManager manager = (FallbackResourceManager) map.get(name); List list = ObfuscationReflectionHelper.getPrivateValue(FallbackResourceManager.class, manager, 0); for (IResourcePack pack : list) { if (pack instanceof AbstractResourcePack) { @@ -147,8 +147,7 @@ public class GuiTextureSelection extends SubGuiInterface implements ICustomScrol } try { url = URLDecoder.decode(url, StandardCharsets.UTF_8.name()); - } catch (UnsupportedEncodingException e) { - e.printStackTrace(); + } catch (UnsupportedEncodingException ignored) { } return new File(url); } diff --git a/src/main/java/noppes/npcs/client/gui/util/GuiContainerNPCInterface.java b/src/main/java/noppes/npcs/client/gui/util/GuiContainerNPCInterface.java index 322b2083f..b4049bc8a 100644 --- a/src/main/java/noppes/npcs/client/gui/util/GuiContainerNPCInterface.java +++ b/src/main/java/noppes/npcs/client/gui/util/GuiContainerNPCInterface.java @@ -27,12 +27,12 @@ public abstract class GuiContainerNPCInterface extends GuiContainer { public int guiLeft, guiTop; public EntityClientPlayerMP player; public EntityNPCInterface npc; - private final HashMap buttons = new HashMap(); - private final HashMap topbuttons = new HashMap(); - private final HashMap textfields = new HashMap(); - private final HashMap labels = new HashMap(); - private final HashMap scrolls = new HashMap(); - private final HashMap sliders = new HashMap(); + private HashMap buttons = new HashMap(); + private HashMap topbuttons = new HashMap(); + private HashMap textfields = new HashMap(); + private HashMap labels = new HashMap(); + private HashMap scrolls = new HashMap(); + private HashMap sliders = new HashMap(); public String title; public boolean closeOnEsc = false; private SubGuiInterface subgui; @@ -100,6 +100,8 @@ public abstract class GuiContainerNPCInterface extends GuiContainer { public void mouseEvent(int i, int j, int k) { } + ; + @Override protected void keyTyped(char c, int i) { if (subgui != null) @@ -125,6 +127,8 @@ public abstract class GuiContainerNPCInterface extends GuiContainer { public void buttonEvent(GuiButton guibutton) { } + ; + public void close() { Keyboard.enableRepeatEvents(false); GuiNpcTextField.unfocus(); diff --git a/src/main/java/noppes/npcs/client/gui/util/GuiContainerNPCInterface2.java b/src/main/java/noppes/npcs/client/gui/util/GuiContainerNPCInterface2.java index aae483a00..3455e4986 100644 --- a/src/main/java/noppes/npcs/client/gui/util/GuiContainerNPCInterface2.java +++ b/src/main/java/noppes/npcs/client/gui/util/GuiContainerNPCInterface2.java @@ -11,7 +11,7 @@ public abstract class GuiContainerNPCInterface2 extends GuiContainerNPCInterface private final ResourceLocation defaultBackground = new ResourceLocation("customnpcs", "textures/gui/menubg.png"); private final ResourceLocation defaultBackground2 = new ResourceLocation("customnpcs", "textures/gui/menubg2.png"); - private final GuiNpcMenu menu; + private GuiNpcMenu menu; public int menuYOffset = 0; public GuiContainerNPCInterface2(EntityNPCInterface npc, Container cont) { diff --git a/src/main/java/noppes/npcs/client/gui/util/GuiCustomScrollCloner.java b/src/main/java/noppes/npcs/client/gui/util/GuiCustomScrollCloner.java index effa0e3da..a69d449e7 100644 --- a/src/main/java/noppes/npcs/client/gui/util/GuiCustomScrollCloner.java +++ b/src/main/java/noppes/npcs/client/gui/util/GuiCustomScrollCloner.java @@ -55,7 +55,7 @@ public class GuiCustomScrollCloner extends GuiCustomScroll { if (GuiNpcMobSpawner.displayTags == 0 || GuiNpcMobSpawner.displayTags == 1) { if (this.parent.tagMap.hasClone(list.get(i))) { for (UUID tagUUID : this.parent.tagMap.getUUIDsList(list.get(i))) { - Tag tag = GuiNpcMobSpawner.tags.get(tagUUID); + Tag tag = this.parent.tags.get(tagUUID); if (tag != null) { if (GuiNpcMobSpawner.displayTags == 1 || !tag.getIsHidden()) { fontRendererObj.drawString("[" + tag.name + "]", tagStartX, k, tag.color); diff --git a/src/main/java/noppes/npcs/client/gui/util/GuiDiagram.java b/src/main/java/noppes/npcs/client/gui/util/GuiDiagram.java index f4c585526..ce886f8cb 100644 --- a/src/main/java/noppes/npcs/client/gui/util/GuiDiagram.java +++ b/src/main/java/noppes/npcs/client/gui/util/GuiDiagram.java @@ -10,15 +10,16 @@ import org.lwjgl.input.Mouse; import org.lwjgl.opengl.GL11; import java.awt.*; -import java.util.*; import java.util.List; +import java.util.Queue; +import java.util.*; /** * Abstract GUI class for drawing diagrams with icons (nodes) and connections (arrows). - * + *

* This revised version ensures that non‑Chart layouts use the full diagram bounds for positioning - * (so that the outer icons lie flush with the edges) and that curved arrow drawing selects the - * best control point (using both curveAngle and its negative) to avoid icons. + * and that curved arrow drawing selects the best control point (using both curveAngle and its negative) + * to avoid icons. */ public abstract class GuiDiagram extends Gui { @@ -45,6 +46,15 @@ public abstract class GuiDiagram extends Gui { protected boolean showArrowHeads = true; protected boolean useColorScaling = true; + // --- Arrow Options --- + protected float arrowSize = 6; + protected float lineThickness = 2f; + + // This flag determines how two‑way connections are drawn. + // When true, a two‑way connection is drawn as one line with dual arrowheads and combined tooltips. + // When false, each direction is drawn as a separate line with its own hitbox and tooltip. + protected boolean allowTwoWay = false; + // --- Layout Options --- protected EnumDiagramLayout layout = EnumDiagramLayout.CIRCULAR; @@ -60,6 +70,7 @@ public abstract class GuiDiagram extends Gui { public void setCurvedArrows(boolean curved) { this.curvedArrows = curved; } + public void setCurveAngle(int angle) { this.curveAngle = angle; } @@ -88,6 +99,7 @@ public abstract class GuiDiagram extends Gui { // --- Data Providers (subclasses must implement) --- protected abstract List createIcons(); + protected abstract List createConnections(); protected final List getIcons() { @@ -96,6 +108,7 @@ public abstract class GuiDiagram extends Gui { } return iconsCache; } + protected final List getConnections() { if (connectionsCache == null) { connectionsCache = createConnections(); @@ -108,8 +121,14 @@ public abstract class GuiDiagram extends Gui { */ protected abstract void renderIcon(DiagramIcon icon, int posX, int posY, IconRenderState state); - protected List getIconTooltip(DiagramIcon icon) { return null; } + protected List getIconTooltip(DiagramIcon icon) { + return null; + } + /** + * Returns the tooltip for a connection. When allowTwoWay is true the tooltip combines both directions, + * otherwise it shows only the current connection's info. + */ protected List getConnectionTooltip(DiagramConnection conn) { List tooltip = new ArrayList<>(); DiagramIcon iconFrom = getIconById(conn.idFrom); @@ -118,16 +137,22 @@ public abstract class GuiDiagram extends Gui { String nameTo = iconTo != null ? getIconName(iconTo) : "Unknown"; tooltip.add(nameFrom + " > " + nameTo + ":"); tooltip.add(conn.hoverText); - DiagramConnection reverse = getConnectionByIds(conn.idTo, conn.idFrom); - if (reverse != null) { - tooltip.add(nameTo + " > " + nameFrom + ":"); - tooltip.add(reverse.hoverText); + if (allowTwoWay) { + DiagramConnection reverse = getConnectionByIds(conn.idTo, conn.idFrom); + if (reverse != null) { + tooltip.add(nameTo + " > " + nameFrom + ":"); + tooltip.add(reverse.hoverText); + } } return tooltip; } - protected String getIconName(DiagramIcon icon) { return "Icon " + icon.id; } + + protected String getIconName(DiagramIcon icon) { + return "Icon " + icon.id; + } // --- Layout Calculation --- + /** * For non‑CHART layouts, returns a mapping from node ID to (x,y) position. */ @@ -158,6 +183,9 @@ public abstract class GuiDiagram extends Gui { case TREE_MANUAL: cachedPositions = calculateTreeManualPositions(); break; + case MANUAL: + cachedPositions = calculateManualPositions(); + break; default: cachedPositions = calculateCircularPositions(); break; @@ -165,6 +193,16 @@ public abstract class GuiDiagram extends Gui { return cachedPositions; } + protected Map calculateManualPositions() { + Map positions = new HashMap<>(); + int centerX = x + width / 2; + int centerY = y + height / 2; + for (DiagramIcon icon : getIcons()) { + positions.put(icon.id, new Point(centerX + icon.index, centerY - icon.priority)); + } + return positions; + } + // --- Standard Layout Methods --- // Circular: use the full available radius so that outer icons are flush with bounds. @@ -184,7 +222,7 @@ public abstract class GuiDiagram extends Gui { return positions; } - // Square: fill the entire bounds + // Square: fill the entire bounds. protected Map calculateSquarePositions() { List icons = getIcons(); Map positions = new HashMap<>(); @@ -193,7 +231,6 @@ public abstract class GuiDiagram extends Gui { int n = (int) Math.ceil(Math.sqrt(count)); int cellWidth = width / n; int cellHeight = height / n; - // Start exactly at the diagram bounds. int startX = x, startY = y; for (int i = 0; i < count; i++) { int row = i / n, col = i % n; @@ -204,29 +241,18 @@ public abstract class GuiDiagram extends Gui { return positions; } - // Tree: distribute levels vertically and icons horizontally so that the top and bottom icons touch y and y+height. + // Tree: distribute levels vertically and icons horizontally. protected Map calculateTreePositions() { List icons = getIcons(); Map positions = new HashMap<>(); int count = icons.size(); if (count == 0) return positions; - // Determine number of levels by a simple breadth-first approach. int levels = (int) Math.ceil(Math.log(count + 1) / Math.log(2)); - // If only one level, place the icon in the center. for (int level = 0; level < levels; level++) { - // Determine number of nodes at this level. int nodesThisLevel = (level == 0) ? 1 : (int) Math.min(Math.pow(2, level), count - (int) Math.pow(2, level) + 1); - // Calculate vertical position: if more than one level, linearly space from y to y+height. int posY = (levels == 1) ? y + height / 2 : y + (int) ((height * level) / (levels - 1.0)); - // Horizontal spacing: if only one node, center it; otherwise, nodes are evenly spaced from x to x+width. for (int i = 0; i < nodesThisLevel; i++) { - int posX; - if (nodesThisLevel == 1) { - posX = x + width / 2; - } else { - posX = x + (int) ((width * i) / (nodesThisLevel - 1.0)); - } - // Here we assign IDs in order. (You may want to use your own ordering.) + int posX = (nodesThisLevel == 1) ? x + width / 2 : x + (int) ((width * i) / (nodesThisLevel - 1.0)); int index = (int) (Math.pow(2, level) - 1 + i); if (index < count) { positions.put(icons.get(index).id, new Point(posX, posY)); @@ -236,14 +262,13 @@ public abstract class GuiDiagram extends Gui { return positions; } - // Generated: Break icons into clusters and fill each cluster’s area exactly. + // Generated layout methods (unchanged)... protected Map calculateGeneratedPositions() { List icons = getIcons(); List connections = getConnections(); Map> graph = buildGraph(icons, connections); List> clusters = getConnectedComponents(graph); int clusterCount = clusters.size(); - // Arrange clusters in a grid that fills the diagram exactly. int gridCols = (int) Math.ceil(Math.sqrt(clusterCount)); int gridRows = (int) Math.ceil((double) clusterCount / gridCols); Map globalPositions = new HashMap<>(); @@ -284,6 +309,7 @@ public abstract class GuiDiagram extends Gui { } return graph; } + private List> getConnectedComponents(Map> graph) { Set visited = new HashSet<>(); List> components = new ArrayList<>(); @@ -296,6 +322,7 @@ public abstract class GuiDiagram extends Gui { } return components; } + private void dfsComponent(Integer current, Map> graph, Set visited, Set comp) { visited.add(current); comp.add(current); @@ -304,6 +331,7 @@ public abstract class GuiDiagram extends Gui { dfsComponent(neighbor, graph, visited, comp); } } + private boolean isCycle(Set cluster, Map> graph) { if (cluster.size() < 3) return false; for (Integer node : cluster) { @@ -315,6 +343,7 @@ public abstract class GuiDiagram extends Gui { } return true; } + private boolean isTree(Set cluster, Map> graph) { int edgeCount = 0; for (Integer node : cluster) { @@ -325,14 +354,14 @@ public abstract class GuiDiagram extends Gui { edgeCount /= 2; return edgeCount == cluster.size() - 1; } + private boolean isSquare(Set cluster) { int n = cluster.size(); int sqrt = (int) Math.round(Math.sqrt(n)); return sqrt * sqrt == n; } - // --- Layout Algorithms for Clusters --- - // Cycle: now use the full available circle. + // Layout algorithms for clusters (unchanged methods: layoutCycle, layoutTree, layoutSquare, layoutForceDirected)... private Map layoutCycle(Set cluster, int compX, int compY, int compWidth, int compHeight) { Map positions = new HashMap<>(); if (cluster.isEmpty()) return positions; @@ -349,13 +378,11 @@ public abstract class GuiDiagram extends Gui { return positions; } - // Tree for clusters: use full comp area. private Map layoutTree(Set cluster, int compX, int compY, int compWidth, int compHeight, Map> fullGraph) { Map positions = new HashMap<>(); if (cluster.isEmpty()) return positions; - // Build a subgraph Map> subgraph = new HashMap<>(); for (Integer id : cluster) { List neighbors = new ArrayList<>(); @@ -365,9 +392,7 @@ public abstract class GuiDiagram extends Gui { } subgraph.put(id, neighbors); } - // Pick a root (lowest id) Integer root = Collections.min(cluster); - // Perform BFS to assign levels. Map levelMap = new HashMap<>(); Map> levels = new HashMap<>(); Queue queue = new LinkedList<>(); @@ -388,7 +413,6 @@ public abstract class GuiDiagram extends Gui { } } int maxLevel = levels.keySet().stream().max(Integer::compare).orElse(0); - // Vertical positions: if only one level, center; otherwise span from compY to compY+compHeight. for (Map.Entry> entry : levels.entrySet()) { int lvl = entry.getKey(); int posY = (maxLevel == 0) ? compY + compHeight / 2 : compY + (int) ((compHeight * lvl) / (maxLevel)); @@ -403,7 +427,6 @@ public abstract class GuiDiagram extends Gui { return positions; } - // Square: fill the available comp area. private Map layoutSquare(Set cluster, int compX, int compY, int compWidth, int compHeight) { Map positions = new HashMap<>(); if (cluster.isEmpty()) return positions; @@ -424,7 +447,6 @@ public abstract class GuiDiagram extends Gui { return positions; } - // Force-directed layout (unchanged) private Map layoutForceDirected(Set cluster, int compX, int compY, int compWidth, int compHeight, List connections) { Map positions = new HashMap<>(); @@ -488,8 +510,8 @@ public abstract class GuiDiagram extends Gui { double[] d = disp.get(id); double dispLength = Math.sqrt(d[0] * d[0] + d[1] * d[1]); if (dispLength < 0.01) dispLength = 0.01; - int newX = positions.get(id).x + (int)((d[0] / dispLength) * Math.min(dispLength, temperature)); - int newY = positions.get(id).y + (int)((d[1] / dispLength) * Math.min(dispLength, temperature)); + int newX = positions.get(id).x + (int) ((d[0] / dispLength) * Math.min(dispLength, temperature)); + int newY = positions.get(id).y + (int) ((d[1] / dispLength) * Math.min(dispLength, temperature)); newX = Math.max(compX, Math.min(compX + compWidth, newX)); newY = Math.max(compY, Math.min(compY + compHeight, newY)); positions.get(id).x = newX; @@ -505,6 +527,7 @@ public abstract class GuiDiagram extends Gui { List icons = getIcons(); Map positions = new HashMap<>(); if (icons.isEmpty()) return positions; + // Group icons by their manual index. Map> groups = new TreeMap<>(); for (DiagramIcon icon : icons) { groups.computeIfAbsent(icon.index, k -> new ArrayList<>()).add(icon); @@ -512,13 +535,21 @@ public abstract class GuiDiagram extends Gui { int centerX = x + width / 2, centerY = y + height / 2; int maxRing = groups.isEmpty() ? 0 : Collections.max(groups.keySet()); int maxRadius = (Math.min(width, height) - iconSize) / 2; - double ringSpacing = (maxRing + 1) > 0 ? (double) maxRadius / (maxRing + 1) : 0; + + // Adjustable parameters: + // spacingExponent controls the non-linear spacing between rings. Increasing this value will push outer rings farther apart. + double spacingExponent = 1.5; // default value; adjust as needed + // ringMultiplier lets you directly scale the computed radius of each ring. + double ringMultiplier = 1.5; // default value; adjust as needed + + // Calculate positions for each ring using a power function and multiplier. for (Map.Entry> entry : groups.entrySet()) { int ring = entry.getKey(); List groupIcons = entry.getValue(); if (groupIcons.isEmpty()) continue; groupIcons.sort(Comparator.comparingInt(icon -> icon.priority)); - double radius = ringSpacing * (ring + 1); + double normalizedRing = (ring + 1) / (double) (maxRing + 1); + double radius = maxRadius * Math.pow(normalizedRing, spacingExponent) * ringMultiplier; int count = groupIcons.size(); double startAngle = (ring == 0) ? -Math.PI / 2 : -3 * Math.PI / 4; for (int i = 0; i < count; i++) { @@ -531,6 +562,7 @@ public abstract class GuiDiagram extends Gui { return positions; } + private Map calculateSquareManualPositions() { List icons = getIcons(); Map positions = new HashMap<>(); @@ -582,15 +614,14 @@ public abstract class GuiDiagram extends Gui { Map positions = new HashMap<>(); if (icons.isEmpty()) return positions; int maxLevel = levels.isEmpty() ? 0 : Collections.max(levels.keySet()); - // If more than one level, span vertically from y to y+height. for (Map.Entry> entry : levels.entrySet()) { int level = entry.getKey(); List levelIcons = entry.getValue(); levelIcons.sort(Comparator.comparingInt(icon -> icon.priority)); int m = levelIcons.size(); - int posY = (m > 0 && maxLevel > 0) ? y + (int)((height * level) / (maxLevel)) : y + height / 2; + int posY = (m > 0 && maxLevel > 0) ? y + (int) ((height * level) / (maxLevel)) : y + height / 2; for (int i = 0; i < m; i++) { - int posX = (m > 1) ? x + (int)((width * i) / (m - 1.0)) : x + width / 2; + int posX = (m > 1) ? x + (int) ((width * i) / (m - 1.0)) : x + width / 2; positions.put(levelIcons.get(i).id, new Point(posX, posY)); } } @@ -598,6 +629,7 @@ public abstract class GuiDiagram extends Gui { } // --- Curved Arrow Helpers --- + /** * Computes a quadratic Bezier control point given endpoints and an angle (in degrees). */ @@ -608,12 +640,12 @@ public abstract class GuiDiagram extends Gui { double angleRad = Math.toRadians(angleDegrees); double offset = len * Math.tan(angleRad) / 2; double perpX = -dy / len, perpY = dx / len; - return new Point((x1 + x2) / 2 + (int)(perpX * offset), - (y1 + y2) / 2 + (int)(perpY * offset)); + return new Point((x1 + x2) / 2 + (int) (perpX * offset), + (y1 + y2) / 2 + (int) (perpY * offset)); } /** - * Returns the minimum distance from the given control point to any icon (except the endpoints of the connection). + * Returns the minimum distance from the given control point to any icon (except endpoints). */ private double getMinDistanceToIcon(Point control, DiagramConnection conn) { double minDist = Double.MAX_VALUE; @@ -632,98 +664,282 @@ public abstract class GuiDiagram extends Gui { } // --- Arrow Drawing Methods --- + /** + * Draws a connection line between two endpoints. + * If a reverse connection exists and allowTwoWay is false, the line is drawn with a perpendicular offset. + */ protected void drawConnectionLine(int x1, int y1, int x2, int y2, DiagramConnection conn, boolean dim) { - int color = getConnectionColor(conn); - if (!useColorScaling) color = 0xFFFFFFFF; - if (!curvedArrows) { - GL11.glPushAttrib(GL11.GL_ENABLE_BIT); - GL11.glDisable(GL11.GL_TEXTURE_2D); - GL11.glLineWidth(2.0F); - float r = ((color >> 16) & 0xFF) / 255f; - float g = ((color >> 8) & 0xFF) / 255f; - float b = (color & 0xFF) / 255f; - if (dim) { r *= 0.4f; g *= 0.4f; b *= 0.4f; } - GL11.glColor4f(r, g, b, 1f); - GL11.glBegin(GL11.GL_LINES); - GL11.glVertex2i(x1, y1); - GL11.glVertex2i(x2, y2); - GL11.glEnd(); - GL11.glEnable(GL11.GL_TEXTURE_2D); - GL11.glPopAttrib(); - } else { - // Compute two potential control points and choose the one farther from nearby icons. - Point cp1 = computeControlPoint(x1, y1, x2, y2, curveAngle); - Point cp2 = computeControlPoint(x1, y1, x2, y2, -curveAngle); - double d1 = getMinDistanceToIcon(cp1, conn); - double d2 = getMinDistanceToIcon(cp2, conn); - Point control = (d1 >= d2) ? cp1 : cp2; - int segments = 400; + DiagramConnection reverse = getConnectionByIds(conn.idTo, conn.idFrom); + boolean twoWay = (reverse != null && allowTwoWay); + boolean separateTwoWay = (reverse != null && !allowTwoWay); + int effectiveCurveAngle = (conn.customCurveAngle != null ? conn.customCurveAngle : this.curveAngle); + boolean useCustomCurveAngle = (conn.customAllowCurve != null ? conn.customAllowCurve : this.curvedArrows); - GL11.glPushAttrib(GL11.GL_ENABLE_BIT | GL11.GL_COLOR_BUFFER_BIT | GL11.GL_HINT_BIT); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glEnable(GL11.GL_LINE_SMOOTH); - GL11.glHint(GL11.GL_LINE_SMOOTH_HINT, GL11.GL_NICEST); - GL11.glDisable(GL11.GL_TEXTURE_2D); - GL11.glLineWidth(2.0F); - float rr = ((color >> 16) & 0xFF) / 255f; - float gg = ((color >> 8) & 0xFF) / 255f; - float bb = (color & 0xFF) / 255f; - if (dim) { rr *= 0.4f; gg *= 0.4f; bb *= 0.4f; } - GL11.glColor4f(rr, gg, bb, 1f); - - GL11.glBegin(GL11.GL_LINE_STRIP); - for (int i = 0; i <= segments; i++) { - double t = (double) i / segments; - int bx = (int)((1 - t) * (1 - t) * x1 + 2 * (1 - t) * t * control.x + t * t * x2); - int by = (int)((1 - t) * (1 - t) * y1 + 2 * (1 - t) * t * control.y + t * t * y2); - GL11.glVertex2i(bx, by); + if (!useCustomCurveAngle) { + if (separateTwoWay) { + int offsetAmount = 4; + double dx = x2 - x1, dy = y2 - y1; + double len = Math.sqrt(dx * dx + dy * dy); + if (len == 0) len = 1; + double offsetX = -dy / len * offsetAmount; + double offsetY = dx / len * offsetAmount; + if (conn.idFrom >= conn.idTo) { + offsetX = -offsetX; + offsetY = -offsetY; + } + int newX1 = x1 + (int) offsetX; + int newY1 = y1 + (int) offsetY; + int newX2 = x2 + (int) offsetX; + int newY2 = y2 + (int) offsetY; + int color = getConnectionColor(conn); + if (!useColorScaling) { + color = 0xFFFFFFFF; + } + drawColoredLine(newX1, newY1, newX2, newY2, color, dim); + } else if (twoWay) { + int midX = (x1 + x2) / 2; + int midY = (y1 + y2) / 2; + int color1 = getConnectionColor(reverse); + int color2 = getConnectionColor(conn); + if (!useColorScaling) { + color1 = color2 = 0xFFFFFFFF; + } + drawColoredLine(x1, y1, midX, midY, color1, dim); + drawColoredLine(midX, midY, x2, y2, color2, dim); + } else { + int color = getConnectionColor(conn); + if (!useColorScaling) { + color = 0xFFFFFFFF; + } + drawColoredLine(x1, y1, x2, y2, color, dim); + } + } else { + // Curved arrows + if (separateTwoWay) { + int offsetAmount = 4; + double dx = x2 - x1, dy = y2 - y1; + double len = Math.sqrt(dx * dx + dy * dy); + if (len == 0) len = 1; + double normX = -dy / len; + double normY = dx / len; + double sign = (conn.idFrom < conn.idTo) ? 1 : -1; + Point baseControl = computeControlPoint(x1, y1, x2, y2, effectiveCurveAngle); + Point offsetControl = new Point(baseControl.x + (int) (normX * offsetAmount * sign), + baseControl.y + (int) (normY * offsetAmount * sign)); + int segments = 800; + int color = getConnectionColor(conn); + if (!useColorScaling) { + color = 0xFFFFFFFF; + } + GL11.glPushAttrib(GL11.GL_ENABLE_BIT | GL11.GL_COLOR_BUFFER_BIT | GL11.GL_HINT_BIT); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glEnable(GL11.GL_LINE_SMOOTH); + GL11.glHint(GL11.GL_LINE_SMOOTH_HINT, GL11.GL_NICEST); + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glLineWidth(lineThickness); + setColor(color, dim); + GL11.glBegin(GL11.GL_LINE_STRIP); + for (int i = 0; i <= segments; i++) { + double t = (double) i / segments; + int bx = (int) ((1 - t) * (1 - t) * x1 + 2 * (1 - t) * t * offsetControl.x + t * t * x2); + int by = (int) ((1 - t) * (1 - t) * y1 + 2 * (1 - t) * t * offsetControl.y + t * t * y2); + GL11.glVertex2i(bx, by); + } + GL11.glEnd(); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glDisable(GL11.GL_LINE_SMOOTH); + GL11.glDisable(GL11.GL_BLEND); + GL11.glPopAttrib(); + } else if (twoWay) { + Point cp1 = computeControlPoint(x1, y1, x2, y2, effectiveCurveAngle); + Point cp2 = computeControlPoint(x1, y1, x2, y2, -effectiveCurveAngle); + double d1 = getMinDistanceToIcon(cp1, conn); + double d2 = getMinDistanceToIcon(cp2, conn); + Point control = (d1 >= d2) ? cp1 : cp2; + int segments = 800; + int color1 = getConnectionColor(reverse); + int color2 = getConnectionColor(conn); + if (!useColorScaling) { + color1 = color2 = 0xFFFFFFFF; + } + int halfSegments = segments / 2; + GL11.glPushAttrib(GL11.GL_ENABLE_BIT | GL11.GL_COLOR_BUFFER_BIT | GL11.GL_HINT_BIT); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glEnable(GL11.GL_LINE_SMOOTH); + GL11.glHint(GL11.GL_LINE_SMOOTH_HINT, GL11.GL_NICEST); + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glLineWidth(lineThickness); + setColor(color1, dim); + GL11.glBegin(GL11.GL_LINE_STRIP); + for (int i = 0; i <= halfSegments; i++) { + double t = (double) i / halfSegments; + int bx = (int) ((1 - t) * (1 - t) * x1 + 2 * (1 - t) * t * control.x + t * t * x2); + int by = (int) ((1 - t) * (1 - t) * y1 + 2 * (1 - t) * t * control.y + t * t * y2); + GL11.glVertex2i(bx, by); + } + GL11.glEnd(); + setColor(color2, dim); + GL11.glBegin(GL11.GL_LINE_STRIP); + for (int i = halfSegments; i <= segments; i++) { + double t = (double) i / segments; + int bx = (int) ((1 - t) * (1 - t) * x1 + 2 * (1 - t) * t * control.x + t * t * x2); + int by = (int) ((1 - t) * (1 - t) * y1 + 2 * (1 - t) * t * control.y + t * t * y2); + GL11.glVertex2i(bx, by); + } + GL11.glEnd(); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glDisable(GL11.GL_LINE_SMOOTH); + GL11.glDisable(GL11.GL_BLEND); + GL11.glPopAttrib(); + } else { + int color = getConnectionColor(conn); + if (!useColorScaling) { + color = 0xFFFFFFFF; + } + // Compute both candidate control points. + Point cp1 = computeControlPoint(x1, y1, x2, y2, effectiveCurveAngle); + Point cp2 = computeControlPoint(x1, y1, x2, y2, -effectiveCurveAngle); + double d1 = getMinDistanceToIcon(cp1, conn); + double d2 = getMinDistanceToIcon(cp2, conn); + Point cp = (d1 >= d2) ? cp1 : cp2; + int segments = 800; + GL11.glPushAttrib(GL11.GL_ENABLE_BIT | GL11.GL_COLOR_BUFFER_BIT | GL11.GL_HINT_BIT); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glEnable(GL11.GL_LINE_SMOOTH); + GL11.glHint(GL11.GL_LINE_SMOOTH_HINT, GL11.GL_NICEST); + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glLineWidth(lineThickness); + setColor(color, dim); + GL11.glBegin(GL11.GL_LINE_STRIP); + for (int i = 0; i <= segments; i++) { + double t = (double) i / segments; + int bx = (int) ((1 - t) * (1 - t) * x1 + 2 * (1 - t) * t * cp.x + t * t * x2); + int by = (int) ((1 - t) * (1 - t) * y1 + 2 * (1 - t) * t * cp.y + t * t * y2); + GL11.glVertex2i(bx, by); + } + GL11.glEnd(); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glDisable(GL11.GL_LINE_SMOOTH); + GL11.glDisable(GL11.GL_BLEND); + GL11.glPopAttrib(); } - GL11.glEnd(); - - GL11.glEnable(GL11.GL_TEXTURE_2D); - GL11.glDisable(GL11.GL_LINE_SMOOTH); - GL11.glDisable(GL11.GL_BLEND); - GL11.glPopAttrib(); } } - protected void drawArrowHead(int x1, int y1, int x2, int y2, DiagramConnection conn, boolean dim) { - int color = getConnectionColor(conn); - if (!useColorScaling) color = 0xFFFFFFFF; - double angle; - if (!curvedArrows) { - angle = Math.atan2(y2 - y1, x2 - x1); - } else { - // Compute two control points and choose the one farther from icons. - double dx = x2 - x1, dy = y2 - y1; - double len = Math.sqrt(dx * dx + dy * dy); - if (len == 0) len = 1; - Point cp1 = computeControlPoint(x1, y1, x2, y2, curveAngle); - Point cp2 = computeControlPoint(x1, y1, x2, y2, -curveAngle); - double d1 = getMinDistanceToIcon(cp1, conn); - double d2 = getMinDistanceToIcon(cp2, conn); - Point control = (d1 >= d2) ? cp1 : cp2; - double t = 0.95; - double bx = (1 - t) * (1 - t) * x1 + 2 * (1 - t) * t * control.x + t * t * x2; - double by = (1 - t) * (1 - t) * y1 + 2 * (1 - t) * t * control.y + t * t * y2; - double dBx = 2 * (1 - t) * (control.x - x1) + 2 * t * (x2 - control.x); - double dBy = 2 * (1 - t) * (control.y - y1) + 2 * t * (y2 - control.y); - angle = Math.atan2(dBy, dBx); + // Helper method to draw a straight colored line. + private void drawColoredLine(int x1, int y1, int x2, int y2, int color, boolean dim) { + GL11.glPushAttrib(GL11.GL_ENABLE_BIT); + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glLineWidth(lineThickness); + setColor(color, dim); + GL11.glBegin(GL11.GL_LINES); + GL11.glVertex2i(x1, y1); + GL11.glVertex2i(x2, y2); + GL11.glEnd(); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glPopAttrib(); + } + + // Helper to set color with dimming applied. + private void setColor(int color, boolean dim) { + float r = ((color >> 16) & 0xFF) / 255f; + float g = ((color >> 8) & 0xFF) / 255f; + float b = (color & 0xFF) / 255f; + if (dim) { + r *= 0.4f; + g *= 0.4f; + b *= 0.4f; } - float defenderEdgeX = x2 - (slotSize / 2f) * (float)Math.cos(angle); - float defenderEdgeY = y2 - (slotSize / 2f) * (float)Math.sin(angle); - int arrowSize = 6; - float leftX = defenderEdgeX - arrowSize * (float)Math.cos(angle - Math.PI / 6); - float leftY = defenderEdgeY - arrowSize * (float)Math.sin(angle - Math.PI / 6); - float rightX = defenderEdgeX - arrowSize * (float)Math.cos(angle + Math.PI / 6); - float rightY = defenderEdgeY - arrowSize * (float)Math.sin(angle + Math.PI / 6); + GL11.glColor4f(r, g, b, 1f); + } + + /** + * Draws the arrow head for a connection. + * When the connection is drawn separately (two-way with allowTwoWay false), + * the arrow head is positioned using the same offset. + */ + // Fixed drawArrowHead: + protected void drawArrowHead(int x1, int y1, int x2, int y2, DiagramConnection conn, boolean dim) { + DiagramConnection reverse = getConnectionByIds(conn.idFrom, conn.idTo); + int color = (reverse != null) ? getConnectionColor(reverse) : getConnectionColor(conn); + if (!useColorScaling) + color = 0xFFFFFFFF; + boolean separateTwoWay = (reverse != null && !allowTwoWay); + double angle; + boolean useCustomCurveAngle = (conn.customAllowCurve != null ? conn.customAllowCurve : this.curvedArrows); + + if (!useCustomCurveAngle) { + if (separateTwoWay) { + int offsetAmount = 4; + double dx = x2 - x1, dy = y2 - y1; + double len = Math.sqrt(dx * dx + dy * dy); + if (len == 0) len = 1; + double offsetX = -dy / len * offsetAmount; + double offsetY = dx / len * offsetAmount; + if (conn.idFrom >= conn.idTo) { + offsetX = -offsetX; + offsetY = -offsetY; + } + int newX2 = x2 + (int) offsetX; + int newY2 = y2 + (int) offsetY; + angle = Math.atan2(newY2 - y1, newX2 - x1); + x2 = newX2; + y2 = newY2; + } else { + angle = Math.atan2(y2 - y1, x2 - x1); + } + } else { + int effectiveCurveAngle = (conn.customCurveAngle != null ? conn.customCurveAngle : this.curveAngle); + if (separateTwoWay) { + int offsetAmount = 4; + double dx = x2 - x1, dy = y2 - y1; + double len = Math.sqrt(dx * dx + dy * dy); + if (len == 0) len = 1; + double normX = -dy / len; + double normY = dx / len; + double sign = (conn.idFrom < conn.idTo) ? 1 : -1; + Point baseControl = computeControlPoint(x1, y1, x2, y2, effectiveCurveAngle); + Point offsetControl = new Point(baseControl.x + (int) (normX * offsetAmount * sign), + baseControl.y + (int) (normY * offsetAmount * sign)); + double t = 0.95; + double bx = (1 - t) * (1 - t) * x1 + 2 * (1 - t) * t * offsetControl.x + t * t * x2; + double by = (1 - t) * (1 - t) * y1 + 2 * (1 - t) * t * offsetControl.y + t * t * y2; + double dBx = 2 * (1 - t) * (offsetControl.x - x1) + 2 * t * (x2 - offsetControl.x); + double dBy = 2 * (1 - t) * (offsetControl.y - y1) + 2 * t * (y2 - offsetControl.y); + angle = Math.atan2(dBy, dBx); + } else { + Point cp1 = computeControlPoint(x1, y1, x2, y2, effectiveCurveAngle); + Point cp2 = computeControlPoint(x1, y1, x2, y2, -effectiveCurveAngle); + double d1 = getMinDistanceToIcon(cp1, conn); + double d2 = getMinDistanceToIcon(cp2, conn); + Point control = (d1 >= d2) ? cp1 : cp2; + double t = 0.95; + double bx = (1 - t) * (1 - t) * x1 + 2 * (1 - t) * t * control.x + t * t * x2; + double by = (1 - t) * (1 - t) * y1 + 2 * (1 - t) * t * control.y + t * t * y2; + double dBx = 2 * (1 - t) * (control.x - x1) + 2 * t * (x2 - control.x); + double dBy = 2 * (1 - t) * (control.y - y1) + 2 * t * (y2 - control.y); + angle = Math.atan2(dBy, dBx); + } + } + float defenderEdgeX = x2 - (slotSize / 2f) * (float) Math.cos(angle); + float defenderEdgeY = y2 - (slotSize / 2f) * (float) Math.sin(angle); + float leftX = defenderEdgeX - arrowSize * (float) Math.cos(angle - Math.PI / 6); + float leftY = defenderEdgeY - arrowSize * (float) Math.sin(angle - Math.PI / 6); + float rightX = defenderEdgeX - arrowSize * (float) Math.cos(angle + Math.PI / 6); + float rightY = defenderEdgeY - arrowSize * (float) Math.sin(angle + Math.PI / 6); GL11.glPushAttrib(GL11.GL_ENABLE_BIT); GL11.glDisable(GL11.GL_TEXTURE_2D); float rr = ((color >> 16) & 0xFF) / 255f; float gg = ((color >> 8) & 0xFF) / 255f; float bb = (color & 0xFF) / 255f; - if (dim) { rr *= 0.4f; gg *= 0.4f; bb *= 0.4f; } + if (dim) { + rr *= 0.4f; + gg *= 0.4f; + bb *= 0.4f; + } GL11.glColor4f(rr, gg, bb, 1f); GL11.glDisable(GL11.GL_CULL_FACE); GL11.glBegin(GL11.GL_TRIANGLES); @@ -736,35 +952,15 @@ public abstract class GuiDiagram extends Gui { GL11.glPopAttrib(); } - // --- Standard Icon Box Drawing --- - protected void drawIconBox(int slotX, int slotY, int slotSize, boolean highlighted) { - int bg = highlighted ? mixColors(iconBackgroundColor, 0xFFFFFFFF, 0.2f) : iconBackgroundColor; - drawRect(slotX, slotY, slotX + slotSize, slotY + slotSize, bg); - for (int i = 0; i < iconBorderThickness; i++) { - drawHorizontalLine(slotX + i, slotX + slotSize - i, slotY + i, iconBorderColor); - drawHorizontalLine(slotX + i, slotX + slotSize - i, slotY + slotSize - 1 - i, iconBorderColor); - drawVerticalLine(slotX + i, slotY + i, slotY + slotSize - i, iconBorderColor); - drawVerticalLine(slotX + slotSize - 1 - i, slotY + i, slotY + slotSize - i, iconBorderColor); - } - } - protected int mixColors(int color1, int color2, float ratio) { - int a1 = (color1 >> 24) & 0xFF, r1 = (color1 >> 16) & 0xFF, g1 = (color1 >> 8) & 0xFF, b1 = color1 & 0xFF; - int a2 = (color2 >> 24) & 0xFF, r2 = (color2 >> 16) & 0xFF, g2 = (color2 >> 8) & 0xFF, b2 = color2 & 0xFF; - int a = (int)(a1 + (a2 - a1) * ratio); - int r = (int)(r1 + (r2 - r1) * ratio); - int g = (int)(g1 + (g2 - g1) * ratio); - int b = (int)(b1 + (b2 - b1) * ratio); - return (a << 24) | (r << 16) | (g << 8) | b; - } // --- Hit-detection helpers --- private double distanceToBezier(Point start, Point control, Point end, int segments, int px, int py) { double minDist = Double.MAX_VALUE; Point prev = null; for (int i = 0; i <= segments; i++) { - double t = (double)i / segments; - int x = (int)((1 - t) * (1 - t) * start.x + 2 * (1 - t) * t * control.x + t * t * end.x); - int y = (int)((1 - t) * (1 - t) * start.y + 2 * (1 - t) * t * control.y + t * t * end.y); + double t = (double) i / segments; + int x = (int) ((1 - t) * (1 - t) * start.x + 2 * (1 - t) * t * control.x + t * t * end.x); + int y = (int) ((1 - t) * (1 - t) * start.y + 2 * (1 - t) * t * control.y + t * t * end.y); Point curr = new Point(x, y); if (prev != null) { double d = distancePointToSegment(px, py, prev, curr); @@ -774,42 +970,235 @@ public abstract class GuiDiagram extends Gui { } return minDist; } + private double distancePointToSegment(int px, int py, Point a, Point b) { double A = px - a.x, B = py - a.y, C = b.x - a.x, D = b.y - a.y; double dot = A * C + B * D; double lenSq = C * C + D * D; double param = (lenSq != 0) ? (dot / lenSq) : -1; double xx, yy; - if (param < 0) { xx = a.x; yy = a.y; } - else if (param > 1) { xx = b.x; yy = b.y; } - else { xx = a.x + param * C; yy = a.y + param * D; } + if (param < 0) { + xx = a.x; + yy = a.y; + } else if (param > 1) { + xx = b.x; + yy = b.y; + } else { + xx = a.x + param * C; + yy = a.y + param * D; + } double dx = px - xx, dy = py - yy; return Math.sqrt(dx * dx + dy * dy); } - // --- CHART Layout Drawing (unchanged) --- private void drawChartDiagram(int mouseX, int mouseY, boolean subGui) { - // ... (chart layout code remains unchanged) Minecraft mc = Minecraft.getMinecraft(); ScaledResolution sr = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight); int factor = sr.getScaleFactor(); + + // 1. Draw the static background for the entire diagram. drawRect(x, y, x + width, y + height, 0xFF333333); + + // 2. Setup scissor to clip drawing to the diagram area. GL11.glEnable(GL11.GL_SCISSOR_TEST); GL11.glScissor(x * factor, (sr.getScaledHeight() - (y + height)) * factor, width * factor, height * factor); + + // 3. Push a matrix and apply pan/zoom for grid, icons, and overlays. GL11.glPushMatrix(); - int centerX = x + width / 2, centerY = y + height / 2; + int centerX = x + width / 2; + int centerY = y + height / 2; GL11.glTranslatef(centerX + panX, centerY + panY, 0); GL11.glScalef(zoom, zoom, 1.0f); GL11.glTranslatef(-centerX, -centerY, 0); - // ... rest of chart drawing code + + // 4. Compute grid parameters. + List icons = getIcons(); + int n = icons.size(); + int cols = n + 1, rows = n + 1; + int cellSize = Math.min(width / cols, height / rows); + int gridWidth = cellSize * cols; + int gridHeight = cellSize * rows; + int startX = x + (width - gridWidth) / 2; + int startY = y + (height - gridHeight) / 2; + + // 5. Draw grid cells. + for (int row = 0; row < rows; row++) { + for (int col = 0; col < cols; col++) { + int cellX = startX + col * cellSize; + int cellY = startY + row * cellSize; + int fillColor = 0xFFCCCCCC; // Default for header cells. + if (row > 0 && col > 0) { // inner cell: use connection color (or darker gray) + DiagramIcon leftIcon = icons.get(row - 1); + DiagramIcon topIcon = icons.get(col - 1); + DiagramConnection conn = getConnectionByIds(leftIcon.id, topIcon.id); + fillColor = (conn != null) ? getConnectionColor(conn) : 0xFF777777; + } + drawRect(cellX, cellY, cellX + cellSize, cellY + cellSize, fillColor); + } + } + + // 6. Draw grid lines. + GL11.glPushAttrib(GL11.GL_ENABLE_BIT); + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glColor4f(0, 0, 0, 1); + GL11.glLineWidth(1.0f); + GL11.glBegin(GL11.GL_LINES); + for (int col = 0; col <= cols; col++) { + int xLine = startX + col * cellSize; + GL11.glVertex2i(xLine, startY); + GL11.glVertex2i(xLine, startY + gridHeight); + } + for (int row = 0; row <= rows; row++) { + int yLine = startY + row * cellSize; + GL11.glVertex2i(startX, yLine); + GL11.glVertex2i(startX + gridWidth, yLine); + } + GL11.glEnd(); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glPopAttrib(); + + // 7. Draw header icons (top and left) scaled to fit within each cell. + float iconMargin = 1f; // margin in pixels inside the cell. + float iconScale = (cellSize - iconMargin) / (float) iconSize; + for (int i = 0; i < n; i++) { + // Top header icon: + int topHeaderCenterX = startX + (i + 1) * cellSize + cellSize / 2; + int topHeaderCenterY = startY + cellSize / 2; + GL11.glPushMatrix(); + GL11.glTranslatef(topHeaderCenterX, topHeaderCenterY, 0); + GL11.glScalef(iconScale, iconScale, 1); + // renderIcon should draw centered at (0,0) + renderIcon(icons.get(i), 0, 0, IconRenderState.DEFAULT); + GL11.glPopMatrix(); + + // Left header icon: + int leftHeaderCenterX = startX + cellSize / 2; + int leftHeaderCenterY = startY + (i + 1) * cellSize + cellSize / 2; + GL11.glPushMatrix(); + GL11.glTranslatef(leftHeaderCenterX, leftHeaderCenterY, 0); + GL11.glScalef(iconScale, iconScale, 1); + renderIcon(icons.get(i), 0, 0, IconRenderState.DEFAULT); + GL11.glPopMatrix(); + } + + // 8. Compute effective mouse coordinates (reverse pan/zoom). + int effectiveMouseX = (int) (((float) mouseX - (centerX + panX)) / zoom + centerX); + int effectiveMouseY = (int) (((float) mouseY - (centerY + panY)) / zoom + centerY); + + // 9. Determine hover state on the grid. + boolean hoverInGrid = (effectiveMouseX >= startX && effectiveMouseX < startX + gridWidth && + effectiveMouseY >= startY && effectiveMouseY < startY + gridHeight); + int hoveredRow = -1, hoveredCol = -1; + Set highlightTop = new HashSet<>(); + Set highlightLeft = new HashSet<>(); + List tooltipToShow = null; + if (hoverInGrid) { + int colIndex = (effectiveMouseX - startX) / cellSize; + int rowIndex = (effectiveMouseY - startY) / cellSize; + // If hovering over a top header cell. + if (rowIndex == 0 && colIndex >= 1) { + highlightTop.add(colIndex - 1); + tooltipToShow = getIconTooltip(icons.get(colIndex - 1)); + onIconHover(icons.get(colIndex - 1)); + } + // If hovering over a left header cell. + else if (colIndex == 0 && rowIndex >= 1) { + highlightLeft.add(rowIndex - 1); + tooltipToShow = getIconTooltip(icons.get(rowIndex - 1)); + onIconHover(icons.get(rowIndex - 1)); + } + // Else, hovering over an inner cell. + else if (rowIndex >= 1 && colIndex >= 1) { + hoveredRow = rowIndex - 1; + hoveredCol = colIndex - 1; + highlightTop.add(hoveredCol); + highlightLeft.add(hoveredRow); + DiagramIcon leftIcon = icons.get(hoveredRow); + DiagramIcon topIcon = icons.get(hoveredCol); + DiagramConnection conn = getConnectionByIds(leftIcon.id, topIcon.id); + if (conn != null) { + tooltipToShow = getConnectionTooltip(conn); + onConnectionHover(conn); + } + } + } + + // 10. Draw hover overlay: + // Dim all inner cells (row>=1 & col>=1) not in highlighted row/column. + GL11.glPushAttrib(GL11.GL_ENABLE_BIT); + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glColor4f(0, 0, 0, 0.5f); + GL11.glBegin(GL11.GL_QUADS); + for (int r = 1; r < rows; r++) { + for (int c = 1; c < cols; c++) { + boolean keepBright = false; + if (!highlightTop.isEmpty() && highlightTop.contains(c - 1)) + keepBright = true; + if (!highlightLeft.isEmpty() && highlightLeft.contains(r - 1)) + keepBright = true; + // Also, if a specific cell is hovered, its entire row/column is bright. + if (hoveredRow != -1 && hoveredCol != -1) { + if (r - 1 == hoveredRow || c - 1 == hoveredCol) + keepBright = true; + } + if (!keepBright) { + int cellX = startX + c * cellSize; + int cellY = startY + r * cellSize; + GL11.glVertex2i(cellX, cellY); + GL11.glVertex2i(cellX + cellSize, cellY); + GL11.glVertex2i(cellX + cellSize, cellY + cellSize); + GL11.glVertex2i(cellX, cellY + cellSize); + } + } + } + GL11.glEnd(); + // Then draw a white overlay on the highlighted headers/inner cell. + GL11.glColor4f(1, 1, 1, 0.3f); + GL11.glBegin(GL11.GL_QUADS); + for (int i = 0; i < n; i++) { + if (highlightTop.contains(i)) { + int hx = startX + (i + 1) * cellSize; + int hy = startY; + GL11.glVertex2i(hx, hy); + GL11.glVertex2i(hx + cellSize, hy); + GL11.glVertex2i(hx + cellSize, hy + cellSize); + GL11.glVertex2i(hx, hy + cellSize); + } + if (highlightLeft.contains(i)) { + int hx = startX; + int hy = startY + (i + 1) * cellSize; + GL11.glVertex2i(hx, hy); + GL11.glVertex2i(hx + cellSize, hy); + GL11.glVertex2i(hx + cellSize, hy + cellSize); + GL11.glVertex2i(hx, hy + cellSize); + } + } + if (hoveredRow != -1 && hoveredCol != -1) { + int cellX = startX + (hoveredCol + 1) * cellSize; + int cellY = startY + (hoveredRow + 1) * cellSize; + GL11.glVertex2i(cellX, cellY); + GL11.glVertex2i(cellX + cellSize, cellY); + GL11.glVertex2i(cellX + cellSize, cellY + cellSize); + GL11.glVertex2i(cellX, cellY + cellSize); + } + GL11.glEnd(); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glPopAttrib(); + + // End pan/zoom block. GL11.glPopMatrix(); GL11.glDisable(GL11.GL_SCISSOR_TEST); + + // 11. Draw tooltip (using raw screen coordinates). + if (tooltipToShow != null && !tooltipToShow.isEmpty()) { + drawHoveringText(tooltipToShow, mouseX, mouseY, mc.fontRenderer); + } } /** * Main method for drawing the diagram. - * For non‑Chart layouts, applies pan/zoom, draws connections (with improved curved hit-detection) - * and icons, and shows tooltips. + * Applies pan/zoom, draws connections (using adjusted endpoints for separate two-way lines), + * icons, and shows tooltips. */ public void drawDiagram(int mouseX, int mouseY, boolean subGui) { boolean allowInput = (parent == null || !parent.hasSubGui()); @@ -824,8 +1213,8 @@ public abstract class GuiDiagram extends Gui { int factor = sr.getScaleFactor(); Map positions = calculatePositions(); int centerX = x + width / 2, centerY = y + height / 2; - int effectiveMouseX = (int)(((float)mouseX - (centerX + panX)) / zoom + centerX); - int effectiveMouseY = (int)(((float)mouseY - (centerY + panY)) / zoom + centerY); + int effectiveMouseX = (int) (((float) mouseX - (centerX + panX)) / zoom + centerX); + int effectiveMouseY = (int) (((float) mouseY - (centerY + panY)) / zoom + centerY); Integer hoveredIconId = null; int hoveredConnFrom = -1, hoveredConnTo = -1; Set selectedIconIds = new HashSet<>(); @@ -844,7 +1233,6 @@ public abstract class GuiDiagram extends Gui { } if (hoveredIconId == null) { final double threshold = 5.0; - outer: for (DiagramConnection conn : getConnections()) { DiagramIcon iconFrom = getIconById(conn.idFrom); DiagramIcon iconTo = getIconById(conn.idTo); @@ -854,18 +1242,51 @@ public abstract class GuiDiagram extends Gui { Point pTo = positions.get(conn.idTo); if (pFrom == null || pTo == null) continue; double dist; - if (curvedArrows) { - // Compute both potential control points - Point cp1 = computeControlPoint(pFrom.x, pFrom.y, pTo.x, pTo.y, curveAngle); - Point cp2 = computeControlPoint(pFrom.x, pFrom.y, pTo.x, pTo.y, -curveAngle); - // Choose the control point that's farther from interfering icons (as done when drawing) - double d1 = getMinDistanceToIcon(cp1, conn); - double d2 = getMinDistanceToIcon(cp2, conn); - Point control = (d1 >= d2) ? cp1 : cp2; - // Use the chosen control point for hit detection - dist = distanceToBezier(pFrom, control, pTo, 200, effectiveMouseX, effectiveMouseY); + boolean separateTwoWay = (getConnectionByIds(conn.idTo, conn.idFrom) != null && !allowTwoWay); + boolean useCustomCurveAngle = (conn.customAllowCurve != null ? conn.customAllowCurve : this.curvedArrows); + if (separateTwoWay) { + if (useCustomCurveAngle) { + int offsetAmount = 4; + double dx = pTo.x - pFrom.x, dy = pTo.y - pFrom.y; + double len = Math.sqrt(dx * dx + dy * dy); + if (len == 0) len = 1; + double normX = -dy / len; + double normY = dx / len; + double sign = (conn.idFrom < conn.idTo) ? 1 : -1; + int effectiveCurveAngle = (conn.customCurveAngle != null ? conn.customCurveAngle : this.curveAngle); + Point baseControl = computeControlPoint(pFrom.x, pFrom.y, pTo.x, pTo.y, effectiveCurveAngle); + Point offsetControl = new Point(baseControl.x + (int) (normX * offsetAmount * sign), + baseControl.y + (int) (normY * offsetAmount * sign)); + dist = distanceToBezier(pFrom, offsetControl, pTo, 200, effectiveMouseX, effectiveMouseY); + } else { + int offsetAmount = 4; + double dx = pTo.x - pFrom.x, dy = pTo.y - pFrom.y; + double len = Math.sqrt(dx * dx + dy * dy); + if (len == 0) len = 1; + double offsetX = -dy / len * offsetAmount; + double offsetY = dx / len * offsetAmount; + if (conn.idFrom >= conn.idTo) { + offsetX = -offsetX; + offsetY = -offsetY; + } + int newX1 = pFrom.x + (int) offsetX; + int newY1 = pFrom.y + (int) offsetY; + int newX2 = pTo.x + (int) offsetX; + int newY2 = pTo.y + (int) offsetY; + dist = pointLineDistance(effectiveMouseX, effectiveMouseY, newX1, newY1, newX2, newY2); + } } else { - dist = pointLineDistance(effectiveMouseX, effectiveMouseY, pFrom.x, pFrom.y, pTo.x, pTo.y); + if (useCustomCurveAngle) { + int effectiveCurveAngle = (conn.customCurveAngle != null ? conn.customCurveAngle : this.curveAngle); + Point cp1 = computeControlPoint(pFrom.x, pFrom.y, pTo.x, pTo.y, effectiveCurveAngle); + Point cp2 = computeControlPoint(pFrom.x, pFrom.y, pTo.x, pTo.y, -effectiveCurveAngle); + double d1 = getMinDistanceToIcon(cp1, conn); + double d2 = getMinDistanceToIcon(cp2, conn); + Point control = (d1 >= d2) ? cp1 : cp2; + dist = distanceToBezier(pFrom, control, pTo, 200, effectiveMouseX, effectiveMouseY); + } else { + dist = pointLineDistance(effectiveMouseX, effectiveMouseY, pFrom.x, pFrom.y, pTo.x, pTo.y); + } } if (dist < threshold) { hoveredConnFrom = conn.idFrom; @@ -873,7 +1294,6 @@ public abstract class GuiDiagram extends Gui { selectedIconIds.add(conn.idFrom); selectedIconIds.add(conn.idTo); onConnectionHover(conn); - break outer; } } } @@ -893,7 +1313,12 @@ public abstract class GuiDiagram extends Gui { Point pTo = positions.get(conn.idTo); if (pFrom == null || pTo == null) continue; int ax = pFrom.x, ay = pFrom.y, bx = pTo.x, by = pTo.y; - boolean dim = !selectedIconIds.isEmpty() && !(selectedIconIds.contains(conn.idFrom) && selectedIconIds.contains(conn.idTo)); + boolean dim; + if (hoveredIconId != null) { + dim = (conn.idFrom != hoveredIconId); + } else { + dim = !selectedIconIds.isEmpty() && !(selectedIconIds.contains(conn.idFrom) && selectedIconIds.contains(conn.idTo)); + } drawConnectionLine(ax, ay, bx, by, conn, dim); } for (DiagramIcon icon : getIcons()) { @@ -913,6 +1338,10 @@ public abstract class GuiDiagram extends Gui { GL11.glScalef(zoom, zoom, 1.0f); GL11.glTranslatef(-centerX, -centerY, 0); for (DiagramConnection conn : getConnections()) { + boolean showArrow = (conn.showArrowHead != null ? conn.showArrowHead : this.showArrowHeads); + if(!showArrow) + continue; + DiagramIcon iconFrom = getIconById(conn.idFrom); DiagramIcon iconTo = getIconById(conn.idTo); if (iconFrom == null || iconTo == null || !iconFrom.enabled || !iconTo.enabled) @@ -921,7 +1350,12 @@ public abstract class GuiDiagram extends Gui { Point pTo = positions.get(conn.idTo); if (pFrom == null || pTo == null) continue; int ax = pFrom.x, ay = pFrom.y, bx = pTo.x, by = pTo.y; - boolean dim = !selectedIconIds.isEmpty() && !(selectedIconIds.contains(conn.idFrom) && selectedIconIds.contains(conn.idTo)); + boolean dim; + if (hoveredIconId != null) { + dim = (conn.idFrom != hoveredIconId); + } else { + dim = !selectedIconIds.isEmpty() && !(selectedIconIds.contains(conn.idFrom) && selectedIconIds.contains(conn.idTo)); + } drawArrowHead(ax, ay, bx, by, conn, dim); } GL11.glPopMatrix(); @@ -940,6 +1374,28 @@ public abstract class GuiDiagram extends Gui { } } + protected void drawIconBox(int slotX, int slotY, int slotSize, boolean highlighted) { + int bg = highlighted ? mixColors(iconBackgroundColor, 0xFFFFFFFF, 0.2f) : iconBackgroundColor; + drawRect(slotX, slotY, slotX + slotSize, slotY + slotSize, bg); + for (int i = 0; i < iconBorderThickness; i++) { + drawHorizontalLine(slotX + i, slotX + slotSize - i, slotY + i, iconBorderColor); + drawHorizontalLine(slotX + i, slotX + slotSize - i, slotY + slotSize - 1 - i, iconBorderColor); + drawVerticalLine(slotX + i, slotY + i, slotY + slotSize - i, iconBorderColor); + drawVerticalLine(slotX + slotSize - 1 - i, slotY + i, slotY + slotSize - i, iconBorderColor); + } + } + + protected int mixColors(int color1, int color2, float ratio) { + int a1 = (color1 >> 24) & 0xFF, r1 = (color1 >> 16) & 0xFF, g1 = (color1 >> 8) & 0xFF, b1 = color1 & 0xFF; + int a2 = (color2 >> 24) & 0xFF, r2 = (color2 >> 16) & 0xFF, g2 = (color2 >> 8) & 0xFF, b2 = color2 & 0xFF; + int a = (int) (a1 + (a2 - a1) * ratio); + int r = (int) (r1 + (r2 - r1) * ratio); + int g = (int) (g1 + (g2 - g1) * ratio); + int b = (int) (b1 + (b2 - b1) * ratio); + return (a << 24) | (r << 16) | (g << 8) | b; + } + + // --- Utility Methods --- protected DiagramIcon getIconById(int id) { for (DiagramIcon icon : getIcons()) { @@ -947,37 +1403,50 @@ public abstract class GuiDiagram extends Gui { } return null; } + protected DiagramConnection getConnectionByIds(int idFrom, int idTo) { for (DiagramConnection conn : getConnections()) { if (conn.idFrom == idFrom && conn.idTo == idTo) return conn; } return null; } + protected int getConnectionColor(DiagramConnection conn) { - float percent = conn.percent; - if (percent <= 0.10f) return 0xFF80FF80; - else if (percent <= 0.40f) return 0xFFCCFF66; - else if (percent <= 0.50f) return 0xFFFFA500; - else { - float ratio = (percent - 0.50f) / 0.50f; - ratio = Math.min(1f, Math.max(0f, ratio)); - int r1 = 0xFF, g1 = 0xA5, b1 = 0x00; - int r2 = 0xFF, g2 = 0x00, b2 = 0x00; - int r = r1 + (int)((r2 - r1) * ratio); - int g = g1 + (int)((g2 - g1) * ratio); - int b = b1 + (int)((b2 - b1) * ratio); - return (0xFF << 24) | (r << 16) | (g << 8) | b; + if (conn.customColor != null) { + return conn.customColor; } + float value = Math.max(-1f, Math.min(1f, conn.percent)); + int r, g, b; + if (value >= 0f) { + float t = value; + r = (int)(144 + (0 - 144) * t); + g = (int)(238 + (100 - 238) * t); + b = (int)(144 + (0 - 144) * t); + } else { + float t = -value; + r = (int)(255 + (139 - 255) * t); + g = (int)(200 + (0 - 200) * t); + b = 0; + } + return (0xFF << 24) | (r << 16) | (g << 8) | b; } + private double pointLineDistance(int px, int py, int x1, int y1, int x2, int y2) { double A = px - x1, B = py - y1, C = x2 - x1, D = y2 - y1; double dot = A * C + B * D; double lenSq = C * C + D * D; double param = (lenSq != 0) ? (dot / lenSq) : -1; double xx, yy; - if (param < 0) { xx = x1; yy = y1; } - else if (param > 1) { xx = x2; yy = y2; } - else { xx = x1 + param * C; yy = y1 + param * D; } + if (param < 0) { + xx = x1; + yy = y1; + } else if (param > 1) { + xx = x2; + yy = y2; + } else { + xx = x1 + param * C; + yy = y1 + param * D; + } double dx = px - xx, dy = py - yy; return Math.sqrt(dx * dx + dy * dy); } @@ -991,8 +1460,8 @@ public abstract class GuiDiagram extends Gui { Point pos = calculatePositions().get(icon.id); if (pos == null) continue; int centerX = x + width / 2, centerY = y + height / 2; - int effectiveX = (int)(((float)mouseX - (centerX + panX)) / zoom + centerX); - int effectiveY = (int)(((float)mouseY - (centerY + panY)) / zoom + centerY); + int effectiveX = (int) (((float) mouseX - (centerX + panX)) / zoom + centerX); + int effectiveY = (int) (((float) mouseY - (centerY + panY)) / zoom + centerY); int slotX = pos.x - slotSize / 2, slotY = pos.y - slotSize / 2; if (effectiveX >= slotX && effectiveX < slotX + slotSize && effectiveY >= slotY && effectiveY < slotY + slotSize) { @@ -1010,7 +1479,9 @@ public abstract class GuiDiagram extends Gui { } return false; } + protected DiagramIcon currentlyPressedIcon = null; + public void mouseClickMove(int mouseX, int mouseY, int mouseButton, long timeSinceLastClick) { if (parent != null && parent.hasSubGui()) return; if (dragging) { @@ -1022,6 +1493,7 @@ public abstract class GuiDiagram extends Gui { } if (currentlyPressedIcon != null) onIconHeld(currentlyPressedIcon); } + public void mouseReleased(int mouseX, int mouseY, int state) { if (parent != null && parent.hasSubGui()) return; if (currentlyPressedIcon != null) { @@ -1030,32 +1502,46 @@ public abstract class GuiDiagram extends Gui { } dragging = false; } + public boolean isWithin(int mouseX, int mouseY) { if (parent.hasSubGui()) return false; return mouseX >= x && mouseX <= x + width && mouseY >= y && mouseY <= y + height; } + public void handleMouseScroll(int scrollDelta) { zoom += scrollDelta * 0.0009f; - if (zoom < 0.5f) zoom = 0.5f; - if (zoom > 2.0f) zoom = 2.0f; + if (zoom < 0.2f) zoom = 0.2f; + if (zoom > 3.0f) zoom = 3.0f; + } + + protected void drawHoveringText(List textLines, int mouseX, int mouseY, FontRenderer font) { } - protected void drawHoveringText(List textLines, int mouseX, int mouseY, FontRenderer font) {} // --- Flag Setters --- public void setShowArrowHeads(boolean showArrowHeads) { this.showArrowHeads = showArrowHeads; } + public void setUseColorScaling(boolean useColorScaling) { this.useColorScaling = useColorScaling; } // --- Icon and Connection Event Callbacks --- - protected void onIconClick(DiagramIcon icon) {} - protected void onIconHeld(DiagramIcon icon) {} - protected void onIconRelease(DiagramIcon icon) {} - protected void onIconHover(DiagramIcon icon) {} - protected void onConnectionHover(DiagramConnection conn) {} + protected void onIconClick(DiagramIcon icon) { + } + + protected void onIconHeld(DiagramIcon icon) { + } + + protected void onIconRelease(DiagramIcon icon) { + } + + protected void onIconHover(DiagramIcon icon) { + } + + protected void onConnectionHover(DiagramConnection conn) { + } // --- Inner Helper Classes --- public static class DiagramIcon { @@ -1064,7 +1550,11 @@ public abstract class GuiDiagram extends Gui { public boolean pressable = false; public int index = 0; public int priority = 0; - public DiagramIcon(int id) { this.id = id; } + + public DiagramIcon(int id) { + this.id = id; + } + public DiagramIcon(int id, int index, int priority) { this.id = id; this.index = index; @@ -1076,6 +1566,11 @@ public abstract class GuiDiagram extends Gui { public int idFrom, idTo; public float percent; public String hoverText; + public Integer customCurveAngle = null; + public Integer customColor = null; + public Boolean customAllowCurve = null; + public Boolean showArrowHead = null; + public DiagramConnection(int idFrom, int idTo, float percent, String hoverText) { this.idFrom = idFrom; this.idTo = idTo; diff --git a/src/main/java/noppes/npcs/client/gui/util/GuiHoverText.java b/src/main/java/noppes/npcs/client/gui/util/GuiHoverText.java index db79ff1ac..8e5d3f722 100644 --- a/src/main/java/noppes/npcs/client/gui/util/GuiHoverText.java +++ b/src/main/java/noppes/npcs/client/gui/util/GuiHoverText.java @@ -8,12 +8,11 @@ import java.util.ArrayList; import java.util.List; public class GuiHoverText extends GuiScreen { - private final int x; - private final int y; + private int x, y; public int id; protected static final ResourceLocation buttonTextures = new ResourceLocation("customnpcs:textures/gui/info.png"); - private final String text; + private String text; public GuiHoverText(int id, String text, int x, int y) { this.text = text; @@ -37,6 +36,8 @@ public class GuiHoverText extends GuiScreen { } public boolean inArea(int x, int y, int width, int height, int mouseX, int mouseY) { - return mouseX >= x && mouseX <= x + width && mouseY >= y && mouseY <= y + height; + if (mouseX < x || mouseX > x + width || mouseY < y || mouseY > y + height) + return false; + return true; } } diff --git a/src/main/java/noppes/npcs/client/gui/util/GuiMenuTopIconButton.java b/src/main/java/noppes/npcs/client/gui/util/GuiMenuTopIconButton.java index d8d434ab2..c49509d94 100644 --- a/src/main/java/noppes/npcs/client/gui/util/GuiMenuTopIconButton.java +++ b/src/main/java/noppes/npcs/client/gui/util/GuiMenuTopIconButton.java @@ -62,7 +62,7 @@ public class GuiMenuTopIconButton extends GuiMenuTopButton { if (hover && !active) { int x = i + mc.fontRenderer.getStringWidth(displayString); GL11.glTranslatef(x, yPosition + 2, 0); - drawHoveringText(Arrays.asList(displayString), 0, 0, mc.fontRenderer); + drawHoveringText(Arrays.asList(new String[]{displayString}), 0, 0, mc.fontRenderer); GL11.glTranslatef(-x, -(yPosition + 2), 0); } mc.getTextureManager().bindTexture(resource); diff --git a/src/main/java/noppes/npcs/client/gui/util/GuiModelInterface2.java b/src/main/java/noppes/npcs/client/gui/util/GuiModelInterface2.java index 5b8080d56..16d3af9d7 100644 --- a/src/main/java/noppes/npcs/client/gui/util/GuiModelInterface2.java +++ b/src/main/java/noppes/npcs/client/gui/util/GuiModelInterface2.java @@ -1,6 +1,7 @@ package noppes.npcs.client.gui.util; import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.entity.RenderManager; @@ -57,7 +58,7 @@ public class GuiModelInterface2 extends GuiNPCInterface2 { return false; } - private final long start = -1; + private long start = -1; @Override public void drawScreen(int par1, int par2, float par3) { @@ -147,7 +148,7 @@ public class GuiModelInterface2 extends GuiNPCInterface2 { } public void close() { - this.mc.displayGuiScreen(null); + this.mc.displayGuiScreen((GuiScreen) null); this.mc.setIngameFocus(); } diff --git a/src/main/java/noppes/npcs/client/gui/util/GuiNPCInterface2.java b/src/main/java/noppes/npcs/client/gui/util/GuiNPCInterface2.java index 048fbfc4e..7c9f1d43e 100644 --- a/src/main/java/noppes/npcs/client/gui/util/GuiNPCInterface2.java +++ b/src/main/java/noppes/npcs/client/gui/util/GuiNPCInterface2.java @@ -5,8 +5,8 @@ import noppes.npcs.entity.EntityNPCInterface; import org.lwjgl.opengl.GL11; public abstract class GuiNPCInterface2 extends GuiNPCInterface { - private final ResourceLocation background = new ResourceLocation("customnpcs:textures/gui/menubg.png"); - private final GuiNpcMenu menu; + private ResourceLocation background = new ResourceLocation("customnpcs:textures/gui/menubg.png"); + private GuiNpcMenu menu; public GuiNPCInterface2(EntityNPCInterface npc) { this(npc, -1); diff --git a/src/main/java/noppes/npcs/client/gui/util/GuiNpcLabel.java b/src/main/java/noppes/npcs/client/gui/util/GuiNpcLabel.java index d5b6cfcdf..f620e1e63 100644 --- a/src/main/java/noppes/npcs/client/gui/util/GuiNpcLabel.java +++ b/src/main/java/noppes/npcs/client/gui/util/GuiNpcLabel.java @@ -11,6 +11,7 @@ public class GuiNpcLabel { public int x, y, color; public boolean enabled = true; public int id; + public boolean drawShadow = false; public GuiNpcLabel(int id, Object label, int x, int y, int color) { this.id = id; @@ -26,7 +27,7 @@ public class GuiNpcLabel { public void drawLabel(GuiScreen gui, FontRenderer fontRenderer) { if (enabled) - fontRenderer.drawString(label, x, y, color); + fontRenderer.drawString(label, x, y, color, drawShadow); } public void center(int width) { diff --git a/src/main/java/noppes/npcs/client/gui/util/GuiNpcTextArea.java b/src/main/java/noppes/npcs/client/gui/util/GuiNpcTextArea.java index 703c05c5b..18584f85d 100644 --- a/src/main/java/noppes/npcs/client/gui/util/GuiNpcTextArea.java +++ b/src/main/java/noppes/npcs/client/gui/util/GuiNpcTextArea.java @@ -17,18 +17,15 @@ import java.util.List; public class GuiNpcTextArea extends GuiNpcTextField { public boolean inMenu = true; public boolean numbersOnly = false; - private final int posX; - private final int posY; - private final int width; - private final int height; + private int posX, posY, width, height; private int cursorCounter; - private final FontContainer font; + private FontContainer font; private int cursorPosition = 0; private int listHeight; private float scrolledY = 0; private int startClick = -1; private boolean clickVerticalBar = false; - private final boolean wrapLine = true; + private boolean wrapLine = true; private List lines = new ArrayList<>(); public GuiNpcTextArea(int id, GuiScreen guiscreen, int i, int j, int k, int l, String s) { @@ -263,7 +260,10 @@ public class GuiNpcTextArea extends GuiNpcTextField { if (listHeight <= height - 4) return false; - return posY < y && posY + height > y && x < posX + width && x > posX + (width - 8); + if (posY < y && posY + height > y && x < posX + width && x > posX + (width - 8)) + return true; + + return false; } private void drawCursorVertical(int p_146188_1_, int p_146188_2_, int p_146188_3_, int p_146188_4_) { @@ -295,10 +295,10 @@ public class GuiNpcTextArea extends GuiNpcTextField { GL11.glEnable(GL11.GL_COLOR_LOGIC_OP); GL11.glLogicOp(GL11.GL_OR_REVERSE); tessellator.startDrawingQuads(); - tessellator.addVertex(p_146188_1_, p_146188_4_, 0.0D); - tessellator.addVertex(p_146188_3_, p_146188_4_, 0.0D); - tessellator.addVertex(p_146188_3_, p_146188_2_, 0.0D); - tessellator.addVertex(p_146188_1_, p_146188_2_, 0.0D); + tessellator.addVertex((double) p_146188_1_, (double) p_146188_4_, 0.0D); + tessellator.addVertex((double) p_146188_3_, (double) p_146188_4_, 0.0D); + tessellator.addVertex((double) p_146188_3_, (double) p_146188_2_, 0.0D); + tessellator.addVertex((double) p_146188_1_, (double) p_146188_2_, 0.0D); tessellator.draw(); GL11.glDisable(GL11.GL_COLOR_LOGIC_OP); GL11.glEnable(GL11.GL_TEXTURE_2D); diff --git a/src/main/java/noppes/npcs/client/gui/util/GuiScriptTextArea.java b/src/main/java/noppes/npcs/client/gui/util/GuiScriptTextArea.java index 9c8ec8dcc..205351715 100644 --- a/src/main/java/noppes/npcs/client/gui/util/GuiScriptTextArea.java +++ b/src/main/java/noppes/npcs/client/gui/util/GuiScriptTextArea.java @@ -402,7 +402,7 @@ public class GuiScriptTextArea extends GuiNpcTextField { addText(" "); } if (i == Keyboard.KEY_RETURN) { - addText('\n' + getIndentCurrentLine()); + addText(Character.toString('\n') + getIndentCurrentLine()); } if (ChatAllowedCharacters.isAllowedCharacter(c)) { addText(Character.toString(c)); @@ -453,6 +453,7 @@ public class GuiScriptTextArea extends GuiNpcTextField { int i; for (i = 0; i < data.text.length() && data.text.charAt(i) == 32; ++i) { + ; } return data.text.substring(0, i); @@ -489,7 +490,7 @@ public class GuiScriptTextArea extends GuiNpcTextField { private int cursorUp() { for (int i = 0; i < this.container.lines.size(); ++i) { - LineData data = this.container.lines.get(i); + LineData data = (LineData) this.container.lines.get(i); if (this.cursorPosition >= data.start && this.cursorPosition < data.end) { if (i == 0) { return 0; @@ -505,7 +506,7 @@ public class GuiScriptTextArea extends GuiNpcTextField { private int cursorDown() { for (int i = 0; i < this.container.lines.size(); ++i) { - LineData data = this.container.lines.get(i); + LineData data = (LineData) this.container.lines.get(i); if (this.cursorPosition >= data.start && this.cursorPosition < data.end) { int var10000 = this.cursorPosition - data.start; return this.getSelectionPos(this.x + 1 + ClientProxy.Font.width(data.text.substring(0, this.cursorPosition - data.start)), this.y + 1 + (i + 1 - this.scrolledLine) * this.container.lineHeight); diff --git a/src/main/java/noppes/npcs/client/gui/util/GuiSelectionListener.java b/src/main/java/noppes/npcs/client/gui/util/GuiSelectionListener.java index 4f0e746b9..e8e78ff87 100644 --- a/src/main/java/noppes/npcs/client/gui/util/GuiSelectionListener.java +++ b/src/main/java/noppes/npcs/client/gui/util/GuiSelectionListener.java @@ -1,5 +1,5 @@ package noppes.npcs.client.gui.util; public interface GuiSelectionListener { - void selected(int id, String name); + public void selected(int id, String name); } diff --git a/src/main/java/noppes/npcs/client/gui/util/GuiTexturedButton.java b/src/main/java/noppes/npcs/client/gui/util/GuiTexturedButton.java index b0ab3248f..cf246292b 100644 --- a/src/main/java/noppes/npcs/client/gui/util/GuiTexturedButton.java +++ b/src/main/java/noppes/npcs/client/gui/util/GuiTexturedButton.java @@ -8,6 +8,8 @@ import net.minecraft.client.renderer.texture.ITextureObject; import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.client.resources.IResource; import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; +import noppes.npcs.client.ClientProxy; import noppes.npcs.client.ImageDownloadAlt; import noppes.npcs.client.renderer.ImageBufferDownloadAlt; import org.lwjgl.opengl.GL11; @@ -29,8 +31,8 @@ public class GuiTexturedButton extends GuiNpcButton { public float scale; private int totalWidth, totalHeight; - private final ImageDownloadAlt imageDownloadAlt = null; - private final boolean isUrl = false; + private ImageDownloadAlt imageDownloadAlt = null; + private boolean isUrl = false; private boolean gotWidthHeight = false; public GuiTexturedButton(int id, String buttonText, int x, int y) { @@ -49,7 +51,7 @@ public class GuiTexturedButton extends GuiNpcButton { super(buttonId, x, y, width, height, buttonText); this.textureX = textureX; this.textureY = textureY; - this.label = buttonText; + this.label = StatCollector.translateToLocal(buttonText); this.scale = 1.0F; this.color = 0xFFFFFF; this.alpha = 1.0F; @@ -91,7 +93,8 @@ public class GuiTexturedButton extends GuiNpcButton { mc.getTextureManager().bindTexture(this.location); this.drawTexturedModalRect(0, 0, this.textureX, this.textureY, this.width, this.height); GL11.glTranslated(0.0D, 0.0D, 0.1D); - this.drawCenteredString(mc.fontRenderer, this.label, this.width / 2, (this.height - 8) / 2, this.color); + this.drawCenteredString(mc.fontRenderer, this.label, (int) (this.xPosition + ((float)this.width)*scale / 2f), + (int) (this.yPosition+(((float)this.height)*scale- ClientProxy.Font.height()+4) / 2f), this.color); } else { FontRenderer fontrenderer = mc.fontRenderer; mc.getTextureManager().bindTexture(buttonTextures); @@ -156,8 +159,14 @@ public class GuiTexturedButton extends GuiNpcButton { } @Override - public boolean mousePressed(Minecraft minecraft, int i, int j) { - return super.mousePressed(minecraft, i, j) || this.field_146123_n; + public boolean mousePressed(Minecraft minecraft, int i, int j) + { + boolean bo = this.enabled && this.visible && i >= this.xPosition && j >= this.yPosition + && i < this.xPosition + this.width*scale && j < this.yPosition + this.height*scale; + if(bo && display != null && display.length != 0){ + setDisplay((getValue()+1) % display.length); + } + return bo; } public void getWidthHeight() throws IOException { diff --git a/src/main/java/noppes/npcs/client/gui/util/IButtonListener.java b/src/main/java/noppes/npcs/client/gui/util/IButtonListener.java index 8e9fd76c1..6c4b1d17d 100644 --- a/src/main/java/noppes/npcs/client/gui/util/IButtonListener.java +++ b/src/main/java/noppes/npcs/client/gui/util/IButtonListener.java @@ -3,5 +3,5 @@ package noppes.npcs.client.gui.util; import net.minecraft.client.gui.GuiButton; public interface IButtonListener { - void actionPerformed(GuiButton button); + public void actionPerformed(GuiButton button); } diff --git a/src/main/java/noppes/npcs/client/gui/util/IGuiClose.java b/src/main/java/noppes/npcs/client/gui/util/IGuiClose.java index 8f2db7183..61b8de415 100644 --- a/src/main/java/noppes/npcs/client/gui/util/IGuiClose.java +++ b/src/main/java/noppes/npcs/client/gui/util/IGuiClose.java @@ -3,5 +3,5 @@ package noppes.npcs.client.gui.util; import net.minecraft.nbt.NBTTagCompound; public interface IGuiClose { - void setClose(int i, NBTTagCompound data); + public void setClose(int i, NBTTagCompound data); } diff --git a/src/main/java/noppes/npcs/client/gui/util/IGuiData.java b/src/main/java/noppes/npcs/client/gui/util/IGuiData.java index 3037b7580..36ba683ac 100644 --- a/src/main/java/noppes/npcs/client/gui/util/IGuiData.java +++ b/src/main/java/noppes/npcs/client/gui/util/IGuiData.java @@ -3,5 +3,5 @@ package noppes.npcs.client.gui.util; import net.minecraft.nbt.NBTTagCompound; public interface IGuiData { - void setGuiData(NBTTagCompound compound); + public void setGuiData(NBTTagCompound compound); } diff --git a/src/main/java/noppes/npcs/client/gui/util/IGuiError.java b/src/main/java/noppes/npcs/client/gui/util/IGuiError.java index 608d89bfd..3a5a68a1f 100644 --- a/src/main/java/noppes/npcs/client/gui/util/IGuiError.java +++ b/src/main/java/noppes/npcs/client/gui/util/IGuiError.java @@ -3,5 +3,5 @@ package noppes.npcs.client.gui.util; import net.minecraft.nbt.NBTTagCompound; public interface IGuiError { - void setError(int i, NBTTagCompound data); + public void setError(int i, NBTTagCompound data); } diff --git a/src/main/java/noppes/npcs/client/gui/util/IJTextAreaListener.java b/src/main/java/noppes/npcs/client/gui/util/IJTextAreaListener.java index 930951b2d..a4d5593ec 100644 --- a/src/main/java/noppes/npcs/client/gui/util/IJTextAreaListener.java +++ b/src/main/java/noppes/npcs/client/gui/util/IJTextAreaListener.java @@ -1,5 +1,5 @@ package noppes.npcs.client.gui.util; public interface IJTextAreaListener { - void saveText(String text); + public void saveText(String text); } diff --git a/src/main/java/noppes/npcs/client/gui/util/IPartyData.java b/src/main/java/noppes/npcs/client/gui/util/IPartyData.java index b91084e6a..b96751a9e 100644 --- a/src/main/java/noppes/npcs/client/gui/util/IPartyData.java +++ b/src/main/java/noppes/npcs/client/gui/util/IPartyData.java @@ -3,5 +3,5 @@ package noppes.npcs.client.gui.util; import net.minecraft.nbt.NBTTagCompound; public interface IPartyData { - void setPartyData(NBTTagCompound compound); + public void setPartyData(NBTTagCompound compound); } diff --git a/src/main/java/noppes/npcs/client/gui/util/IScrollData.java b/src/main/java/noppes/npcs/client/gui/util/IScrollData.java index a451398d0..1df06aac5 100644 --- a/src/main/java/noppes/npcs/client/gui/util/IScrollData.java +++ b/src/main/java/noppes/npcs/client/gui/util/IScrollData.java @@ -6,7 +6,7 @@ import java.util.HashMap; import java.util.Vector; public interface IScrollData { - void setData(Vector list, HashMap data, EnumScrollData type); + public void setData(Vector list, HashMap data, EnumScrollData type); - void setSelected(String selected); + public void setSelected(String selected); } diff --git a/src/main/java/noppes/npcs/client/gui/util/ISubGuiListener.java b/src/main/java/noppes/npcs/client/gui/util/ISubGuiListener.java index 21d4667c8..cb5c94eb1 100644 --- a/src/main/java/noppes/npcs/client/gui/util/ISubGuiListener.java +++ b/src/main/java/noppes/npcs/client/gui/util/ISubGuiListener.java @@ -1,5 +1,5 @@ package noppes.npcs.client.gui.util; public interface ISubGuiListener { - void subGuiClosed(SubGuiInterface subgui); + public void subGuiClosed(SubGuiInterface subgui); } diff --git a/src/main/java/noppes/npcs/client/gui/util/TextContainer.java b/src/main/java/noppes/npcs/client/gui/util/TextContainer.java index c81f8c216..dc66332cb 100644 --- a/src/main/java/noppes/npcs/client/gui/util/TextContainer.java +++ b/src/main/java/noppes/npcs/client/gui/util/TextContainer.java @@ -160,15 +160,15 @@ public class TextContainer { int found = 0; for (MarkUp entry : makeup) { if (entry.start >= start && entry.start < end) { - builder.insert(entry.start - start + found * 2, Character.toString(colorChar) + entry.c); + builder.insert(entry.start - start + found * 2, Character.toString(colorChar) + Character.toString(entry.c)); found++; } if (entry.start < start && entry.end > start) { - builder.insert(0, Character.toString(colorChar) + entry.c); + builder.insert(0, Character.toString(colorChar) + Character.toString(entry.c)); found++; } if (entry.end >= start && entry.end < end) { - builder.insert(entry.end - start + found * 2, Character.toString(colorChar) + 'r'); + builder.insert(entry.end - start + found * 2, Character.toString(colorChar) + Character.toString('r')); found++; } } diff --git a/src/main/java/noppes/npcs/client/model/ModelMPM.java b/src/main/java/noppes/npcs/client/model/ModelMPM.java index 139583b30..f4d92a8dd 100644 --- a/src/main/java/noppes/npcs/client/model/ModelMPM.java +++ b/src/main/java/noppes/npcs/client/model/ModelMPM.java @@ -35,7 +35,7 @@ public class ModelMPM extends ModelNPCMale { private ModelPartInterface mohawk; private ModelPartInterface hair; private ModelPartInterface beard; - private final ModelPartInterface breasts; + private ModelPartInterface breasts; private ModelPartInterface snout; private ModelPartInterface ears; private ModelPartInterface fin; @@ -52,8 +52,8 @@ public class ModelMPM extends ModelNPCMale { public ModelRenderer bipedRightLegWear; public ModelRenderer bipedLeftLegWear; - private final ModelScaleRenderer headwear; - private final ModelScaleRenderer bodywear; + private ModelScaleRenderer headwear; + private ModelScaleRenderer bodywear; private final ModelScaleRenderer solidLeftArmWear; private final ModelScaleRenderer solidRightArmWear; private final ModelScaleRenderer solidLeftLegWear; @@ -185,8 +185,7 @@ public class ModelMPM extends ModelNPCMale { this.bipedHead.addChild(horns = new ModelHorns(this)); // Completed - tail = new ModelTail(this); - + this.bipedBody.addChild(tail = new ModelTail(this)); this.bipedBody.addChild(wings = new ModelWings(this)); this.bipedBody.addChild(fin = new ModelFin(this)); @@ -303,8 +302,7 @@ public class ModelMPM extends ModelNPCMale { this.bipedHead.addChild(horns = new ModelHorns(this)); // Completed - tail = new ModelTail(this); - + this.bipedBody.addChild(tail = new ModelTail(this)); this.bipedBody.addChild(wings = new ModelWings(this)); this.bipedBody.addChild(fin = new ModelFin(this)); @@ -355,7 +353,7 @@ public class ModelMPM extends ModelNPCMale { part.interpolateAngles(); } float pi = 180 / (float) Math.PI; - GL11.glTranslatef(part.prevPivots[0], part.prevPivots[1], part.prevPivots[2]); + GL11.glTranslatef(part.prevPivots[0], -part.prevPivots[1], part.prevPivots[2]); GL11.glRotatef(part.prevRotations[0] * pi, 1, 0, 0); GL11.glRotatef(part.prevRotations[1] * pi, 0, 1, 0); GL11.glRotatef(part.prevRotations[2] * pi, 0, 0, 1); @@ -401,7 +399,7 @@ public class ModelMPM extends ModelNPCMale { if (overlayData.getGlow()) { GL11.glDisable(GL11.GL_LIGHTING); - Minecraft.getMinecraft().entityRenderer.disableLightmap(0); + Minecraft.getMinecraft().entityRenderer.disableLightmap((double) 0); } GL11.glColor4f(1.0F, 1.0F, 1.0F, overlayData.getAlpha()); @@ -430,7 +428,7 @@ public class ModelMPM extends ModelNPCMale { GL11.glDepthFunc(GL11.GL_LEQUAL); GL11.glDisable(GL11.GL_BLEND); GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F); - Minecraft.getMinecraft().entityRenderer.enableLightmap(0); + Minecraft.getMinecraft().entityRenderer.enableLightmap((double) 0); } catch (Exception ignored) { } } @@ -505,7 +503,10 @@ public class ModelMPM extends ModelNPCMale { } @Override - public void setRotationAngles(float par1, float par2, float par3, float par4, float par5, float par6, Entity entity) { + public void setRotationAngles(float limbSwing, float limbSwingAmount, + float ageInTicks, float netHeadYaw, float headPitch, + float scaleFactor, Entity entity) { + EntityCustomNpc npc = (EntityCustomNpc) entity; isRiding = npc.isRiding(); if (isSneak && (npc.currentAnimation == EnumAnimation.CRAWLING || npc.currentAnimation == EnumAnimation.LYING)) @@ -599,16 +600,16 @@ public class ModelMPM extends ModelNPCMale { this.bipedRightArmWear.rotateAngleY = 0; this.bipedRightArmWear.rotateAngleZ = 0; - super.setRotationAngles(par1, par2, par3, par4, par5, par6, entity); + super.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scaleFactor, entity); if (!isArmor) { - hair.setRotationAngles(par1, par2, par3, par4, par5, par6, entity); - beard.setRotationAngles(par1, par2, par3, par4, par5, par6, entity); - wings.setRotationAngles(par1, par2, par3, par4, par5, par6, entity); - tail.setRotationAngles(par1, par2, par3, par4, par5, par6, entity); - skirt.setRotationAngles(par1, par2, par3, par4, par5, par6, entity); + hair.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scaleFactor, entity); + beard.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scaleFactor, entity); + wings.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scaleFactor, entity); + tail.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scaleFactor, entity); + skirt.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scaleFactor, entity); } - legs.setRotationAngles(par1, par2, par3, par4, par5, par6, entity); + legs.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scaleFactor, entity); if (isSleeping(entity)) { if (bipedHead.rotateAngleX < 0) { @@ -619,9 +620,9 @@ public class ModelMPM extends ModelNPCMale { bipedHeadwear.rotateAngleX = bipedHead.rotateAngleX = 0.7f; else if (npc.currentAnimation == EnumAnimation.HUG) { - AniHug.setRotationAngles(par1, par2, par3, par4, par5, par6, entity, this); + AniHug.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scaleFactor, entity, this); } else if (npc.currentAnimation == EnumAnimation.CRAWLING) - AniCrawling.setRotationAngles(par1, par2, par3, par4, par5, par6, entity, this); + AniCrawling.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scaleFactor, entity, this); else if (npc.currentAnimation == EnumAnimation.WAVING) { bipedRightArm.rotateAngleX = -0.1f; @@ -685,7 +686,7 @@ public class ModelMPM extends ModelNPCMale { part.interpolateAngles(); } float pi = 180 / (float) Math.PI; - GL11.glTranslatef(part.prevPivots[0], part.prevPivots[1], part.prevPivots[2]); + GL11.glTranslatef(part.prevPivots[0], -part.prevPivots[1], part.prevPivots[2]); GL11.glRotatef(part.prevRotations[0] * pi, 1, 0, 0); GL11.glRotatef(part.prevRotations[1] * pi, 0, 1, 0); GL11.glRotatef(part.prevRotations[2] * pi, 0, 0, 1); @@ -742,19 +743,19 @@ public class ModelMPM extends ModelNPCMale { this.copyAnglesPivots(bipedHeadwear, bipedHead); // Hide Head - this.bipedHead.isHidden = entity.modelData.hideHead == 1; + ((ModelScaleRenderer) this.bipedHead).isHidden = entity.modelData.hideHead == 1; if (bipedHeadwear.showModel && !bipedHeadwear.isHidden) { if (entity.modelData.headwear == 1 || isArmor) { ((ModelScaleRenderer) this.bipedHeadwear).setConfig(head, x, y, z); - this.bipedHeadwear.render(f); + ((ModelScaleRenderer) this.bipedHeadwear).render(f); } else if (entity.modelData.headwear == 2) { this.headwear.setConfig(head, x, y, z); this.headwear.render(f); } } ((ModelScaleRenderer) this.bipedHead).setConfig(head, x, y, z); - this.bipedHead.render(f); + ((ModelScaleRenderer) this.bipedHead).render(f); GL11.glPopMatrix(); } @@ -774,14 +775,14 @@ public class ModelMPM extends ModelNPCMale { ModelScalePart body = entity.modelData.modelScale.body; // Hide Body - this.bipedBody.isHidden = entity.modelData.hideBody == 1; + ((ModelScaleRenderer) this.bipedBody).isHidden = entity.modelData.hideBody == 1; // Hide Bodywear this.bipedBodywear.isHidden = entity.modelData.bodywear != 1; this.bodywear.isHidden = entity.modelData.bodywear != 2; ((ModelScaleRenderer) this.bipedBody).setConfig(body, x, y, z); - this.bipedBody.render(f); + ((ModelScaleRenderer) this.bipedBody).render(f); GL11.glPopMatrix(); } @@ -806,41 +807,41 @@ public class ModelMPM extends ModelNPCMale { // Hide Arms if (entity.modelData.hideArms == 1) { - this.bipedRightArm.isHidden = true; - this.bipedLeftArm.isHidden = true; + ((ModelScaleRenderer) this.bipedRightArm).isHidden = true; + ((ModelScaleRenderer) this.bipedLeftArm).isHidden = true; } else if (entity.modelData.hideArms == 2) { - this.bipedRightArm.isHidden = true; - this.bipedLeftArm.isHidden = false; + ((ModelScaleRenderer) this.bipedRightArm).isHidden = true; + ((ModelScaleRenderer) this.bipedLeftArm).isHidden = false; } else if (entity.modelData.hideArms == 3) { - this.bipedRightArm.isHidden = false; - this.bipedLeftArm.isHidden = true; + ((ModelScaleRenderer) this.bipedRightArm).isHidden = false; + ((ModelScaleRenderer) this.bipedLeftArm).isHidden = true; } else { - this.bipedRightArm.isHidden = false; - this.bipedLeftArm.isHidden = false; + ((ModelScaleRenderer) this.bipedRightArm).isHidden = false; + ((ModelScaleRenderer) this.bipedLeftArm).isHidden = false; } // Hide Armwear if (entity.modelData.armwear == 1) { - this.bipedRightArmWear.isHidden = entity.modelData.solidArmwear == 1 || entity.modelData.solidArmwear == 3; - this.bipedLeftArmWear.isHidden = entity.modelData.solidArmwear == 1 || entity.modelData.solidArmwear == 2; + ((ModelScaleRenderer) this.bipedRightArmWear).isHidden = entity.modelData.solidArmwear == 1 || entity.modelData.solidArmwear == 3; + ((ModelScaleRenderer) this.bipedLeftArmWear).isHidden = entity.modelData.solidArmwear == 1 || entity.modelData.solidArmwear == 2; this.solidRightArmWear.isHidden = entity.modelData.solidArmwear == 0 || entity.modelData.solidArmwear == 2; this.solidLeftArmWear.isHidden = entity.modelData.solidArmwear == 0 || entity.modelData.solidArmwear == 3; } else if (entity.modelData.armwear == 2) { - this.bipedRightArmWear.isHidden = true; - this.bipedLeftArmWear.isHidden = entity.modelData.solidArmwear == 1 || entity.modelData.solidArmwear == 2; + ((ModelScaleRenderer) this.bipedRightArmWear).isHidden = true; + ((ModelScaleRenderer) this.bipedLeftArmWear).isHidden = entity.modelData.solidArmwear == 1 || entity.modelData.solidArmwear == 2; this.solidRightArmWear.isHidden = true; this.solidLeftArmWear.isHidden = entity.modelData.solidArmwear == 0 || entity.modelData.solidArmwear == 3; } else if (entity.modelData.armwear == 3) { - this.bipedRightArmWear.isHidden = entity.modelData.solidArmwear == 1 || entity.modelData.solidArmwear == 3; - this.bipedLeftArmWear.isHidden = true; + ((ModelScaleRenderer) this.bipedRightArmWear).isHidden = entity.modelData.solidArmwear == 1 || entity.modelData.solidArmwear == 3; + ((ModelScaleRenderer) this.bipedLeftArmWear).isHidden = true; this.solidRightArmWear.isHidden = entity.modelData.solidArmwear == 0 || entity.modelData.solidArmwear == 2; this.solidLeftArmWear.isHidden = true; } else { - this.bipedRightArmWear.isHidden = true; - this.bipedLeftArmWear.isHidden = true; + ((ModelScaleRenderer) this.bipedRightArmWear).isHidden = true; + ((ModelScaleRenderer) this.bipedLeftArmWear).isHidden = true; this.solidRightArmWear.isHidden = true; this.solidLeftArmWear.isHidden = true; } @@ -848,14 +849,14 @@ public class ModelMPM extends ModelNPCMale { loadPlayerTexture(entity); if (!bo) { ((ModelScaleRenderer) this.bipedLeftArm).setConfig(arms, -x, y, z); - this.bipedLeftArm.render(f); + ((ModelScaleRenderer) this.bipedLeftArm).render(f); loadPlayerTexture(entity); ((ModelScaleRenderer) this.bipedRightArm).setConfig(arms, x, y, z); - this.bipedRightArm.render(f); + ((ModelScaleRenderer) this.bipedRightArm).render(f); } else { ((ModelScaleRenderer) this.bipedRightArm).setConfig(arms, 0, 0, 0); - this.bipedRightArm.render(f); + ((ModelScaleRenderer) this.bipedRightArm).render(f); } GL11.glPopMatrix(); @@ -874,41 +875,41 @@ public class ModelMPM extends ModelNPCMale { // Hide Legs if (entity.modelData.hideLegs == 1) { - this.bipedRightLeg.isHidden = true; - this.bipedLeftLeg.isHidden = true; + ((ModelScaleRenderer) this.bipedRightLeg).isHidden = true; + ((ModelScaleRenderer) this.bipedLeftLeg).isHidden = true; } else if (entity.modelData.hideLegs == 2) { - this.bipedRightLeg.isHidden = true; - this.bipedLeftLeg.isHidden = false; + ((ModelScaleRenderer) this.bipedRightLeg).isHidden = true; + ((ModelScaleRenderer) this.bipedLeftLeg).isHidden = false; } else if (entity.modelData.hideLegs == 3) { - this.bipedRightLeg.isHidden = false; - this.bipedLeftLeg.isHidden = true; + ((ModelScaleRenderer) this.bipedRightLeg).isHidden = false; + ((ModelScaleRenderer) this.bipedLeftLeg).isHidden = true; } else { - this.bipedRightLeg.isHidden = false; - this.bipedLeftLeg.isHidden = false; + ((ModelScaleRenderer) this.bipedRightLeg).isHidden = false; + ((ModelScaleRenderer) this.bipedLeftLeg).isHidden = false; } // Hide Legwear if (entity.modelData.legwear == 1) { - this.bipedRightLegWear.isHidden = entity.modelData.solidLegwear == 1 || entity.modelData.solidLegwear == 3; - this.bipedLeftLegWear.isHidden = entity.modelData.solidLegwear == 1 || entity.modelData.solidLegwear == 2; + ((ModelScaleRenderer) this.bipedRightLegWear).isHidden = entity.modelData.solidLegwear == 1 || entity.modelData.solidLegwear == 3; + ((ModelScaleRenderer) this.bipedLeftLegWear).isHidden = entity.modelData.solidLegwear == 1 || entity.modelData.solidLegwear == 2; this.solidRightLegWear.isHidden = entity.modelData.solidLegwear == 0 || entity.modelData.solidLegwear == 2; this.solidLeftLegWear.isHidden = entity.modelData.solidLegwear == 0 || entity.modelData.solidLegwear == 3; } else if (entity.modelData.legwear == 2) { - this.bipedRightLegWear.isHidden = true; - this.bipedLeftLegWear.isHidden = entity.modelData.solidLegwear == 1 || entity.modelData.solidLegwear == 2; + ((ModelScaleRenderer) this.bipedRightLegWear).isHidden = true; + ((ModelScaleRenderer) this.bipedLeftLegWear).isHidden = entity.modelData.solidLegwear == 1 || entity.modelData.solidLegwear == 2; this.solidRightLegWear.isHidden = true; this.solidLeftLegWear.isHidden = entity.modelData.solidLegwear == 0 || entity.modelData.solidLegwear == 3; } else if (entity.modelData.legwear == 3) { - this.bipedRightLegWear.isHidden = entity.modelData.solidLegwear == 1 || entity.modelData.solidLegwear == 3; - this.bipedLeftLegWear.isHidden = true; + ((ModelScaleRenderer) this.bipedRightLegWear).isHidden = entity.modelData.solidLegwear == 1 || entity.modelData.solidLegwear == 3; + ((ModelScaleRenderer) this.bipedLeftLegWear).isHidden = true; this.solidRightLegWear.isHidden = entity.modelData.solidLegwear == 0 || entity.modelData.solidLegwear == 2; this.solidLeftLegWear.isHidden = true; } else { - this.bipedRightLegWear.isHidden = true; - this.bipedLeftLegWear.isHidden = true; + ((ModelScaleRenderer) this.bipedRightLegWear).isHidden = true; + ((ModelScaleRenderer) this.bipedLeftLegWear).isHidden = true; this.solidRightLegWear.isHidden = true; this.solidLeftLegWear.isHidden = true; } @@ -917,7 +918,6 @@ public class ModelMPM extends ModelNPCMale { this.legs.render(f); if (!isArmor) { this.tail.setConfig(legs, 0, y, z); - this.tail.render(f); } GL11.glPopMatrix(); } @@ -985,6 +985,8 @@ public class ModelMPM extends ModelNPCMale { if (!npc.isEntityAlive()) return false; - return npc.modelData.rotation.whileAttacking && npc.isAttacking() || npc.modelData.rotation.whileMoving && npc.isWalking() || npc.modelData.rotation.whileStanding && !npc.isWalking(); + if (npc.modelData.rotation.whileAttacking && npc.isAttacking() || npc.modelData.rotation.whileMoving && npc.isWalking() || npc.modelData.rotation.whileStanding && !npc.isWalking()) + return true; + return false; } } diff --git a/src/main/java/noppes/npcs/client/model/ModelNpcCrystal.java b/src/main/java/noppes/npcs/client/model/ModelNpcCrystal.java index 467813774..521a2b3d2 100644 --- a/src/main/java/noppes/npcs/client/model/ModelNpcCrystal.java +++ b/src/main/java/noppes/npcs/client/model/ModelNpcCrystal.java @@ -8,9 +8,9 @@ import net.minecraft.util.MathHelper; import org.lwjgl.opengl.GL11; public class ModelNpcCrystal extends ModelBase { - private final ModelRenderer field_41057_g; - private final ModelRenderer field_41058_h; - private final ModelRenderer field_41059_i; + private ModelRenderer field_41057_g; + private ModelRenderer field_41058_h; + private ModelRenderer field_41059_i; public ModelNpcCrystal(float par1) { field_41058_h = new ModelRenderer(this, "glass"); diff --git a/src/main/java/noppes/npcs/client/model/ModelNpcDragon.java b/src/main/java/noppes/npcs/client/model/ModelNpcDragon.java index 9897a1a04..c47057839 100644 --- a/src/main/java/noppes/npcs/client/model/ModelNpcDragon.java +++ b/src/main/java/noppes/npcs/client/model/ModelNpcDragon.java @@ -10,18 +10,18 @@ import org.lwjgl.opengl.GL11; public class ModelNpcDragon extends ModelBase { - private final ModelRenderer head; - private final ModelRenderer neck; - private final ModelRenderer jaw; - private final ModelRenderer body; - private final ModelRenderer rearLeg; - private final ModelRenderer frontLeg; - private final ModelRenderer rearLegTip; - private final ModelRenderer frontLegTip; - private final ModelRenderer rearFoot; - private final ModelRenderer frontFoot; - private final ModelRenderer wing; - private final ModelRenderer wingTip; + private ModelRenderer head; + private ModelRenderer neck; + private ModelRenderer jaw; + private ModelRenderer body; + private ModelRenderer rearLeg; + private ModelRenderer frontLeg; + private ModelRenderer rearLegTip; + private ModelRenderer frontLegTip; + private ModelRenderer rearFoot; + private ModelRenderer frontFoot; + private ModelRenderer wing; + private ModelRenderer wingTip; private float field_40317_s; @@ -122,7 +122,7 @@ public class ModelNpcDragon extends ModelBase { float f9 = 22F; float f10 = 0.0F; float f11 = 1.5F; - double[] ad = entitydragon.func_40160_a(6, field_40317_s); + double ad[] = entitydragon.func_40160_a(6, field_40317_s); float f12 = func_40307_a(entitydragon.func_40160_a(5, field_40317_s)[0] - entitydragon.func_40160_a(10, field_40317_s)[0]); float f13 = func_40307_a(entitydragon.func_40160_a(5, field_40317_s)[0] + (double) (f12 / 2.0F)); f8 += 2.0F; @@ -131,7 +131,7 @@ public class ModelNpcDragon extends ModelBase { f8 = 20F; f9 = -12F; for (int i = 0; i < 5; i++) { - double[] ad3 = entitydragon.func_40160_a(5 - i, field_40317_s); + double ad3[] = entitydragon.func_40160_a(5 - i, field_40317_s); f14 = (float) Math.cos((float) i * 0.45F + f15) * 0.15F; neck.rotateAngleY = ((func_40307_a(ad3[0] - ad[0]) * (float) Math.PI) / 180F) * f11; neck.rotateAngleX = f14 + (((float) (ad3[1] - ad[1]) * (float) Math.PI) / 180F) * f11 * 5F; @@ -148,9 +148,9 @@ public class ModelNpcDragon extends ModelBase { head.rotationPointY = f8; head.rotationPointZ = f9; head.rotationPointX = f10; - double[] ad1 = entitydragon.func_40160_a(0, field_40317_s); - head.rotateAngleY = ((func_40307_a(ad1[0] - ad[0]) * (float) Math.PI) / 180F); - head.rotateAngleZ = ((-func_40307_a(ad1[0] - (double) f13) * (float) Math.PI) / 180F); + double ad1[] = entitydragon.func_40160_a(0, field_40317_s); + head.rotateAngleY = ((func_40307_a(ad1[0] - ad[0]) * (float) Math.PI) / 180F) * 1.0F; + head.rotateAngleZ = ((-func_40307_a(ad1[0] - (double) f13) * (float) Math.PI) / 180F) * 1.0F; head.render(f5); GL11.glPushMatrix(); GL11.glTranslatef(0.0F, 1.0F, 0.0F); @@ -222,7 +222,7 @@ public class ModelNpcDragon extends ModelBase { f10 = 0.0F; ad = entitydragon.func_40160_a(11, field_40317_s); for (int k = 0; k < 12; k++) { - double[] ad2 = entitydragon.func_40160_a(12 + k, field_40317_s); + double ad2[] = entitydragon.func_40160_a(12 + k, field_40317_s); f14 = (float) ((double) f14 + Math.sin((float) k * 0.45F + f15) * 0.05000000074505806D); neck.rotateAngleY = ((func_40307_a(ad2[0] - ad[0]) * f11 + 180F) * (float) Math.PI) / 180F; neck.rotateAngleX = f14 + (((float) (ad2[1] - ad[1]) * (float) Math.PI) / 180F) * f11 * 5F; diff --git a/src/main/java/noppes/npcs/client/model/ModelPony.java b/src/main/java/noppes/npcs/client/model/ModelPony.java index bfa1e095d..57e47f8bc 100644 --- a/src/main/java/noppes/npcs/client/model/ModelPony.java +++ b/src/main/java/noppes/npcs/client/model/ModelPony.java @@ -29,20 +29,20 @@ public class ModelPony extends ModelBase { private float WingRotateAngleZ; private float TailRotateAngleY; public ModelRenderer Head; - public ModelRenderer[] Headpiece; + public ModelRenderer Headpiece[]; public ModelRenderer Helmet; public ModelRenderer Body; - public ModelPlaneRenderer[] Bodypiece; + public ModelPlaneRenderer Bodypiece[]; public ModelRenderer RightArm; public ModelRenderer LeftArm; public ModelRenderer RightLeg; public ModelRenderer LeftLeg; public ModelRenderer unicornarm; - public ModelPlaneRenderer[] Tail; - public ModelRenderer[] LeftWing; - public ModelRenderer[] RightWing; - public ModelRenderer[] LeftWingExt; - public ModelRenderer[] RightWingExt; + public ModelPlaneRenderer Tail[]; + public ModelRenderer LeftWing[]; + public ModelRenderer RightWing[]; + public ModelRenderer LeftWingExt[]; + public ModelRenderer RightWingExt[]; public boolean isPegasus; public boolean isUnicorn; public boolean isFlying; @@ -569,8 +569,8 @@ public class ModelPony extends ModelBase { unicornarm.rotateAngleZ += f36; unicornarm.rotateAngleX += f39; if (isPegasus && isFlying) { - WingRotateAngleY = MathHelper.sin(f2 * 0.067F * 8F); - WingRotateAngleZ = MathHelper.sin(f2 * 0.067F * 8F); + WingRotateAngleY = MathHelper.sin(f2 * 0.067F * 8F) * 1.0F; + WingRotateAngleZ = MathHelper.sin(f2 * 0.067F * 8F) * 1.0F; for (int k4 = 0; k4 < LeftWingExt.length; k4++) { LeftWingExt[k4].rotateAngleX = 2.5F; LeftWingExt[k4].rotateAngleZ = -WingRotateAngleZ - 4.712F - 0.4F; @@ -842,6 +842,7 @@ public class ModelPony extends ModelBase { protected void renderGlow(RenderManager rendermanager, EntityPlayer entityplayer) { ItemStack itemstack = entityplayer.inventory.getCurrentItem(); if (itemstack == null) { + return; } else { GL11.glPushMatrix(); double d = entityplayer.posX; @@ -871,6 +872,7 @@ public class ModelPony extends ModelBase { tessellator.draw(); GL11.glDisable(32826 /*GL_RESCALE_NORMAL_EXT*/); GL11.glPopMatrix(); + return; } } } diff --git a/src/main/java/noppes/npcs/client/model/ModelSkirtArmor.java b/src/main/java/noppes/npcs/client/model/ModelSkirtArmor.java index de4d8ea1d..539dbc8a2 100644 --- a/src/main/java/noppes/npcs/client/model/ModelSkirtArmor.java +++ b/src/main/java/noppes/npcs/client/model/ModelSkirtArmor.java @@ -8,7 +8,7 @@ import noppes.npcs.client.model.util.ModelPlaneRenderer; import org.lwjgl.opengl.GL11; public class ModelSkirtArmor extends ModelBiped { - private final ModelPlaneRenderer Shape1; + private ModelPlaneRenderer Shape1; public ModelSkirtArmor() { float pi = (float) (Math.PI / 5); diff --git a/src/main/java/noppes/npcs/client/model/part/ModelBeard.java b/src/main/java/noppes/npcs/client/model/part/ModelBeard.java index c6bfb5a15..190a308b3 100644 --- a/src/main/java/noppes/npcs/client/model/part/ModelBeard.java +++ b/src/main/java/noppes/npcs/client/model/part/ModelBeard.java @@ -9,7 +9,7 @@ import noppes.npcs.entity.data.ModelPartData; public class ModelBeard extends ModelPartInterface { - private final Model2DRenderer model; + private Model2DRenderer model; public ModelBeard(ModelMPM base) { super(base); diff --git a/src/main/java/noppes/npcs/client/model/part/ModelBreasts.java b/src/main/java/noppes/npcs/client/model/part/ModelBreasts.java index ca0a58e35..1cd400ca0 100644 --- a/src/main/java/noppes/npcs/client/model/part/ModelBreasts.java +++ b/src/main/java/noppes/npcs/client/model/part/ModelBreasts.java @@ -8,9 +8,9 @@ import noppes.npcs.client.model.util.ModelPartInterface; import noppes.npcs.entity.data.ModelData; public class ModelBreasts extends ModelPartInterface { - private final Model2DRenderer breasts; - private final ModelRenderer breasts2; - private final ModelRenderer breasts3; + private Model2DRenderer breasts; + private ModelRenderer breasts2; + private ModelRenderer breasts3; public ModelBreasts(ModelMPM base, int width, int height) { super(base); diff --git a/src/main/java/noppes/npcs/client/model/part/ModelClaws.java b/src/main/java/noppes/npcs/client/model/part/ModelClaws.java index 1f4e12796..36cc1bd7e 100644 --- a/src/main/java/noppes/npcs/client/model/part/ModelClaws.java +++ b/src/main/java/noppes/npcs/client/model/part/ModelClaws.java @@ -8,7 +8,7 @@ import noppes.npcs.entity.data.ModelPartData; public class ModelClaws extends ModelPartInterface { - private final Model2DRenderer model; + private Model2DRenderer model; private boolean isRight = false; public ModelClaws(ModelMPM base, boolean isRight) { diff --git a/src/main/java/noppes/npcs/client/model/part/ModelEars.java b/src/main/java/noppes/npcs/client/model/part/ModelEars.java index ce864f42b..8e70c4b2e 100644 --- a/src/main/java/noppes/npcs/client/model/part/ModelEars.java +++ b/src/main/java/noppes/npcs/client/model/part/ModelEars.java @@ -8,8 +8,8 @@ import noppes.npcs.entity.data.ModelData; import noppes.npcs.entity.data.ModelPartData; public class ModelEars extends ModelPartInterface { - private final ModelRenderer ears; - private final ModelRenderer bunny; + private ModelRenderer ears; + private ModelRenderer bunny; public ModelEars(ModelMPM par1ModelBase) { super(par1ModelBase); diff --git a/src/main/java/noppes/npcs/client/model/part/ModelFin.java b/src/main/java/noppes/npcs/client/model/part/ModelFin.java index 4577ec764..3bf5ec535 100644 --- a/src/main/java/noppes/npcs/client/model/part/ModelFin.java +++ b/src/main/java/noppes/npcs/client/model/part/ModelFin.java @@ -8,7 +8,7 @@ import noppes.npcs.entity.data.ModelPartData; public class ModelFin extends ModelPartInterface { - private final Model2DRenderer model; + private Model2DRenderer model; public ModelFin(ModelMPM base) { super(base); diff --git a/src/main/java/noppes/npcs/client/model/part/ModelHair.java b/src/main/java/noppes/npcs/client/model/part/ModelHair.java index a268b6920..9ea59830e 100644 --- a/src/main/java/noppes/npcs/client/model/part/ModelHair.java +++ b/src/main/java/noppes/npcs/client/model/part/ModelHair.java @@ -9,7 +9,7 @@ import noppes.npcs.entity.data.ModelData; import noppes.npcs.entity.data.ModelPartData; public class ModelHair extends ModelPartInterface { - private final Model2DRenderer model; + private Model2DRenderer model; public ModelHair(ModelMPM base) { super(base); diff --git a/src/main/java/noppes/npcs/client/model/part/ModelHorns.java b/src/main/java/noppes/npcs/client/model/part/ModelHorns.java index 856337534..8f96c4be2 100644 --- a/src/main/java/noppes/npcs/client/model/part/ModelHorns.java +++ b/src/main/java/noppes/npcs/client/model/part/ModelHorns.java @@ -12,10 +12,10 @@ import noppes.npcs.entity.data.ModelData; import noppes.npcs.entity.data.ModelPartData; public class ModelHorns extends ModelPartInterface { - private final ModelRenderer bull; - private final ModelRenderer antlers; - private final ModelRenderer antennasBack; - private final ModelRenderer antennasFront; + private ModelRenderer bull; + private ModelRenderer antlers; + private ModelRenderer antennasBack; + private ModelRenderer antennasFront; public ModelHorns(ModelMPM base) { super(base); diff --git a/src/main/java/noppes/npcs/client/model/part/ModelLegs.java b/src/main/java/noppes/npcs/client/model/part/ModelLegs.java index 372ff00b1..fe9325b4d 100644 --- a/src/main/java/noppes/npcs/client/model/part/ModelLegs.java +++ b/src/main/java/noppes/npcs/client/model/part/ModelLegs.java @@ -18,8 +18,7 @@ import org.lwjgl.opengl.GL11; public class ModelLegs extends ModelScaleRenderer { private EntityCustomNpc entity; - private final ModelScaleRenderer leg1; - private final ModelScaleRenderer leg2; + private ModelScaleRenderer leg1, leg2; private ModelRenderer spider; private ModelRenderer horse; private ModelNagaLegs naga; @@ -54,7 +53,7 @@ public class ModelLegs extends ModelScaleRenderer { private ModelRenderer frontRightShin; private ModelRenderer frontRightHoof; - private final ModelMPM base; + private ModelMPM base; public ModelLegs(ModelMPM base, ModelScaleRenderer leg1, ModelScaleRenderer leg2, int textWidth, int textHeight) { super(base); @@ -73,61 +72,61 @@ public class ModelLegs extends ModelScaleRenderer { spiderNeck = new ModelRenderer(base, 0, 0); spiderNeck.setTextureSize(64, 32); spiderNeck.addBox(-3.0F, -3.0F, -3.0F, 6, 6, 6, var1); - spiderNeck.setRotationPoint(0.0F, var2, 2.0F); + spiderNeck.setRotationPoint(0.0F, (float) var2, 2.0F); spider.addChild(spiderNeck); spiderBody = new ModelRenderer(base, 0, 12); spiderBody.setTextureSize(64, 32); spiderBody.addBox(-5.0F, -4.0F, -6.0F, 10, 8, 12, var1); - spiderBody.setRotationPoint(0.0F, var2, 11.0F); + spiderBody.setRotationPoint(0.0F, (float) var2, 11.0F); spider.addChild(spiderBody); this.spiderLeg1 = new ModelRenderer(base, 18, 0); this.spiderLeg1.setTextureSize(64, 32); this.spiderLeg1.addBox(-15.0F, -1.0F, -1.0F, 16, 2, 2, var1); - this.spiderLeg1.setRotationPoint(-4.0F, var2, 4.0F); + this.spiderLeg1.setRotationPoint(-4.0F, (float) var2, 4.0F); spider.addChild(spiderLeg1); this.spiderLeg2 = new ModelRenderer(base, 18, 0); this.spiderLeg2.setTextureSize(64, 32); this.spiderLeg2.addBox(-1.0F, -1.0F, -1.0F, 16, 2, 2, var1); - this.spiderLeg2.setRotationPoint(4.0F, var2, 4.0F); + this.spiderLeg2.setRotationPoint(4.0F, (float) var2, 4.0F); spider.addChild(spiderLeg2); this.spiderLeg3 = new ModelRenderer(base, 18, 0); this.spiderLeg3.setTextureSize(64, 32); this.spiderLeg3.addBox(-15.0F, -1.0F, -1.0F, 16, 2, 2, var1); - this.spiderLeg3.setRotationPoint(-4.0F, var2, 3.0F); + this.spiderLeg3.setRotationPoint(-4.0F, (float) var2, 3.0F); spider.addChild(spiderLeg3); this.spiderLeg4 = new ModelRenderer(base, 18, 0); this.spiderLeg4.setTextureSize(64, 32); this.spiderLeg4.addBox(-1.0F, -1.0F, -1.0F, 16, 2, 2, var1); - this.spiderLeg4.setRotationPoint(4.0F, var2, 3.0F); + this.spiderLeg4.setRotationPoint(4.0F, (float) var2, 3.0F); spider.addChild(spiderLeg4); this.spiderLeg5 = new ModelRenderer(base, 18, 0); this.spiderLeg5.setTextureSize(64, 32); this.spiderLeg5.addBox(-15.0F, -1.0F, -1.0F, 16, 2, 2, var1); - this.spiderLeg5.setRotationPoint(-4.0F, var2, 2.0F); + this.spiderLeg5.setRotationPoint(-4.0F, (float) var2, 2.0F); spider.addChild(spiderLeg5); this.spiderLeg6 = new ModelRenderer(base, 18, 0); this.spiderLeg6.setTextureSize(64, 32); this.spiderLeg6.addBox(-1.0F, -1.0F, -1.0F, 16, 2, 2, var1); - this.spiderLeg6.setRotationPoint(4.0F, var2, 2.0F); + this.spiderLeg6.setRotationPoint(4.0F, (float) var2, 2.0F); spider.addChild(spiderLeg6); this.spiderLeg7 = new ModelRenderer(base, 18, 0); this.spiderLeg7.setTextureSize(64, 32); this.spiderLeg7.addBox(-15.0F, -1.0F, -1.0F, 16, 2, 2, var1); - this.spiderLeg7.setRotationPoint(-4.0F, var2, 1.0F); + this.spiderLeg7.setRotationPoint(-4.0F, (float) var2, 1.0F); spider.addChild(spiderLeg7); this.spiderLeg8 = new ModelRenderer(base, 18, 0); this.spiderLeg8.setTextureSize(64, 32); this.spiderLeg8.addBox(-1.0F, -1.0F, -1.0F, 16, 2, 2, var1); - this.spiderLeg8.setRotationPoint(4.0F, var2, 1.0F); + this.spiderLeg8.setRotationPoint(4.0F, (float) var2, 1.0F); spider.addChild(spiderLeg8); @@ -215,7 +214,10 @@ public class ModelLegs extends ModelScaleRenderer { this.addChild(mermaid); this.addChild(mermaid2); - boolean mirror = textHeight != textWidth; + boolean mirror = false; + if (textHeight != textWidth) { + mirror = true; + } digitigrade = new ModelDigitigradeLegs(base, mirror, textWidth, textHeight); @@ -228,7 +230,7 @@ public class ModelLegs extends ModelScaleRenderer { model.rotateAngleZ = z; } - public void setRotationAngles(float par1, float par2, float par3, float par4, float par5, float par6, Entity entity) { + public void setRotationAngles(float limbSwing, float limbSwingAmount, float par3, float par4, float par5, float par6, Entity entity) { if (this.entity == null) return; ModelPartData part = this.entity.modelData.legParts; @@ -256,20 +258,20 @@ public class ModelLegs extends ModelScaleRenderer { float var10 = 0.3926991F; this.spiderLeg1.rotateAngleY = var10 * 2.0F + var9; this.spiderLeg2.rotateAngleY = -var10 * 2.0F - var9; - this.spiderLeg3.rotateAngleY = var10 + var9; - this.spiderLeg4.rotateAngleY = -var10 - var9; - this.spiderLeg5.rotateAngleY = -var10 + var9; - this.spiderLeg6.rotateAngleY = var10 - var9; + this.spiderLeg3.rotateAngleY = var10 * 1.0F + var9; + this.spiderLeg4.rotateAngleY = -var10 * 1.0F - var9; + this.spiderLeg5.rotateAngleY = -var10 * 1.0F + var9; + this.spiderLeg6.rotateAngleY = var10 * 1.0F - var9; this.spiderLeg7.rotateAngleY = -var10 * 2.0F + var9; this.spiderLeg8.rotateAngleY = var10 * 2.0F - var9; - float var11 = -(MathHelper.cos(par1 * 0.6662F * 2.0F + 0.0F) * 0.4F) * par2; - float var12 = -(MathHelper.cos(par1 * 0.6662F * 2.0F + (float) Math.PI) * 0.4F) * par2; - float var13 = -(MathHelper.cos(par1 * 0.6662F * 2.0F + ((float) Math.PI / 2F)) * 0.4F) * par2; - float var14 = -(MathHelper.cos(par1 * 0.6662F * 2.0F + ((float) Math.PI * 3F / 2F)) * 0.4F) * par2; - float var15 = Math.abs(MathHelper.sin(par1 * 0.6662F + 0.0F) * 0.4F) * par2; - float var16 = Math.abs(MathHelper.sin(par1 * 0.6662F + (float) Math.PI) * 0.4F) * par2; - float var17 = Math.abs(MathHelper.sin(par1 * 0.6662F + ((float) Math.PI / 2F)) * 0.4F) * par2; - float var18 = Math.abs(MathHelper.sin(par1 * 0.6662F + ((float) Math.PI * 3F / 2F)) * 0.4F) * par2; + float var11 = -(MathHelper.cos(limbSwing * 0.6662F * 2.0F + 0.0F) * 0.4F) * limbSwingAmount; + float var12 = -(MathHelper.cos(limbSwing * 0.6662F * 2.0F + (float) Math.PI) * 0.4F) * limbSwingAmount; + float var13 = -(MathHelper.cos(limbSwing * 0.6662F * 2.0F + ((float) Math.PI / 2F)) * 0.4F) * limbSwingAmount; + float var14 = -(MathHelper.cos(limbSwing * 0.6662F * 2.0F + ((float) Math.PI * 3F / 2F)) * 0.4F) * limbSwingAmount; + float var15 = Math.abs(MathHelper.sin(limbSwing * 0.6662F + 0.0F) * 0.4F) * limbSwingAmount; + float var16 = Math.abs(MathHelper.sin(limbSwing * 0.6662F + (float) Math.PI) * 0.4F) * limbSwingAmount; + float var17 = Math.abs(MathHelper.sin(limbSwing * 0.6662F + ((float) Math.PI / 2F)) * 0.4F) * limbSwingAmount; + float var18 = Math.abs(MathHelper.sin(limbSwing * 0.6662F + ((float) Math.PI * 3F / 2F)) * 0.4F) * limbSwingAmount; this.spiderLeg1.rotateAngleY += var11; this.spiderLeg2.rotateAngleY += -var11; this.spiderLeg3.rotateAngleY += var12; @@ -302,16 +304,16 @@ public class ModelLegs extends ModelScaleRenderer { this.rotateAngleX = (float) (Math.PI / -2); } } else if (part.type == 3) { - this.frontLeftLeg.rotateAngleX = MathHelper.cos(par1 * 0.6662F) * .4F * par2; - this.frontRightLeg.rotateAngleX = MathHelper.cos(par1 * 0.6662F + (float) Math.PI) * .4F * par2; - this.backLeftLeg.rotateAngleX = MathHelper.cos(par1 * 0.6662F + (float) Math.PI) * .4F * par2; - this.backRightLeg.rotateAngleX = MathHelper.cos(par1 * 0.6662F) * .4F * par2; + this.frontLeftLeg.rotateAngleX = MathHelper.cos(limbSwing * 0.6662F) * .4F * limbSwingAmount; + this.frontRightLeg.rotateAngleX = MathHelper.cos(limbSwing * 0.6662F + (float) Math.PI) * .4F * limbSwingAmount; + this.backLeftLeg.rotateAngleX = MathHelper.cos(limbSwing * 0.6662F + (float) Math.PI) * .4F * limbSwingAmount; + this.backRightLeg.rotateAngleX = MathHelper.cos(limbSwing * 0.6662F) * .4F * limbSwingAmount; } else if (part.type == 1) { naga.isRiding = base.isRiding; naga.isSleeping = base.isSleeping(entity); naga.isCrawling = this.entity.currentAnimation == EnumAnimation.CRAWLING; naga.isSneaking = base.isSneak; - naga.setRotationAngles(par1, par2, par3, par4, par5, par6, entity); + naga.setRotationAngles(limbSwing, limbSwingAmount, par3, par4, par5, par6, entity); } else if (part.type == 4 || part.type == 6) { mermaid.isRiding = base.isRiding; mermaid.isSleeping = base.isSleeping(entity); @@ -321,10 +323,10 @@ public class ModelLegs extends ModelScaleRenderer { mermaid2.isSleeping = base.isSleeping(entity); mermaid2.isCrawling = this.entity.currentAnimation == EnumAnimation.CRAWLING; mermaid2.isSneaking = base.isSneak; - mermaid.setRotationAngles(par1, par2, par3, par4, par5, par6, entity); - mermaid2.setRotationAngles(par1, par2, par3, par4, par5, par6, entity); + mermaid.setRotationAngles(limbSwing, limbSwingAmount, par3, par4, par5, par6, entity); + mermaid2.setRotationAngles(limbSwing, limbSwingAmount, par3, par4, par5, par6, entity); } else if (part.type == 5) { - digitigrade.setRotationAngles(par1, par2, par3, par4, par5, par6, entity); + digitigrade.setRotationAngles(limbSwing, limbSwingAmount, par3, par4, par5, par6, entity); } } diff --git a/src/main/java/noppes/npcs/client/model/part/ModelMohawk.java b/src/main/java/noppes/npcs/client/model/part/ModelMohawk.java index bb7e53281..a18c39d6c 100644 --- a/src/main/java/noppes/npcs/client/model/part/ModelMohawk.java +++ b/src/main/java/noppes/npcs/client/model/part/ModelMohawk.java @@ -8,7 +8,7 @@ import noppes.npcs.entity.data.ModelData; import noppes.npcs.entity.data.ModelPartData; public class ModelMohawk extends ModelPartInterface { - private final Model2DRenderer model; + private Model2DRenderer model; public ModelMohawk(ModelMPM base) { super(base); diff --git a/src/main/java/noppes/npcs/client/model/part/ModelSkirt.java b/src/main/java/noppes/npcs/client/model/part/ModelSkirt.java index 031802771..ba06b3639 100644 --- a/src/main/java/noppes/npcs/client/model/part/ModelSkirt.java +++ b/src/main/java/noppes/npcs/client/model/part/ModelSkirt.java @@ -2,6 +2,7 @@ package noppes.npcs.client.model.part; import net.minecraft.entity.Entity; import net.minecraft.util.MathHelper; +import net.minecraft.util.ResourceLocation; import noppes.npcs.client.model.ModelMPM; import noppes.npcs.client.model.util.ModelPartInterface; import noppes.npcs.client.model.util.ModelPlaneRenderer; @@ -10,7 +11,7 @@ import noppes.npcs.entity.data.ModelPartData; import org.lwjgl.opengl.GL11; public class ModelSkirt extends ModelPartInterface { - private final ModelPlaneRenderer Shape1; + private ModelPlaneRenderer Shape1; public ModelSkirt(ModelMPM base) { super(base); @@ -67,6 +68,6 @@ public class ModelSkirt extends ModelPartInterface { } color = config.color; isHidden = false; - location = config.getResource(); + location = (ResourceLocation) config.getResource(); } } diff --git a/src/main/java/noppes/npcs/client/model/part/ModelSnout.java b/src/main/java/noppes/npcs/client/model/part/ModelSnout.java index c1a54a05c..398f1a6b9 100644 --- a/src/main/java/noppes/npcs/client/model/part/ModelSnout.java +++ b/src/main/java/noppes/npcs/client/model/part/ModelSnout.java @@ -8,11 +8,11 @@ import noppes.npcs.entity.data.ModelData; import noppes.npcs.entity.data.ModelPartData; public class ModelSnout extends ModelPartInterface { - private final ModelRenderer small; - private final ModelRenderer medium; - private final ModelRenderer large; - private final ModelRenderer bunny; - private final ModelRenderer beak; + private ModelRenderer small; + private ModelRenderer medium; + private ModelRenderer large; + private ModelRenderer bunny; + private ModelRenderer beak; public ModelSnout(ModelMPM base) { super(base); diff --git a/src/main/java/noppes/npcs/client/model/part/ModelTail.java b/src/main/java/noppes/npcs/client/model/part/ModelTail.java index 251f0052c..d49eb565f 100644 --- a/src/main/java/noppes/npcs/client/model/part/ModelTail.java +++ b/src/main/java/noppes/npcs/client/model/part/ModelTail.java @@ -17,7 +17,7 @@ import org.lwjgl.opengl.GL11; public class ModelTail extends ModelScaleRenderer { private EntityCustomNpc entity; - private final ModelMPM base; + private ModelMPM base; public ModelRenderer tail; public ModelRenderer dragon; diff --git a/src/main/java/noppes/npcs/client/model/part/ModelWings.java b/src/main/java/noppes/npcs/client/model/part/ModelWings.java index 6684eb7c0..b26e72d91 100644 --- a/src/main/java/noppes/npcs/client/model/part/ModelWings.java +++ b/src/main/java/noppes/npcs/client/model/part/ModelWings.java @@ -10,8 +10,8 @@ import noppes.npcs.entity.data.ModelPartData; public class ModelWings extends ModelPartInterface { - private final Model2DRenderer lWing; - private final Model2DRenderer rWing; + private Model2DRenderer lWing; + private Model2DRenderer rWing; public ModelWings(ModelMPM base) { super(base); @@ -41,7 +41,7 @@ public class ModelWings extends ModelPartInterface { float motion = Math.abs(MathHelper.sin(par1 * 0.033F + (float) Math.PI) * 0.4F) * par2; if ((!entity.worldObj.isRemote && !entity.onGround) || motion > 0.1D) { - float speed = 0.55f + 0.5f * motion; + float speed = (float) (0.55f + 0.5f * motion); float y = MathHelper.sin(par3 * 0.67F); rWing.rotateAngleZ += y * 0.5f * speed; diff --git a/src/main/java/noppes/npcs/client/model/part/legs/ModelDigitigradeLegs.java b/src/main/java/noppes/npcs/client/model/part/legs/ModelDigitigradeLegs.java index 0d838e467..101ad743f 100644 --- a/src/main/java/noppes/npcs/client/model/part/legs/ModelDigitigradeLegs.java +++ b/src/main/java/noppes/npcs/client/model/part/legs/ModelDigitigradeLegs.java @@ -6,21 +6,21 @@ import noppes.npcs.client.model.ModelMPM; public class ModelDigitigradeLegs extends ModelRenderer { - private final ModelRenderer rightleg; - private final ModelRenderer rightleg2; - private final ModelRenderer rightleglow; - private final ModelRenderer rightfoot; - private final ModelRenderer leftleg; - private final ModelRenderer leftleg2; - private final ModelRenderer leftleglow; - private final ModelRenderer leftfoot; + private ModelRenderer rightleg; + private ModelRenderer rightleg2; + private ModelRenderer rightleglow; + private ModelRenderer rightfoot; + private ModelRenderer leftleg; + private ModelRenderer leftleg2; + private ModelRenderer leftleglow; + private ModelRenderer leftfoot; public boolean isRiding = false; public boolean isSneaking = false; public boolean isSleeping = false; public boolean isCrawling = false; - private final ModelMPM base; + private ModelMPM base; public ModelDigitigradeLegs(ModelMPM base, boolean mirror, int textWidth, int textHeight) { super(base); diff --git a/src/main/java/noppes/npcs/client/model/part/legs/ModelNagaLegs.java b/src/main/java/noppes/npcs/client/model/part/legs/ModelNagaLegs.java index f33ca5464..345878668 100644 --- a/src/main/java/noppes/npcs/client/model/part/legs/ModelNagaLegs.java +++ b/src/main/java/noppes/npcs/client/model/part/legs/ModelNagaLegs.java @@ -9,11 +9,11 @@ import org.lwjgl.opengl.GL11; public class ModelNagaLegs extends ModelRenderer { - private final ModelRenderer nagaPart1; - private final ModelRenderer nagaPart2; - private final ModelRenderer nagaPart3; - private final ModelRenderer nagaPart4; - private final ModelRenderer nagaPart5; + private ModelRenderer nagaPart1; + private ModelRenderer nagaPart2; + private ModelRenderer nagaPart3; + private ModelRenderer nagaPart4; + private ModelRenderer nagaPart5; public boolean isRiding = false; public boolean isSneaking = false; @@ -81,6 +81,7 @@ public class ModelNagaLegs extends ModelRenderer { plane.mirror = true; plane.addTopPlane(0, -2, 0, 4, 6); nagaPart3.addChild(plane); + ; plane = new ModelPlaneRenderer(base, 0, 26); plane.rotateAngleX = (float) (Math.PI / 2); diff --git a/src/main/java/noppes/npcs/client/model/part/tails/ModelSquirrelTail.java b/src/main/java/noppes/npcs/client/model/part/tails/ModelSquirrelTail.java index d62c0f612..00ba7db0f 100644 --- a/src/main/java/noppes/npcs/client/model/part/tails/ModelSquirrelTail.java +++ b/src/main/java/noppes/npcs/client/model/part/tails/ModelSquirrelTail.java @@ -6,7 +6,7 @@ import noppes.npcs.client.model.ModelMPM; public class ModelSquirrelTail extends ModelRenderer { - private final ModelMPM base; + private ModelMPM base; public ModelSquirrelTail(ModelMPM base) { super(base); diff --git a/src/main/java/noppes/npcs/client/model/util/Model2DRenderer.java b/src/main/java/noppes/npcs/client/model/util/Model2DRenderer.java index c5b80ba8f..2c9b25d74 100644 --- a/src/main/java/noppes/npcs/client/model/util/Model2DRenderer.java +++ b/src/main/java/noppes/npcs/client/model/util/Model2DRenderer.java @@ -14,12 +14,8 @@ public class Model2DRenderer extends ModelRenderer { private int displayListModel; - private final float x1; - private final float x2; - private final float y1; - private final float y2; - private final int width; - private final int height; + private float x1, x2, y1, y2; + private int width, height; private float rotationOffsetX, rotationOffsetY; private float scaleX = 1, scaleY = 1, thickness = 1; diff --git a/src/main/java/noppes/npcs/client/renderer/NpcItemRenderer.java b/src/main/java/noppes/npcs/client/renderer/NpcItemRenderer.java index 229695c50..9205958b2 100644 --- a/src/main/java/noppes/npcs/client/renderer/NpcItemRenderer.java +++ b/src/main/java/noppes/npcs/client/renderer/NpcItemRenderer.java @@ -18,7 +18,10 @@ public class NpcItemRenderer implements IItemRenderer { @Override public boolean handleRenderType(ItemStack item, ItemRenderType type) { - return type == ItemRenderType.EQUIPPED || type == ItemRenderType.EQUIPPED_FIRST_PERSON; + if (type == ItemRenderType.EQUIPPED || type == ItemRenderType.EQUIPPED_FIRST_PERSON) { + return true; + } + return false; } @Override diff --git a/src/main/java/noppes/npcs/client/renderer/RenderCNPCHand.java b/src/main/java/noppes/npcs/client/renderer/RenderCNPCHand.java index 6b45a6170..d4e94b31b 100644 --- a/src/main/java/noppes/npcs/client/renderer/RenderCNPCHand.java +++ b/src/main/java/noppes/npcs/client/renderer/RenderCNPCHand.java @@ -2,6 +2,7 @@ package noppes.npcs.client.renderer; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityClientPlayerMP; +import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.client.renderer.ItemRenderer; import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.RenderHelper; @@ -19,7 +20,7 @@ public class RenderCNPCHand extends ItemRenderer { /** * A reference to the Minecraft object. */ - private final Minecraft mc; + private Minecraft mc; private ItemStack itemToRender; /** * How far the current item has been equipped (0 disequipped and 1 fully up) @@ -48,8 +49,8 @@ public class RenderCNPCHand extends ItemRenderer { GL11.glRotatef(entityclientplayermp.prevRotationYaw + (entityclientplayermp.rotationYaw - entityclientplayermp.prevRotationYaw) * partialTickTime, 0.0F, 1.0F, 0.0F); RenderHelper.enableStandardItemLighting(); GL11.glPopMatrix(); - float f3 = entityclientplayermp.prevRenderArmPitch + (entityclientplayermp.renderArmPitch - entityclientplayermp.prevRenderArmPitch) * partialTickTime; - float f4 = entityclientplayermp.prevRenderArmYaw + (entityclientplayermp.renderArmYaw - entityclientplayermp.prevRenderArmYaw) * partialTickTime; + float f3 = ((EntityPlayerSP) entityclientplayermp).prevRenderArmPitch + (((EntityPlayerSP) entityclientplayermp).renderArmPitch - ((EntityPlayerSP) entityclientplayermp).prevRenderArmPitch) * partialTickTime; + float f4 = ((EntityPlayerSP) entityclientplayermp).prevRenderArmYaw + (((EntityPlayerSP) entityclientplayermp).renderArmYaw - ((EntityPlayerSP) entityclientplayermp).prevRenderArmYaw) * partialTickTime; 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); @@ -57,7 +58,7 @@ public class RenderCNPCHand extends ItemRenderer { int i = this.mc.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; - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float) j, (float) k); + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float) j / 1.0F, (float) k / 1.0F); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); float f5; float f6; diff --git a/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayer.java b/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayer.java index 2b1b5e078..1339607b3 100644 --- a/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayer.java +++ b/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayer.java @@ -54,7 +54,7 @@ public class RenderCNPCPlayer extends RenderPlayer { if (overlayData.texture.isEmpty()) return false; - ImageData imageData = ClientCacheHandler.getImageData(overlayData.texture); + ImageData imageData = ClientCacheHandler.getImageData(((SkinOverlay) overlayData).texture); if (!imageData.imageLoaded()) return false; @@ -75,7 +75,7 @@ public class RenderCNPCPlayer extends RenderPlayer { if (overlayData.glow) { GL11.glDisable(GL11.GL_LIGHTING); - Minecraft.getMinecraft().entityRenderer.disableLightmap(0); + Minecraft.getMinecraft().entityRenderer.disableLightmap((double) 0); RenderHelper.disableStandardItemLighting(); } @@ -108,7 +108,7 @@ public class RenderCNPCPlayer extends RenderPlayer { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glDisable(GL11.GL_BLEND); GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F); - Minecraft.getMinecraft().entityRenderer.enableLightmap(0); + Minecraft.getMinecraft().entityRenderer.enableLightmap((double) 0); RenderHelper.enableStandardItemLighting(); } @@ -118,10 +118,10 @@ public class RenderCNPCPlayer extends RenderPlayer { if (!entity.isInvisible()) { if (ClientCacheHandler.skinOverlays.containsKey(player.getUniqueID())) { for (SkinOverlay overlayData : ClientCacheHandler.skinOverlays.get(player.getUniqueID()).values()) { - if (overlayData.texture.isEmpty()) + if (((SkinOverlay) overlayData).texture.isEmpty()) continue; - ImageData imageData = ClientCacheHandler.getImageData(overlayData.texture); + ImageData imageData = ClientCacheHandler.getImageData(((SkinOverlay) overlayData).texture); if (!imageData.imageLoaded()) continue; @@ -198,9 +198,9 @@ public class RenderCNPCPlayer extends RenderPlayer { } if (mc.gameSettings.thirdPersonView == 0 && !mc.renderViewEntity.isPlayerSleeping() && !mc.gameSettings.hideGUI && !mc.playerController.enableEverythingIsScrewedUpMode()) { - entityRenderer.enableLightmap(partialTicks); + entityRenderer.enableLightmap((double) partialTicks); itemRenderer.renderOverlayInFirstPerson(partialTicks); - entityRenderer.disableLightmap(partialTicks); + entityRenderer.disableLightmap((double) partialTicks); } GL11.glPopMatrix(); @@ -213,7 +213,7 @@ public class RenderCNPCPlayer extends RenderPlayer { private float getFOVModifier(float p_78481_1_, boolean p_78481_2_) { Minecraft mc = Minecraft.getMinecraft(); - EntityLivingBase entityplayer = mc.renderViewEntity; + EntityLivingBase entityplayer = (EntityLivingBase) mc.renderViewEntity; float f1 = 70.0F; if (p_78481_2_) { @@ -319,7 +319,9 @@ public class RenderCNPCPlayer extends RenderPlayer { // Render the arm this.modelBipedMain.onGround = 0.0F; this.modelBipedMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, player); - this.modelBipedMain.bipedRightArm.render(0.0625F); + + if(this.modelBipedMain.bipedRightArm != null) + this.modelBipedMain.bipedRightArm.render(0.0625F); postRenderOverlay(); } @@ -450,10 +452,10 @@ public class RenderCNPCPlayer extends RenderPlayer { try { if (ClientCacheHandler.skinOverlays.containsKey(player.getUniqueID())) { for (SkinOverlay overlayData : ClientCacheHandler.skinOverlays.get(player.getUniqueID()).values()) { - if (overlayData.texture.isEmpty()) + if (((SkinOverlay) overlayData).texture.isEmpty()) continue; - ImageData imageData = ClientCacheHandler.getImageData(overlayData.texture); + ImageData imageData = ClientCacheHandler.getImageData(((SkinOverlay) overlayData).texture); if (!imageData.imageLoaded()) continue; @@ -468,8 +470,8 @@ public class RenderCNPCPlayer extends RenderPlayer { bipedHead.isHidden = true; renderDBC.invoke(m, player, - rot1.get(m), rot2.get(m), rot3.get(m), - rot4.get(m), rot5.get(m), rot6.get(m) + (float) rot1.get(m), (float) rot2.get(m), (float) rot3.get(m), + (float) rot4.get(m), (float) rot5.get(m), (float) rot6.get(m) ); bipedHead.isHidden = false; @@ -507,8 +509,8 @@ public class RenderCNPCPlayer extends RenderPlayer { } } renderDBC.invoke(m, player, - rot1.get(m), rot2.get(m), rot3.get(m), - rot4.get(m), rot5.get(m), rot6.get(m) + (float) rot1.get(m), (float) rot2.get(m), (float) rot3.get(m), + (float) rot4.get(m), (float) rot5.get(m), (float) rot6.get(m) ); bipedBody.isHidden = false; bipedRA.isHidden = false; diff --git a/src/main/java/noppes/npcs/client/renderer/RenderCustomNpc.java b/src/main/java/noppes/npcs/client/renderer/RenderCustomNpc.java index 20603fa4b..a2be8c19c 100644 --- a/src/main/java/noppes/npcs/client/renderer/RenderCustomNpc.java +++ b/src/main/java/noppes/npcs/client/renderer/RenderCustomNpc.java @@ -21,7 +21,7 @@ public class RenderCustomNpc extends RenderNPCHumanMale { private RendererLivingEntity renderEntity; public static EntityLivingBase entity; - private final ModelRenderPassHelper renderpass = new ModelRenderPassHelper(); + private ModelRenderPassHelper renderpass = new ModelRenderPassHelper(); // Default Renderer public RenderCustomNpc() { diff --git a/src/main/java/noppes/npcs/client/renderer/RenderNPCHumanMale.java b/src/main/java/noppes/npcs/client/renderer/RenderNPCHumanMale.java index c393ac519..dcd19ce2d 100644 --- a/src/main/java/noppes/npcs/client/renderer/RenderNPCHumanMale.java +++ b/src/main/java/noppes/npcs/client/renderer/RenderNPCHumanMale.java @@ -163,7 +163,7 @@ public class RenderNPCHumanMale extends RenderNPCInterface { int i = npc.getBrightnessForRender(f); int j = i % 65536; int k = i / 65536; - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float) j, (float) k); + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float) j / 1.0F, (float) k / 1.0F); GL11.glColor3f(1, 1, 1); ItemStack itemstack = npc.inventory.armorItemInSlot(0); if (itemstack != null) { diff --git a/src/main/java/noppes/npcs/client/renderer/RenderNPCInterface.java b/src/main/java/noppes/npcs/client/renderer/RenderNPCInterface.java index 8c559691f..2d1d1f258 100644 --- a/src/main/java/noppes/npcs/client/renderer/RenderNPCInterface.java +++ b/src/main/java/noppes/npcs/client/renderer/RenderNPCInterface.java @@ -39,7 +39,6 @@ import javax.imageio.ImageIO; import java.awt.image.BufferedImage; import java.io.IOException; import java.io.InputStream; -import java.nio.charset.StandardCharsets; import java.security.MessageDigest; import java.util.Map; @@ -97,7 +96,7 @@ public class RenderNPCInterface extends RenderLiving { i = npc.getBrightnessForRender(0); int j = i % 65536; int k = i / 65536; - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float) j, (float) k); + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float) j / 1.0F, (float) k / 1.0F); float f1 = (npc.baseHeight / 5f) * npc.display.modelSize; float f2 = 0.01666667F * f1; @@ -184,7 +183,7 @@ public class RenderNPCInterface extends RenderLiving { GL11.glRotatef(270F, 0.0F, 1.0F, 0.0F); } else if (npc.isEntityAlive() && npc.currentAnimation == EnumAnimation.CRAWLING) { GL11.glRotatef(270.0F - f1, 0.0F, 1.0F, 0.0F); - float scale = npc.display.modelSize / 5f; + float scale = ((EntityCustomNpc) npc).display.modelSize / 5f; GL11.glTranslated(-scale + ((EntityCustomNpc) npc).modelData.getLegsY() * scale, 0.14f, 0); GL11.glRotatef(270F, 0.0F, 0.0F, 1.0F); GL11.glRotatef(270F, 0.0F, 1.0F, 0.0F); @@ -428,6 +427,7 @@ public class RenderNPCInterface extends RenderLiving { float f3; for (f3 = p_77034_2_ - p_77034_1_; f3 < -180.0F; f3 += 360.0F) { + ; } while (f3 >= 180.0F) { @@ -479,7 +479,7 @@ public class RenderNPCInterface extends RenderLiving { if (overlayData.getGlow()) { GL11.glDisable(GL11.GL_LIGHTING); - Minecraft.getMinecraft().entityRenderer.disableLightmap(0); + Minecraft.getMinecraft().entityRenderer.disableLightmap((double) 0); } GL11.glColor4f(1.0F, 1.0F, 1.0F, overlayData.getAlpha()); @@ -513,7 +513,7 @@ public class RenderNPCInterface extends RenderLiving { GL11.glDepthFunc(GL11.GL_LEQUAL); GL11.glDisable(GL11.GL_BLEND); GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F); - Minecraft.getMinecraft().entityRenderer.enableLightmap(0); + Minecraft.getMinecraft().entityRenderer.enableLightmap((double) 0); } catch (Exception ignored) { } } @@ -619,15 +619,15 @@ public class RenderNPCInterface extends RenderLiving { try { MessageDigest digest = MessageDigest.getInstance("MD5"); - byte[] hash = digest.digest(npc.display.texture.getBytes(StandardCharsets.UTF_8)); + byte[] hash = digest.digest(npc.display.texture.getBytes("UTF-8")); StringBuilder sb = new StringBuilder(2 * hash.length); for (byte b : hash) { sb.append(String.format("%02x", b & 0xff)); } if (npc.display.modelType == 0) { - location = new ResourceLocation("skin/" + sb); + location = new ResourceLocation("skin/" + sb.toString()); } else { - location = new ResourceLocation("skin64/" + sb); + location = new ResourceLocation("skin64/" + sb.toString()); } } catch (Exception ignored) { } diff --git a/src/main/java/noppes/npcs/client/renderer/RenderNpcSlime.java b/src/main/java/noppes/npcs/client/renderer/RenderNpcSlime.java index fdf3a1062..8e257da77 100644 --- a/src/main/java/noppes/npcs/client/renderer/RenderNpcSlime.java +++ b/src/main/java/noppes/npcs/client/renderer/RenderNpcSlime.java @@ -6,7 +6,7 @@ import noppes.npcs.entity.EntityNPCInterface; import org.lwjgl.opengl.GL11; public class RenderNpcSlime extends RenderNPCInterface { - private final ModelBase scaleAmount; + private ModelBase scaleAmount; public RenderNpcSlime(ModelBase par1ModelBase, ModelBase par2ModelBase, float par3) { super(par1ModelBase, par3); diff --git a/src/main/java/noppes/npcs/client/renderer/RenderProjectile.java b/src/main/java/noppes/npcs/client/renderer/RenderProjectile.java index ba807e4af..aaafdf66b 100644 --- a/src/main/java/noppes/npcs/client/renderer/RenderProjectile.java +++ b/src/main/java/noppes/npcs/client/renderer/RenderProjectile.java @@ -28,7 +28,7 @@ public class RenderProjectile extends Render { public boolean renderWithColor = true; private static final ResourceLocation field_110780_a = new ResourceLocation("textures/entity/arrow.png"); private static final ResourceLocation field_110798_h = new ResourceLocation("textures/misc/enchanted_item_glint.png"); - private final RenderBlocks itemRenderBlocks = new RenderBlocks(); + private RenderBlocks itemRenderBlocks = new RenderBlocks(); public void doRenderProjectile(EntityProjectile par1EntityProjectile, double par2, double par4, double par6, float par8, float par9) { GL11.glPushMatrix(); @@ -47,7 +47,7 @@ public class RenderProjectile extends Render { byte b0 = 0; float f2 = 0.0F; float f3 = 0.5F; - float f4 = (float) (b0 * 10) / 32.0F; + float f4 = (float) (0 + b0 * 10) / 32.0F; float f5 = (float) (5 + b0 * 10) / 32.0F; float f6 = 0.0F; float f7 = 0.15625F; @@ -67,27 +67,27 @@ public class RenderProjectile extends Render { GL11.glTranslatef(-4.0F, 0.0F, 0.0F); GL11.glNormal3f(f10, 0.0F, 0.0F); tessellator.startDrawingQuads(); - tessellator.addVertexWithUV(-7.0D, -2.0D, -2.0D, f6, f8); - tessellator.addVertexWithUV(-7.0D, -2.0D, 2.0D, f7, f8); - tessellator.addVertexWithUV(-7.0D, 2.0D, 2.0D, f7, f9); - tessellator.addVertexWithUV(-7.0D, 2.0D, -2.0D, f6, f9); + tessellator.addVertexWithUV(-7.0D, -2.0D, -2.0D, (double) f6, (double) f8); + tessellator.addVertexWithUV(-7.0D, -2.0D, 2.0D, (double) f7, (double) f8); + tessellator.addVertexWithUV(-7.0D, 2.0D, 2.0D, (double) f7, (double) f9); + tessellator.addVertexWithUV(-7.0D, 2.0D, -2.0D, (double) f6, (double) f9); tessellator.draw(); GL11.glNormal3f(-f10, 0.0F, 0.0F); tessellator.startDrawingQuads(); - tessellator.addVertexWithUV(-7.0D, 2.0D, -2.0D, f6, f8); - tessellator.addVertexWithUV(-7.0D, 2.0D, 2.0D, f7, f8); - tessellator.addVertexWithUV(-7.0D, -2.0D, 2.0D, f7, f9); - tessellator.addVertexWithUV(-7.0D, -2.0D, -2.0D, f6, f9); + tessellator.addVertexWithUV(-7.0D, 2.0D, -2.0D, (double) f6, (double) f8); + tessellator.addVertexWithUV(-7.0D, 2.0D, 2.0D, (double) f7, (double) f8); + tessellator.addVertexWithUV(-7.0D, -2.0D, 2.0D, (double) f7, (double) f9); + tessellator.addVertexWithUV(-7.0D, -2.0D, -2.0D, (double) f6, (double) f9); tessellator.draw(); for (int i = 0; i < 4; ++i) { GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F); GL11.glNormal3f(0.0F, 0.0F, f10); tessellator.startDrawingQuads(); - tessellator.addVertexWithUV(-8.0D, -2.0D, 0.0D, f2, f4); - tessellator.addVertexWithUV(8.0D, -2.0D, 0.0D, f3, f4); - tessellator.addVertexWithUV(8.0D, 2.0D, 0.0D, f3, f5); - tessellator.addVertexWithUV(-8.0D, 2.0D, 0.0D, f2, f5); + tessellator.addVertexWithUV(-8.0D, -2.0D, 0.0D, (double) f2, (double) f4); + tessellator.addVertexWithUV(8.0D, -2.0D, 0.0D, (double) f3, (double) f4); + tessellator.addVertexWithUV(8.0D, 2.0D, 0.0D, (double) f3, (double) f5); + tessellator.addVertexWithUV(-8.0D, 2.0D, 0.0D, (double) f2, (double) f5); tessellator.draw(); } } else if (par1EntityProjectile.is3D()) { @@ -201,10 +201,10 @@ public class RenderProjectile extends Render { GL11.glRotatef(-this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F); par1Tessellator.startDrawingQuads(); par1Tessellator.setNormal(0.0F, 1.0F, 0.0F); - par1Tessellator.addVertexWithUV(0.0F - f5, 0.0F - f6, 0.0D, f, f3); - par1Tessellator.addVertexWithUV(f4 - f5, 0.0F - f6, 0.0D, f1, f3); - par1Tessellator.addVertexWithUV(f4 - f5, f4 - f6, 0.0D, f1, f2); - par1Tessellator.addVertexWithUV(0.0F - f5, f4 - f6, 0.0D, f, f2); + par1Tessellator.addVertexWithUV((double) (0.0F - f5), (double) (0.0F - f6), 0.0D, (double) f, (double) f3); + par1Tessellator.addVertexWithUV((double) (f4 - f5), (double) (0.0F - f6), 0.0D, (double) f1, (double) f3); + par1Tessellator.addVertexWithUV((double) (f4 - f5), (double) (f4 - f6), 0.0D, (double) f1, (double) f2); + par1Tessellator.addVertexWithUV((double) (0.0F - f5), (double) (f4 - f6), 0.0D, (double) f, (double) f2); par1Tessellator.draw(); } @@ -234,7 +234,7 @@ public class RenderProjectile extends Render { } GL11.glColor4f(par5, par6, par7, 1.0F); - ItemRenderer.renderItemIn2D(tessellator, f5, f6, f4, f7, par2Icon.getIconWidth(), par2Icon.getIconHeight(), f12); + ItemRenderer.renderItemIn2D(tessellator, f5, f6, f4, f7, ((IIcon) par2Icon).getIconWidth(), ((IIcon) par2Icon).getIconHeight(), f12); if (item != null && item.hasEffect(0)) { GL11.glDepthFunc(GL11.GL_EQUAL); diff --git a/src/main/java/noppes/npcs/client/renderer/blocks/BlockRendererInterface.java b/src/main/java/noppes/npcs/client/renderer/blocks/BlockRendererInterface.java index 5b5c1533b..692314428 100644 --- a/src/main/java/noppes/npcs/client/renderer/blocks/BlockRendererInterface.java +++ b/src/main/java/noppes/npcs/client/renderer/blocks/BlockRendererInterface.java @@ -86,6 +86,7 @@ public abstract class BlockRendererInterface extends TileEntitySpecialRenderer i double d6 = mc.renderViewEntity.posX - tile.xCoord; double d7 = mc.renderViewEntity.posY - tile.yCoord; double d8 = mc.renderViewEntity.posZ - tile.zCoord; + ; return d6 * d6 + d7 * d7 + d8 * d8 > specialRenderDistance() * specialRenderDistance(); } diff --git a/src/main/java/noppes/npcs/client/renderer/items/ItemCustomRenderer.java b/src/main/java/noppes/npcs/client/renderer/items/ItemCustomRenderer.java index ac4b8534c..8b8c1f452 100644 --- a/src/main/java/noppes/npcs/client/renderer/items/ItemCustomRenderer.java +++ b/src/main/java/noppes/npcs/client/renderer/items/ItemCustomRenderer.java @@ -197,7 +197,7 @@ public class ItemCustomRenderer implements IItemRenderer { entityItem.boundingBox.maxY = entityItem.boundingBox.minY + (double) entityItem.height; if (entityItem.width > f2 && !entityItem.firstUpdate && !entityItem.worldObj.isRemote) { - entityItem.moveEntity(f2 - entityItem.width, 0.0D, f2 - entityItem.width); + entityItem.moveEntity((double) (f2 - entityItem.width), 0.0D, (double) (f2 - entityItem.width)); } } @@ -337,10 +337,10 @@ public class ItemCustomRenderer implements IItemRenderer { tessellator.startDrawingQuads(); tessellator.setNormal(0.0F, 1.0F, 0.0F); - tessellator.addVertexWithUV(0.0F - f7, 0.0F - f8, 0.0D, f14, f5); - tessellator.addVertexWithUV(f6 - f7, 0.0F - f8, 0.0D, f15, f5); - tessellator.addVertexWithUV(f6 - f7, 1.0F - f8, 0.0D, f15, f4); - tessellator.addVertexWithUV(0.0F - f7, 1.0F - f8, 0.0D, f14, f4); + tessellator.addVertexWithUV((double) (0.0F - f7), (double) (0.0F - f8), 0.0D, (double) f14, (double) f5); + tessellator.addVertexWithUV((double) (f6 - f7), (double) (0.0F - f8), 0.0D, (double) f15, (double) f5); + tessellator.addVertexWithUV((double) (f6 - f7), (double) (1.0F - f8), 0.0D, (double) f15, (double) f4); + tessellator.addVertexWithUV((double) (0.0F - f7), (double) (1.0F - f8), 0.0D, (double) f14, (double) f4); tessellator.draw(); GL11.glPopMatrix(); } @@ -403,10 +403,10 @@ public class ItemCustomRenderer implements IItemRenderer { } tessellator.startDrawingQuads(); - tessellator.addVertexWithUV(p_77018_2_, p_77018_3_ + p_77018_5_, 0, (f2 + (float) p_77018_5_ * f4) * f, (f3 + (float) p_77018_5_) * f1); - tessellator.addVertexWithUV(p_77018_2_ + p_77018_4_, p_77018_3_ + p_77018_5_, 0, (f2 + (float) p_77018_4_ + (float) p_77018_5_ * f4) * f, (f3 + (float) p_77018_5_) * f1); - tessellator.addVertexWithUV(p_77018_2_ + p_77018_4_, p_77018_3_, 0, (f2 + (float) p_77018_4_) * f, (f3 + 0.0F) * f1); - tessellator.addVertexWithUV(p_77018_2_, p_77018_3_, 0, (f2 + 0.0F) * f, (f3 + 0.0F) * f1); + tessellator.addVertexWithUV((double) (p_77018_2_ + 0), (double) (p_77018_3_ + p_77018_5_), 0, (double) ((f2 + (float) p_77018_5_ * f4) * f), (double) ((f3 + (float) p_77018_5_) * f1)); + tessellator.addVertexWithUV((double) (p_77018_2_ + p_77018_4_), (double) (p_77018_3_ + p_77018_5_), 0, (double) ((f2 + (float) p_77018_4_ + (float) p_77018_5_ * f4) * f), (double) ((f3 + (float) p_77018_5_) * f1)); + tessellator.addVertexWithUV((double) (p_77018_2_ + p_77018_4_), (double) (p_77018_3_ + 0), 0, (double) ((f2 + (float) p_77018_4_) * f), (double) ((f3 + 0.0F) * f1)); + tessellator.addVertexWithUV((double) (p_77018_2_ + 0), (double) (p_77018_3_ + 0), 0, (double) ((f2 + 0.0F) * f), (double) ((f3 + 0.0F) * f1)); tessellator.draw(); } } @@ -415,10 +415,10 @@ public class ItemCustomRenderer implements IItemRenderer { Tessellator tessellator = Tessellator.instance; tessellator.startDrawingQuads(); tessellator.setColorRGBA_F(itemRed, itemGreen, itemBlue, 1.0F); - tessellator.addVertexWithUV(posX, posY + imageHeight, 0, 0, 1); - tessellator.addVertexWithUV(posX + imageWidth, posY + imageHeight, 0, 1, 1); - tessellator.addVertexWithUV(posX + imageWidth, posY, 0, 1, 0); - tessellator.addVertexWithUV(posX, posY, 0, 0, 0); + tessellator.addVertexWithUV((double) (posX), (double) (posY + imageHeight), 0, 0, 1); + tessellator.addVertexWithUV((double) (posX + imageWidth), (double) (posY + imageHeight), 0, 1, 1); + tessellator.addVertexWithUV((double) (posX + imageWidth), (double) (posY), 0, 1, 0); + tessellator.addVertexWithUV((double) (posX), (double) (posY), 0, 0, 0); tessellator.draw(); } @@ -489,17 +489,17 @@ public class ItemCustomRenderer implements IItemRenderer { p_78439_0_.startDrawingQuads(); p_78439_0_.setNormal(0.0F, 0.0F, 1.0F); - p_78439_0_.addVertexWithUV(0.0D, 0.0D, 0.0D, p_78439_1_, p_78439_4_); - p_78439_0_.addVertexWithUV(1.0D, 0.0D, 0.0D, p_78439_3_, p_78439_4_); - p_78439_0_.addVertexWithUV(1.0D, 1.0D, 0.0D, p_78439_3_, p_78439_2_); - p_78439_0_.addVertexWithUV(0.0D, 1.0D, 0.0D, p_78439_1_, p_78439_2_); + p_78439_0_.addVertexWithUV(0.0D, 0.0D, 0.0D, (double) p_78439_1_, (double) p_78439_4_); + p_78439_0_.addVertexWithUV(1.0D, 0.0D, 0.0D, (double) p_78439_3_, (double) p_78439_4_); + p_78439_0_.addVertexWithUV(1.0D, 1.0D, 0.0D, (double) p_78439_3_, (double) p_78439_2_); + p_78439_0_.addVertexWithUV(0.0D, 1.0D, 0.0D, (double) p_78439_1_, (double) p_78439_2_); p_78439_0_.draw(); p_78439_0_.startDrawingQuads(); p_78439_0_.setNormal(0.0F, 0.0F, -1.0F); - p_78439_0_.addVertexWithUV(0.0D, 1.0D, 0.0F - p_78439_7_, p_78439_1_, p_78439_2_); - p_78439_0_.addVertexWithUV(1.0D, 1.0D, 0.0F - p_78439_7_, p_78439_3_, p_78439_2_); - p_78439_0_.addVertexWithUV(1.0D, 0.0D, 0.0F - p_78439_7_, p_78439_3_, p_78439_4_); - p_78439_0_.addVertexWithUV(0.0D, 0.0D, 0.0F - p_78439_7_, p_78439_1_, p_78439_4_); + p_78439_0_.addVertexWithUV(0.0D, 1.0D, (double) (0.0F - p_78439_7_), (double) p_78439_1_, (double) p_78439_2_); + p_78439_0_.addVertexWithUV(1.0D, 1.0D, (double) (0.0F - p_78439_7_), (double) p_78439_3_, (double) p_78439_2_); + p_78439_0_.addVertexWithUV(1.0D, 0.0D, (double) (0.0F - p_78439_7_), (double) p_78439_3_, (double) p_78439_4_); + p_78439_0_.addVertexWithUV(0.0D, 0.0D, (double) (0.0F - p_78439_7_), (double) p_78439_1_, (double) p_78439_4_); p_78439_0_.draw(); float f5 = 0.5F * (p_78439_1_ - p_78439_3_) / (float) width; float f6 = 0.5F * (p_78439_4_ - p_78439_2_) / (float) height; @@ -512,10 +512,10 @@ public class ItemCustomRenderer implements IItemRenderer { for (k = 0; k < width; ++k) { f7 = (float) k / (float) width; f8 = p_78439_1_ + (p_78439_3_ - p_78439_1_) * f7 - f5; - p_78439_0_.addVertexWithUV(f7, 0.0D, 0.0F - p_78439_7_, f8, p_78439_4_); - p_78439_0_.addVertexWithUV(f7, 0.0D, 0.0D, f8, p_78439_4_); - p_78439_0_.addVertexWithUV(f7, 1.0D, 0.0D, f8, p_78439_2_); - p_78439_0_.addVertexWithUV(f7, 1.0D, 0.0F - p_78439_7_, f8, p_78439_2_); + p_78439_0_.addVertexWithUV((double) f7, 0.0D, (double) (0.0F - p_78439_7_), (double) f8, (double) p_78439_4_); + p_78439_0_.addVertexWithUV((double) f7, 0.0D, 0.0D, (double) f8, (double) p_78439_4_); + p_78439_0_.addVertexWithUV((double) f7, 1.0D, 0.0D, (double) f8, (double) p_78439_2_); + p_78439_0_.addVertexWithUV((double) f7, 1.0D, (double) (0.0F - p_78439_7_), (double) f8, (double) p_78439_2_); } p_78439_0_.draw(); @@ -527,10 +527,10 @@ public class ItemCustomRenderer implements IItemRenderer { f7 = (float) k / (float) width; f8 = p_78439_1_ + (p_78439_3_ - p_78439_1_) * f7 - f5; f9 = f7 + 1.0F / (float) width; - p_78439_0_.addVertexWithUV(f9, 1.0D, 0.0F - p_78439_7_, f8, p_78439_2_); - p_78439_0_.addVertexWithUV(f9, 1.0D, 0.0D, f8, p_78439_2_); - p_78439_0_.addVertexWithUV(f9, 0.0D, 0.0D, f8, p_78439_4_); - p_78439_0_.addVertexWithUV(f9, 0.0D, 0.0F - p_78439_7_, f8, p_78439_4_); + p_78439_0_.addVertexWithUV((double) f9, 1.0D, (double) (0.0F - p_78439_7_), (double) f8, (double) p_78439_2_); + p_78439_0_.addVertexWithUV((double) f9, 1.0D, 0.0D, (double) f8, (double) p_78439_2_); + p_78439_0_.addVertexWithUV((double) f9, 0.0D, 0.0D, (double) f8, (double) p_78439_4_); + p_78439_0_.addVertexWithUV((double) f9, 0.0D, (double) (0.0F - p_78439_7_), (double) f8, (double) p_78439_4_); } p_78439_0_.draw(); @@ -541,10 +541,10 @@ public class ItemCustomRenderer implements IItemRenderer { f7 = (float) k / (float) height; f8 = p_78439_4_ + (p_78439_2_ - p_78439_4_) * f7 - f6; f9 = f7 + 1.0F / (float) height; - p_78439_0_.addVertexWithUV(0.0D, f9, 0.0D, p_78439_1_, f8); - p_78439_0_.addVertexWithUV(1.0D, f9, 0.0D, p_78439_3_, f8); - p_78439_0_.addVertexWithUV(1.0D, f9, 0.0F - p_78439_7_, p_78439_3_, f8); - p_78439_0_.addVertexWithUV(0.0D, f9, 0.0F - p_78439_7_, p_78439_1_, f8); + p_78439_0_.addVertexWithUV(0.0D, (double) f9, 0.0D, (double) p_78439_1_, (double) f8); + p_78439_0_.addVertexWithUV(1.0D, (double) f9, 0.0D, (double) p_78439_3_, (double) f8); + p_78439_0_.addVertexWithUV(1.0D, (double) f9, (double) (0.0F - p_78439_7_), (double) p_78439_3_, (double) f8); + p_78439_0_.addVertexWithUV(0.0D, (double) f9, (double) (0.0F - p_78439_7_), (double) p_78439_1_, (double) f8); } p_78439_0_.draw(); @@ -554,10 +554,10 @@ public class ItemCustomRenderer implements IItemRenderer { for (k = 0; k < height; ++k) { f7 = (float) k / (float) height; f8 = p_78439_4_ + (p_78439_2_ - p_78439_4_) * f7 - f6; - p_78439_0_.addVertexWithUV(1.0D, f7, 0.0D, p_78439_3_, f8); - p_78439_0_.addVertexWithUV(0.0D, f7, 0.0D, p_78439_1_, f8); - p_78439_0_.addVertexWithUV(0.0D, f7, 0.0F - p_78439_7_, p_78439_1_, f8); - p_78439_0_.addVertexWithUV(1.0D, f7, 0.0F - p_78439_7_, p_78439_3_, f8); + p_78439_0_.addVertexWithUV(1.0D, (double) f7, 0.0D, (double) p_78439_3_, (double) f8); + p_78439_0_.addVertexWithUV(0.0D, (double) f7, 0.0D, (double) p_78439_1_, (double) f8); + p_78439_0_.addVertexWithUV(0.0D, (double) f7, (double) (0.0F - p_78439_7_), (double) p_78439_1_, (double) f8); + p_78439_0_.addVertexWithUV(1.0D, (double) f7, (double) (0.0F - p_78439_7_), (double) p_78439_3_, (double) f8); } p_78439_0_.draw(); diff --git a/src/main/java/noppes/npcs/client/renderer/items/ItemToolRenderer.java b/src/main/java/noppes/npcs/client/renderer/items/ItemToolRenderer.java index 7fc23618d..b6a75c360 100644 --- a/src/main/java/noppes/npcs/client/renderer/items/ItemToolRenderer.java +++ b/src/main/java/noppes/npcs/client/renderer/items/ItemToolRenderer.java @@ -26,8 +26,8 @@ public class ItemToolRenderer implements IItemRenderer { private static final ResourceLocation RES_ITEM_GLINT = new ResourceLocation("textures/misc/enchanted_item_glint.png"); private static final ResourceLocation PAINTBRUSH_HANDLE = new ResourceLocation("customnpcs", "textures/items/npcBrushHandle.png"); private static final ResourceLocation PAINTBRUSH_BRUSH = new ResourceLocation("customnpcs", "textures/items/npcBrushHair.png"); - - private static final ResourceLocation HAMMER = new ResourceLocation("customnpcs", "textures/items/npcHammer.png"); + private static final ResourceLocation HAMMER = new ResourceLocation("customnpcs", "textures/items/npcToolHammer.png"); + private static final ResourceLocation MAGIC_BOOK = new ResourceLocation("customnpcs", "textures/items/npcToolMagicBook.png"); private final Random random = new Random(); @@ -78,8 +78,10 @@ public class ItemToolRenderer implements IItemRenderer { float blue = (color & 0xFF) / 255.0F; GL11.glColor3f(red, green, blue); renderEntityCustomItem(itemStack, entityItem, PAINTBRUSH_BRUSH); - } else { + } else if (itemStack.getItemDamage() == 0){ renderEntityCustomItem(itemStack, entityItem, HAMMER); + } else if (itemStack.getItemDamage() == 2){ + renderEntityCustomItem(itemStack, entityItem, MAGIC_BOOK); } GL11.glPopMatrix(); return; @@ -112,10 +114,14 @@ public class ItemToolRenderer implements IItemRenderer { GL11.glPushMatrix(); renderItem3d(entityLivingBase, itemStack, PAINTBRUSH_BRUSH); GL11.glPopMatrix(); - } else { + } else if (itemStack.getItemDamage() == 0){ GL11.glPushMatrix(); renderItem3d(entityLivingBase, itemStack, HAMMER); GL11.glPopMatrix(); + } else if (itemStack.getItemDamage() == 2){ + GL11.glPushMatrix(); + renderItem3d(entityLivingBase, itemStack, MAGIC_BOOK); + GL11.glPopMatrix(); } GL11.glPopMatrix(); @@ -133,7 +139,7 @@ public class ItemToolRenderer implements IItemRenderer { entityItem.boundingBox.maxY = entityItem.boundingBox.minY + (double) entityItem.height; if (entityItem.width > f2 && !entityItem.firstUpdate && !entityItem.worldObj.isRemote) { - entityItem.moveEntity(f2 - entityItem.width, 0.0D, f2 - entityItem.width); + entityItem.moveEntity((double) (f2 - entityItem.width), 0.0D, (double) (f2 - entityItem.width)); } } @@ -263,10 +269,10 @@ public class ItemToolRenderer implements IItemRenderer { tessellator.startDrawingQuads(); tessellator.setNormal(0.0F, 1.0F, 0.0F); - tessellator.addVertexWithUV(0.0F - f7, 0.0F - f8, 0.0D, f14, f5); - tessellator.addVertexWithUV(f6 - f7, 0.0F - f8, 0.0D, f15, f5); - tessellator.addVertexWithUV(f6 - f7, 1.0F - f8, 0.0D, f15, f4); - tessellator.addVertexWithUV(0.0F - f7, 1.0F - f8, 0.0D, f14, f4); + tessellator.addVertexWithUV((double) (0.0F - f7), (double) (0.0F - f8), 0.0D, (double) f14, (double) f5); + tessellator.addVertexWithUV((double) (f6 - f7), (double) (0.0F - f8), 0.0D, (double) f15, (double) f5); + tessellator.addVertexWithUV((double) (f6 - f7), (double) (1.0F - f8), 0.0D, (double) f15, (double) f4); + tessellator.addVertexWithUV((double) (0.0F - f7), (double) (1.0F - f8), 0.0D, (double) f14, (double) f4); tessellator.draw(); GL11.glPopMatrix(); } @@ -291,9 +297,12 @@ public class ItemToolRenderer implements IItemRenderer { float blue = (color & 0xFF) / 255.0F; textureManager.bindTexture(PAINTBRUSH_BRUSH); renderCustomItemSlot(0, 0, 16, 16, red, green, blue); - } else { + } else if (itemStack.getItemDamage() == 0){ textureManager.bindTexture(HAMMER); renderCustomItemSlot(0, 0, 16, 16, 1.0f, 1.0f, 1.0f); + } else if (itemStack.getItemDamage() == 2){ + textureManager.bindTexture(MAGIC_BOOK); + renderCustomItemSlot(0, 0, 16, 16, 1.0f, 1.0f, 1.0f); } GL11.glEnable(GL11.GL_LIGHTING); @@ -338,10 +347,10 @@ public class ItemToolRenderer implements IItemRenderer { } tessellator.startDrawingQuads(); - tessellator.addVertexWithUV(p_77018_2_, p_77018_3_ + p_77018_5_, 0, (f2 + (float) p_77018_5_ * f4) * f, (f3 + (float) p_77018_5_) * f1); - tessellator.addVertexWithUV(p_77018_2_ + p_77018_4_, p_77018_3_ + p_77018_5_, 0, (f2 + (float) p_77018_4_ + (float) p_77018_5_ * f4) * f, (f3 + (float) p_77018_5_) * f1); - tessellator.addVertexWithUV(p_77018_2_ + p_77018_4_, p_77018_3_, 0, (f2 + (float) p_77018_4_) * f, (f3 + 0.0F) * f1); - tessellator.addVertexWithUV(p_77018_2_, p_77018_3_, 0, (f2 + 0.0F) * f, (f3 + 0.0F) * f1); + tessellator.addVertexWithUV((double) (p_77018_2_ + 0), (double) (p_77018_3_ + p_77018_5_), 0, (double) ((f2 + (float) p_77018_5_ * f4) * f), (double) ((f3 + (float) p_77018_5_) * f1)); + tessellator.addVertexWithUV((double) (p_77018_2_ + p_77018_4_), (double) (p_77018_3_ + p_77018_5_), 0, (double) ((f2 + (float) p_77018_4_ + (float) p_77018_5_ * f4) * f), (double) ((f3 + (float) p_77018_5_) * f1)); + tessellator.addVertexWithUV((double) (p_77018_2_ + p_77018_4_), (double) (p_77018_3_ + 0), 0, (double) ((f2 + (float) p_77018_4_) * f), (double) ((f3 + 0.0F) * f1)); + tessellator.addVertexWithUV((double) (p_77018_2_ + 0), (double) (p_77018_3_ + 0), 0, (double) ((f2 + 0.0F) * f), (double) ((f3 + 0.0F) * f1)); tessellator.draw(); } } @@ -350,10 +359,10 @@ public class ItemToolRenderer implements IItemRenderer { Tessellator tessellator = Tessellator.instance; tessellator.startDrawingQuads(); tessellator.setColorRGBA_F(itemRed, itemGreen, itemBlue, 1.0F); - tessellator.addVertexWithUV(posX, posY + imageHeight, 0, 0, 1); - tessellator.addVertexWithUV(posX + imageWidth, posY + imageHeight, 0, 1, 1); - tessellator.addVertexWithUV(posX + imageWidth, posY, 0, 1, 0); - tessellator.addVertexWithUV(posX, posY, 0, 0, 0); + tessellator.addVertexWithUV((double) (posX), (double) (posY + imageHeight), 0, 0, 1); + tessellator.addVertexWithUV((double) (posX + imageWidth), (double) (posY + imageHeight), 0, 1, 1); + tessellator.addVertexWithUV((double) (posX + imageWidth), (double) (posY), 0, 1, 0); + tessellator.addVertexWithUV((double) (posX), (double) (posY), 0, 0, 0); tessellator.draw(); } @@ -421,17 +430,17 @@ public class ItemToolRenderer implements IItemRenderer { p_78439_0_.startDrawingQuads(); p_78439_0_.setNormal(0.0F, 0.0F, 1.0F); - p_78439_0_.addVertexWithUV(0.0D, 0.0D, 0.0D, p_78439_1_, p_78439_4_); - p_78439_0_.addVertexWithUV(1.0D, 0.0D, 0.0D, p_78439_3_, p_78439_4_); - p_78439_0_.addVertexWithUV(1.0D, 1.0D, 0.0D, p_78439_3_, p_78439_2_); - p_78439_0_.addVertexWithUV(0.0D, 1.0D, 0.0D, p_78439_1_, p_78439_2_); + p_78439_0_.addVertexWithUV(0.0D, 0.0D, 0.0D, (double) p_78439_1_, (double) p_78439_4_); + p_78439_0_.addVertexWithUV(1.0D, 0.0D, 0.0D, (double) p_78439_3_, (double) p_78439_4_); + p_78439_0_.addVertexWithUV(1.0D, 1.0D, 0.0D, (double) p_78439_3_, (double) p_78439_2_); + p_78439_0_.addVertexWithUV(0.0D, 1.0D, 0.0D, (double) p_78439_1_, (double) p_78439_2_); p_78439_0_.draw(); p_78439_0_.startDrawingQuads(); p_78439_0_.setNormal(0.0F, 0.0F, -1.0F); - p_78439_0_.addVertexWithUV(0.0D, 1.0D, 0.0F - p_78439_7_, p_78439_1_, p_78439_2_); - p_78439_0_.addVertexWithUV(1.0D, 1.0D, 0.0F - p_78439_7_, p_78439_3_, p_78439_2_); - p_78439_0_.addVertexWithUV(1.0D, 0.0D, 0.0F - p_78439_7_, p_78439_3_, p_78439_4_); - p_78439_0_.addVertexWithUV(0.0D, 0.0D, 0.0F - p_78439_7_, p_78439_1_, p_78439_4_); + p_78439_0_.addVertexWithUV(0.0D, 1.0D, (double) (0.0F - p_78439_7_), (double) p_78439_1_, (double) p_78439_2_); + p_78439_0_.addVertexWithUV(1.0D, 1.0D, (double) (0.0F - p_78439_7_), (double) p_78439_3_, (double) p_78439_2_); + p_78439_0_.addVertexWithUV(1.0D, 0.0D, (double) (0.0F - p_78439_7_), (double) p_78439_3_, (double) p_78439_4_); + p_78439_0_.addVertexWithUV(0.0D, 0.0D, (double) (0.0F - p_78439_7_), (double) p_78439_1_, (double) p_78439_4_); p_78439_0_.draw(); float f5 = 0.5F * (p_78439_1_ - p_78439_3_) / (float) width; float f6 = 0.5F * (p_78439_4_ - p_78439_2_) / (float) height; @@ -444,10 +453,10 @@ public class ItemToolRenderer implements IItemRenderer { for (k = 0; k < width; ++k) { f7 = (float) k / (float) width; f8 = p_78439_1_ + (p_78439_3_ - p_78439_1_) * f7 - f5; - p_78439_0_.addVertexWithUV(f7, 0.0D, 0.0F - p_78439_7_, f8, p_78439_4_); - p_78439_0_.addVertexWithUV(f7, 0.0D, 0.0D, f8, p_78439_4_); - p_78439_0_.addVertexWithUV(f7, 1.0D, 0.0D, f8, p_78439_2_); - p_78439_0_.addVertexWithUV(f7, 1.0D, 0.0F - p_78439_7_, f8, p_78439_2_); + p_78439_0_.addVertexWithUV((double) f7, 0.0D, (double) (0.0F - p_78439_7_), (double) f8, (double) p_78439_4_); + p_78439_0_.addVertexWithUV((double) f7, 0.0D, 0.0D, (double) f8, (double) p_78439_4_); + p_78439_0_.addVertexWithUV((double) f7, 1.0D, 0.0D, (double) f8, (double) p_78439_2_); + p_78439_0_.addVertexWithUV((double) f7, 1.0D, (double) (0.0F - p_78439_7_), (double) f8, (double) p_78439_2_); } p_78439_0_.draw(); @@ -459,10 +468,10 @@ public class ItemToolRenderer implements IItemRenderer { f7 = (float) k / (float) width; f8 = p_78439_1_ + (p_78439_3_ - p_78439_1_) * f7 - f5; f9 = f7 + 1.0F / (float) width; - p_78439_0_.addVertexWithUV(f9, 1.0D, 0.0F - p_78439_7_, f8, p_78439_2_); - p_78439_0_.addVertexWithUV(f9, 1.0D, 0.0D, f8, p_78439_2_); - p_78439_0_.addVertexWithUV(f9, 0.0D, 0.0D, f8, p_78439_4_); - p_78439_0_.addVertexWithUV(f9, 0.0D, 0.0F - p_78439_7_, f8, p_78439_4_); + p_78439_0_.addVertexWithUV((double) f9, 1.0D, (double) (0.0F - p_78439_7_), (double) f8, (double) p_78439_2_); + p_78439_0_.addVertexWithUV((double) f9, 1.0D, 0.0D, (double) f8, (double) p_78439_2_); + p_78439_0_.addVertexWithUV((double) f9, 0.0D, 0.0D, (double) f8, (double) p_78439_4_); + p_78439_0_.addVertexWithUV((double) f9, 0.0D, (double) (0.0F - p_78439_7_), (double) f8, (double) p_78439_4_); } p_78439_0_.draw(); @@ -473,10 +482,10 @@ public class ItemToolRenderer implements IItemRenderer { f7 = (float) k / (float) height; f8 = p_78439_4_ + (p_78439_2_ - p_78439_4_) * f7 - f6; f9 = f7 + 1.0F / (float) height; - p_78439_0_.addVertexWithUV(0.0D, f9, 0.0D, p_78439_1_, f8); - p_78439_0_.addVertexWithUV(1.0D, f9, 0.0D, p_78439_3_, f8); - p_78439_0_.addVertexWithUV(1.0D, f9, 0.0F - p_78439_7_, p_78439_3_, f8); - p_78439_0_.addVertexWithUV(0.0D, f9, 0.0F - p_78439_7_, p_78439_1_, f8); + p_78439_0_.addVertexWithUV(0.0D, (double) f9, 0.0D, (double) p_78439_1_, (double) f8); + p_78439_0_.addVertexWithUV(1.0D, (double) f9, 0.0D, (double) p_78439_3_, (double) f8); + p_78439_0_.addVertexWithUV(1.0D, (double) f9, (double) (0.0F - p_78439_7_), (double) p_78439_3_, (double) f8); + p_78439_0_.addVertexWithUV(0.0D, (double) f9, (double) (0.0F - p_78439_7_), (double) p_78439_1_, (double) f8); } p_78439_0_.draw(); @@ -486,10 +495,10 @@ public class ItemToolRenderer implements IItemRenderer { for (k = 0; k < height; ++k) { f7 = (float) k / (float) height; f8 = p_78439_4_ + (p_78439_2_ - p_78439_4_) * f7 - f6; - p_78439_0_.addVertexWithUV(1.0D, f7, 0.0D, p_78439_3_, f8); - p_78439_0_.addVertexWithUV(0.0D, f7, 0.0D, p_78439_1_, f8); - p_78439_0_.addVertexWithUV(0.0D, f7, 0.0F - p_78439_7_, p_78439_1_, f8); - p_78439_0_.addVertexWithUV(1.0D, f7, 0.0F - p_78439_7_, p_78439_3_, f8); + p_78439_0_.addVertexWithUV(1.0D, (double) f7, 0.0D, (double) p_78439_3_, (double) f8); + p_78439_0_.addVertexWithUV(0.0D, (double) f7, 0.0D, (double) p_78439_1_, (double) f8); + p_78439_0_.addVertexWithUV(0.0D, (double) f7, (double) (0.0F - p_78439_7_), (double) p_78439_1_, (double) f8); + p_78439_0_.addVertexWithUV(1.0D, (double) f7, (double) (0.0F - p_78439_7_), (double) p_78439_3_, (double) f8); } p_78439_0_.draw(); diff --git a/src/main/java/noppes/npcs/compat/PixelmonHelper.java b/src/main/java/noppes/npcs/compat/PixelmonHelper.java index 6575ee6d9..670fe1015 100644 --- a/src/main/java/noppes/npcs/compat/PixelmonHelper.java +++ b/src/main/java/noppes/npcs/compat/PixelmonHelper.java @@ -162,7 +162,10 @@ public class PixelmonHelper { try { Class c = Class.forName("com.pixelmonmod.pixelmon.battles.BattleRegistry"); Method m = c.getMethod("getBattle", EntityPlayer.class); - return m.invoke(null, player) == null; + if (m.invoke(null, player) != null) + return false; + + return true; } catch (Exception e) { LogManager.getLogger().error("canBattle", e); return false; @@ -194,7 +197,10 @@ public class PixelmonHelper { Method m = ob.getClass().getMethod("countAblePokemon"); - return (Integer) m.invoke(ob) != 0; + if ((Integer) m.invoke(ob) == 0) + return false; + + return true; } catch (Exception e) { LogManager.getLogger().error("canBattle", e); return false; diff --git a/src/main/java/noppes/npcs/config/ConfigExperimental.java b/src/main/java/noppes/npcs/config/ConfigExperimental.java new file mode 100644 index 000000000..da2fd0019 --- /dev/null +++ b/src/main/java/noppes/npcs/config/ConfigExperimental.java @@ -0,0 +1,35 @@ +package noppes.npcs.config; + +import cpw.mods.fml.common.FMLLog; +import net.minecraftforge.common.config.Configuration; +import net.minecraftforge.common.config.Property; +import org.apache.logging.log4j.Level; + +import java.io.File; + +public class ConfigExperimental { + public static Configuration config; + + public final static String CLIENT = "Client"; + public final static String SERVER = "Server"; + public static Property ModernGuiSystemProperty; + public static boolean ModernGuiSystem = false; + + + public static void init(File configFile) { + config = new Configuration(configFile); + + try { + config.load(); + + ModernGuiSystemProperty = config.get(CLIENT, "Experimental Dialog GUI", false, "Enables the new CNPC+ Modern GUI for Dialog and Quest information"); + ModernGuiSystem = ModernGuiSystemProperty.getBoolean(false); + } catch (Exception e) { + FMLLog.log(Level.ERROR, e, "CNPC+ has had a problem loading its experimental configuration"); + } finally { + if (config.hasChanged()) { + config.save(); + } + } + } +} diff --git a/src/main/java/noppes/npcs/config/ConfigMain.java b/src/main/java/noppes/npcs/config/ConfigMain.java index ca73668e8..04744580f 100644 --- a/src/main/java/noppes/npcs/config/ConfigMain.java +++ b/src/main/java/noppes/npcs/config/ConfigMain.java @@ -21,7 +21,6 @@ public class ConfigMain { public final static String PARTY = "PARTY"; public final static String PROFILES = "Profile"; public final static String ATTRIBUTES = "Attributes"; - public final static String ITEM = "Item"; /** * General Main Properties @@ -94,6 +93,8 @@ public class ConfigMain { public static Property RestrictedProfileRegionsProperty; public static List> RestrictedProfileRegions = new ArrayList<>(); + public static int DefaultProfileSlots = 5; + /** * General NPC Properties @@ -234,6 +235,8 @@ public class ConfigMain { "1, 50, 60, 50, 150, 75, 150" }, "List of restricted regions where profile switching is enabled. Format: DIM, X1, Y1, Z1, X2, Y2, Z2"); + DefaultProfileSlots = config.get(PROFILES, "Default Profile Slots", 5, "This is the default amount without any permission handling").getInt(5); + RestrictedProfileRegions.clear(); for (String region : RestrictedProfileRegionsProperty.getStringList()) { String[] parts = region.split(", "); diff --git a/src/main/java/noppes/npcs/config/ConfigScript.java b/src/main/java/noppes/npcs/config/ConfigScript.java index 41804cdde..41968cb93 100644 --- a/src/main/java/noppes/npcs/config/ConfigScript.java +++ b/src/main/java/noppes/npcs/config/ConfigScript.java @@ -58,6 +58,8 @@ public class ConfigScript { public static Property BannedClassesProperty; public final static HashSet BannedClasses = new HashSet<>(); + public static boolean IndividualPlayerScripts = false; + public static void init(File configFile) { config = new Configuration(configFile); @@ -109,6 +111,9 @@ public class ConfigScript { "Classes must be fully written out with library names preceding them.\n" + "This is a feature ONLY AVAILABLE ON NASHORN."); + + IndividualPlayerScripts = config.get(CUSTOMIZATION, "Individual Player Scripts", false, "Acts similar to CNPC 1.12 where Player Scripts like Init are run PER Player").getBoolean(false); + // Convert to Legacy if (CustomNpcs.legacyExist) { ScriptingEnabled = LegacyConfig.ScriptingEnabled; diff --git a/src/main/java/noppes/npcs/config/GlyphCache.java b/src/main/java/noppes/npcs/config/GlyphCache.java index 0bd650be9..fc4922be9 100644 --- a/src/main/java/noppes/npcs/config/GlyphCache.java +++ b/src/main/java/noppes/npcs/config/GlyphCache.java @@ -62,7 +62,7 @@ public class GlyphCache { /** * Transparent (alpha zero) white background color for use with BufferedImage.clearRect(). */ - private static final Color BACK_COLOR = new Color(255, 255, 255, 0); + private static Color BACK_COLOR = new Color(255, 255, 255, 0); /** * The point size at which every OpenType font is rendered. @@ -89,40 +89,40 @@ public class GlyphCache { /** * All font glyphs are packed inside this image and are then loaded from here into an OpenGL texture. */ - private final BufferedImage glyphCacheImage = new BufferedImage(TEXTURE_WIDTH, TEXTURE_HEIGHT, BufferedImage.TYPE_INT_ARGB); + private BufferedImage glyphCacheImage = new BufferedImage(TEXTURE_WIDTH, TEXTURE_HEIGHT, BufferedImage.TYPE_INT_ARGB); /** * The Graphics2D associated with glyphCacheImage and used for bit blitting between stringImage. */ - private final Graphics2D glyphCacheGraphics = glyphCacheImage.createGraphics(); + private Graphics2D glyphCacheGraphics = glyphCacheImage.createGraphics(); /** * Needed for all text layout operations that create GlyphVectors (maps point size to pixel size). */ - private final FontRenderContext fontRenderContext = glyphCacheGraphics.getFontRenderContext(); + private FontRenderContext fontRenderContext = glyphCacheGraphics.getFontRenderContext(); /** * Intermediate data array for use with textureImage.getRgb(). */ - private final int[] imageData = new int[TEXTURE_WIDTH * TEXTURE_HEIGHT]; + private int imageData[] = new int[TEXTURE_WIDTH * TEXTURE_HEIGHT]; /** * A big-endian direct int buffer used with glTexSubImage2D() and glTexImage2D(). Used for loading the pre-rendered glyph * images from the glyphCacheImage BufferedImage into OpenGL textures. This buffer uses big-endian byte ordering to ensure * that the integers holding packed RGBA colors are stored into memory in a predictable order. */ - private final IntBuffer imageBuffer = ByteBuffer.allocateDirect(4 * TEXTURE_WIDTH * TEXTURE_HEIGHT).order(ByteOrder.BIG_ENDIAN).asIntBuffer(); + private IntBuffer imageBuffer = ByteBuffer.allocateDirect(4 * TEXTURE_WIDTH * TEXTURE_HEIGHT).order(ByteOrder.BIG_ENDIAN).asIntBuffer(); /** * A single integer direct buffer with native byte ordering used for returning values from glGenTextures(). */ - private final IntBuffer singleIntBuffer = GLAllocation.createDirectIntBuffer(1); + private IntBuffer singleIntBuffer = GLAllocation.createDirectIntBuffer(1); /** * List of all available physical fonts on the system. Used by lookupFont() to find alternate fonts. */ - private final List allFonts = Arrays.asList(GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts()); + private List allFonts = Arrays.asList(GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts()); /** * A list of all fonts that have been returned so far by lookupFont(), and that will always be searched first for a usable font before @@ -143,14 +143,14 @@ public class GlyphCache { * increasing) which forms the upper 32 bits of the key into the glyphCache map. This font cache can include different styles * of the same font family like bold or italic. */ - private final LinkedHashMap fontCache = new LinkedHashMap(); + private LinkedHashMap fontCache = new LinkedHashMap(); /** * A cache of pre-rendered glyphs mapping each glyph by its glyphcode to the position of its pre-rendered image within * the cache texture. The key is a 64 bit number such that the lower 32 bits are the glyphcode and the upper 32 are the * index of the font in the fontCache. This makes for a single globally unique number to identify any glyph from any font. */ - private final LinkedHashMap glyphCache = new LinkedHashMap(); + private LinkedHashMap glyphCache = new LinkedHashMap(); /** @@ -283,7 +283,7 @@ public class GlyphCache { * @param layoutFlags either Font.LAYOUT_RIGHT_TO_LEFT or Font.LAYOUT_LEFT_TO_RIGHT * @return the newly created GlyphVector */ - GlyphVector layoutGlyphVector(Font font, char[] text, int start, int limit, int layoutFlags) { + GlyphVector layoutGlyphVector(Font font, char text[], int start, int limit, int layoutFlags) { /* Ensure this font is already in fontCache so it can be referenced by cacheGlyphs() later on */ if (!fontCache.containsKey(font)) { fontCache.put(font, fontCache.size()); @@ -301,7 +301,7 @@ public class GlyphCache { * @param style combination of the Font.PLAIN, Font.BOLD, and Font.ITALIC to request a particular font style * @return an OpenType font capable of displaying at least the first character at the start position in text */ - Font lookupFont(char[] text, int start, int limit, int style) { + Font lookupFont(char text[], int start, int limit, int style) { /* Try using an already known base font; the first font in usedFonts list is the one set with setDefaultFont() */ Iterator iterator = usedFonts.iterator(); while (iterator.hasNext()) { @@ -362,7 +362,7 @@ public class GlyphCache { * parenthesis which are mapped to two different glyph codes depending on the surrounding text direction * @todo May need a blank border of pixels around everything for mip-map/tri-linear filtering with Optifine */ - void cacheGlyphs(Font font, char[] text, int start, int limit, int layoutFlags) { + void cacheGlyphs(Font font, char text[], int start, int limit, int layoutFlags) { /* Create new GlyphVector so glyphs can be moved around (kerning workaround; see below) without affecting caller */ GlyphVector vector = layoutGlyphVector(font, text, start, limit, layoutFlags); diff --git a/src/main/java/noppes/npcs/config/LoadConfiguration.java b/src/main/java/noppes/npcs/config/LoadConfiguration.java index 9dc1b7cef..19fad65c2 100644 --- a/src/main/java/noppes/npcs/config/LoadConfiguration.java +++ b/src/main/java/noppes/npcs/config/LoadConfiguration.java @@ -8,6 +8,7 @@ public class LoadConfiguration { public static File scriptConfigFile; public static File debugConfigFile; public static File clientConfigFile; + public static File experimentalConfigFile; public static void init(String configpath) { mainConfigFile = new File(configpath + "main.cfg"); @@ -15,11 +16,13 @@ public class LoadConfiguration { clientConfigFile = new File(configpath + "client.cfg"); scriptConfigFile = new File(configpath + "script.cfg"); debugConfigFile = new File(configpath + "debug.cfg"); + experimentalConfigFile = new File(configpath + "experimental.cfg"); ConfigMain.init(mainConfigFile); ConfigItem.init(itemConfigFile); ConfigClient.init(clientConfigFile); ConfigScript.init(scriptConfigFile); ConfigDebug.init(debugConfigFile); + ConfigExperimental.init(experimentalConfigFile); } } diff --git a/src/main/java/noppes/npcs/config/StringCache.java b/src/main/java/noppes/npcs/config/StringCache.java index e68a7b125..263b480b9 100644 --- a/src/main/java/noppes/npcs/config/StringCache.java +++ b/src/main/java/noppes/npcs/config/StringCache.java @@ -73,20 +73,20 @@ public class StringCache { /** * Reference to the unicode.FontRenderer class. Needed for creating GlyphVectors and retrieving glyph texture coordinates. */ - private final GlyphCache glyphCache; + private GlyphCache glyphCache; /** * Color codes from original FontRender class. First 16 entries are the primary chat colors; second 16 are darker versions * used for drop shadows. */ - private final int[] colorTable; + private int colorTable[]; /** * A cache of recently seen strings to their fully layed-out state, complete with color changes and texture coordinates of * all pre-rendered glyph images needed to display this string. The weakRefCache holds strong references to the Key * objects used in this map. */ - private final WeakHashMap stringCache = new WeakHashMap(); + private WeakHashMap stringCache = new WeakHashMap(); /** * Every String passed to the public renderString() function is added to this WeakHashMap. As long as As long as Minecraft @@ -94,14 +94,14 @@ public class StringCache { * weakRefCache map will continue to hold a strong reference to the Key object that said strings all map to (multiple strings * in weakRefCache can map to a single Key if those strings only differ by their ASCII digits). */ - private final WeakHashMap weakRefCache = new WeakHashMap(); + private WeakHashMap weakRefCache = new WeakHashMap(); /** * Temporary Key object re-used for lookups with stringCache.get(). Using a temporary object like this avoids the overhead * of allocating new objects in the critical rendering path. Of course, new Key objects are always created when adding * a mapping to stringCache. */ - private final Key lookupKey = new Key(); + private Key lookupKey = new Key(); /** * Pre-cached glyphs for the ASCII digits 0-9 (in that order). Used by renderString() to substiture digit glyphs on the fly @@ -109,7 +109,7 @@ public class StringCache { * The 4 element array is index by the font style (combination of Font.PLAIN, Font.BOLD, and Font.ITALIC), and each of the * nested elements is index by the digit value 0-9. */ - private final Glyph[][] digitGlyphs = new Glyph[4][]; + private Glyph[][] digitGlyphs = new Glyph[4][]; /** * True if digitGlyphs[] has been assigned and cacheString() can begin replacing all digits with '0' in the string. @@ -128,7 +128,7 @@ public class StringCache { * it will crash LWJGL with a NullPointerException. By remembering the initial thread and comparing it later against * Thread.currentThread(), the StringCache code can avoid calling cacheGlyphs() when it's not safe to do so. */ - private final Thread mainThread; + private Thread mainThread; public int fontHeight; @@ -248,12 +248,12 @@ public class StringCache { /** * Array of fully layed out glyphs for the string. Sorted by logical order of characters (i.e. glyph.stringIndex) */ - public Glyph[] glyphs; + public Glyph glyphs[]; /** * Array of color code locations from the original string */ - public ColorCode[] colors; + public ColorCode colors[]; /** * True if the string uses strikethrough or underlines anywhere and needs an extra pass in renderString() @@ -699,7 +699,7 @@ public class StringCache { width += width; /* The glyph array for a string is sorted by the string's logical character position */ - Glyph[] glyphs = cacheString(str).glyphs; + Glyph glyphs[] = cacheString(str).glyphs; /* Index of the last whitespace found in the string; used if breakAtSpaces is true */ int wsIndex = -1; @@ -814,7 +814,7 @@ public class StringCache { /* If string is not cached (or not on main thread) then layout the string */ if (entry == null) { /* layoutGlyphVector() requires a char[] so create it here and pass it around to avoid duplication later on */ - char[] text = str.toCharArray(); + char text[] = str.toCharArray(); /* Strip all color codes from the string */ entry = new Entry(); @@ -822,7 +822,7 @@ public class StringCache { /* Layout the entire string, splitting it up by color codes and the Unicode bidirectional algorithm */ List glyphList = new ArrayList(); - entry.advance = layoutBidiString(glyphList, text, 0, length, entry.colors); + entry.advance = (int) layoutBidiString(glyphList, text, 0, length, entry.colors); /* Convert the accumulated Glyph list to an array for efficient storage */ entry.glyphs = new Glyph[glyphList.size()]; @@ -861,7 +861,7 @@ public class StringCache { key = new Key(); /* Make a copy of the original String to avoid creating a strong reference to it */ - key.str = str; + key.str = new String(str); entry.keyRef = new WeakReference(key); stringCache.put(key, entry); } @@ -896,7 +896,7 @@ public class StringCache { * @param text on input it should be an identical copy of str; on output it will be string with all color codes removed * @return the length of the new stripped string in text[]; actual text.length will not change because the array is not reallocated */ - private int stripColorCodes(Entry cacheEntry, String str, char[] text) { + private int stripColorCodes(Entry cacheEntry, String str, char text[]) { List colorList = new ArrayList(); int start = 0, shift = 0, next; @@ -992,7 +992,7 @@ public class StringCache { * @param limit the (offset + length) at which to stop performing the layout * @return the total advance (horizontal distance) of this string */ - private int layoutBidiString(List glyphList, char[] text, int start, int limit, ColorCode[] colors) { + private int layoutBidiString(List glyphList, char text[], int start, int limit, ColorCode colors[]) { int advance = 0; /* Avoid performing full bidirectional analysis if text has no "strong" right-to-left characters */ @@ -1008,13 +1008,13 @@ public class StringCache { /* Otherwise text has a mixture of LTR and RLT, and it requires full bidirectional analysis */ else { int runCount = bidi.getRunCount(); - byte[] levels = new byte[runCount]; - Integer[] ranges = new Integer[runCount]; + byte levels[] = new byte[runCount]; + Integer ranges[] = new Integer[runCount]; /* Reorder contiguous runs of text into their display order from left to right */ for (int index = 0; index < runCount; index++) { levels[index] = (byte) bidi.getRunLevel(index); - ranges[index] = Integer.valueOf(index); + ranges[index] = new Integer(index); } Bidi.reorderVisually(levels, 0, ranges, 0, runCount); @@ -1042,7 +1042,7 @@ public class StringCache { } } - private int layoutStyle(List glyphList, char[] text, int start, int limit, int layoutFlags, int advance, ColorCode[] colors) { + private int layoutStyle(List glyphList, char text[], int start, int limit, int layoutFlags, int advance, ColorCode colors[]) { int currentFontStyle = Font.PLAIN; /* Find ColorCode object with stripIndex <= start; that will have the font style in effect at the beginning of this text run */ @@ -1106,7 +1106,7 @@ public class StringCache { * @todo Correctly handling RTL font selection requires scanning the sctring from RTL as well. * @todo Use bitmap fonts as a fallback if no OpenType font could be found */ - private int layoutString(List glyphList, char[] text, int start, int limit, int layoutFlags, int advance, int style) { + private int layoutString(List glyphList, char text[], int start, int limit, int layoutFlags, int advance, int style) { /* * Convert all digits in the string to a '0' before layout to ensure that any glyphs replaced on the fly will all have * the same positions. Under Windows, Java's "SansSerif" logical font uses the "Arial" font for digits, in which the "1" @@ -1162,7 +1162,7 @@ public class StringCache { * @return the advance (horizontal distance) of this string plus the advance passed in as an argument * @todo need to ajust position of all glyphs if digits are present, by assuming every digit should be 0 in length */ - private int layoutFont(List glyphList, char[] text, int start, int limit, int layoutFlags, int advance, Font font) { + private int layoutFont(List glyphList, char text[], int start, int limit, int layoutFlags, int advance, Font font) { /* * Ensure that all glyphs used by the string are pre-rendered and cached in the texture. Only safe to do so from the * main thread because cacheGlyphs() can crash LWJGL if it makes OpenGL calls from any other thread. In this case, diff --git a/src/main/java/noppes/npcs/config/legacy/LegacyLoader.java b/src/main/java/noppes/npcs/config/legacy/LegacyLoader.java index 4280d9df3..608824c08 100644 --- a/src/main/java/noppes/npcs/config/legacy/LegacyLoader.java +++ b/src/main/java/noppes/npcs/config/legacy/LegacyLoader.java @@ -9,10 +9,10 @@ import java.util.LinkedList; public class LegacyLoader { private boolean updateFile = false; - private final File dir; - private final String fileName; - private final Class configClass; - private final LinkedList configFields; + private File dir; + private String fileName; + private Class configClass; + private LinkedList configFields; public LegacyLoader(Class clss, File dir, String fileName) { if (!dir.exists()) @@ -21,7 +21,7 @@ public class LegacyLoader { configClass = clss; configFields = new LinkedList(); this.fileName = fileName + ".cfg"; - Field[] fields = configClass.getDeclaredFields(); + Field fields[] = configClass.getDeclaredFields(); for (Field field : fields) { if (field.isAnnotationPresent(ConfigProp.class)) { configFields.add(field); @@ -34,7 +34,7 @@ public class LegacyLoader { File configFile = new File(dir, fileName); HashMap types = new HashMap(); for (Field field : configFields) { - ConfigProp prop = field.getAnnotation(ConfigProp.class); + ConfigProp prop = (ConfigProp) field.getAnnotation(ConfigProp.class); types.put(!prop.name().isEmpty() ? prop.name() : field.getName(), field); } if (configFile.exists()) { @@ -47,10 +47,8 @@ public class LegacyLoader { } } for (String type : types.keySet()) - if (!properties.containsKey(type)) { + if (!properties.containsKey(type)) updateFile = true; - break; - } } else { updateFile = true; } @@ -113,7 +111,7 @@ public class LegacyLoader { file.createNewFile(); BufferedWriter out = new BufferedWriter(new FileWriter(file)); for (Field field : configFields) { - ConfigProp prop = field.getAnnotation(ConfigProp.class); + ConfigProp prop = (ConfigProp) field.getAnnotation(ConfigProp.class); if (prop.info().length() != 0) out.write("#" + prop.info() + System.getProperty("line.separator")); String name = !prop.name().isEmpty() ? prop.name() : field.getName(); diff --git a/src/main/java/noppes/npcs/constants/EnumAnimationPart.java b/src/main/java/noppes/npcs/constants/EnumAnimationPart.java index e392d3b60..3360a758d 100644 --- a/src/main/java/noppes/npcs/constants/EnumAnimationPart.java +++ b/src/main/java/noppes/npcs/constants/EnumAnimationPart.java @@ -1,17 +1,11 @@ package noppes.npcs.constants; public enum EnumAnimationPart { - HEAD(0), - BODY(1), - RIGHT_ARM(2), - LEFT_ARM(3), - RIGHT_LEG(4), - LEFT_LEG(5), - FULL_MODEL(6); - - public int id; - - EnumAnimationPart(int id) { - this.id = id; - } + HEAD, + BODY, + RIGHT_ARM, + LEFT_ARM, + RIGHT_LEG, + LEFT_LEG, + FULL_MODEL; } diff --git a/src/main/java/noppes/npcs/constants/EnumCompanionTalent.java b/src/main/java/noppes/npcs/constants/EnumCompanionTalent.java index 5e6ed0bc3..673f7cae1 100644 --- a/src/main/java/noppes/npcs/constants/EnumCompanionTalent.java +++ b/src/main/java/noppes/npcs/constants/EnumCompanionTalent.java @@ -12,7 +12,7 @@ public enum EnumCompanionTalent { public ItemStack item; - EnumCompanionTalent(Item item) { + private EnumCompanionTalent(Item item) { this.item = new ItemStack(item); } } diff --git a/src/main/java/noppes/npcs/constants/EnumDiagramLayout.java b/src/main/java/noppes/npcs/constants/EnumDiagramLayout.java index 817b2c9ff..b361a5245 100644 --- a/src/main/java/noppes/npcs/constants/EnumDiagramLayout.java +++ b/src/main/java/noppes/npcs/constants/EnumDiagramLayout.java @@ -10,9 +10,10 @@ public enum EnumDiagramLayout { CIRCULAR_MANUAL("diagram.circular_manual"), SQUARE_MANUAL("diagram.square_manual"), TREE_MANUAL("diagram.tree_manual"), - CHART("diagram.chart"); + CHART("diagram.chart"), + MANUAL("diagram.manual"); - private final String lang; + private String lang; EnumDiagramLayout(String langName) { this.lang = langName; diff --git a/src/main/java/noppes/npcs/constants/EnumGuiType.java b/src/main/java/noppes/npcs/constants/EnumGuiType.java index 45fc35c8f..d0919b9b1 100644 --- a/src/main/java/noppes/npcs/constants/EnumGuiType.java +++ b/src/main/java/noppes/npcs/constants/EnumGuiType.java @@ -62,5 +62,6 @@ public enum EnumGuiType { CustomGui, ScriptItem, ScriptBlock, - Paintbrush + Paintbrush, + MagicBook; } diff --git a/src/main/java/noppes/npcs/constants/EnumNpcToolMaterial.java b/src/main/java/noppes/npcs/constants/EnumNpcToolMaterial.java index 124b41717..065228b3d 100644 --- a/src/main/java/noppes/npcs/constants/EnumNpcToolMaterial.java +++ b/src/main/java/noppes/npcs/constants/EnumNpcToolMaterial.java @@ -37,7 +37,7 @@ public enum EnumNpcToolMaterial { */ private final int enchantability; - EnumNpcToolMaterial(int par3, int par4, float par5, int par6, int par7) { + private EnumNpcToolMaterial(int par3, int par4, float par5, int par6, int par7) { this.harvestLevel = par3; this.maxUses = par4; this.efficiencyOnProperMaterial = par5; diff --git a/src/main/java/noppes/npcs/constants/EnumOptionType.java b/src/main/java/noppes/npcs/constants/EnumOptionType.java index 735a18ab7..2b5fd97cf 100644 --- a/src/main/java/noppes/npcs/constants/EnumOptionType.java +++ b/src/main/java/noppes/npcs/constants/EnumOptionType.java @@ -1,6 +1,6 @@ package noppes.npcs.constants; public enum EnumOptionType { - QuitOption, DialogOption, Disabled, RoleOption, CommandBlock + QuitOption, DialogOption, Disabled, RoleOption, CommandBlock; } diff --git a/src/main/java/noppes/npcs/constants/EnumParticleType.java b/src/main/java/noppes/npcs/constants/EnumParticleType.java index 6b5dc8666..db88b2221 100644 --- a/src/main/java/noppes/npcs/constants/EnumParticleType.java +++ b/src/main/java/noppes/npcs/constants/EnumParticleType.java @@ -9,7 +9,17 @@ public enum EnumParticleType { LargeSmoke("largesmoke"), Magic("witchMagic"), Enchant("enchantmenttable"), - Crit("crit"); + Crit("crit"), + Explode("explode"), + Music("note"), + Flame("flame"), + Lava("lava"), + Splash("splash"), + Slime("slime"), + Heart("heart"), + AngryVillager("angryVillager"), + HappyVillager("happyVillager"), + Custom("custom"); public String particleName; diff --git a/src/main/java/noppes/npcs/constants/EnumPotionType.java b/src/main/java/noppes/npcs/constants/EnumPotionType.java index 8229028e8..f6d5ad111 100644 --- a/src/main/java/noppes/npcs/constants/EnumPotionType.java +++ b/src/main/java/noppes/npcs/constants/EnumPotionType.java @@ -1,5 +1,5 @@ package noppes.npcs.constants; public enum EnumPotionType { - None, Fire, Poison, Hunger, Weakness, Slowness, Nausea, Blindness, Wither + None, Fire, Poison, Hunger, Weakness, Slowness, Nausea, Blindness, Wither; } diff --git a/src/main/java/noppes/npcs/constants/EnumQuestCompletion.java b/src/main/java/noppes/npcs/constants/EnumQuestCompletion.java index ff9388956..69ead517d 100644 --- a/src/main/java/noppes/npcs/constants/EnumQuestCompletion.java +++ b/src/main/java/noppes/npcs/constants/EnumQuestCompletion.java @@ -1,5 +1,5 @@ package noppes.npcs.constants; public enum EnumQuestCompletion { - Npc, Instant + Npc, Instant; } diff --git a/src/main/java/noppes/npcs/constants/EnumQuestRepeat.java b/src/main/java/noppes/npcs/constants/EnumQuestRepeat.java index 6e2a467a8..706afab01 100644 --- a/src/main/java/noppes/npcs/constants/EnumQuestRepeat.java +++ b/src/main/java/noppes/npcs/constants/EnumQuestRepeat.java @@ -1,5 +1,5 @@ package noppes.npcs.constants; public enum EnumQuestRepeat { - NONE, REPEATABLE, MCDAILY, MCWEEKLY, RLDAILY, RLWEEKLY, MCCUSTOM, RLCUSTOM + NONE, REPEATABLE, MCDAILY, MCWEEKLY, RLDAILY, RLWEEKLY, MCCUSTOM, RLCUSTOM; } diff --git a/src/main/java/noppes/npcs/constants/EnumQuestType.java b/src/main/java/noppes/npcs/constants/EnumQuestType.java index cada70bc0..72792ccab 100644 --- a/src/main/java/noppes/npcs/constants/EnumQuestType.java +++ b/src/main/java/noppes/npcs/constants/EnumQuestType.java @@ -1,5 +1,5 @@ package noppes.npcs.constants; public enum EnumQuestType { - Item, Dialog, Kill, Location, AreaKill, Manual + Item, Dialog, Kill, Location, AreaKill, Manual; } diff --git a/src/main/java/noppes/npcs/constants/EnumScriptType.java b/src/main/java/noppes/npcs/constants/EnumScriptType.java index 3d2fbb837..14ce38f41 100644 --- a/src/main/java/noppes/npcs/constants/EnumScriptType.java +++ b/src/main/java/noppes/npcs/constants/EnumScriptType.java @@ -123,7 +123,7 @@ public enum EnumScriptType { return valueOf(channelName); } - EnumScriptType(String function) { + private EnumScriptType(String function) { this.function = function; } } diff --git a/src/main/java/noppes/npcs/constants/EnumTextureType.java b/src/main/java/noppes/npcs/constants/EnumTextureType.java index bb7e21429..154818460 100644 --- a/src/main/java/noppes/npcs/constants/EnumTextureType.java +++ b/src/main/java/noppes/npcs/constants/EnumTextureType.java @@ -6,7 +6,7 @@ public enum EnumTextureType { BASE("texture.base"), ITEM("texture.item"); - private final String lang; + private String lang; EnumTextureType(String langName) { this.lang = langName; diff --git a/src/main/java/noppes/npcs/containers/ContainerCarpentryBench.java b/src/main/java/noppes/npcs/containers/ContainerCarpentryBench.java index 0c80d0318..ef5d3a9b3 100644 --- a/src/main/java/noppes/npcs/containers/ContainerCarpentryBench.java +++ b/src/main/java/noppes/npcs/containers/ContainerCarpentryBench.java @@ -14,11 +14,11 @@ import noppes.npcs.controllers.data.RecipeCarpentry; public class ContainerCarpentryBench extends Container { public InventoryCrafting craftMatrix = new InventoryCrafting(this, 4, 4); public IInventory craftResult = new InventoryCraftResult(); - private final EntityPlayer player; - private final World worldObj; - private final int posX; - private final int posY; - private final int posZ; + private EntityPlayer player; + private World worldObj; + private int posX; + private int posY; + private int posZ; public ContainerCarpentryBench(InventoryPlayer par1InventoryPlayer, World par2World, int par3, int par4, int par5) { this.worldObj = par2World; @@ -92,7 +92,7 @@ public class ContainerCarpentryBench extends Container { @Override public boolean canInteractWith(EntityPlayer par1EntityPlayer) { - return this.worldObj.getBlock(this.posX, this.posY, this.posZ) == CustomItems.carpentyBench && par1EntityPlayer.getDistanceSq((double) this.posX + 0.5D, (double) this.posY + 0.5D, (double) this.posZ + 0.5D) <= 64.0D; + return this.worldObj.getBlock(this.posX, this.posY, this.posZ) != CustomItems.carpentyBench ? false : par1EntityPlayer.getDistanceSq((double) this.posX + 0.5D, (double) this.posY + 0.5D, (double) this.posZ + 0.5D) <= 64.0D; } /** @@ -126,7 +126,7 @@ public class ContainerCarpentryBench extends Container { } if (var4.stackSize == 0) { - var3.putStack(null); + var3.putStack((ItemStack) null); } else { var3.onSlotChanged(); } diff --git a/src/main/java/noppes/npcs/containers/ContainerCrate.java b/src/main/java/noppes/npcs/containers/ContainerCrate.java index 4ddf099a3..7e0c6f7b1 100644 --- a/src/main/java/noppes/npcs/containers/ContainerCrate.java +++ b/src/main/java/noppes/npcs/containers/ContainerCrate.java @@ -64,7 +64,7 @@ public class ContainerCrate extends Container { } if (itemstack1.stackSize == 0) { - slot.putStack(null); + slot.putStack((ItemStack) null); } else { slot.onSlotChanged(); } diff --git a/src/main/java/noppes/npcs/containers/ContainerMail.java b/src/main/java/noppes/npcs/containers/ContainerMail.java index 5cbc87d4a..8cc88e23a 100644 --- a/src/main/java/noppes/npcs/containers/ContainerMail.java +++ b/src/main/java/noppes/npcs/containers/ContainerMail.java @@ -3,7 +3,7 @@ package noppes.npcs.containers; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -import noppes.npcs.controllers.PlayerDataController; +import noppes.npcs.controllers.data.PlayerData; import noppes.npcs.controllers.data.PlayerMail; import noppes.npcs.controllers.data.PlayerMailData; @@ -12,8 +12,7 @@ import java.util.Iterator; public class ContainerMail extends ContainerNpcInterface { public static PlayerMail staticmail = new PlayerMail(); public PlayerMail mail = new PlayerMail(); - private final boolean canEdit; - private final boolean canSend; + private boolean canEdit, canSend; public ContainerMail(EntityPlayer player, boolean canEdit, boolean canSend) { @@ -61,7 +60,7 @@ public class ContainerMail extends ContainerNpcInterface { } if (itemstack1.stackSize == 0) { - slot.putStack(null); + slot.putStack((ItemStack) null); } else { slot.onSlotChanged(); } @@ -77,7 +76,7 @@ public class ContainerMail extends ContainerNpcInterface { public void onContainerClosed(EntityPlayer player) { super.onContainerClosed(player); if (!canEdit && !player.worldObj.isRemote) { - PlayerMailData data = PlayerDataController.Instance.getPlayerData(player).mailData; + PlayerMailData data = PlayerData.get(player).mailData; Iterator it = data.playermail.iterator(); while (it.hasNext()) { PlayerMail mail = it.next(); diff --git a/src/main/java/noppes/npcs/containers/ContainerManageRecipes.java b/src/main/java/noppes/npcs/containers/ContainerManageRecipes.java index 2303fa539..b5af7d900 100644 --- a/src/main/java/noppes/npcs/containers/ContainerManageRecipes.java +++ b/src/main/java/noppes/npcs/containers/ContainerManageRecipes.java @@ -14,12 +14,12 @@ import java.util.HashMap; import java.util.Map; public class ContainerManageRecipes extends Container { - private final InventoryBasic craftingMatrix; + private InventoryBasic craftingMatrix; public RecipeCarpentry recipe; public RecipeAnvil recipeAnvil; public int size; public int width; - private final boolean init = false; + private boolean init = false; public ContainerManageRecipes(EntityPlayer player, int size) { this.size = size * size; @@ -108,6 +108,7 @@ public class ContainerManageRecipes extends Container { r.itemToRepair = output.copy(); r.repairMaterial = repairMat.copy(); this.recipeAnvil = RecipeAnvil.saveRecipe(r, output, repairMat); + return; } else { // Carpentry Recipe save (existing code) int nextChar = 0; diff --git a/src/main/java/noppes/npcs/containers/ContainerMerchantAdd.java b/src/main/java/noppes/npcs/containers/ContainerMerchantAdd.java index d49896c4f..6fa9e4d8e 100644 --- a/src/main/java/noppes/npcs/containers/ContainerMerchantAdd.java +++ b/src/main/java/noppes/npcs/containers/ContainerMerchantAdd.java @@ -15,8 +15,8 @@ public class ContainerMerchantAdd extends ContainerNpcInterface { /** * Instance of Merchant. */ - private final IMerchant theMerchant; - private final InventoryBasic merchantInventory; + private IMerchant theMerchant; + private InventoryBasic merchantInventory; /** * Instance of World. @@ -96,7 +96,7 @@ public class ContainerMerchantAdd extends ContainerNpcInterface { } if (itemstack1.stackSize == 0) { - slot.putStack(null); + slot.putStack((ItemStack) null); } else { slot.onSlotChanged(); } @@ -116,7 +116,7 @@ public class ContainerMerchantAdd extends ContainerNpcInterface { */ public void onContainerClosed(EntityPlayer par1EntityPlayer) { super.onContainerClosed(par1EntityPlayer); - this.theMerchant.setCustomer(null); + this.theMerchant.setCustomer((EntityPlayer) null); super.onContainerClosed(par1EntityPlayer); if (!this.theWorld.isRemote) { diff --git a/src/main/java/noppes/npcs/containers/ContainerNPCFollowerSetup.java b/src/main/java/noppes/npcs/containers/ContainerNPCFollowerSetup.java index 8fc42fbbc..40c5785bc 100644 --- a/src/main/java/noppes/npcs/containers/ContainerNPCFollowerSetup.java +++ b/src/main/java/noppes/npcs/containers/ContainerNPCFollowerSetup.java @@ -8,7 +8,7 @@ import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.roles.RoleFollower; public class ContainerNPCFollowerSetup extends Container { - private final RoleFollower role; + private RoleFollower role; public ContainerNPCFollowerSetup(EntityNPCInterface npc, EntityPlayer player) { role = (RoleFollower) npc.roleInterface; diff --git a/src/main/java/noppes/npcs/containers/ContainerNPCTrader.java b/src/main/java/noppes/npcs/containers/ContainerNPCTrader.java index 613be749a..71dcd6fa6 100644 --- a/src/main/java/noppes/npcs/containers/ContainerNPCTrader.java +++ b/src/main/java/noppes/npcs/containers/ContainerNPCTrader.java @@ -104,7 +104,9 @@ public class ContainerNPCTrader extends ContainerNpcInterface { return true; } else if (NoppesUtilPlayer.compareItems(itemstack3, item, false, false)) { int k1 = item.stackSize; - return k1 > 0 && k1 + itemstack3.stackSize <= itemstack3.getMaxStackSize(); + if (k1 > 0 && k1 + itemstack3.stackSize <= itemstack3.getMaxStackSize()) { + return true; + } } return false; } diff --git a/src/main/java/noppes/npcs/containers/ContainerNpcInterface.java b/src/main/java/noppes/npcs/containers/ContainerNpcInterface.java index 3dfedb0fe..8091481e6 100644 --- a/src/main/java/noppes/npcs/containers/ContainerNpcInterface.java +++ b/src/main/java/noppes/npcs/containers/ContainerNpcInterface.java @@ -7,8 +7,7 @@ import noppes.npcs.api.IContainer; import noppes.npcs.scripted.ScriptContainer; public class ContainerNpcInterface extends Container { - private final int posX; - private final int posZ; + private int posX, posZ; public EntityPlayer player; public IContainer scriptContainer; diff --git a/src/main/java/noppes/npcs/containers/ContainerNpcItemGiver.java b/src/main/java/noppes/npcs/containers/ContainerNpcItemGiver.java index 46ab3c3f5..d10fdd70a 100644 --- a/src/main/java/noppes/npcs/containers/ContainerNpcItemGiver.java +++ b/src/main/java/noppes/npcs/containers/ContainerNpcItemGiver.java @@ -8,7 +8,7 @@ import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.roles.JobItemGiver; public class ContainerNpcItemGiver extends Container { - private final JobItemGiver role; + private JobItemGiver role; public ContainerNpcItemGiver(EntityNPCInterface npc, EntityPlayer player) { this.role = (JobItemGiver) npc.jobInterface; diff --git a/src/main/java/noppes/npcs/containers/SlotNpcBankCurrency.java b/src/main/java/noppes/npcs/containers/SlotNpcBankCurrency.java index 6fdfbc56a..de0e38bcb 100644 --- a/src/main/java/noppes/npcs/containers/SlotNpcBankCurrency.java +++ b/src/main/java/noppes/npcs/containers/SlotNpcBankCurrency.java @@ -22,7 +22,8 @@ public class SlotNpcBankCurrency extends Slot { if (item == null) return false; if (item.getItem() == itemstack.getItem()) { - return !item.getHasSubtypes() || item.getItemDamage() == itemstack.getItemDamage(); + if (!item.getHasSubtypes() || item.getItemDamage() == itemstack.getItemDamage()) + return true; } return false; } diff --git a/src/main/java/noppes/npcs/controllers/BankController.java b/src/main/java/noppes/npcs/controllers/BankController.java index 716d13f82..ddc258859 100644 --- a/src/main/java/noppes/npcs/controllers/BankController.java +++ b/src/main/java/noppes/npcs/controllers/BankController.java @@ -47,7 +47,11 @@ public class BankController { File file = CustomNpcs.getWorldSaveDirectory(); if (file == null) return false; - return !instance.filePath.equals(file.getAbsolutePath()); + if (!instance.filePath.equals(file.getAbsolutePath())) { + return true; + } + + return false; } private void loadBanks() { diff --git a/src/main/java/noppes/npcs/controllers/CustomEffectController.java b/src/main/java/noppes/npcs/controllers/CustomEffectController.java index 6f2f33046..bd3cf8531 100644 --- a/src/main/java/noppes/npcs/controllers/CustomEffectController.java +++ b/src/main/java/noppes/npcs/controllers/CustomEffectController.java @@ -26,7 +26,7 @@ import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; import java.util.zip.GZIPInputStream; -import static noppes.npcs.scripted.event.PlayerEvent.EffectEvent.ExpirationType; +import static noppes.npcs.scripted.event.player.PlayerEvent.EffectEvent.ExpirationType; public class CustomEffectController implements ICustomEffectHandler { @@ -251,7 +251,6 @@ public class CustomEffectController implements ICustomEffectHandler { CustomEffect parent = get(id, index); if (parent != null) { PlayerEffect playerEffect = new PlayerEffect(id, duration, level, index); - playerEffect.index = index; currentEffects.put(new EffectKey(id, index), playerEffect); parent.onAdded(player, playerEffect); } @@ -507,7 +506,9 @@ public class CustomEffectController implements ICustomEffectHandler { @Override public boolean hasEffect(IPlayer player, ICustomEffect effect) { - return hasEffect((EntityPlayer) player, effect.getID(), effect.getIndex()); + if (player == null || player.getMCEntity() == null) + return false; + return hasEffect((EntityPlayer) player.getMCEntity(), effect.getID(), effect.getIndex()); } @Override @@ -519,7 +520,9 @@ public class CustomEffectController implements ICustomEffectHandler { @Override public int getEffectDuration(IPlayer player, ICustomEffect effect) { - return getEffectDuration(player, effect.getID()); + if(effect == null) + return -1; + return getEffectDuration(player, effect.getID(), effect.getIndex()); } @Override diff --git a/src/main/java/noppes/npcs/controllers/CustomGuiController.java b/src/main/java/noppes/npcs/controllers/CustomGuiController.java index 5c8b6d582..66decf7de 100644 --- a/src/main/java/noppes/npcs/controllers/CustomGuiController.java +++ b/src/main/java/noppes/npcs/controllers/CustomGuiController.java @@ -14,8 +14,9 @@ import noppes.npcs.api.item.IItemStack; import noppes.npcs.constants.EnumGuiType; import noppes.npcs.constants.EnumScriptType; import noppes.npcs.containers.ContainerCustomGui; +import noppes.npcs.controllers.data.PlayerDataScript; import noppes.npcs.scripted.NpcAPI; -import noppes.npcs.scripted.event.CustomGuiEvent; +import noppes.npcs.scripted.event.player.CustomGuiEvent; import noppes.npcs.scripted.gui.ScriptGui; import noppes.npcs.scripted.overlay.ScriptOverlay; @@ -76,53 +77,65 @@ public class CustomGuiController { public static void onButton(CustomGuiEvent.ButtonEvent event) { EntityPlayer player = (EntityPlayer) event.player.getMCEntity(); - if (checkGui(event) && getOpenGui(player).getScriptHandler() != null) { - getOpenGui(player).getScriptHandler().callScript(EnumScriptType.CUSTOM_GUI_BUTTON, event); + if(player != null){ + ScriptGui gui = getOpenGui(player); + if (checkGui(event) && gui != null) { + gui.getScriptHandler(player).callScript(EnumScriptType.CUSTOM_GUI_BUTTON, event); + } } - NpcAPI.EVENT_BUS.post(event); } public static void onSlotChange(CustomGuiEvent.SlotEvent event) { EntityPlayer player = (EntityPlayer) event.player.getMCEntity(); - if (checkGui(event) && getOpenGui(player).getScriptHandler() != null) { - getOpenGui(player).getScriptHandler().callScript(EnumScriptType.CUSTOM_GUI_SLOT, event); + if(player != null){ + ScriptGui gui = getOpenGui(player); + if (checkGui(event) && gui != null) { + gui.getScriptHandler(player).callScript(EnumScriptType.CUSTOM_GUI_SLOT, event); + } } - NpcAPI.EVENT_BUS.post(event); } public static boolean onSlotClick(CustomGuiEvent.SlotClickEvent event) { EntityPlayer player = (EntityPlayer) event.player.getMCEntity(); - if (checkGui(event) && getOpenGui(player).getScriptHandler() != null) { - (getOpenGui(player).getScriptHandler()).callScript(EnumScriptType.CUSTOM_GUI_SLOT_CLICKED, event); + if(player != null){ + ScriptGui gui = getOpenGui(player); + if (checkGui(event) && gui != null) { + gui.getScriptHandler(player).callScript(EnumScriptType.CUSTOM_GUI_SLOT_CLICKED, event); + } } return NpcAPI.EVENT_BUS.post(event); } public static void onCustomGuiUnfocused(CustomGuiEvent.UnfocusedEvent event) { EntityPlayer player = (EntityPlayer) event.player.getMCEntity(); - if (checkGui(event) && getOpenGui(player).getScriptHandler() != null) { - getOpenGui(player).getScriptHandler().callScript(EnumScriptType.CUSTOM_GUI_TEXTFIELD, event); + if(player != null){ + ScriptGui gui = getOpenGui(player); + if (checkGui(event) && gui != null) { + gui.getScriptHandler(player).callScript(EnumScriptType.CUSTOM_GUI_TEXTFIELD, event); + } } - NpcAPI.EVENT_BUS.post(event); } public static void onScrollClick(CustomGuiEvent.ScrollEvent event) { EntityPlayer player = (EntityPlayer) event.player.getMCEntity(); - if (checkGui(event) && getOpenGui(player).getScriptHandler() != null) { - getOpenGui(player).getScriptHandler().callScript(EnumScriptType.CUSTOM_GUI_SCROLL, event); + if(player != null){ + ScriptGui gui = getOpenGui(player); + if (checkGui(event) && gui != null) { + gui.getScriptHandler(player).callScript(EnumScriptType.CUSTOM_GUI_SCROLL, event); + } } - NpcAPI.EVENT_BUS.post(event); } public static void onClose(CustomGuiEvent.CloseEvent event) { - if (ScriptController.Instance.playerScripts != null) { - ScriptController.Instance.playerScripts.callScript(EnumScriptType.CUSTOM_GUI_CLOSED, event); + EntityPlayer player = (EntityPlayer) event.player.getMCEntity(); + if(player != null){ + PlayerDataScript handler = ScriptController.Instance.getPlayerScripts(player); + handler.callScript(EnumScriptType.CUSTOM_GUI_CLOSED, event); } - NpcAPI.EVENT_BUS.post(event); } diff --git a/src/main/java/noppes/npcs/controllers/DialogController.java b/src/main/java/noppes/npcs/controllers/DialogController.java index d482c96cb..3faf29b62 100644 --- a/src/main/java/noppes/npcs/controllers/DialogController.java +++ b/src/main/java/noppes/npcs/controllers/DialogController.java @@ -26,6 +26,7 @@ public class DialogController implements IDialogHandler { public HashMap categories = new HashMap(); public HashMap dialogs = new HashMap(); public static DialogController Instance = new DialogController(); + ; private int lastUsedDialogID = 0; private int lastUsedCatID = 0; @@ -332,6 +333,6 @@ public class DialogController implements IDialogHandler { } public IDialog get(int id) { - return this.dialogs.get(id); + return (IDialog) this.dialogs.get(id); } } diff --git a/src/main/java/noppes/npcs/controllers/FactionController.java b/src/main/java/noppes/npcs/controllers/FactionController.java index e02e8c9c6..995fddd13 100644 --- a/src/main/java/noppes/npcs/controllers/FactionController.java +++ b/src/main/java/noppes/npcs/controllers/FactionController.java @@ -183,7 +183,7 @@ public class FactionController implements IFactionHandler { public IFaction delete(int id) { if (id >= 0 && this.factions.size() > 1) { - Faction faction = this.factions.remove(id); + Faction faction = (Faction) this.factions.remove(id); saveFactions(); if (faction == null) { return null; diff --git a/src/main/java/noppes/npcs/controllers/LinkedItemController.java b/src/main/java/noppes/npcs/controllers/LinkedItemController.java index efd4b0bd9..d97948b49 100644 --- a/src/main/java/noppes/npcs/controllers/LinkedItemController.java +++ b/src/main/java/noppes/npcs/controllers/LinkedItemController.java @@ -93,6 +93,7 @@ public class LinkedItemController { //////////////////////////////////////////////////////// public void load() { + lastUsedID = 0; bootOrder = new HashMap<>(); linkedItems = new HashMap<>(); LogWriter.info("Loading linked items..."); @@ -285,10 +286,12 @@ public class LinkedItemController { } } nbt.setTag("LinkedItems", linkedList); + nbt.setInteger("lastID", lastUsedID); return nbt; } public void readMapNBT(NBTTagCompound compound) { + lastUsedID = compound.getInteger("lastID"); NBTTagList list = compound.getTagList("LinkedItems", 10); if (list != null) { for (int i = 0; i < list.tagCount(); i++) { diff --git a/src/main/java/noppes/npcs/controllers/LinkedNpcController.java b/src/main/java/noppes/npcs/controllers/LinkedNpcController.java index 4570ce778..8873f256f 100644 --- a/src/main/java/noppes/npcs/controllers/LinkedNpcController.java +++ b/src/main/java/noppes/npcs/controllers/LinkedNpcController.java @@ -48,6 +48,7 @@ public class LinkedNpcController { if (file.getName().endsWith(".json")) { try { NBTTagCompound compound = NBTJsonUtil.LoadFile(file); + ; LinkedData linked = new LinkedData(); linked.setNBT(compound); list.add(linked); diff --git a/src/main/java/noppes/npcs/controllers/MagicController.java b/src/main/java/noppes/npcs/controllers/MagicController.java index 02dac4690..e5c6be1a8 100644 --- a/src/main/java/noppes/npcs/controllers/MagicController.java +++ b/src/main/java/noppes/npcs/controllers/MagicController.java @@ -10,6 +10,7 @@ import noppes.npcs.CustomItems; import noppes.npcs.CustomNpcs; import noppes.npcs.LogWriter; import noppes.npcs.api.handler.IMagicHandler; +import noppes.npcs.constants.EnumDiagramLayout; import noppes.npcs.controllers.data.Magic; import noppes.npcs.controllers.data.MagicAssociation; import noppes.npcs.controllers.data.MagicCycle; @@ -99,26 +100,55 @@ public class MagicController implements IMagicHandler { arcane.setItem(new ItemStack(CustomItems.spellArcane)); // Insiders - earth.interactions.put(air.id, 0.60f); - water.interactions.put(earth.id, 0.60f); - fire.interactions.put(water.id, 0.60f); - air.interactions.put(fire.id, 0.60f); + earth.interactions.put(air.id, -0.50f); + air.interactions.put(earth.id, 0.50f); + + water.interactions.put(earth.id, -0.50f); + earth.interactions.put(water.id, 0.50f); + + fire.interactions.put(water.id, -0.50f); + water.interactions.put(fire.id, 0.50f); + + air.interactions.put(fire.id, -0.50f); + fire.interactions.put(air.id, 0.50f); // Outsiders - dark.interactions.put(nature.id, 0.60f); - nature.interactions.put(holy.id, 0.60f); - holy.interactions.put(arcane.id, 0.60f); - arcane.interactions.put(dark.id, 0.60f); + dark.interactions.put(nature.id, -0.50f); + nature.interactions.put(dark.id, 0.50f); + + nature.interactions.put(holy.id, -0.50f); + holy.interactions.put(nature.id, 0.50f); + + holy.interactions.put(arcane.id, -0.50f); + arcane.interactions.put(holy.id, 0.50f); + + arcane.interactions.put(dark.id, -0.50f); + dark.interactions.put(arcane.id, 0.50f); // Cross Interactions - earth.interactions.put(nature.id, 0.30f); - water.interactions.put(holy.id, 0.30f); - fire.interactions.put(arcane.id, 0.30f); - air.interactions.put(dark.id, 0.30f); - dark.interactions.put(fire.id, 0.30f); - nature.interactions.put(air.id, 0.30f); - holy.interactions.put(earth.id, 0.30f); - arcane.interactions.put(water.id, 0.30f); + earth.interactions.put(nature.id, -0.25f); + nature.interactions.put(earth.id, 0.25f); + + water.interactions.put(holy.id, -0.25f); + holy.interactions.put(water.id, 0.25f); + + fire.interactions.put(arcane.id, -0.25f); + arcane.interactions.put(fire.id, 0.25f); + + air.interactions.put(dark.id, -0.25f); + dark.interactions.put(air.id, 0.25f); + + dark.interactions.put(fire.id, -0.25f); + fire.interactions.put(dark.id, 0.25f); + + nature.interactions.put(air.id, -0.25f); + air.interactions.put(nature.id, 0.25f); + + holy.interactions.put(earth.id, -0.25f); + earth.interactions.put(holy.id, 0.25f); + + arcane.interactions.put(water.id, -0.25f); + water.interactions.put(arcane.id, 0.25f); // Add them to the registry magics.put(earth.id, earth); @@ -133,7 +163,8 @@ public class MagicController implements IMagicHandler { MagicCycle defaultCycle = new MagicCycle(); defaultCycle.id = getUnusedCycleId(); defaultCycle.name = "Universal"; - defaultCycle.displayName = "Elementa Cycle"; + defaultCycle.layout = EnumDiagramLayout.CIRCULAR_MANUAL; + defaultCycle.displayName = "&6Elementa Cycle"; cycles.put(defaultCycle.id, defaultCycle); // Add magic associations using your old index and priority values: diff --git a/src/main/java/noppes/npcs/controllers/PartyController.java b/src/main/java/noppes/npcs/controllers/PartyController.java index bce4a72f7..3b7394657 100644 --- a/src/main/java/noppes/npcs/controllers/PartyController.java +++ b/src/main/java/noppes/npcs/controllers/PartyController.java @@ -33,7 +33,7 @@ import static kamkeel.npcs.network.packets.request.party.PartyInvitePacket.sendI public class PartyController implements IPartyHandler { private static PartyController Instance; - private final HashMap parties = new HashMap<>(); + private HashMap parties = new HashMap<>(); private PartyController() { } @@ -60,7 +60,7 @@ public class PartyController implements IPartyHandler { return null; EntityPlayer entityPlayer = (EntityPlayer) player.getMCEntity(); - PlayerData playerData = PlayerDataController.Instance.getPlayerData(entityPlayer); + PlayerData playerData = PlayerData.get(entityPlayer); if (playerData.partyUUID != null) return getParty(playerData.partyUUID); @@ -80,10 +80,11 @@ public class PartyController implements IPartyHandler { return; EntityPlayer entityPlayer = (EntityPlayer) player.getMCEntity(); - PlayerData playerData = PlayerDataController.Instance.getPlayerData(entityPlayer); + PlayerData playerData = PlayerData.get(entityPlayer); if (playerData.partyUUID != null) disbandParty(playerData.partyUUID); + return; } public Party getParty(UUID partyUUID) { @@ -94,12 +95,12 @@ public class PartyController implements IPartyHandler { Party party = this.parties.get(partyUUID); if (party != null) { PartyEvent.PartyDisbandEvent partyEvent = new PartyEvent.PartyDisbandEvent(party, party.getQuest()); - EventHooks.onPartyDisband(partyEvent); + EventHooks.onPartyDisband(party, partyEvent); for (UUID uuid : party.getPlayerUUIDs()) { EntityPlayer player = NoppesUtilServer.getPlayer(uuid); PlayerData playerData; if (player != null) { - playerData = PlayerDataController.Instance.getPlayerData(player); + playerData = PlayerData.get(player); } else { playerData = PlayerDataController.Instance.getPlayerDataCache(uuid.toString()); } @@ -171,7 +172,7 @@ public class PartyController implements IPartyHandler { for (String name : party.getPlayerNames()) { EntityPlayer playerMP = NoppesUtilServer.getPlayerByName(name); if (playerMP != null) { - PlayerData playerData = PlayerDataController.Instance.getPlayerData(playerMP); + PlayerData playerData = PlayerData.get(playerMP); if (playerData != null) { PartyDataPacket.sendPartyData((EntityPlayerMP) playerMP, compound); } @@ -202,7 +203,7 @@ public class PartyController implements IPartyHandler { for (String name : party.getPlayerNames()) { EntityPlayer playerMP = NoppesUtilServer.getPlayerByName(name); if (playerMP != null) { - PlayerData playerData = PlayerDataController.Instance.getPlayerData(playerMP); + PlayerData playerData = PlayerData.get(playerMP); if (playerData != null) { PartyDataPacket.sendPartyData((EntityPlayerMP) playerMP, compound); } @@ -250,7 +251,7 @@ public class PartyController implements IPartyHandler { for (String name : party.getPlayerNames()) { EntityPlayer playerMP = NoppesUtilServer.getPlayerByName(name); if (playerMP != null) { - PlayerData playerData = PlayerDataController.Instance.getPlayerData(playerMP); + PlayerData playerData = PlayerData.get(playerMP); if (playerData != null) { if (playerData.questData.getTrackedQuest() != null && questData.quest.getId() == playerData.questData.getTrackedQuest().getId()) { NoppesUtilPlayer.sendPartyTrackedQuestData((EntityPlayerMP) playerMP, party); diff --git a/src/main/java/noppes/npcs/controllers/PlayerDataController.java b/src/main/java/noppes/npcs/controllers/PlayerDataController.java index ca113e13a..e5649a379 100644 --- a/src/main/java/noppes/npcs/controllers/PlayerDataController.java +++ b/src/main/java/noppes/npcs/controllers/PlayerDataController.java @@ -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; @@ -266,7 +263,7 @@ public class PlayerDataController { public PlayerBankData getBankData(EntityPlayer player, int bankId) { Bank bank = BankController.getInstance().getBank(bankId); - PlayerBankData data = getPlayerData(player).bankData; + PlayerBankData data = PlayerData.get(player).bankData; if (!data.hasBank(bank.id)) { data.loadNew(bank.id); } @@ -278,7 +275,7 @@ public class PlayerDataController { List list = MinecraftServer.getServer().getConfigurationManager().playerEntityList; for (Object o : list) { if (o instanceof EntityPlayer) { - playerDataList.add(this.getPlayerData((EntityPlayer) o)); + playerDataList.add(PlayerData.get((EntityPlayer) o)); } } return playerDataList; @@ -295,6 +292,7 @@ public class PlayerDataController { if (data == null) { player.registerExtendedProperties("CustomNpcsData", data = new PlayerData()); data.player = player; + data.scriptData = new PlayerDataScript(player); data.load(); } @@ -347,7 +345,7 @@ public class PlayerDataController { } } } else - data = PlayerDataController.Instance.getPlayerData(player); + data = PlayerData.get(player); return data; } @@ -370,7 +368,7 @@ public class PlayerDataController { list.add(data); } else { for (EntityPlayer player : players) { - list.add(PlayerDataController.Instance.getPlayerData(player)); + list.add(PlayerData.get(player)); } } @@ -383,7 +381,7 @@ public class PlayerDataController { } public boolean hasMail(EntityPlayer player) { - return getPlayerData(player).mailData.hasMail(); + return PlayerData.get(player).mailData.hasMail(); } public void readNBT(NBTTagCompound compound) { diff --git a/src/main/java/noppes/npcs/controllers/QuestController.java b/src/main/java/noppes/npcs/controllers/QuestController.java index 292f875e2..5987b3a44 100644 --- a/src/main/java/noppes/npcs/controllers/QuestController.java +++ b/src/main/java/noppes/npcs/controllers/QuestController.java @@ -27,6 +27,7 @@ public class QuestController implements IQuestHandler { public HashMap sharedQuests = new HashMap<>(); public static QuestController Instance = new QuestController(); + ; private int lastUsedCatID = 0; private int lastUsedQuestID = 0; @@ -256,6 +257,6 @@ public class QuestController implements IQuestHandler { } public IQuest get(int id) { - return this.quests.get(id); + return (IQuest) this.quests.get(id); } } diff --git a/src/main/java/noppes/npcs/controllers/ScriptContainer.java b/src/main/java/noppes/npcs/controllers/ScriptContainer.java index 4ff4e9a98..bb2ef4500 100644 --- a/src/main/java/noppes/npcs/controllers/ScriptContainer.java +++ b/src/main/java/noppes/npcs/controllers/ScriptContainer.java @@ -101,7 +101,7 @@ public class ScriptContainer { while (var1.hasNext()) { String loc = (String) var1.next(); - String code = ScriptController.Instance.scripts.get(loc); + String code = (String) ScriptController.Instance.scripts.get(loc); if (code != null && !code.isEmpty()) { this.fullscript = this.fullscript + code + "\n"; } @@ -141,7 +141,7 @@ public class ScriptContainer { if (!ConfigScript.ScriptingEnabled) return; - this.run(type.function, event); + this.run((String) type.function, (Object) event); } public void run(String type, Object event) { @@ -209,7 +209,7 @@ public class ScriptContainer { if (message != null && !message.isEmpty()) { long time = System.currentTimeMillis(); if (this.console.containsKey(time)) { - message = this.console.get(time) + "\n" + message; + message = (String) this.console.get(time) + "\n" + message; } this.console.put(time, message); diff --git a/src/main/java/noppes/npcs/controllers/ScriptController.java b/src/main/java/noppes/npcs/controllers/ScriptController.java index a77f83196..dae8cf00e 100644 --- a/src/main/java/noppes/npcs/controllers/ScriptController.java +++ b/src/main/java/noppes/npcs/controllers/ScriptController.java @@ -3,6 +3,7 @@ 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; import net.minecraft.nbt.NBTTagString; @@ -10,10 +11,13 @@ import net.minecraft.server.MinecraftServer; import net.minecraftforge.event.world.WorldEvent; import noppes.npcs.CustomNpcs; import noppes.npcs.LogWriter; +import noppes.npcs.api.entity.IPlayer; import noppes.npcs.config.ConfigScript; import noppes.npcs.controllers.data.ForgeDataScript; import noppes.npcs.controllers.data.GlobalNPCDataScript; +import noppes.npcs.controllers.data.PlayerData; import noppes.npcs.controllers.data.PlayerDataScript; +import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.scripted.ScriptWorld; import noppes.npcs.util.JsonException; import noppes.npcs.util.NBTJsonUtil; @@ -43,13 +47,13 @@ public class ScriptController { public NBTTagCompound compound = new NBTTagCompound(); public boolean shouldSave = false; - public PlayerDataScript playerScripts = new PlayerDataScript(null); + public PlayerDataScript playerScripts = new PlayerDataScript((EntityPlayer) null); public long lastPlayerUpdate = 0L; public ForgeDataScript forgeScripts = new ForgeDataScript(); public long lastForgeUpdate = 0L; - public GlobalNPCDataScript globalNpcScripts = new GlobalNPCDataScript(null); + public GlobalNPCDataScript globalNpcScripts = new GlobalNPCDataScript((EntityNPCInterface) null); public long lastGlobalNpcUpdate = 0L; public ScriptController() { @@ -146,6 +150,20 @@ public class ScriptController { } } + public PlayerDataScript getPlayerScripts(EntityPlayer player){ + if(ConfigScript.IndividualPlayerScripts) + return PlayerData.get(player).scriptData; + + return this.playerScripts; + } + + public PlayerDataScript getPlayerScripts(IPlayer player){ + if(ConfigScript.IndividualPlayerScripts) + return PlayerData.get((EntityPlayer) player.getMCEntity()).scriptData; + + return this.playerScripts; + } + public boolean loadGlobalNPCScripts() { this.globalNpcScripts.clear(); File file = this.npcScriptsFile(); diff --git a/src/main/java/noppes/npcs/controllers/ServerCloneController.java b/src/main/java/noppes/npcs/controllers/ServerCloneController.java index f4276e4f7..95c932943 100644 --- a/src/main/java/noppes/npcs/controllers/ServerCloneController.java +++ b/src/main/java/noppes/npcs/controllers/ServerCloneController.java @@ -279,9 +279,9 @@ public class ServerCloneController implements ICloneHandler { } public IEntity spawn(double x, double y, double z, int tab, String name, IWorld world, boolean ignoreProtection) { - NBTTagCompound compound = this.getCloneData(null, name, tab); + NBTTagCompound compound = this.getCloneData((ICommandSender) null, name, tab); if (compound == null) { - throw new CustomNPCsException("Unknown clone tab:" + tab + " name:" + name); + throw new CustomNPCsException("Unknown clone tab:" + tab + " name:" + name, new Object[0]); } else { Entity entity; if (!ignoreProtection) { @@ -329,9 +329,9 @@ public class ServerCloneController implements ICloneHandler { } public IEntity get(int tab, String name, IWorld world) { - NBTTagCompound compound = this.getCloneData(null, name, tab); + NBTTagCompound compound = this.getCloneData((ICommandSender) null, name, tab); if (compound == null) { - throw new CustomNPCsException("Unknown clone tab:" + tab + " name:" + name); + throw new CustomNPCsException("Unknown clone tab:" + tab + " name:" + name, new Object[0]); } else { Instance.cleanTags(compound); Entity entity = EntityList.createEntityFromNBT(compound, world.getMCWorld()); @@ -340,7 +340,7 @@ public class ServerCloneController implements ICloneHandler { } public boolean has(int tab, String name) { - NBTTagCompound compound = this.getCloneData(null, name, tab); + NBTTagCompound compound = this.getCloneData((ICommandSender) null, name, tab); return compound != null; } @@ -348,7 +348,7 @@ public class ServerCloneController implements ICloneHandler { public void set(int tab, String name, IEntity entity) { NBTTagCompound compound = new NBTTagCompound(); if (!entity.getMCEntity().writeMountToNBT(compound)) - throw new CustomNPCsException("Cannot save dead entities"); + throw new CustomNPCsException("Cannot save dead entities", new Object[0]); this.cleanTags(compound); this.saveClone(tab, name, compound); diff --git a/src/main/java/noppes/npcs/controllers/TagController.java b/src/main/java/noppes/npcs/controllers/TagController.java index fa5a23ea0..14fd6b066 100644 --- a/src/main/java/noppes/npcs/controllers/TagController.java +++ b/src/main/java/noppes/npcs/controllers/TagController.java @@ -170,7 +170,7 @@ public class TagController implements ITagHandler { public ITag delete(int id) { if (id >= 0 && this.tags.size() > 1) { - Tag tag = this.tags.remove(id); + Tag tag = (Tag) this.tags.remove(id); saveTags(); if (tag == null) { return null; diff --git a/src/main/java/noppes/npcs/controllers/data/AnimationData.java b/src/main/java/noppes/npcs/controllers/data/AnimationData.java index 681a403b1..43fe42016 100644 --- a/src/main/java/noppes/npcs/controllers/data/AnimationData.java +++ b/src/main/java/noppes/npcs/controllers/data/AnimationData.java @@ -17,7 +17,6 @@ import noppes.npcs.api.entity.IEntity; import noppes.npcs.api.handler.data.IAnimation; import noppes.npcs.api.handler.data.IAnimationData; import noppes.npcs.constants.EnumAnimationPart; -import noppes.npcs.controllers.PlayerDataController; import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.scripted.NpcAPI; @@ -117,7 +116,7 @@ public class AnimationData implements IAnimationData { entities.removeIf(player -> Arrays.stream(excludedPlayers).anyMatch(exp -> player == exp)); for (EntityPlayer player : entities) { - AnimationData animationData = PlayerDataController.Instance.getPlayerData(player).animationData; + AnimationData animationData = PlayerData.get(player).animationData; NBTTagCompound animationNBT = this.animation != null ? this.animation.writeToNBT() : null; animationData.viewAnimation(this.animation, this, animationNBT); } diff --git a/src/main/java/noppes/npcs/controllers/data/Availability.java b/src/main/java/noppes/npcs/controllers/data/Availability.java index cfc577d19..ffc59bd3f 100644 --- a/src/main/java/noppes/npcs/controllers/data/Availability.java +++ b/src/main/java/noppes/npcs/controllers/data/Availability.java @@ -205,7 +205,10 @@ public class Availability implements ICompatibilty, IAvailability { if (!factionAvailable(faction2Id, faction2Stance, faction2Available, player)) return false; - return player.experienceLevel >= minPlayerLevel; + if (player.experienceLevel < minPlayerLevel) + return false; + + return true; } @SideOnly(Side.CLIENT) @@ -286,7 +289,11 @@ public class Availability implements ICompatibilty, IAvailability { if (available == EnumAvailabilityFactionType.Is && stance == current) { return true; } - return available == EnumAvailabilityFactionType.IsNot && stance != current; + if (available == EnumAvailabilityFactionType.IsNot && stance != current) { + return true; + } + + return false; } public boolean dialogAvailable(int id, EnumAvailabilityDialog en, EntityPlayer player) { @@ -300,7 +307,9 @@ public class Availability implements ICompatibilty, IAvailability { boolean hasRead = data.dialogData.dialogsRead.contains(id); if (hasRead && en == EnumAvailabilityDialog.After) return true; - else return !hasRead && en == EnumAvailabilityDialog.Before; + else if (!hasRead && en == EnumAvailabilityDialog.Before) + return true; + return false; } public boolean questAvailable(int id, EnumAvailabilityQuest en, EntityPlayer player) { @@ -356,7 +365,7 @@ public class Availability implements ICompatibilty, IAvailability { public int getDialog(int i) { if (i < 0 || i > 3) { - throw new CustomNPCsException(i + " isnt between 0 and 3"); + throw new CustomNPCsException(i + " isnt between 0 and 3", new Object[0]); } else if (i == 0) { return this.dialogId; } else if (i == 1) { @@ -368,7 +377,7 @@ public class Availability implements ICompatibilty, IAvailability { public void setDialog(int i, int id, int type) { if (i < 0 || i > 3) { - throw new CustomNPCsException(i + " isnt between 0 and 3"); + throw new CustomNPCsException(i + " isnt between 0 and 3", new Object[0]); } else { EnumAvailabilityDialog e = EnumAvailabilityDialog.values()[MathHelper.clamp_int(type, 0, 2)]; if (i == 0) { @@ -390,7 +399,7 @@ public class Availability implements ICompatibilty, IAvailability { public void removeDialog(int i) { if (i < 0 || i > 3) { - throw new CustomNPCsException(i + " isnt between 0 and 3"); + throw new CustomNPCsException(i + " isnt between 0 and 3", new Object[0]); } else { if (i == 0) { this.dialogId = -1; @@ -411,7 +420,7 @@ public class Availability implements ICompatibilty, IAvailability { public int getQuest(int i) { if (i < 0 || i > 3) { - throw new CustomNPCsException(i + " isnt between 0 and 3"); + throw new CustomNPCsException(i + " isnt between 0 and 3", new Object[0]); } else if (i == 0) { return this.questId; } else if (i == 1) { @@ -423,7 +432,7 @@ public class Availability implements ICompatibilty, IAvailability { public void setQuest(int i, int id, int type) { if (i < 0 || i > 3) { - throw new CustomNPCsException(i + " isnt between 0 and 3"); + throw new CustomNPCsException(i + " isnt between 0 and 3", new Object[0]); } else { EnumAvailabilityQuest e = EnumAvailabilityQuest.values()[MathHelper.clamp_int(type, 0, 5)]; if (i == 0) { @@ -445,7 +454,7 @@ public class Availability implements ICompatibilty, IAvailability { public void removeQuest(int i) { if (i < 0 || i > 3) { - throw new CustomNPCsException(i + " isnt between 0 and 3"); + throw new CustomNPCsException(i + " isnt between 0 and 3", new Object[0]); } else { if (i == 0) { this.questId = -1; @@ -466,7 +475,7 @@ public class Availability implements ICompatibilty, IAvailability { public void setFaction(int i, int id, int type, int stance) { if (i < 0 || i > 1) { - throw new CustomNPCsException(i + " isnt between 0 and 1"); + throw new CustomNPCsException(i + " isnt between 0 and 1", new Object[0]); } else { EnumAvailabilityFactionType e = EnumAvailabilityFactionType.values()[MathHelper.clamp_int(type, 0, 2)]; EnumAvailabilityFaction ee = EnumAvailabilityFaction.values()[MathHelper.clamp_int(stance, 0, 2)]; @@ -485,7 +494,7 @@ public class Availability implements ICompatibilty, IAvailability { public void removeFaction(int i) { if (i < 0 || i > 1) { - throw new CustomNPCsException(i + " isnt between 0 and 1"); + throw new CustomNPCsException(i + " isnt between 0 and 1", new Object[0]); } else { if (i == 0) { this.factionId = -1; diff --git a/src/main/java/noppes/npcs/controllers/data/CustomEffect.java b/src/main/java/noppes/npcs/controllers/data/CustomEffect.java index 6c9eb45e8..911ac5e11 100644 --- a/src/main/java/noppes/npcs/controllers/data/CustomEffect.java +++ b/src/main/java/noppes/npcs/controllers/data/CustomEffect.java @@ -3,11 +3,12 @@ package noppes.npcs.controllers.data; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.util.Constants; +import noppes.npcs.EventHooks; import noppes.npcs.NoppesUtilServer; import noppes.npcs.api.entity.IPlayer; import noppes.npcs.api.handler.data.ICustomEffect; import noppes.npcs.controllers.CustomEffectController; -import noppes.npcs.scripted.event.PlayerEvent; +import noppes.npcs.scripted.event.player.PlayerEvent; import java.util.function.Consumer; @@ -181,48 +182,62 @@ public class CustomEffect implements ICustomEffect { public void onAdded(EntityPlayer player, PlayerEffect playerEffect) { IPlayer iPlayer = NoppesUtilServer.getIPlayer(player); + if(playerEffect.index == 0){ + PlayerEvent.EffectEvent.Added event = new PlayerEvent.EffectEvent.Added(iPlayer, playerEffect); - PlayerEvent.EffectEvent.Added event = new PlayerEvent.EffectEvent.Added(iPlayer, playerEffect); - if (onAddedConsumer != null) onAddedConsumer.accept(event); - EffectScript script = getScriptHandler(); - if (script == null) { - return; + if (onAddedConsumer != null) + onAddedConsumer.accept(event); + + EffectScript script = getScriptHandler(); + if (script == null) { + return; + } + + script.callScript(EffectScript.ScriptType.OnEffectAdd, event); } - script.callScript(EffectScript.ScriptType.OnAdd, event); + EventHooks.onEffectAdded(iPlayer, playerEffect); } public void onTick(EntityPlayer player, PlayerEffect playerEffect) { IPlayer iPlayer = NoppesUtilServer.getIPlayer(player); - PlayerEvent.EffectEvent.Ticked event = new PlayerEvent.EffectEvent.Ticked(iPlayer, playerEffect); + if(playerEffect.index == 0){ + PlayerEvent.EffectEvent.Ticked event = new PlayerEvent.EffectEvent.Ticked(iPlayer, playerEffect); - if (onTickConsumer != null) { - onTickConsumer.accept(event); + if (onTickConsumer != null) { + onTickConsumer.accept(event); + } + + EffectScript script = getScriptHandler(); + if (script == null) { + return; + } + + script.callScript(EffectScript.ScriptType.OnEffectTick, event); } - EffectScript script = getScriptHandler(); - if (script == null) { - return; - } - - script.callScript(EffectScript.ScriptType.OnTick, event); + EventHooks.onEffectTick(iPlayer, playerEffect); } public void onRemoved(EntityPlayer player, PlayerEffect playerEffect, PlayerEvent.EffectEvent.ExpirationType type) { IPlayer iPlayer = NoppesUtilServer.getIPlayer(player); - PlayerEvent.EffectEvent.Removed event = new PlayerEvent.EffectEvent.Removed(iPlayer, playerEffect, type); + if(playerEffect.index == 0){ + PlayerEvent.EffectEvent.Removed event = new PlayerEvent.EffectEvent.Removed(iPlayer, playerEffect, type); - if (onRemovedConsumer != null) { - onRemovedConsumer.accept(event); + if (onRemovedConsumer != null) { + onRemovedConsumer.accept(event); + } + + EffectScript script = getScriptHandler(); + if (script == null) { + return; + } + + script.callScript(EffectScript.ScriptType.OnEffectRemove, event); } - EffectScript script = getScriptHandler(); - if (script == null) { - return; - } - - script.callScript(EffectScript.ScriptType.OnRemove, event); + EventHooks.onEffectRemove(iPlayer, playerEffect, type); } public NBTTagCompound writeToNBT(boolean saveScripts) { diff --git a/src/main/java/noppes/npcs/controllers/data/DataScript.java b/src/main/java/noppes/npcs/controllers/data/DataScript.java index 8fb8d04b9..f27b83990 100644 --- a/src/main/java/noppes/npcs/controllers/data/DataScript.java +++ b/src/main/java/noppes/npcs/controllers/data/DataScript.java @@ -4,7 +4,6 @@ import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.eventhandler.Event; import cpw.mods.fml.relauncher.Side; import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityCreature; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.world.World; @@ -39,7 +38,7 @@ public class DataScript implements INpcScriptHandler { private final static RoleType roles = new RoleType(); public String scriptLanguage = "ECMAScript"; - private final EntityNPCInterface npc; + private EntityNPCInterface npc; public boolean enabled = false; public ICustomNpc dummyNpc; @@ -60,7 +59,7 @@ public class DataScript implements INpcScriptHandler { dummyNpc = npc.wrappedNPC; if (npc.worldObj instanceof WorldServer) - dummyWorld = NpcAPI.Instance().getIWorld(npc.worldObj);//new ScriptWorld((WorldServer) npc.worldObj); + dummyWorld = NpcAPI.Instance().getIWorld((WorldServer) npc.worldObj);//new ScriptWorld((WorldServer) npc.worldObj); } public void readFromNBT(NBTTagCompound compound) { @@ -167,9 +166,9 @@ public class DataScript implements INpcScriptHandler { } if (ConfigDebug.ScriptLogging && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) { if (obs.length > 1 && obs[1] == null) { - LogWriter.postScriptLog(EntityCreature.field_110179_h, type, String.format("[%s] NPC %s (%s, %s, %s)", type.function.toUpperCase(), npc.display.name, (int) npc.posX, (int) npc.posY, (int) npc.posZ)); + LogWriter.postScriptLog(npc.field_110179_h, type, String.format("[%s] NPC %s (%s, %s, %s)", ((String) type.function).toUpperCase(), npc.display.name, (int) npc.posX, (int) npc.posY, (int) npc.posZ)); } else { - LogWriter.postScriptLog(EntityCreature.field_110179_h, type, String.format("[%s] NPC %s (%s, %s, %s) | Objects: %s", type.function.toUpperCase(), npc.display.name, (int) npc.posX, (int) npc.posY, (int) npc.posZ, Arrays.toString(obs))); + LogWriter.postScriptLog(npc.field_110179_h, type, String.format("[%s] NPC %s (%s, %s, %s) | Objects: %s", ((String) type.function).toUpperCase(), npc.display.name, (int) npc.posX, (int) npc.posY, (int) npc.posZ, Arrays.toString(obs))); } } return callScript(script, event); diff --git a/src/main/java/noppes/npcs/controllers/data/DataTransform.java b/src/main/java/noppes/npcs/controllers/data/DataTransform.java index 2a22e862e..16b2cc766 100644 --- a/src/main/java/noppes/npcs/controllers/data/DataTransform.java +++ b/src/main/java/noppes/npcs/controllers/data/DataTransform.java @@ -21,7 +21,7 @@ public class DataTransform { public boolean hasDisplay, hasAi, hasAdvanced, hasInv, hasStats, hasRole, hasJob, isActive; - private final EntityNPCInterface npc; + private EntityNPCInterface npc; public boolean editingModus = false; diff --git a/src/main/java/noppes/npcs/controllers/data/Dialog.java b/src/main/java/noppes/npcs/controllers/data/Dialog.java index d7ce865f7..884822098 100644 --- a/src/main/java/noppes/npcs/controllers/data/Dialog.java +++ b/src/main/java/noppes/npcs/controllers/data/Dialog.java @@ -23,6 +23,7 @@ public class Dialog implements ICompatibilty, IDialog { public String text = ""; public int quest = -1; public DialogCategory category; + public DialogColorData colorData = new DialogColorData(); public HashMap options = new HashMap(); public Availability availability = new Availability(); public FactionOptions factionOptions = new FactionOptions(); @@ -167,6 +168,7 @@ public class Dialog implements ICompatibilty, IDialog { availability.readFromNBT(compound); factionOptions.readFromNBT(compound); + colorData.readFromNBT(compound); } @@ -202,6 +204,7 @@ public class Dialog implements ICompatibilty, IDialog { availability.writeToNBT(compound); factionOptions.writeToNBT(compound); + colorData.writeToNBT(compound); compound.setInteger("ModRev", version); compound.setInteger("Color", color); @@ -284,6 +287,7 @@ public class Dialog implements ICompatibilty, IDialog { dialog.npcOffsetX = npcOffsetX; dialog.npcOffsetY = npcOffsetY; dialog.dialogImages = dialogImages; + dialog.colorData = colorData; for (int slot : options.keySet()) { DialogOption option = options.get(slot); @@ -319,7 +323,7 @@ public class Dialog implements ICompatibilty, IDialog { public IDialogOption getOption(int slot) { IDialogOption option = (IDialogOption) this.options.get(slot); if (option == null) { - throw new CustomNPCsException("There is no DialogOption for slot: " + slot); + throw new CustomNPCsException("There is no DialogOption for slot: " + slot, new Object[0]); } else { return option; } @@ -354,7 +358,7 @@ public class Dialog implements ICompatibilty, IDialog { this.quest = -1; } else { if (quest.getId() < 0) { - throw new CustomNPCsException("Quest id is lower than 0"); + throw new CustomNPCsException("Quest id is lower than 0", new Object[0]); } this.quest = quest.getId(); @@ -363,7 +367,7 @@ public class Dialog implements ICompatibilty, IDialog { } public Quest getQuest() { - return QuestController.Instance == null ? null : QuestController.Instance.quests.get(this.quest); + return QuestController.Instance == null ? null : (Quest) QuestController.Instance.quests.get(this.quest); } public String getCommand() { diff --git a/src/main/java/noppes/npcs/controllers/data/DialogColorData.java b/src/main/java/noppes/npcs/controllers/data/DialogColorData.java new file mode 100644 index 000000000..86c45e037 --- /dev/null +++ b/src/main/java/noppes/npcs/controllers/data/DialogColorData.java @@ -0,0 +1,94 @@ +package noppes.npcs.controllers.data; + +import net.minecraft.nbt.NBTTagCompound; + +public class DialogColorData { + private boolean enableColorSettings = false; + private int lineColor1 = 0xff8d3800; + private int lineColor2 = 0xfffea53b; + private int lineColor3 = 0xff8d3800; + private int slotColor = 0xfff96605; + private int buttonAcceptColor = 0xfff96605; + private int buttonRejectColor = 0xfff96605; + + public NBTTagCompound writeToNBT(NBTTagCompound compound) { + compound.setBoolean("ColorSettings", enableColorSettings); + if(enableColorSettings){ + compound.setInteger("LineColor1", lineColor1); + compound.setInteger("LineColor2", lineColor2); + compound.setInteger("LineColor3", lineColor3); + compound.setInteger("SlotColor", slotColor); + compound.setInteger("ButtonAcceptColor", buttonAcceptColor); + compound.setInteger("ButtonRejectColor", buttonRejectColor); + } + return compound; + } + + public void readFromNBT(NBTTagCompound compound) { + this.enableColorSettings = compound.getBoolean("ColorSettings"); + if(enableColorSettings){ + lineColor1 =compound.getInteger("LineColor1"); + lineColor2 =compound.getInteger("LineColor2"); + lineColor3 =compound.getInteger("LineColor3"); + slotColor =compound.getInteger("SlotColor"); + buttonAcceptColor =compound.getInteger("ButtonAcceptColor"); + buttonRejectColor =compound.getInteger("ButtonRejectColor"); + } + } + + public boolean getEnableColorSettings() { + return enableColorSettings; + } + + public void setEnableColorSettings(boolean enableColorSettings) { + this.enableColorSettings = enableColorSettings; + } + + public int getLineColor1() { + return lineColor1; + } + + public void setLineColor1(int lineColour1) { + this.lineColor1 = lineColour1; + } + + public int getLineColor2() { + return lineColor2; + } + + public void setLineColor2(int lineColour2) { + this.lineColor2 = lineColour2; + } + + public int getLineColor3() { + return lineColor3; + } + + public void setLineColor3(int lineColour3) { + this.lineColor3 = lineColour3; + } + + public int getSlotColor() { + return slotColor; + } + + public void setSlotColor(int slotColour) { + this.slotColor = slotColour; + } + + public int getButtonAcceptColor() { + return buttonAcceptColor; + } + + public void setButtonAcceptColor(int buttonAcceptColour) { + this.buttonAcceptColor = buttonAcceptColour; + } + + public int getButtonRejectColor() { + return buttonRejectColor; + } + + public void setButtonRejectColor(int buttonRejectColour) { + this.buttonRejectColor = buttonRejectColour; + } +} diff --git a/src/main/java/noppes/npcs/controllers/data/EffectScript.java b/src/main/java/noppes/npcs/controllers/data/EffectScript.java index c39239935..a6e66bec8 100644 --- a/src/main/java/noppes/npcs/controllers/data/EffectScript.java +++ b/src/main/java/noppes/npcs/controllers/data/EffectScript.java @@ -10,7 +10,7 @@ import noppes.npcs.config.ConfigScript; import noppes.npcs.constants.EnumScriptType; import noppes.npcs.controllers.ScriptContainer; import noppes.npcs.controllers.ScriptController; -import noppes.npcs.scripted.event.PlayerEvent; +import noppes.npcs.scripted.event.player.PlayerEvent; import java.io.IOException; import java.util.*; @@ -121,7 +121,7 @@ public class EffectScript implements INpcScriptHandler { while (var5.hasNext()) { Map.Entry longStringEntry = (Map.Entry) var5.next(); - map.put(longStringEntry.getKey(), " tab " + tab + ":\n" + longStringEntry.getValue()); + map.put(longStringEntry.getKey(), " tab " + tab + ":\n" + (String) longStringEntry.getValue()); } } @@ -165,9 +165,9 @@ public class EffectScript implements INpcScriptHandler { } public enum ScriptType { - OnAdd("onAdded"), - OnTick("onTick"), - OnRemove("onRemove"); + OnEffectAdd("onEffectAdd"), + OnEffectTick("onEffectTick"), + OnEffectRemove("onEffectRemove"); public final String function; diff --git a/src/main/java/noppes/npcs/controllers/data/Faction.java b/src/main/java/noppes/npcs/controllers/data/Faction.java index d8d38ca1e..1a9b83aef 100644 --- a/src/main/java/noppes/npcs/controllers/data/Faction.java +++ b/src/main/java/noppes/npcs/controllers/data/Faction.java @@ -8,7 +8,6 @@ import noppes.npcs.api.entity.IPlayer; import noppes.npcs.api.handler.IPlayerFactionData; import noppes.npcs.api.handler.data.IFaction; import noppes.npcs.controllers.FactionController; -import noppes.npcs.controllers.PlayerDataController; import noppes.npcs.entity.EntityNPCInterface; import java.util.ArrayList; @@ -80,17 +79,17 @@ public class Faction implements IFaction { } public boolean isFriendlyToPlayer(EntityPlayer player) { - PlayerFactionData data = PlayerDataController.Instance.getPlayerData(player).factionData; + PlayerFactionData data = PlayerData.get(player).factionData; return data.getFactionPoints(id) >= friendlyPoints; } public boolean isAggressiveToPlayer(EntityPlayer player) { - PlayerFactionData data = PlayerDataController.Instance.getPlayerData(player).factionData; + PlayerFactionData data = PlayerData.get(player).factionData; return data.getFactionPoints(id) < neutralPoints; } public boolean isNeutralToPlayer(EntityPlayer player) { - PlayerFactionData data = PlayerDataController.Instance.getPlayerData(player).factionData; + PlayerFactionData data = PlayerData.get(player).factionData; int points = data.getFactionPoints(id); return points >= neutralPoints && points < friendlyPoints; } diff --git a/src/main/java/noppes/npcs/controllers/data/FactionOptions.java b/src/main/java/noppes/npcs/controllers/data/FactionOptions.java index e80537f07..6f41b7f7b 100644 --- a/src/main/java/noppes/npcs/controllers/data/FactionOptions.java +++ b/src/main/java/noppes/npcs/controllers/data/FactionOptions.java @@ -4,7 +4,6 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.ChatComponentTranslation; import noppes.npcs.controllers.FactionController; -import noppes.npcs.controllers.PlayerDataController; public class FactionOptions { @@ -48,7 +47,7 @@ public class FactionOptions { if (factionId < 0 && faction2Id < 0) return; - PlayerFactionData data = PlayerDataController.Instance.getPlayerData(player).factionData; + PlayerFactionData data = PlayerData.get(player).factionData; if (factionId >= 0 && factionPoints > 0) addPoints(player, data, factionId, decreaseFactionPoints, factionPoints); if (faction2Id >= 0 && faction2Points > 0) diff --git a/src/main/java/noppes/npcs/controllers/data/FramePart.java b/src/main/java/noppes/npcs/controllers/data/FramePart.java index 15490dd7e..82f573591 100644 --- a/src/main/java/noppes/npcs/controllers/data/FramePart.java +++ b/src/main/java/noppes/npcs/controllers/data/FramePart.java @@ -41,7 +41,7 @@ public class FramePart implements IFramePart { } public int getPartId() { - return part.id; + return part.ordinal(); } public void setPart(EnumAnimationPart part) { @@ -58,7 +58,7 @@ public class FramePart implements IFramePart { public IFramePart setPart(int partId) { for (EnumAnimationPart enumPart : EnumAnimationPart.values()) { - if (enumPart.id == partId) { + if (enumPart.ordinal() == partId) { this.setPart(enumPart); break; } diff --git a/src/main/java/noppes/npcs/controllers/data/GlobalNPCDataScript.java b/src/main/java/noppes/npcs/controllers/data/GlobalNPCDataScript.java index 546adcd7b..c1a468279 100644 --- a/src/main/java/noppes/npcs/controllers/data/GlobalNPCDataScript.java +++ b/src/main/java/noppes/npcs/controllers/data/GlobalNPCDataScript.java @@ -160,14 +160,14 @@ public class GlobalNPCDataScript implements INpcScriptHandler { private final GlobalNPCDataScript.ToStringHelper.ValueHolder holderHead; private GlobalNPCDataScript.ToStringHelper.ValueHolder holderTail; private boolean omitNullValues; - private final boolean omitEmptyValues; + private boolean omitEmptyValues; private ToStringHelper(String className) { this.holderHead = new GlobalNPCDataScript.ToStringHelper.ValueHolder(); this.holderTail = this.holderHead; this.omitNullValues = false; this.omitEmptyValues = false; - this.className = Preconditions.checkNotNull(className); + this.className = (String) Preconditions.checkNotNull(className); } public GlobalNPCDataScript.ToStringHelper omitNullValues() { @@ -302,7 +302,7 @@ public class GlobalNPCDataScript implements INpcScriptHandler { private GlobalNPCDataScript.ToStringHelper addHolder(String name, @CheckForNull Object value) { GlobalNPCDataScript.ToStringHelper.ValueHolder valueHolder = this.addHolder(); valueHolder.value = value; - valueHolder.name = Preconditions.checkNotNull(name); + valueHolder.name = (String) Preconditions.checkNotNull(name); return this; } @@ -321,7 +321,7 @@ public class GlobalNPCDataScript implements INpcScriptHandler { private GlobalNPCDataScript.ToStringHelper addUnconditionalHolder(String name, Object value) { GlobalNPCDataScript.ToStringHelper.UnconditionalValueHolder valueHolder = this.addUnconditionalHolder(); valueHolder.value = value; - valueHolder.name = Preconditions.checkNotNull(name); + valueHolder.name = (String) Preconditions.checkNotNull(name); return this; } diff --git a/src/main/java/noppes/npcs/controllers/data/LinkedItemScript.java b/src/main/java/noppes/npcs/controllers/data/LinkedItemScript.java index 25c70b39c..64c3dd7ff 100644 --- a/src/main/java/noppes/npcs/controllers/data/LinkedItemScript.java +++ b/src/main/java/noppes/npcs/controllers/data/LinkedItemScript.java @@ -115,7 +115,7 @@ public class LinkedItemScript implements INpcScriptHandler { while (var5.hasNext()) { Map.Entry longStringEntry = (Map.Entry) var5.next(); - map.put(longStringEntry.getKey(), " tab " + tab + ":\n" + longStringEntry.getValue()); + map.put(longStringEntry.getKey(), " tab " + tab + ":\n" + (String) longStringEntry.getValue()); } } diff --git a/src/main/java/noppes/npcs/controllers/data/Party.java b/src/main/java/noppes/npcs/controllers/data/Party.java index fc347d8ee..df826bb9e 100644 --- a/src/main/java/noppes/npcs/controllers/data/Party.java +++ b/src/main/java/noppes/npcs/controllers/data/Party.java @@ -118,7 +118,7 @@ public class Party implements IParty { return false; } - PlayerData playerData = PlayerDataController.Instance.getPlayerData(player); + PlayerData playerData = PlayerData.get(player); playerData.partyUUID = this.partyUUID; partyMembers.put(player.getUniqueID(), player.getCommandSenderName()); @@ -140,7 +140,7 @@ public class Party implements IParty { } } - PlayerData playerData = PlayerDataController.Instance.getPlayerData(player); + PlayerData playerData = PlayerData.get(player); playerData.partyUUID = null; return true; @@ -314,7 +314,7 @@ public class Party implements IParty { } private boolean isValidLeaderQuest(EntityPlayer leader, int questID) { - IPlayerQuestData questData = PlayerDataController.Instance.getPlayerData(leader).getQuestData(); + IPlayerQuestData questData = PlayerData.get(leader).getQuestData(); return questData != null && questData.hasActiveQuest(questID); } @@ -323,7 +323,7 @@ public class Party implements IParty { for (UUID playerUUID : partyMembers.keySet()) { EntityPlayer player = PlayerDataController.getPlayerFromUUID(playerUUID); if (player != null) { - PlayerData playerData = PlayerDataController.Instance.getPlayerData(player); + PlayerData playerData = PlayerData.get(player); if (playerData != null) { IPlayerQuestData questData = playerData.getQuestData(); if (questData != null) { diff --git a/src/main/java/noppes/npcs/controllers/data/PlayerData.java b/src/main/java/noppes/npcs/controllers/data/PlayerData.java index f8eda5914..bd97b85d0 100644 --- a/src/main/java/noppes/npcs/controllers/data/PlayerData.java +++ b/src/main/java/noppes/npcs/controllers/data/PlayerData.java @@ -29,6 +29,7 @@ import noppes.npcs.entity.data.DataTimers; import noppes.npcs.roles.RoleCompanion; import noppes.npcs.scripted.NpcAPI; import noppes.npcs.scripted.ScreenSize; +import noppes.npcs.scripted.ScriptedActionManager; import noppes.npcs.util.CustomNPCsThreader; import noppes.npcs.util.NBTJsonUtil; @@ -51,6 +52,9 @@ public class PlayerData implements IExtendedEntityProperties, IPlayerData { public DataSkinOverlays skinOverlays = new DataSkinOverlays(this); public MagicData magicData = new MagicData(); + public ScriptedActionManager actionManager = new ScriptedActionManager(); + public PlayerDataScript scriptData; + public EntityNPCInterface editingNpc; public NBTTagCompound cloned; @@ -94,6 +98,7 @@ public class PlayerData implements IExtendedEntityProperties, IPlayerData { public void onLogout() { this.partyInvites.clear(); + this.actionManager.clear(); } @Override diff --git a/src/main/java/noppes/npcs/controllers/data/PlayerDataScript.java b/src/main/java/noppes/npcs/controllers/data/PlayerDataScript.java index b3b39b459..17aaf809b 100644 --- a/src/main/java/noppes/npcs/controllers/data/PlayerDataScript.java +++ b/src/main/java/noppes/npcs/controllers/data/PlayerDataScript.java @@ -13,6 +13,7 @@ import noppes.npcs.constants.EnumScriptType; import noppes.npcs.controllers.ScriptContainer; import noppes.npcs.controllers.ScriptController; import noppes.npcs.scripted.NpcAPI; +import noppes.npcs.scripted.event.player.PlayerEvent; import javax.annotation.CheckForNull; import java.lang.reflect.Array; @@ -25,8 +26,13 @@ public class PlayerDataScript implements INpcScriptHandler { private EntityPlayer player; private IPlayer playerAPI; private long lastPlayerUpdate = 0L; - public long lastInited = -1L; - public boolean enabled = false; + + public long lastInited = -1; + public boolean hadInteract = true; + private boolean enabled = false; + + private static Map console = new TreeMap(); + private static List errored = new ArrayList(); public PlayerDataScript(EntityPlayer player) { if (player != null) { @@ -35,7 +41,9 @@ public class PlayerDataScript implements INpcScriptHandler { } public void clear() { - this.scripts = new ArrayList(); + console = new TreeMap(); + errored = new ArrayList(); + scripts = new ArrayList(); } public void readFromNBT(NBTTagCompound compound) { @@ -53,6 +61,7 @@ public class PlayerDataScript implements INpcScriptHandler { } } this.enabled = compound.getBoolean("ScriptEnabled"); + console = NBTTags.GetLongStringMap(compound.getTagList("ScriptConsole", 10)); } public NBTTagCompound writeToNBT(NBTTagCompound compound) { @@ -62,6 +71,7 @@ public class PlayerDataScript implements INpcScriptHandler { } compound.setString("ScriptLanguage", this.scriptLanguage); compound.setBoolean("ScriptEnabled", this.enabled); + compound.setTag("ScriptConsole", NBTTags.NBTLongStringMap(console)); return compound; } @@ -75,7 +85,42 @@ public class PlayerDataScript implements INpcScriptHandler { @Override public void callScript(String hookName, Event event) { - if (this.isEnabled()) { + if(!isEnabled()) + return; + + if(ConfigScript.IndividualPlayerScripts){ + if(ScriptController.Instance.lastLoaded > lastInited || ScriptController.Instance.lastPlayerUpdate > lastPlayerUpdate){ + lastInited = ScriptController.Instance.lastLoaded; + errored.clear(); + if(player != null) { + scripts.clear(); + for(ScriptContainer script : ScriptController.Instance.playerScripts.scripts){ + ScriptContainer s = new ScriptContainer(this); + s.readFromNBT(script.writeToNBT(new NBTTagCompound())); + scripts.add(s); + } + } + lastPlayerUpdate = ScriptController.Instance.lastPlayerUpdate; + if (!Objects.equals(hookName, EnumScriptType.INIT.function) && event instanceof PlayerEvent) { + PlayerEvent playerEvent = (PlayerEvent) event; + EventHooks.onPlayerInit(this, playerEvent.player); + } + } + for(int i = 0; i < scripts.size(); i++){ + ScriptContainer script = scripts.get(i); + if(errored.contains(i)) + continue; + script.run(hookName, event); + if(script.errored){ + errored.add(i); + } + for(Entry entry : script.console.entrySet()){ + if(!console.containsKey(entry.getKey())) + console.put(entry.getKey(), " tab " + (i + 1) + ":\n" + entry.getValue()); + } + script.console.clear(); + } + } else { if (ScriptController.Instance.lastLoaded > this.lastInited || ScriptController.Instance.lastPlayerUpdate > this.lastPlayerUpdate) { this.lastInited = ScriptController.Instance.lastLoaded; this.lastPlayerUpdate = ScriptController.Instance.lastPlayerUpdate; @@ -84,8 +129,8 @@ public class PlayerDataScript implements INpcScriptHandler { scriptContainer.errored = false; } - if (!Objects.equals(hookName, EnumScriptType.INIT.function)) { - noppes.npcs.scripted.event.PlayerEvent playerEvent = (noppes.npcs.scripted.event.PlayerEvent) event; + if (!Objects.equals(hookName, EnumScriptType.INIT.function) && event instanceof PlayerEvent) { + PlayerEvent playerEvent = (PlayerEvent) event; EventHooks.onPlayerInit(this, playerEvent.player); } } @@ -145,6 +190,9 @@ public class PlayerDataScript implements INpcScriptHandler { } public Map getConsoleText() { + if(ConfigScript.IndividualPlayerScripts) + return console; + TreeMap map = new TreeMap<>(); int tab = 0; for (ScriptContainer script : this.getScripts()) { @@ -158,8 +206,12 @@ public class PlayerDataScript implements INpcScriptHandler { } public void clearConsole() { - for (ScriptContainer script : this.getScripts()) { - script.console.clear(); + if(ConfigScript.IndividualPlayerScripts) + console.clear(); + else { + for (ScriptContainer script : this.getScripts()) { + script.console.clear(); + } } } @@ -168,14 +220,14 @@ public class PlayerDataScript implements INpcScriptHandler { private final PlayerDataScript.ToStringHelper.ValueHolder holderHead; private PlayerDataScript.ToStringHelper.ValueHolder holderTail; private boolean omitNullValues; - private final boolean omitEmptyValues; + private boolean omitEmptyValues; private ToStringHelper(String className) { this.holderHead = new PlayerDataScript.ToStringHelper.ValueHolder(); this.holderTail = this.holderHead; this.omitNullValues = false; this.omitEmptyValues = false; - this.className = Preconditions.checkNotNull(className); + this.className = (String) Preconditions.checkNotNull(className); } public PlayerDataScript.ToStringHelper omitNullValues() { @@ -310,7 +362,7 @@ public class PlayerDataScript implements INpcScriptHandler { private PlayerDataScript.ToStringHelper addHolder(String name, @CheckForNull Object value) { PlayerDataScript.ToStringHelper.ValueHolder valueHolder = this.addHolder(); valueHolder.value = value; - valueHolder.name = Preconditions.checkNotNull(name); + valueHolder.name = (String) Preconditions.checkNotNull(name); return this; } @@ -329,7 +381,7 @@ public class PlayerDataScript implements INpcScriptHandler { private PlayerDataScript.ToStringHelper addUnconditionalHolder(String name, Object value) { PlayerDataScript.ToStringHelper.UnconditionalValueHolder valueHolder = this.addUnconditionalHolder(); valueHolder.value = value; - valueHolder.name = Preconditions.checkNotNull(name); + valueHolder.name = (String) Preconditions.checkNotNull(name); return this; } diff --git a/src/main/java/noppes/npcs/controllers/data/PlayerFactionData.java b/src/main/java/noppes/npcs/controllers/data/PlayerFactionData.java index c26f48f21..968cc2949 100644 --- a/src/main/java/noppes/npcs/controllers/data/PlayerFactionData.java +++ b/src/main/java/noppes/npcs/controllers/data/PlayerFactionData.java @@ -1,6 +1,7 @@ package noppes.npcs.controllers.data; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import noppes.npcs.EventHooks; @@ -8,7 +9,7 @@ import noppes.npcs.api.entity.IPlayer; import noppes.npcs.api.handler.IPlayerFactionData; import noppes.npcs.controllers.FactionController; import noppes.npcs.scripted.NpcAPI; -import noppes.npcs.scripted.event.FactionEvent; +import noppes.npcs.scripted.event.player.FactionEvent; import java.util.HashMap; @@ -61,7 +62,7 @@ public class PlayerFactionData implements IPlayerFactionData { } public void increasePoints(int factionId, int points, EntityPlayer player) { - if (EventHooks.onFactionPoints(new FactionEvent.FactionPoints((IPlayer) NpcAPI.Instance().getIEntity(player), FactionController.getInstance().get(factionId), points < 0, points))) + if (EventHooks.onFactionPoints(player, new FactionEvent.FactionPoints((IPlayer) NpcAPI.Instance().getIEntity((EntityPlayerMP) player), FactionController.getInstance().get(factionId), points < 0, points))) return; if (!factionData.containsKey(factionId)) { diff --git a/src/main/java/noppes/npcs/controllers/data/PlayerQuestData.java b/src/main/java/noppes/npcs/controllers/data/PlayerQuestData.java index a4d97d3fd..995e5d85f 100644 --- a/src/main/java/noppes/npcs/controllers/data/PlayerQuestData.java +++ b/src/main/java/noppes/npcs/controllers/data/PlayerQuestData.java @@ -16,7 +16,6 @@ import noppes.npcs.api.handler.data.IQuest; import noppes.npcs.constants.EnumQuestCompletion; import noppes.npcs.constants.EnumQuestType; import noppes.npcs.controllers.PartyController; -import noppes.npcs.controllers.PlayerDataController; import noppes.npcs.controllers.PlayerQuestController; import noppes.npcs.controllers.QuestController; import noppes.npcs.entity.EntityNPCInterface; @@ -104,7 +103,7 @@ public class PlayerQuestData implements IPlayerQuestData { } public QuestData getQuestCompletion(EntityPlayer player, EntityNPCInterface npc) { - PlayerData playerData = PlayerDataController.Instance.getPlayerData(player); + PlayerData playerData = PlayerData.get(player); for (QuestData data : activeQuests.values()) { Quest quest = data.quest; if (quest != null && quest.completion == EnumQuestCompletion.Npc && quest.completerNpc.equals(npc.getCommandSenderName()) && quest.questInterface.isCompleted(playerData)) { @@ -115,7 +114,7 @@ public class PlayerQuestData implements IPlayerQuestData { } public Party getPartyQuestCompletion(EntityPlayer player, EntityNPCInterface npc) { - PlayerData playerData = PlayerDataController.Instance.getPlayerData(player); + PlayerData playerData = PlayerData.get(player); if (playerData != null) { Party party = playerData.getPlayerParty(); if (party != null) { @@ -260,26 +259,26 @@ public class PlayerQuestData implements IPlayerQuestData { List quests = new ArrayList<>(); for (int id : activeQuests.keySet()) { - IQuest quest = QuestController.Instance.quests.get(id); + IQuest quest = (IQuest) QuestController.Instance.quests.get(id); if (quest != null) { quests.add(quest); } } - return quests.toArray(new IQuest[0]); + return (IQuest[]) quests.toArray(new IQuest[0]); } public IQuest[] getFinishedQuests() { List quests = new ArrayList<>(); for (int id : finishedQuests.keySet()) { - IQuest quest = QuestController.Instance.quests.get(id); + IQuest quest = (IQuest) QuestController.Instance.quests.get(id); if (quest != null) { quests.add(quest); } } - return quests.toArray(new IQuest[0]); + return (IQuest[]) quests.toArray(new IQuest[0]); } public long getLastCompletedTime(int id) { diff --git a/src/main/java/noppes/npcs/controllers/data/Quest.java b/src/main/java/noppes/npcs/controllers/data/Quest.java index d50f653a4..02f3e3f87 100644 --- a/src/main/java/noppes/npcs/controllers/data/Quest.java +++ b/src/main/java/noppes/npcs/controllers/data/Quest.java @@ -17,7 +17,6 @@ import noppes.npcs.constants.EnumProfileSync; import noppes.npcs.constants.EnumQuestCompletion; import noppes.npcs.constants.EnumQuestRepeat; import noppes.npcs.constants.EnumQuestType; -import noppes.npcs.controllers.PlayerDataController; import noppes.npcs.controllers.QuestController; import noppes.npcs.quests.*; import noppes.npcs.scripted.CustomNPCsException; @@ -173,7 +172,7 @@ public class Quest implements ICompatibilty, IQuest { } return timeRemaining; } - IPlayerQuestData questData = PlayerDataController.Instance.getPlayerData(player).getQuestData(); + IPlayerQuestData questData = PlayerData.get(player).getQuestData(); return getTimeUntilRepeatQuestData(player, questData); } @@ -314,7 +313,7 @@ public class Quest implements ICompatibilty, IQuest { this.nextQuestTitle = ""; } else { if (quest.getId() < 0) { - throw new CustomNPCsException("Quest id is lower than 0"); + throw new CustomNPCsException("Quest id is lower than 0", new Object[0]); } this.nextQuestid = quest.getId(); @@ -333,7 +332,7 @@ public class Quest implements ICompatibilty, IQuest { public IQuestObjective[] getObjectives(IPlayer player) { if (!player.hasActiveQuest(this.id)) { - throw new CustomNPCsException("Player doesnt have this quest active."); + throw new CustomNPCsException("Player doesnt have this quest active.", new Object[0]); } else { return this.questInterface.getObjectives((EntityPlayer) player.getMCEntity()); } diff --git a/src/main/java/noppes/npcs/controllers/data/RecipeAnvil.java b/src/main/java/noppes/npcs/controllers/data/RecipeAnvil.java index d30a22e38..fe6fd0905 100644 --- a/src/main/java/noppes/npcs/controllers/data/RecipeAnvil.java +++ b/src/main/java/noppes/npcs/controllers/data/RecipeAnvil.java @@ -86,7 +86,10 @@ public class RecipeAnvil implements IAnvilRecipe { if (!NoppesUtilPlayer.compareItems(this.itemToRepair, inputItem, true, this.ignoreRepairItemNBT)) { return false; } - return NoppesUtilPlayer.compareItems(this.repairMaterial, inputRepairMaterial, this.ignoreRepairMaterialDamage, this.ignoreRepairMaterialNBT); + if (!NoppesUtilPlayer.compareItems(this.repairMaterial, inputRepairMaterial, this.ignoreRepairMaterialDamage, this.ignoreRepairMaterialNBT)) { + return false; + } + return true; } @Override @@ -143,6 +146,7 @@ public class RecipeAnvil implements IAnvilRecipe { this.ignoreRepairItemNBT = recipe.ignoreRepairItemNBT; this.ignoreRepairMaterialNBT = recipe.ignoreRepairMaterialNBT; this.repairPercentage = recipe.repairPercentage; + ; this.xpCost = recipe.xpCost; } } diff --git a/src/main/java/noppes/npcs/controllers/data/RecipeCarpentry.java b/src/main/java/noppes/npcs/controllers/data/RecipeCarpentry.java index 95027e59b..da03b548c 100644 --- a/src/main/java/noppes/npcs/controllers/data/RecipeCarpentry.java +++ b/src/main/java/noppes/npcs/controllers/data/RecipeCarpentry.java @@ -126,7 +126,7 @@ public class RecipeCarpentry extends ShapedRecipes implements IRecipe { int var9; if (par2ArrayOfObj[var4] instanceof String[]) { - String[] var7 = (String[]) par2ArrayOfObj[var4++]; + String[] var7 = (String[]) ((String[]) par2ArrayOfObj[var4++]); String[] var8 = var7; var9 = var7.length; diff --git a/src/main/java/noppes/npcs/controllers/data/TransportCategory.java b/src/main/java/noppes/npcs/controllers/data/TransportCategory.java index e43da7f88..f95159d5a 100644 --- a/src/main/java/noppes/npcs/controllers/data/TransportCategory.java +++ b/src/main/java/noppes/npcs/controllers/data/TransportCategory.java @@ -92,6 +92,7 @@ public class TransportCategory implements ITransportCategory { for (Map.Entry entry : locations.entrySet()) { if (entry.getValue().getName().equals(name)) { id = entry.getKey(); + ; locations.remove(entry.getKey()); break; } diff --git a/src/main/java/noppes/npcs/enchants/EnchantInterface.java b/src/main/java/noppes/npcs/enchants/EnchantInterface.java index eb45c0578..2f7867eaf 100644 --- a/src/main/java/noppes/npcs/enchants/EnchantInterface.java +++ b/src/main/java/noppes/npcs/enchants/EnchantInterface.java @@ -17,7 +17,7 @@ public abstract class EnchantInterface extends Enchantment { public static EnchantInterface Confusion; public static EnchantInterface Infinite; - private final Class[] classes; + private Class[] classes; protected EnchantInterface(int par2, Class... obs) { super(ConfigMain.EnchantStartId++, par2, CustomNpcsType); diff --git a/src/main/java/noppes/npcs/entity/EntityCustomNpc.java b/src/main/java/noppes/npcs/entity/EntityCustomNpc.java index 3ca261a84..708ba3e42 100644 --- a/src/main/java/noppes/npcs/entity/EntityCustomNpc.java +++ b/src/main/java/noppes/npcs/entity/EntityCustomNpc.java @@ -82,8 +82,8 @@ public class EntityCustomNpc extends EntityNPCFlying { if (isKilled() && stats.hideKilledBody) { width = 0.00001f; } - if (width / 2 > World.MAX_ENTITY_RADIUS) { - World.MAX_ENTITY_RADIUS = width / 2; + if (width / 2 > worldObj.MAX_ENTITY_RADIUS) { + worldObj.MAX_ENTITY_RADIUS = width / 2; } this.setPosition(posX, posY, posZ); diff --git a/src/main/java/noppes/npcs/entity/EntityNPCInterface.java b/src/main/java/noppes/npcs/entity/EntityNPCInterface.java index 3de022548..c79354347 100644 --- a/src/main/java/noppes/npcs/entity/EntityNPCInterface.java +++ b/src/main/java/noppes/npcs/entity/EntityNPCInterface.java @@ -70,7 +70,6 @@ import noppes.npcs.constants.*; import noppes.npcs.controllers.FactionController; import noppes.npcs.controllers.LinkedNpcController; import noppes.npcs.controllers.LinkedNpcController.LinkedData; -import noppes.npcs.controllers.PlayerDataController; import noppes.npcs.controllers.data.*; import noppes.npcs.entity.data.DataTimers; import noppes.npcs.roles.*; @@ -446,7 +445,7 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti addInteract(player); Dialog dialog = getDialog(player); - PlayerQuestData playerdata = PlayerDataController.Instance.getPlayerData(player).questData; + PlayerQuestData playerdata = PlayerData.get(player).questData; QuestData data = playerdata.getQuestCompletion(player, this); Party partyCompleted = playerdata.getPartyQuestCompletion(player, this); if (partyCompleted != null) { @@ -682,7 +681,11 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti EntityProjectile projectile = shoot(entity, stats.accuracy, proj, f == 1); projectile.damage = event.getDamage(); } - this.playSound(this.stats.fireSound, 2.0F, 1.0f); + + if (this.stats.playBurstSound || !this.stats.onSoundBegin) { + this.playSound(this.stats.fireSound, 1.5F, 1.0f); + this.stats.playBurstSound = false; + } } } @@ -1511,6 +1514,10 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti return ais.movingType != EnumMovingType.Standing || isAttacking() || isFollower() || getBoolFlag(1); } + public boolean isFlying() { + return isWalking() && !onGround; + } + public void setBoolFlag(boolean bo, int id) { int i = dataWatcher.getWatchableObjectInt(15); if (bo && (i & id) == 0) diff --git a/src/main/java/noppes/npcs/entity/EntityNpcDragon.java b/src/main/java/noppes/npcs/entity/EntityNpcDragon.java index 2ec52574d..0d899ee2d 100644 --- a/src/main/java/noppes/npcs/entity/EntityNpcDragon.java +++ b/src/main/java/noppes/npcs/entity/EntityNpcDragon.java @@ -22,7 +22,7 @@ public class EntityNpcDragon extends EntityNPCInterface { height = 1.4f; } - public double[][] field_40162_d; + public double field_40162_d[][]; public int field_40164_e; public float field_40173_aw; public float field_40172_ax; @@ -37,9 +37,9 @@ public class EntityNpcDragon extends EntityNPCInterface { public double[] func_40160_a(int i, float f) { f = 1.0F - f; - int j = field_40164_e - i & 0x3f; - int k = field_40164_e - i - 1 & 0x3f; - double[] ad = new double[3]; + int j = field_40164_e - i * 1 & 0x3f; + int k = field_40164_e - i * 1 - 1 & 0x3f; + double ad[] = new double[3]; double d = field_40162_d[j][0]; double d1; for (d1 = field_40162_d[k][0] - d; d1 < -180D; d1 += 360D) { diff --git a/src/main/java/noppes/npcs/entity/EntityProjectile.java b/src/main/java/noppes/npcs/entity/EntityProjectile.java index 60d7d8cb6..37e903890 100644 --- a/src/main/java/noppes/npcs/entity/EntityProjectile.java +++ b/src/main/java/noppes/npcs/entity/EntityProjectile.java @@ -3,6 +3,8 @@ package noppes.npcs.entity; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import kamkeel.npcs.addon.DBCAddon; +import kamkeel.npcs.network.PacketHandler; +import kamkeel.npcs.network.packets.data.script.ScriptedParticlePacket; import net.minecraft.block.Block; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; @@ -35,6 +37,7 @@ import noppes.npcs.constants.EnumParticleType; import noppes.npcs.constants.EnumPotionType; import noppes.npcs.controllers.ScriptContainer; import noppes.npcs.scripted.NpcAPI; +import noppes.npcs.scripted.ScriptParticle; import noppes.npcs.scripted.event.ProjectileEvent; import noppes.npcs.util.IProjectileCallback; @@ -84,6 +87,7 @@ public class EntityProjectile extends EntityThrowable { public boolean destroyTerrain = true; public int explosiveRadius = 0; public EnumPotionType effect = EnumPotionType.None; + public boolean burnItem = true; public int duration = 5; public int amplify = 0; public int accuracy = 60; @@ -99,7 +103,7 @@ public class EntityProjectile extends EntityThrowable { protected void entityInit() { this.dataWatcher.addObjectByDataType(21, 5); - this.dataWatcher.addObject(22, "");//particle + this.dataWatcher.addObject(22, String.valueOf(""));//particle this.dataWatcher.addObject(23, Integer.valueOf(5));//size this.dataWatcher.addObject(24, Byte.valueOf((byte) 0));//glows this.dataWatcher.addObject(25, Integer.valueOf(10));//velocity @@ -132,9 +136,9 @@ public class EntityProjectile extends EntityThrowable { this.dataWatcher.updateObject(27, Byte.valueOf((byte) ((this.getItem() == Items.arrow) ? 1 : 0))); this.setSize(this.dataWatcher.getWatchableObjectInt(23) / 10, this.dataWatcher.getWatchableObjectInt(23) / 10); this.setLocationAndAngles(par2EntityLiving.posX, par2EntityLiving.posY + (double) par2EntityLiving.getEyeHeight(), par2EntityLiving.posZ, par2EntityLiving.rotationYaw, par2EntityLiving.rotationPitch); - this.posX -= MathHelper.cos(this.rotationYaw / 180.0F * (float) Math.PI) * 0.1F; + this.posX -= (double) (MathHelper.cos(this.rotationYaw / 180.0F * (float) Math.PI) * 0.1F); this.posY -= 0.1f; - this.posZ -= MathHelper.sin(this.rotationYaw / 180.0F * (float) Math.PI) * 0.1F; + this.posZ -= (double) (MathHelper.sin(this.rotationYaw / 180.0F * (float) Math.PI) * 0.1F); this.setPosition(this.posX, this.posY, this.posZ); this.yOffset = 0.0F; @@ -157,12 +161,12 @@ public class EntityProjectile extends EntityThrowable { float f2 = MathHelper.sqrt_double(par1 * par1 + par3 * par3 + par5 * par5); float f3 = MathHelper.sqrt_double(par1 * par1 + par5 * par5); float yaw = (float) (Math.atan2(par1, par5) * 180.0D / Math.PI); - float pitch = this.hasGravity() ? par7 : (float) (Math.atan2(par3, f3) * 180.0D / Math.PI); + float pitch = this.hasGravity() ? par7 : (float) (Math.atan2(par3, (double) f3) * 180.0D / Math.PI); this.prevRotationYaw = this.rotationYaw = yaw; this.prevRotationPitch = this.rotationPitch = pitch; - this.motionX = MathHelper.sin(yaw / 180.0F * (float) Math.PI) * MathHelper.cos(pitch / 180.0F * (float) Math.PI); - this.motionZ = MathHelper.cos(yaw / 180.0F * (float) Math.PI) * MathHelper.cos(pitch / 180.0F * (float) Math.PI); - this.motionY = MathHelper.sin((pitch + 1.0F) / 180.0F * (float) Math.PI); + this.motionX = (double) (MathHelper.sin(yaw / 180.0F * (float) Math.PI) * MathHelper.cos(pitch / 180.0F * (float) Math.PI)); + this.motionZ = (double) (MathHelper.cos(yaw / 180.0F * (float) Math.PI) * MathHelper.cos(pitch / 180.0F * (float) Math.PI)); + this.motionY = (double) (MathHelper.sin((pitch + 1.0F) / 180.0F * (float) Math.PI)); this.motionX += this.rand.nextGaussian() * 0.007499999832361937D * (double) par8; this.motionZ += this.rand.nextGaussian() * 0.007499999832361937D * (double) par8; this.motionY += this.rand.nextGaussian() * 0.007499999832361937D * (double) par8; @@ -192,9 +196,9 @@ public class EntityProjectile extends EntityThrowable { } public void shoot(float speed) { - double varX = -MathHelper.sin(this.rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float) Math.PI); - double varZ = MathHelper.cos(this.rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float) Math.PI); - double varY = -MathHelper.sin(this.rotationPitch / 180.0F * (float) Math.PI); + double varX = (double) (-MathHelper.sin(this.rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float) Math.PI)); + double varZ = (double) (MathHelper.cos(this.rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float) Math.PI)); + double varY = (double) (-MathHelper.sin(this.rotationPitch / 180.0F * (float) Math.PI)); this.setThrowableHeading(varX, varY, varZ, -rotationPitch, speed); } @@ -224,15 +228,14 @@ public class EntityProjectile extends EntityThrowable { if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F) { float f = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ); this.prevRotationYaw = this.rotationYaw = (float) (Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI); - this.prevRotationPitch = this.rotationPitch = (float) (Math.atan2(this.motionY, f) * 180.0D / Math.PI); + this.prevRotationPitch = this.rotationPitch = (float) (Math.atan2(this.motionY, (double) f) * 180.0D / Math.PI); if (this.isRotating()) { this.rotationPitch -= 20; } } - if (this.effect == EnumPotionType.Fire && !this.inGround) + if (this.effect == EnumPotionType.Fire && !this.inGround && this.burnItem) this.setFire(1); - Block block = this.worldObj.getBlock(this.xTile, this.yTile, this.zTile); if ((this.isArrow() || this.sticksToWalls()) && block != null) { @@ -258,9 +261,9 @@ public class EntityProjectile extends EntityThrowable { } } else { this.inGround = false; - this.motionX *= this.rand.nextFloat() * 0.2F; - this.motionY *= this.rand.nextFloat() * 0.2F; - this.motionZ *= this.rand.nextFloat() * 0.2F; + this.motionX *= (double) (this.rand.nextFloat() * 0.2F); + this.motionY *= (double) (this.rand.nextFloat() * 0.2F); + this.motionZ *= (double) (this.rand.nextFloat() * 0.2F); this.ticksInGround = 0; this.ticksInAir = 0; } @@ -290,7 +293,7 @@ public class EntityProjectile extends EntityThrowable { if (entity1.canBeCollidedWith() && (!entity1.isEntityEqual(this.thrower) || this.ticksInAir >= 25)) { float f = 0.3F; - AxisAlignedBB axisalignedbb = entity1.boundingBox.expand(f, f, f); + AxisAlignedBB axisalignedbb = entity1.boundingBox.expand((double) f, (double) f, (double) f); MovingObjectPosition movingobjectposition1 = axisalignedbb.calculateIntercept(vec3, vec31); if (movingobjectposition1 != null) { @@ -331,7 +334,8 @@ public class EntityProjectile extends EntityThrowable { float f1 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ); this.rotationYaw = (float) (Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI); - for (this.rotationPitch = (float) (Math.atan2(this.motionY, f1) * 180.0D / Math.PI); this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F) { + for (this.rotationPitch = (float) (Math.atan2(this.motionY, (double) f1) * 180.0D / Math.PI); this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F) { + ; } while (this.rotationPitch - this.prevRotationPitch >= 180.0F) { @@ -367,12 +371,12 @@ public class EntityProjectile extends EntityThrowable { f2 = 0.8F; } - this.motionX *= f2; - this.motionY *= f2; - this.motionZ *= f2; + this.motionX *= (double) f2; + this.motionY *= (double) f2; + this.motionZ *= (double) f2; if (hasGravity()) - this.motionY -= f3; + this.motionY -= (double) f3; if (accelerate) { this.motionX += this.accelerationX; @@ -380,14 +384,27 @@ public class EntityProjectile extends EntityThrowable { this.motionZ += this.accelerationZ; } - if (worldObj.isRemote && !this.dataWatcher.getWatchableObjectString(22).equals("")) { - this.worldObj.spawnParticle(this.dataWatcher.getWatchableObjectString(22), this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D); + if (worldObj.isRemote && !this.dataWatcher.getWatchableObjectString(22).isEmpty()) { + String particle = this.dataWatcher.getWatchableObjectString(22); + if(!particle.equals("custom")){ + this.worldObj.spawnParticle(particle, this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D); + + } + } else if (!worldObj.isRemote){ + if(this.npc != null && this.npc.stats.pTrail == EnumParticleType.Custom){ + this.npc.stats.pCustom.setPosition(this.posX, this.posY, this.posZ); + spawnScriptedParticle(this.npc.stats.pCustom.writeToNBT(), this.npc); + } } this.setPosition(this.posX, this.posY, this.posZ); this.func_145775_I();//doBlockCollisions } } + public static void spawnScriptedParticle(NBTTagCompound compound, EntityNPCInterface entity) { + PacketHandler.Instance.sendTracking(new ScriptedParticlePacket(compound), entity); + } + public boolean isBlock() { ItemStack item = this.getItemDisplay(); if (item == null) @@ -501,9 +518,9 @@ public class EntityProjectile extends EntityThrowable { this.zTile = movingobjectposition.blockZ; this.inTile = this.worldObj.getBlock(this.xTile, this.yTile, this.zTile); this.inData = this.worldObj.getBlockMetadata(this.xTile, this.yTile, this.zTile); - this.motionX = (float) (movingobjectposition.hitVec.xCoord - this.posX); - this.motionY = (float) (movingobjectposition.hitVec.yCoord - this.posY); - this.motionZ = (float) (movingobjectposition.hitVec.zCoord - this.posZ); + this.motionX = (double) ((float) (movingobjectposition.hitVec.xCoord - this.posX)); + this.motionY = (double) ((float) (movingobjectposition.hitVec.yCoord - this.posY)); + this.motionZ = (double) ((float) (movingobjectposition.hitVec.zCoord - this.posZ)); float f2 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ); this.posX -= this.motionX / (double) f2 * 0.05000000074505806D; this.posY -= this.motionY / (double) f2 * 0.05000000074505806D; @@ -634,7 +651,7 @@ public class EntityProjectile extends EntityThrowable { par1NBTTagCompound.setByte("shake", (byte) this.throwableShake); par1NBTTagCompound.setByte("inGround", (byte) (this.inGround ? 1 : 0)); par1NBTTagCompound.setByte("isArrow", (byte) (this.isArrow() ? 1 : 0)); - par1NBTTagCompound.setTag("direction", this.newDoubleNBTList(this.motionX, this.motionY, this.motionZ)); + par1NBTTagCompound.setTag("direction", this.newDoubleNBTList(new double[]{this.motionX, this.motionY, this.motionZ})); par1NBTTagCompound.setBoolean("canBePickedUp", canBePickedUp); if ((this.throwerName == null || this.throwerName.length() == 0) && this.thrower != null && this.thrower instanceof EntityPlayer) { @@ -662,6 +679,7 @@ public class EntityProjectile extends EntityThrowable { par1NBTTagCompound.setByte("Render3D", this.dataWatcher.getWatchableObjectByte(28)); par1NBTTagCompound.setByte("Spins", this.dataWatcher.getWatchableObjectByte(29)); par1NBTTagCompound.setByte("Sticks", this.dataWatcher.getWatchableObjectByte(30)); + par1NBTTagCompound.setByte("trailCustom", this.dataWatcher.getWatchableObjectByte(31)); } /** @@ -695,6 +713,7 @@ public class EntityProjectile extends EntityThrowable { this.dataWatcher.updateObject(28, Byte.valueOf((byte) (par1NBTTagCompound.getBoolean("Render3D") ? 1 : 0))); this.dataWatcher.updateObject(29, Byte.valueOf((byte) (par1NBTTagCompound.getBoolean("Spins") ? 1 : 0))); this.dataWatcher.updateObject(30, Byte.valueOf((byte) (par1NBTTagCompound.getBoolean("Sticks") ? 1 : 0))); + this.dataWatcher.updateObject(31, par1NBTTagCompound.getString("trailCustom")); if (this.throwerName != null && this.throwerName.length() == 0) { this.throwerName = null; @@ -779,6 +798,7 @@ public class EntityProjectile extends EntityThrowable { this.explosive = stats.pExplode; this.explosiveRadius = stats.pArea; this.effect = stats.pEffect; + this.burnItem = stats.pBurnItem; this.duration = stats.pDur; this.amplify = stats.pEffAmp; this.setParticleEffect(stats.pTrail); @@ -795,6 +815,10 @@ public class EntityProjectile extends EntityThrowable { this.dataWatcher.updateObject(22, type.particleName); } + public void setCustomParticle(ScriptParticle particle) { + + } + public void setHasGravity(boolean bo) { this.dataWatcher.updateObject(26, Byte.valueOf((byte) (bo ? 1 : 0))); } diff --git a/src/main/java/noppes/npcs/entity/data/ModelData.java b/src/main/java/noppes/npcs/entity/data/ModelData.java index a3e1b7c07..95708e553 100644 --- a/src/main/java/noppes/npcs/entity/data/ModelData.java +++ b/src/main/java/noppes/npcs/entity/data/ModelData.java @@ -13,7 +13,7 @@ public class ModelData extends ModelDataShared { return null; if (entity == null) { try { - entity = entityClass.getConstructor(new Class[]{World.class}).newInstance(npc.worldObj); + entity = entityClass.getConstructor(new Class[]{World.class}).newInstance(new Object[]{npc.worldObj}); entity.readEntityFromNBT(extra); diff --git a/src/main/java/noppes/npcs/items/ItemBullet.java b/src/main/java/noppes/npcs/items/ItemBullet.java index cf66b7972..6f7b843be 100644 --- a/src/main/java/noppes/npcs/items/ItemBullet.java +++ b/src/main/java/noppes/npcs/items/ItemBullet.java @@ -5,7 +5,7 @@ import noppes.npcs.constants.EnumNpcToolMaterial; public class ItemBullet extends ItemNpcInterface { - private final EnumNpcToolMaterial material; + private EnumNpcToolMaterial material; public ItemBullet(int par1, EnumNpcToolMaterial material) { super(par1); diff --git a/src/main/java/noppes/npcs/items/ItemCrossbow.java b/src/main/java/noppes/npcs/items/ItemCrossbow.java index e0b80d5cf..c68d9238c 100644 --- a/src/main/java/noppes/npcs/items/ItemCrossbow.java +++ b/src/main/java/noppes/npcs/items/ItemCrossbow.java @@ -57,6 +57,7 @@ public class ItemCrossbow extends ItemNpcInterface { player.worldObj.playSoundAtEntity(player, "random.click", 1.0F, 1); stack.stackTagCompound.setInteger("IsLoaded", 1); } + return; } } } diff --git a/src/main/java/noppes/npcs/items/ItemDaggerReversed.java b/src/main/java/noppes/npcs/items/ItemDaggerReversed.java index 5bc7936c6..b0f16f6ec 100644 --- a/src/main/java/noppes/npcs/items/ItemDaggerReversed.java +++ b/src/main/java/noppes/npcs/items/ItemDaggerReversed.java @@ -5,7 +5,7 @@ import org.lwjgl.opengl.GL11; public class ItemDaggerReversed extends ItemDagger { - private final ItemDagger dagger; + private ItemDagger dagger; public ItemDaggerReversed(int par1, ItemDagger dagger, ToolMaterial tool) { super(par1, tool); diff --git a/src/main/java/noppes/npcs/items/ItemGun.java b/src/main/java/noppes/npcs/items/ItemGun.java index 6d71d5fcd..f890c7193 100644 --- a/src/main/java/noppes/npcs/items/ItemGun.java +++ b/src/main/java/noppes/npcs/items/ItemGun.java @@ -18,7 +18,7 @@ import org.lwjgl.opengl.GL11; public class ItemGun extends ItemNpcInterface implements IProjectileCallback { - private final EnumNpcToolMaterial material; + private EnumNpcToolMaterial material; public ItemGun(int par1, EnumNpcToolMaterial material) { super(par1); diff --git a/src/main/java/noppes/npcs/items/ItemLinked.java b/src/main/java/noppes/npcs/items/ItemLinked.java index 011f971ea..8392beaf6 100644 --- a/src/main/java/noppes/npcs/items/ItemLinked.java +++ b/src/main/java/noppes/npcs/items/ItemLinked.java @@ -4,6 +4,7 @@ import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; +import net.minecraft.network.play.server.S04PacketEntityEquipment; import net.minecraft.world.World; import noppes.npcs.CustomNpcs; import noppes.npcs.EventHooks; @@ -44,12 +45,25 @@ public class ItemLinked extends ItemCustomizable { } else if (linkedItem == null) { if (entity instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) entity; - player.inventory.setInventorySlotContents(itemSlot, null); // Remove the item - player.inventory.markDirty(); // Ensure inventory updates + player.inventory.setInventorySlotContents(itemSlot, null); + player.inventory.markDirty(); // Sync inventory with client if (player instanceof EntityPlayerMP) { - ((EntityPlayerMP) player).sendContainerToPlayer(player.inventoryContainer); + EntityPlayerMP playerMP = (EntityPlayerMP) player; + int equipmentSlot = -1; + // In vanilla 1.7.10, container slots 36-39 are the armor slots: + // slot 36: boots, 37: leggings, 38: chestplate, 39: helmet. + if (itemSlot >= 36 && itemSlot < 40) { + // Map container slot to equipment slot: boots=1, leggings=2, chestplate=3, helmet=4. + equipmentSlot = itemSlot - 35; + } + if (equipmentSlot != -1) { + playerMP.playerNetServerHandler.sendPacket( + new S04PacketEntityEquipment(player.getEntityId(), equipmentSlot, null) + ); + } + playerMP.sendContainerToPlayer(player.inventoryContainer); } } } diff --git a/src/main/java/noppes/npcs/items/ItemMusket.java b/src/main/java/noppes/npcs/items/ItemMusket.java index 5e06c5627..84aa88ec5 100644 --- a/src/main/java/noppes/npcs/items/ItemMusket.java +++ b/src/main/java/noppes/npcs/items/ItemMusket.java @@ -63,6 +63,7 @@ public class ItemMusket extends ItemNpcInterface { player.worldObj.playSoundAtEntity(player, "customnpcs:gun.ak47.load", 1.0F, 1); stack.stackTagCompound.setBoolean("IsLoaded2", true); } + return; } } } diff --git a/src/main/java/noppes/npcs/items/ItemNpcArmor.java b/src/main/java/noppes/npcs/items/ItemNpcArmor.java index 0e7350b60..25aa8e45a 100644 --- a/src/main/java/noppes/npcs/items/ItemNpcArmor.java +++ b/src/main/java/noppes/npcs/items/ItemNpcArmor.java @@ -9,7 +9,7 @@ import noppes.npcs.CustomItems; public class ItemNpcArmor extends ItemArmor { - private final String texture; + private String texture; public ItemNpcArmor(int par1, ArmorMaterial par2EnumArmorMaterial, int par4, String texture) { super(par2EnumArmorMaterial, 0, par4); diff --git a/src/main/java/noppes/npcs/items/ItemNpcArmorColorable.java b/src/main/java/noppes/npcs/items/ItemNpcArmorColorable.java index 65710c2df..d29d8f65f 100644 --- a/src/main/java/noppes/npcs/items/ItemNpcArmorColorable.java +++ b/src/main/java/noppes/npcs/items/ItemNpcArmorColorable.java @@ -14,7 +14,7 @@ import noppes.npcs.CustomItems; public class ItemNpcArmorColorable extends ItemArmor { - private final String texture; + private String texture; public ItemNpcArmorColorable(int par1, ArmorMaterial par2EnumArmorMaterial, int par4, String texture) { super(par2EnumArmorMaterial, 0, par4); @@ -101,7 +101,7 @@ public class ItemNpcArmorColorable extends ItemArmor { @Override public boolean hasColor(ItemStack par1ItemStack) { - return par1ItemStack.hasTagCompound() && (par1ItemStack.getTagCompound().hasKey("display", 10) && par1ItemStack.getTagCompound().getCompoundTag("display").hasKey("color", 3)); + return !par1ItemStack.hasTagCompound() ? false : (!par1ItemStack.getTagCompound().hasKey("display", 10) ? false : par1ItemStack.getTagCompound().getCompoundTag("display").hasKey("color", 3)); } @Override diff --git a/src/main/java/noppes/npcs/items/ItemNpcCloner.java b/src/main/java/noppes/npcs/items/ItemNpcCloner.java index d4aef3415..b8482475e 100644 --- a/src/main/java/noppes/npcs/items/ItemNpcCloner.java +++ b/src/main/java/noppes/npcs/items/ItemNpcCloner.java @@ -23,7 +23,7 @@ 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 || !CustomNpcsPermissions.hasPermission(par2EntityPlayer, CustomNpcsPermissions.TOOL_CLONER)) + if (par3World.isRemote || !CustomNpcsPermissions.Instance.hasPermission(par2EntityPlayer, CustomNpcsPermissions.TOOL_CLONER)) return false; NoppesUtilServer.setClonerGui((EntityPlayerMP) par2EntityPlayer, par4, par5, par6); diff --git a/src/main/java/noppes/npcs/items/ItemNpcInterface.java b/src/main/java/noppes/npcs/items/ItemNpcInterface.java index 010926904..16f198825 100644 --- a/src/main/java/noppes/npcs/items/ItemNpcInterface.java +++ b/src/main/java/noppes/npcs/items/ItemNpcInterface.java @@ -25,6 +25,8 @@ public class ItemNpcInterface extends Item implements ItemRenderInterface { GL11.glTranslatef(0, 0.3f, 0); } + ; + @Override public int getItemEnchantability() { //return this.toolMaterial.getEnchantability(); diff --git a/src/main/java/noppes/npcs/items/ItemNpcMovingPath.java b/src/main/java/noppes/npcs/items/ItemNpcMovingPath.java index 6cc1252d6..5d0ebbdf0 100644 --- a/src/main/java/noppes/npcs/items/ItemNpcMovingPath.java +++ b/src/main/java/noppes/npcs/items/ItemNpcMovingPath.java @@ -30,7 +30,7 @@ public class ItemNpcMovingPath extends Item { @Override public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - if (par2World.isRemote || !CustomNpcsPermissions.hasPermission(par3EntityPlayer, CustomNpcsPermissions.TOOL_MOUNTER)) + if (par2World.isRemote || !CustomNpcsPermissions.Instance.hasPermission(par3EntityPlayer, CustomNpcsPermissions.TOOL_MOUNTER)) return par1ItemStack; EntityNPCInterface npc = getNpc(par1ItemStack, par2World); if (npc != null) @@ -40,7 +40,7 @@ public class ItemNpcMovingPath extends Item { @Override public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer player, World par3World, int x, int y, int z, int par7, float par8, float par9, float par10) { - if (par3World.isRemote || !CustomNpcsPermissions.hasPermission(player, CustomNpcsPermissions.TOOL_MOUNTER)) + if (par3World.isRemote || !CustomNpcsPermissions.Instance.hasPermission(player, CustomNpcsPermissions.TOOL_MOUNTER)) return false; EntityNPCInterface npc = getNpc(par1ItemStack, par3World); if (npc == null) @@ -52,7 +52,7 @@ public class ItemNpcMovingPath extends Item { double d3 = x - pos[0]; double d4 = y - pos[1]; double d5 = z - pos[2]; - double distance = MathHelper.sqrt_double(d3 * d3 + d4 * d4 + d5 * d5); + double distance = (double) MathHelper.sqrt_double(d3 * d3 + d4 * d4 + d5 * d5); player.addChatMessage(new ChatComponentText("Added point x:" + x + " y:" + y + " z:" + z + " to npc " + npc.getCommandSenderName())); if (distance > ConfigMain.NpcNavRange) diff --git a/src/main/java/noppes/npcs/items/ItemNpcTool.java b/src/main/java/noppes/npcs/items/ItemNpcTool.java index 3e45f757d..39431e908 100644 --- a/src/main/java/noppes/npcs/items/ItemNpcTool.java +++ b/src/main/java/noppes/npcs/items/ItemNpcTool.java @@ -2,6 +2,8 @@ package noppes.npcs.items; import cpw.mods.fml.common.registry.GameRegistry; import kamkeel.npcs.network.PacketClient; +import kamkeel.npcs.network.packets.player.item.GuiMagicBookPacket; +import kamkeel.npcs.network.packets.player.item.GuiPaintbrushPacket; import kamkeel.npcs.network.packets.request.item.ColorBrushPacket; import kamkeel.npcs.network.packets.request.item.ColorSetPacket; import kamkeel.npcs.network.packets.request.item.HammerPacket; @@ -23,7 +25,6 @@ import noppes.npcs.blocks.BlockWallBanner; import noppes.npcs.blocks.tiles.TileBanner; import noppes.npcs.blocks.tiles.TileChair; import noppes.npcs.blocks.tiles.TileColorable; -import noppes.npcs.client.NoppesUtil; import noppes.npcs.constants.EnumGuiType; import java.util.List; @@ -32,7 +33,7 @@ public class ItemNpcTool extends Item { // Define our tool types based on metadata: // meta 0: Hammer, meta 1: Paintbrush, meta 2: Wrench - public static final String[] toolTypes = new String[]{"hammer", "paintbrush"}; + public static final String[] toolTypes = new String[]{"hammer", "paintbrush", "magic_book"}; public static String BRUSH_COLOR_TAG = "BrushColor"; public ItemNpcTool() { @@ -62,13 +63,18 @@ public class ItemNpcTool extends Item { @Override public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { - if (world.isRemote) + if (!world.isRemote) return stack; if (isPaintbrush(stack) && player.isSneaking()) { if (CustomNpcsPermissions.hasPermission(player, CustomNpcsPermissions.PAINTBRUSH_GUI)) { - NoppesUtil.requestOpenGUI(EnumGuiType.Paintbrush); + PacketClient.sendClient(new GuiPaintbrushPacket(EnumGuiType.Paintbrush.ordinal(), 0, 0, 0)); } + return stack; + } + if (isMagicBook(stack)) { + PacketClient.sendClient(new GuiMagicBookPacket(EnumGuiType.MagicBook.ordinal(), 0, 0, 0)); + return stack; } return stack; } @@ -145,6 +151,10 @@ public class ItemNpcTool extends Item { return itemStack.getItemDamage() == 0; } + public static boolean isMagicBook(ItemStack itemStack) { + return itemStack.getItemDamage() == 2; + } + @Override public Item setUnlocalizedName(String name) { GameRegistry.registerItem(this, name); diff --git a/src/main/java/noppes/npcs/items/ItemRenderInterface.java b/src/main/java/noppes/npcs/items/ItemRenderInterface.java index 2c0bcc870..a21d1602e 100644 --- a/src/main/java/noppes/npcs/items/ItemRenderInterface.java +++ b/src/main/java/noppes/npcs/items/ItemRenderInterface.java @@ -1,5 +1,5 @@ package noppes.npcs.items; public interface ItemRenderInterface { - void renderSpecial(); + public void renderSpecial(); } diff --git a/src/main/java/noppes/npcs/items/ItemSkirt.java b/src/main/java/noppes/npcs/items/ItemSkirt.java index 340985fe7..ae6e43bb6 100644 --- a/src/main/java/noppes/npcs/items/ItemSkirt.java +++ b/src/main/java/noppes/npcs/items/ItemSkirt.java @@ -15,7 +15,7 @@ import noppes.npcs.CustomNpcs; public class ItemSkirt extends ItemArmor { - private final String texture; + private String texture; public ItemSkirt(ArmorMaterial par2EnumArmorMaterial, String texture) { super(par2EnumArmorMaterial, 0, 2); diff --git a/src/main/java/noppes/npcs/items/ItemSoulstoneEmpty.java b/src/main/java/noppes/npcs/items/ItemSoulstoneEmpty.java index 82d0359a6..7bc7f70b7 100644 --- a/src/main/java/noppes/npcs/items/ItemSoulstoneEmpty.java +++ b/src/main/java/noppes/npcs/items/ItemSoulstoneEmpty.java @@ -15,7 +15,6 @@ import noppes.npcs.CustomNpcsPermissions; import noppes.npcs.NoppesUtilServer; import noppes.npcs.config.ConfigMain; import noppes.npcs.constants.EnumRoleType; -import noppes.npcs.controllers.PlayerDataController; import noppes.npcs.controllers.ServerCloneController; import noppes.npcs.controllers.data.PlayerData; import noppes.npcs.entity.EntityNPCInterface; @@ -83,7 +82,7 @@ public class ItemSoulstoneEmpty extends Item { int p = npc.advanced.minFactionPointsToSoulStone; if (p == -1 && npc.getFaction().isFriendlyToPlayer(player)) return true; else if (p != -1) { - PlayerData data = PlayerDataController.Instance.getPlayerData(player); + PlayerData data = PlayerData.get(player); return data.factionData.getFactionPoints(npc.getFaction().getId()) >= p; } } diff --git a/src/main/java/noppes/npcs/items/ItemSoulstoneFilled.java b/src/main/java/noppes/npcs/items/ItemSoulstoneFilled.java index abca79104..94bb6072f 100644 --- a/src/main/java/noppes/npcs/items/ItemSoulstoneFilled.java +++ b/src/main/java/noppes/npcs/items/ItemSoulstoneFilled.java @@ -16,7 +16,6 @@ import net.minecraft.world.World; import noppes.npcs.LogWriter; import noppes.npcs.config.ConfigDebug; import noppes.npcs.constants.EnumRoleType; -import noppes.npcs.controllers.PlayerDataController; import noppes.npcs.controllers.data.PlayerData; import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.roles.RoleCompanion; @@ -93,7 +92,7 @@ public class ItemSoulstoneFilled extends Item { npc.advanced.soulStonePlayerName = sourceName; npc.advanced.soulStoneInit = true; if (npc.advanced.role == EnumRoleType.Companion && player != null) { - PlayerData data = PlayerDataController.Instance.getPlayerData(player); + PlayerData data = PlayerData.get(player); if (data.hasCompanion()) return false; ((RoleCompanion) npc.roleInterface).setOwner(player); diff --git a/src/main/java/noppes/npcs/items/ItemStaff.java b/src/main/java/noppes/npcs/items/ItemStaff.java index cc272800d..89ce879cf 100644 --- a/src/main/java/noppes/npcs/items/ItemStaff.java +++ b/src/main/java/noppes/npcs/items/ItemStaff.java @@ -10,6 +10,7 @@ import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; import net.minecraft.util.MathHelper; import net.minecraft.world.World; +import net.minecraft.world.WorldServer; import noppes.npcs.CustomItems; import noppes.npcs.CustomNpcs; import noppes.npcs.constants.EnumNpcToolMaterial; @@ -21,7 +22,7 @@ import org.lwjgl.opengl.GL11; public class ItemStaff extends ItemNpcInterface implements IProjectileCallback { - private final EnumNpcToolMaterial material; + private EnumNpcToolMaterial material; public ItemStaff(int par1, EnumNpcToolMaterial material) { super(par1); @@ -41,7 +42,7 @@ public class ItemStaff extends ItemNpcInterface implements IProjectileCallback { } if (stack.stackTagCompound == null) return; - Entity entity = player.worldObj.getEntityByID(stack.stackTagCompound.getInteger("MagicProjectile")); + Entity entity = ((WorldServer) player.worldObj).getEntityByID(stack.stackTagCompound.getInteger("MagicProjectile")); if (entity == null || !(entity instanceof EntityProjectile)) return; EntityProjectile item = (EntityProjectile) entity; @@ -88,7 +89,7 @@ public class ItemStaff extends ItemNpcInterface implements IProjectileCallback { stack.stackTagCompound.setInteger("MagicProjectile", projectile.getEntityId());//entityid } if (tick > chargeTime && stack.stackTagCompound != null) { - Entity entity = player.worldObj.getEntityByID(stack.stackTagCompound.getInteger("MagicProjectile")); + Entity entity = ((WorldServer) player.worldObj).getEntityByID(stack.stackTagCompound.getInteger("MagicProjectile")); if (entity == null || !(entity instanceof EntityProjectile)) return; EntityProjectile item = (EntityProjectile) entity; diff --git a/src/main/java/noppes/npcs/items/ItemTeleporter.java b/src/main/java/noppes/npcs/items/ItemTeleporter.java index a59f94e73..8d2a890c5 100644 --- a/src/main/java/noppes/npcs/items/ItemTeleporter.java +++ b/src/main/java/noppes/npcs/items/ItemTeleporter.java @@ -33,7 +33,7 @@ public class ItemTeleporter extends Item { @Override public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - if (par2World.isRemote || !CustomNpcsPermissions.hasPermission(par3EntityPlayer, CustomNpcsPermissions.TOOL_TELEPORTER)) + if (par2World.isRemote || !CustomNpcsPermissions.Instance.hasPermission(par3EntityPlayer, CustomNpcsPermissions.TOOL_TELEPORTER)) return par1ItemStack; NoppesUtilServer.setTeleporterGUI((EntityPlayerMP) par3EntityPlayer); @@ -66,14 +66,14 @@ public class ItemTeleporter extends Item { Vec3 vec32 = par3EntityPlayer.getLook(f); boolean flag = false; float f9 = 1.0F; - List list = par3EntityPlayer.worldObj.getEntitiesWithinAABBExcludingEntity(par3EntityPlayer, par3EntityPlayer.boundingBox.addCoord(vec32.xCoord * d3, vec32.yCoord * d3, vec32.zCoord * d3).expand(f9, f9, f9)); + List list = par3EntityPlayer.worldObj.getEntitiesWithinAABBExcludingEntity(par3EntityPlayer, par3EntityPlayer.boundingBox.addCoord(vec32.xCoord * d3, vec32.yCoord * d3, vec32.zCoord * d3).expand((double) f9, (double) f9, (double) f9)); for (int i = 0; i < list.size(); ++i) { Entity entity = (Entity) list.get(i); if (entity.canBeCollidedWith()) { float f10 = entity.getCollisionBorderSize(); - AxisAlignedBB axisalignedbb = entity.boundingBox.expand(f10, f10, f10); + AxisAlignedBB axisalignedbb = entity.boundingBox.expand((double) f10, (double) f10, (double) f10); if (axisalignedbb.isVecInside(vec3)) { flag = true; diff --git a/src/main/java/noppes/npcs/items/ItemThrowingWeapon.java b/src/main/java/noppes/npcs/items/ItemThrowingWeapon.java index 307d71a4c..ce00858ac 100644 --- a/src/main/java/noppes/npcs/items/ItemThrowingWeapon.java +++ b/src/main/java/noppes/npcs/items/ItemThrowingWeapon.java @@ -26,6 +26,7 @@ public class ItemThrowingWeapon extends ItemNpcInterface { projectile.damage = damage; projectile.canBePickedUp = !player.capabilities.isCreativeMode && dropItem; projectile.setRotating(rotating); + ; projectile.setIs3D(true); projectile.setStickInWall(true); projectile.setHasGravity(true); diff --git a/src/main/java/noppes/npcs/items/MoneyBagContents.java b/src/main/java/noppes/npcs/items/MoneyBagContents.java index 602cc4de3..e75e2e615 100644 --- a/src/main/java/noppes/npcs/items/MoneyBagContents.java +++ b/src/main/java/noppes/npcs/items/MoneyBagContents.java @@ -5,7 +5,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; public class MoneyBagContents { - private final EntityPlayer player; + private EntityPlayer player; private int[] coinData = new int[]{0, 0, 0, 0, 0, 0, 0}; public MoneyBagContents(EntityPlayer player) { @@ -24,7 +24,7 @@ public class MoneyBagContents { public enum CoinType { - WOOD, STONE, IRON, GOLD, DIAMOND, BRONZE, EMERALD + WOOD, STONE, IRON, GOLD, DIAMOND, BRONZE, EMERALD; } diff --git a/src/main/java/noppes/npcs/mixin/MixinItemRenderer.java b/src/main/java/noppes/npcs/mixin/MixinItemRenderer.java index 174a81e4a..954dfb72f 100644 --- a/src/main/java/noppes/npcs/mixin/MixinItemRenderer.java +++ b/src/main/java/noppes/npcs/mixin/MixinItemRenderer.java @@ -20,6 +20,11 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(ItemRenderer.class) public abstract class MixinItemRenderer { + @Shadow + private RenderBlocks renderBlocksIr; + @Shadow + private static ResourceLocation RES_ITEM_GLINT; + @Inject(method = "renderItemInFirstPerson", at = @At(value = "HEAD"), cancellable = true) public void renderItemInFirstPerson(float p_78440_1_, CallbackInfo callbackInfo) { EntityPlayer player = Minecraft.getMinecraft().thePlayer; @@ -32,6 +37,7 @@ public abstract class MixinItemRenderer { ClientEventHandler.partialRenderTick = Minecraft.getMinecraft().timer.renderPartialTicks; ClientEventHandler.partialHandTicks = p_78440_1_; + ClientEventHandler.renderingNpc = null; ClientEventHandler.renderingPlayer = player; ClientEventHandler.firstPersonAnimation = true; ClientEventHandler.firstPersonModel = (ModelBiped) ((RendererLivingEntity) renderer).mainModel; @@ -43,8 +49,9 @@ public abstract class MixinItemRenderer { } } - @Shadow - private RenderBlocks renderBlocksIr; - @Shadow - private static ResourceLocation RES_ITEM_GLINT; + @Inject(method = "renderItemInFirstPerson", at = @At(value = "TAIL")) + public void renderItemInFirstPerson_tail(float p_78440_1_, CallbackInfo callbackInfo) { + ClientEventHandler.firstPersonAnimation = false; + ClientEventHandler.renderingPlayer = null; + } } diff --git a/src/main/java/noppes/npcs/quests/QuestDialog.java b/src/main/java/noppes/npcs/quests/QuestDialog.java index 83845adc2..ea6bf3e73 100644 --- a/src/main/java/noppes/npcs/quests/QuestDialog.java +++ b/src/main/java/noppes/npcs/quests/QuestDialog.java @@ -53,7 +53,7 @@ public class QuestDialog extends QuestInterface implements IQuestDialog { if (dialog == null) continue; String title = dialog.title; - if (PlayerDataController.Instance.getPlayerData(player).dialogData.dialogsRead.contains(dialogId)) + if (PlayerData.get(player).dialogData.dialogsRead.contains(dialogId)) title += " (read)"; else title += " (unread)"; @@ -69,14 +69,14 @@ public class QuestDialog extends QuestInterface implements IQuestDialog { for (int i = 0; i < 3; ++i) { if (this.dialogs.containsKey(i)) { - Dialog dialog = DialogController.Instance.dialogs.get(this.dialogs.get(i)); + Dialog dialog = (Dialog) DialogController.Instance.dialogs.get(this.dialogs.get(i)); if (dialog != null) { list.add(new noppes.npcs.quests.QuestDialog.QuestDialogObjective(this, player, dialog)); } } } - return list.toArray(new IQuestObjective[list.size()]); + return (IQuestObjective[]) list.toArray(new IQuestObjective[list.size()]); } @Override @@ -85,14 +85,14 @@ public class QuestDialog extends QuestInterface implements IQuestDialog { for (int i = 0; i < 3; ++i) { if (this.dialogs.containsKey(i)) { - Dialog dialog = DialogController.Instance.dialogs.get(this.dialogs.get(i)); + Dialog dialog = (Dialog) DialogController.Instance.dialogs.get(this.dialogs.get(i)); if (dialog != null) { list.add(new noppes.npcs.quests.QuestDialog.QuestDialogObjective(this, party, dialog)); } } } - return list.toArray(new IQuestObjective[list.size()]); + return (IQuestObjective[]) list.toArray(new IQuestObjective[list.size()]); } @Override @@ -119,7 +119,7 @@ public class QuestDialog extends QuestInterface implements IQuestDialog { EntityPlayer player = NoppesUtilServer.getPlayer(uuid); PlayerData playerData; if (player != null) { - playerData = PlayerDataController.Instance.getPlayerData(player); + playerData = PlayerData.get(player); } else { playerData = PlayerDataController.Instance.getPlayerDataCache(uuid.toString()); } @@ -153,7 +153,7 @@ public class QuestDialog extends QuestInterface implements IQuestDialog { EntityPlayer leader = NoppesUtilServer.getPlayer(party.getLeaderUUID()); PlayerData playerData; if (leader != null) { - playerData = PlayerDataController.Instance.getPlayerData(leader); + playerData = PlayerData.get(leader); } else { playerData = PlayerDataController.Instance.getPlayerDataCache(party.getLeaderUUID().toString()); } @@ -181,7 +181,7 @@ public class QuestDialog extends QuestInterface implements IQuestDialog { EntityPlayer player = NoppesUtilServer.getPlayer(uuid); PlayerData sharedData; if (player != null) { - sharedData = PlayerDataController.Instance.getPlayerData(player); + sharedData = PlayerData.get(player); } else { sharedData = PlayerDataController.Instance.getPlayerDataCache(uuid.toString()); } @@ -224,7 +224,7 @@ public class QuestDialog extends QuestInterface implements IQuestDialog { EntityPlayer individual = NoppesUtilServer.getPlayer(uuid); PlayerData individualData; if (individual != null) { - individualData = PlayerDataController.Instance.getPlayerData(individual); + individualData = PlayerData.get(individual); } else { individualData = PlayerDataController.Instance.getPlayerDataCache(uuid.toString()); } @@ -242,7 +242,7 @@ public class QuestDialog extends QuestInterface implements IQuestDialog { EntityPlayer leaderPlayer = NoppesUtilServer.getPlayer(party.getLeaderUUID()); PlayerData leaderData; if (leaderPlayer != null) { - leaderData = PlayerDataController.Instance.getPlayerData(leaderPlayer); + leaderData = PlayerData.get(leaderPlayer); } else { leaderData = PlayerDataController.Instance.getPlayerDataCache(party.getLeaderUUID().toString()); } @@ -262,7 +262,7 @@ public class QuestDialog extends QuestInterface implements IQuestDialog { EntityPlayer player = NoppesUtilServer.getPlayer(uuid); PlayerData playerData; if (player != null) { - playerData = PlayerDataController.Instance.getPlayerData(player); + playerData = PlayerData.get(player); } else { playerData = PlayerDataController.Instance.getPlayerDataCache(uuid.toString()); } @@ -309,7 +309,7 @@ public class QuestDialog extends QuestInterface implements IQuestDialog { public void setProgress(int progress) { if (progress >= 0 && progress <= 1) { if (player != null) { - PlayerData data = PlayerDataController.Instance.getPlayerData(player); + PlayerData data = PlayerData.get(player); boolean completed = data.dialogData.dialogsRead.contains(this.dialog.id); if (progress == 0 && completed) { data.dialogData.dialogsRead.remove(this.dialog.id); @@ -331,7 +331,7 @@ public class QuestDialog extends QuestInterface implements IQuestDialog { EntityPlayer leaderPlayer = NoppesUtilServer.getPlayer(party.getLeaderUUID()); PlayerData leaderData; if (leaderPlayer != null) { - leaderData = PlayerDataController.Instance.getPlayerData(leaderPlayer); + leaderData = PlayerData.get(leaderPlayer); } else { leaderData = PlayerDataController.Instance.getPlayerDataCache(party.getLeaderUUID().toString()); } @@ -356,7 +356,7 @@ public class QuestDialog extends QuestInterface implements IQuestDialog { EntityPlayer individual = NoppesUtilServer.getPlayer(uuid); PlayerData individualData; if (individual != null) { - individualData = PlayerDataController.Instance.getPlayerData(individual); + individualData = PlayerData.get(individual); } else { individualData = PlayerDataController.Instance.getPlayerDataCache(uuid.toString()); } @@ -379,7 +379,7 @@ public class QuestDialog extends QuestInterface implements IQuestDialog { } } } else { - throw new CustomNPCsException("Progress has to be 0 or 1"); + throw new CustomNPCsException("Progress has to be 0 or 1", new Object[0]); } } @@ -388,7 +388,7 @@ public class QuestDialog extends QuestInterface implements IQuestDialog { if (progress >= 0 && progress <= 1) { EntityPlayer foundplayer = NoppesUtilServer.getPlayerByName(playerName); if (foundplayer != null && party == null) { - PlayerData data = PlayerDataController.Instance.getPlayerData(foundplayer); + PlayerData data = PlayerData.get(foundplayer); boolean completed = data.dialogData.dialogsRead.contains(this.dialog.id); if (progress == 0 && completed) { data.dialogData.dialogsRead.remove(this.dialog.id); @@ -410,7 +410,7 @@ public class QuestDialog extends QuestInterface implements IQuestDialog { EntityPlayer leaderPlayer = NoppesUtilServer.getPlayer(party.getLeaderUUID()); PlayerData leaderData; if (leaderPlayer != null) { - leaderData = PlayerDataController.Instance.getPlayerData(leaderPlayer); + leaderData = PlayerData.get(leaderPlayer); } else { leaderData = PlayerDataController.Instance.getPlayerDataCache(party.getLeaderUUID().toString()); } @@ -431,7 +431,7 @@ public class QuestDialog extends QuestInterface implements IQuestDialog { leaderData.save(); } } else { - PlayerData individualData = PlayerDataController.Instance.getPlayerData(foundplayer); + PlayerData individualData = PlayerData.get(foundplayer); if (individualData != null) { boolean completed = individualData.dialogData.dialogsRead.contains(this.dialog.id); if (progress == 0 && completed) { @@ -450,7 +450,7 @@ public class QuestDialog extends QuestInterface implements IQuestDialog { } } } else { - throw new CustomNPCsException("Progress has to be 0 or 1"); + throw new CustomNPCsException("Progress has to be 0 or 1", new Object[0]); } } @@ -460,7 +460,7 @@ public class QuestDialog extends QuestInterface implements IQuestDialog { public boolean isCompleted() { if (player != null) { - PlayerData data = PlayerDataController.Instance.getPlayerData(player); + PlayerData data = PlayerData.get(player); return data.dialogData.dialogsRead.contains(this.dialog.id); } else if (party != null) { if (party.getObjectiveRequirement() != null) { @@ -469,7 +469,7 @@ public class QuestDialog extends QuestInterface implements IQuestDialog { EntityPlayer leaderPlayer = NoppesUtilServer.getPlayer(party.getLeaderUUID()); PlayerData leaderData; if (leaderPlayer != null) { - leaderData = PlayerDataController.Instance.getPlayerData(leaderPlayer); + leaderData = PlayerData.get(leaderPlayer); } else { leaderData = PlayerDataController.Instance.getPlayerDataCache(party.getLeaderUUID().toString()); } @@ -482,7 +482,7 @@ public class QuestDialog extends QuestInterface implements IQuestDialog { EntityPlayer individual = NoppesUtilServer.getPlayer(uuid); PlayerData individualData; if (individual != null) { - individualData = PlayerDataController.Instance.getPlayerData(individual); + individualData = PlayerData.get(individual); } else { individualData = PlayerDataController.Instance.getPlayerDataCache(uuid.toString()); } @@ -514,7 +514,7 @@ public class QuestDialog extends QuestInterface implements IQuestDialog { EntityPlayer individual = NoppesUtilServer.getPlayer(uuid); PlayerData individualData; if (individual != null) { - individualData = PlayerDataController.Instance.getPlayerData(individual); + individualData = PlayerData.get(individual); } else { individualData = PlayerDataController.Instance.getPlayerDataCache(uuid.toString()); } diff --git a/src/main/java/noppes/npcs/quests/QuestInterface.java b/src/main/java/noppes/npcs/quests/QuestInterface.java index 14e52d2a0..4c5672a40 100644 --- a/src/main/java/noppes/npcs/quests/QuestInterface.java +++ b/src/main/java/noppes/npcs/quests/QuestInterface.java @@ -5,7 +5,6 @@ import net.minecraft.nbt.NBTTagCompound; import noppes.npcs.api.handler.data.IQuestInterface; import noppes.npcs.api.handler.data.IQuestObjective; import noppes.npcs.constants.EnumPartyObjectives; -import noppes.npcs.controllers.PlayerDataController; import noppes.npcs.controllers.data.Party; import noppes.npcs.controllers.data.PlayerData; import noppes.npcs.controllers.data.PlayerQuestData; @@ -22,10 +21,10 @@ public abstract class QuestInterface implements IQuestInterface { public abstract boolean isCompleted(PlayerData player); public void handleComplete(EntityPlayer player) { - PlayerQuestData questData = PlayerDataController.Instance.getPlayerData(player).questData; + PlayerQuestData questData = PlayerData.get(player).questData; if (questData != null && questData.getTrackedQuest() != null) { - if (this.questId == PlayerDataController.Instance.getPlayerData(player).questData.getTrackedQuest().getId()) { - PlayerDataController.Instance.getPlayerData(player).questData.untrackQuest(); + if (this.questId == PlayerData.get(player).questData.getTrackedQuest().getId()) { + PlayerData.get(player).questData.untrackQuest(); } } } diff --git a/src/main/java/noppes/npcs/quests/QuestItem.java b/src/main/java/noppes/npcs/quests/QuestItem.java index bf538f0ee..a9302ff66 100644 --- a/src/main/java/noppes/npcs/quests/QuestItem.java +++ b/src/main/java/noppes/npcs/quests/QuestItem.java @@ -200,7 +200,7 @@ public class QuestItem extends QuestInterface implements IQuestItem { String process = item.stackSize + ""; if (item.stackSize > quest.stackSize) process = quest.stackSize + ""; - process += "/" + quest.stackSize; + process += "/" + quest.stackSize + ""; if (item.hasDisplayName()) vec.add(item.getDisplayName() + ": " + process); else @@ -294,7 +294,7 @@ public class QuestItem extends QuestInterface implements IQuestItem { } playerNamesBuilder.append(playerName); } - vec.add("[" + playerNamesBuilder + "]"); + vec.add("[" + playerNamesBuilder.toString() + "]"); } } } else if (objectives == EnumPartyObjectives.Shared || objectives == EnumPartyObjectives.Leader) { @@ -540,12 +540,12 @@ public class QuestItem extends QuestInterface implements IQuestItem { } public void setProgress(int progress) { - throw new CustomNPCsException("Cant set the progress of ItemQuests"); + throw new CustomNPCsException("Cant set the progress of ItemQuests", new Object[0]); } @Override public void setPlayerProgress(String playerName, int progress) { - throw new CustomNPCsException("Cant set the progress of ItemQuests"); + throw new CustomNPCsException("Cant set the progress of ItemQuests", new Object[0]); } public int getMaxProgress() { diff --git a/src/main/java/noppes/npcs/quests/QuestKill.java b/src/main/java/noppes/npcs/quests/QuestKill.java index 0004509fb..70f283938 100644 --- a/src/main/java/noppes/npcs/quests/QuestKill.java +++ b/src/main/java/noppes/npcs/quests/QuestKill.java @@ -9,7 +9,6 @@ import noppes.npcs.api.handler.data.IQuestObjective; import noppes.npcs.constants.EnumPartyObjectives; import noppes.npcs.constants.EnumQuestType; import noppes.npcs.controllers.PartyController; -import noppes.npcs.controllers.PlayerDataController; import noppes.npcs.controllers.data.Party; import noppes.npcs.controllers.data.PlayerData; import noppes.npcs.controllers.data.PlayerQuestData; @@ -81,7 +80,7 @@ public class QuestKill extends QuestInterface implements IQuestKill { @Override public Vector getQuestLogStatus(EntityPlayer player) { Vector vec = new Vector(); - PlayerQuestData playerdata = PlayerDataController.Instance.getPlayerData(player).questData; + PlayerQuestData playerdata = PlayerData.get(player).questData; QuestData data = playerdata.activeQuests.get(questId); if (data == null) return vec; @@ -113,10 +112,10 @@ public class QuestKill extends QuestInterface implements IQuestKill { while (var3.hasNext()) { Map.Entry entry = (Map.Entry) var3.next(); - list.add(new noppes.npcs.quests.QuestKill.QuestKillObjective(this, player, entry.getKey(), entry.getValue())); + list.add(new noppes.npcs.quests.QuestKill.QuestKillObjective(this, player, (String) entry.getKey(), (Integer) entry.getValue())); } - return list.toArray(new IQuestObjective[list.size()]); + return (IQuestObjective[]) list.toArray(new IQuestObjective[list.size()]); } public HashMap getPlayerKilled(QuestData data, String playerName) { @@ -133,10 +132,10 @@ public class QuestKill extends QuestInterface implements IQuestKill { while (var3.hasNext()) { Map.Entry entry = (Map.Entry) var3.next(); - list.add(new noppes.npcs.quests.QuestKill.QuestKillObjective(this, party, entry.getKey(), entry.getValue())); + list.add(new noppes.npcs.quests.QuestKill.QuestKillObjective(this, party, (String) entry.getKey(), (Integer) entry.getValue())); } - return list.toArray(new IQuestObjective[list.size()]); + return (IQuestObjective[]) list.toArray(new IQuestObjective[list.size()]); } @Override @@ -265,12 +264,12 @@ public class QuestKill extends QuestInterface implements IQuestKill { public int getProgress() { if (player != null) { - PlayerData data = PlayerDataController.Instance.getPlayerData(player); + PlayerData data = PlayerData.get(player); PlayerQuestData playerdata = data.questData; - QuestData questdata = playerdata.activeQuests.get(this.parent.questId); + QuestData questdata = (QuestData) playerdata.activeQuests.get(this.parent.questId); if (questdata != null) { HashMap killed = this.parent.getKilled(questdata); - return !killed.containsKey(this.entity) ? 0 : killed.get(this.entity); + return !killed.containsKey(this.entity) ? 0 : (Integer) killed.get(this.entity); } } else if (party != null) { QuestData questdata = party.getQuestData(); @@ -279,7 +278,7 @@ public class QuestKill extends QuestInterface implements IQuestKill { int howManyDone = 0; for (String player : party.getPlayerNames()) { HashMap killed = this.parent.getPlayerKilled(questdata, player); - int currentProgress = !killed.containsKey(this.entity) ? 0 : killed.get(this.entity); + int currentProgress = !killed.containsKey(this.entity) ? 0 : (Integer) killed.get(this.entity); if (currentProgress >= this.amount) howManyDone += 1; } @@ -289,7 +288,7 @@ public class QuestKill extends QuestInterface implements IQuestKill { return 0; } else { HashMap killed = this.parent.getKilled(questdata); - return !killed.containsKey(this.entity) ? 0 : killed.get(this.entity); + return !killed.containsKey(this.entity) ? 0 : (Integer) killed.get(this.entity); } } } @@ -299,12 +298,12 @@ public class QuestKill extends QuestInterface implements IQuestKill { public void setProgress(int progress) { if (progress >= 0 && progress <= this.amount) { if (player != null) { - PlayerData data = PlayerDataController.Instance.getPlayerData(player); + PlayerData data = PlayerData.get(player); PlayerQuestData playerdata = data.questData; - QuestData questdata = playerdata.activeQuests.get(this.parent.questId); + QuestData questdata = (QuestData) playerdata.activeQuests.get(this.parent.questId); if (questdata != null) { HashMap killed = this.parent.getKilled(questdata); - if (!killed.containsKey(this.entity) || killed.get(this.entity) != progress) { + if (!killed.containsKey(this.entity) || (Integer) killed.get(this.entity) != progress) { killed.put(this.entity, progress); this.parent.setKilled(questdata, killed); data.questData.checkQuestCompletion(data, EnumQuestType.values()[2]); @@ -319,7 +318,7 @@ public class QuestKill extends QuestInterface implements IQuestKill { if (questdata.quest.partyOptions.objectiveRequirement == EnumPartyObjectives.All) { for (String player : party.getPlayerNames()) { HashMap killed = this.parent.getPlayerKilled(questdata, player); - if (!killed.containsKey(this.entity) || killed.get(this.entity) != progress) { + if (!killed.containsKey(this.entity) || (Integer) killed.get(this.entity) != progress) { killed.put(this.entity, progress); this.parent.setPlayerKilled(questdata, killed, player); } @@ -328,7 +327,7 @@ public class QuestKill extends QuestInterface implements IQuestKill { PartyController.Instance().checkQuestCompletion(party, EnumQuestType.values()[4]); } else { HashMap killed = this.parent.getKilled(questdata); - if (!killed.containsKey(this.entity) || killed.get(this.entity) != progress) { + if (!killed.containsKey(this.entity) || (Integer) killed.get(this.entity) != progress) { killed.put(this.entity, progress); this.parent.setKilled(questdata, killed); PartyController.Instance().checkQuestCompletion(party, EnumQuestType.values()[2]); @@ -338,7 +337,7 @@ public class QuestKill extends QuestInterface implements IQuestKill { } } } else { - throw new CustomNPCsException("Progress has to be between 0 and " + this.amount); + throw new CustomNPCsException("Progress has to be between 0 and " + this.amount, new Object[0]); } } @@ -347,12 +346,12 @@ public class QuestKill extends QuestInterface implements IQuestKill { if (progress >= 0 && progress <= this.amount) { EntityPlayer foundplayer = NoppesUtilServer.getPlayerByName(playerName); if (foundplayer != null && party == null) { - PlayerData data = PlayerDataController.Instance.getPlayerData(foundplayer); + PlayerData data = PlayerData.get(foundplayer); PlayerQuestData playerdata = data.questData; - QuestData questdata = playerdata.activeQuests.get(this.parent.questId); + QuestData questdata = (QuestData) playerdata.activeQuests.get(this.parent.questId); if (questdata != null) { HashMap killed = this.parent.getKilled(questdata); - if (!killed.containsKey(this.entity) || killed.get(this.entity) != progress) { + if (!killed.containsKey(this.entity) || (Integer) killed.get(this.entity) != progress) { killed.put(this.entity, progress); this.parent.setKilled(questdata, killed); data.questData.checkQuestCompletion(data, EnumQuestType.values()[2]); @@ -366,7 +365,7 @@ public class QuestKill extends QuestInterface implements IQuestKill { if (questdata != null) { if (questdata.quest.partyOptions.objectiveRequirement == EnumPartyObjectives.All) { HashMap killed = this.parent.getPlayerKilled(questdata, playerName); - if (!killed.containsKey(this.entity) || killed.get(this.entity) != progress) { + if (!killed.containsKey(this.entity) || (Integer) killed.get(this.entity) != progress) { killed.put(this.entity, progress); this.parent.setPlayerKilled(questdata, killed, playerName); } @@ -374,7 +373,7 @@ public class QuestKill extends QuestInterface implements IQuestKill { PartyController.Instance().checkQuestCompletion(party, EnumQuestType.values()[4]); } else { HashMap killed = this.parent.getKilled(questdata); - if (!killed.containsKey(this.entity) || killed.get(this.entity) != progress) { + if (!killed.containsKey(this.entity) || (Integer) killed.get(this.entity) != progress) { killed.put(this.entity, progress); this.parent.setKilled(questdata, killed); PartyController.Instance().checkQuestCompletion(party, EnumQuestType.values()[2]); @@ -384,7 +383,7 @@ public class QuestKill extends QuestInterface implements IQuestKill { } } } else { - throw new CustomNPCsException("Progress has to be between 0 and " + this.amount); + throw new CustomNPCsException("Progress has to be between 0 and " + this.amount, new Object[0]); } } @@ -414,7 +413,7 @@ public class QuestKill extends QuestInterface implements IQuestKill { if (questdata.quest.partyOptions.objectiveRequirement == EnumPartyObjectives.All) { for (String player : party.getPlayerNames()) { HashMap killed = this.parent.getPlayerKilled(questdata, player); - int currentProgress = !killed.containsKey(this.entity) ? 0 : killed.get(this.entity); + int currentProgress = !killed.containsKey(this.entity) ? 0 : (Integer) killed.get(this.entity); if (currentProgress < this.amount) { String state = player + ": " + currentProgress; incompletePlayers.add(state); diff --git a/src/main/java/noppes/npcs/quests/QuestLocation.java b/src/main/java/noppes/npcs/quests/QuestLocation.java index c9f19eb10..ed23af743 100644 --- a/src/main/java/noppes/npcs/quests/QuestLocation.java +++ b/src/main/java/noppes/npcs/quests/QuestLocation.java @@ -10,7 +10,6 @@ import noppes.npcs.api.handler.data.IQuestObjective; import noppes.npcs.constants.EnumPartyObjectives; import noppes.npcs.constants.EnumQuestType; import noppes.npcs.controllers.PartyController; -import noppes.npcs.controllers.PlayerDataController; import noppes.npcs.controllers.data.Party; import noppes.npcs.controllers.data.PlayerData; import noppes.npcs.controllers.data.PlayerQuestData; @@ -57,7 +56,7 @@ public class QuestLocation extends QuestInterface implements IQuestLocation { @Override public Vector getQuestLogStatus(EntityPlayer player) { Vector vec = new Vector(); - PlayerQuestData playerdata = PlayerDataController.Instance.getPlayerData(player).questData; + PlayerQuestData playerdata = PlayerData.get(player).questData; QuestData data = playerdata.activeQuests.get(questId); if (data == null) return vec; @@ -89,7 +88,7 @@ public class QuestLocation extends QuestInterface implements IQuestLocation { list.add(new noppes.npcs.quests.QuestLocation.QuestLocationObjective(this, player, this.location3, "Location3Found")); } - return list.toArray(new IQuestObjective[list.size()]); + return (IQuestObjective[]) list.toArray(new IQuestObjective[list.size()]); } public boolean getFound(QuestData data, int i) { @@ -104,7 +103,9 @@ public class QuestLocation extends QuestInterface implements IQuestLocation { return false; if (!location2.isEmpty() && !data.extraData.getBoolean("Location2Found")) return false; - return location3.isEmpty() || data.extraData.getBoolean("Location3Found"); + if (!location3.isEmpty() && !data.extraData.getBoolean("Location3Found")) + return false; + return true; } public boolean setFound(QuestData data, String location) { @@ -217,7 +218,7 @@ public class QuestLocation extends QuestInterface implements IQuestLocation { list.add(new noppes.npcs.quests.QuestLocation.QuestLocationObjective(this, party, this.location3, "Location3Found", getPartyFound(party, "Location3Found"))); } - return list.toArray(new IQuestObjective[list.size()]); + return (IQuestObjective[]) list.toArray(new IQuestObjective[list.size()]); } @Override @@ -339,8 +340,8 @@ public class QuestLocation extends QuestInterface implements IQuestLocation { public void setProgress(int progress) { if (progress >= 0 && progress <= 1) { if (player != null) { - PlayerData data = PlayerDataController.Instance.getPlayerData(player); - QuestData questData = data.questData.activeQuests.get(this.parent.questId); + PlayerData data = PlayerData.get(player); + QuestData questData = (QuestData) data.questData.activeQuests.get(this.parent.questId); boolean completed = questData.extraData.getBoolean(this.nbtName); if ((!completed || progress != 1) && (completed || progress != 0)) { questData.extraData.setBoolean(this.nbtName, progress == 1); @@ -366,7 +367,7 @@ public class QuestLocation extends QuestInterface implements IQuestLocation { } } } else { - throw new CustomNPCsException("Progress has to be 0 or 1"); + throw new CustomNPCsException("Progress has to be 0 or 1", new Object[0]); } } @@ -375,8 +376,8 @@ public class QuestLocation extends QuestInterface implements IQuestLocation { if (progress >= 0 && progress <= 1) { EntityPlayer foundplayer = NoppesUtilServer.getPlayerByName(playerName); if (foundplayer != null && party == null) { - PlayerData data = PlayerDataController.Instance.getPlayerData(foundplayer); - QuestData questData = data.questData.activeQuests.get(this.parent.questId); + PlayerData data = PlayerData.get(foundplayer); + QuestData questData = (QuestData) data.questData.activeQuests.get(this.parent.questId); boolean completed = questData.extraData.getBoolean(this.nbtName); if ((!completed || progress != 1) && (completed || progress != 0)) { questData.extraData.setBoolean(this.nbtName, progress == 1); @@ -404,7 +405,7 @@ public class QuestLocation extends QuestInterface implements IQuestLocation { } } } else { - throw new CustomNPCsException("Progress has to be 0 or 1"); + throw new CustomNPCsException("Progress has to be 0 or 1", new Object[0]); } } @@ -415,7 +416,7 @@ public class QuestLocation extends QuestInterface implements IQuestLocation { public boolean isCompleted() { QuestData questData = null; if (player != null) { - PlayerData data = PlayerDataController.Instance.getPlayerData(player); + PlayerData data = PlayerData.get(player); PlayerQuestData playerQuestData = data.questData; if (playerQuestData != null) { questData = playerQuestData.activeQuests.get(this.parent.questId); diff --git a/src/main/java/noppes/npcs/quests/QuestManual.java b/src/main/java/noppes/npcs/quests/QuestManual.java index bbde7f7ad..80a59709e 100644 --- a/src/main/java/noppes/npcs/quests/QuestManual.java +++ b/src/main/java/noppes/npcs/quests/QuestManual.java @@ -8,7 +8,6 @@ import noppes.npcs.api.handler.data.IQuestObjective; import noppes.npcs.constants.EnumPartyObjectives; import noppes.npcs.constants.EnumQuestType; import noppes.npcs.controllers.PartyController; -import noppes.npcs.controllers.PlayerDataController; import noppes.npcs.controllers.data.Party; import noppes.npcs.controllers.data.PlayerData; import noppes.npcs.controllers.data.PlayerQuestData; @@ -58,7 +57,7 @@ public class QuestManual extends QuestInterface { @Override public Vector getQuestLogStatus(EntityPlayer player) { Vector vec = new Vector(); - PlayerData playerdata = PlayerDataController.Instance.getPlayerData(player); + PlayerData playerdata = PlayerData.get(player); if (playerdata == null) return vec; @@ -104,7 +103,7 @@ public class QuestManual extends QuestInterface { for (Entry entry : manuals.entrySet()) { list.add(new QuestManualObjective(party, entry.getKey(), entry.getValue())); } - return list.toArray(new IQuestObjective[list.size()]); + return (IQuestObjective[]) list.toArray(new IQuestObjective[list.size()]); } @Override @@ -216,12 +215,12 @@ public class QuestManual extends QuestInterface { @Override public int getProgress() { if (player != null) { - PlayerData data = PlayerDataController.Instance.getPlayerData(player); + PlayerData data = PlayerData.get(player); PlayerQuestData playerdata = data.questData; - QuestData questdata = playerdata.activeQuests.get(questId); + QuestData questdata = (QuestData) playerdata.activeQuests.get(questId); if (questdata != null) { HashMap playerManual = getManual(questdata); - return !playerManual.containsKey(this.entity) ? 0 : playerManual.get(this.entity); + return !playerManual.containsKey(this.entity) ? 0 : (Integer) playerManual.get(this.entity); } } else if (party != null) { QuestData questdata = party.getQuestData(); @@ -230,7 +229,7 @@ public class QuestManual extends QuestInterface { int howManyDone = 0; for (String player : party.getPlayerNames()) { HashMap playerManual = getPlayerManual(questdata, player); - int currentProgress = !playerManual.containsKey(this.entity) ? 0 : playerManual.get(this.entity); + int currentProgress = !playerManual.containsKey(this.entity) ? 0 : (Integer) playerManual.get(this.entity); if (currentProgress >= this.amount) howManyDone += 1; } @@ -240,7 +239,7 @@ public class QuestManual extends QuestInterface { return 0; } else { HashMap playerManual = getManual(questdata); - return !playerManual.containsKey(this.entity) ? 0 : playerManual.get(this.entity); + return !playerManual.containsKey(this.entity) ? 0 : (Integer) playerManual.get(this.entity); } } } @@ -251,12 +250,12 @@ public class QuestManual extends QuestInterface { public void setProgress(int progress) { if (progress >= 0 && progress <= this.amount) { if (player != null) { - PlayerData data = PlayerDataController.Instance.getPlayerData(player); + PlayerData data = PlayerData.get(player); PlayerQuestData playerdata = data.questData; - QuestData questdata = playerdata.activeQuests.get(questId); + QuestData questdata = (QuestData) playerdata.activeQuests.get(questId); if (questdata != null) { HashMap playerManual = getManual(questdata); - if (!playerManual.containsKey(this.entity) || playerManual.get(this.entity) != progress) { + if (!playerManual.containsKey(this.entity) || (Integer) playerManual.get(this.entity) != progress) { playerManual.put(this.entity, progress); setManual(questdata, playerManual); data.questData.checkQuestCompletion(data, EnumQuestType.Manual); @@ -270,7 +269,7 @@ public class QuestManual extends QuestInterface { if (questdata.quest.partyOptions.objectiveRequirement == EnumPartyObjectives.All) { for (String player : party.getPlayerNames()) { HashMap playerManual = getPlayerManual(questdata, player); - if (!playerManual.containsKey(this.entity) || playerManual.get(this.entity) != progress) { + if (!playerManual.containsKey(this.entity) || (Integer) playerManual.get(this.entity) != progress) { playerManual.put(this.entity, progress); setPlayerManual(questdata, playerManual, player); } @@ -278,7 +277,7 @@ public class QuestManual extends QuestInterface { PartyController.Instance().checkQuestCompletion(party, EnumQuestType.Manual); } else { HashMap playerManual = getManual(questdata); - if (!playerManual.containsKey(this.entity) || playerManual.get(this.entity) != progress) { + if (!playerManual.containsKey(this.entity) || (Integer) playerManual.get(this.entity) != progress) { playerManual.put(this.entity, progress); setManual(questdata, playerManual); PartyController.Instance().checkQuestCompletion(party, EnumQuestType.Manual); @@ -287,7 +286,7 @@ public class QuestManual extends QuestInterface { } } } else { - throw new CustomNPCsException("Progress has to be between 0 and " + this.amount); + throw new CustomNPCsException("Progress has to be between 0 and " + this.amount, new Object[0]); } } @@ -296,12 +295,12 @@ public class QuestManual extends QuestInterface { if (progress >= 0 && progress <= this.amount) { EntityPlayer foundplayer = NoppesUtilServer.getPlayerByName(playerName); if (foundplayer != null && party == null) { - PlayerData data = PlayerDataController.Instance.getPlayerData(foundplayer); + PlayerData data = PlayerData.get(foundplayer); PlayerQuestData playerdata = data.questData; - QuestData questdata = playerdata.activeQuests.get(questId); + QuestData questdata = (QuestData) playerdata.activeQuests.get(questId); if (questdata != null) { HashMap playerManual = getManual(questdata); - if (!playerManual.containsKey(this.entity) || playerManual.get(this.entity) != progress) { + if (!playerManual.containsKey(this.entity) || (Integer) playerManual.get(this.entity) != progress) { playerManual.put(this.entity, progress); setManual(questdata, playerManual); data.questData.checkQuestCompletion(data, EnumQuestType.Manual); @@ -314,14 +313,14 @@ public class QuestManual extends QuestInterface { if (questdata != null) { if (questdata.quest.partyOptions.objectiveRequirement == EnumPartyObjectives.All) { HashMap playerManual = getPlayerManual(questdata, foundplayer.getCommandSenderName()); - if (!playerManual.containsKey(this.entity) || playerManual.get(this.entity) != progress) { + if (!playerManual.containsKey(this.entity) || (Integer) playerManual.get(this.entity) != progress) { playerManual.put(this.entity, progress); setPlayerManual(questdata, playerManual, foundplayer.getCommandSenderName()); } PartyController.Instance().checkQuestCompletion(party, EnumQuestType.Manual); } else { HashMap playerManual = getManual(questdata); - if (!playerManual.containsKey(this.entity) || playerManual.get(this.entity) != progress) { + if (!playerManual.containsKey(this.entity) || (Integer) playerManual.get(this.entity) != progress) { playerManual.put(this.entity, progress); setManual(questdata, playerManual); PartyController.Instance().checkQuestCompletion(party, EnumQuestType.Manual); @@ -330,7 +329,7 @@ public class QuestManual extends QuestInterface { } } } else { - throw new CustomNPCsException("Progress has to be between 0 and " + this.amount); + throw new CustomNPCsException("Progress has to be between 0 and " + this.amount, new Object[0]); } } @@ -363,7 +362,7 @@ public class QuestManual extends QuestInterface { if (questdata.quest.partyOptions.objectiveRequirement == EnumPartyObjectives.All) { for (String player : party.getPlayerNames()) { HashMap playerManual = getPlayerManual(questdata, player); - int currentProgress = !playerManual.containsKey(this.entity) ? 0 : playerManual.get(this.entity); + int currentProgress = !playerManual.containsKey(this.entity) ? 0 : (Integer) playerManual.get(this.entity); if (currentProgress < this.amount) { String state = player + ": " + currentProgress; incompletePlayers.add(state); diff --git a/src/main/java/noppes/npcs/roles/JobConversation.java b/src/main/java/noppes/npcs/roles/JobConversation.java index 75e93bfb7..6ba55f958 100644 --- a/src/main/java/noppes/npcs/roles/JobConversation.java +++ b/src/main/java/noppes/npcs/roles/JobConversation.java @@ -18,8 +18,8 @@ import java.util.List; public class JobConversation extends JobInterface { public Availability availability = new Availability(); - private final ArrayList names = new ArrayList(); - private final HashMap npcs = new HashMap(); + private ArrayList names = new ArrayList(); + private HashMap npcs = new HashMap(); public HashMap lines = new HashMap(); diff --git a/src/main/java/noppes/npcs/roles/JobFollower.java b/src/main/java/noppes/npcs/roles/JobFollower.java index ca78b4183..9d80c9dc0 100644 --- a/src/main/java/noppes/npcs/roles/JobFollower.java +++ b/src/main/java/noppes/npcs/roles/JobFollower.java @@ -9,7 +9,7 @@ import java.util.List; public class JobFollower extends JobInterface { public EntityNPCInterface following = null; private int ticks = 40; - private final int range = 20; + private int range = 20; public String name = ""; public JobFollower(EntityNPCInterface npc) { diff --git a/src/main/java/noppes/npcs/roles/JobGuard.java b/src/main/java/noppes/npcs/roles/JobGuard.java index 59e3e882e..20adbe62e 100644 --- a/src/main/java/noppes/npcs/roles/JobGuard.java +++ b/src/main/java/noppes/npcs/roles/JobGuard.java @@ -56,7 +56,9 @@ public class JobGuard extends JobInterface { return true; if (entity instanceof EntityAnimal) { - return attacksAnimals && (!(entity instanceof EntityTameable) || ((EntityTameable) entity).getOwner() == null); + if (!attacksAnimals || entity instanceof EntityTameable && ((EntityTameable) entity).getOwner() != null) + return false; + return true; } else if (entity instanceof EntityCreeper) { return attackCreepers; } else if (entity instanceof IMob || entity instanceof EntityDragon) { diff --git a/src/main/java/noppes/npcs/roles/JobHealer.java b/src/main/java/noppes/npcs/roles/JobHealer.java index 19f32d5e7..576761f86 100644 --- a/src/main/java/noppes/npcs/roles/JobHealer.java +++ b/src/main/java/noppes/npcs/roles/JobHealer.java @@ -31,11 +31,11 @@ public class JobHealer extends JobInterface { speed = nbttagcompound.getInteger("HealerSpeed"); } - private final List toHeal = new ArrayList(); + private List toHeal = new ArrayList(); public boolean aiShouldExecute() { healTicks++; - if (healTicks < speed * 10L) + if (healTicks < speed * 10) return false; for (Object plObj : npc.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, npc.boundingBox.expand(range, range / 2.0, range))) { diff --git a/src/main/java/noppes/npcs/roles/JobInterface.java b/src/main/java/noppes/npcs/roles/JobInterface.java index 49f7c2809..34cd0c70d 100644 --- a/src/main/java/noppes/npcs/roles/JobInterface.java +++ b/src/main/java/noppes/npcs/roles/JobInterface.java @@ -24,9 +24,13 @@ public abstract class JobInterface { public void killed() { } + ; + public void delete() { } + ; + public boolean aiShouldExecute() { return false; } diff --git a/src/main/java/noppes/npcs/roles/JobItemGiver.java b/src/main/java/noppes/npcs/roles/JobItemGiver.java index 69692bf81..7b674803e 100644 --- a/src/main/java/noppes/npcs/roles/JobItemGiver.java +++ b/src/main/java/noppes/npcs/roles/JobItemGiver.java @@ -8,9 +8,9 @@ import net.minecraft.nbt.NBTTagList; import noppes.npcs.NBTTags; import noppes.npcs.NpcMiscInventory; import noppes.npcs.controllers.GlobalDataController; -import noppes.npcs.controllers.PlayerDataController; import noppes.npcs.controllers.data.Availability; import noppes.npcs.controllers.data.Line; +import noppes.npcs.controllers.data.PlayerData; import noppes.npcs.controllers.data.PlayerItemGiverData; import noppes.npcs.entity.EntityNPCInterface; @@ -31,7 +31,7 @@ public class JobItemGiver extends JobInterface { private int ticks = 10; - private final List recentlyChecked = new ArrayList(); + private List recentlyChecked = new ArrayList(); private List toCheck; public Availability availability = new Availability(); @@ -98,7 +98,7 @@ public class JobItemGiver extends JobInterface { } public boolean giveItems(EntityPlayer player) { - PlayerItemGiverData data = PlayerDataController.Instance.getPlayerData(player).itemgiverData; + PlayerItemGiverData data = PlayerData.get(player).itemgiverData; if (!canPlayerInteract(data)) { return false; } @@ -170,7 +170,7 @@ public class JobItemGiver extends JobInterface { if (isOnTimer()) { if (!data.hasInteractedBefore(this)) return true; - return data.getTime(this) + (cooldown * 1000L) < System.currentTimeMillis(); + return data.getTime(this) + (cooldown * 1000) < System.currentTimeMillis(); } else if (isGiveOnce()) { return !data.hasInteractedBefore(this); } else if (isDaily()) { diff --git a/src/main/java/noppes/npcs/roles/JobSpawner.java b/src/main/java/noppes/npcs/roles/JobSpawner.java index fc0c6d7be..a533a7625 100644 --- a/src/main/java/noppes/npcs/roles/JobSpawner.java +++ b/src/main/java/noppes/npcs/roles/JobSpawner.java @@ -26,7 +26,7 @@ public class JobSpawner extends JobInterface { public List spawned = new ArrayList(); - private final Map cooldown = new HashMap(); + private Map cooldown = new HashMap(); private String id = RandomStringUtils.random(8, true, true); @@ -249,7 +249,10 @@ public class JobSpawner extends JobInterface { return false; if (compound5 != null && compound5.hasKey("id")) return false; - return compound6 == null || !compound6.hasKey("id"); + if (compound6 != null && compound6.hasKey("id")) + return false; + + return true; } private void setTarget(EntityLivingBase base, EntityLivingBase target) { diff --git a/src/main/java/noppes/npcs/roles/RoleCompanion.java b/src/main/java/noppes/npcs/roles/RoleCompanion.java index b7239f046..39209c238 100644 --- a/src/main/java/noppes/npcs/roles/RoleCompanion.java +++ b/src/main/java/noppes/npcs/roles/RoleCompanion.java @@ -18,7 +18,6 @@ import net.minecraft.util.Vec3; import noppes.npcs.NoppesUtilServer; import noppes.npcs.NpcMiscInventory; import noppes.npcs.constants.*; -import noppes.npcs.controllers.PlayerDataController; import noppes.npcs.controllers.data.PlayerData; import noppes.npcs.entity.EntityCustomNpc; import noppes.npcs.entity.EntityNPCInterface; @@ -69,7 +68,7 @@ public class RoleCompanion extends RoleInterface { npc.isDead = true; } else if (prev != owner && owner != null) { ownerName = owner.getDisplayName(); - PlayerData data = PlayerDataController.Instance.getPlayerData(owner); + PlayerData data = PlayerData.get(owner); if (data.companionID != companionID) { npc.isDead = true; } @@ -405,8 +404,8 @@ public class RoleCompanion extends RoleInterface { } public void levelSword() { - if (!talents.containsKey(EnumCompanionTalent.SWORD)) { - } + if (!talents.containsKey(EnumCompanionTalent.SWORD)) + return; } public void levelTalent(EnumCompanionTalent talent, int exp) { @@ -465,7 +464,9 @@ public class RoleCompanion extends RoleInterface { return true; if (reduction <= 15 && level >= 3) return true; - return reduction <= 33 && level >= 4; + if (reduction <= 33 && level >= 4) + return true; + return false; } public boolean canWearSword(ItemStack item) { @@ -513,7 +514,7 @@ public class RoleCompanion extends RoleInterface { public void setSelfsuficient(boolean bo) { if (owner == null || jobInterface != null && bo == jobInterface.isSelfSufficient()) return; - PlayerData data = PlayerDataController.Instance.getPlayerData(owner); + PlayerData data = PlayerData.get(owner); if (!bo && data.hasCompanion()) return; data.setCompanion(bo ? null : npc); @@ -593,7 +594,9 @@ public class RoleCompanion extends RoleInterface { @Override public boolean defendOwner() { - return defendOwner && owner != null && stage != EnumCompanionStage.BABY && (jobInterface == null || !jobInterface.isSelfSufficient()); + if (!defendOwner || owner == null || stage == EnumCompanionStage.BABY || jobInterface != null && jobInterface.isSelfSufficient()) + return false; + return true; } public int followRange() { diff --git a/src/main/java/noppes/npcs/roles/RoleFollower.java b/src/main/java/noppes/npcs/roles/RoleFollower.java index 4b2c55382..f87f8f207 100644 --- a/src/main/java/noppes/npcs/roles/RoleFollower.java +++ b/src/main/java/noppes/npcs/roles/RoleFollower.java @@ -148,7 +148,7 @@ public class RoleFollower extends RoleInterface { public void setOwner(EntityPlayer player) { UUID id = player.getUniqueID(); - if (ownerUUID == null || !ownerUUID.equals(id)) + if (ownerUUID == null || id == null || !ownerUUID.equals(id)) killed(); ownerUUID = id.toString(); npc.stats.canDespawn = false; diff --git a/src/main/java/noppes/npcs/roles/RoleInterface.java b/src/main/java/noppes/npcs/roles/RoleInterface.java index 25b3fe523..ba62d199d 100644 --- a/src/main/java/noppes/npcs/roles/RoleInterface.java +++ b/src/main/java/noppes/npcs/roles/RoleInterface.java @@ -23,9 +23,13 @@ public abstract class RoleInterface { public void killed() { } + ; + public void delete() { } + ; + public boolean aiShouldExecute() { return false; } diff --git a/src/main/java/noppes/npcs/roles/RolePostman.java b/src/main/java/noppes/npcs/roles/RolePostman.java index 4cc48efb4..3d6da3e9d 100644 --- a/src/main/java/noppes/npcs/roles/RolePostman.java +++ b/src/main/java/noppes/npcs/roles/RolePostman.java @@ -15,7 +15,7 @@ import java.util.List; public class RolePostman extends RoleInterface { public NpcMiscInventory inventory = new NpcMiscInventory(1); - private final List recentlyChecked = new ArrayList(); + private List recentlyChecked = new ArrayList(); private List toCheck; public RolePostman(EntityNPCInterface npc) { diff --git a/src/main/java/noppes/npcs/roles/RoleTransporter.java b/src/main/java/noppes/npcs/roles/RoleTransporter.java index 40d16d294..519715b9f 100644 --- a/src/main/java/noppes/npcs/roles/RoleTransporter.java +++ b/src/main/java/noppes/npcs/roles/RoleTransporter.java @@ -6,8 +6,8 @@ import net.minecraft.util.ChatComponentTranslation; import noppes.npcs.NoppesUtilServer; import noppes.npcs.api.handler.data.ITransportLocation; import noppes.npcs.constants.EnumGuiType; -import noppes.npcs.controllers.PlayerDataController; import noppes.npcs.controllers.TransportController; +import noppes.npcs.controllers.data.PlayerData; import noppes.npcs.controllers.data.PlayerTransportData; import noppes.npcs.controllers.data.TransportLocation; import noppes.npcs.entity.EntityNPCInterface; @@ -82,7 +82,7 @@ public class RoleTransporter extends RoleInterface { } public void unlock(EntityPlayer player, ITransportLocation loc) { - PlayerTransportData data = PlayerDataController.Instance.getPlayerData(player).transportData; + PlayerTransportData data = PlayerData.get(player).transportData; if (data.transports.contains(transportId)) return; data.transports.add(transportId); diff --git a/src/main/java/noppes/npcs/roles/companion/CompanionGuard.java b/src/main/java/noppes/npcs/roles/companion/CompanionGuard.java index 8c3bef4e0..7753b8111 100644 --- a/src/main/java/noppes/npcs/roles/companion/CompanionGuard.java +++ b/src/main/java/noppes/npcs/roles/companion/CompanionGuard.java @@ -29,7 +29,10 @@ public class CompanionGuard extends CompanionJobInterface { else if (entity instanceof EntityCreeper) { return false; - } else return entity instanceof IMob; + } else if (entity instanceof IMob) { + return true; + } + return false; } public boolean isSelfSufficient() { diff --git a/src/main/java/noppes/npcs/scripted/NpcAPI.java b/src/main/java/noppes/npcs/scripted/NpcAPI.java index 4d035ae6a..54d86963d 100644 --- a/src/main/java/noppes/npcs/scripted/NpcAPI.java +++ b/src/main/java/noppes/npcs/scripted/NpcAPI.java @@ -3,6 +3,7 @@ package noppes.npcs.scripted; import cpw.mods.fml.common.Loader; import cpw.mods.fml.common.eventhandler.EventBus; import foxz.command.ScriptedCommand; +import kamkeel.npcs.controllers.AttributeController; import kamkeel.npcs.controllers.ProfileController; import net.minecraft.block.Block; import net.minecraft.command.CommandHandler; @@ -73,10 +74,10 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; public class NpcAPI extends AbstractNpcAPI { - private static final Map tempData = new HashMap<>(); + private static final Map tempData = new HashMap<>(); private static final Map worldCache = new LRUHashMap<>(10); - private static final CacheHashMap> scriptItemCache = new CacheHashMap<>(60*1000); - public static final HashMap engineObjects = new HashMap<>(); + private static final CacheHashMap> scriptItemCache = new CacheHashMap<>(60 * 1000); + public static final HashMap engineObjects = new HashMap<>(); public static final EventBus EVENT_BUS = new EventBus(); private static AbstractNpcAPI instance = null; @@ -91,23 +92,23 @@ public class NpcAPI extends AbstractNpcAPI { scriptItemCache.clear(); } - public Object getTempData(String key){ + public Object getTempData(String key) { return tempData.get(key); } - public void setTempData(String key, Object value){ + public void setTempData(String key, Object value) { tempData.put(key, value); } - public boolean hasTempData(String key){ + public boolean hasTempData(String key) { return tempData.containsKey(key); } - public void removeTempData(String key){ + public void removeTempData(String key) { tempData.remove(key); } - public void clearTempData(){ + public void clearTempData() { tempData.clear(); } @@ -115,35 +116,35 @@ public class NpcAPI extends AbstractNpcAPI { return tempData.keySet().toArray(new String[0]); } - public Object getStoredData(String key){ + public Object getStoredData(String key) { NBTTagCompound compound = ScriptController.Instance.compound; - if(!compound.hasKey(key)) + if (!compound.hasKey(key)) return null; NBTBase base = compound.getTag(key); - if(base instanceof NBTBase.NBTPrimitive) - return ((NBTBase.NBTPrimitive)base).func_150286_g(); - return ((NBTTagString)base).func_150285_a_(); + if (base instanceof NBTBase.NBTPrimitive) + return ((NBTBase.NBTPrimitive) base).func_150286_g(); + return ((NBTTagString) base).func_150285_a_(); } - public void setStoredData(String key, Object value){ + public void setStoredData(String key, Object value) { NBTTagCompound compound = ScriptController.Instance.compound; - if(value instanceof Number) + if (value instanceof Number) compound.setDouble(key, ((Number) value).doubleValue()); - else if(value instanceof String) - compound.setString(key, (String)value); + else if (value instanceof String) + compound.setString(key, (String) value); ScriptController.Instance.shouldSave = true; } - public boolean hasStoredData(String key){ + public boolean hasStoredData(String key) { return ScriptController.Instance.compound.hasKey(key); } - public void removeStoredData(String key){ + public void removeStoredData(String key) { ScriptController.Instance.compound.removeTag(key); ScriptController.Instance.shouldSave = true; } - public void clearStoredData(){ + public void clearStoredData() { ScriptController.Instance.compound = new NBTTagCompound(); ScriptController.Instance.shouldSave = true; } @@ -153,7 +154,7 @@ public class NpcAPI extends AbstractNpcAPI { if (compound != null) { Set keySet = compound.func_150296_c(); List list = new ArrayList<>(); - for(Object o : keySet){ + for (Object o : keySet) { list.add((String) o); } String[] array = list.toArray(new String[list.size()]); @@ -163,15 +164,15 @@ public class NpcAPI extends AbstractNpcAPI { } public void registerICommand(ICommand command) { - ((CommandHandler)CustomNpcs.getServer().getCommandManager()).registerCommand((ScriptedCommand) command); + ((CommandHandler) CustomNpcs.getServer().getCommandManager()).registerCommand((ScriptedCommand) command); } public ICommand getICommand(String commandName, int priorityLevel) { - return new ScriptedCommand(commandName,priorityLevel); + return new ScriptedCommand(commandName, priorityLevel); } public void addGlobalObject(String key, Object obj) { - NpcAPI.engineObjects.put(key,obj); + NpcAPI.engineObjects.put(key, obj); } public void removeGlobalObject(String key) { @@ -182,7 +183,7 @@ public class NpcAPI extends AbstractNpcAPI { return NpcAPI.engineObjects.containsKey(key); } - public HashMap getEngineObjects() { + public HashMap getEngineObjects() { return NpcAPI.engineObjects; } @@ -241,17 +242,30 @@ public class NpcAPI extends AbstractNpcAPI { return ServerCloneController.Instance; } - public INaturalSpawnsHandler getNaturalSpawns() { return SpawnController.Instance; } + public INaturalSpawnsHandler getNaturalSpawns() { + return SpawnController.Instance; + } - public IProfileHandler getProfileHandler() { return ProfileController.Instance; } + public IProfileHandler getProfileHandler() { + return ProfileController.Instance; + } - public ICustomEffectHandler getCustomEffectHandler() { return CustomEffectController.Instance; } + public ICustomEffectHandler getCustomEffectHandler() { + return CustomEffectController.Instance; + } - public IPartyHandler getPartyHandler() { return PartyController.Instance(); } public IMagicHandler getMagicHandler() { return MagicController.getInstance(); } + public IPartyHandler getPartyHandler() { + return PartyController.Instance(); + } + + public IAttributeHandler getAttributeHandler() { + return AttributeController.Instance; + } + public ITransportHandler getLocations() { return TransportController.getInstance(); } @@ -275,21 +289,21 @@ public class NpcAPI extends AbstractNpcAPI { public static Boolean dbcLoaded = null; + public IEntity getIEntity(Entity entity) { - if(entity == null) + if (entity == null) return null; - if(entity instanceof EntityNPCInterface) - return ((EntityNPCInterface)entity).wrappedNPC; - else{ + if (entity instanceof EntityNPCInterface) + return ((EntityNPCInterface) entity).wrappedNPC; + else { ScriptEntityData data = (ScriptEntityData) entity.getExtendedProperties("ScriptedObject"); if (data == null) { if (entity instanceof EntityPlayerMP) { - if(dbcLoaded == null){ + if (dbcLoaded == null) { dbcLoaded = Loader.isModLoaded("jinryuujrmcore"); } data = dbcLoaded ? new ScriptEntityData(new ScriptDBCPlayer<>((EntityPlayerMP) entity)) : new ScriptEntityData(new ScriptPlayer<>((EntityPlayerMP) entity)); - } - else if (PixelmonHelper.isPixelmon(entity)) + } else if (PixelmonHelper.isPixelmon(entity)) return new ScriptPixelmon((EntityTameable) entity); else if (entity instanceof EntityAnimal) data = new ScriptEntityData(new ScriptAnimal<>((EntityAnimal) entity)); @@ -339,14 +353,14 @@ public class NpcAPI extends AbstractNpcAPI { public IBlock getIBlock(IWorld world, int x, int y, int z) { Block block = world.getMCWorld().getBlock(x, y, z); - if(block == null || block.isAir(world.getMCWorld(), x, y, z)) + if (block == null || block.isAir(world.getMCWorld(), x, y, z)) return null; - return new ScriptBlock(world.getMCWorld(), world.getMCWorld().getBlock(x, y, z), new BlockPos(x,y,z)); + return new ScriptBlock(world.getMCWorld(), world.getMCWorld().getBlock(x, y, z), new BlockPos(x, y, z)); } public IBlock getIBlock(IWorld world, IPos pos) { - return pos == null ? null : this.getIBlock(world, pos.getX(),pos.getY(),pos.getZ()); + return pos == null ? null : this.getIBlock(world, pos.getX(), pos.getY(), pos.getZ()); } public ITileEntity getITileEntity(IWorld world, IPos pos) { @@ -354,12 +368,12 @@ public class NpcAPI extends AbstractNpcAPI { return null; } - TileEntity tileEntity = world.getMCWorld().getTileEntity(pos.getX(), pos.getY(),pos.getZ()); + TileEntity tileEntity = world.getMCWorld().getTileEntity(pos.getX(), pos.getY(), pos.getZ()); return this.getITileEntity(tileEntity); } public ITileEntity getITileEntity(IWorld world, int x, int y, int z) { - TileEntity tileEntity = world.getMCWorld().getTileEntity(x,y,z); + TileEntity tileEntity = world.getMCWorld().getTileEntity(x, y, z); return this.getITileEntity(tileEntity); } @@ -372,7 +386,7 @@ public class NpcAPI extends AbstractNpcAPI { } public IPos getIPos(double x, double y, double z) { - return this.getIPos(new BlockPos(x,y,z)); + return this.getIPos(new BlockPos(x, y, z)); } public IPos getIPos(int x, int y, int z) { @@ -390,7 +404,7 @@ public class NpcAPI extends AbstractNpcAPI { public IPos[] getAllInBox(IPos from, IPos to, boolean sortByDistance) { ArrayList list = new ArrayList<>(); if (from != null && to != null) { - Iterator posIterable = BlockPos.getAllInBox(from.getMCPos(),to.getMCPos()).iterator(); + Iterator posIterable = BlockPos.getAllInBox(from.getMCPos(), to.getMCPos()).iterator(); posIterable.forEachRemaining(BlockPos -> list.add(this.getIPos(BlockPos))); if (sortByDistance) { list.sort(Comparator.comparingDouble(pos -> pos.distanceTo(from))); @@ -400,11 +414,11 @@ public class NpcAPI extends AbstractNpcAPI { } public IPos[] getAllInBox(IPos from, IPos to) { - return this.getAllInBox(from,to,true); + return this.getAllInBox(from, to, true); } public INbt getINbt(NBTTagCompound nbtTagCompound) { - return nbtTagCompound == null?new ScriptNbt(new NBTTagCompound()):new ScriptNbt(nbtTagCompound); + return nbtTagCompound == null ? new ScriptNbt(new NBTTagCompound()) : new ScriptNbt(nbtTagCompound); } public INbt stringToNbt(String str) { @@ -433,7 +447,7 @@ public class NpcAPI extends AbstractNpcAPI { return null; } else { EntityCustomNpc npc = new EntityCustomNpc(world.getMCWorld()); - npc.setPositionAndRotation((double)x + 0.5D, y, (double)z + 0.5D, 0.0F, 0.0F); + npc.setPositionAndRotation((double) x + 0.5D, y, (double) z + 0.5D, 0.0F, 0.0F); npc.setHealth(npc.getMaxHealth()); world.getMCWorld().spawnEntityInWorld(npc); return npc.wrappedNPC; @@ -460,7 +474,7 @@ public class NpcAPI extends AbstractNpcAPI { } public IItemStack getIItemStack(ItemStack itemstack) { - if(itemstack == null) + if (itemstack == null) return null; synchronized (scriptItemCache) { @@ -524,10 +538,10 @@ public class NpcAPI extends AbstractNpcAPI { public IWorld getIWorldLoad(int dimensionId) { try { IWorld iWorld = this.getIWorld(dimensionId); - if(iWorld != null) + if (iWorld != null) return iWorld; + } catch (CustomNPCsException ignored) { } - catch (CustomNPCsException ignored){} WorldServer worldServer = CustomNpcs.getServer().worldServerForDimension(dimensionId); if (worldServer != null) { @@ -542,7 +556,7 @@ public class NpcAPI extends AbstractNpcAPI { } public IContainer getIContainer(Container container) { - return container instanceof ContainerNpcInterface ? ContainerNpcInterface.getOrCreateIContainer((ContainerNpcInterface)container) : new ScriptContainer(container); + return container instanceof ContainerNpcInterface ? ContainerNpcInterface.getOrCreateIContainer((ContainerNpcInterface) container) : new ScriptContainer(container); } private void checkWorld() { @@ -555,7 +569,7 @@ public class NpcAPI extends AbstractNpcAPI { this.checkWorld(); IWorld[] worlds = new IWorld[CustomNpcs.getServer().worldServers.length]; - for(int i = 0; i < CustomNpcs.getServer().worldServers.length; ++i) { + for (int i = 0; i < CustomNpcs.getServer().worldServers.length; ++i) { worlds[i] = this.getIWorld(CustomNpcs.getServer().worldServers[i]); } @@ -575,15 +589,15 @@ public class NpcAPI extends AbstractNpcAPI { } public IDamageSource getIDamageSource(IEntity entity) { - if(entity.getType() == 1)//if player - return new ScriptDamageSource(new EntityDamageSource("player",entity.getMCEntity())); + if (entity.getType() == 1)//if player + return new ScriptDamageSource(new EntityDamageSource("player", entity.getMCEntity())); else - return new ScriptDamageSource(new EntityDamageSource(entity.getTypeName(),entity.getMCEntity())); + return new ScriptDamageSource(new EntityDamageSource(entity.getTypeName(), entity.getMCEntity())); } public void executeCommand(IWorld world, String command) { //if(!world.getMCWorld().isRemote) - NoppesUtilServer.runCommand(world.getMCWorld(), "API", command); + NoppesUtilServer.runCommand(world.getMCWorld(), "API", command); } public String getRandomName(int dictionary, int gender) { @@ -599,11 +613,11 @@ public class NpcAPI extends AbstractNpcAPI { return player == null ? null : (IPlayer) NpcAPI.Instance().getIEntity(player); } - public IPlayer[] getAllServerPlayers(){ + public IPlayer[] getAllServerPlayers() { List list = MinecraftServer.getServer().getConfigurationManager().playerEntityList; IPlayer[] arr = new IPlayer[list.size()]; - for(int i = 0; i < list.size(); i++){ - arr[i] = (IPlayer) NpcAPI.Instance().getIEntity((EntityPlayerMP)list.get(i)); + for (int i = 0; i < list.size(); i++) { + arr[i] = (IPlayer) NpcAPI.Instance().getIEntity((EntityPlayerMP) list.get(i)); } return arr; @@ -613,30 +627,28 @@ public class NpcAPI extends AbstractNpcAPI { return MinecraftServer.getServer().getConfigurationManager().getAllUsernames(); } - public void playSoundAtEntity(IEntity entity, String sound, float volume, float pitch){ + public void playSoundAtEntity(IEntity entity, String sound, float volume, float pitch) { entity.getWorld().getMCWorld().playSoundAtEntity(entity.getMCEntity(), sound, volume, pitch); } - public void playSoundToNearExcept(IPlayer player, String sound, float volume, float pitch){ + public void playSoundToNearExcept(IPlayer player, String sound, float volume, float pitch) { player.getWorld().getMCWorld().playSoundToNearExcept(player.getMCEntity(), sound, volume, pitch); } - public String getMOTD() - { + public String getMOTD() { return MinecraftServer.getServer().getMOTD(); } - public void setMOTD(String motd) - { + public void setMOTD(String motd) { MinecraftServer.getServer().setMOTD(motd); } - public IParticle createParticle(String directory){ + public IParticle createParticle(String directory) { return new ScriptParticle(directory); } @Deprecated - public IParticle createEntityParticle(String directory){ + public IParticle createEntityParticle(String directory) { return new ScriptParticle(directory); } @@ -729,7 +741,7 @@ public class NpcAPI extends AbstractNpcAPI { } public IFrame createFrame(int duration, float speed, byte smooth) { - return new Frame(duration,speed,smooth); + return new Frame(duration, speed, smooth); } public IFramePart createPart(String name) { @@ -752,7 +764,7 @@ public class NpcAPI extends AbstractNpcAPI { } public IFramePart createPart(String name, float[] rotation, float[] pivot, float speed, byte smooth) { - FramePart part = (FramePart) this.createPart(name,rotation,pivot); + FramePart part = (FramePart) this.createPart(name, rotation, pivot); part.setSpeed(speed); part.setSmooth(smooth); return part; @@ -760,7 +772,7 @@ public class NpcAPI extends AbstractNpcAPI { public IFramePart createPart(int partId) { for (EnumAnimationPart part : EnumAnimationPart.values()) { - if (part.id == partId) { + if (part.ordinal() == partId) { return new FramePart(part); } } @@ -779,7 +791,7 @@ public class NpcAPI extends AbstractNpcAPI { } public IFramePart createPart(int partId, float[] rotation, float[] pivot, float speed, byte smooth) { - FramePart part = (FramePart) this.createPart(partId,rotation,pivot); + FramePart part = (FramePart) this.createPart(partId, rotation, pivot); part.setSpeed(speed); part.setSmooth(smooth); return part; diff --git a/src/main/java/noppes/npcs/scripted/ScriptBlock.java b/src/main/java/noppes/npcs/scripted/ScriptBlock.java index 9e4c2515f..074ba4269 100644 --- a/src/main/java/noppes/npcs/scripted/ScriptBlock.java +++ b/src/main/java/noppes/npcs/scripted/ScriptBlock.java @@ -116,14 +116,14 @@ public class ScriptBlock implements IBlock { public IContainer getContainer() { if (!this.isContainer()) { - throw new CustomNPCsException("This block is not a container"); + throw new CustomNPCsException("This block is not a container", new Object[0]); } else { return NpcAPI.Instance().getIContainer((IInventory) this.tile.getMCTileEntity()); } } public String getName() { - return Block.blockRegistry.getNameForObject(this.block); + return Block.blockRegistry.getNameForObject(this.block) + ""; } public String getDisplayName() { diff --git a/src/main/java/noppes/npcs/scripted/ScriptNbt.java b/src/main/java/noppes/npcs/scripted/ScriptNbt.java index 6dd7d032d..88471dc94 100644 --- a/src/main/java/noppes/npcs/scripted/ScriptNbt.java +++ b/src/main/java/noppes/npcs/scripted/ScriptNbt.java @@ -7,7 +7,7 @@ import noppes.npcs.util.NBTJsonUtil; import java.util.Iterator; public class ScriptNbt implements INbt { - private final NBTTagCompound compound; + private NBTTagCompound compound; public ScriptNbt(NBTTagCompound compound) { this.compound = compound; @@ -129,7 +129,7 @@ public class ScriptNbt implements INbt { if (b == null) { return 0; } else if (b.getId() != 9) { - throw new CustomNPCsException("NBT tag " + key + " isn't a list"); + throw new CustomNPCsException("NBT tag " + key + " isn\'t a list", new Object[0]); } else { return ((NBTTagList) b).func_150303_d(); } @@ -153,7 +153,7 @@ public class ScriptNbt implements INbt { } else if (nbt instanceof Integer) { list.appendTag(new NBTTagInt(((Integer) nbt).intValue())); } else if (nbt instanceof int[]) { - list.appendTag(new NBTTagIntArray((int[]) nbt)); + list.appendTag(new NBTTagIntArray((int[]) ((int[]) nbt))); } } @@ -166,7 +166,7 @@ public class ScriptNbt implements INbt { public void setCompound(String key, INbt value) { if (value == null) { - throw new CustomNPCsException("Value cant be null"); + throw new CustomNPCsException("Value cant be null", new Object[0]); } else { this.compound.setTag(key, value.getMCNBT()); } diff --git a/src/main/java/noppes/npcs/scripted/ScriptPixelmonPlayerData.java b/src/main/java/noppes/npcs/scripted/ScriptPixelmonPlayerData.java index ad18e47ce..25e0914f3 100644 --- a/src/main/java/noppes/npcs/scripted/ScriptPixelmonPlayerData.java +++ b/src/main/java/noppes/npcs/scripted/ScriptPixelmonPlayerData.java @@ -8,7 +8,7 @@ import noppes.npcs.compat.PixelmonHelper; import noppes.npcs.scripted.entity.ScriptPixelmon; public class ScriptPixelmonPlayerData implements IPixelmonPlayerData { - private final EntityPlayerMP player; + private EntityPlayerMP player; public ScriptPixelmonPlayerData(EntityPlayerMP player) { this.player = player; diff --git a/src/main/java/noppes/npcs/scripted/ScriptWorld.java b/src/main/java/noppes/npcs/scripted/ScriptWorld.java index 2a94093f6..a413910a3 100644 --- a/src/main/java/noppes/npcs/scripted/ScriptWorld.java +++ b/src/main/java/noppes/npcs/scripted/ScriptWorld.java @@ -631,21 +631,21 @@ public class ScriptWorld implements IWorld { } Vec3 vec32 = Vec3.createVectorHelper(startVec.xCoord, startVec.yCoord, startVec.zCoord); - l = (int) (vec32.xCoord = MathHelper.floor_double(startVec.xCoord)); + l = (int) (vec32.xCoord = (double) MathHelper.floor_double(startVec.xCoord)); if (b0 == 5) { --l; ++vec32.xCoord; } - i1 = (int) (vec32.yCoord = MathHelper.floor_double(startVec.yCoord)); + i1 = (int) (vec32.yCoord = (double) MathHelper.floor_double(startVec.yCoord)); if (b0 == 1) { --i1; ++vec32.yCoord; } - j1 = (int) (vec32.zCoord = MathHelper.floor_double(startVec.zCoord)); + j1 = (int) (vec32.zCoord = (double) MathHelper.floor_double(startVec.zCoord)); if (b0 == 3) { --j1; @@ -898,21 +898,21 @@ public class ScriptWorld implements IWorld { } Vec3 vec32 = Vec3.createVectorHelper(startVec.xCoord, startVec.yCoord, startVec.zCoord); - l = (int) (vec32.xCoord = MathHelper.floor_double(startVec.xCoord)); + l = (int) (vec32.xCoord = (double) MathHelper.floor_double(startVec.xCoord)); if (b0 == 5) { --l; ++vec32.xCoord; } - i1 = (int) (vec32.yCoord = MathHelper.floor_double(startVec.yCoord)); + i1 = (int) (vec32.yCoord = (double) MathHelper.floor_double(startVec.yCoord)); if (b0 == 1) { --i1; ++vec32.yCoord; } - j1 = (int) (vec32.zCoord = MathHelper.floor_double(startVec.zCoord)); + j1 = (int) (vec32.zCoord = (double) MathHelper.floor_double(startVec.zCoord)); if (b0 == 3) { --j1; diff --git a/src/main/java/noppes/npcs/scripted/ScriptedActionManager.java b/src/main/java/noppes/npcs/scripted/ScriptedActionManager.java index 2b36ff7df..d418f0250 100644 --- a/src/main/java/noppes/npcs/scripted/ScriptedActionManager.java +++ b/src/main/java/noppes/npcs/scripted/ScriptedActionManager.java @@ -3,18 +3,27 @@ package noppes.npcs.scripted; import noppes.npcs.api.handler.IActionManager; import noppes.npcs.api.handler.data.IAction; -import java.util.HashMap; +import java.util.Deque; import java.util.LinkedList; import java.util.Queue; import java.util.function.Consumer; +import java.util.function.Supplier; +/** + * Full-featured ActionManager: + * - delayed start, max-duration, tick-interval + * - chaining (getNext, getPrevious, scheduleAfter/Before) + * - per-action data + * - conditional actions + * - cancellation & clearing + */ public class ScriptedActionManager implements IActionManager { - private boolean isWorking; - private final Queue actionQueue = new LinkedList<>(); + private boolean isWorking = false; + private final Deque actionQueue = new LinkedList<>(); @Override - public IAction create(String name, int maxDuration, int startAfterTicks, Consumer action) { - return new CustomAction(name, maxDuration, startAfterTicks, action); + public IAction create(String name, int maxDuration, int startAfterTicks, Consumer task) { + return new Action(name, maxDuration, startAfterTicks, task); } @Override @@ -29,29 +38,32 @@ public class ScriptedActionManager implements IActionManager { @Override public void scheduleAction(IAction action) { - actionQueue.add(action); + actionQueue.addLast(action); } @Override - public void scheduleAction(String name, int maxDuration, int startAfterTicks, Consumer action) { - scheduleAction(create(name, maxDuration, startAfterTicks, action)); + public void scheduleAction(String name, int maxDuration, int startAfterTicks, Consumer task) { + scheduleAction(create(name, maxDuration, startAfterTicks, task)); } @Override public void scheduleActionAt(int index, IAction action) { - ((LinkedList) actionQueue).add(index, action); + if (index < 0 || index > actionQueue.size()) { + actionQueue.addLast(action); + } else { + ((LinkedList) actionQueue).add(index, action); + } } @Override public int getIndex(IAction action) { - if (action == null) - return -1; - return ((LinkedList) actionQueue).indexOf(action); + if (action == null) return -1; + return ((LinkedList) actionQueue).indexOf(action); } @Override public IAction getCurrentAction() { - return actionQueue.peek(); + return actionQueue.peekFirst(); } @Override @@ -59,57 +71,91 @@ public class ScriptedActionManager implements IActionManager { return actionQueue; } + @Override public void clear() { actionQueue.clear(); } + @Override + public boolean cancelAction(String name) { + for (IAction act : actionQueue) { + if (act.getName().equals(name)) { + ((LinkedList) actionQueue).remove(act); + return true; + } + } + return false; + } + + @Override + public void scheduleConditionalAction(String name, + int checkIntervalTicks, + Supplier predicate, + Consumer task) { + scheduleConditionalAction(name, checkIntervalTicks, predicate, task, -1); + } + + @Override + public void scheduleConditionalAction(String name, + int checkIntervalTicks, + Supplier predicate, + Consumer task, + int maxChecks) { + scheduleAction(new ConditionalAction(name, checkIntervalTicks, predicate, task, maxChecks)); + } + + /** + * Call once per tick from your main loop. + * + * @param ticksExisted the global tick count, used for modulo checks. + */ public void tick(int ticksExisted) { - if (isWorking) { - CustomAction current = (CustomAction) getCurrentAction(); - if (current != null) { - current.tick(ticksExisted); - if (current.isDone || current.duration >= current.maxDuration) { - current.destroy(); - actionQueue.poll(); - } + if (!isWorking) return; + IAction current = getCurrentAction(); + if (current instanceof ActionBase) { + ActionBase cab = (ActionBase) current; + cab.tick(ticksExisted); + if (cab.isDone() || cab.getDuration() >= cab.getMaxDuration()) { + actionQueue.pollFirst(); } } } - //Nested not static to access outer class instance - public class CustomAction implements IAction { - Consumer action; - private final HashMap data = new HashMap<>(); + // ──── base class for all custom actions ────────────────────────────────── - private final String name; - private int startAfterTicks; //number of ticks to start action after - private int count; //number of times action ran - private int duration; - private final int maxDuration; //duration since action began - private int updateEveryXTick = 5; + private abstract class ActionBase implements IAction { + protected final String name; + protected int startAfterTicks; + protected int count = 0; + protected int duration = 0; + protected final int maxDuration; + protected int updateEveryXTick = 5; + protected final Consumer task; + private boolean done = false; - private boolean isDone; - - public CustomAction(String name, int maxDuration, int startAfterTicks, Consumer task) { + protected ActionBase(String name, int maxDuration, int startAfterTicks, Consumer task) { this.name = name; this.maxDuration = maxDuration; this.startAfterTicks = startAfterTicks; - this.action = task; + this.task = task; } - private void tick(int ticksExisted) { - if (startAfterTicks <= 0) { - if (ticksExisted % updateEveryXTick == 0) { - action.accept(this); - count++; - } - duration++; - } else + /** + * Called once per global tick; respects delay, interval, duration & done‐flag. + */ + public void tick(int ticksExisted) { + if (done) return; + + if (startAfterTicks > 0) { startAfterTicks--; - } - - private void destroy() { - data.clear(); + return; + } + // only run on our update tick + if (ticksExisted % updateEveryXTick == 0) { + task.accept(this); + count++; + } + duration++; } @Override @@ -134,22 +180,22 @@ public class ScriptedActionManager implements IActionManager { @Override public void markDone() { - isDone = true; + done = true; } @Override public boolean isDone() { - return isDone; + return done; } @Override public Object getData(String key) { - return data.get(key); + return dataStore.get(key); } @Override - public void addData(String key, Object value) { - data.put(key, value); + public void addData(String key, Object v) { + dataStore.put(key, v); } @Override @@ -158,8 +204,8 @@ public class ScriptedActionManager implements IActionManager { } @Override - public void setUpdateEveryXTick(int X) { - this.updateEveryXTick = X; + public void setUpdateEveryXTick(int x) { + updateEveryXTick = x; } @Override @@ -168,46 +214,85 @@ public class ScriptedActionManager implements IActionManager { } @Override - public IAction create(String name, int maxDuration, int startAfterTicks, Consumer action) { - return ScriptedActionManager.this.create(name, maxDuration, startAfterTicks, action); + public IAction create(String n, int md, int sat, Consumer t) { + return ScriptedActionManager.this.create(n, md, sat, t); } @Override public IAction getNext() { - int index = getIndex(this); - if (index != -1 && index + 1 < actionQueue.size()) - return ((LinkedList) actionQueue).get(index + 1); - - return null; + int idx = getIndex(this); + return (idx >= 0 && idx + 1 < actionQueue.size()) + ? ((LinkedList) actionQueue).get(idx + 1) + : null; } @Override public IAction getPrevious() { - int index = getIndex(this); - - if (index == 0) - return null; - else if (index != -1) - return ((LinkedList) actionQueue).get(index - 1); - - return null; + int idx = getIndex(this); + return (idx > 0) + ? ((LinkedList) actionQueue).get(idx - 1) + : null; } @Override public void scheduleAfter(IAction after) { - int index = getIndex(this); - if (index != -1) - scheduleActionAt(index + 1, after); + int idx = getIndex(this); + if (idx >= 0) scheduleActionAt(idx + 1, after); } @Override public void scheduleBefore(IAction before) { - int index = getIndex(this); - if (index != -1) - scheduleActionAt(index == 0 ? 0 : index - 1, before); + int idx = getIndex(this); + if (idx >= 0) scheduleActionAt(Math.max(0, idx), before); } + + private final java.util.Map dataStore = new java.util.HashMap<>(); + } + + private class Action extends ActionBase { + public Action(String name, int maxDuration, int startAfterTicks, Consumer task) { + super(name, maxDuration, startAfterTicks, task); + } + + @Override public int getCheckCount() { return 0; } + + @Override public int getMaxChecks() { return 0; } + } + + private class ConditionalAction extends ActionBase { + private final Supplier predicate; + private final int maxChecks; + private int checkCount = 0; + + public ConditionalAction(String name, + int checkIntervalTicks, + Supplier predicate, + Consumer task, + int maxChecks) { + super(name, Integer.MAX_VALUE, 0, task); + this.predicate = predicate; + this.updateEveryXTick = checkIntervalTicks; + this.maxChecks = maxChecks; + } + + @Override + public void tick(int ticksExisted) { + if (isDone()) return; + if (ticksExisted % updateEveryXTick == 0) { + checkCount++; + if (maxChecks >= 0 && checkCount > maxChecks) { + markDone(); + return; + } + if (predicate.get()) { + task.accept(this); + markDone(); + } + } + } + + @Override public int getCheckCount() { return checkCount; } + + @Override public int getMaxChecks() { return maxChecks; } } } - - - diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptDBCPlayer.java b/src/main/java/noppes/npcs/scripted/entity/ScriptDBCPlayer.java index b5715d4e7..c1f4f9bb2 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptDBCPlayer.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptDBCPlayer.java @@ -71,7 +71,7 @@ public class ScriptDBCPlayer extends ScriptPlayer i } throw new CustomNPCsException("Invalid stat name: " + stat + "\nValid stat names are:" + - "\nstr, dex, con, wil, mnd, spi\nstrength, dexterity, constitution, willpower, mind, spirit"); + "\nstr, dex, con, wil, mnd, spi\nstrength, dexterity, constitution, willpower, mind, spirit", new Object[0]); } private double applyOperator(String method, double n1, double n2) { @@ -124,11 +124,10 @@ public class ScriptDBCPlayer extends ScriptPlayer i for (String s : actions) { if (s.equals(action.toLowerCase())) { valid = true; - break; } } if (!valid) { - throw new CustomNPCsException("Action can be: get/remove/clear"); + throw new CustomNPCsException("Action can be: get/remove/clear", new Object[0]); } return bonusAttribute(action, stat, bonusID, "*", 1.0, false); @@ -142,11 +141,10 @@ public class ScriptDBCPlayer extends ScriptPlayer i for (String s : actions) { if (s.equals(action.toLowerCase())) { valid = true; - break; } } if (!valid) { - throw new CustomNPCsException("Action can be: add/addTo/set/get/remove/clear"); + throw new CustomNPCsException("Action can be: add/addTo/set/get/remove/clear", new Object[0]); } if (!action.equals("remove") && !action.equals("get") && !action.equals("clear")) { @@ -154,11 +152,10 @@ public class ScriptDBCPlayer extends ScriptPlayer i for (String s : operations) { if (s.equals(operation)) { valid = true; - break; } } if (!valid) { - throw new CustomNPCsException("Operation can be: + - * / %"); + throw new CustomNPCsException("Operation can be: + - * / %", new Object[0]); } } @@ -185,11 +182,11 @@ public class ScriptDBCPlayer extends ScriptPlayer i } if (!(stat.equals("str") || stat.equals("dex") || stat.equals("con") || stat.equals("wil") || stat.equals("mnd") || stat.equals("spi"))) throw new CustomNPCsException("Invalid stat name: " + stat + "\nValid stat names are:" + - "\nstr, dex, con, wil, mnd, spi\nstrength, dexterity, constitution, willpower, mind, spirit"); + "\nstr, dex, con, wil, mnd, spi\nstrength, dexterity, constitution, willpower, mind, spirit", new Object[0]); String bonusValueString = operation + attributeValue; String bonus = player.getEntityData().getCompoundTag("PlayerPersisted").getString("jrmcAttrBonus" + stat); - String[] bonuses = bonus.split("\\|"); + String bonuses[] = bonus.split("\\|"); String[][] bonusValues = new String[bonuses.length][2]; if (bonuses.length > 0 && bonuses[0].length() > 0) { for (int i = 0; i < bonuses.length; ++i) { @@ -496,17 +493,24 @@ public class ScriptDBCPlayer extends ScriptPlayer i } public IItemStack[] getInventory() { + // Get the base inventory from the super class + IItemStack[] baseInventory = super.getInventory(); + + // Load extra items from the NBT data NBTTagCompound compound = new NBTTagCompound(); this.player.writeToNBT(compound); - - NBTTagList list = compound.getCompoundTag("JRMCEP").getTagList("dbcExtraInvTag", 10); - IItemStack[] itemList = new IItemStack[list.tagCount()]; - for (int i = 0; i < list.tagCount(); i++) { - ItemStack itemStack = ItemStack.loadItemStackFromNBT(list.getCompoundTagAt(i)); - itemList[i] = NpcAPI.Instance().getIItemStack(itemStack); + NBTTagList extraList = compound.getCompoundTag("JRMCEP").getTagList("dbcExtraInvTag", 10); + IItemStack[] extraInventory = new IItemStack[extraList.tagCount()]; + for (int i = 0; i < extraList.tagCount(); i++) { + ItemStack itemStack = ItemStack.loadItemStackFromNBT(extraList.getCompoundTagAt(i)); + extraInventory[i] = NpcAPI.Instance().getIItemStack(itemStack); } - return itemList; + // Combine base and extra inventories + IItemStack[] fullInventory = new IItemStack[baseInventory.length + extraInventory.length]; + System.arraycopy(baseInventory, 0, fullInventory, 0, baseInventory.length); + System.arraycopy(extraInventory, 0, fullInventory, baseInventory.length, extraInventory.length); + return fullInventory; } public void setForm(byte form) { @@ -820,7 +824,7 @@ public class ScriptDBCPlayer extends ScriptPlayer i return evilKills + goodKills + neutKills; } - throw new CustomNPCsException("Invalid kill type: " + type + "\nValid kill types are: evil, good, neutral, all"); + throw new CustomNPCsException("Invalid kill type: " + type + "\nValid kill types are: evil, good, neutral, all", new Object[0]); } public String getFusionString() { diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptEntity.java b/src/main/java/noppes/npcs/scripted/entity/ScriptEntity.java index 1935f4fe2..7564562f8 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptEntity.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptEntity.java @@ -289,6 +289,7 @@ public class ScriptEntity implements IEntity { */ public void setX(double x) { entity.setPosition(x, entity.posY, entity.posZ); + ; } /** @@ -317,6 +318,7 @@ public class ScriptEntity implements IEntity { */ public void setZ(double z) { entity.setPosition(entity.posX, entity.posY, z); + ; } /** @@ -437,10 +439,10 @@ public class ScriptEntity implements IEntity { if (world != null) { WorldServer mcWorld = world.getMCWorld(); if (this.entity.riddenByEntity != null) { - this.entity.riddenByEntity.mountEntity(null); + this.entity.riddenByEntity.mountEntity((Entity) null); } if (this.entity.ridingEntity != null) { - this.entity.mountEntity(null); + this.entity.mountEntity((Entity) null); } WorldServer prevWorld = ((WorldServer) this.entity.worldObj); prevWorld.unloadEntities(new ArrayList(Collections.singleton(this.entity))); @@ -730,6 +732,7 @@ public class ScriptEntity implements IEntity { public void setRider(IEntity entity) { if (entity != null) { entity.getMCEntity().mountEntity(this.entity); + ; } else if (this.entity.riddenByEntity != null) this.entity.riddenByEntity.mountEntity(null); } @@ -916,7 +919,7 @@ public class ScriptEntity implements IEntity { public void storeAsClone(int tab, String name) { NBTTagCompound compound = new NBTTagCompound(); if (!this.entity.writeToNBTOptional(compound)) { - throw new CustomNPCsException("Cannot store dead entities"); + throw new CustomNPCsException("Cannot store dead entities", new Object[0]); } else { ServerCloneController.Instance.addClone(compound, name, tab); } diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptLivingBase.java b/src/main/java/noppes/npcs/scripted/entity/ScriptLivingBase.java index cf2859b76..edf9d2d29 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptLivingBase.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptLivingBase.java @@ -58,7 +58,7 @@ public class ScriptLivingBase extends ScriptEntity extends ScriptLiving implemen @Override public boolean typeOf(int type) { - return type == EntityType.MONSTER || super.typeOf(type); + return type == EntityType.MONSTER ? true : super.typeOf(type); } } diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java b/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java index 36b9ffeb3..8ffb84820 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java @@ -1,6 +1,7 @@ package noppes.npcs.scripted.entity; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; import noppes.npcs.NoppesUtilServer; import noppes.npcs.api.IPos; import noppes.npcs.api.ITimers; @@ -291,7 +292,7 @@ public class ScriptNpc extends ScriptLiving imp @Override public boolean typeOf(int type) { - return type == EntityType.NPC || super.typeOf(type); + return type == EntityType.NPC ? true : super.typeOf(type); } /** @@ -518,11 +519,21 @@ public class ScriptNpc extends ScriptLiving imp } public boolean canAimWhileShooting() { - return !npc.stats.aimWhileShooting; + return npc.stats.aimType == 1; } - public void aimWhileShooting(boolean aimWhileShooting) { - npc.stats.aimWhileShooting = aimWhileShooting; + public void aimWhileShooting(boolean aimWhileShooting){ + npc.stats.aimType = (byte) (aimWhileShooting ? 1 : 0); + } + + public void setAimType(byte aimWhileShooting) { + if(aimWhileShooting < 0 || aimWhileShooting > 2) + return; + npc.stats.aimType = aimWhileShooting; + } + + public byte getAimType() { + return npc.stats.aimType; } public void setMinProjectileDelay(int minDelay) { @@ -634,7 +645,7 @@ public class ScriptNpc extends ScriptLiving imp */ public void setLootItem(int slot, IItemStack item) { if (item == null || item.getMCItemStack() == null) { - npc.inventory.setInventorySlotContents(slot + 7, null); + npc.inventory.setInventorySlotContents(slot + 7, (ItemStack) null); } else { npc.inventory.setInventorySlotContents(slot + 7, item.getMCItemStack()); } @@ -740,10 +751,8 @@ public class ScriptNpc extends ScriptLiving imp public void setTacticalVariant(String variant) { boolean found = false; for (String s : EnumNavType.names()) { - if (s.equals(variant)) { + if (s.equals(variant)) found = true; - break; - } } if (!found) @@ -770,10 +779,8 @@ public class ScriptNpc extends ScriptLiving imp public void setCombatPolicy(String variant) { boolean found = false; for (String s : EnumCombatPolicy.names()) { - if (s.equals(variant)) { + if (s.equals(variant)) found = true; - break; - } } if (!found) @@ -1266,7 +1273,7 @@ public class ScriptNpc extends ScriptLiving imp } public ITimers getTimers() { - return this.npc.timers; + return ((EntityNPCInterface) this.npc).timers; } public void setFly(int fly) { diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptPixelmon.java b/src/main/java/noppes/npcs/scripted/entity/ScriptPixelmon.java index 248845d1e..f8c585899 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptPixelmon.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptPixelmon.java @@ -8,7 +8,7 @@ import noppes.npcs.scripted.constants.EntityType; import noppes.npcs.util.ValueUtil; public class ScriptPixelmon extends ScriptAnimal implements IPixelmon { - private final T pixelmon; + private T pixelmon; private NBTTagCompound compound = null; public ScriptPixelmon(T pixelmon) { diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java b/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java index 3dbc07d1e..c7187d9aa 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java @@ -1,5 +1,6 @@ package noppes.npcs.scripted.entity; +import kamkeel.npcs.controllers.AttributeController; import kamkeel.npcs.network.PacketHandler; import kamkeel.npcs.network.packets.data.AchievementPacket; import kamkeel.npcs.network.packets.data.ChatAlertPacket; @@ -199,7 +200,7 @@ public class ScriptPlayer extends ScriptLivingBase } public boolean hasReadDialog(int id) { - PlayerDialogData data = PlayerDataController.Instance.getPlayerData(player).dialogData; + PlayerDialogData data = PlayerData.get(player).dialogData; return data.dialogsRead.contains(id); } @@ -252,12 +253,12 @@ public class ScriptPlayer extends ScriptLivingBase } public boolean hasFinishedQuest(int id) { - PlayerQuestData data = PlayerDataController.Instance.getPlayerData(player).questData; + PlayerQuestData data = PlayerData.get(player).questData; return data.finishedQuests.containsKey(id); } public boolean hasActiveQuest(int id) { - PlayerQuestData data = PlayerDataController.Instance.getPlayerData(player).questData; + PlayerQuestData data = PlayerData.get(player).questData; return data.activeQuests.containsKey(id); } @@ -270,14 +271,14 @@ public class ScriptPlayer extends ScriptLivingBase Quest quest = QuestController.Instance.quests.get(id); if (quest == null) return; - PlayerData data = PlayerDataController.Instance.getPlayerData(player); + PlayerData data = PlayerData.get(player); if (data.questData.activeQuests.containsKey(id)) return; QuestData questdata = new QuestData(quest); data.questData.activeQuests.put(id, questdata); - AchievementPacket.sendAchievement(player, false, "quest.newquest", quest.title); - ChatAlertPacket.sendChatAlert(player, "quest.newquest", ": ", quest.title); + AchievementPacket.sendAchievement((EntityPlayerMP) player, false, "quest.newquest", quest.title); + ChatAlertPacket.sendChatAlert((EntityPlayerMP) player, "quest.newquest", ": ", quest.title); data.updateClient = true; } @@ -304,7 +305,7 @@ public class ScriptPlayer extends ScriptLivingBase Quest quest = QuestController.Instance.quests.get(id); if (quest == null) return; - PlayerData data = PlayerDataController.Instance.getPlayerData(player); + PlayerData data = PlayerData.get(player); data.questData.activeQuests.remove(id); data.updateClient = true; } @@ -331,7 +332,7 @@ public class ScriptPlayer extends ScriptLivingBase @Override public boolean typeOf(int type) { - return type == EntityType.PLAYER || super.typeOf(type); + return type == EntityType.PLAYER ? true : super.typeOf(type); } /** @@ -339,7 +340,7 @@ public class ScriptPlayer extends ScriptLivingBase * @param points The points to increase. Use negative values to decrease */ public void addFactionPoints(int faction, int points) { - PlayerData data = PlayerDataController.Instance.getPlayerData(player); + PlayerData data = PlayerData.get(player); data.factionData.increasePoints(faction, points, player); } @@ -348,7 +349,7 @@ public class ScriptPlayer extends ScriptLivingBase * @param points The new point value for this faction */ public void setFactionPoints(int faction, int points) { - PlayerData data = PlayerDataController.Instance.getPlayerData(player); + PlayerData data = PlayerData.get(player); data.factionData.increasePoints(faction, points - getFactionPoints(faction), player); } @@ -357,7 +358,7 @@ public class ScriptPlayer extends ScriptLivingBase * @return points */ public int getFactionPoints(int faction) { - PlayerData data = PlayerDataController.Instance.getPlayerData(player); + PlayerData data = PlayerData.get(player); return data.factionData.getFactionPoints(faction); } @@ -603,6 +604,11 @@ public class ScriptPlayer extends ScriptLivingBase NoppesUtilPlayer.teleportPlayer(player, player.posX, player.posY, player.posZ, rotationYaw, rotationPitch, player.dimension); } + @Override + public float getRotation(){ + return entity.rotationYaw; + } + public void swingHand() { NoppesUtilPlayer.swingPlayerArm(player); } @@ -712,18 +718,18 @@ public class ScriptPlayer extends ScriptLivingBase } public ITimers getTimers() { - return PlayerDataController.Instance.getPlayerData(player).timers; + return PlayerData.get(player).timers; } @Override public IScreenSize getScreenSize() { - PlayerData data = PlayerDataController.Instance.getPlayerData(player); + PlayerData data = PlayerData.get(player); return data.getScreenSize(); } public void updatePlayerInventory() { - this.entity.inventoryContainer.detectAndSendChanges(); - PlayerData playerData = PlayerDataController.Instance.getPlayerData(player); + ((EntityPlayerMP) this.entity).inventoryContainer.detectAndSendChanges(); + PlayerData playerData = PlayerData.get(player); PlayerQuestData questData = playerData.questData; Party playerParty = playerData.getPlayerParty(); if (playerParty != null) @@ -735,7 +741,7 @@ public class ScriptPlayer extends ScriptLivingBase @Deprecated public boolean checkGUIOpen() { NoppesUtilPlayer.isGUIOpen(player); - PlayerData data = PlayerDataController.Instance.getPlayerData(player); + PlayerData data = PlayerData.get(player); return data.getGUIOpen(); } @@ -750,7 +756,7 @@ public class ScriptPlayer extends ScriptLivingBase public PlayerData getData() { if (this.data == null) { - this.data = PlayerDataController.Instance.getPlayerData(player); + this.data = PlayerData.get(player); } return this.data; @@ -767,17 +773,17 @@ public class ScriptPlayer extends ScriptLivingBase while (var3.hasNext()) { int id = (Integer) var3.next(); - IQuest quest = QuestController.Instance.quests.get(id); + IQuest quest = (IQuest) QuestController.Instance.quests.get(id); if (quest != null) { quests.add(quest); } } - return quests.toArray(new IQuest[quests.size()]); + return (IQuest[]) quests.toArray(new IQuest[quests.size()]); } public IContainer getOpenContainer() { - return NpcAPI.Instance().getIContainer(this.entity.openContainer); + return NpcAPI.Instance().getIContainer(((EntityPlayerMP) this.entity).openContainer); } public void showCustomGui(ICustomGui gui) { @@ -785,11 +791,11 @@ public class ScriptPlayer extends ScriptLivingBase } public ICustomGui getCustomGui() { - return this.entity.openContainer instanceof ContainerCustomGui ? ((ContainerCustomGui) this.entity.openContainer).customGui : null; + return ((EntityPlayerMP) this.entity).openContainer instanceof ContainerCustomGui ? ((ContainerCustomGui) ((EntityPlayerMP) this.entity).openContainer).customGui : null; } public void closeGui() { - this.entity.closeContainer(); + ((EntityPlayerMP) this.entity).closeContainer(); GuiClosePacket.closeGUI(player, -1, new NBTTagCompound()); } @@ -798,7 +804,7 @@ public class ScriptPlayer extends ScriptLivingBase } public void closeOverlay(int id) { - PacketHandler.Instance.sendToPlayer(new ScriptOverlayClosePacket(id), this.entity); + PacketHandler.Instance.sendToPlayer(new ScriptOverlayClosePacket(id), (EntityPlayerMP) this.entity); } public IOverlayHandler getOverlays() { @@ -816,13 +822,13 @@ public class ScriptPlayer extends ScriptLivingBase while (var3.hasNext()) { int id = (Integer) var3.next(); - IQuest quest = QuestController.Instance.quests.get(id); + IQuest quest = (IQuest) QuestController.Instance.quests.get(id); if (quest != null) { quests.add(quest); } } - return quests.toArray(new IQuest[quests.size()]); + return (IQuest[]) quests.toArray(new IQuest[quests.size()]); } public void setConqueredEnd(boolean conqueredEnd) { @@ -836,4 +842,6 @@ public class ScriptPlayer extends ScriptLivingBase public IMagicData getMagicData() { return this.getData().magicData; } + + public IPlayerAttributes getAttributes(){ return AttributeController.getTracker(this.player); } } diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptProjectile.java b/src/main/java/noppes/npcs/scripted/entity/ScriptProjectile.java index e4bd7401b..538b46f5e 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptProjectile.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptProjectile.java @@ -46,7 +46,7 @@ public class ScriptProjectile extends ScriptEntity extends ScriptEntity extends ScriptLiving im @Override public IEntityLivingBase getCustomer() { - return NpcAPI.Instance().getPlayer(entity.getCustomer().getCommandSenderName()); + return (IEntityLivingBase) NpcAPI.Instance().getPlayer(entity.getCustomer().getCommandSenderName()); } @Override diff --git a/src/main/java/noppes/npcs/scripted/event/ForgeEvent.java b/src/main/java/noppes/npcs/scripted/event/ForgeEvent.java index 90ad5929f..a4704f5f1 100644 --- a/src/main/java/noppes/npcs/scripted/event/ForgeEvent.java +++ b/src/main/java/noppes/npcs/scripted/event/ForgeEvent.java @@ -61,7 +61,7 @@ public class ForgeEvent extends CustomNPCsEvent implements IForgeEvent { public static class InitEvent extends ForgeEvent implements IForgeEvent.InitEvent { public InitEvent() { - super(null); + super((Event) null); } public String getHookName() { diff --git a/src/main/java/noppes/npcs/scripted/event/NpcEvent.java b/src/main/java/noppes/npcs/scripted/event/NpcEvent.java index 02472638e..0cc75792d 100644 --- a/src/main/java/noppes/npcs/scripted/event/NpcEvent.java +++ b/src/main/java/noppes/npcs/scripted/event/NpcEvent.java @@ -226,7 +226,7 @@ public class NpcEvent extends CustomNPCsEvent implements INpcEvent { public SwingEvent(ICustomNpc npc, ItemStack itemStack) { super(npc); - this.itemStack = itemStack == null ? null : NpcAPI.Instance().getIItemStack(itemStack); + this.itemStack = itemStack == null ? null : (IItemStack) NpcAPI.Instance().getIItemStack(itemStack); } public String getHookName() { diff --git a/src/main/java/noppes/npcs/scripted/event/CustomGuiEvent.java b/src/main/java/noppes/npcs/scripted/event/player/CustomGuiEvent.java similarity index 95% rename from src/main/java/noppes/npcs/scripted/event/CustomGuiEvent.java rename to src/main/java/noppes/npcs/scripted/event/player/CustomGuiEvent.java index 3aaba5788..c6014c111 100644 --- a/src/main/java/noppes/npcs/scripted/event/CustomGuiEvent.java +++ b/src/main/java/noppes/npcs/scripted/event/player/CustomGuiEvent.java @@ -1,4 +1,4 @@ -package noppes.npcs.scripted.event; +package noppes.npcs.scripted.event.player; import cpw.mods.fml.common.eventhandler.Cancelable; import net.minecraft.item.ItemStack; @@ -10,12 +10,11 @@ import noppes.npcs.api.item.IItemStack; import noppes.npcs.constants.EnumScriptType; import noppes.npcs.scripted.NpcAPI; -public class CustomGuiEvent extends CustomNPCsEvent implements ICustomGuiEvent { - public final IPlayer player; +public class CustomGuiEvent extends PlayerEvent implements ICustomGuiEvent { public final ICustomGui gui; public CustomGuiEvent(IPlayer player, ICustomGui gui) { - this.player = player; + super(player); this.gui = gui; } @@ -23,10 +22,6 @@ public class CustomGuiEvent extends CustomNPCsEvent implements ICustomGuiEvent { return EnumScriptType.CUSTOM_GUI_EVENT.function; } - public IPlayer getPlayer() { - return this.player; - } - public ICustomGui getGui() { return gui; } diff --git a/src/main/java/noppes/npcs/scripted/event/DialogEvent.java b/src/main/java/noppes/npcs/scripted/event/player/DialogEvent.java similarity index 86% rename from src/main/java/noppes/npcs/scripted/event/DialogEvent.java rename to src/main/java/noppes/npcs/scripted/event/player/DialogEvent.java index 0d489279d..a5ebfc1ff 100644 --- a/src/main/java/noppes/npcs/scripted/event/DialogEvent.java +++ b/src/main/java/noppes/npcs/scripted/event/player/DialogEvent.java @@ -1,4 +1,4 @@ -package noppes.npcs.scripted.event; +package noppes.npcs.scripted.event.player; import cpw.mods.fml.common.eventhandler.Cancelable; import noppes.npcs.api.entity.IPlayer; @@ -6,17 +6,12 @@ import noppes.npcs.api.event.IDialogEvent; import noppes.npcs.api.handler.data.IDialog; import noppes.npcs.constants.EnumScriptType; -public class DialogEvent extends CustomNPCsEvent implements IDialogEvent { +public class DialogEvent extends PlayerEvent implements IDialogEvent { public final IDialog dialog; - public final IPlayer player; public DialogEvent(IPlayer player, IDialog dialog) { + super(player); this.dialog = dialog; - this.player = player; - } - - public IPlayer getPlayer() { - return player; } public IDialog getDialog() { diff --git a/src/main/java/noppes/npcs/scripted/event/FactionEvent.java b/src/main/java/noppes/npcs/scripted/event/player/FactionEvent.java similarity index 83% rename from src/main/java/noppes/npcs/scripted/event/FactionEvent.java rename to src/main/java/noppes/npcs/scripted/event/player/FactionEvent.java index 5898e37f5..fe2d4a644 100644 --- a/src/main/java/noppes/npcs/scripted/event/FactionEvent.java +++ b/src/main/java/noppes/npcs/scripted/event/player/FactionEvent.java @@ -1,4 +1,4 @@ -package noppes.npcs.scripted.event; +package noppes.npcs.scripted.event.player; import cpw.mods.fml.common.eventhandler.Cancelable; import noppes.npcs.api.entity.IPlayer; @@ -6,17 +6,12 @@ import noppes.npcs.api.event.IFactionEvent; import noppes.npcs.api.handler.data.IFaction; import noppes.npcs.constants.EnumScriptType; -public class FactionEvent extends CustomNPCsEvent implements IFactionEvent { +public class FactionEvent extends PlayerEvent implements IFactionEvent { public final IFaction faction; - public final IPlayer player; public FactionEvent(IPlayer player, IFaction faction) { + super(player); this.faction = faction; - this.player = player; - } - - public IPlayer getPlayer() { - return player; } public IFaction getFaction() { diff --git a/src/main/java/noppes/npcs/scripted/event/PlayerEvent.java b/src/main/java/noppes/npcs/scripted/event/player/PlayerEvent.java similarity index 99% rename from src/main/java/noppes/npcs/scripted/event/PlayerEvent.java rename to src/main/java/noppes/npcs/scripted/event/player/PlayerEvent.java index 74bd4e30c..0fae26ab0 100644 --- a/src/main/java/noppes/npcs/scripted/event/PlayerEvent.java +++ b/src/main/java/noppes/npcs/scripted/event/player/PlayerEvent.java @@ -1,4 +1,4 @@ -package noppes.npcs.scripted.event; +package noppes.npcs.scripted.event.player; import cpw.mods.fml.common.eventhandler.Cancelable; import net.minecraft.entity.Entity; @@ -19,6 +19,7 @@ import noppes.npcs.api.handler.data.IProfile; import noppes.npcs.api.item.IItemStack; import noppes.npcs.constants.EnumScriptType; import noppes.npcs.scripted.NpcAPI; +import noppes.npcs.scripted.event.CustomNPCsEvent; public class PlayerEvent extends CustomNPCsEvent implements IPlayerEvent { public final IPlayer player; diff --git a/src/main/java/noppes/npcs/scripted/event/QuestEvent.java b/src/main/java/noppes/npcs/scripted/event/player/QuestEvent.java similarity index 89% rename from src/main/java/noppes/npcs/scripted/event/QuestEvent.java rename to src/main/java/noppes/npcs/scripted/event/player/QuestEvent.java index 264e6f8c8..24afcb21e 100644 --- a/src/main/java/noppes/npcs/scripted/event/QuestEvent.java +++ b/src/main/java/noppes/npcs/scripted/event/player/QuestEvent.java @@ -1,4 +1,4 @@ -package noppes.npcs.scripted.event; +package noppes.npcs.scripted.event.player; import cpw.mods.fml.common.eventhandler.Cancelable; import noppes.npcs.api.entity.IPlayer; @@ -7,17 +7,12 @@ import noppes.npcs.api.handler.data.IQuest; import noppes.npcs.api.item.IItemStack; import noppes.npcs.constants.EnumScriptType; -public class QuestEvent extends CustomNPCsEvent implements IQuestEvent { +public class QuestEvent extends PlayerEvent implements IQuestEvent { public final IQuest quest; - public final IPlayer player; public QuestEvent(IPlayer player, IQuest quest) { + super(player); this.quest = quest; - this.player = player; - } - - public IPlayer getPlayer() { - return player; } public IQuest getQuest() { diff --git a/src/main/java/noppes/npcs/scripted/gui/ScriptGui.java b/src/main/java/noppes/npcs/scripted/gui/ScriptGui.java index 14fe70005..a3d5a62be 100644 --- a/src/main/java/noppes/npcs/scripted/gui/ScriptGui.java +++ b/src/main/java/noppes/npcs/scripted/gui/ScriptGui.java @@ -1,5 +1,6 @@ package noppes.npcs.scripted.gui; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; @@ -63,8 +64,8 @@ public class ScriptGui implements ICustomGui { return this.slots; } - public PlayerDataScript getScriptHandler() { - return ScriptController.Instance.playerScripts;//this.scriptHandler; + public PlayerDataScript getScriptHandler(EntityPlayer player) { + return ScriptController.Instance.getPlayerScripts(player); } public void setSize(int width, int height) { diff --git a/src/main/java/noppes/npcs/scripted/item/ScriptCustomItem.java b/src/main/java/noppes/npcs/scripted/item/ScriptCustomItem.java index d36b13a3b..7a3e2fdbf 100644 --- a/src/main/java/noppes/npcs/scripted/item/ScriptCustomItem.java +++ b/src/main/java/noppes/npcs/scripted/item/ScriptCustomItem.java @@ -189,7 +189,7 @@ public class ScriptCustomItem extends ScriptCustomizableItem implements IItemCus this.stackSize = size; saveItemData(); } else { - throw new CustomNPCsException("Stacksize has to be between 1 and 127"); + throw new CustomNPCsException("Stacksize has to be between 1 and 127", new Object[0]); } } @@ -198,7 +198,7 @@ public class ScriptCustomItem extends ScriptCustomizableItem implements IItemCus } public void setDurabilityValue(float value) { - this.durabilityValue = value; + this.durabilityValue = (double) value; saveItemData(); } diff --git a/src/main/java/noppes/npcs/scripted/item/ScriptItemBook.java b/src/main/java/noppes/npcs/scripted/item/ScriptItemBook.java index 7ae752c5c..06f5dfd3f 100644 --- a/src/main/java/noppes/npcs/scripted/item/ScriptItemBook.java +++ b/src/main/java/noppes/npcs/scripted/item/ScriptItemBook.java @@ -23,7 +23,7 @@ public class ScriptItemBook extends ScriptItemStack implements IItemBook { list.add(pages.getStringTagAt(i)); } - return list.toArray(new String[list.size()]); + return (String[]) list.toArray(new String[list.size()]); } public void setText(String[] pages) { diff --git a/src/main/java/noppes/npcs/scripted/item/ScriptItemStack.java b/src/main/java/noppes/npcs/scripted/item/ScriptItemStack.java index 9552c8db9..8e80f3eb6 100644 --- a/src/main/java/noppes/npcs/scripted/item/ScriptItemStack.java +++ b/src/main/java/noppes/npcs/scripted/item/ScriptItemStack.java @@ -1,6 +1,9 @@ package noppes.npcs.scripted.item; import com.google.common.collect.Multimap; +import kamkeel.npcs.controllers.data.attribute.requirement.IRequirementChecker; +import kamkeel.npcs.controllers.data.attribute.requirement.RequirementCheckerRegistry; +import kamkeel.npcs.util.AttributeItemUtil; import net.minecraft.block.Block; import net.minecraft.enchantment.Enchantment; import net.minecraft.entity.ai.attributes.AttributeModifier; @@ -22,10 +25,7 @@ import noppes.npcs.scripted.CustomNPCsException; import noppes.npcs.scripted.NpcAPI; import noppes.npcs.scripted.ScriptNbt; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.Map; +import java.util.*; public class ScriptItemStack implements IItemStack { public ItemStack item; @@ -184,7 +184,7 @@ public class ScriptItemStack implements IItemStack { public void addEnchant(int id, int strength) { Enchantment ench = Enchantment.enchantmentsList[id]; if (ench == null) { - throw new CustomNPCsException("Unknown enchant id:" + id); + throw new CustomNPCsException("Unknown enchant id:" + id, new Object[0]); } else { this.item.addEnchantment(ench, strength); } @@ -232,7 +232,7 @@ public class ScriptItemStack implements IItemStack { while (var4.hasNext()) { Map.Entry entry = (Map.Entry) var4.next(); - if (entry.getKey().equals(name)) { + if (((String) entry.getKey()).equals(name)) { AttributeModifier mod = (AttributeModifier) entry.getValue(); return mod.getAmount(); } @@ -254,7 +254,7 @@ public class ScriptItemStack implements IItemStack { lore.add(nbttaglist.getStringTagAt(i)); } - return lore.toArray(new String[lore.size()]); + return (String[]) ((String[]) lore.toArray(new String[lore.size()])); } } } @@ -390,7 +390,9 @@ public class ScriptItemStack implements IItemStack { */ public boolean isBlock() { Block block = Block.getBlockFromItem(item.getItem()); - return block != null && block != Blocks.air; + if (block == null || block == Blocks.air) + return false; + return true; } public boolean isFood() { @@ -452,4 +454,131 @@ public class ScriptItemStack implements IItemStack { public boolean compare(IItemStack item, boolean ignoreDamage, boolean ignoreNBT) { return NoppesUtilPlayer.compareItems(getMCItemStack(), item.getMCItemStack(), ignoreDamage, ignoreNBT); } + + @Override + public void setCustomAttribute(String key, double value) { + AttributeItemUtil.applyAttribute(item, key, (float) value); + } + + @Override + public boolean hasCustomAttribute(String key) { + return AttributeItemUtil.readAttributes(item).containsKey(key); + } + + @Override + public float getCustomAttribute(String key) { + return hasCustomAttribute(key) ? AttributeItemUtil.readAttributes(item).get(key) : 0.0f; + } + + @Override + public void removeCustomAttribute(String key) { + AttributeItemUtil.removeAttribute(item, key); + } + + @Override + public void setMagicAttribute(String key, int magicId, double value) { + AttributeItemUtil.writeMagicAttribute(item, key, magicId, (float) value); + } + + @Override + public float getMagicAttribute(String key, int magicId) { + Map magicMap = AttributeItemUtil.readMagicAttributeMap(item, key); + return magicMap.getOrDefault(magicId, 0.0f); + } + + @Override + public boolean hasMagicAttribute(String key, int magicId) { + Map magicMap = AttributeItemUtil.readMagicAttributeMap(item, key); + return magicMap.containsKey(magicId); + } + + @Override + public void removeMagicAttribute(String key, int magicId) { + AttributeItemUtil.removeMagicAttribute(item, key, magicId); + } + + @Override + public void setRequirement(String reqKey, Object value) { + // Delegate to the utility method that applies the requirement into the item's NBT. + AttributeItemUtil.applyRequirement(item, reqKey, value); + } + + @Override + public boolean hasRequirement(String reqKey) { + if (item == null || item.stackTagCompound == null) + return false; + NBTTagCompound root = item.stackTagCompound; + if (!root.hasKey(AttributeItemUtil.TAG_RPGCORE)) + return false; + NBTTagCompound rpgCore = root.getCompoundTag(AttributeItemUtil.TAG_RPGCORE); + if (!rpgCore.hasKey(AttributeItemUtil.TAG_REQUIREMENTS)) + return false; + NBTTagCompound reqTag = rpgCore.getCompoundTag(AttributeItemUtil.TAG_REQUIREMENTS); + return reqTag.hasKey(reqKey); + } + + @Override + public Object getRequirement(String reqKey) { + if (item == null || item.stackTagCompound == null) + return null; + NBTTagCompound root = item.stackTagCompound; + if (!root.hasKey(AttributeItemUtil.TAG_RPGCORE)) + return null; + NBTTagCompound rpgCore = root.getCompoundTag(AttributeItemUtil.TAG_RPGCORE); + if (!rpgCore.hasKey(AttributeItemUtil.TAG_REQUIREMENTS)) + return null; + NBTTagCompound reqTag = rpgCore.getCompoundTag(AttributeItemUtil.TAG_REQUIREMENTS); + if (reqTag.hasKey(reqKey)) { + IRequirementChecker checker = RequirementCheckerRegistry.getChecker(reqKey); + if (checker != null) { + return checker.getValue(reqTag); + } + // If no checker exists, fall back to returning the raw stored value. + NBTBase tag = reqTag.getTag(reqKey); + if (tag instanceof NBTPrimitive) + return ((NBTPrimitive) tag).func_150286_g(); + if (tag instanceof NBTTagString) + return ((NBTTagString) tag).func_150285_a_(); + return tag; + } + return null; + } + + @Override + public void removeRequirement(String reqKey) { + AttributeItemUtil.removeRequirement(item, reqKey); + } + + @Override + public String[] getCustomAttributeKeys() { + Map attrs = AttributeItemUtil.readAttributes(item); + return attrs.keySet().toArray(new String[attrs.size()]); + } + + @Override + public String[] getMagicAttributeKeys(String key) { + Map magicMap = AttributeItemUtil.readMagicAttributeMap(item, key); + // Convert the integer magic IDs to strings. + String[] keys = new String[magicMap.size()]; + int i = 0; + for (Integer magicId : magicMap.keySet()) { + keys[i++] = magicId.toString(); + } + return keys; + } + + @Override + public String[] getRequirementKeys() { + if (item == null || item.stackTagCompound == null) + return new String[0]; + NBTTagCompound root = item.stackTagCompound; + if (!root.hasKey(AttributeItemUtil.TAG_RPGCORE)) + return new String[0]; + NBTTagCompound rpgCore = root.getCompoundTag(AttributeItemUtil.TAG_RPGCORE); + if (!rpgCore.hasKey(AttributeItemUtil.TAG_REQUIREMENTS)) + return new String[0]; + NBTTagCompound reqTag = rpgCore.getCompoundTag(AttributeItemUtil.TAG_REQUIREMENTS); + Set keys = reqTag.func_150296_c(); + return keys.toArray(new String[keys.size()]); + } } diff --git a/src/main/java/noppes/npcs/scripted/overlay/ScriptOverlay.java b/src/main/java/noppes/npcs/scripted/overlay/ScriptOverlay.java index 9dc889ea8..7da5ade14 100644 --- a/src/main/java/noppes/npcs/scripted/overlay/ScriptOverlay.java +++ b/src/main/java/noppes/npcs/scripted/overlay/ScriptOverlay.java @@ -92,7 +92,7 @@ public class ScriptOverlay implements ICustomOverlay { public void removeComponent(int componentID) { for (int i = 0; i < this.components.size(); ++i) { - if (this.components.get(i).getID() == componentID) { + if (((ICustomOverlayComponent) this.components.get(i)).getID() == componentID) { this.components.remove(i); return; } @@ -102,7 +102,7 @@ public class ScriptOverlay implements ICustomOverlay { public void updateComponent(ICustomOverlayComponent component) { for (int i = 0; i < this.components.size(); ++i) { - ICustomOverlayComponent c = this.components.get(i); + ICustomOverlayComponent c = (ICustomOverlayComponent) this.components.get(i); if (c.getID() == component.getID()) { this.components.set(i, component); return; @@ -141,7 +141,7 @@ public class ScriptOverlay implements ICustomOverlay { ICustomOverlayComponent c; while (var3.hasNext()) { c = (ICustomOverlayComponent) var3.next(); - list.appendTag(c.toNBT(new NBTTagCompound())); + list.appendTag(((ScriptOverlayComponent) c).toNBT(new NBTTagCompound())); } tag.setTag("components", list); diff --git a/src/main/java/noppes/npcs/scripted/roles/ScriptJobBard.java b/src/main/java/noppes/npcs/scripted/roles/ScriptJobBard.java index bb2d4a824..a45514c46 100644 --- a/src/main/java/noppes/npcs/scripted/roles/ScriptJobBard.java +++ b/src/main/java/noppes/npcs/scripted/roles/ScriptJobBard.java @@ -6,7 +6,7 @@ import noppes.npcs.roles.JobBard; import noppes.npcs.scripted.constants.JobType; public class ScriptJobBard extends ScriptJobInterface implements IJobBard { - private final JobBard job; + private JobBard job; public ScriptJobBard(EntityNPCInterface npc) { super(npc); diff --git a/src/main/java/noppes/npcs/scripted/roles/ScriptJobConversation.java b/src/main/java/noppes/npcs/scripted/roles/ScriptJobConversation.java index b0749b70a..0b39da342 100644 --- a/src/main/java/noppes/npcs/scripted/roles/ScriptJobConversation.java +++ b/src/main/java/noppes/npcs/scripted/roles/ScriptJobConversation.java @@ -6,7 +6,7 @@ import noppes.npcs.roles.JobConversation; import noppes.npcs.scripted.constants.JobType; public class ScriptJobConversation extends ScriptJobInterface implements IJobConversation { - private final JobConversation job; + private JobConversation job; public ScriptJobConversation(EntityNPCInterface npc) { super(npc); diff --git a/src/main/java/noppes/npcs/scripted/roles/ScriptJobFollower.java b/src/main/java/noppes/npcs/scripted/roles/ScriptJobFollower.java index 54e2f6bdc..3ce52b061 100644 --- a/src/main/java/noppes/npcs/scripted/roles/ScriptJobFollower.java +++ b/src/main/java/noppes/npcs/scripted/roles/ScriptJobFollower.java @@ -7,7 +7,7 @@ import noppes.npcs.roles.JobFollower; import noppes.npcs.scripted.constants.JobType; public class ScriptJobFollower extends ScriptJobInterface implements IJobFollower { - private final JobFollower job; + private JobFollower job; public ScriptJobFollower(EntityNPCInterface npc) { super(npc); diff --git a/src/main/java/noppes/npcs/scripted/roles/ScriptJobGuard.java b/src/main/java/noppes/npcs/scripted/roles/ScriptJobGuard.java index 3f2d908a8..32b0ea77b 100644 --- a/src/main/java/noppes/npcs/scripted/roles/ScriptJobGuard.java +++ b/src/main/java/noppes/npcs/scripted/roles/ScriptJobGuard.java @@ -6,7 +6,7 @@ import noppes.npcs.roles.JobGuard; import noppes.npcs.scripted.constants.JobType; public class ScriptJobGuard extends ScriptJobInterface implements IJobGuard { - private final JobGuard job; + private JobGuard job; public ScriptJobGuard(EntityNPCInterface npc) { super(npc); diff --git a/src/main/java/noppes/npcs/scripted/roles/ScriptJobHealer.java b/src/main/java/noppes/npcs/scripted/roles/ScriptJobHealer.java index 2b4d5e57e..827047ea6 100644 --- a/src/main/java/noppes/npcs/scripted/roles/ScriptJobHealer.java +++ b/src/main/java/noppes/npcs/scripted/roles/ScriptJobHealer.java @@ -7,7 +7,7 @@ import noppes.npcs.roles.JobHealer; import noppes.npcs.scripted.constants.JobType; public class ScriptJobHealer extends ScriptJobInterface implements IJobHealer { - private final JobHealer job; + private JobHealer job; public ScriptJobHealer(EntityNPCInterface npc) { super(npc); diff --git a/src/main/java/noppes/npcs/scripted/roles/ScriptJobItemGiver.java b/src/main/java/noppes/npcs/scripted/roles/ScriptJobItemGiver.java index 541220c24..6a0c41c67 100644 --- a/src/main/java/noppes/npcs/scripted/roles/ScriptJobItemGiver.java +++ b/src/main/java/noppes/npcs/scripted/roles/ScriptJobItemGiver.java @@ -16,7 +16,7 @@ import java.util.ArrayList; import java.util.Arrays; public class ScriptJobItemGiver extends ScriptJobInterface implements IJobItemGiver { - private final JobItemGiver job; + private JobItemGiver job; public ScriptJobItemGiver(JobItemGiver job) { super(job); diff --git a/src/main/java/noppes/npcs/scripted/roles/ScriptRoleFollower.java b/src/main/java/noppes/npcs/scripted/roles/ScriptRoleFollower.java index 5e7ea0761..0bc6f57d5 100644 --- a/src/main/java/noppes/npcs/scripted/roles/ScriptRoleFollower.java +++ b/src/main/java/noppes/npcs/scripted/roles/ScriptRoleFollower.java @@ -9,7 +9,7 @@ import noppes.npcs.scripted.NpcAPI; import noppes.npcs.scripted.constants.RoleType; public class ScriptRoleFollower extends ScriptRoleInterface implements IRoleFollower { - private final RoleFollower role; + private RoleFollower role; public ScriptRoleFollower(EntityNPCInterface npc) { super(npc); diff --git a/src/main/java/noppes/npcs/scripted/roles/ScriptRoleTrader.java b/src/main/java/noppes/npcs/scripted/roles/ScriptRoleTrader.java index e622d18e0..825c2e46b 100644 --- a/src/main/java/noppes/npcs/scripted/roles/ScriptRoleTrader.java +++ b/src/main/java/noppes/npcs/scripted/roles/ScriptRoleTrader.java @@ -10,7 +10,7 @@ import noppes.npcs.scripted.NpcAPI; import noppes.npcs.scripted.constants.RoleType; public class ScriptRoleTrader extends ScriptRoleInterface implements IRoleTrader { - private final RoleTrader role; + private RoleTrader role; public ScriptRoleTrader(EntityNPCInterface npc) { super(npc); diff --git a/src/main/java/noppes/npcs/scripted/scoreboard/ScriptScoreboard.java b/src/main/java/noppes/npcs/scripted/scoreboard/ScriptScoreboard.java index 2bb060247..8ab5de0b1 100644 --- a/src/main/java/noppes/npcs/scripted/scoreboard/ScriptScoreboard.java +++ b/src/main/java/noppes/npcs/scripted/scoreboard/ScriptScoreboard.java @@ -14,7 +14,7 @@ import java.util.List; * @author Karel */ public class ScriptScoreboard implements IScoreboard { - private final Scoreboard board; + private Scoreboard board; public ScriptScoreboard() { board = MinecraftServer.getServer().worldServerForDimension(0).getScoreboard(); diff --git a/src/main/java/noppes/npcs/scripted/scoreboard/ScriptScoreboardObjective.java b/src/main/java/noppes/npcs/scripted/scoreboard/ScriptScoreboardObjective.java index f6c4a4fec..477bb5b4d 100644 --- a/src/main/java/noppes/npcs/scripted/scoreboard/ScriptScoreboardObjective.java +++ b/src/main/java/noppes/npcs/scripted/scoreboard/ScriptScoreboardObjective.java @@ -4,7 +4,7 @@ import net.minecraft.scoreboard.ScoreObjective; import noppes.npcs.api.scoreboard.IScoreboardObjective; public class ScriptScoreboardObjective implements IScoreboardObjective { - private final ScoreObjective objective; + private ScoreObjective objective; public ScriptScoreboardObjective(ScoreObjective objective) { this.objective = objective; diff --git a/src/main/java/noppes/npcs/scripted/scoreboard/ScriptScoreboardTeam.java b/src/main/java/noppes/npcs/scripted/scoreboard/ScriptScoreboardTeam.java index 250e06d7a..1af95fd58 100644 --- a/src/main/java/noppes/npcs/scripted/scoreboard/ScriptScoreboardTeam.java +++ b/src/main/java/noppes/npcs/scripted/scoreboard/ScriptScoreboardTeam.java @@ -10,8 +10,8 @@ import java.util.ArrayList; import java.util.List; public class ScriptScoreboardTeam implements IScoreboardTeam { - private final ScorePlayerTeam team; - private final Scoreboard board; + private ScorePlayerTeam team; + private Scoreboard board; public ScriptScoreboardTeam(ScorePlayerTeam team, Scoreboard board) { this.team = team; diff --git a/src/main/java/noppes/npcs/util/NBTJsonUtil.java b/src/main/java/noppes/npcs/util/NBTJsonUtil.java index 04ee25bb1..7e93bbbbb 100644 --- a/src/main/java/noppes/npcs/util/NBTJsonUtil.java +++ b/src/main/java/noppes/npcs/util/NBTJsonUtil.java @@ -54,7 +54,6 @@ public class NBTJsonUtil { compound.setTag(key, base); if (json.startsWith(",")) FillCompound(compound, json); - } public static NBTBase ReadValue(JsonFile json) throws JsonException { @@ -65,13 +64,11 @@ public class NBTJsonUtil { throw new JsonException("Expected }", json); } json.cut(1); - return compound; } if (json.startsWith("[")) { json.cut(1); NBTTagList list = new NBTTagList(); - NBTBase value = ReadValue(json); while (value != null) { list.appendTag(value); @@ -84,7 +81,6 @@ public class NBTJsonUtil { throw new JsonException("Expected ]", json); } json.cut(1); - if (list.func_150303_d() == 3) { int[] arr = new int[list.tagCount()]; for (int i = 0; list.tagCount() > 0; i++) { @@ -99,7 +95,6 @@ public class NBTJsonUtil { } return new NBTTagByteArray(arr); } - return list; } if (json.startsWith("\"")) { @@ -153,11 +148,26 @@ public class NBTJsonUtil { private static JsonLine ReadTag(String name, NBTBase base, List list) { if (!name.isEmpty()) name = "\"" + name + "\": "; - if (base.getId() == 8) {//NBTTagString + if (base.getId() == 8) { // NBTTagString String data = ((NBTTagString) base).func_150285_a_(); - data = data.replace("\"", "\\\""); //replace " with \" + data = data.replace("\"", "\\\""); // Escape quotes list.add(new JsonLine(name + "\"" + data + "\"")); - } else if (base.getId() == 9) {//NBTTagList + } else if (base.getId() == 7) { // NBTTagByteArray + byte[] arr = ((NBTTagByteArray) base).func_150292_c(); + StringBuilder sb = new StringBuilder(); + sb.append("["); + for (int i = 0; i < arr.length; i++) { + sb.append(arr[i]).append("b"); + if (i < arr.length - 1) { + sb.append(","); + } + } + sb.append("]"); + list.add(new JsonLine(name + sb.toString())); + JsonLine line = list.get(list.size() - 1); + line.line += ","; + return line; + } else if (base.getId() == 9) { // NBTTagList list.add(new JsonLine(name + "[")); NBTTagList tags = (NBTTagList) base; JsonLine line = null; @@ -167,18 +177,16 @@ public class NBTJsonUtil { if (line != null) line.removeComma(); list.add(new JsonLine("]")); - } else if (base.getId() == 10) { //NBTTagCompound + } else if (base.getId() == 10) { // NBTTagCompound list.add(new JsonLine(name + "{")); NBTTagCompound compound = (NBTTagCompound) base; JsonLine line = null; for (Object key : compound.func_150296_c()) line = ReadTag(key.toString(), compound.getTag(key.toString()), list); - if (line != null) line.removeComma(); - list.add(new JsonLine("}")); - } else if (base.getId() == 11) {//NBTTagList + } else if (base.getId() == 11) { // NBTTagIntArray list.add(new JsonLine(name + base.toString().replaceFirst(",]", "]"))); } else { list.add(new JsonLine(name + base)); @@ -198,7 +206,6 @@ public class NBTJsonUtil { json += " "; } json += tag + "\n"; - if (tag.increaseTab()) tab++; } @@ -243,7 +250,7 @@ public class NBTJsonUtil { } static class JsonFile { - private final String original; + private String original; private String text; public JsonFile(String text) { @@ -277,14 +284,12 @@ public class NBTJsonUtil { int currentPos = lengthOr - lengthCur; String done = original.substring(0, currentPos); String[] lines = done.split("\r\n|\r|\n"); - int pos = 0; String line = ""; if (lines.length > 0) { pos = lines[lines.length - 1].length(); line = original.split("\r\n|\r|\n")[lines.length - 1].trim(); } - return "Line: " + lines.length + ", Pos: " + pos + ", Text: " + line; } @@ -300,7 +305,6 @@ public class NBTJsonUtil { } } - public static NBTTagCompound LoadFile(File file) throws IOException, JsonException { return Convert(Files.toString(file, Charsets.UTF_8)); } @@ -311,10 +315,66 @@ public class NBTJsonUtil { try { writer = new OutputStreamWriter(new FileOutputStream(file), Charsets.UTF_8); writer.write(json); - } finally { if (writer != null) writer.close(); } } + + public static void main(String[] args) { + try { + // Create a test compound with various NBT types + NBTTagCompound comp = new NBTTagCompound(); + NBTTagCompound comp2 = new NBTTagCompound(); + + // ByteArray and IntArray + comp2.setByteArray("test", new byte[]{0, 0, 1, 1, 0}); + comp2.setIntArray("intArray", new int[]{0, 0, 1, 1, 0}); + + // Primitive types + comp2.setByte("byte", (byte)7); + comp2.setShort("short", (short)123); + comp2.setInteger("int", 456); + comp2.setLong("long", 789L); + comp2.setFloat("float", 3.14F); + comp2.setDouble("double", 2.71828); + comp2.setString("string", "Testing"); + + // A list containing strings + NBTTagList list = new NBTTagList(); + list.appendTag(new NBTTagString("jim")); + list.appendTag(new NBTTagString("foo")); + comp2.setTag("list", list); + + // A nested compound + NBTTagCompound innerComp = new NBTTagCompound(); + innerComp.setString("innerString", "innerValue"); + innerComp.setInteger("innerInt", 10); + innerComp.setByte("innerByte", (byte) 11); + comp2.setTag("innerComp", innerComp); + + // Add our compound to the root compound. + comp.setTag("comp", comp2); + + // Convert NBT to JSON string (writing) + String json = Convert(comp); + System.out.println("Generated JSON:"); + System.out.println(json); + + // Read back from JSON string (reading) + NBTTagCompound compFromJson = Convert(json); + String jsonAfterRead = Convert(compFromJson); + System.out.println("\nRe-converted JSON from read NBT:"); + System.out.println(jsonAfterRead); + + // Basic check: compare the JSON outputs to verify consistency. + if (json.equals(jsonAfterRead)) { + System.out.println("\nSUCCESS: Read and write operations are consistent for all types."); + } else { + System.out.println("\nWARNING: There is a mismatch in read and write results for some types."); + } + } catch (Exception e) { + e.printStackTrace(); + } + } } diff --git a/src/main/java/tconstruct/client/tabs/TabRegistry.java b/src/main/java/tconstruct/client/tabs/TabRegistry.java index bb080b7c2..9d21a784c 100644 --- a/src/main/java/tconstruct/client/tabs/TabRegistry.java +++ b/src/main/java/tconstruct/client/tabs/TabRegistry.java @@ -14,7 +14,7 @@ import java.util.ArrayList; import java.util.List; public class TabRegistry { - private static final ArrayList tabList = new ArrayList(); + private static ArrayList tabList = new ArrayList(); public static void registerTab(AbstractTab tab) { tabList.add(tab); @@ -38,7 +38,7 @@ public class TabRegistry { } } - private static final Minecraft mc = FMLClientHandler.instance().getClient(); + private static Minecraft mc = FMLClientHandler.instance().getClient(); public static void openInventoryGui() { mc.thePlayer.sendQueue.addToSendQueue(new C0DPacketCloseWindow( diff --git a/src/main/resources/assets/customnpcs/lang/en_US.lang b/src/main/resources/assets/customnpcs/lang/en_US.lang index a825947cd..92f6c1c8e 100644 --- a/src/main/resources/assets/customnpcs/lang/en_US.lang +++ b/src/main/resources/assets/customnpcs/lang/en_US.lang @@ -154,6 +154,25 @@ gui.change=Change gui.create=Create gui.rename=Rename gui.playerMap=Regen PlayerMap +gui.unused=Unused + +gui.lineColor1=Upper line color +gui.lineColor2=Middle line color +gui.lineColor3=Lower line color +gui.slotColour=Slots color +gui.buttonAcceptColour=Accept button color +gui.buttonRejectColour=Reject button color +questgui.doyouaccept=Do you accept the quest? +questgui.bringitems=Bring items +questgui.readdialog=Read dialog +questgui.killmobs=Kill mobs +questgui.findlocation=Find location +questgui.defeat=Defeat +questgui.objectives=Objectives: +questgui.rewards=Rewards: +questgui.experience=Experience: +questgui.reject=Reject +questgui.accept=Accept party.accept=Accept party.allowParty=Allow Partying @@ -326,6 +345,7 @@ use_action.none=None use_action.block=Block use_action.eat=Eat use_action.drink=Drink +use_action.bow=Bow armor_type.none=None armor_type.all=All @@ -470,6 +490,9 @@ stats.stick=Sticks stats.regular=No Amp stats.amplified=Amp stats.explosion=Explosion +stats.onShot=On Shot +stats.onStart=On Start +stats.burnItem=Burn Item ai.standing=Standing ai.wandering=Wandering @@ -556,6 +579,7 @@ menu.tags=Tags menu.general=General menu.magics=Magics menu.cycles=Cycles +menu.attributes=Attributes cloner.tagFilters=Tag Filters cloner.tagVisibility=Tag Visibility @@ -653,6 +677,7 @@ dialog.npcScale=NPC Scale dialog.npcOffset=NPC Offset dialog.titleColor=Title Color dialog.titlePos=Title Position +dialog.enableColorSettings=Enable Color Settings quest.quest=Quest quest.active=Active Quest @@ -775,6 +800,7 @@ item.scripted_item.name=Scripted Item item.linked_item.name=Linked Item item.npcTool.hammer.name=Npc Hammer item.npcTool.paintbrush.name=Npc Brush +item.npcTool.magic_book.name=Magic Book item.npcBanjo.name=Banjo @@ -1329,6 +1355,10 @@ effect.editor.xPos=X Pos effect.editor.yPos=Y Pos effect.editor.lossOnDeath=Loss on Death +particle.maxAge=Max Age +particle.facePlayer=Face Player +particle.noClip=No Clip + profile.lastLoaded=Last Loaded profile.info.quest.active=Quests Active profile.info.quest.finished=Quests Finished @@ -1341,6 +1371,7 @@ profile.enableOptions=Enable Options profile.completion=Completion profile.cooldown=Cooldown profile.individual=Individual +profile.slot=Slot magic.interaction=Interaction magic.diagram=Diagram Type @@ -1360,6 +1391,7 @@ diagram.circular_manual=Circular [Manual] diagram.square_manual=Square [Manual] diagram.tree_manual=Tree [Manual] diagram.chart=Chart +diagram.manual=Manual diagram.info=Manual: Index is the level, Priority is the order. rpgcore:tooltip=Hold %key% to view attributes @@ -1368,3 +1400,23 @@ rpgcore:attribute.defense=Defense rpgcore:attribute.resistance=Resistance rpgcore:attribute.neutral=Neutral Damage +requirement.soulbind=Soulbind + +trail.smoke=Smoke +trail.portal=Portal +trail.redstone=Redstone +trail.lightning=Lightning +trail.largesmoke=Large Smoke +trail.magic=Magic +trail.enchant=Enchant +trail.crit=Critical +trail.explode=Explode +trail.music=Music +trail.flame=Flame +trail.lava=Lava +trail.splash=Splash +trail.slime=Slime +trail.heart=Heart +trail.angryvillager=AngryVillager +trail.happyvillager=HappyVillager +trail.custom=Custom diff --git a/src/main/resources/assets/customnpcs/lang/ru_RU.lang b/src/main/resources/assets/customnpcs/lang/ru_RU.lang index a729216e5..f0f552f84 100644 --- a/src/main/resources/assets/customnpcs/lang/ru_RU.lang +++ b/src/main/resources/assets/customnpcs/lang/ru_RU.lang @@ -997,3 +997,21 @@ markov.gender.female=Женский markov.gender.male=Мужской markov.generate=Сгенерировать +dialog.enableColorSettings=Включить настройки цвета +gui.lineColor1=Цвет верхней линии +gui.lineColor2=Цвет средней линии +gui.lineColor3=Цвет нижней линии +gui.slotColour=Цвет слотов +gui.buttonAcceptColour=Цвет кнопки принятия квеста +gui.buttonRejectColour=Цвет кнопки отклонения квеста +questgui.doyouaccept=Принимаешь задание? +questgui.bringitems=Принести +questgui.readdialog=Прочитать +questgui.killmobs=Убить +questgui.findlocation=Исследовать +questgui.defeat=Зачистить +questgui.objectives=Цели: +questgui.rewards=Награды: +questgui.experience=Опыт: +questgui.reject=Отменить +questgui.accept=Принять diff --git a/src/main/resources/assets/customnpcs/shaders/post/blur.json b/src/main/resources/assets/customnpcs/shaders/post/blur.json new file mode 100644 index 000000000..a6be10f40 --- /dev/null +++ b/src/main/resources/assets/customnpcs/shaders/post/blur.json @@ -0,0 +1,87 @@ +{ + "targets": [ + "swap" + ], + "passes": [ + { + "name": "blur", + "intarget": "minecraft:main", + "outtarget": "swap", + "uniforms": [ + { + "name": "BlurDir", + "values": [ + 1, + 0 + ] + }, + { + "name": "Radius", + "values": [ + 20 + ] + } + ] + }, + { + "name": "blur", + "intarget": "swap", + "outtarget": "minecraft:main", + "uniforms": [ + { + "name": "BlurDir", + "values": [ + 0, + 1 + ] + }, + { + "name": "Radius", + "values": [ + 20 + ] + } + ] + }, + { + "name": "blur", + "intarget": "minecraft:main", + "outtarget": "swap", + "uniforms": [ + { + "name": "BlurDir", + "values": [ + 1, + 0 + ] + }, + { + "name": "Radius", + "values": [ + 20 + ] + } + ] + }, + { + "name": "blur", + "intarget": "swap", + "outtarget": "minecraft:main", + "uniforms": [ + { + "name": "BlurDir", + "values": [ + 0, + 1 + ] + }, + { + "name": "Radius", + "values": [ + 20 + ] + } + ] + } + ] +} diff --git a/src/main/resources/assets/customnpcs/textures/gui/dialog_menu_decomposed.png b/src/main/resources/assets/customnpcs/textures/gui/dialog_menu_decomposed.png new file mode 100644 index 000000000..96fa4fe9d Binary files /dev/null and b/src/main/resources/assets/customnpcs/textures/gui/dialog_menu_decomposed.png differ diff --git a/src/main/resources/assets/customnpcs/textures/items/npcToolHammer.png b/src/main/resources/assets/customnpcs/textures/items/npcToolHammer.png new file mode 100644 index 000000000..7b80106da Binary files /dev/null and b/src/main/resources/assets/customnpcs/textures/items/npcToolHammer.png differ diff --git a/src/main/resources/assets/customnpcs/textures/items/npcToolMagicBook.png b/src/main/resources/assets/customnpcs/textures/items/npcToolMagicBook.png new file mode 100644 index 000000000..c2030aa97 Binary files /dev/null and b/src/main/resources/assets/customnpcs/textures/items/npcToolMagicBook.png differ diff --git a/src/main/resources/mcmod.info b/src/main/resources/mcmod.info index e09e6284d..9d443a8fa 100644 --- a/src/main/resources/mcmod.info +++ b/src/main/resources/mcmod.info @@ -1,26 +1,24 @@ { - "modListVersion": 2, - "modList": [ - { - "modid": "${modId}", - "name": "${modName}", - "description": "CustomNPC+ is a continuation of the Custom NPCs Mod which allows you to create NPCs with various different functionalities", - "version": "${modVersion}", - "mcversion": "${minecraftVersion}", - "url": "https://tinyurl.com/customnpc-plus", - "updateUrl": "", - "authorList": [ - "KAMKEEL (CNPC+)", - "Louis XII (CNPC+ Scripting)" - ], - "credits": "Noppes (CNPC), DarkSignal (AI), Foxz (Retro-Commands), PopsicleNate (Textures), Goodbird (CustomModel)", - "logoFile": "assets/customnpcs/textures/gui/logo.png", - "screenshots": [], - "parent": "", - "requiredMods": [], - "dependencies": [], - "dependants": [], - "useDependencyInformation": false - } - ] + "modListVersion": 2, + "modList": [{ + "modid": "${modId}", + "name": "${modName}", + "description": "CustomNPC+ is a continuation of the Custom NPCs Mod which allows you to create NPCs with various different functionalities", + "version": "${modVersion}", + "mcversion": "${minecraftVersion}", + "url": "https://tinyurl.com/customnpc-plus", + "updateUrl": "", + "authorList": [ + "KAMKEEL (CNPC+)", + "Louis XII (CNPC+ Scripting)" + ], + "credits": "Noppes (CNPC), DarkSignal (AI), Foxz (Retro-Commands), PopsicleNate (Textures), Goodbird (CustomModel), Hussar [Scroll Window/Packets]", + "logoFile": "assets/customnpcs/textures/gui/logo.png", + "screenshots": [], + "parent": "", + "requiredMods": [], + "dependencies": [], + "dependants": [], + "useDependencyInformation": false + }] } diff --git a/todo.txt b/todo.txt index 8a657ebb4..e69de29bb 100644 --- a/todo.txt +++ b/todo.txt @@ -1,15 +0,0 @@ -Interfaces: -- IProfile -- Need Work -- ISlot -- Need Work - --- Fix Default Magic Cycle Load Up - ---- FIX MAGIC CYCLE ----- Add Two Way arrows in Diagram Support - -Item Attribute Scripting --- Item Attribute Recalc --- Durability Attribute --- Get Attributes --- View Attributes on Profiles ---