Compare commits

...
101 Commits
Author SHA1 Message Date
KAMKEEL 36992c5abd Added Awen Capes 2022-04-20 18:04:48 -04:00
Kamron Vaswani 09f2e19c88 Merge pull request #48 from KAMKEEL/dev
Dev
2022-04-20 17:56:29 -04:00
KAMKEEL a53baefafa Merge branch 'dev' of https://github.com/KAMKEEL/CustomNPC-Plus into dev 2022-04-20 17:50:18 -04:00
KAMKEEL d6cd41946c Remove ZSTD Compression 2022-04-20 17:49:20 -04:00
Kamron Vaswani 1e088323e9 Merge pull request #47 from KAMKEEL/revert-44-dev
Revert "Remove redundant files and make support for specific OS for zstd compression"
2022-04-20 17:24:01 -04:00
Kamron Vaswani b90406ddd6 Revert "Remove redundant files and make support for specific OS for zstd compression" 2022-04-20 17:23:45 -04:00
Kamron Vaswani 0ed0893682 Merge pull request #46 from c0508383/master
Scripted Dialog Hook Fix
2022-04-20 17:23:24 -04:00
Luis C.M ff37a8bec2 Merge branch 'KAMKEEL:master' into master 2022-04-13 04:27:25 -05:00
Luis C.M 1e88a4458d Fixed bug with NPC dialog scripts. 2022-04-13 04:25:44 -05:00
KAMKEEL a3414d8d75 New Cape Textures - Daybreak 2022-04-12 03:35:42 -04:00
KAMKEEL e72672ad71 Revert to Original 😦 2022-04-11 23:01:41 -04:00
KAMKEEL 77ed924492 Steve32 Fake Framework
Started Creating Steve32 Fake so that 64x64 Textures can be applied to 64x32 Steve
2022-04-09 21:04:09 -04:00
KAMKEEL 628fd1084e Cloak Reorganization Compatibility Update 2022-04-09 02:36:14 -04:00
KAMKEEL 18a86d30e7 Update build.gradle 2022-04-09 02:15:14 -04:00
KAMKEEL 71216350d8 Merge branch 'master' into dev 2022-04-09 02:14:21 -04:00
KAMKEEL 0732d98ff8 1.5.3 Gradle Update | Add Version Compatibility Changes
Update Version to 1.5.3
Remove Useless String Statements / Comments
Add Temporary Fixes to Version Compatibility as permanent fixes
2022-04-09 01:31:21 -04:00
KAMKEEL 5ad6bb094a Merge branch 'master' into dev 2022-04-09 01:22:15 -04:00
KAMKEEL 465f52b811 Update RenderNPCInterface.java 2022-04-09 01:21:40 -04:00
Kamron Vaswani 32f89f8e92 Merge pull request #45 from c0508383/master
Important script hook fix, additions to dialog and dialog closed hooks for NPCs
2022-04-09 01:20:53 -04:00
Luis C.M 65bb3b5939 Important fix to some NPC hook scripts crashing, added option and dialog object fields to local NPC dialog and NPC dialog closed scripts 2022-04-09 00:17:16 -05:00
KAMKEEL 8c677901d0 Reorganized Cape Textures 2022-04-09 01:11:05 -04:00
KAMKEEL dd67f12818 Cape System Overhaul 2022-04-08 03:40:46 -04:00
KAMKEEL e95eb0ee98 Add Texture Pack 2022-04-06 19:00:27 -04:00
Kamron Vaswani ea3669fed8 Merge pull request #44 from luiz-otavio/dev
Remove redundant files and make support for specific OS for zstd compression
2022-04-06 15:08:11 -04:00
luiz-otavio 6294062d23 chore(gradle): make supported OS for zstd compression 2022-04-06 00:32:55 -03:00
KAMKEEL 5aa5fb335c Remove ME 2022-04-05 20:01:27 -04:00
KAMKEEL be44db63d3 Update Alex Arm Item Offset 2022-04-05 19:33:36 -04:00
KAMKEEL 993e7a9d7c LOTR Capes! 2022-04-05 17:56:05 -04:00
KAMKEEL ebc0b96582 Code Cleanup for Bow Fix 2022-04-05 17:55:13 -04:00
Kamron Vaswani 6101e75306 Merge pull request #43 from c0508383/master
Bow & Solid Legwear Fixes
2022-04-05 17:51:03 -04:00
Luis C.M 4abe8dca92 Merge remote-tracking branch 'origin/master' 2022-04-05 16:48:37 -05:00
Luis C.M 8749ba0280 Fixed bow rendering for mods with custom bow renderers 2022-04-05 16:48:27 -05:00
Luis C.M 6a0af3b0a0 Fixed solid legwear right & left sides being flipped 2022-04-05 16:10:58 -05:00
Kamron Vaswani f59b5d1e87 Merge pull request #42 from c0508383/master
Solid Steve armwear fix
2022-04-05 04:01:54 -04:00
Luis C.M cddada1984 Merge branch 'KAMKEEL:master' into master 2022-04-03 19:14:46 -05:00
Luis C.M 917f0d030a Fixed solid Steve armwear 2022-04-03 19:14:19 -05:00
KAMKEEL 3454ecb78a Update Version 2022-04-03 14:37:50 -04:00
KAMKEEL 57de575d42 Merge branch 'dev' 2022-04-03 14:36:11 -04:00
Kamron Vaswani 8ab652361e Merge pull request #41 from c0508383/master
Alex Solid Armor Fix & GLOBAL NPC SCRIPTS
2022-04-03 14:35:27 -04:00
Luis C.M 694afb7b6b Possible fix for instant complete kill quests having their progress stuck. 2022-03-24 20:42:38 -05:00
Luis C.M 464f5ecb1e Fixed scaling issue on custom gui textured rectangles 2022-03-24 01:58:39 -05:00
Luis C.M 3066e1dfbc Global event script buttons and the script GUI for an NPC are enabled/disabled/darkened based on their respective configs. 2022-03-23 18:54:55 -05:00
Luis C.M 286f6862cb Small clarifications in the new scripting configs, and removed some unused imports. 2022-03-23 17:48:58 -05:00
Luis C.M 9a244ca2fe Renamed NPCs button on GUI, added configs for enabling player, forge, NPC, and all scripts. 2022-03-23 17:42:35 -05:00
Luis C.M 33378fba59 Merge remote-tracking branch 'origin/master' 2022-03-23 04:02:20 -05:00
Luis C.M e26a0a1bd5 null NPC check for NPC events 2022-03-23 04:02:01 -05:00
Luis C.M 50fe08ce2e Merge branch 'KAMKEEL:master' into master 2022-03-23 03:55:08 -05:00
Luis C.M 18ff2bff78 Implemented Global NPC Events!
All NPCs activate these scripts. If a player wants to create a script that's universally used by all NPCs, this allows for that to happen with a lot of ease!
2022-03-23 03:54:06 -05:00
Luis C.M 092592bd27 Fixed Alex solid armwear 2022-03-23 01:24:24 -05:00
Luis C.M 769a574210 Fixed setHunger/Saturation using client-side functions from FoodStats 2022-03-19 22:51:39 -05:00
Luis C.M df2e742cbb Added overloaded spawnParticle functions for ScriptEntity 2022-03-16 23:15:30 -05:00
KAMKEEL c0bac481ad [WIP] Arm Fix 2022-03-15 02:03:58 -04:00
KAMKEEL d867017871 Merge branch 'master' of https://github.com/KAMKEEL/CustomNPC-Plus 2022-03-15 00:21:00 -04:00
Kamron Vaswani 1752cdd14d Merge pull request #40 from c0508383/master
Spring Pull Request
2022-03-15 00:18:12 -04:00
KAMKEEL 1e771bce8a Update GuiContainerNPCInterface2.java
Cleanup
2022-03-15 00:16:44 -04:00
KAMKEEL a507f06d7f Fix Texture Issue in Menu 2022-03-14 03:15:42 -04:00
KAMKEEL df5c6afd2e Update Version 2022-03-14 02:24:43 -04:00
KAMKEEL dafd5f4460 Fix Sizing for Clone Menu 2022-03-14 02:24:32 -04:00
KAMKEEL 08fb12f716 Fixed Compressor Messages 2022-03-14 00:26:19 -04:00
Kamron Vaswani c0fa3935cd Update README.md 2022-03-14 00:10:06 -04:00
Kamron Vaswani a10d79da9b Merge pull request #36 from luiz-otavio/feat/zstd-compressor
feat: add config property to use `Zstd` compression instead of `JSON`
2022-03-14 00:08:54 -04:00
Kamron Vaswani 0226001596 Merge branch 'dev' into feat/zstd-compressor 2022-03-14 00:07:23 -04:00
luisc 60e14f548e Custom GUIs now only close when the ESC key is pressed. 2022-03-09 00:33:55 -06:00
luisc 16321dd4ff Added hasLore() function to ScriptItemStack
Fixed getLore() null pointer error
2022-03-06 13:47:47 -06:00
luisc 1cb27a9e7a Implemented XYZ rotations correctly, now clearly rotate around an axis respective to the player's camera. 2022-03-04 18:08:05 -06:00
Kamron Vaswani 89b7019e29 Delete CompressorTest.java
Not needed in final version
2022-03-03 16:02:02 -05:00
Kamron Vaswani 3339488a6f Version Correction 2022-03-03 15:59:17 -05:00
Kamron Vaswani 1a7267349f Update Config Description with Warning 2022-03-03 15:58:21 -05:00
luiz-otavio 5578f2055e fix(gradle): assign resourcesDir to classesDir from sourcesSets 2022-03-03 17:50:28 -03:00
luiz-otavio e23620d724 refactor: use JSONas default codec for PlayerData instead of .dat files 2022-03-03 17:43:18 -03:00
KAMKEEL 3bc9686816 ReadMe | Texture Pack | Version Change
Updated ReadME with Donation Link
Added CNPCs TexturePack
Updated Version for future 1.5.1 full release
2022-03-03 15:38:01 -05:00
KAMKEEL 805054ceb0 Merge branch 'master' into dev 2022-03-03 14:51:35 -05:00
luisc 75b7c01f87 Removed some unnecessary fields in ScriptEntityParticle 2022-03-02 19:36:15 -06:00
luisc f1741b4660 Removed some unnecessary lines of OpenGL code 2022-03-02 19:35:24 -06:00
luisc 7f8246e04e PARTICLE ROTATION 2022-03-02 18:18:03 -06:00
luisc 65ab37158f Fixed flying limits not working on flying NPCs with the new smoother flight 2022-02-27 23:23:41 -06:00
luisc d2d3cef681 When setMaxTicks() is called and the remaining ticks in a timer are greater than that value, the remaining ticks are updated to the new max tick value. 2022-02-27 23:11:52 -06:00
luisc 403738262c Added timer functions.
ticks(int id):
Gets the remaining ticks in the timer that matches this id.

setTicks(int id, int ticks):
Sets the remaining ticks in the timer that matches this id.

maxTicks(int id):
Gets the maximum ticks that must elapse for the timer that matches this id to finish.

setMaxTicks(int id, int ticks):
Sets the maximum ticks that must elapse for the timer that matches this id to finish.

repeats(int id):
Returns true if the timer with the given id is set to repeat, false otherwise.

setRepeats(int id, bool repeat):
Sets whether the timer with the given id should repeat. If true, the timer will repeat, and not repeat otherwise.
2022-02-27 23:08:24 -06:00
luiz-otavio 90c6574125 fix: ensure playerdata type and remove useless checking about transforming 2022-02-27 08:12:24 -03:00
luiz-otavio 7b0a6b7497 feat: add some utilities messages on each case of compressor command 2022-02-27 08:11:48 -03:00
luiz-otavio 54fa6d106f chore: add shade configuration 2022-02-27 08:10:53 -03:00
luiz-otavio 451a60f297 test: make CompressorTest to retrieve the measure time of compression to see how much each one will take 2022-02-27 07:00:42 -03:00
luiz-otavio 3ac531a49d feat: add compressor command to convert data files to zstd or json 2022-02-27 06:59:24 -03:00
luiz-otavio 34b6eb05e5 feat: integrate the compressor type to config property and add number of IO-Workers to write compressed files 2022-02-27 06:58:53 -03:00
luiz-otavio 4bdbe0efee refactor: ensure almost compression types to load/write each NBTTagCompound 2022-02-27 06:57:37 -03:00
luiz-otavio c3bba543f0 feat: add ZstdCompressor to write/read almost compressed data 2022-02-27 06:56:57 -03:00
luiz-otavio d4f6df5a81 chore: add zstd and modify encoding on compile time to UTF-8 2022-02-27 06:56:20 -03:00
luisc 22b622d46c Fixed hovering text for custom GUI labels and textured rectangles. 2022-02-23 00:39:01 -06:00
luisc ee02988d8c Removed client-side imports from EntityNPCFlying 2022-02-22 22:14:05 -06:00
luisc 450e065e27 Slightly improved flight pathing downwards. 2022-02-22 01:52:47 -06:00
luisc c2a669fbeb The setForm() function in ScriptDBCPlayer prevents crashes from form levels that are out of bounds now. 2022-02-21 20:16:42 -06:00
luisc 732e97e0fe Override updateLeashedState() function in EntityNPCInterface.
NPCs can't be leashed anyway. This should avoid the "does not know how to add entity" crash with NPCs.
2022-02-20 00:56:57 -06:00
luisc 33e884c217 Flying is now smoother, NPCs can pathfind downwards easier while flying. 2022-02-18 03:34:20 -06:00
luisc 3d1caf494b Small fix to min XP and max XP text fields in NPC inventory menu 2022-02-16 12:57:46 -06:00
luisc 18e02461a6 Added misspelled cancel functions to player & forge events, and correctly spelled cancel functions to npc events 2022-02-06 12:39:07 -06:00
Luis C.M 6bfbffb0e6 Merge branch 'KAMKEEL:master' into master 2022-02-05 23:58:11 -06:00
KAMKEEL e42c4cab7e Update ScriptLivingBase.java 2022-02-05 20:35:44 -05:00
luisc 47f41ff5b7 Added custom kill types 2022-02-02 22:11:49 -06:00
KAMKEEL 5a86d1cc6f Delete Scripting_Documentation.pdf 2022-02-02 19:58:36 -05:00
KAMKEEL 7d647d788f Version Update 2022-02-02 19:42:58 -05:00
KAMKEEL 01e568d0c7 Remove More Print Statements 2022-02-02 19:41:34 -05:00
244 changed files with 1782 additions and 828 deletions

No files matched your search

Binary file not shown.
+5 -3
View File
@@ -9,7 +9,7 @@ Link to CurseForge: [HERE](https://www.curseforge.com/minecraft/mc-mods/customnp
### ❗ Notice ### ❗ Notice
I am not the original creator of CustomNPC. The original creator is @[Noppes](https://github.com/Noppes). I have been permitted to update the 1.7.10 and post my results on GitHub. The original mod that is updated to the latest versions of Minecraft can be found on these links: [CurseForge](https://www.curseforge.com/minecraft/mc-mods/custom-npcs), [kodevelopment](http://www.kodevelopment.nl/minecraft/customnpcs) I am not the original creator of CustomNPC. The original creator is @[Noppes](https://github.com/Noppes). I have been permitted to update the 1.7.10 and post my results on GitHub. The original mod that is updated to the latest versions of Minecraft can be found on these links: [CurseForge](https://www.curseforge.com/minecraft/mc-mods/custom-npcs), [kodevelopment](http://www.kodevelopment.nl/minecraft/customnpcs)
### 🔹 First Release! V1.0 (Installation) ### 🔹 Installation
This mod is an ***update*** to CustomNPC and not an add-on. Do not install CustomNPC with CustomNPC-Plus. CustomNPC-Plus does not remove any functional features from the original mod. It expands upon CustomNPC with original features and backported features from newer versions. Simply drag CustomNPC-Plus into any client/server mods folder to utilize. Please **backup** before using as this could still have unforeseen errors. Report any bugs if found, thank you and enjoy. This mod is an ***update*** to CustomNPC and not an add-on. Do not install CustomNPC with CustomNPC-Plus. CustomNPC-Plus does not remove any functional features from the original mod. It expands upon CustomNPC with original features and backported features from newer versions. Simply drag CustomNPC-Plus into any client/server mods folder to utilize. Please **backup** before using as this could still have unforeseen errors. Report any bugs if found, thank you and enjoy.
### ❓ Features: ### ❓ Features:
@@ -32,7 +32,8 @@ This mod is an ***update*** to CustomNPC and not an add-on. Do not install Custo
- Custom Part Disabling - Custom Part Disabling
- Markov Name Generator - Markov Name Generator
- Flying NPCS - Flying NPCS
- Better Script Speeds - PlayerData Storage Options [JSON/Zstd]
- Script Enchanments and Fixes
- Scripting Additions: [Documentation](https://github.com/PewDizinho/CustomNPCPlus-Script-Documentation) - Scripting Additions: [Documentation](https://github.com/PewDizinho/CustomNPCPlus-Script-Documentation)
--- Please Suggest New Features! --- Please Suggest New Features!
@@ -56,5 +57,6 @@ This mod is an ***update*** to CustomNPC and not an add-on. Do not install Custo
[![Discord Badge](https://img.shields.io/badge/CustomNPC-7289DA?style=for-the-badge&logo=discord&logoColor=white)](https://discord.gg/rgeWsmQaKa) [![Discord Badge](https://img.shields.io/badge/CustomNPC-7289DA?style=for-the-badge&logo=discord&logoColor=white)](https://discord.gg/rgeWsmQaKa)
[![Discord Badge](https://img.shields.io/badge/CustomNPC+-7289DA?style=for-the-badge&logo=discord&logoColor=white)](https://discord.gg/pQqRTvFeJ5) [![Discord Badge](https://img.shields.io/badge/CustomNPC+-7289DA?style=for-the-badge&logo=discord&logoColor=white)](https://discord.gg/pQqRTvFeJ5)
[![Download CustomNPC+](https://img.shields.io/badge/Download⠀CustomNPC⠀Plus!-0081CB?style=for-the-badge&logo=material-ui&logoColor=white)](https://www.curseforge.com/minecraft/mc-mods/customnpc-plus) [![Download CustomNPC+](https://img.shields.io/badge/Download⠀CustomNPC⠀Plus!-0081CB?style=for-the-badge&logo=material-ui&logoColor=white)](https://www.curseforge.com/minecraft/mc-mods/customnpc-plus)
[![Download CustomNPC+](https://img.shields.io/badge/Download⠀Plugin⠀Mod!-0081CB?style=for-the-badge&logo=material-ui&logoColor=white)](https://github.com/KAMKEEL/Plugin-Mod) [![Download PluginMod](https://img.shields.io/badge/Download⠀Plugin⠀Mod!-0081CB?style=for-the-badge&logo=material-ui&logoColor=white)](https://github.com/KAMKEEL/Plugin-Mod)
<a href="https://ko-fi.com/kamkeel"> <img src="https://i.imgur.com/zvdVbeW.png" alt="Support Me on Kofi" width="180" height="27"> </a>
Binary file not shown.
+20 -21
View File
@@ -17,7 +17,7 @@ buildscript {
apply plugin: 'forge' apply plugin: 'forge'
version = "1.5.1-beta" version = "1.6-beta"
group= "com.yourname.modid" // http://maven.apache.org/guides/mini/guide-naming-conventions.html group= "com.yourname.modid" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "CustomNPC-Plus" archivesBaseName = "CustomNPC-Plus"
@@ -34,7 +34,7 @@ dependencies {
// or you may define them like so.. // or you may define them like so..
//compile "some.group:artifact:version:classifier" //compile "some.group:artifact:version:classifier"
//compile "some.group:artifact:version" //compile "some.group:artifact:version"
// real examples // real examples
//compile 'com.mod-buildcraft:buildcraft:6.0.8:dev' // adds buildcraft to the dev env //compile 'com.mod-buildcraft:buildcraft:6.0.8:dev' // adds buildcraft to the dev env
//compile 'com.googlecode.efficient-java-matrix-library:ejml:0.24' // adds ejml to the dev env //compile 'com.googlecode.efficient-java-matrix-library:ejml:0.24' // adds ejml to the dev env
@@ -42,27 +42,26 @@ dependencies {
// for more info... // for more info...
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html // http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
// http://www.gradle.org/docs/current/userguide/dependency_management.html // http://www.gradle.org/docs/current/userguide/dependency_management.html
} }
processResources processResources
{ {
// this will ensure that this task is redone when the versions change. // this will ensure that this task is redone when the versions change.
inputs.property "version", project.version inputs.property "version", project.version
inputs.property "mcversion", project.minecraft.version inputs.property "mcversion", project.minecraft.version
// replace stuff in mcmod.info, nothing else // replace stuff in mcmod.info, nothing else
from(sourceSets.main.resources.srcDirs) { from(sourceSets.main.resources.srcDirs) {
include 'mcmod.info' include 'mcmod.info'
// replace version and mcversion
expand 'version':project.version, 'mcversion':project.minecraft.version
}
// copy everything else, thats not the mcmod.info
from(sourceSets.main.resources.srcDirs) {
exclude 'mcmod.info'
}
}
sourceSets {main { output.resourcesDir = output.classesDir }} // replace version and mcversion
expand 'version':project.version, 'mcversion':project.minecraft.version
}
// copy everything else, thats not the mcmod.info
from(sourceSets.main.resources.srcDirs) {
exclude 'mcmod.info'
}
}
sourceSets {main { output.resourcesDir = output.classesDir }}
+1 -1
View File
@@ -123,6 +123,6 @@ public class CmdDialog extends ChMcLogger {
option.dialogId = diagid; option.dialogId = diagid;
option.title = dialog.title; option.title = dialog.title;
npc.dialogs.put(0, option); npc.dialogs.put(0, option);
NoppesUtilServer.openDialog(player, npc, dialog); NoppesUtilServer.openDialog(player, npc, dialog, 0);
} }
} }
+23 -42
View File
@@ -1,8 +1,6 @@
package noppes.npcs; package noppes.npcs;
import java.io.File; import com.google.common.util.concurrent.ThreadFactoryBuilder;
import java.util.Set;
import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.Mod.EventHandler;
@@ -25,50 +23,34 @@ import net.minecraftforge.common.MinecraftForge;
import nikedemos.markovnames.generators.*; import nikedemos.markovnames.generators.*;
import noppes.npcs.config.ConfigLoader; import noppes.npcs.config.ConfigLoader;
import noppes.npcs.config.ConfigProp; import noppes.npcs.config.ConfigProp;
import noppes.npcs.controllers.BankController; import noppes.npcs.controllers.*;
import noppes.npcs.controllers.ChunkController;
import noppes.npcs.controllers.DialogController;
import noppes.npcs.controllers.FactionController;
import noppes.npcs.controllers.GlobalDataController;
import noppes.npcs.controllers.LinkedNpcController;
import noppes.npcs.controllers.PixelmonHelper;
import noppes.npcs.controllers.PlayerDataController;
import noppes.npcs.controllers.QuestController;
import noppes.npcs.controllers.RecipeController;
import noppes.npcs.controllers.ScriptController;
import noppes.npcs.controllers.ServerCloneController;
import noppes.npcs.controllers.SpawnController;
import noppes.npcs.controllers.TransportController;
import noppes.npcs.enchants.EnchantInterface; import noppes.npcs.enchants.EnchantInterface;
import noppes.npcs.entity.*; import noppes.npcs.entity.*;
import noppes.npcs.entity.old.EntityNPCDwarfFemale; import noppes.npcs.entity.old.*;
import noppes.npcs.entity.old.EntityNPCDwarfMale;
import noppes.npcs.entity.old.EntityNPCElfFemale;
import noppes.npcs.entity.old.EntityNPCElfMale;
import noppes.npcs.entity.old.EntityNPCEnderman;
import noppes.npcs.entity.old.EntityNPCFurryFemale;
import noppes.npcs.entity.old.EntityNPCFurryMale;
import noppes.npcs.entity.old.EntityNPCHumanFemale;
import noppes.npcs.entity.old.EntityNPCHumanMale;
import noppes.npcs.entity.old.EntityNPCOrcFemale;
import noppes.npcs.entity.old.EntityNPCOrcMale;
import noppes.npcs.entity.old.EntityNPCVillager;
import noppes.npcs.entity.old.EntityNpcEnderchibi;
import noppes.npcs.entity.old.EntityNpcMonsterFemale;
import noppes.npcs.entity.old.EntityNpcMonsterMale;
import noppes.npcs.entity.old.EntityNpcNagaFemale;
import noppes.npcs.entity.old.EntityNpcNagaMale;
import noppes.npcs.entity.old.EntityNpcSkeleton;
import noppes.npcs.scripted.wrapper.WrapperNpcAPI; import noppes.npcs.scripted.wrapper.WrapperNpcAPI;
import java.io.File;
import java.util.Set;
@Mod(modid = "customnpcs", name = "CustomNpcs", version = "1.5.1-beta") @Mod(modid = "customnpcs", name = "CustomNpcs", version = "1.6-beta")
public class CustomNpcs { public class CustomNpcs {
@ConfigProp(info = "Disable Chat Bubbles") @ConfigProp(info = "Disable Chat Bubbles")
public static boolean EnableChatBubbles = true; public static boolean EnableChatBubbles = true;
private static int NewEntityStartId = 0; private static int NewEntityStartId = 0;
@ConfigProp(info = "Enables/Disables ALL scripting. You can still see and write code in the scripter, but these scripts won't run. True by default")
public static boolean ScriptingEnabled = true;
@ConfigProp(info = "Enables global player event scripts to be used in the scripter. You can still see and write code in the scripter, but these scripts won't run. True by default.")
public static boolean GlobalPlayerScripts = true;
@ConfigProp(info = "Enables global forge event scripts to be used in the scripter. You can still see and write code in the scripter, but these scripts won't run. True by default.")
public static boolean GlobalForgeScripts = true;
@ConfigProp(info = "Enables global NPC scripts to be used in the scripter. You can still see and write code in the scripter, but these scripts won't run. False by default, use with caution!")
public static boolean GlobalNPCScripts = false;
@ConfigProp(info = "Navigation search range for NPCs. Not recommended to increase if you have a slow pc or on a server. Minimum of 16, maximum of 96.") @ConfigProp(info = "Navigation search range for NPCs. Not recommended to increase if you have a slow pc or on a server. Minimum of 16, maximum of 96.")
public static int NpcNavRange = 32; public static int NpcNavRange = 32;
@@ -227,14 +209,12 @@ public class CustomNpcs {
registerNpc(EntityNPCGolem.class, "npcGolem"); registerNpc(EntityNPCGolem.class, "npcGolem");
registerNpc(EntityCustomNpc.class, "CustomNpc"); registerNpc(EntityCustomNpc.class, "CustomNpc");
registerNewEntity(EntityChairMount.class, "CustomNpcChairMount", 64, 10, false); registerNewEntity(EntityChairMount.class, "CustomNpcChairMount", 64, 10, false);
registerNewEntity(EntityProjectile.class, "throwableitem", 64, 3, true); registerNewEntity(EntityProjectile.class, "throwableitem", 64, 3, true);
registerNewEntity(EntityMagicProjectile.class, "magicprojectile", 64, 3, true); registerNewEntity(EntityMagicProjectile.class, "magicprojectile", 64, 3, true);
new RecipeController(); new RecipeController();
ForgeChunkManager.setForcedChunkLoadingCallback(this, new ChunkController()); ForgeChunkManager.setForcedChunkLoadingCallback(this, new ChunkController());
new CustomNpcsPermissions(); new CustomNpcsPermissions();
@@ -270,6 +250,7 @@ public class CustomNpcs {
new LinkedNpcController(); new LinkedNpcController();
ScriptController.Instance.loadStoredData(); ScriptController.Instance.loadStoredData();
ScriptController.Instance.loadForgeScripts(); ScriptController.Instance.loadForgeScripts();
ScriptController.Instance.loadNPCScripts();
ScriptController.Instance.loadPlayerScripts(); ScriptController.Instance.loadPlayerScripts();
ScriptController.HasStart = false; ScriptController.HasStart = false;
WrapperNpcAPI.clearCache(); WrapperNpcAPI.clearCache();
@@ -109,6 +109,7 @@ public class DataScript implements IScriptHandler {
return false; return false;
if(!hasInited){ if(!hasInited){
hasInited = true; hasInited = true;
EventHooks.onNPCInit(this.npc);
callScript(EnumScriptType.INIT); callScript(EnumScriptType.INIT);
} }
ScriptContainer script = scripts.get(type.ordinal()); ScriptContainer script = scripts.get(type.ordinal());
+138 -5
View File
@@ -19,13 +19,13 @@ import net.minecraft.world.World;
import net.minecraft.world.WorldServer; import net.minecraft.world.WorldServer;
import net.minecraftforge.event.entity.EntityEvent; import net.minecraftforge.event.entity.EntityEvent;
import net.minecraftforge.event.world.WorldEvent; import net.minecraftforge.event.world.WorldEvent;
import noppes.npcs.controllers.CustomGuiController; import noppes.npcs.controllers.*;
import noppes.npcs.controllers.Quest;
import noppes.npcs.controllers.ScriptController;
import noppes.npcs.controllers.data.ForgeDataScript; import noppes.npcs.controllers.data.ForgeDataScript;
import noppes.npcs.controllers.data.NPCDataScript;
import noppes.npcs.controllers.data.PlayerDataScript; import noppes.npcs.controllers.data.PlayerDataScript;
import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.scripted.*; import noppes.npcs.scripted.*;
import noppes.npcs.scripted.entity.ScriptNpc;
import noppes.npcs.scripted.entity.ScriptPlayer; import noppes.npcs.scripted.entity.ScriptPlayer;
import noppes.npcs.scripted.event.*; import noppes.npcs.scripted.event.*;
import noppes.npcs.scripted.event.PlayerEvent.ChatEvent; import noppes.npcs.scripted.event.PlayerEvent.ChatEvent;
@@ -42,7 +42,6 @@ import noppes.npcs.scripted.interfaces.IItemStack;
import noppes.npcs.scripted.interfaces.IWorld; import noppes.npcs.scripted.interfaces.IWorld;
import noppes.npcs.scripted.wrapper.WrapperNpcAPI; import noppes.npcs.scripted.wrapper.WrapperNpcAPI;
import noppes.npcs.constants.EnumScriptType; import noppes.npcs.constants.EnumScriptType;
import noppes.npcs.controllers.PlayerData;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import java.util.ArrayList; import java.util.ArrayList;
@@ -51,12 +50,146 @@ public class EventHooks {
public EventHooks() { public EventHooks() {
} }
public static void onNPCInit(EntityNPCInterface npc) {
if(npc == null || npc.wrappedNPC == null)
return;
noppes.npcs.scripted.event.NpcEvent.InitEvent event = new noppes.npcs.scripted.event.NpcEvent.InitEvent(npc.wrappedNPC);
ScriptController.Instance.npcScripts.callScript(EnumScriptType.INIT, event);
npc.script.callScript(EnumScriptType.INIT);
WrapperNpcAPI.EVENT_BUS.post(event);
}
public static void onNPCUpdate(EntityNPCInterface npc) {
if(npc == null || npc.wrappedNPC == null)
return;
noppes.npcs.scripted.event.NpcEvent.UpdateEvent event = new noppes.npcs.scripted.event.NpcEvent.UpdateEvent(npc.wrappedNPC);
ScriptController.Instance.npcScripts.callScript(EnumScriptType.TICK, event);
npc.script.callScript(EnumScriptType.TICK);
WrapperNpcAPI.EVENT_BUS.post(event);
}
public static void onNPCDialog(EntityNPCInterface npc, EntityPlayer player, int dialogId, int optionId, Dialog dialog) {
if(npc == null || npc.wrappedNPC == null)
return;
NpcEvent.DialogEvent event = new NpcEvent.DialogEvent(npc.wrappedNPC, player, dialogId, optionId, dialog);
ScriptController.Instance.npcScripts.callScript(EnumScriptType.DIALOG, event);
ScriptEventDialog npcEvent = new ScriptEventDialog(player,dialogId,optionId,dialog);
npc.script.callScript(EnumScriptType.DIALOG, "event", npcEvent, "player", npcEvent.getPlayer(), "dialog", npcEvent.getDialogId(), "option", npcEvent.getOptionId(), "dialogObj", npcEvent.getDialog());
WrapperNpcAPI.EVENT_BUS.post(event);
}
public static void onNPCDialogClosed(EntityNPCInterface npc, EntityPlayer player, int dialogId, int optionId, Dialog dialog) {
if(npc == null || npc.wrappedNPC == null)
return;
NpcEvent.DialogClosedEvent event = new NpcEvent.DialogClosedEvent(npc.wrappedNPC, player, dialogId, optionId, dialog);
ScriptController.Instance.npcScripts.callScript(EnumScriptType.DIALOG_CLOSE, event);
ScriptEventDialog npcEvent = new ScriptEventDialog(player,dialogId,optionId,dialog);
npc.script.callScript(EnumScriptType.DIALOG_CLOSE, "event", npcEvent, "player", npcEvent.getPlayer(), "dialog", npcEvent.getDialogId(), "option", npcEvent.getOptionId(), "dialogObj", npcEvent.getDialog());
WrapperNpcAPI.EVENT_BUS.post(event);
}
public static boolean onNPCInteract(EntityNPCInterface npc, EntityPlayer player) {
if(npc == null || npc.wrappedNPC == null)
return false;
NpcEvent.InteractEvent event = new NpcEvent.InteractEvent(npc.wrappedNPC,player);
ScriptController.Instance.npcScripts.callScript(EnumScriptType.INTERACT, event);
boolean result = npc.script.callScript(EnumScriptType.INTERACT, "player", player);
WrapperNpcAPI.EVENT_BUS.post(event);
return result;
}
public static boolean onNPCMeleeAttack(EntityNPCInterface npc, float damage, EntityLivingBase target){
if(npc == null || npc.wrappedNPC == null)
return false;
NpcEvent.MeleeAttackEvent event = new NpcEvent.MeleeAttackEvent(npc.wrappedNPC,damage,target);
ScriptController.Instance.npcScripts.callScript(EnumScriptType.ATTACK_MELEE, event);
boolean result = npc.script.callScript(EnumScriptType.ATTACK, "event", new ScriptEventAttack(damage,target,false), "target", target);
WrapperNpcAPI.EVENT_BUS.post(event);
return result;
}
public static boolean onNPCRangedAttack(EntityNPCInterface npc, float damage, EntityLivingBase target){
if(npc == null || npc.wrappedNPC == null)
return false;
NpcEvent.RangedLaunchedEvent event = new NpcEvent.RangedLaunchedEvent(npc.wrappedNPC,damage,target);
ScriptController.Instance.npcScripts.callScript(EnumScriptType.RANGED_LAUNCHED, event);
boolean result = npc.script.callScript(EnumScriptType.ATTACK, "event", new ScriptEventAttack(damage,target,true), "target", target);
WrapperNpcAPI.EVENT_BUS.post(event);
return result;
}
public static void onNPCKilledEntity(EntityNPCInterface npc, EntityLivingBase entity){
if(npc == null || npc.wrappedNPC == null)
return;
NpcEvent.KilledEntityEvent event = new NpcEvent.KilledEntityEvent(npc.wrappedNPC,entity);
ScriptController.Instance.npcScripts.callScript(EnumScriptType.KILLS, event);
npc.script.callScript(EnumScriptType.KILLS, "target", entity);
WrapperNpcAPI.EVENT_BUS.post(event);
}
public static boolean onNPCTarget(EntityNPCInterface npc, EntityLivingBase target){
if(npc == null || npc.wrappedNPC == null)
return false;
NpcEvent.TargetEvent event = new NpcEvent.TargetEvent(npc.wrappedNPC,target);
ScriptController.Instance.npcScripts.callScript(EnumScriptType.TARGET, event);
boolean result = npc.script.callScript(EnumScriptType.TARGET, "event", new ScriptEventTarget(target));
WrapperNpcAPI.EVENT_BUS.post(event);
return result;
}
public static void onNPCCollide(EntityNPCInterface npc, Entity entity){
if(npc == null || npc.wrappedNPC == null)
return;
NpcEvent.CollideEvent event = new NpcEvent.CollideEvent(npc.wrappedNPC,entity);
ScriptController.Instance.npcScripts.callScript(EnumScriptType.COLLIDE, event);
npc.script.callScript(EnumScriptType.COLLIDE, "entity", entity);
WrapperNpcAPI.EVENT_BUS.post(event);
}
public static boolean onNPCDamaged(EntityNPCInterface npc, Entity source, float damage, DamageSource damagesource, ScriptEventDamaged damagedEvent){
if(npc == null || npc.wrappedNPC == null)
return false;
NpcEvent.DamagedEvent event = new NpcEvent.DamagedEvent(npc.wrappedNPC,source,damage,damagesource);
ScriptController.Instance.npcScripts.callScript(EnumScriptType.DAMAGED, event);
boolean result = npc.script.callScript(EnumScriptType.DAMAGED, "event", damagedEvent);
WrapperNpcAPI.EVENT_BUS.post(event);
return result;
}
public static boolean onNPCKilled(EntityNPCInterface npc, DamageSource damagesource, Entity entity, ScriptEventKilled killedEvent){
if(npc == null || npc.wrappedNPC == null)
return false;
NpcEvent.DiedEvent event = new NpcEvent.DiedEvent(npc.wrappedNPC,damagesource,entity);
ScriptController.Instance.npcScripts.callScript(EnumScriptType.KILLED, event);
boolean result = npc.script.callScript(EnumScriptType.KILLED, "event", killedEvent);
WrapperNpcAPI.EVENT_BUS.post(event);
return result;
}
public static void onNPCTimer(EntityNPCInterface npc, int id) { public static void onNPCTimer(EntityNPCInterface npc, int id) {
if(npc == null || npc.wrappedNPC == null)
return;
NpcEvent.TimerEvent event = new NpcEvent.TimerEvent(npc.wrappedNPC, id); NpcEvent.TimerEvent event = new NpcEvent.TimerEvent(npc.wrappedNPC, id);
ScriptEventTimer scriptEvent = new ScriptEventTimer(id); ScriptEventTimer scriptEvent = new ScriptEventTimer(id);
npc.script.callScript(EnumScriptType.TIMER, "event", scriptEvent); npc.script.callScript(EnumScriptType.TIMER, "event", scriptEvent);
ScriptController.Instance.npcScripts.callScript(EnumScriptType.TIMER, event);
WrapperNpcAPI.EVENT_BUS.post(event); WrapperNpcAPI.EVENT_BUS.post(event);
} }
@@ -35,9 +35,6 @@ public class ModelPartData {
type = compound.getByte("Type"); type = compound.getByte("Type");
color = compound.getInteger("Color"); color = compound.getInteger("Color");
texture = compound.getString("Texture"); texture = compound.getString("Texture");
if(texture.contains("moreplayermodels:textures")){
texture = texture.replace("moreplayermodels:textures", "customnpcs:textures/parts");
}
playerTexture = compound.getBoolean("PlayerTexture"); playerTexture = compound.getBoolean("PlayerTexture");
location = null; location = null;
} }
@@ -253,7 +253,7 @@ public class NoppesUtilPlayer {
return; return;
EventHooks.onDialogOption(new DialogEvent.DialogOption(new ScriptPlayer((EntityPlayerMP) player), dialog)); EventHooks.onDialogOption(new DialogEvent.DialogOption(new ScriptPlayer((EntityPlayerMP) player), dialog));
npc.script.callScript(EnumScriptType.DIALOG_CLOSE, "player", player, "dialog", dialogId, "option", optionId + 1); EventHooks.onNPCDialogClosed(npc,player,dialogId,optionId+1,dialog);
if(!dialog.hasDialogs(player) && !dialog.hasOtherOptions()) { if(!dialog.hasDialogs(player) && !dialog.hasOtherOptions()) {
EventHooks.onDialogClosed(new DialogEvent.DialogClosed(new ScriptPlayer((EntityPlayerMP) player), dialog)); EventHooks.onDialogClosed(new DialogEvent.DialogClosed(new ScriptPlayer((EntityPlayerMP) player), dialog));
@@ -271,7 +271,7 @@ public class NoppesUtilPlayer {
Server.sendData(player, EnumPacketClient.GUI_CLOSE); Server.sendData(player, EnumPacketClient.GUI_CLOSE);
} }
else if(option.optionType == EnumOptionType.DialogOption){ else if(option.optionType == EnumOptionType.DialogOption){
NoppesUtilServer.openDialog(player, npc, option.getDialog()); NoppesUtilServer.openDialog(player, npc, option.getDialog(), optionId+1);
} }
else if(option.optionType == EnumOptionType.CommandBlock){ else if(option.optionType == EnumOptionType.CommandBlock){
Server.sendData(player, EnumPacketClient.GUI_CLOSE); Server.sendData(player, EnumPacketClient.GUI_CLOSE);
@@ -180,7 +180,7 @@ public class NoppesUtilServer {
return item; return item;
} }
public static void openDialog(EntityPlayer player, EntityNPCInterface npc, Dialog dia){ public static void openDialog(EntityPlayer player, EntityNPCInterface npc, Dialog dia, int optionId){
Dialog dialog = dia.copy(player); Dialog dialog = dia.copy(player);
EventHooks.onDialogOpen(new DialogEvent.DialogOpen(new ScriptPlayer((EntityPlayerMP) player), dialog)); EventHooks.onDialogOpen(new DialogEvent.DialogOpen(new ScriptPlayer((EntityPlayerMP) player), dialog));
@@ -203,7 +203,7 @@ public class NoppesUtilServer {
if(!data.dialogsRead.contains(dialog.id)) if(!data.dialogsRead.contains(dialog.id))
data.dialogsRead.add(dialog.id); data.dialogsRead.add(dialog.id);
setEditingNpc(player, npc); setEditingNpc(player, npc);
npc.script.callScript(EnumScriptType.DIALOG, "event", new ScriptEventDialog(), "player", player, "dialog", dialog.id); EventHooks.onNPCDialog(npc, player, dialog.id, optionId, dialog);
} }
public static void runCommand(EntityPlayer player, String name, String command){ public static void runCommand(EntityPlayer player, String name, String command){
runCommand(player, name, command, player); runCommand(player, name, command, player);
@@ -312,11 +312,14 @@ public class NoppesUtilServer {
Server.sendAssociatedData(entity, EnumPacketClient.PARTICLE, entity.posX, entity.posY, entity.posZ, entity.height, entity.width, entity.yOffset, particle); Server.sendAssociatedData(entity, EnumPacketClient.PARTICLE, entity.posX, entity.posY, entity.posZ, entity.height, entity.width, entity.yOffset, particle);
} }
public static void spawnScriptedParticle(Entity entity, String directory, int HEXcolor, int amount, int maxAge, public static void spawnScriptedParticle(String directory, int HEXcolor, int amount, int maxAge,
double x, double y, double z, double x, double y, double z,
double motionX, double motionY, double motionZ, float gravity, double motionX, double motionY, double motionZ, float gravity,
float scale1, float scale2, float scaleRate, int scaleRateStart, float scale1, float scale2, float scaleRate, int scaleRateStart,
float alpha1, float alpha2, float alphaRate, int alphaRateStart, float alpha1, float alpha2, float alphaRate, int alphaRateStart,
float rotationX1, float rotationX2, float rotationXRate, int rotationXRateStart,
float rotationY1, float rotationY2, float rotationYRate, int rotationYRateStart,
float rotationZ1, float rotationZ2, float rotationZRate, int rotationZRateStart,
int entityID int entityID
){ ){
Server.sendToAll(EnumPacketClient.SCRIPTED_PARTICLE, Server.sendToAll(EnumPacketClient.SCRIPTED_PARTICLE,
@@ -325,6 +328,9 @@ public class NoppesUtilServer {
motionX, motionY, motionZ, gravity, motionX, motionY, motionZ, gravity,
scale1, scale2, scaleRate, scaleRateStart, scale1, scale2, scaleRate, scaleRateStart,
alpha1, alpha2, alphaRate, alphaRateStart, alpha1, alpha2, alphaRate, alphaRateStart,
rotationX1, rotationX2, rotationXRate, rotationXRateStart,
rotationY1, rotationY2, rotationYRate, rotationYRateStart,
rotationZ1, rotationZ2, rotationZRate, rotationZRateStart,
entityID entityID
); );
} }
@@ -41,6 +41,7 @@ import noppes.npcs.containers.ContainerMail;
import noppes.npcs.controllers.*; import noppes.npcs.controllers.*;
import noppes.npcs.controllers.LinkedNpcController.LinkedData; import noppes.npcs.controllers.LinkedNpcController.LinkedData;
import noppes.npcs.controllers.data.ForgeDataScript; import noppes.npcs.controllers.data.ForgeDataScript;
import noppes.npcs.controllers.data.NPCDataScript;
import noppes.npcs.controllers.data.PlayerDataScript; import noppes.npcs.controllers.data.PlayerDataScript;
import noppes.npcs.entity.EntityCustomNpc; import noppes.npcs.entity.EntityCustomNpc;
import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.entity.EntityNPCInterface;
@@ -102,7 +103,7 @@ public class PacketHandlerServer{
else if(type.hasPermission() && !CustomNpcsPermissions.Instance.hasPermission(player, type.permission)){ else if(type.hasPermission() && !CustomNpcsPermissions.Instance.hasPermission(player, type.permission)){
//player doesnt have permission to do this //player doesnt have permission to do this
} }
else if(item == null && (type == EnumPacketServer.ScriptPlayerGet || type == EnumPacketServer.ScriptPlayerSave || type == EnumPacketServer.ScriptForgeGet || type == EnumPacketServer.ScriptForgeSave)) else if(item == null && (type == EnumPacketServer.ScriptPlayerGet || type == EnumPacketServer.ScriptPlayerSave || type == EnumPacketServer.ScriptNPCGet || type == EnumPacketServer.ScriptNPCSave || type == EnumPacketServer.ScriptForgeGet || type == EnumPacketServer.ScriptForgeSave))
warn(player, "tried to use custom npcs without a tool in hand, probably a hacker"); warn(player, "tried to use custom npcs without a tool in hand, probably a hacker");
else { else {
if (item != null) { if (item != null) {
@@ -118,6 +119,8 @@ public class PacketHandlerServer{
featherPackets(type, buffer, player); featherPackets(type, buffer, player);
else if (type == EnumPacketServer.ScriptPlayerGet || type == EnumPacketServer.ScriptPlayerSave) else if (type == EnumPacketServer.ScriptPlayerGet || type == EnumPacketServer.ScriptPlayerSave)
playerScriptPackets(type, buffer, player); playerScriptPackets(type, buffer, player);
else if (type == EnumPacketServer.ScriptNPCGet || type == EnumPacketServer.ScriptNPCSave)
npcScriptPackets(type, buffer, player);
else if (type == EnumPacketServer.ScriptForgeGet || type == EnumPacketServer.ScriptForgeSave) else if (type == EnumPacketServer.ScriptForgeGet || type == EnumPacketServer.ScriptForgeSave)
forgeScriptPackets(type, buffer, player); forgeScriptPackets(type, buffer, player);
else if (item.getItem() == CustomItems.scripter) else if (item.getItem() == CustomItems.scripter)
@@ -172,6 +175,18 @@ public class PacketHandlerServer{
} }
} }
private void npcScriptPackets(EnumPacketServer type, ByteBuf buffer, EntityPlayerMP player) throws Exception {
NBTTagCompound compound;
if(type == EnumPacketServer.ScriptNPCGet) {
NPCDataScript data = ScriptController.Instance.npcScripts;
compound = data.writeToNBT(new NBTTagCompound());
compound.setTag("Languages", ScriptController.Instance.nbtLanguages());
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
} else if(type == EnumPacketServer.ScriptNPCSave) {
ScriptController.Instance.setNPCScripts(Server.readNBT(buffer));
}
}
private void featherPackets(EnumPacketServer type, ByteBuf buffer, EntityPlayerMP player) throws IOException { private void featherPackets(EnumPacketServer type, ByteBuf buffer, EntityPlayerMP player) throws IOException {
if(type == EnumPacketServer.DimensionsGet){ if(type == EnumPacketServer.DimensionsGet){
HashMap<String,Integer> map = new HashMap<String,Integer>(); HashMap<String,Integer> map = new HashMap<String,Integer>();
@@ -257,7 +257,7 @@ public class ServerEventsHandler {
if(line != null) if(line != null)
npc.saySurrounding(line.formatTarget(event.entityLiving)); npc.saySurrounding(line.formatTarget(event.entityLiving));
npc.script.callScript(EnumScriptType.KILLS, "target", event.entityLiving); EventHooks.onNPCKilledEntity(npc,event.entityLiving);
} }
EntityPlayer player = null; EntityPlayer player = null;
@@ -308,7 +308,16 @@ public class ServerEventsHandler {
} }
String name = entityName; String name = entityName;
QuestKill quest = (QuestKill) data.quest.questInterface; QuestKill quest = (QuestKill) data.quest.questInterface;
if(quest.targetType == 1 && !(entity instanceof EntityNPCInterface))
Class entityType = EntityNPCInterface.class;
if(quest.targetType == 2) {
try {
entityType = Class.forName(quest.customTargetType);
} catch (ClassNotFoundException notFoundException) {
continue;
}
}
if(quest.targetType > 0 && !(entityType.isInstance(entity)))
continue; continue;
if(quest.targets.containsKey(entity.getCommandSenderName())) if(quest.targets.containsKey(entity.getCommandSenderName()))
name = entity.getCommandSenderName(); name = entity.getCommandSenderName();
@@ -12,11 +12,32 @@ import noppes.npcs.controllers.Lines;
import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.entity.EntityNPCInterface;
public class VersionCompatibility { public class VersionCompatibility {
public static int ModRev = 16; public static int ModRev = 18;
public static void CheckNpcCompatibility(EntityNPCInterface npc, NBTTagCompound compound){ public static void CheckNpcCompatibility(EntityNPCInterface npc, NBTTagCompound compound){
if(npc.npcVersion == ModRev) if(npc.npcVersion == ModRev)
return; return;
if(npc.npcVersion < 18){
// Fix 64-Texture (Reorganization)
// Fix CloakTexture (Reorganization)
String cloakTexture = compound.getString("CloakTexture");
cloakTexture = cloakTexture.replace("/cloak/Daybreak/", "/cloak/Guilds/Daybreak/");
cloakTexture = cloakTexture.replace("/cloak/Created/", "/cloak/Extras/");
cloakTexture = cloakTexture.replace("/cloak/Color Capes/", "/cloak/Color/");
compound.setString("CloakTexture", cloakTexture);
}
if(npc.npcVersion < 17){
// Fix DialogDarkenScreen
if(compound.hasKey("DialogDarkenScreen")){
compound.removeTag("DialogDarkenScreen");
}
// Remove MPM Texture Requirement
String texture = compound.getString("Texture");
texture = texture.replace("moreplayermodels:textures", "customnpcs:textures/parts");
compound.setString("Texture", texture);
}
if(npc.npcVersion < 12){ if(npc.npcVersion < 12){
CompatabilityFix(compound, npc.advanced.writeToNBT(new NBTTagCompound())); CompatabilityFix(compound, npc.advanced.writeToNBT(new NBTTagCompound()));
CompatabilityFix(compound, npc.ai.writeToNBT(new NBTTagCompound())); CompatabilityFix(compound, npc.ai.writeToNBT(new NBTTagCompound()));
@@ -166,79 +166,27 @@ public class FlyPathFinder extends PathFinder
b0 = 1; b0 = 1;
} }
FlyPathPoint pathpoint3 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord, p_75860_2_.yCoord, p_75860_2_.zCoord + 1, p_75860_3_, b0); for(int y = -1; y <= 1; y ++) {
FlyPathPoint pathpoint4 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord - 1, p_75860_2_.yCoord, p_75860_2_.zCoord, p_75860_3_, b0); FlyPathPoint pathpoint3 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord, p_75860_2_.yCoord + y, p_75860_2_.zCoord + 1, p_75860_3_, b0);
FlyPathPoint pathpoint5 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord + 1, p_75860_2_.yCoord, p_75860_2_.zCoord, p_75860_3_, b0); FlyPathPoint pathpoint4 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord - 1, p_75860_2_.yCoord + y, p_75860_2_.zCoord, p_75860_3_, b0);
FlyPathPoint pathpoint6 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord, p_75860_2_.yCoord, p_75860_2_.zCoord - 1, p_75860_3_, b0); FlyPathPoint pathpoint5 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord + 1, p_75860_2_.yCoord + y, p_75860_2_.zCoord, p_75860_3_, b0);
FlyPathPoint pathpoint6 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord, p_75860_2_.yCoord + y, p_75860_2_.zCoord - 1, p_75860_3_, b0);
FlyPathPoint pathpoint7 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord, p_75860_2_.yCoord + 1, p_75860_2_.zCoord + 1, p_75860_3_, b0); if (pathpoint3 != null && !pathpoint3.isFirst && pathpoint3.distanceTo(p_75860_4_) < p_75860_5_) {
FlyPathPoint pathpoint8 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord - 1, p_75860_2_.yCoord + 1, p_75860_2_.zCoord, p_75860_3_, b0); this.pathOptions[i++] = pathpoint3;
FlyPathPoint pathpoint9 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord + 1, p_75860_2_.yCoord + 1, p_75860_2_.zCoord, p_75860_3_, b0); }
FlyPathPoint pathpoint10 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord, p_75860_2_.yCoord + 1, p_75860_2_.zCoord - 1, p_75860_3_, b0);
FlyPathPoint pathpoint11 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord, p_75860_2_.yCoord - 1, p_75860_2_.zCoord + 1, p_75860_3_, b0); if (pathpoint4 != null && !pathpoint4.isFirst && pathpoint4.distanceTo(p_75860_4_) < p_75860_5_) {
FlyPathPoint pathpoint12 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord - 1, p_75860_2_.yCoord - 1, p_75860_2_.zCoord, p_75860_3_, b0); this.pathOptions[i++] = pathpoint4;
FlyPathPoint pathpoint13 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord + 1, p_75860_2_.yCoord - 1, p_75860_2_.zCoord, p_75860_3_, b0); }
FlyPathPoint pathpoint14 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord, p_75860_2_.yCoord - 1, p_75860_2_.zCoord - 1, p_75860_3_, b0);
if (pathpoint3 != null && !pathpoint3.isFirst && pathpoint3.distanceTo(p_75860_4_) < p_75860_5_) if (pathpoint5 != null && !pathpoint5.isFirst && pathpoint5.distanceTo(p_75860_4_) < p_75860_5_) {
{ this.pathOptions[i++] = pathpoint5;
this.pathOptions[i++] = pathpoint3; }
}
if (pathpoint4 != null && !pathpoint4.isFirst && pathpoint4.distanceTo(p_75860_4_) < p_75860_5_) if (pathpoint6 != null && !pathpoint6.isFirst && pathpoint6.distanceTo(p_75860_4_) < p_75860_5_) {
{ this.pathOptions[i++] = pathpoint6;
this.pathOptions[i++] = pathpoint4; }
}
if (pathpoint5 != null && !pathpoint5.isFirst && pathpoint5.distanceTo(p_75860_4_) < p_75860_5_)
{
this.pathOptions[i++] = pathpoint5;
}
if (pathpoint6 != null && !pathpoint6.isFirst && pathpoint6.distanceTo(p_75860_4_) < p_75860_5_)
{
this.pathOptions[i++] = pathpoint6;
}
if (pathpoint7 != null && !pathpoint7.isFirst && pathpoint7.distanceTo(p_75860_4_) < p_75860_5_)
{
this.pathOptions[i++] = pathpoint7;
}
if (pathpoint8 != null && !pathpoint8.isFirst && pathpoint8.distanceTo(p_75860_4_) < p_75860_5_)
{
this.pathOptions[i++] = pathpoint8;
}
if (pathpoint9 != null && !pathpoint9.isFirst && pathpoint9.distanceTo(p_75860_4_) < p_75860_5_)
{
this.pathOptions[i++] = pathpoint9;
}
if (pathpoint10 != null && !pathpoint10.isFirst && pathpoint10.distanceTo(p_75860_4_) < p_75860_5_)
{
this.pathOptions[i++] = pathpoint10;
}
if (pathpoint11 != null && !pathpoint11.isFirst && pathpoint11.distanceTo(p_75860_4_) < p_75860_5_)
{
this.pathOptions[i++] = pathpoint11;
}
if (pathpoint12 != null && !pathpoint12.isFirst && pathpoint12.distanceTo(p_75860_4_) < p_75860_5_)
{
this.pathOptions[i++] = pathpoint12;
}
if (pathpoint13 != null && !pathpoint13.isFirst && pathpoint13.distanceTo(p_75860_4_) < p_75860_5_)
{
this.pathOptions[i++] = pathpoint13;
}
if (pathpoint14 != null && !pathpoint14.isFirst && pathpoint14.distanceTo(p_75860_4_) < p_75860_5_)
{
this.pathOptions[i++] = pathpoint14;
} }
return i; return i;
@@ -29,48 +29,36 @@ public class FlyingMoveHelper extends EntityMoveHelper{
if (this.update) { if (this.update) {
this.update = false; this.update = false;
double speed = this.entity.getEntityAttribute(SharedMonsterAttributes.movementSpeed).getAttributeValue(); double speed = this.speed * this.entity.getEntityAttribute(SharedMonsterAttributes.movementSpeed).getAttributeValue() * this.entity.ai.flySpeed;
double speedMult = 0.6000000238418579D / 0.5D;
double d0 = this.posX - this.entity.posX; double d0 = this.posX - this.entity.posX;
double d1 = this.posY - this.entity.posY; double d1 = this.posY - MathHelper.floor_double(this.entity.boundingBox.minY + 0.05D);
double d2 = this.posZ - this.entity.posZ; double d2 = this.posZ - this.entity.posZ;
double d4 = d0 * d0 + d1 * d1 + d2 * d2; double d4 = d0 * d0 + d1 * d1 + d2 * d2;
double d5 = MathHelper.sqrt_double(d4);
if (this.entity.hurtTime == 0 && d4 > 0.5D) { double heightOffGround = 0;
if (this.posY != this.entity.posY) { if(this.entity.ai.hasFlyLimit) {
if (this.entity.motionY * Math.signum(this.entity.posY - this.posY) > 0.0D) { for (int blockY = (int) this.posY; blockY > 0; blockY--) {
this.entity.motionY = 0.0D; heightOffGround = this.posY - blockY;
if (this.entity.worldObj.getBlock((int) this.posX, blockY, (int) this.posZ) != Blocks.air || heightOffGround > this.entity.ai.flyHeightLimit){
break;
} }
double verticalSpeed = Math.abs(this.entity.posY - this.posY);
if(verticalSpeed > speed * speedMult)
verticalSpeed = speed * speedMult;
verticalSpeed += this.entity.ai.flySpeed/2.0D;
if(verticalSpeed > Math.abs(this.entity.posY - this.posY))
verticalSpeed = Math.abs(this.entity.posY - this.posY);
int blockY = (int) this.posY;
double heightOffGround = 0;
if(this.entity.ai.hasFlyLimit) {
for (blockY = (int) this.posY; blockY > 0; blockY--) {
heightOffGround = this.posY - blockY;
if (this.entity.worldObj.getBlock((int) this.posX, blockY, (int) this.posZ) != Blocks.air || heightOffGround > this.entity.ai.flyHeightLimit){
break;
}
}
}
if(heightOffGround < this.entity.ai.flyHeightLimit || !this.entity.ai.hasFlyLimit)
this.entity.motionY -= Math.signum(this.entity.posY - this.posY) * verticalSpeed;
} }
double d5 = MathHelper.sqrt_double(d4);
this.entity.motionX += (d0 / d5 * speed - this.entity.motionX) * speed * speedMult;
this.entity.motionZ += (d2 / d5 * speed - this.entity.motionZ) * speed * speedMult;
} }
this.entity.rotationYaw = this.limitAngle(this.entity.rotationYaw,(float) ((Math.atan2(-d0, -d2) + Math.PI) * -(180F / Math.PI)),30.0F); if (this.entity.hurtTime == 0 && d4 > 0.5D) {
this.entity.motionX += (d0 / d5 * speed - this.entity.motionX) * speed;
this.entity.motionZ += (d2 / d5 * speed - this.entity.motionZ) * speed;
if (heightOffGround < this.entity.ai.flyHeightLimit || !this.entity.ai.hasFlyLimit) {
this.entity.motionY += (d1 / d5 * speed - this.entity.motionY) * speed;
}
this.entity.velocityChanged = true;
}
this.entity.rotationYaw = this.limitAngle(this.entity.rotationYaw,(float) ((Math.atan2(-d0, -d2) + Math.PI) * -(180F / Math.PI)),18.0F);
} }
} }
@@ -289,15 +289,15 @@ public class PathNavigateFlying extends PathNavigate {
private Vec3 getEntityPosition() private Vec3 getEntityPosition()
{ {
return Vec3.createVectorHelper(this.theEntity.posX, (double)this.getPathableYPos(), this.theEntity.posZ); return Vec3.createVectorHelper(this.theEntity.posX, this.getPathableYPos(), this.theEntity.posZ);
} }
/** /**
* Gets the safe pathing Y position for the entity depending on if it can path swim or not * Gets the safe pathing Y position for the entity depending on if it can path swim or not
*/ */
private int getPathableYPos() private double getPathableYPos()
{ {
return (int)(this.theEntity.boundingBox.minY + 0.5D); return this.theEntity.boundingBox.minY + 0.05D;
} }
/** /**
@@ -355,7 +355,7 @@ public class ClientProxy extends CommonProxy {
else if(gui == EnumGuiType.PlayerTransporter) else if(gui == EnumGuiType.PlayerTransporter)
return new GuiTransportSelection(npc); return new GuiTransportSelection(npc);
else if(gui == EnumGuiType.Script) else if(gui == EnumGuiType.Script && CustomNpcs.ScriptingEnabled)
return new GuiScript(npc); return new GuiScript(npc);
else if(gui == EnumGuiType.PlayerAnvil) else if(gui == EnumGuiType.PlayerAnvil)
@@ -98,6 +98,21 @@ public class NoppesUtil {
float alphaRate = buffer.readFloat(); float alphaRate = buffer.readFloat();
int alphaRateStart = buffer.readInt(); int alphaRateStart = buffer.readInt();
float rotationX1 = buffer.readFloat();
float rotationX2 = buffer.readFloat();
float rotationXRate = buffer.readFloat();
int rotationXRateStart = buffer.readInt();
float rotationY1 = buffer.readFloat();
float rotationY2 = buffer.readFloat();
float rotationYRate = buffer.readFloat();
int rotationYRateStart = buffer.readInt();
float rotationZ1 = buffer.readFloat();
float rotationZ2 = buffer.readFloat();
float rotationZRate = buffer.readFloat();
int rotationZRateStart = buffer.readInt();
int entityID = buffer.readInt(); int entityID = buffer.readInt();
World worldObj = Minecraft.getMinecraft().theWorld; World worldObj = Minecraft.getMinecraft().theWorld;
@@ -113,6 +128,9 @@ public class NoppesUtil {
motionX, motionY, motionZ, gravity, motionX, motionY, motionZ, gravity,
scale1, scale2, scaleRate, scaleRateStart, scale1, scale2, scaleRate, scaleRateStart,
alpha1, alpha2, alphaRate, alphaRateStart, alpha1, alpha2, alphaRate, alphaRateStart,
rotationX1, rotationX2, rotationXRate, rotationXRateStart,
rotationY1, rotationY2, rotationYRate, rotationYRateStart,
rotationZ1, rotationZ2, rotationZRate, rotationZRateStart,
maxAge maxAge
); );
@@ -99,7 +99,7 @@ public class TranslateUtil {
return null; return null;
element = array.get(0); element = array.get(0);
} }
System.out.println(element.getAsString()); // System.out.println(element.getAsString());
return element.getAsString(); return element.getAsString();
} }
} }
@@ -7,7 +7,6 @@ import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import noppes.npcs.client.ClientProxy; import noppes.npcs.client.ClientProxy;
import org.lwjgl.Sys;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
public class EntityCustomFX extends EntityFX { public class EntityCustomFX extends EntityFX {
@@ -27,10 +26,31 @@ public class EntityCustomFX extends EntityFX {
public float alphaRate = 0.0F; public float alphaRate = 0.0F;
public int alphaRateStart = 0; public int alphaRateStart = 0;
public float rotationX = 0;
public float rotationX1 = 0;
public float rotationX2 = 0;
public float rotationXRate = 0.0F;
public int rotationXRateStart = 0;
public float rotationY = 0;
public float rotationY1 = 0;
public float rotationY2 = 0;
public float rotationYRate = 0.0F;
public int rotationYRateStart = 0;
public float rotationZ = 0;
public float rotationZ1 = 0;
public float rotationZ2 = 0;
public float rotationZRate = 0.0F;
public int rotationZRateStart = 0;
public EntityCustomFX(Entity entity, String directory, int HEXColor, double x, double y, double z, public EntityCustomFX(Entity entity, String directory, int HEXColor, double x, double y, double z,
double motionX, double motionY, double motionZ, float gravity, double motionX, double motionY, double motionZ, float gravity,
float scale1, float scale2, float scaleRate, int scaleRateStart, float scale1, float scale2, float scaleRate, int scaleRateStart,
float alpha1, float alpha2, float alphaRate, int alphaRateStart, float alpha1, float alpha2, float alphaRate, int alphaRateStart,
float rotationX1, float rotationX2, float rotationXRate, int rotationXRateStart,
float rotationY1, float rotationY2, float rotationYRate, int rotationYRateStart,
float rotationZ1, float rotationZ2, float rotationZRate, int rotationZRateStart,
int age) { int age) {
super(entity.worldObj, x, y, z, motionX, motionY, motionZ); super(entity.worldObj, x, y, z, motionX, motionY, motionZ);
@@ -50,6 +70,30 @@ public class EntityCustomFX extends EntityFX {
if(alpha1 > alpha2) if(alpha1 > alpha2)
this.alphaRate *= -1; this.alphaRate *= -1;
this.rotationX1 = rotationX1;
this.rotationX2 = rotationX2;
this.rotationXRate = Math.abs(rotationXRate);
this.rotationXRateStart = rotationXRateStart;
rotationX = rotationX1;
if(rotationX1 > rotationX2)
this.rotationXRate *= -1;
this.rotationY1 = rotationY1;
this.rotationY2 = rotationY2;
this.rotationYRate = Math.abs(rotationYRate);
this.rotationYRateStart = rotationYRateStart;
rotationY = rotationY1;
if(rotationY1 > rotationY2)
this.rotationYRate *= -1;
this.rotationZ1 = rotationZ1;
this.rotationZ2 = rotationZ2;
this.rotationZRate = Math.abs(rotationZRate);
this.rotationZRateStart = rotationZRateStart;
rotationZ = rotationZ1;
if(rotationZ1 > rotationZ2)
this.rotationZRate *= -1;
particleGravity = gravity/0.04F; particleGravity = gravity/0.04F;
particleMaxAge = age; particleMaxAge = age;
@@ -74,148 +118,92 @@ public class EntityCustomFX extends EntityFX {
location = new ResourceLocation(directory); location = new ResourceLocation(directory);
} }
/*
par2 = partial tick time
par3 = ActiveRenderInfo.rotationX;
par4 = ActiveRenderInfo.rotationZ;
par5 = ActiveRenderInfo.rotationYZ;
par6 = ActiveRenderInfo.rotationXY;
par7 = ActiveRenderInfo.rotationXZ;
*/
@Override @Override
public void renderParticle(Tessellator par1Tessellator, float par2, float par3, float par4, float par5, float par6, float par7) public void renderParticle(Tessellator tessellator, float partialTick, float cosYaw, float cosPitch, float sinYaw, float sinSinPitch, float cosSinPitch)
{ {
if(move){
startX = (float)(entity.prevPosX + (entity.posX - entity.prevPosX) * (double)par2);
startY = (float)(entity.prevPosY + (entity.posY - entity.prevPosY) * (double)par2);
startZ = (float)(entity.prevPosZ + (entity.posZ - entity.prevPosZ) * (double)par2);
}
Tessellator tessellator = Tessellator.instance;
tessellator.draw(); tessellator.draw();
float scale = this.scaleRate / (float)particleMaxAge;
if((this.scaleRate < 0 && particleScale+scale < this.scale2) || (this.scaleRate > 0 && particleScale+scale > this.scale2))
particleScale = this.scale2;
else if(particleAge >= this.scaleRateStart)
particleScale += scale;
float alpha = this.alphaRate / (float)particleMaxAge;
if((this.alphaRate < 0 && particleAlpha+alpha < this.alpha2) || (this.alphaRate > 0 && particleAlpha+alpha > this.alpha2))
particleAlpha = this.alpha2;
else if(particleAge >= this.alphaRateStart)
particleAlpha += alpha;
ClientProxy.bindTexture(location);
float f = 0.0f;
float f1 = 1.0f;
float f2 = 0.0f;
float f3 = 1.0f;
float f4 = 0.1F * particleScale;
float f5 = (float)(((prevPosX + (posX - prevPosX) * (double)par2) - interpPosX) + startX);
float f6 = (float)(((prevPosY + (posY - prevPosY) * (double)par2) - interpPosY) + startY);
float f7 = (float)(((prevPosZ + (posZ - prevPosZ) * (double)par2) - interpPosZ) + startZ);
tessellator.startDrawingQuads();
tessellator.setBrightness(240);
par1Tessellator.setColorOpaque_F(1, 1, 1);
par1Tessellator.setColorRGBA_F(particleRed, particleGreen, particleBlue, particleAlpha);
par1Tessellator.addVertexWithUV(f5 - par3 * f4 - par6 * f4, f6 - par4 * f4, f7 - par5 * f4 - par7 * f4, f1, f3);
par1Tessellator.addVertexWithUV((f5 - par3 * f4) + par6 * f4, f6 + par4 * f4, (f7 - par5 * f4) + par7 * f4, f1, f2);
par1Tessellator.addVertexWithUV(f5 + par3 * f4 + par6 * f4, f6 + par4 * f4, f7 + par5 * f4 + par7 * f4, f, f2);
par1Tessellator.addVertexWithUV((f5 + par3 * f4) - par6 * f4, f6 - par4 * f4, (f7 + par5 * f4) - par7 * f4, f, f3);
/*
Minecraft minecraft = Minecraft.getMinecraft();
EntityPlayer player = minecraft.thePlayer;
double angle = Minecraft.getMinecraft().theWorld.getWorldTime()%360;
double angleRad = (angle/180)*Math.PI;
double diffX = player.posX - this.startX;
double diffY = player.posY - player.getYOffset() - this.startY;
double diffZ = player.posZ - this.startZ;
double yaw = (player.rotationYaw/180)*Math.PI;
double pitch = (player.rotationPitch/180)*Math.PI;
double angleX = Math.sin(yaw)*Math.cos(pitch);
if(Math.abs(angleX) < 0.0001){
angleX = 0.0D;
}
double angleY = Math.sin(pitch);
if(Math.abs(angleY) < 0.0001){
angleY = 0.0D;
}
double angleZ = -Math.cos(yaw)*Math.cos(pitch);
if(Math.abs(angleZ) < 0.0001){
angleZ = 0.0D;
}
double angleXtranslateX = 0.0D;
double angleXtranslateY = 0.0D;//(-diffY + Math.cos(angleRad)*diffY) + (-Math.sin(angleRad)*diffZ);
double angleXtranslateZ = 0.0D;//(Math.sin(angleRad)*diffY) + (-diffZ + Math.cos(angleRad)*diffZ);
double angleYtranslateX = 0.0D;//(-diffX + Math.cos(angleRad)*diffX) + (Math.sin(angleRad)*diffZ);
double angleYtranslateY = 0.0D;
double angleYtranslateZ = 0.0D;//(-Math.sin(angleRad)*diffX) + (-diffZ + Math.cos(angleRad)*diffZ);
double angleZtranslateX = 0.0D;//(-diffX + Math.cos(angleRad)*diffX) + (-Math.sin(angleRad)*diffY);
double angleZtranslateY = 0.0D;//(Math.sin(angleRad)*diffX) + (-diffY + Math.cos(angleRad)*diffY);
double angleZtranslateZ = 0.0D;
double translateX = angleXtranslateX + angleYtranslateX + angleZtranslateX;
double translateY = angleXtranslateY + angleYtranslateY + angleZtranslateY;
double translateZ = angleXtranslateZ + angleYtranslateZ + angleZtranslateZ;
//distance in the X & Z plane
double distXZ = Math.sqrt(Math.pow(diffX,2) + Math.pow(diffZ,2));
//distance in the X & Y plane
double distXY = Math.sqrt(Math.pow(diffX,2) + Math.pow(diffY,2));
//distance in the Y & Z plane
double distYZ = Math.sqrt(Math.pow(diffY,2) + Math.pow(diffZ,2));
double signDiffX = Math.signum(diffX);
double signDiffY = Math.signum(diffY);
double signDiffZ = Math.signum(diffZ);
double angleXtoNorm = Math.sin(Math.acos(diffX/distXZ));
double angleZtoNorm = Math.sin(Math.acos(diffZ/distXZ));
double angleDiffX = (Math.abs(Math.cos(yaw))-angleXtoNorm);
double angleDiffZ = (Math.abs(Math.cos(yaw))-angleZtoNorm);
double translateX = -Math.abs(angleDiffX*angleZ*distXZ)*signDiffX;
double translateY = 0;
double translateZ = -Math.abs(angleDiffX*angleX*distXZ)*signDiffZ + Math.cos(angleRad)*Math.abs(angleDiffX*angleX*distXZ)*signDiffZ;
if(minecraft.currentScreen == null) {
System.out.println();
//System.out.printf("diffX: %f, diffY: %f, diffZ: %f\n", diffX, diffY, diffZ);
//System.out.printf("angleX: %f, angleY: %f, angleZ: %f\n", angleX, angleY, angleZ);
//System.out.printf("angleXtoNorm: %f, angleZtoNorm: %f\n", angleXtoNorm, angleZtoNorm);
System.out.printf("Math.sin(yaw): %f\n", Math.sin(yaw));
System.out.printf("Math.cos(yaw): %f\n", Math.cos(yaw));
//System.out.printf("Math.sin(pitch): %f\n", Math.sin(pitch));
//System.out.printf("Math.cos(pitch): %f\n", Math.cos(pitch));
System.out.printf("angleDiffX: %f\n", angleDiffX);
System.out.printf("angleDiffZ: %f\n", angleDiffZ);
System.out.printf("translateX: %f\n", Math.cos(angleRad)*Math.abs(angleDiffX*angleZ*distXZ)*signDiffX);
System.out.printf("translateZ: %f\n", Math.cos(angleRad)*Math.abs(angleDiffX*angleX*distXZ)*signDiffZ);
}
*/
GL11.glPushMatrix(); GL11.glPushMatrix();
GL11.glColor4f(1, 1, 1, 1.0F); ClientProxy.bindTexture(location);
//GL11.glTranslated(translateX,translateY,translateZ); if(move){
//GL11.glRotated(angle, angleX, angleY, angleZ); startX = (float)(entity.prevPosX + (entity.posX - entity.prevPosX) * (double)partialTick);
startY = (float)(entity.prevPosY + (entity.posY - entity.prevPosY) * (double)partialTick);
startZ = (float)(entity.prevPosZ + (entity.posZ - entity.prevPosZ) * (double)partialTick);
}
float scaleChange = this.scaleRate / (float)particleMaxAge;
if((this.scaleRate < 0 && particleScale+scaleChange < this.scale2) || (this.scaleRate > 0 && particleScale+scaleChange > this.scale2))
particleScale = this.scale2;
else if(particleAge >= this.scaleRateStart)
particleScale += scaleChange;
float alphaChange = this.alphaRate / (float)particleMaxAge;
if((this.alphaRate < 0 && particleAlpha+alphaChange < this.alpha2) || (this.alphaRate > 0 && particleAlpha+alphaChange > this.alpha2))
particleAlpha = this.alpha2;
else if(particleAge >= this.alphaRateStart)
particleAlpha += alphaChange;
float rotationXChange = this.rotationXRate / (float)particleMaxAge;
if((this.rotationXRate < 0 && rotationX+rotationXChange < this.rotationX2) || (this.rotationXRate > 0 && rotationX+rotationXChange > this.rotationX2))
rotationX = this.rotationX2;
else if(particleAge >= this.rotationXRateStart)
rotationX += rotationXChange;
float rotationYChange = this.rotationYRate / (float)particleMaxAge;
if((this.rotationYRate < 0 && rotationY+rotationYChange < this.rotationY2) || (this.rotationYRate > 0 && rotationY+rotationYChange > this.rotationY2))
rotationY = this.rotationY2;
else if(particleAge >= this.rotationYRateStart)
rotationY += rotationYChange;
float rotationZChange = this.rotationZRate / (float)particleMaxAge;
if((this.rotationZRate < 0 && rotationZ+rotationZChange < this.rotationZ2) || (this.rotationZRate > 0 && rotationZ+rotationZChange > this.rotationZ2))
rotationZ = this.rotationZ2;
else if(particleAge >= this.rotationZRateStart)
rotationZ += rotationZChange;
float u1 = 0.0f;
float u2 = 1.0f;
float v1 = 0.0f;
float v2 = 1.0f;
float renderScale = 0.1F * particleScale;
float posX = (float)(((prevPosX + (this.posX - prevPosX) * (double)partialTick) - interpPosX) + startX);
float posY = (float)(((prevPosY + (this.posY - prevPosY) * (double)partialTick) - interpPosY) + startY);
float posZ = (float)(((prevPosZ + (this.posZ - prevPosZ) * (double)partialTick) - interpPosZ) + startZ);
GL11.glTranslated((double)posX, (double)posY, (double)posZ);
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
double yaw = (player.rotationYaw/180)*Math.PI;
double pitch = (player.rotationPitch/180)*Math.PI;
if(Math.abs(rotationX%360) >= 90 && Math.abs(rotationX%360) < 270) {
rotationX += 180*Math.signum(rotationX);
}
if(Math.abs(rotationY%360) >= 90 && Math.abs(rotationY%360) < 270) {
rotationY += 180*Math.signum(rotationY);
}
GL11.glRotated(rotationX, Math.cos(yaw)*Math.cos(pitch),0.0,Math.sin(yaw)*Math.cos(pitch));
GL11.glRotated(rotationY, -Math.sin(yaw)*Math.sin(pitch), Math.cos(pitch), Math.cos(yaw)*Math.sin(pitch));
GL11.glRotated(rotationZ, Math.sin(yaw)*Math.cos(pitch), Math.sin(pitch), -Math.cos(yaw)*Math.cos(pitch));
tessellator.startDrawingQuads();
tessellator.setBrightness(240);
tessellator.setColorOpaque_F(1, 1, 1);
tessellator.setColorRGBA_F(particleRed, particleGreen, particleBlue, particleAlpha);
tessellator.addVertexWithUV( - cosYaw * renderScale - sinSinPitch * renderScale, - cosPitch * renderScale, - sinYaw * renderScale - cosSinPitch * renderScale, u2, v2);
tessellator.addVertexWithUV(( - cosYaw * renderScale) + sinSinPitch * renderScale, + cosPitch * renderScale, ( - sinYaw * renderScale) + cosSinPitch * renderScale, u2, v1);
tessellator.addVertexWithUV( + cosYaw * renderScale + sinSinPitch * renderScale, + cosPitch * renderScale, + sinYaw * renderScale + cosSinPitch * renderScale, u1, v1);
tessellator.addVertexWithUV(( + cosYaw * renderScale) - sinSinPitch * renderScale, - cosPitch * renderScale, ( + sinYaw * renderScale) - cosSinPitch * renderScale, u1, v2);
tessellator.draw(); tessellator.draw();
ClientProxy.bindTexture(resource);
tessellator.startDrawingQuads();
GL11.glPopMatrix(); GL11.glPopMatrix();
GL11.glColor4f(1, 1, 1, 1.0F);
ClientProxy.bindTexture(resource);
tessellator.startDrawingQuads();
} }
public int getFXLayer(){ public int getFXLayer(){
@@ -39,8 +39,7 @@ public class GuiNpcMobSpawner extends GuiNPCInterface implements IGuiData{
public GuiNpcMobSpawner(int i, int j, int k) { public GuiNpcMobSpawner(int i, int j, int k) {
super(); super();
xSize = 384; xSize = 354;
posX = i; posX = i;
posY = j; posY = j;
posZ = k; posZ = k;
@@ -53,6 +52,7 @@ public class GuiNpcMobSpawner extends GuiNPCInterface implements IGuiData{
{ {
super.initGui(); super.initGui();
guiTop += 10; guiTop += 10;
guiLeft += 30;
if(scroll == null){ if(scroll == null){
scroll = new GuiCustomScroll(this,0); scroll = new GuiCustomScroll(this,0);
@@ -69,36 +69,37 @@ public class GuiNpcMobSpawner extends GuiNPCInterface implements IGuiData{
GuiMenuTopButton button; GuiMenuTopButton button;
addTopButton(button = new GuiMenuTopButton(3,guiLeft + 4, guiTop - 17, "spawner.clones")); addTopButton(button = new GuiMenuTopButton(3,guiLeft + 4, guiTop - 17, "spawner.clones"));
button.active = showingClones == 0; button.active = showingClones == 0;
addTopButton(button = new GuiMenuTopButton(4, button, "spawner.entities"));
button.active = showingClones == 1;
addTopButton(button = new GuiMenuTopButton(5, button, "gui.server")); addTopButton(button = new GuiMenuTopButton(5, button, "gui.server"));
button.active = showingClones == 2; button.active = showingClones == 2;
addTopButton(button = new GuiMenuTopButton(4, button, "spawner.entities"));
button.active = showingClones == 1;
addButton(new GuiNpcButton(1, guiLeft + 298, guiTop + 6, 82, 20, "item.monsterPlacer.name")); addButton(new GuiNpcButton(1, guiLeft + 298, guiTop + 6, 52, 20, "item.monsterPlacer.name"));
addButton(new GuiNpcButton(2, guiLeft + 298, guiTop + 100, 82, 20, "spawner.mobspawner")); addButton(new GuiNpcButton(2, guiLeft + 298, guiTop + 100, 52, 20, "spawner.mobspawner"));
if(showingClones == 0 || showingClones == 2){ if(showingClones == 0 || showingClones == 2){
addSideButton(new GuiMenuSideButton(21,guiLeft - 90, this.guiTop + 2, 90,22, "1")); addSideButton(new GuiMenuSideButton(21,guiLeft - 70, this.guiTop + 2, 70,22, "1"));
addSideButton(new GuiMenuSideButton(22,guiLeft - 90, this.guiTop + 23, 90,22, "2")); addSideButton(new GuiMenuSideButton(22,guiLeft - 70, this.guiTop + 23, 70,22, "2"));
addSideButton(new GuiMenuSideButton(23,guiLeft - 90, this.guiTop + 44, 90,22, "3")); addSideButton(new GuiMenuSideButton(23,guiLeft - 70, this.guiTop + 44, 70,22, "3"));
addSideButton(new GuiMenuSideButton(24,guiLeft - 90, this.guiTop + 65, 90,22, "4")); addSideButton(new GuiMenuSideButton(24,guiLeft - 70, this.guiTop + 65, 70,22, "4"));
addSideButton(new GuiMenuSideButton(25,guiLeft - 90, this.guiTop + 86, 90,22, "5")); addSideButton(new GuiMenuSideButton(25,guiLeft - 70, this.guiTop + 86, 70,22, "5"));
addSideButton(new GuiMenuSideButton(26,guiLeft - 90, this.guiTop + 107, 45,22, "6")); addSideButton(new GuiMenuSideButton(26,guiLeft - 70, this.guiTop + 107, 35,22, "6"));
addSideButton(new GuiMenuSideButton(27,guiLeft - 45, this.guiTop + 107, 45,22, "7")); addSideButton(new GuiMenuSideButton(27,guiLeft - 35, this.guiTop + 107, 35,22, "7"));
addSideButton(new GuiMenuSideButton(28,guiLeft - 90, this.guiTop + 128, 45,22, "8")); addSideButton(new GuiMenuSideButton(28,guiLeft - 70, this.guiTop + 128, 35,22, "8"));
addSideButton(new GuiMenuSideButton(29,guiLeft - 45, this.guiTop + 128, 45,22, "9")); addSideButton(new GuiMenuSideButton(29,guiLeft - 35, this.guiTop + 128, 35,22, "9"));
addSideButton(new GuiMenuSideButton(30,guiLeft - 90, this.guiTop + 149, 45,22, "10")); addSideButton(new GuiMenuSideButton(30,guiLeft - 70, this.guiTop + 149, 35,22, "10"));
addSideButton(new GuiMenuSideButton(31,guiLeft - 45, this.guiTop + 149, 45,22, "11")); addSideButton(new GuiMenuSideButton(31,guiLeft - 35, this.guiTop + 149, 35,22, "11"));
addSideButton(new GuiMenuSideButton(32,guiLeft - 90, this.guiTop + 170, 45,22, "12")); addSideButton(new GuiMenuSideButton(32,guiLeft - 70, this.guiTop + 170, 35,22, "12"));
addSideButton(new GuiMenuSideButton(33,guiLeft - 45, this.guiTop + 170, 45,22, "13")); addSideButton(new GuiMenuSideButton(33,guiLeft - 35, this.guiTop + 170, 35,22, "13"));
addSideButton(new GuiMenuSideButton(34,guiLeft - 90, this.guiTop + 191, 45,22, "14")); addSideButton(new GuiMenuSideButton(34,guiLeft - 70, this.guiTop + 191, 35,22, "14"));
addSideButton(new GuiMenuSideButton(35,guiLeft - 45, this.guiTop + 191, 45,22, "15")); addSideButton(new GuiMenuSideButton(35,guiLeft - 35, this.guiTop + 191, 35,22, "15"));
addButton(new GuiNpcButton(6, guiLeft + 298, guiTop + 190, 82, 20, "gui.remove")); // addButton(new GuiNpcButton(6, guiLeft + 298, guiTop + 190, 82, 20, "gui.remove"));
addButton(new GuiNpcButton(6, guiLeft + 298, guiTop + 190, 52, 20, "gui.remove"));
getSideButton(20 + activeTab).active = true; getSideButton(20 + activeTab).active = true;
showClones(); showClones();
@@ -8,6 +8,7 @@ import net.minecraft.client.gui.GuiYesNoCallback;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList; import net.minecraft.nbt.NBTTagList;
import net.minecraft.server.MinecraftServer; import net.minecraft.server.MinecraftServer;
import noppes.npcs.CustomNpcs;
import noppes.npcs.DataScript; import noppes.npcs.DataScript;
import noppes.npcs.NoppesStringUtils; import noppes.npcs.NoppesStringUtils;
import noppes.npcs.client.Client; import noppes.npcs.client.Client;
@@ -513,7 +513,7 @@ public class GuiCustom extends GuiScreen implements ICustomScrollListener, IGuiD
} }
protected void keyTyped(char typedChar, int keyCode) { protected void keyTyped(char typedChar, int keyCode) {
if (keyCode == 1 || keyCode == this.mc.gameSettings.keyBindInventory.getKeyCode()) if (keyCode == 1)
{ {
this.mc.thePlayer.closeScreen(); this.mc.thePlayer.closeScreen();
} }
@@ -119,7 +119,7 @@ public class CustomGuiLabel extends Gui implements IGuiComponent {
} }
public void onRender(Minecraft mc, int mouseX, int mouseY, int mouseWheel, float partialTicks) { public void onRender(Minecraft mc, int mouseX, int mouseY, int mouseWheel, float partialTicks) {
boolean hovered = mouseX >= this.field_146162_g && mouseY >= this.field_146174_h && mouseX < this.field_146162_g + this.field_146167_a && mouseY < this.field_146174_h + this.field_146161_f; boolean hovered = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.field_146167_a && mouseY < this.y + this.field_146161_f;
this.drawLabel(); this.drawLabel();
if (hovered && this.hoverText != null && this.hoverText.length > 0) { if (hovered && this.hoverText != null && this.hoverText.length > 0) {
this.parent.hoverText = this.hoverText; this.parent.hoverText = this.hoverText;
@@ -146,6 +146,8 @@ public class CustomGuiLabel extends Gui implements IGuiComponent {
lbl.color = component.getColor(); lbl.color = component.getColor();
lbl.alpha = component.getAlpha(); lbl.alpha = component.getAlpha();
lbl.rotation = component.getRotation(); lbl.rotation = component.getRotation();
lbl.field_146167_a = component.getWidth();
lbl.field_146161_f = component.getHeight();
return lbl; return lbl;
} }
@@ -71,7 +71,7 @@ public class CustomGuiTexturedRect extends Gui implements IGuiComponent {
} }
public void onRender(Minecraft mc, int mouseX, int mouseY, int mouseWheel, float partialTicks) { public void onRender(Minecraft mc, int mouseX, int mouseY, int mouseWheel, float partialTicks) {
boolean hovered = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height; boolean hovered = mouseX >= this.x + GuiCustom.guiLeft && mouseY >= this.y + GuiCustom.guiTop && mouseX < this.x + GuiCustom.guiLeft + this.width && mouseY < this.y + GuiCustom.guiTop + this.height;
mc.getTextureManager().bindTexture(this.texture); mc.getTextureManager().bindTexture(this.texture);
GL11.glPushMatrix(); GL11.glPushMatrix();
@@ -80,10 +80,9 @@ public class CustomGuiTexturedRect extends Gui implements IGuiComponent {
float blue = (color & 255) / 255f; float blue = (color & 255) / 255f;
GL11.glColor4f(red,green,blue,this.alpha); GL11.glColor4f(red,green,blue,this.alpha);
GL11.glScalef(this.scale, this.scale, this.scale);
GL11.glTranslatef(GuiCustom.guiLeft,GuiCustom.guiTop,0.0F); GL11.glTranslatef(GuiCustom.guiLeft,GuiCustom.guiTop,0.0F);
GL11.glRotatef(this.rotation,0.0F,0.0F,1.0F); GL11.glRotatef(this.rotation,0.0F,0.0F,1.0F);
GL11.glScalef(this.scale, this.scale, this.scale);
int p_73729_1_ = (int) (this.x/this.scale); int p_73729_1_ = (int) (this.x/this.scale);
int p_73729_2_ = (int) (this.y/this.scale); int p_73729_2_ = (int) (this.y/this.scale);
@@ -46,13 +46,14 @@ public class GuiNPCInv extends GuiContainerNPCInterface2 implements IGuiData, IT
addLabel(new GuiNpcLabel(0,"inv.minExp", guiLeft + 118, guiTop + 18)); addLabel(new GuiNpcLabel(0,"inv.minExp", guiLeft + 118, guiTop + 18));
addTextField(new GuiNpcTextField(0,this, fontRendererObj, guiLeft + 108, guiTop + 29, 60, 20, npc.inventory.minExp + "")); addTextField(new GuiNpcTextField(0,this, fontRendererObj, guiLeft + 108, guiTop + 29, 60, 20, npc.inventory.minExp + ""));
getTextField(0).integersOnly = true; getTextField(0).integersOnly = true;
getTextField(0).setMinMaxDefault(0, npc.inventory.maxExp, 0);
addLabel(new GuiNpcLabel(1,"inv.maxExp", guiLeft + 118, guiTop + 52)); addLabel(new GuiNpcLabel(1,"inv.maxExp", guiLeft + 118, guiTop + 52));
addTextField(new GuiNpcTextField(1,this, fontRendererObj, guiLeft + 108, guiTop + 63, 60, 20, npc.inventory.maxExp + "")); addTextField(new GuiNpcTextField(1,this, fontRendererObj, guiLeft + 108, guiTop + 63, 60, 20, npc.inventory.maxExp + ""));
getTextField(1).integersOnly = true; getTextField(1).integersOnly = true;
getTextField(1).setMinMaxDefault(npc.inventory.maxExp, Short.MAX_VALUE, 0);
getTextField(0).setMinMaxDefault(0, getTextField(1).getInteger(), 0);
getTextField(1).setMinMaxDefault(getTextField(0).getInteger(), Short.MAX_VALUE, 0);
addButton(new GuiNpcButton(10, guiLeft + 88, guiTop + 88, 80, 20, new String[]{"stats.normal", "inv.auto"}, npc.inventory.lootMode)); addButton(new GuiNpcButton(10, guiLeft + 88, guiTop + 88, 80, 20, new String[]{"stats.normal", "inv.auto"}, npc.inventory.lootMode));
addLabel(new GuiNpcLabel(2,"inv.npcInventory", guiLeft + 191, guiTop + 5)); addLabel(new GuiNpcLabel(2,"inv.npcInventory", guiLeft + 191, guiTop + 5));
@@ -194,7 +195,9 @@ public class GuiNPCInv extends GuiContainerNPCInterface2 implements IGuiData, IT
public void unFocused(GuiNpcTextField textfield) { public void unFocused(GuiNpcTextField textfield) {
if(textfield.id >= 2){ if(textfield.id >= 2){
chances.put(textfield.id-2, Double.parseDouble(textfield.getText())); chances.put(textfield.id-2, Double.parseDouble(textfield.getText()));
this.save();
} }
getTextField(0).setMinMaxDefault(0, getTextField(1).getInteger(), 0);
getTextField(1).setMinMaxDefault(getTextField(0).getInteger(), Short.MAX_VALUE, 0);
this.save();
} }
} }
@@ -88,8 +88,12 @@ public class GuiNpcQuestTypeKill extends SubGuiInterface implements ITextfieldLi
addScroll(scroll); addScroll(scroll);
guiTop += 50; guiTop += 50;
this.addButton(new GuiNpcButton(0, guiLeft + 4, guiTop + 300, 98, 20, "gui.back")); this.addButton(new GuiNpcButton(0, guiLeft + 4, guiTop + 310, 98, 20, "gui.back"));
this.addButton(new GuiNpcButton(1, guiLeft + 4, guiTop + 260, 98, 20, new String[]{"Any", "NPCs"}, quest.targetType)); this.addButton(new GuiNpcButton(1, guiLeft + 4, guiTop + 260, 98, 20, new String[]{"Any", "NPCs", "Custom"}, quest.targetType));
this.addTextField(new GuiNpcTextField(36, this, fontRendererObj, guiLeft + 4, guiTop + 282, 180, 20, quest.customTargetType));
this.getTextField(36).setVisible(this.getButton(1).getValue() == 2);
guiTop -= 50; guiTop -= 50;
scroll.visible = GuiNpcTextField.isFieldActive(); scroll.visible = GuiNpcTextField.isFieldActive();
@@ -101,7 +105,8 @@ public class GuiNpcQuestTypeKill extends SubGuiInterface implements ITextfieldLi
close(); close();
} }
if (guibutton.id == 1) { if (guibutton.id == 1) {
quest.targetType = guibutton.displayString.equals("NPCs") ? 1 : 0; quest.targetType = this.getButton(1).getValue();
this.getTextField(36).setVisible(this.getButton(1).getValue() == 2);
} }
} }
public void mouseClicked(int i, int j, int k) public void mouseClicked(int i, int j, int k)
@@ -117,6 +122,9 @@ public class GuiNpcQuestTypeKill extends SubGuiInterface implements ITextfieldLi
if(guiNpcTextField.id < 12) if(guiNpcTextField.id < 12)
lastSelected = guiNpcTextField; lastSelected = guiNpcTextField;
if(guiNpcTextField.id == 36)
quest.customTargetType = guiNpcTextField.getText();
saveTargets(); saveTargets();
} }
private void saveTargets(){ private void saveTargets(){
@@ -163,8 +163,6 @@ public class GuiNpcPuppet extends GuiModelInterface implements ISliderListener{
} }
if(btn.id == 170 || btn.id == 171 || btn.id == 172){ if(btn.id == 170 || btn.id == 171 || btn.id == 172){
if(btn.id == 170){ if(btn.id == 170){
System.out.println(part.rotationX);
System.out.println(rotateX.sliderValue);
part.rotationX = 0.0f; part.rotationX = 0.0f;
rotateX.sliderValue = 0.5f; rotateX.sliderValue = 0.5f;
int percent = (int) ((rotateX.sliderValue) * 360); int percent = (int) ((rotateX.sliderValue) * 360);
@@ -0,0 +1,31 @@
package noppes.npcs.client.gui.script;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.client.Client;
import noppes.npcs.constants.EnumPacketServer;
import noppes.npcs.controllers.ScriptController;
import noppes.npcs.controllers.data.NPCDataScript;
public class GuiScriptAllNPCs extends GuiScriptInterface {
private NPCDataScript script = new NPCDataScript(null);
public GuiScriptAllNPCs() {
this.handler = this.script;
Client.sendData(EnumPacketServer.ScriptNPCGet, new Object[0]);
}
public void setGuiData(NBTTagCompound compound) {
this.script.readFromNBT(compound);
super.setGuiData(compound);
}
public void save() {
super.save();
Client.sendData(EnumPacketServer.ScriptNPCSave, new Object[]{this.script.writeToNBT(new NBTTagCompound())});
}
public void close() {
super.close();
ScriptController.Instance.npcScripts.errored.clear();
}
}
@@ -7,6 +7,7 @@ package noppes.npcs.client.gui.script;
import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiButton;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import noppes.npcs.CustomNpcs;
import noppes.npcs.client.gui.util.GuiNPCInterface; import noppes.npcs.client.gui.util.GuiNPCInterface;
import noppes.npcs.client.gui.util.GuiNpcButton; import noppes.npcs.client.gui.util.GuiNpcButton;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
@@ -23,8 +24,17 @@ public class GuiScriptGlobal extends GuiNPCInterface {
public void initGui() { public void initGui() {
super.initGui(); super.initGui();
this.addButton(new GuiNpcButton(0, this.guiLeft + 38, this.guiTop + 20, 100, 20, "Players")); GuiNpcButton playerButton = new GuiNpcButton(0, this.guiLeft + 38, this.guiTop + 20, 100, 20, "Players");
this.addButton(new GuiNpcButton(1, this.guiLeft + 38, this.guiTop + 50, 100, 20, "Forge")); playerButton.setEnabled(CustomNpcs.GlobalPlayerScripts && CustomNpcs.ScriptingEnabled);
this.addButton(playerButton);
GuiNpcButton forgeButton = new GuiNpcButton(1, this.guiLeft + 38, this.guiTop + 50, 100, 20, "Forge");
forgeButton.setEnabled(CustomNpcs.GlobalForgeScripts && CustomNpcs.ScriptingEnabled);
this.addButton(forgeButton);
GuiNpcButton npcButton = new GuiNpcButton(2, this.guiLeft + 38, this.guiTop + 80, 100, 20, "All NPCs");
npcButton.setEnabled(CustomNpcs.GlobalNPCScripts && CustomNpcs.ScriptingEnabled);
this.addButton(npcButton);
} }
public void drawScreen(int i, int j, float f) { public void drawScreen(int i, int j, float f) {
@@ -42,6 +52,9 @@ public class GuiScriptGlobal extends GuiNPCInterface {
if (guibutton.id == 1) { if (guibutton.id == 1) {
this.displayGuiScreen(new GuiScriptForge()); this.displayGuiScreen(new GuiScriptForge());
} }
if (guibutton.id == 2) {
this.displayGuiScreen(new GuiScriptAllNPCs());
}
} }
public void keyTyped(char c, int i) { public void keyTyped(char c, int i) {
@@ -35,6 +35,7 @@ import noppes.npcs.client.gui.util.*;
import noppes.npcs.controllers.IScriptHandler; import noppes.npcs.controllers.IScriptHandler;
import noppes.npcs.controllers.ScriptController; import noppes.npcs.controllers.ScriptController;
import noppes.npcs.controllers.data.ForgeDataScript; import noppes.npcs.controllers.data.ForgeDataScript;
import noppes.npcs.controllers.data.NPCDataScript;
import noppes.npcs.controllers.data.PlayerDataScript; import noppes.npcs.controllers.data.PlayerDataScript;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@@ -147,6 +148,22 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
hookList.add("customGuiSlot"); hookList.add("customGuiSlot");
hookList.add("customGuiScroll"); hookList.add("customGuiScroll");
hookList.add("customGuiTextfield"); hookList.add("customGuiTextfield");
}
else if(handler instanceof NPCDataScript) {
hookList.add("init");
hookList.add("tick");
hookList.add("interact");
hookList.add("dialog");
hookList.add("damaged");
hookList.add("killed");
hookList.add("meleeAttack");
hookList.add("rangedLaunched");
hookList.add("target");
hookList.add("collide");
hookList.add("kills");
hookList.add("dialogClose");
hookList.add("timer");
} }
else if(handler instanceof ForgeDataScript) { else if(handler instanceof ForgeDataScript) {
hooks.setSize(238, 198); hooks.setSize(238, 198);
@@ -24,7 +24,9 @@ public abstract class GuiContainerNPCInterface2 extends GuiContainerNPCInterface
{ {
private ResourceLocation background = new ResourceLocation("customnpcs","textures/gui/menubg.png"); private ResourceLocation background = new ResourceLocation("customnpcs","textures/gui/menubg.png");
private final ResourceLocation defaultBackground = new ResourceLocation("customnpcs","textures/gui/menubg.png"); private final ResourceLocation defaultBackground = new ResourceLocation("customnpcs","textures/gui/menubg.png");
private GuiNpcMenu menu; private final ResourceLocation defaultBackground2 = new ResourceLocation("customnpcs","textures/gui/menubg2.png");
private GuiNpcMenu menu;
public int menuYOffset = 0; public int menuYOffset = 0;
public GuiContainerNPCInterface2(EntityNPCInterface npc,Container cont) public GuiContainerNPCInterface2(EntityNPCInterface npc,Container cont)
@@ -74,18 +76,12 @@ public abstract class GuiContainerNPCInterface2 extends GuiContainerNPCInterface
mc.renderEngine.bindTexture(background); mc.renderEngine.bindTexture(background);
drawTexturedModalRect(guiLeft, guiTop, 0, 0, 256, 256); drawTexturedModalRect(guiLeft, guiTop, 0, 0, 256, 256);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
mc.renderEngine.bindTexture(defaultBackground); mc.renderEngine.bindTexture(defaultBackground2);
drawTexturedModalRect(guiLeft + xSize-200, guiTop, 26, 0, 200, 220); drawTexturedModalRect(guiLeft + xSize-256, guiTop, 0, 0, 256, 220);
menu.drawElements(fontRendererObj, i, j, mc, f); menu.drawElements(fontRendererObj, i, j, mc, f);
super.drawGuiContainerBackgroundLayer(f, i, j); super.drawGuiContainerBackgroundLayer(f, i, j);
} }
// @Override
// protected void drawSlotInventory(Slot par1Slot)
// {this.dra
// if(subgui == null)
// super.drawSlotInventory(par1Slot);
// } //TODO fix
} }
@@ -25,6 +25,7 @@ import noppes.npcs.entity.EntityCustomNpc;
import noppes.npcs.roles.JobPuppet; import noppes.npcs.roles.JobPuppet;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
public class ModelMPM extends ModelNPCMale{ public class ModelMPM extends ModelNPCMale{
private ModelPartInterface wings; private ModelPartInterface wings;
@@ -65,13 +66,10 @@ public class ModelMPM extends ModelNPCMale{
public boolean isArmor; public boolean isArmor;
public float alpha = 1; public float alpha = 1;
// Check Legacy Code for Old Version
// Updated False = 64x32 Skin
// Steve 64x64 and Alex 64x64 // Steve 64x64 and Alex 64x64
public ModelMPM(float par1, boolean arms) { public ModelMPM(float par1, boolean alex) {
super(par1, arms); super(par1, alex);
isArmor = par1 > 0; isArmor = par1 > 0;
float par2 = 0; float par2 = 0;
@@ -101,7 +99,7 @@ public class ModelMPM extends ModelNPCMale{
// this.bipedBodywear.setRotationPoint(0.0F, 0.0F + par2, 0.0F); // this.bipedBodywear.setRotationPoint(0.0F, 0.0F + par2, 0.0F);
// Steve 64x64 Model or Alex 64x64 Model // Steve 64x64 Model or Alex 64x64 Model
if (arms){ if (alex){
// Alex Version // Alex Version
this.bipedRightArm = (new ModelScaleRenderer(this, 40, 16)); this.bipedRightArm = (new ModelScaleRenderer(this, 40, 16));
this.bipedRightArm.addBox(-2.0F, -2.0F, -2.0F, 3, 12, 4, par1); this.bipedRightArm.addBox(-2.0F, -2.0F, -2.0F, 3, 12, 4, par1);
@@ -114,13 +112,13 @@ public class ModelMPM extends ModelNPCMale{
this.bipedRightArmWear = (new ModelScaleRenderer(this, 40, 32)); this.bipedRightArmWear = (new ModelScaleRenderer(this, 40, 32));
this.bipedRightArmWear.addBox(-2.0F, -2.0F, -2.0F, 3, 12, 4, par1 + 0.25F); this.bipedRightArmWear.addBox(-2.0F, -2.0F, -2.0F, 3, 12, 4, par1 + 0.25F);
this.bipedRightArm.addChild(this.bipedRightArmWear); this.bipedRightArm.addChild(this.bipedRightArmWear);
this.solidRightArmWear = new ModelLimbWear(this,"arm","right"); this.solidRightArmWear = new ModelLimbWear(this,"arm","right","Alex");
this.bipedRightArm.addChild(this.solidRightArmWear); this.bipedRightArm.addChild(this.solidRightArmWear);
this.bipedLeftArmwear = new ModelScaleRenderer(this, 48, 48); this.bipedLeftArmwear = new ModelScaleRenderer(this, 48, 48);
this.bipedLeftArmwear.addBox(-1.0F, -2.0F, -2.0F, 3, 12, 4, par1 + 0.25F); this.bipedLeftArmwear.addBox(-1.0F, -2.0F, -2.0F, 3, 12, 4, par1 + 0.25F);
this.bipedLeftArm.addChild(this.bipedLeftArmwear); this.bipedLeftArm.addChild(this.bipedLeftArmwear);
this.solidLeftArmWear = new ModelLimbWear(this,"arm","left"); this.solidLeftArmWear = new ModelLimbWear(this,"arm","left","Alex");
this.bipedLeftArm.addChild(this.solidLeftArmWear); this.bipedLeftArm.addChild(this.solidLeftArmWear);
} }
else{ else{
@@ -136,13 +134,13 @@ public class ModelMPM extends ModelNPCMale{
this.bipedRightArmWear = (new ModelScaleRenderer(this, 40, 32)); this.bipedRightArmWear = (new ModelScaleRenderer(this, 40, 32));
this.bipedRightArmWear.addBox(-3.0F, -2.0F, -2.0F, 4, 12, 4, par1 + 0.25F); this.bipedRightArmWear.addBox(-3.0F, -2.0F, -2.0F, 4, 12, 4, par1 + 0.25F);
this.bipedRightArm.addChild(this.bipedRightArmWear); this.bipedRightArm.addChild(this.bipedRightArmWear);
this.solidRightArmWear = new ModelLimbWear(this,"arm","right"); this.solidRightArmWear = new ModelLimbWear(this,"arm","right","Steve");
this.bipedRightArm.addChild(this.solidRightArmWear); this.bipedRightArm.addChild(this.solidRightArmWear);
this.bipedLeftArmwear = new ModelScaleRenderer(this, 48, 48); this.bipedLeftArmwear = new ModelScaleRenderer(this, 48, 48);
this.bipedLeftArmwear.addBox(-1.0F, -2.0F, -2.0F, 4, 12, 4, par1 + 0.25F); this.bipedLeftArmwear.addBox(-1.0F, -2.0F, -2.0F, 4, 12, 4, par1 + 0.25F);
this.bipedLeftArm.addChild(this.bipedLeftArmwear); this.bipedLeftArm.addChild(this.bipedLeftArmwear);
this.solidLeftArmWear = new ModelLimbWear(this,"arm","left"); this.solidLeftArmWear = new ModelLimbWear(this,"arm","left","Steve");
this.bipedLeftArm.addChild(this.solidLeftArmWear); this.bipedLeftArm.addChild(this.solidLeftArmWear);
} }
@@ -157,13 +155,13 @@ public class ModelMPM extends ModelNPCMale{
this.bipedRightLegWear = (new ModelScaleRenderer(this, 0, 32)); this.bipedRightLegWear = (new ModelScaleRenderer(this, 0, 32));
this.bipedRightLegWear.addBox(-2.08F, 0.0F, -2.0F, 4, 12, 4, par1 + 0.25F); this.bipedRightLegWear.addBox(-2.08F, 0.0F, -2.0F, 4, 12, 4, par1 + 0.25F);
this.bipedRightLeg.addChild(this.bipedRightLegWear); this.bipedRightLeg.addChild(this.bipedRightLegWear);
this.solidRightLegWear = new ModelLimbWear(this,"leg","right"); this.solidRightLegWear = new ModelLimbWear(this,"leg","right","Steve");
this.bipedRightLeg.addChild(this.solidRightLegWear); this.bipedRightLeg.addChild(this.solidRightLegWear);
this.bipedLeftLegWear = new ModelScaleRenderer(this, 0, 48); this.bipedLeftLegWear = new ModelScaleRenderer(this, 0, 48);
this.bipedLeftLegWear.addBox(-1.92F, 0.0F, -2.0F, 4, 12, 4, par1 + 0.25F); this.bipedLeftLegWear.addBox(-1.92F, 0.0F, -2.0F, 4, 12, 4, par1 + 0.25F);
this.bipedLeftLeg.addChild(this.bipedLeftLegWear); this.bipedLeftLeg.addChild(this.bipedLeftLegWear);
this.solidLeftLegWear = new ModelLimbWear(this,"leg","left"); this.solidLeftLegWear = new ModelLimbWear(this,"leg","left","Steve");
this.bipedLeftLeg.addChild(this.solidLeftLegWear); this.bipedLeftLeg.addChild(this.solidLeftLegWear);
@@ -28,10 +28,10 @@ public class ModelNPCMale extends ModelBiped
init(f, 0.0F); init(f, 0.0F);
} }
public ModelNPCMale(float f, boolean arms) public ModelNPCMale(float f, boolean alex)
{ {
super(f, 0.0F, 64, 64); super(f, 0.0F, 64, 64);
init(f, 0.0F, arms); init(f, 0.0F, alex);
} }
@Override @Override
@@ -1,3 +1,5 @@
package noppes.npcs.client.model.part; package noppes.npcs.client.model.part;
import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelBase;
@@ -6,18 +8,32 @@ import noppes.npcs.client.model.util.Model2DRenderer;
import noppes.npcs.client.model.util.ModelScaleRenderer; import noppes.npcs.client.model.util.ModelScaleRenderer;
public class ModelLimbWear extends ModelScaleRenderer { public class ModelLimbWear extends ModelScaleRenderer {
public ModelLimbWear(ModelBase base, String limb, String side) { public ModelLimbWear(ModelBase base, String limb, String side, String type) {
super(base); super(base);
float thick = 0.55f; float thick = 0.55f;
switch (limb){ switch (limb){
case "arm": case "arm":
switch (side){ switch(type) {
case "right": case "Steve":
rightArm(base,thick); switch (side) {
case "right":
rightArm(base, thick);
break;
case "left":
leftArm(base, thick);
break;
}
break; break;
case "left": case "Alex":
leftArm(base,thick); switch (side) {
case "right":
rightArmAlex(base, thick);
break;
case "left":
leftArmAlex(base, thick);
break;
}
break; break;
} }
break; break;
@@ -36,6 +52,100 @@ public class ModelLimbWear extends ModelScaleRenderer {
} }
public void rightArmAlex(ModelBase base, float thick){
float x = 0.95f;
float y = -2.0f;
Model2DRenderer front = new Model2DRenderer(base, 44, 36, 3, 12, 64, 64);
front.setRotationPoint(-3.39375f+x, 12.535f+y, -2.58f);
front.setScale(0.96f,0.8175f);
front.setThickness(thick);
setRotation(front, 0, 0, 0);
this.addChild(front);
Model2DRenderer back = new Model2DRenderer(base, 51, 36, 3, 12, 64, 64);
back.setRotationPoint(0.44f+x, 12.535f+y, 2.58f);
back.setScale(0.96f,0.8175f);
back.setThickness(thick);
setRotation(back, 0, (float)(Math.PI), 0);
this.addChild(back);
Model2DRenderer right = new Model2DRenderer(base, 47, 36, 4, 12, 64, 64);
right.setRotationPoint(0.45f+x, 12.55f+y, -2.55f);
right.setScale(0.96f,0.82f);
right.setThickness(thick);
setRotation(right, 0, (float)(Math.PI/-2f), 0);
this.addChild(right);
Model2DRenderer left = new Model2DRenderer(base, 40, 36, 4, 12, 64, 64);
left.setRotationPoint(-3.405f+x, 12.55f+y, 2.55f);
left.setScale(0.96f,0.82f);
left.setThickness(thick);
setRotation(left, 0, (float)(Math.PI/2f), 0);
this.addChild(left);
Model2DRenderer top = new Model2DRenderer(base, 44, 32, 3, 4, 64, 64);
top.setRotationPoint(-3.39375f+x, -0.6f+y, -2.55f);
top.setScale(0.32f);
top.setThickness(thick);
setRotation(top, (float)(Math.PI / -2), 0, 0);
this.addChild(top);
Model2DRenderer bottom = new Model2DRenderer(base, 47, 32, 3, 4, 64, 64);
bottom.setRotationPoint(-3.39375f+x, 12.0f+y, -2.545f);
bottom.setScale(0.32f);
bottom.setThickness(thick);
setRotation(bottom, (float)(Math.PI / -2), 0, 0);
this.addChild(bottom);
}
public void leftArmAlex(ModelBase base,float thick){
float x = 1.95f;
float y = -2.0f;
Model2DRenderer front = new Model2DRenderer(base, 44+8, 36+16, 3, 12, 64, 64);
front.setRotationPoint(-3.39375f+x, 12.535f+y, -2.58f);
front.setScale(0.96f,0.8175f);
front.setThickness(thick);
setRotation(front, 0, 0, 0);
this.addChild(front);
Model2DRenderer back = new Model2DRenderer(base, 51+8, 36+16, 3, 12, 64, 64);
back.setRotationPoint(0.44f+x, 12.535f+y, 2.58f);
back.setScale(0.96f,0.8175f);
back.setThickness(thick);
setRotation(back, 0, (float)(Math.PI), 0);
this.addChild(back);
Model2DRenderer right = new Model2DRenderer(base, 47+8, 36+16, 4, 12, 64, 64);
right.setRotationPoint(0.45f+x, 12.55f+y, -2.55f);
right.setScale(0.96f,0.82f);
right.setThickness(thick);
setRotation(right, 0, (float)(Math.PI/-2f), 0);
this.addChild(right);
Model2DRenderer left = new Model2DRenderer(base, 40+8, 36+16, 4, 12, 64, 64);
left.setRotationPoint(-3.405f+x, 12.55f+y, 2.55f);
left.setScale(0.96f,0.82f);
left.setThickness(thick);
setRotation(left, 0, (float)(Math.PI/2f), 0);
this.addChild(left);
Model2DRenderer top = new Model2DRenderer(base, 44+8, 32+16, 3, 4, 64, 64);
top.setRotationPoint(-3.39375f+x, -0.6f+y, -2.55f);
top.setScale(0.32f);
top.setThickness(thick);
setRotation(top, (float)(Math.PI / -2), 0, 0);
this.addChild(top);
Model2DRenderer bottom = new Model2DRenderer(base, 47+8, 32+16, 3, 4, 64, 64);
bottom.setRotationPoint(-3.39375f+x, 12.0f+y, -2.545f);
bottom.setScale(0.32f);
bottom.setThickness(thick);
setRotation(bottom, (float)(Math.PI / -2), 0, 0);
this.addChild(bottom);
}
public void rightArm(ModelBase base, float thick){ public void rightArm(ModelBase base, float thick){
float x = 0.95f; float x = 0.95f;
float y = -2.0f; float y = -2.0f;
@@ -55,17 +165,17 @@ public class ModelLimbWear extends ModelScaleRenderer {
this.addChild(back); this.addChild(back);
Model2DRenderer right = new Model2DRenderer(base, 48, 36, 4, 12, 64, 64); Model2DRenderer right = new Model2DRenderer(base, 48, 36, 4, 12, 64, 64);
right.setRotationPoint(0.1f+x, 12.55f+y, 2.55f); right.setRotationPoint(0.62f+x, 12.55f+y, -2.55f);
right.setScale(0.96f,0.82f); right.setScale(0.96f,0.82f);
right.setThickness(thick); right.setThickness(thick);
setRotation(right, 0, (float)(Math.PI/2f), 0); setRotation(right, 0, (float)(Math.PI/-2f), 0);
this.addChild(right); this.addChild(right);
Model2DRenderer left = new Model2DRenderer(base, 40, 36, 4, 12, 64, 64); Model2DRenderer left = new Model2DRenderer(base, 40, 36, 4, 12, 64, 64);
left.setRotationPoint(-3.98f+x, 12.55f+y, -2.55f); left.setRotationPoint(-4.56f+x, 12.55f+y, 2.55f);
left.setScale(0.96f,0.82f); left.setScale(0.96f,0.82f);
left.setThickness(thick); left.setThickness(thick);
setRotation(left, 0, (float)(Math.PI/-2f), 0); setRotation(left, 0, (float)(Math.PI/2f), 0);
this.addChild(left); this.addChild(left);
Model2DRenderer top = new Model2DRenderer(base, 44, 32, 4, 4, 64, 64); Model2DRenderer top = new Model2DRenderer(base, 44, 32, 4, 4, 64, 64);
@@ -102,17 +212,17 @@ public class ModelLimbWear extends ModelScaleRenderer {
this.addChild(back); this.addChild(back);
Model2DRenderer right = new Model2DRenderer(base, 56, 52, 4, 12, 64, 64); Model2DRenderer right = new Model2DRenderer(base, 56, 52, 4, 12, 64, 64);
right.setRotationPoint(0.06f+x, 12.55f+y, 2.55f); right.setRotationPoint(0.62f+x, 12.55f+y, -2.55f);
right.setScale(0.96f,0.82f); right.setScale(0.96f,0.82f);
right.setThickness(thick); right.setThickness(thick);
setRotation(right, 0, (float)(Math.PI/2f), 0); setRotation(right, 0, (float)(Math.PI/-2f), 0);
this.addChild(right); this.addChild(right);
Model2DRenderer left = new Model2DRenderer(base, 48, 52, 4, 12, 64, 64); Model2DRenderer left = new Model2DRenderer(base, 48, 52, 4, 12, 64, 64);
left.setRotationPoint(-4.03f+x, 12.55f+y, -2.55f); left.setRotationPoint(-4.56f+x, 12.55f+y, 2.55f);
left.setScale(0.96f,0.82f); left.setScale(0.96f,0.82f);
left.setThickness(thick); left.setThickness(thick);
setRotation(left, 0, (float)(Math.PI/-2f), 0); setRotation(left, 0, (float)(Math.PI/2f), 0);
this.addChild(left); this.addChild(left);
@@ -150,17 +260,17 @@ public class ModelLimbWear extends ModelScaleRenderer {
this.addChild(back); this.addChild(back);
Model2DRenderer right = new Model2DRenderer(base, 8, 36, 4, 12, 64, 64); Model2DRenderer right = new Model2DRenderer(base, 8, 36, 4, 12, 64, 64);
right.setRotationPoint(0.15f+x, 12.55f+y, 2.55f); right.setRotationPoint(0.62f+x, 12.55f+y, -2.55f);
right.setScale(0.96f,0.82f); right.setScale(0.96f,0.82f);
right.setThickness(thick); right.setThickness(thick);
setRotation(right, 0, (float)(Math.PI/2f), 0); setRotation(right, 0, (float)(Math.PI/-2f), 0);
this.addChild(right); this.addChild(right);
Model2DRenderer left = new Model2DRenderer(base, 0, 36, 4, 12, 64, 64); Model2DRenderer left = new Model2DRenderer(base, 0, 36, 4, 12, 64, 64);
left.setRotationPoint(-4.03f+x, 12.55f+y, -2.55f); left.setRotationPoint(-4.53f+x, 12.55f+y, 2.55f);
left.setScale(0.96f,0.82f); left.setScale(0.96f,0.82f);
left.setThickness(thick); left.setThickness(thick);
setRotation(left, 0, (float)(Math.PI/-2f), 0); setRotation(left, 0, (float)(Math.PI/2f), 0);
this.addChild(left); this.addChild(left);
@@ -198,17 +308,17 @@ public class ModelLimbWear extends ModelScaleRenderer {
this.addChild(back); this.addChild(back);
Model2DRenderer right = new Model2DRenderer(base, 8, 52, 4, 12, 64, 64); Model2DRenderer right = new Model2DRenderer(base, 8, 52, 4, 12, 64, 64);
right.setRotationPoint(0.15f+x, 12.55f+y, 2.55f); right.setRotationPoint(0.62f+x, 12.55f+y, -2.55f);
right.setScale(0.96f,0.82f); right.setScale(0.96f,0.82f);
right.setThickness(thick); right.setThickness(thick);
setRotation(right, 0, (float)(Math.PI/2f), 0); setRotation(right, 0, (float)(Math.PI/-2f), 0);
this.addChild(right); this.addChild(right);
Model2DRenderer left = new Model2DRenderer(base, 0, 52, 4, 12, 64, 64); Model2DRenderer left = new Model2DRenderer(base, 0, 52, 4, 12, 64, 64);
left.setRotationPoint(-4.03f+x, 12.55f+y, -2.55f); left.setRotationPoint(-4.53f+x, 12.55f+y, 2.55f);
left.setScale(0.96f,0.82f); left.setScale(0.96f,0.82f);
left.setThickness(thick); left.setThickness(thick);
setRotation(left, 0, (float)(Math.PI/-2f), 0); setRotation(left, 0, (float)(Math.PI/2f), 0);
this.addChild(left); this.addChild(left);
@@ -4,6 +4,7 @@ import static net.minecraftforge.client.IItemRenderer.ItemRenderType.EQUIPPED;
import static net.minecraftforge.client.IItemRenderer.ItemRendererHelper.BLOCK_3D; import static net.minecraftforge.client.IItemRenderer.ItemRendererHelper.BLOCK_3D;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.model.ModelBiped; import net.minecraft.client.model.ModelBiped;
import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.RenderBlocks;
@@ -11,7 +12,6 @@ import net.minecraft.client.renderer.entity.RenderBiped;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
import net.minecraft.init.Items;
import net.minecraft.item.*; import net.minecraft.item.*;
import net.minecraft.util.MathHelper; import net.minecraft.util.MathHelper;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
@@ -23,8 +23,6 @@ import noppes.npcs.client.model.ModelNPCMale;
import noppes.npcs.constants.EnumAnimation; import noppes.npcs.constants.EnumAnimation;
import noppes.npcs.entity.EntityCustomNpc; import noppes.npcs.entity.EntityCustomNpc;
import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.items.ItemClaw;
import noppes.npcs.items.ItemShield;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
@@ -36,8 +34,8 @@ public class RenderNPCHumanMale extends RenderNPCInterface
protected ModelNPCMale modelArmor; protected ModelNPCMale modelArmor;
protected final ModelNPCMale originalBipedMain; protected final ModelNPCMale originalBipedMain;
protected final ModelMPM steve = new ModelMPM(0, false); protected final static ModelMPM steve64 = new ModelMPM(0, false);
protected final ModelMPM alex = new ModelMPM(0, true); protected final static ModelMPM alex = new ModelMPM(0, true);
public RenderNPCHumanMale(ModelNPCMale mainmodel, ModelNPCMale armorChest, ModelNPCMale armor) public RenderNPCHumanMale(ModelNPCMale mainmodel, ModelNPCMale armorChest, ModelNPCMale armor)
{ {
@@ -113,14 +111,13 @@ public class RenderNPCHumanMale extends RenderNPCInterface
public void renderPlayer(EntityNPCInterface npc, double d, double d1, double d2, public void renderPlayer(EntityNPCInterface npc, double d, double d1, double d2,
float f, float f1) float f, float f1)
{ {
// SEEMS TO WORK FOR NOW. Keeps NPC from outsyncing with Creature Models
if(npc instanceof EntityCustomNpc){ if(npc instanceof EntityCustomNpc){
EntityCustomNpc test = (EntityCustomNpc) npc; EntityCustomNpc test = (EntityCustomNpc) npc;
if(test.modelData.entityClass == null){ if(test.modelData.entityClass == null){
int modelVal = npc.display.modelType; int modelVal = npc.display.modelType;
if(modelVal == 1){ if(modelVal == 1){
this.mainModel = steve; this.mainModel = steve64;
this.modelBipedMain = steve; this.modelBipedMain = steve64;
} }
else if(modelVal == 2){ else if(modelVal == 2){
this.mainModel = alex; this.mainModel = alex;
@@ -177,7 +174,6 @@ public class RenderNPCHumanMale extends RenderNPCInterface
npc.textureCloakLocation = new ResourceLocation(npc.display.cloakTexture); npc.textureCloakLocation = new ResourceLocation(npc.display.cloakTexture);
} }
bindTexture((ResourceLocation) npc.textureCloakLocation); bindTexture((ResourceLocation) npc.textureCloakLocation);
//AbstractClientPlayer.func_110307_b(, null);
GL11.glPushMatrix(); GL11.glPushMatrix();
GL11.glTranslatef(0.0F, 0.0F, 0.125F); GL11.glTranslatef(0.0F, 0.0F, 0.125F);
double d = (npc.field_20066_r + (npc.field_20063_u - npc.field_20066_r) * (double)f) - (npc.prevPosX + (npc.posX - npc.prevPosX) * (double)f); double d = (npc.field_20066_r + (npc.field_20063_u - npc.field_20066_r) * (double)f) - (npc.prevPosX + (npc.posX - npc.prevPosX) * (double)f);
@@ -193,13 +189,12 @@ public class RenderNPCHumanMale extends RenderNPCInterface
f14 = 0.0F; f14 = 0.0F;
} }
float f16 = npc.prevRotationYaw + (npc.rotationYaw - npc.prevRotationYaw) * f; float f16 = npc.prevRotationYaw + (npc.rotationYaw - npc.prevRotationYaw) * f;
//f13 += MathHelper.sin((entityplayer.prevDistanceWalkedModified + (entityplayer.distanceWalkedModified - entityplayer.prevDistanceWalkedModified) * f) * 6F) * 32F * f16;
float f13 = 5f; float f13 = 5f;
if (npc.isSneaking()) if (npc.isSneaking())
{ {
f13 += 25F; f13 += 25F;
} }
//System.out.println(entityplayer.prevDistanceWalkedModified);
GL11.glRotatef(6F + f14 / 2.0F + f13, 1.0F, 0.0F, 0.0F); GL11.glRotatef(6F + f14 / 2.0F + f13, 1.0F, 0.0F, 0.0F);
GL11.glRotatef(f15 / 2.0F, 0.0F, 0.0F, 1.0F); GL11.glRotatef(f15 / 2.0F, 0.0F, 0.0F, 1.0F);
GL11.glRotatef(-f15 / 2.0F, 0.0F, 1.0F, 0.0F); GL11.glRotatef(-f15 / 2.0F, 0.0F, 1.0F, 0.0F);
@@ -255,7 +250,13 @@ public class RenderNPCHumanMale extends RenderNPCInterface
GL11.glTranslatef(x, cnpc.modelData.getBodyY(), 0); GL11.glTranslatef(x, cnpc.modelData.getBodyY(), 0);
} }
this.modelBipedMain.bipedRightArm.postRender(0.0625F); this.modelBipedMain.bipedRightArm.postRender(0.0625F);
GL11.glTranslatef(-0.0625F, 0.4375F + y, 0.0625F);
if(npc.getModelType() == 2){
GL11.glTranslatef(-0.0125F, 0.4375F + y, 0.0625F);
}
else {
GL11.glTranslatef(-0.0625F, 0.4375F + y, 0.0625F);
}
IItemRenderer customRenderer = MinecraftForgeClient.getItemRenderer(itemstack2, EQUIPPED); IItemRenderer customRenderer = MinecraftForgeClient.getItemRenderer(itemstack2, EQUIPPED);
boolean is3D = (customRenderer != null && customRenderer.shouldUseRenderHelper(EQUIPPED, itemstack2, BLOCK_3D)); boolean is3D = (customRenderer != null && customRenderer.shouldUseRenderHelper(EQUIPPED, itemstack2, BLOCK_3D));
@@ -269,8 +270,7 @@ public class RenderNPCHumanMale extends RenderNPCInterface
GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F); GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F);
GL11.glScalef(-var6, -var6, var6); GL11.glScalef(-var6, -var6, var6);
} }
// CHANGE HERE else if (itemstack2.getItem() instanceof ItemBow && customRenderer == null)
else if (itemstack2.getItem() instanceof ItemBow)
{ {
var6 = 0.625F; var6 = 0.625F;
GL11.glTranslatef(0.0F, 0.125F, 0.3125F); GL11.glTranslatef(0.0F, 0.125F, 0.3125F);
@@ -343,8 +343,15 @@ public class RenderNPCHumanMale extends RenderNPCInterface
GL11.glTranslatef(x, cnpc.modelData.getBodyY(), 0); GL11.glTranslatef(x, cnpc.modelData.getBodyY(), 0);
} }
this.modelBipedMain.bipedLeftArm.postRender(0.0625F); this.modelBipedMain.bipedLeftArm.postRender(0.0625F);
GL11.glTranslatef(0.0625F, 0.4375F + y, 0.0625F);
float var6; if(npc.getModelType() == 2){
GL11.glTranslatef(0.0125F, 0.4375F + y, 0.0625F);
}
else {
GL11.glTranslatef(0.0625F, 0.4375F + y, 0.0625F);
}
float var6;
IItemRenderer customRenderer = MinecraftForgeClient.getItemRenderer(itemstack2, EQUIPPED); IItemRenderer customRenderer = MinecraftForgeClient.getItemRenderer(itemstack2, EQUIPPED);
boolean is3D = (customRenderer != null && customRenderer.shouldUseRenderHelper(EQUIPPED, itemstack2, BLOCK_3D)); boolean is3D = (customRenderer != null && customRenderer.shouldUseRenderHelper(EQUIPPED, itemstack2, BLOCK_3D));
@@ -362,7 +369,7 @@ public class RenderNPCHumanMale extends RenderNPCInterface
GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F); GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F);
GL11.glScalef(var6, -var6, var6); GL11.glScalef(var6, -var6, var6);
} }
else if (itemstack2.getItem() instanceof ItemBow) else if (itemstack2.getItem() instanceof ItemBow && customRenderer == null)
{ {
var6 = 0.625F; var6 = 0.625F;
GL11.glTranslatef(0.0F, 0.125F, 0.3125F); GL11.glTranslatef(0.0F, 0.125F, 0.3125F);
@@ -32,22 +32,22 @@ import com.mojang.authlib.minecraft.MinecraftProfileTexture;
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type; import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
public class RenderNPCInterface extends RenderLiving{ public class RenderNPCInterface extends RenderLiving{
public static long LastTextureTick = 0; public static long LastTextureTick = 0;
public ModelBase originalModel; public ModelBase originalModel;
public RenderNPCInterface(ModelBase model, float f){ public RenderNPCInterface(ModelBase model, float f){
super(model, f); super(model, f);
this.originalModel = model; this.originalModel = model;
} }
protected void renderName(EntityNPCInterface npc, double d, double d1, double d2) { protected void renderName(EntityNPCInterface npc, double d, double d1, double d2) {
if (!this.func_110813_b(npc)) if (!this.func_110813_b(npc))
return; return;
float f2 = npc.getDistanceToEntity(renderManager.livingPlayer); float f2 = npc.getDistanceToEntity(renderManager.livingPlayer);
float f3 = npc.isSneaking() ? 32F : 64F; float f3 = npc.isSneaking() ? 32F : 64F;
if (f2 > f3) if (f2 > f3)
return; return;
if (npc.messages != null){ if (npc.messages != null){
@@ -69,199 +69,201 @@ public class RenderNPCInterface extends RenderLiving{
height = 1; height = 1;
} }
} }
}
public void doRenderShadowAndFire(Entity par1Entity, double par2, double par4, double par6, float par8, float par9){
EntityNPCInterface npc = (EntityNPCInterface) par1Entity;
if(!npc.isKilled() && !npc.scriptInvisibleToPlayer(Minecraft.getMinecraft().thePlayer))
super.doRenderShadowAndFire(par1Entity, par2, par4, par6, par8, par9);
}
protected void renderLivingLabel(EntityNPCInterface npc, double d, double d1, double d2, int i, Object... obs){
FontRenderer fontrenderer = getFontRendererFromRenderManager();
i = npc.getBrightnessForRender(0);
int j = i % 65536;
int k = i / 65536;
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;
GL11.glPushMatrix();
GL11.glTranslatef((float)d + 0.0F, (float)d1, (float)d2);
GL11.glNormal3f(0.0F, 1.0F, 0.0F);
GL11.glRotatef(-renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
GL11.glRotatef(renderManager.playerViewX, 1.0F, 0.0F, 0.0F);
Tessellator tessellator = Tessellator.instance;
float height = f1 / 6.5f;
for(j = 0; j < obs.length; j += 2){
float scale = (Float) obs[j + 1];
height += f1 / 6.5f * scale;
GL11.glPushMatrix();
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glDepthMask(false);
GL11.glDisable(GL11.GL_ALPHA_TEST);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glDisable(GL11.GL_TEXTURE_2D);
String s = obs[j].toString();
GL11.glTranslatef(0, height, 0);
GL11.glScalef(-f2 * scale, -f2 * scale, f2 * scale);
tessellator.startDrawingQuads();
int size = fontrenderer.getStringWidth(s) / 2;
tessellator.setColorRGBA_F(0.0F, 0.0F, 0.0F, 0.25F);
tessellator.addVertex(-size - 1, -1, 0.0D);
tessellator.addVertex(-size - 1, 8 , 0.0D);
tessellator.addVertex(size + 1, 8 , 0.0D);
tessellator.addVertex(size + 1, -1 , 0.0D);
tessellator.draw();
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glEnable(GL11.GL_DEPTH_TEST);
GL11.glDepthMask(true);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
int color = npc.faction.color;
fontrenderer.drawString(s, -fontrenderer.getStringWidth(s) / 2, 0, color);
GL11.glPopMatrix();
}
GL11.glEnable(GL11.GL_ALPHA_TEST);
GL11.glEnable(GL11.GL_LIGHTING /*GL_LIGHTING*/);
GL11.glDisable(GL11.GL_BLEND /*GL_BLEND*/);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glPopMatrix();
}
protected void renderPlayerScale(EntityNPCInterface npc, float f){
GL11.glScalef((npc.scaleX / 5) * npc.display.modelSize, (npc.scaleY / 5) * npc.display.modelSize, (npc.scaleZ / 5) * npc.display.modelSize);
}
protected void renderPlayerSleep(EntityNPCInterface npc, double d, double d1, double d2){
shadowSize = npc.display.modelSize / 10f;
float xOffset = 0;
float yOffset = npc.currentAnimation == EnumAnimation.NONE?npc.ai.bodyOffsetY / 10 - 0.5f:0;
float zOffset = 0;
if(npc.isEntityAlive()){
if(npc.isPlayerSleeping()){
xOffset = (float) -Math.cos(Math.toRadians(180 - npc.ai.orientation));
zOffset = (float) -Math.sin(Math.toRadians(npc.ai.orientation));
yOffset += 0.14f;
}
else if(npc.isRiding()){
yOffset -= 0.5f - ((EntityCustomNpc)npc).modelData.getLegsY() * 0.8f;
}
}
renderLiving(npc, d, d1, d2, xOffset, yOffset, zOffset);
}
private void renderLiving(EntityNPCInterface npc, double d, double d1, double d2,float xoffset,float yoffset,float zoffset){
xoffset = (xoffset/ 5f) * npc.display.modelSize;
yoffset = (yoffset/ 5f) * npc.display.modelSize;
zoffset = (zoffset/ 5f) * npc.display.modelSize;
super.renderLivingAt(npc, d+xoffset, d1+yoffset, d2 + zoffset);
}
@Override
protected void rotateCorpse(EntityLivingBase entity, float f, float f1, float f2){
EntityNPCInterface npc = (EntityNPCInterface) entity;
if(npc.isEntityAlive() && npc.isPlayerSleeping())
{
GL11.glRotatef(npc.ai.orientation, 0.0F, 1.0F, 0.0F);
GL11.glRotatef(getDeathMaxRotation(npc), 0.0F, 0.0F, 1.0F);
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 = ((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);
}
else {
super.rotateCorpse(npc, f, f1, f2);
}
}
@Override
protected void passSpecialRender(EntityLivingBase par1EntityLivingBase, double par2, double par4, double par6){
renderName((EntityNPCInterface)par1EntityLivingBase, par2, par4, par6);
}
@Override
protected void preRenderCallback(EntityLivingBase entityliving, float f){
renderPlayerScale((EntityNPCInterface)entityliving, f);
}
@Override
public void doRender(EntityLiving entityliving, double d, double d1, double d2, float f, float f1){
EntityNPCInterface npc = (EntityNPCInterface) entityliving;
if(npc.isKilled() && npc.stats.hideKilledBody && npc.deathTime > 20){
return;
}
if((npc.display.showBossBar == 1 || npc.display.showBossBar == 2 && npc.isAttacking()) && !npc.isKilled() && npc.deathTime <= 20 && npc.canSee(Minecraft.getMinecraft().thePlayer))
BossStatus.setBossStatus(npc, true);
if(npc.ai.standingType == EnumStandingType.HeadRotation && !npc.isWalking() && !npc.isInteracting()){
npc.prevRenderYawOffset = npc.renderYawOffset = npc.ai.orientation;
}
super.doRender(entityliving, d, d1, d2, f, f1);
} }
protected void renderModel(EntityLivingBase entityliving, float par2, float par3, float par4, float par5, float par6, float par7){ public void doRenderShadowAndFire(Entity par1Entity, double par2, double par4, double par6, float par8, float par9){
super.renderModel(entityliving, par2, par3, par4, par5, par6, par7); EntityNPCInterface npc = (EntityNPCInterface) par1Entity;
EntityNPCInterface npc = (EntityNPCInterface) entityliving; if(!npc.isKilled() && !npc.scriptInvisibleToPlayer(Minecraft.getMinecraft().thePlayer))
if (!npc.display.glowTexture.isEmpty()) super.doRenderShadowAndFire(par1Entity, par2, par4, par6, par8, par9);
{ }
GL11.glDepthFunc(GL11.GL_LEQUAL);
if(npc.textureGlowLocation == null){
npc.textureGlowLocation = new ResourceLocation(npc.display.glowTexture);
}
bindTexture((ResourceLocation) npc.textureGlowLocation);
float f1 = 1.0F;
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE);
GL11.glDisable(GL11.GL_LIGHTING);
if (npc.isInvisible())
{
GL11.glDepthMask(false);
}
else
{
GL11.glDepthMask(true);
}
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glPushMatrix();
GL11.glScalef(1.001f, 1.001f, 1.001f);
if(mainModel instanceof ModelMPM){
((ModelMPM)mainModel).isArmor = true;
mainModel.render(entityliving, par2, par3, par4, par5, par6, par7);
((ModelMPM)mainModel).isArmor = false;
}
else
mainModel.render(entityliving, par2, par3, par4, par5, par6, par7);
GL11.glPopMatrix();
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glColor4f(1.0F, 1.0F, 1.0F, f1);
GL11.glDepthFunc(GL11.GL_LEQUAL); protected void renderLivingLabel(EntityNPCInterface npc, double d, double d1, double d2, int i, Object... obs){
GL11.glDisable(GL11.GL_BLEND); FontRenderer fontrenderer = getFontRendererFromRenderManager();
}
} i = npc.getBrightnessForRender(0);
@Override int j = i % 65536;
protected float handleRotationFloat(EntityLivingBase par1EntityLiving, float par2){ int k = i / 65536;
EntityNPCInterface npc = (EntityNPCInterface) par1EntityLiving; OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)j / 1.0F, (float)k / 1.0F);
if(npc.isKilled() || npc.display.disableLivingAnimation)
return 0; float f1 = (npc.baseHeight / 5f) * npc.display.modelSize;
return super.handleRotationFloat(par1EntityLiving, par2); float f2 = 0.01666667F * f1;
} GL11.glPushMatrix();
GL11.glTranslatef((float)d + 0.0F, (float)d1, (float)d2);
GL11.glNormal3f(0.0F, 1.0F, 0.0F);
GL11.glRotatef(-renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
GL11.glRotatef(renderManager.playerViewX, 1.0F, 0.0F, 0.0F);
Tessellator tessellator = Tessellator.instance;
float height = f1 / 6.5f;
for(j = 0; j < obs.length; j += 2){
float scale = (Float) obs[j + 1];
height += f1 / 6.5f * scale;
GL11.glPushMatrix();
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glDepthMask(false);
GL11.glDisable(GL11.GL_ALPHA_TEST);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glDisable(GL11.GL_TEXTURE_2D);
String s = obs[j].toString();
GL11.glTranslatef(0, height, 0);
GL11.glScalef(-f2 * scale, -f2 * scale, f2 * scale);
tessellator.startDrawingQuads();
int size = fontrenderer.getStringWidth(s) / 2;
tessellator.setColorRGBA_F(0.0F, 0.0F, 0.0F, 0.25F);
tessellator.addVertex(-size - 1, -1, 0.0D);
tessellator.addVertex(-size - 1, 8 , 0.0D);
tessellator.addVertex(size + 1, 8 , 0.0D);
tessellator.addVertex(size + 1, -1 , 0.0D);
tessellator.draw();
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glEnable(GL11.GL_DEPTH_TEST);
GL11.glDepthMask(true);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
int color = npc.faction.color;
fontrenderer.drawString(s, -fontrenderer.getStringWidth(s) / 2, 0, color);
GL11.glPopMatrix();
}
GL11.glEnable(GL11.GL_ALPHA_TEST);
GL11.glEnable(GL11.GL_LIGHTING /*GL_LIGHTING*/);
GL11.glDisable(GL11.GL_BLEND /*GL_BLEND*/);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glPopMatrix();
}
protected void renderPlayerScale(EntityNPCInterface npc, float f){
GL11.glScalef((npc.scaleX / 5) * npc.display.modelSize, (npc.scaleY / 5) * npc.display.modelSize, (npc.scaleZ / 5) * npc.display.modelSize);
}
protected void renderPlayerSleep(EntityNPCInterface npc, double d, double d1, double d2){
shadowSize = npc.display.modelSize / 10f;
float xOffset = 0;
float yOffset = npc.currentAnimation == EnumAnimation.NONE?npc.ai.bodyOffsetY / 10 - 0.5f:0;
float zOffset = 0;
if(npc.isEntityAlive()){
if(npc.isPlayerSleeping()){
xOffset = (float) -Math.cos(Math.toRadians(180 - npc.ai.orientation));
zOffset = (float) -Math.sin(Math.toRadians(npc.ai.orientation));
yOffset += 0.14f;
}
else if(npc.isRiding()){
yOffset -= 0.5f - ((EntityCustomNpc)npc).modelData.getLegsY() * 0.8f;
}
}
renderLiving(npc, d, d1, d2, xOffset, yOffset, zOffset);
}
private void renderLiving(EntityNPCInterface npc, double d, double d1, double d2,float xoffset,float yoffset,float zoffset){
xoffset = (xoffset/ 5f) * npc.display.modelSize;
yoffset = (yoffset/ 5f) * npc.display.modelSize;
zoffset = (zoffset/ 5f) * npc.display.modelSize;
super.renderLivingAt(npc, d+xoffset, d1+yoffset, d2 + zoffset);
}
@Override
protected void rotateCorpse(EntityLivingBase entity, float f, float f1, float f2){
EntityNPCInterface npc = (EntityNPCInterface) entity;
if(npc.isEntityAlive() && npc.isPlayerSleeping())
{
GL11.glRotatef(npc.ai.orientation, 0.0F, 1.0F, 0.0F);
GL11.glRotatef(getDeathMaxRotation(npc), 0.0F, 0.0F, 1.0F);
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 = ((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);
}
else {
super.rotateCorpse(npc, f, f1, f2);
}
}
@Override
protected void passSpecialRender(EntityLivingBase par1EntityLivingBase, double par2, double par4, double par6){
renderName((EntityNPCInterface)par1EntityLivingBase, par2, par4, par6);
}
@Override
protected void preRenderCallback(EntityLivingBase entityliving, float f){
renderPlayerScale((EntityNPCInterface)entityliving, f);
}
@Override
public void doRender(EntityLiving entityliving, double d, double d1, double d2, float f, float f1){
EntityNPCInterface npc = (EntityNPCInterface) entityliving;
if(npc.isKilled() && npc.stats.hideKilledBody && npc.deathTime > 20){
return;
}
if((npc.display.showBossBar == 1 || npc.display.showBossBar == 2 && npc.isAttacking()) && !npc.isKilled() && npc.deathTime <= 20 && npc.canSee(Minecraft.getMinecraft().thePlayer))
BossStatus.setBossStatus(npc, true);
if(npc.ai.standingType == EnumStandingType.HeadRotation && !npc.isWalking() && !npc.isInteracting()){
npc.prevRenderYawOffset = npc.renderYawOffset = npc.ai.orientation;
}
super.doRender(entityliving, d, d1, d2, f, f1);
}
protected void renderModel(EntityLivingBase entityliving, float par2, float par3, float par4, float par5, float par6, float par7){
super.renderModel(entityliving, par2, par3, par4, par5, par6, par7);
EntityNPCInterface npc = (EntityNPCInterface) entityliving;
if (!npc.display.glowTexture.isEmpty())
{
GL11.glDepthFunc(GL11.GL_LEQUAL);
if(npc.textureGlowLocation == null){
npc.textureGlowLocation = new ResourceLocation(npc.display.glowTexture);
}
bindTexture((ResourceLocation) npc.textureGlowLocation);
float f1 = 1.0F;
GL11.glEnable(GL11.GL_BLEND);
// Overlay & Glow
GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE);
GL11.glDisable(GL11.GL_LIGHTING);
if (npc.isInvisible())
{
GL11.glDepthMask(false);
}
else
{
GL11.glDepthMask(true);
}
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glPushMatrix();
GL11.glScalef(1.001f, 1.001f, 1.001f);
if(mainModel instanceof ModelMPM){
((ModelMPM)mainModel).isArmor = true;
mainModel.render(entityliving, par2, par3, par4, par5, par6, par7);
((ModelMPM)mainModel).isArmor = false;
}
else
mainModel.render(entityliving, par2, par3, par4, par5, par6, par7);
GL11.glPopMatrix();
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glColor4f(1.0F, 1.0F, 1.0F, f1);
GL11.glDepthFunc(GL11.GL_LEQUAL);
GL11.glDisable(GL11.GL_BLEND);
}
}
@Override
protected float handleRotationFloat(EntityLivingBase par1EntityLiving, float par2){
EntityNPCInterface npc = (EntityNPCInterface) par1EntityLiving;
if(npc.isKilled() || npc.display.disableLivingAnimation)
return 0;
return super.handleRotationFloat(par1EntityLiving, par2);
}
@Override
protected void renderLivingAt(EntityLivingBase entityliving, double d, double d1, double d2){
renderPlayerSleep((EntityNPCInterface)entityliving, d, d1, d2);
}
@Override
protected void renderLivingAt(EntityLivingBase entityliving, double d, double d1, double d2){
renderPlayerSleep((EntityNPCInterface)entityliving, d, d1, d2);
}
@Override @Override
public ResourceLocation getEntityTexture(Entity entity) { public ResourceLocation getEntityTexture(Entity entity) {
@@ -276,11 +278,11 @@ public class RenderNPCInterface extends RenderLiving{
return AbstractClientPlayer.locationStevePng; return AbstractClientPlayer.locationStevePng;
} }
else if(npc.display.skinType == 1 && npc.display.playerProfile != null){ else if(npc.display.skinType == 1 && npc.display.playerProfile != null){
Minecraft minecraft = Minecraft.getMinecraft(); Minecraft minecraft = Minecraft.getMinecraft();
Map map = minecraft.func_152342_ad().func_152788_a(npc.display.playerProfile); Map map = minecraft.func_152342_ad().func_152788_a(npc.display.playerProfile);
if (map.containsKey(Type.SKIN)){ if (map.containsKey(Type.SKIN)){
npc.textureLocation = minecraft.func_152342_ad().func_152792_a((MinecraftProfileTexture)map.get(Type.SKIN), Type.SKIN); npc.textureLocation = minecraft.func_152342_ad().func_152792_a((MinecraftProfileTexture)map.get(Type.SKIN), Type.SKIN);
} }
LastTextureTick = 0; LastTextureTick = 0;
} }
else if(npc.display.skinType == 2 || npc.display.skinType == 3){ else if(npc.display.skinType == 2 || npc.display.skinType == 3){
@@ -291,7 +293,6 @@ public class RenderNPCInterface extends RenderLiving{
for(byte b : hash){ for(byte b : hash){
sb.append(String.format("%02x", b&0xff)); sb.append(String.format("%02x", b&0xff));
} }
// SKIN CHANGE
if(npc.display.skinType == 2){ if(npc.display.skinType == 2){
npc.textureLocation = new ResourceLocation("skins/" + sb.toString()); npc.textureLocation = new ResourceLocation("skins/" + sb.toString());
loadSkin(null, npc.textureLocation, npc.display.url, false); loadSkin(null, npc.textureLocation, npc.display.url, false);
@@ -313,10 +314,10 @@ public class RenderNPCInterface extends RenderLiving{
} }
// 64x64 Skin is True // 64x64 Skin is True
private void loadSkin(File file, ResourceLocation resource, String par1Str, boolean version){ private void loadSkin(File file, ResourceLocation resource, String par1Str, boolean version){
TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager(); TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager();
ITextureObject object = new ImageDownloadAlt(file, par1Str, SkinManager.field_152793_a, new ImageBufferDownloadAlt(version)); ITextureObject object = new ImageDownloadAlt(file, par1Str, SkinManager.field_152793_a, new ImageBufferDownloadAlt(version));
texturemanager.loadTexture(resource, object); texturemanager.loadTexture(resource, object);
} }
} }
@@ -219,7 +219,6 @@ public class RenderNPCPony extends RenderNPCInterface
float f4 = 0.375F * f; float f4 = 0.375F * f;
GL11.glScalef(f4, -f4, f4); GL11.glScalef(f4, -f4, f4);
} else } else
// CHANGE HERE
if(itemstack.getItem() instanceof ItemBow) if(itemstack.getItem() instanceof ItemBow)
{ {
GL11.glTranslatef(0.0F, 0.125F, 0.3125F); GL11.glTranslatef(0.0F, 0.125F, 0.3125F);
@@ -40,6 +40,9 @@ public enum EnumPacketServer {
ScriptForgeSave(CustomNpcsPermissions.TOOL_SCRIPTER, false), ScriptForgeSave(CustomNpcsPermissions.TOOL_SCRIPTER, false),
ScriptForgeGet(false), ScriptForgeGet(false),
ScriptNPCSave(CustomNpcsPermissions.TOOL_SCRIPTER, false),
ScriptNPCGet(false),
LinkedGetAll, LinkedRemove(CustomNpcsPermissions.GLOBAL_LINKED), LinkedAdd(CustomNpcsPermissions.GLOBAL_LINKED), LinkedGetAll, LinkedRemove(CustomNpcsPermissions.GLOBAL_LINKED), LinkedAdd(CustomNpcsPermissions.GLOBAL_LINKED),
ScriptDataSave(CustomNpcsPermissions.TOOL_SCRIPTER, true), ScriptDataGet(true), ScriptDataSave(CustomNpcsPermissions.TOOL_SCRIPTER, true), ScriptDataGet(true),
PlayerDataRemove(CustomNpcsPermissions.GLOBAL_PLAYERDATA), PlayerDataRemove(CustomNpcsPermissions.GLOBAL_PLAYERDATA),
@@ -67,10 +67,7 @@ public class Dialog implements ICompatibilty, IDialog {
else { else {
darkenScreen = true; darkenScreen = true;
} }
// Temporary Remove after Few Versions
if(compound.hasKey("DialogDarkenScreen")){
compound.removeTag("DialogDarkenScreen");
}
NBTTagList options = compound.getTagList("Options", 10); NBTTagList options = compound.getTagList("Options", 10);
HashMap<Integer,DialogOption> newoptions = new HashMap<Integer,DialogOption>(); HashMap<Integer,DialogOption> newoptions = new HashMap<Integer,DialogOption>();
@@ -104,10 +101,6 @@ public class Dialog implements ICompatibilty, IDialog {
compound.setBoolean("DialogDisableEsc", disableEsc); compound.setBoolean("DialogDisableEsc", disableEsc);
compound.setBoolean("DialogDarkScreen", darkenScreen); compound.setBoolean("DialogDarkScreen", darkenScreen);
// Temporary Remove after Few Versions
if(compound.hasKey("DialogDarkenScreen")){
compound.removeTag("DialogDarkenScreen");
}
if(sound != null && !sound.isEmpty()) if(sound != null && !sound.isEmpty())
compound.setString("DialogSound", sound); compound.setString("DialogSound", sound);
@@ -4,13 +4,11 @@ import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.CompressedStreamTools; import net.minecraft.nbt.CompressedStreamTools;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.IExtendedEntityProperties; import net.minecraftforge.common.IExtendedEntityProperties;
import noppes.npcs.CustomNpcs; import noppes.npcs.CustomNpcs;
import noppes.npcs.LogWriter; import noppes.npcs.LogWriter;
import noppes.npcs.constants.EnumRoleType; import noppes.npcs.constants.EnumRoleType;
import noppes.npcs.controllers.data.PlayerDataScript;
import noppes.npcs.entity.EntityCustomNpc; import noppes.npcs.entity.EntityCustomNpc;
import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.entity.data.DataTimers; import noppes.npcs.entity.data.DataTimers;
@@ -16,9 +16,9 @@ import noppes.npcs.CustomNpcs;
import noppes.npcs.LogWriter; import noppes.npcs.LogWriter;
import noppes.npcs.util.NBTJsonUtil; import noppes.npcs.util.NBTJsonUtil;
public class PlayerDataController { public class PlayerDataController {
public static PlayerDataController instance; public static PlayerDataController instance;
public PlayerDataController(){ public PlayerDataController(){
instance = this; instance = this;
} }
@@ -42,24 +42,24 @@ public class PlayerDataController {
filename = "noplayername"; filename = "noplayername";
filename += ".dat"; filename += ".dat";
try { try {
File file = new File(saveDir, filename); File file = new File(saveDir, filename);
if(file.exists()){ if(file.exists()){
NBTTagCompound comp = CompressedStreamTools.readCompressed(new FileInputStream(file)); NBTTagCompound comp = CompressedStreamTools.readCompressed(new FileInputStream(file));
file.delete(); file.delete();
file = new File(saveDir, filename+"_old"); file = new File(saveDir, filename+"_old");
if(file.exists()) if(file.exists())
file.delete(); file.delete();
return comp; return comp;
} }
} catch (Exception e) { } catch (Exception e) {
LogWriter.except(e); LogWriter.except(e);
} }
try { try {
File file = new File(saveDir, filename+"_old"); File file = new File(saveDir, filename+"_old");
if(file.exists()){ if(file.exists()){
return CompressedStreamTools.readCompressed(new FileInputStream(file)); return CompressedStreamTools.readCompressed(new FileInputStream(file));
} }
} catch (Exception e) { } catch (Exception e) {
LogWriter.except(e); LogWriter.except(e);
} }
@@ -74,34 +74,34 @@ public class PlayerDataController {
filename = "noplayername"; filename = "noplayername";
filename += ".json"; filename += ".json";
try { try {
File file = new File(saveDir, filename); File file = new File(saveDir, filename);
if(file.exists()){ if(file.exists()){
return NBTJsonUtil.LoadFile(file); return NBTJsonUtil.LoadFile(file);
} }
} catch (Exception e) { } catch (Exception e) {
LogWriter.error("Error loading: " + filename, e); LogWriter.error("Error loading: " + filename, e);
} }
return new NBTTagCompound(); return new NBTTagCompound();
} }
public void savePlayerData(PlayerData data){ public void savePlayerData(PlayerData data){
NBTTagCompound compound = data.getNBT(); NBTTagCompound compound = data.getNBT();
String filename = data.uuid + ".json"; String filename = data.uuid + ".json";
try { try {
File saveDir = getSaveDir(); File saveDir = getSaveDir();
File file = new File(saveDir, filename+"_new"); File file = new File(saveDir, filename+"_new");
File file1 = new File(saveDir, filename); File file1 = new File(saveDir, filename);
NBTJsonUtil.SaveFile(file, compound); NBTJsonUtil.SaveFile(file, compound);
if(file1.exists()){ if(file1.exists()){
file1.delete(); file1.delete();
} }
file.renameTo(file1); file.renameTo(file1);
} catch (Exception e) { } catch (Exception e) {
LogWriter.except(e); LogWriter.except(e);
} }
} }
public PlayerBankData getBankData(EntityPlayer player, int bankId) { public PlayerBankData getBankData(EntityPlayer player, int bankId) {
Bank bank = BankController.getInstance().getBank(bankId); Bank bank = BankController.getInstance().getBank(bankId);
PlayerBankData data = getPlayerData(player).bankData; PlayerBankData data = getPlayerData(player).bankData;
@@ -110,7 +110,7 @@ public class PlayerDataController {
} }
return data; return data;
} }
public PlayerData getPlayerData(EntityPlayer player){ public PlayerData getPlayerData(EntityPlayer player){
PlayerData data = (PlayerData) player.getExtendedProperties("CustomNpcsData"); PlayerData data = (PlayerData) player.getExtendedProperties("CustomNpcsData");
if(data == null){ if(data == null){
@@ -122,14 +122,14 @@ public class PlayerDataController {
return data; return data;
} }
public String hasPlayer(String username) { public String hasPlayer(String username) {
for(String name : getUsernameData().keySet()){ for(String name : getUsernameData().keySet()){
if(name.equalsIgnoreCase(username)) if(name.equalsIgnoreCase(username))
return name; return name;
} }
return ""; return "";
} }
public PlayerData getDataFromUsername(String username){ public PlayerData getDataFromUsername(String username){
EntityPlayer player = MinecraftServer.getServer().getConfigurationManager().func_152612_a(username); EntityPlayer player = MinecraftServer.getServer().getConfigurationManager().func_152612_a(username);
PlayerData data = null; PlayerData data = null;
@@ -145,37 +145,37 @@ public class PlayerDataController {
} }
else else
data = getPlayerData(player); data = getPlayerData(player);
return data; return data;
} }
public void addPlayerMessage(String username, PlayerMail mail) { public void addPlayerMessage(String username, PlayerMail mail) {
mail.time = System.currentTimeMillis(); mail.time = System.currentTimeMillis();
EntityPlayer player = MinecraftServer.getServer().getConfigurationManager().func_152612_a(username); EntityPlayer player = MinecraftServer.getServer().getConfigurationManager().func_152612_a(username);
PlayerData data = getDataFromUsername(username); PlayerData data = getDataFromUsername(username);
data.mailData.playermail.add(mail.copy()); data.mailData.playermail.add(mail.copy());
savePlayerData(data); savePlayerData(data);
} }
public Map<String, NBTTagCompound> getUsernameData(){ public Map<String, NBTTagCompound> getUsernameData(){
Map<String, NBTTagCompound> map = new HashMap<String, NBTTagCompound>(); Map<String, NBTTagCompound> map = new HashMap<String, NBTTagCompound>();
for(File file : getSaveDir().listFiles()){ for(File file : getSaveDir().listFiles()){
if(file.isDirectory() || !file.getName().endsWith(".json")) if(file.isDirectory() || !file.getName().endsWith(".json"))
continue; continue;
try { try {
NBTTagCompound compound = NBTJsonUtil.LoadFile(file); NBTTagCompound compound = NBTJsonUtil.LoadFile(file);
if(compound.hasKey("PlayerName")){ if(compound.hasKey("PlayerName")){
map.put(compound.getString("PlayerName"), compound); map.put(compound.getString("PlayerName"), compound);
} }
} catch (Exception e) { } catch (Exception e) {
LogWriter.error("Error loading: " + file.getAbsolutePath(), e); LogWriter.error("Error loading: " + file.getAbsolutePath(), e);
} }
} }
return map; return map;
} }
public boolean hasMail(EntityPlayer player) { public boolean hasMail(EntityPlayer player) {
return getPlayerData(player).mailData.hasMail(); return getPlayerData(player).mailData.hasMail();
} }
} }
@@ -110,10 +110,16 @@ public class ScriptContainer {
} }
public void run(EnumScriptType type, Event event) { public void run(EnumScriptType type, Event event) {
if(!CustomNpcs.ScriptingEnabled)
return;
this.run((String)type.function, (Object)event); this.run((String)type.function, (Object)event);
} }
public void run(String type, Object event) { public void run(String type, Object event) {
if(!CustomNpcs.ScriptingEnabled)
return;
if (!this.errored && this.hasCode() && !this.unknownFunctions.contains(type)) { if (!this.errored && this.hasCode() && !this.unknownFunctions.contains(type)) {
this.setEngine(this.handler.getLanguage()); this.setEngine(this.handler.getLanguage());
if (this.engine != null) { if (this.engine != null) {
@@ -29,6 +29,7 @@ import net.minecraftforge.event.world.WorldEvent;
import noppes.npcs.CustomNpcs; import noppes.npcs.CustomNpcs;
import noppes.npcs.LogWriter; import noppes.npcs.LogWriter;
import noppes.npcs.controllers.data.ForgeDataScript; import noppes.npcs.controllers.data.ForgeDataScript;
import noppes.npcs.controllers.data.NPCDataScript;
import noppes.npcs.controllers.data.PlayerDataScript; import noppes.npcs.controllers.data.PlayerDataScript;
import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.scripted.entity.*; import noppes.npcs.scripted.entity.*;
@@ -56,6 +57,8 @@ public class ScriptController {
public ForgeDataScript forgeScripts = new ForgeDataScript(); public ForgeDataScript forgeScripts = new ForgeDataScript();
public NPCDataScript npcScripts = new NPCDataScript((EntityNPCInterface) null);
public ScriptController(){ public ScriptController(){
loaded = false; loaded = false;
Instance = this; Instance = this;
@@ -111,6 +114,10 @@ public class ScriptController {
return new File(dir, "player_scripts.json"); return new File(dir, "player_scripts.json");
} }
private File npcScriptsFile() {
return new File(dir, "npc_scripts.json");
}
public boolean loadPlayerScripts() { public boolean loadPlayerScripts() {
this.playerScripts.clear(); this.playerScripts.clear();
File file = this.playerScriptsFile(); File file = this.playerScriptsFile();
@@ -143,6 +150,37 @@ public class ScriptController {
} }
} }
public boolean loadNPCScripts() {
this.npcScripts.clear();
File file = this.npcScriptsFile();
try {
if(!file.exists()) {
return false;
} else {
this.npcScripts.readFromNBT(NBTJsonUtil.LoadFile(file));
shouldSave = false;
return true;
}
} catch (Exception var3) {
LogWriter.error("Error loading: " + file.getAbsolutePath(), var3);
return false;
}
}
public void setNPCScripts(NBTTagCompound compound) {
this.npcScripts.readFromNBT(compound);
File file = this.npcScriptsFile();
try {
NBTJsonUtil.SaveFile(file, compound);
} catch (IOException var4) {
var4.printStackTrace();
} catch (JsonException var5) {
var5.printStackTrace();
}
}
private void loadCategories(){ private void loadCategories(){
dir = new File(CustomNpcs.getWorldSaveDirectory(), "scripts"); dir = new File(CustomNpcs.getWorldSaveDirectory(), "scripts");
if(!dir.exists()) if(!dir.exists())
@@ -42,8 +42,8 @@ public class ServerCloneController implements ICloneHandler {
try { try {
File dir = new File(getDir(), ".."); File dir = new File(getDir(), "..");
File file = new File(dir, "clonednpcs.dat"); File file = new File(dir, "clonednpcs.dat");
System.out.println(file.getAbsolutePath()); // System.out.println(file.getAbsolutePath());
System.out.println(file.exists()); // System.out.println(file.exists());
if(file.exists()){ if(file.exists()){
Map<Integer, Map<String, NBTTagCompound>> clones = loadOldClones(file); Map<Integer, Map<String, NBTTagCompound>> clones = loadOldClones(file);
file.delete(); file.delete();
@@ -14,6 +14,7 @@ import java.util.Map.Entry;
import cpw.mods.fml.common.eventhandler.Event; import cpw.mods.fml.common.eventhandler.Event;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.CustomNpcs;
import noppes.npcs.EventHooks; import noppes.npcs.EventHooks;
import noppes.npcs.controllers.ScriptContainer; import noppes.npcs.controllers.ScriptContainer;
import noppes.npcs.NBTTags; import noppes.npcs.NBTTags;
@@ -84,7 +85,7 @@ public class ForgeDataScript implements IScriptHandler {
} }
public boolean getEnabled() { public boolean getEnabled() {
return this.enabled; return CustomNpcs.GlobalForgeScripts && this.enabled;
} }
public void setEnabled(boolean bo) { public void setEnabled(boolean bo) {
@@ -0,0 +1,297 @@
package noppes.npcs.controllers.data;
import com.google.common.base.Preconditions;
import cpw.mods.fml.common.eventhandler.Event;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.math.BlockPos;
import noppes.npcs.CustomNpcs;
import noppes.npcs.NBTTags;
import noppes.npcs.constants.EnumScriptType;
import noppes.npcs.controllers.IScriptHandler;
import noppes.npcs.controllers.ScriptContainer;
import noppes.npcs.controllers.ScriptController;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.scripted.interfaces.ICustomNpc;
import javax.annotation.CheckForNull;
import java.lang.reflect.Array;
import java.util.*;
public class NPCDataScript implements IScriptHandler {
public List<ScriptContainer> scripts = new ArrayList();
public String scriptLanguage = "ECMAScript";
private EntityNPCInterface npc;
private ICustomNpc npcAPI;
public long lastInited = -1L;
public boolean enabled = false;
private Map<Long, String> console = new TreeMap();
public List<Integer> errored = new ArrayList();
public NPCDataScript(EntityNPCInterface npc) {
if(npc != null) {
this.npc = npc;
}
}
public void clear() {
this.console = new TreeMap();
this.errored = new ArrayList();
this.scripts = new ArrayList();
}
public void readFromNBT(NBTTagCompound compound) {
this.scripts = NBTTags.GetScript(compound.getTagList("Scripts", 10), this);
this.scriptLanguage = compound.getString("ScriptLanguage");
this.enabled = compound.getBoolean("ScriptEnabled");
this.console = NBTTags.GetLongStringMap(compound.getTagList("ScriptConsole", 10));
}
public NBTTagCompound writeToNBT(NBTTagCompound compound) {
compound.setTag("Scripts", NBTTags.NBTScript(this.scripts));
compound.setString("ScriptLanguage", this.scriptLanguage);
compound.setBoolean("ScriptEnabled", this.enabled);
compound.setTag("ScriptConsole", NBTTags.NBTLongStringMap(this.console));
return compound;
}
public void callScript(EnumScriptType type, Event event) {
if (this.isEnabled()) {
ScriptContainer script;
if (ScriptController.Instance.lastLoaded > this.lastInited) {
this.lastInited = ScriptController.Instance.lastLoaded;
errored.clear();
}
for(int i = 0; i < ScriptController.Instance.npcScripts.scripts.size(); ++i) {
script = (ScriptContainer)ScriptController.Instance.npcScripts.scripts.get(i);
if (!errored.contains(i)) {
if(script == null || script.errored || !script.hasCode() || ScriptController.Instance.npcScripts.errored.contains(i))
return;
script.run(type, event);
if (script.errored) {
ScriptController.Instance.npcScripts.errored.add(i);
}
Iterator var8 = script.console.entrySet().iterator();
while(var8.hasNext()) {
Map.Entry<Long, String> entry = (Map.Entry)var8.next();
if (!ScriptController.Instance.npcScripts.console.containsKey(entry.getKey())) {
ScriptController.Instance.npcScripts.console.put(entry.getKey(), " tab " + (i + 1) + ":\n" + (String)entry.getValue());
}
}
script.console.clear();
}
}
}
}
public boolean isEnabled() {
return CustomNpcs.GlobalNPCScripts && ScriptController.Instance.npcScripts.enabled && ScriptController.HasStart && (this.npc == null || !this.npc.worldObj.isRemote);
}
public boolean isClient() {
return this.npc.isClientWorld();
}
public boolean getEnabled() {
return ScriptController.Instance.npcScripts.enabled;
}
public void setEnabled(boolean bo) {
ScriptController.Instance.npcScripts.enabled = bo;
this.enabled = bo;
}
public String getLanguage() {
return ScriptController.Instance.npcScripts.scriptLanguage;
}
public void setLanguage(String lang) {
this.scriptLanguage = lang;
}
public List<ScriptContainer> getScripts() {
return this.scripts;
}
public String noticeString() {
if(this.npc == null) {
return "Global script";
} else {
BlockPos pos = new BlockPos(this.npc);
return NPCDataScript.toStringHelper(this.npc).add("x", pos.getX()).add("y", pos.getY()).add("z", pos.getZ()).toString();
}
}
public ICustomNpc getNpc() {
if (this.npcAPI == null) {
this.npcAPI = (ICustomNpc) NpcAPI.Instance().getIEntity(this.npc);
}
return this.npcAPI;
}
public Map<Long, String> getConsoleText() {
return this.console;
}
public void clearConsole() {
this.console.clear();
}
public static final class ToStringHelper {
private final String className;
private final NPCDataScript.ToStringHelper.ValueHolder holderHead;
private NPCDataScript.ToStringHelper.ValueHolder holderTail;
private boolean omitNullValues;
private boolean omitEmptyValues;
private ToStringHelper(String className) {
this.holderHead = new NPCDataScript.ToStringHelper.ValueHolder();
this.holderTail = this.holderHead;
this.omitNullValues = false;
this.omitEmptyValues = false;
this.className = (String) Preconditions.checkNotNull(className);
}
public NPCDataScript.ToStringHelper omitNullValues() {
this.omitNullValues = true;
return this;
}
public NPCDataScript.ToStringHelper add(String name, @CheckForNull Object value) {
return this.addHolder(name, value);
}
public NPCDataScript.ToStringHelper add(String name, boolean value) {
return this.addUnconditionalHolder(name, String.valueOf(value));
}
public NPCDataScript.ToStringHelper add(String name, char value) {
return this.addUnconditionalHolder(name, String.valueOf(value));
}
public NPCDataScript.ToStringHelper add(String name, double value) {
return this.addUnconditionalHolder(name, String.valueOf(value));
}
public NPCDataScript.ToStringHelper add(String name, float value) {
return this.addUnconditionalHolder(name, String.valueOf(value));
}
public NPCDataScript.ToStringHelper add(String name, int value) {
return this.addUnconditionalHolder(name, String.valueOf(value));
}
public NPCDataScript.ToStringHelper add(String name, long value) {
return this.addUnconditionalHolder(name, String.valueOf(value));
}
public NPCDataScript.ToStringHelper addValue(@CheckForNull Object value) {
return this.addHolder(value);
}
public NPCDataScript.ToStringHelper addValue(boolean value) {
return this.addUnconditionalHolder(String.valueOf(value));
}
public NPCDataScript.ToStringHelper addValue(char value) {
return this.addUnconditionalHolder(String.valueOf(value));
}
public NPCDataScript.ToStringHelper addValue(double value) {
return this.addUnconditionalHolder(String.valueOf(value));
}
public NPCDataScript.ToStringHelper addValue(float value) {
return this.addUnconditionalHolder(String.valueOf(value));
}
public NPCDataScript.ToStringHelper addValue(int value) {
return this.addUnconditionalHolder(String.valueOf(value));
}
public NPCDataScript.ToStringHelper addValue(long value) {
return this.addUnconditionalHolder(String.valueOf(value));
}
private static boolean isEmpty(Object value) {
if (value instanceof CharSequence) {
return ((CharSequence)value).length() == 0;
} else if (value instanceof Collection) {
return ((Collection)value).isEmpty();
} else if (value instanceof Map) {
return ((Map)value).isEmpty();
} else if (value instanceof Optional) {
return !((Optional)value).isPresent();
} else if (value instanceof OptionalInt) {
return !((OptionalInt)value).isPresent();
} else if (value instanceof OptionalLong) {
return !((OptionalLong)value).isPresent();
} else if (value instanceof OptionalDouble) {
return !((OptionalDouble)value).isPresent();
} else if (value instanceof com.google.common.base.Optional) {
return !((com.google.common.base.Optional)value).isPresent();
} else if (value.getClass().isArray()) {
return Array.getLength(value) == 0;
} else {
return false;
}
}
public String toString() {
boolean omitNullValuesSnapshot = this.omitNullValues;
boolean omitEmptyValuesSnapshot = this.omitEmptyValues;
String nextSeparator = "";
StringBuilder builder = (new StringBuilder(32)).append(this.className).append('{');
for(NPCDataScript.ToStringHelper.ValueHolder valueHolder = this.holderHead.next; valueHolder != null; valueHolder = valueHolder.next) {
Object value = valueHolder.value;
if (!(valueHolder instanceof NPCDataScript.ToStringHelper.UnconditionalValueHolder)) {
if (value == null) {
if (omitNullValuesSnapshot) {
continue;
}
} else if (omitEmptyValuesSnapshot && isEmpty(value)) {
continue;
}
}
builder.append(nextSeparator);
nextSeparator = ", ";
if (valueHolder.name != null) {
builder.append(valueHolder.name).append('=');
}
if (value != null && value.getClass().isArray()) {
Object[] objectArray = new Object[]{value};
String arrayString = Arrays.deepToString(objectArray);
builder.append(arrayString, 1, arrayString.length() - 1);
} else {
builder.append(value);
}
}
return builder.append('}').toString();
}
private NPCDataScript.ToStringHelper.ValueHolder addHolder() {
NPCDataScript.ToStringHelper.ValueHolder valueHolder = new NPCDataScript.ToStringHelper.ValueHolder();
this.holderTail = this.holderTail.next = valueHolder;
return valueHolder;
}
private NPCDataScript.ToStringHelper addHolder(@CheckForNull Object value) {
NPCDataScript.ToStringHelper.ValueHolder valueHolder = this.addHolder();
valueHolder.value = value;
return this;
}
private NPCDataScript.ToStringHelper addHolder(String name, @CheckForNull Object value) {
NPCDataScript.ToStringHelper.ValueHolder valueHolder = this.addHolder();
valueHolder.value = value;
valueHolder.name = (String)Preconditions.checkNotNull(name);
return this;
}
private NPCDataScript.ToStringHelper.UnconditionalValueHolder addUnconditionalHolder() {
NPCDataScript.ToStringHelper.UnconditionalValueHolder valueHolder = new NPCDataScript.ToStringHelper.UnconditionalValueHolder();
this.holderTail = this.holderTail.next = valueHolder;
return valueHolder;
}
private NPCDataScript.ToStringHelper addUnconditionalHolder(Object value) {
NPCDataScript.ToStringHelper.UnconditionalValueHolder valueHolder = this.addUnconditionalHolder();
valueHolder.value = value;
return this;
}
private NPCDataScript.ToStringHelper addUnconditionalHolder(String name, Object value) {
NPCDataScript.ToStringHelper.UnconditionalValueHolder valueHolder = this.addUnconditionalHolder();
valueHolder.value = value;
valueHolder.name = (String)Preconditions.checkNotNull(name);
return this;
}
private static final class UnconditionalValueHolder extends NPCDataScript.ToStringHelper.ValueHolder {
private UnconditionalValueHolder() {
super();
}
}
private static class ValueHolder {
@CheckForNull
String name;
@CheckForNull
Object value;
@CheckForNull
NPCDataScript.ToStringHelper.ValueHolder next;
private ValueHolder() {
}
}
}
public static NPCDataScript.ToStringHelper toStringHelper(Object self) {
return new NPCDataScript.ToStringHelper(self.getClass().getSimpleName());
}
}
@@ -13,6 +13,7 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import cpw.mods.fml.common.eventhandler.Event; import cpw.mods.fml.common.eventhandler.Event;
import net.minecraft.world.WorldServer; import net.minecraft.world.WorldServer;
import noppes.npcs.CustomNpcs;
import noppes.npcs.EventHooks; import noppes.npcs.EventHooks;
import noppes.npcs.controllers.ScriptContainer; import noppes.npcs.controllers.ScriptContainer;
import noppes.npcs.NBTTags; import noppes.npcs.NBTTags;
@@ -106,7 +107,7 @@ public class PlayerDataScript implements IScriptHandler {
} }
public boolean isEnabled() { public boolean isEnabled() {
return ScriptController.Instance.playerScripts.enabled && ScriptController.HasStart && (this.player == null || !this.player.worldObj.isRemote); return CustomNpcs.GlobalPlayerScripts && ScriptController.Instance.playerScripts.enabled && ScriptController.HasStart && (this.player == null || !this.player.worldObj.isRemote);
} }
public boolean isClient() { public boolean isClient() {
return this.player.isClientWorld(); return this.player.isClientWorld();
@@ -10,9 +10,6 @@ import noppes.npcs.ModelData;
import noppes.npcs.ModelPartData; import noppes.npcs.ModelPartData;
import noppes.npcs.client.EntityUtil; import noppes.npcs.client.EntityUtil;
// FLY CHANGE
// extends EntityNPCInterface
// extends EntityNPCFlying
public class EntityCustomNpc extends EntityNPCFlying { public class EntityCustomNpc extends EntityNPCFlying {
public ModelData modelData = new ModelData(); public ModelData modelData = new ModelData();
@@ -1,10 +1,6 @@
package noppes.npcs.entity; package noppes.npcs.entity;
import net.minecraft.entity.Entity;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityAISwimming;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World; import net.minecraft.world.World;
public abstract class EntityNPCFlying extends EntityNPCInterface { public abstract class EntityNPCFlying extends EntityNPCInterface {
@@ -30,17 +26,21 @@ public abstract class EntityNPCFlying extends EntityNPCInterface {
super.updateFallState(p_180433_1_, p_180433_3_); super.updateFallState(p_180433_1_, p_180433_3_);
} }
public void onLivingUpdate() @Override
public boolean isOnLadder(){
return false;
}
public void moveEntityWithHeading(float p_70612_1_, float p_70612_2_)
{ {
super.onLivingUpdate(); if(!this.canFly() || this.hurtTime != 0) {
if(!canFly()){ super.moveEntityWithHeading(p_70612_1_, p_70612_2_);
return; return;
} }
int blockY = (int) this.posY;
double heightOffGround = 0; double heightOffGround = 0;
if(this.ai.hasFlyLimit) { if(this.ai.hasFlyLimit) {
for (blockY = (int) this.posY; blockY > 0; blockY--) { for (int blockY = (int) this.posY; blockY > 0; blockY--) {
heightOffGround = this.posY - blockY; heightOffGround = this.posY - blockY;
if (this.worldObj.getBlock((int) this.posX, blockY, (int) this.posZ) != Blocks.air || heightOffGround > this.ai.flyHeightLimit){ if (this.worldObj.getBlock((int) this.posX, blockY, (int) this.posZ) != Blocks.air || heightOffGround > this.ai.flyHeightLimit){
break; break;
@@ -48,24 +48,19 @@ public abstract class EntityNPCFlying extends EntityNPCInterface {
} }
} }
if (!this.onGround && !this.velocityChanged && this.motionY < 0 && this.hurtTime == 0) if(heightOffGround > this.ai.flyHeightLimit && this.ai.hasFlyLimit){
{ super.moveEntityWithHeading(p_70612_1_,p_70612_2_);
if(heightOffGround >= this.ai.flyHeightLimit && this.ai.hasFlyLimit){ return;
this.motionY *= 0.8D;
this.velocityChanged = true;
} else {
this.motionY *= this.ai.flyGravity;
this.velocityChanged = true;
}
} }
double d3 = this.motionY;
super.moveEntityWithHeading(p_70612_1_, p_70612_2_);
this.motionY = d3;
this.fallDistance = 0.0F;
this.velocityChanged = true;
if(this.getNavigator().noPath())
this.motionY = 0.0D;
} }
@Override
public boolean isOnLadder(){
return false;
}
} }
@@ -40,20 +40,7 @@ import net.minecraft.world.WorldServer;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.util.FakePlayer; import net.minecraftforge.common.util.FakePlayer;
import net.minecraftforge.event.ServerChatEvent; import net.minecraftforge.event.ServerChatEvent;
import noppes.npcs.CustomItems; import noppes.npcs.*;
import noppes.npcs.CustomNpcs;
import noppes.npcs.DataAI;
import noppes.npcs.DataAdvanced;
import noppes.npcs.DataDisplay;
import noppes.npcs.DataInventory;
import noppes.npcs.DataScript;
import noppes.npcs.DataStats;
import noppes.npcs.IChatMessages;
import noppes.npcs.NBTTags;
import noppes.npcs.NoppesUtilServer;
import noppes.npcs.NpcDamageSource;
import noppes.npcs.Server;
import noppes.npcs.VersionCompatibility;
import noppes.npcs.ai.*; import noppes.npcs.ai.*;
import noppes.npcs.ai.EntityAIMoveIndoors; import noppes.npcs.ai.EntityAIMoveIndoors;
import noppes.npcs.ai.EntityAIPanic; import noppes.npcs.ai.EntityAIPanic;
@@ -153,7 +140,6 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
public boolean updateClient = false; public boolean updateClient = false;
public boolean updateAI = false; public boolean updateAI = false;
// Fly Change
public FlyingMoveHelper flyMoveHelper = new FlyingMoveHelper(this); public FlyingMoveHelper flyMoveHelper = new FlyingMoveHelper(this);
public PathNavigate flyNavigator = new PathNavigateFlying(this, worldObj); public PathNavigate flyNavigator = new PathNavigateFlying(this, worldObj);
@@ -233,8 +219,9 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
@Override @Override
public void onUpdate(){ public void onUpdate(){
super.onUpdate(); super.onUpdate();
if(this.ticksExisted % 10 == 0) if(this.ticksExisted % 10 == 0) {
script.callScript(EnumScriptType.TICK); EventHooks.onNPCUpdate(this);
}
this.timers.update(); this.timers.update();
} }
@@ -243,6 +230,11 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
script.setWorld(world); script.setWorld(world);
} }
public int getMaxSafePointTries()
{
return 5;
}
@Override @Override
public boolean attackEntityAsMob(Entity par1Entity){ public boolean attackEntityAsMob(Entity par1Entity){
float f = stats.getAttackStrength(); float f = stats.getAttackStrength();
@@ -252,7 +244,7 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
} }
if(par1Entity instanceof EntityLivingBase){ if(par1Entity instanceof EntityLivingBase){
ScriptEventAttack event = new ScriptEventAttack(f, (EntityLivingBase)par1Entity, false); ScriptEventAttack event = new ScriptEventAttack(f, (EntityLivingBase)par1Entity, false);
if(script.callScript(EnumScriptType.ATTACK, "event", event, "target", par1Entity)) if(EventHooks.onNPCMeleeAttack(this, f, (EntityLivingBase)par1Entity))
return false; return false;
f = event.getDamage(); f = event.getDamage();
} }
@@ -393,8 +385,8 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
return true; return true;
} }
} }
if(script.callScript(EnumScriptType.INTERACT, "player", player) || isAttacking() || isKilled() || faction.isAggressiveToPlayer(player)) if(EventHooks.onNPCInteract(this, player) || isAttacking() || isKilled() || faction.isAggressiveToPlayer(player))
return false; return false;
addInteract(player); addInteract(player);
@@ -406,7 +398,7 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
Server.sendData((EntityPlayerMP)player, EnumPacketClient.QUEST_COMPLETION, data.quest.writeToNBT(new NBTTagCompound())); Server.sendData((EntityPlayerMP)player, EnumPacketClient.QUEST_COMPLETION, data.quest.writeToNBT(new NBTTagCompound()));
} }
else if (dialog != null){ else if (dialog != null){
NoppesUtilServer.openDialog(player, this, dialog); NoppesUtilServer.openDialog(player, this, dialog, 0);
} }
else if(roleInterface != null) else if(roleInterface != null)
roleInterface.interact(player); roleInterface.interact(player);
@@ -510,7 +502,7 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
else if (attackingEntity instanceof EntityPlayer && faction.isFriendlyToPlayer((EntityPlayer) attackingEntity)) else if (attackingEntity instanceof EntityPlayer && faction.isFriendlyToPlayer((EntityPlayer) attackingEntity))
return false; return false;
ScriptEventDamaged result = new ScriptEventDamaged(i, attackingEntity, damagesource); ScriptEventDamaged result = new ScriptEventDamaged(i, attackingEntity, damagesource);
if(script.callScript(EnumScriptType.DAMAGED, "event", result) || isKilled()) if(EventHooks.onNPCDamaged(this, attackingEntity, i, damagesource, result) || isKilled())
return false; return false;
i = result.getDamage(); i = result.getDamage();
@@ -560,7 +552,7 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
return; return;
if(getAttackTarget() != entity && entity != null){ if(getAttackTarget() != entity && entity != null){
ScriptEventTarget event = new ScriptEventTarget(entity); ScriptEventTarget event = new ScriptEventTarget(entity);
if(script.callScript(EnumScriptType.TARGET, "event", event)) if(EventHooks.onNPCTarget(this,entity))
return; return;
if(event.getTarget() == null) if(event.getTarget() == null)
@@ -585,7 +577,7 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
return; return;
} }
ScriptEventAttack event = new ScriptEventAttack(stats.pDamage, entity, true); ScriptEventAttack event = new ScriptEventAttack(stats.pDamage, entity, true);
if(script.callScript(EnumScriptType.ATTACK, "event", event, "target", entity)) if(EventHooks.onNPCRangedAttack(this, f, (EntityLivingBase)entity))
return; return;
for(int i = 0; i < this.stats.shotCount; i++) for(int i = 0; i < this.stats.shotCount; i++)
{ {
@@ -914,7 +906,7 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
} }
public void saySurrounding(Line line) { public void saySurrounding(Line line) {
if (line == null || line.text == null) if (line == null || line.text == null || getFakePlayer() == null)
return; return;
ServerChatEvent event = new ServerChatEvent(getFakePlayer(), line.text, new ChatComponentTranslation(line.text.replace("%", "%%"))); ServerChatEvent event = new ServerChatEvent(getFakePlayer(), line.text, new ChatComponentTranslation(line.text.replace("%", "%%")));
if (MinecraftForge.EVENT_BUS.post(event) || event.component == null){ if (MinecraftForge.EVENT_BUS.post(event) || event.component == null){
@@ -1067,8 +1059,8 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
if(jobInterface != null) if(jobInterface != null)
jobInterface.reset(); jobInterface.reset();
script.callScript(EnumScriptType.INIT); EventHooks.onNPCInit(this);
} }
public void onCollide() { public void onCollide() {
@@ -1090,8 +1082,9 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
for (int i = 0; i < list.size(); ++i){ for (int i = 0; i < list.size(); ++i){
Entity entity = (Entity)list.get(i); Entity entity = (Entity)list.get(i);
if (entity.isEntityAlive()) if (entity.isEntityAlive()) {
script.callScript(EnumScriptType.COLLIDE, "entity", entity); EventHooks.onNPCCollide(this,entity);
}
} }
} }
@@ -1218,7 +1211,7 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
attackingEntity = ((EntityThrowable) entity).getThrower(); attackingEntity = ((EntityThrowable) entity).getThrower();
ScriptEventKilled result = new ScriptEventKilled(attackingEntity, damagesource); ScriptEventKilled result = new ScriptEventKilled(attackingEntity, damagesource);
if(script.callScript(EnumScriptType.KILLED, "event", result)) if(EventHooks.onNPCKilled(this,damagesource,attackingEntity,result))
return; return;
if(!isRemote()){ if(!isRemote()){
if(this.recentlyHit > 0) if(this.recentlyHit > 0)
@@ -1293,7 +1286,6 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
@Override @Override
public IIcon getItemIcon(ItemStack par1ItemStack, int par2){ public IIcon getItemIcon(ItemStack par1ItemStack, int par2){
// Change Here
if (par1ItemStack.getItem() instanceof ItemBow){ if (par1ItemStack.getItem() instanceof ItemBow){
return par1ItemStack.getItem().getIcon(par1ItemStack, par2); return par1ItemStack.getItem().getIcon(par1ItemStack, par2);
} }
@@ -1812,4 +1804,6 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
{ {
this.display.modelType = val; this.display.modelType = val;
} }
protected void updateLeashedState(){}
} }
@@ -55,6 +55,42 @@ public class DataTimers implements ITimers {
} }
} }
public int ticks(int id){
return this.timers.get(Integer.valueOf(id)).ticks;
}
public void setTicks(int id, int ticks){
DataTimers.Timer timer = (DataTimers.Timer)this.timers.get(Integer.valueOf(id));
if(ticks < 0)
ticks = 0;
if(ticks > timer.timerTicks)
ticks = timer.timerTicks;
timer.ticks = ticks;
}
public int maxTicks(int id){
return this.timers.get(Integer.valueOf(id)).timerTicks;
}
public void setMaxTicks(int id, int maxTicks){
DataTimers.Timer timer = (DataTimers.Timer)this.timers.get(Integer.valueOf(id));
if(maxTicks < 0)
maxTicks = 0;
if(timer.ticks > maxTicks)
timer.ticks = maxTicks;
timer.timerTicks = maxTicks;
}
public boolean repeats(int id){
return this.timers.get(Integer.valueOf(id)).repeat;
}
public void setRepeats(int id, boolean repeat){
this.timers.get(Integer.valueOf(id)).repeat = repeat;
}
public void writeToNBT(NBTTagCompound compound) { public void writeToNBT(NBTTagCompound compound) {
NBTTagList list = new NBTTagList(); NBTTagList list = new NBTTagList();
Iterator var3 = this.timers.values().iterator(); Iterator var3 = this.timers.values().iterator();
@@ -20,12 +20,14 @@ import noppes.npcs.scripted.handler.data.IQuestObjective;
public class QuestKill extends QuestInterface implements IQuestKill { public class QuestKill extends QuestInterface implements IQuestKill {
public HashMap<String,Integer> targets = new HashMap<String,Integer>(); public HashMap<String,Integer> targets = new HashMap<String,Integer>();
public int targetType = 0; public int targetType = 0;
public String customTargetType = "noppes.npcs.entity.EntityCustomNpc";
@Override @Override
public void writeEntityToNBT(NBTTagCompound compound) { public void writeEntityToNBT(NBTTagCompound compound) {
compound.setTag("QuestKills", NBTTags.nbtStringIntegerMap(targets)); compound.setTag("QuestKills", NBTTags.nbtStringIntegerMap(targets));
//compound.setTag("QuestDialogs", NBTTags.nbtStringIntegerMap(targets)); //compound.setTag("QuestDialogs", NBTTags.nbtStringIntegerMap(targets));
compound.setInteger("TargetType",targetType); compound.setInteger("TargetType",targetType);
compound.setString("CustomTargetType",customTargetType);
} }
@Override @Override
@@ -40,6 +42,7 @@ public class QuestKill extends QuestInterface implements IQuestKill {
//targets = NBTTags.getStringIntegerMap(compound.getTagList("QuestDialogs", 10)); //targets = NBTTags.getStringIntegerMap(compound.getTagList("QuestDialogs", 10));
targetType = compound.getInteger("TargetType"); targetType = compound.getInteger("TargetType");
customTargetType = compound.getString("CustomTargetType");
} }
@Override @Override
@@ -48,7 +51,20 @@ public class QuestKill extends QuestInterface implements IQuestKill {
QuestData data = playerdata.activeQuests.get(questId); QuestData data = playerdata.activeQuests.get(questId);
if(data == null) if(data == null)
return false; return false;
HashMap<String,Integer> killed = getKilled(data); HashMap<String,Integer> killed = getKilled(data);
int completed = 0;
for(String entityName : targets.keySet()){
int amount = 0;
if(killed.containsKey(entityName))
amount = killed.get(entityName);
if(amount >= targets.get(entityName)){
completed++;
}
}
if(completed >= targets.keySet().size())
return true;
if(killed.size() != targets.size()) if(killed.size() != targets.size())
return false; return false;
for(String entity : killed.keySet()){ for(String entity : killed.keySet()){
@@ -106,8 +122,8 @@ public class QuestKill extends QuestInterface implements IQuestKill {
public void setTargetType(int type) { public void setTargetType(int type) {
if(type < 0) if(type < 0)
type = 0; type = 0;
if(type > 1) if(type > 2)
type = 1; type = 2;
this.targetType = type; this.targetType = type;
} }
@@ -18,17 +18,35 @@ public class ScriptEntityParticle {
private float alpha1 = 1.0f,alpha2 = 1.0f,alphaRate = 0.0f; private float alpha1 = 1.0f,alpha2 = 1.0f,alphaRate = 0.0f;
private int scaleRateStart = 0, alphaRateStart = 0; private int scaleRateStart = 0, alphaRateStart = 0;
public float rotationX1 = 0;
public float rotationX2 = 0;
public float rotationXRate = 0.0F;
public int rotationXRateStart = 0;
public float rotationY1 = 0;
public float rotationY2 = 0;
public float rotationYRate = 0.0F;
public int rotationYRateStart = 0;
public float rotationZ1 = 0;
public float rotationZ2 = 0;
public float rotationZRate = 0.0F;
public int rotationZRateStart = 0;
public ScriptEntityParticle(String directory){ public ScriptEntityParticle(String directory){
this.directory = directory; this.directory = directory;
} }
public void spawnOnEntity(ScriptEntity entity){ public void spawnOnEntity(ScriptEntity entity){
int entityID = entity.getMCEntity().getEntityId(); int entityID = entity.getMCEntity().getEntityId();
NoppesUtilServer.spawnScriptedParticle(entity.getMCEntity(), directory, HEXcolor, amount, maxAge, NoppesUtilServer.spawnScriptedParticle(directory, HEXcolor, amount, maxAge,
x, y, z, x, y, z,
motionX, motionY, motionZ, gravity, motionX, motionY, motionZ, gravity,
scale1, scale2, scaleRate, scaleRateStart, scale1, scale2, scaleRate, scaleRateStart,
alpha1, alpha2, alphaRate, alphaRateStart, alpha1, alpha2, alphaRate, alphaRateStart,
rotationX1, rotationX2, rotationXRate, rotationXRateStart,
rotationY1, rotationY2, rotationYRate, rotationYRateStart,
rotationZ1, rotationZ2, rotationZRate, rotationZRateStart,
entityID entityID
); );
} }
@@ -52,11 +70,9 @@ public class ScriptEntityParticle {
public double getX() { public double getX() {
return x; return x;
} }
public double getY() { public double getY() {
return y; return y;
} }
public double getZ() { public double getZ() {
return z; return z;
} }
@@ -64,50 +80,56 @@ public class ScriptEntityParticle {
public double getMotionX() { public double getMotionX() {
return motionX; return motionX;
} }
public double getMotionY() { public double getMotionY() {
return motionY; return motionY;
} }
public double getMotionZ() { public double getMotionZ() {
return motionZ; return motionZ;
} }
public float getGravity() { public float getGravity() {
return gravity; return gravity;
} }
public float getScale1() {
return scale1;
}
public float getScale2() {
return scale2;
}
public float getScaleRate() {
return scaleRate;
}
public float getAlpha1() { public float getAlpha1() {
return alpha1; return alpha1;
} }
public float getAlpha2() { public float getAlpha2() {
return alpha2; return alpha2;
} }
public float getAlphaRate() { public float getAlphaRate() {
return alphaRate; return alphaRate;
} }
public int getAlphaRateStart() {
return alphaRateStart;
}
public float getScale1() {
return scale1;
}
public float getScale2() {
return scale2;
}
public float getScaleRate() {
return scaleRate;
}
public int getScaleRateStart() { public int getScaleRateStart() {
return scaleRateStart; return scaleRateStart;
} }
public int getAlphaRateStart() { public float getRotationX1() {return rotationX1;}
return alphaRateStart; public float getRotationX2() {return rotationX2;}
} public float getRotationXRate() {return rotationXRate;}
public int getRotationXRateStart() {return rotationXRateStart;}
public float getRotationY1() {return rotationY1;}
public float getRotationY2() {return rotationY2;}
public float getRotationYRate() {return rotationYRate;}
public int getRotationYRateStart() {return rotationYRateStart;}
public float getRotationZ1() {return rotationZ1;}
public float getRotationZ2() {return rotationZ2;}
public float getRotationZRate() {return rotationZRate;}
public int getRotationZRateStart() {return rotationZRateStart;}
public void setDirectory(String directory) { public void setDirectory(String directory) {
this.directory = directory; this.directory = directory;
@@ -130,15 +152,12 @@ public class ScriptEntityParticle {
this.y = y; this.y = y;
this.z = z; this.z = z;
} }
public void setX(double x) { public void setX(double x) {
this.x = x; this.x = x;
} }
public void setY(double y) { public void setY(double y) {
this.y = y; this.y = y;
} }
public void setZ(double z) { public void setZ(double z) {
this.z = z; this.z = z;
} }
@@ -149,19 +168,15 @@ public class ScriptEntityParticle {
this.motionZ = motionZ; this.motionZ = motionZ;
this.gravity = gravity; this.gravity = gravity;
} }
public void setMotionX(double motionX) { public void setMotionX(double motionX) {
this.motionX = motionX; this.motionX = motionX;
} }
public void setMotionY(double motionY) { public void setMotionY(double motionY) {
this.motionY = motionY; this.motionY = motionY;
} }
public void setMotionZ(double motionZ) { public void setMotionZ(double motionZ) {
this.motionZ = motionZ; this.motionZ = motionZ;
} }
public void setGravity(float gravity) { public void setGravity(float gravity) {
this.gravity = gravity; this.gravity = gravity;
} }
@@ -172,19 +187,15 @@ public class ScriptEntityParticle {
this.scaleRate = scaleRate; this.scaleRate = scaleRate;
this.scaleRateStart = scaleRateStart; this.scaleRateStart = scaleRateStart;
} }
public void setScale1(float scale1) { public void setScale1(float scale1) {
this.scale1 = scale1; this.scale1 = scale1;
} }
public void setScale2(float scale2) { public void setScale2(float scale2) {
this.scale2 = scale2; this.scale2 = scale2;
} }
public void setScaleRate(float scaleRate) { public void setScaleRate(float scaleRate) {
this.scaleRate = scaleRate; this.scaleRate = scaleRate;
} }
public void setScaleRateStart(int scaleRateStart) { public void setScaleRateStart(int scaleRateStart) {
this.scaleRateStart = scaleRateStart; this.scaleRateStart = scaleRateStart;
} }
@@ -195,20 +206,49 @@ public class ScriptEntityParticle {
this.alphaRate = alphaRate; this.alphaRate = alphaRate;
this.alphaRateStart = alphaRateStart; this.alphaRateStart = alphaRateStart;
} }
public void setAlpha1(float alpha1) { public void setAlpha1(float alpha1) {
this.alpha1 = alpha1; this.alpha1 = alpha1;
} }
public void setAlpha2(float alpha2) { public void setAlpha2(float alpha2) {
this.alpha2 = alpha2; this.alpha2 = alpha2;
} }
public void setAlphaRate(float alphaRate) { public void setAlphaRate(float alphaRate) {
this.alphaRate = alphaRate; this.alphaRate = alphaRate;
} }
public void setAlphaRateStart(int alphaRateStart) { public void setAlphaRateStart(int alphaRateStart) {
this.alphaRateStart = alphaRateStart; this.alphaRateStart = alphaRateStart;
} }
public void setRotationX(float rotationX1, float rotationX2, float rotationXRate, int rotationXRateStart){
this.rotationX1 = rotationX1;
this.rotationX2 = rotationX2;
this.rotationXRate = rotationXRate;
this.rotationXRateStart = rotationXRateStart;
}
public void setRotationX1(float rotationX1) {this.rotationX1 = rotationX1;}
public void setRotationX2(float rotationX2) {this.rotationX2 = rotationX2;}
public void setRotationXRate(float rotationXRate) {this.rotationXRate = rotationXRate;}
public void setRotationXRateStart(int rotationXRateStart) {this.rotationXRateStart = rotationXRateStart;}
public void setRotationY(float rotationY1, float rotationY2, float rotationYRate, int rotationYRateStart){
this.rotationY1 = rotationY1;
this.rotationY2 = rotationY2;
this.rotationYRate = rotationYRate;
this.rotationYRateStart = rotationYRateStart;
}
public void setRotationY1(float rotationY1) {this.rotationY1 = rotationY1;}
public void setRotationY2(float rotationY2) {this.rotationY2 = rotationY2;}
public void setRotationYRate(float rotationYRate) {this.rotationYRate = rotationYRate;}
public void setRotationYRateStart(int rotationYRateStart) {this.rotationYRateStart = rotationYRateStart;}
public void setRotationZ(float rotationZ1, float rotationZ2, float rotationZRate, int rotationZRateStart){
this.rotationZ1 = rotationZ1;
this.rotationZ2 = rotationZ2;
this.rotationZRate = rotationZRate;
this.rotationZRateStart = rotationZRateStart;
}
public void setRotationZ1(float rotationZ1) {this.rotationZ1 = rotationZ1;}
public void setRotationZ2(float rotationZ2) {this.rotationZ2 = rotationZ2;}
public void setRotationZRate(float rotationZRate) {this.rotationZRate = rotationZRate;}
public void setRotationZRateStart(int rotationZRateStart) {this.rotationZRateStart = rotationZRateStart;}
} }
@@ -224,23 +224,33 @@ public class ScriptItemStack implements IItemStack {
} }
public String[] getLore() { public String[] getLore() {
NBTTagCompound compound = this.item.getTagCompound().getCompoundTag("display"); if (this.item.getTagCompound() != null) {
if (compound != null && compound.func_150299_b("Lore") == 9) { NBTTagCompound compound = this.item.getTagCompound().getCompoundTag("display");
NBTTagList nbttaglist = compound.getTagList("Lore", 8); if(compound != null && compound.func_150299_b("Lore") == 9) {
if (nbttaglist.tagCount() < 1) { NBTTagList nbttaglist = compound.getTagList("Lore", 8);
return new String[0]; if (nbttaglist.tagCount() > 0) {
} else { List<String> lore = new ArrayList();
List<String> lore = new ArrayList();
for(int i = 0; i < nbttaglist.tagCount(); ++i) { for (int i = 0; i < nbttaglist.tagCount(); ++i) {
lore.add(nbttaglist.getStringTagAt(i)); lore.add(nbttaglist.getStringTagAt(i));
}
return (String[]) ((String[]) lore.toArray(new String[lore.size()]));
} }
return (String[])((String[])lore.toArray(new String[lore.size()]));
} }
} else {
return new String[0];
} }
return new String[0];
}
public boolean hasLore() {
if (this.item.getTagCompound() != null) {
NBTTagCompound compound = this.item.getTagCompound().getCompoundTag("display");
if (compound != null && compound.func_150299_b("Lore") == 9) {
NBTTagList nbttaglist = compound.getTagList("Lore", 8);
return nbttaglist.tagCount() > 0;
}
}
return false;
} }
public void setLore(String[] lore) { public void setLore(String[] lore) {
@@ -445,6 +445,26 @@ public class ScriptDBCPlayer<T extends EntityPlayerMP> extends ScriptPlayer<T>{
} }
public void setForm(byte form){ public void setForm(byte form){
if(form < 0)
return;
switch(getRace()){
case 0:
case 3:
if(form > 3)
return;
break;
case 1:
case 2:
if(form > 15)
return;
break;
case 4:
if(form > 7)
return;
break;
}
player.getEntityData().getCompoundTag("PlayerPersisted").setByte("jrmcState",form); player.getEntityData().getCompoundTag("PlayerPersisted").setByte("jrmcState",form);
} }
public byte getForm(){ public byte getForm(){
@@ -67,14 +67,101 @@ public class ScriptEntity<T extends Entity> implements IEntity {
double x, double y, double z, double x, double y, double z,
double motionX, double motionY, double motionZ, float gravity, double motionX, double motionY, double motionZ, float gravity,
float scale1, float scale2, float scaleRate, int scaleRateStart, float scale1, float scale2, float scaleRate, int scaleRateStart,
float alpha1, float alpha2, float alphaRate, int alphaRateStart float alpha1, float alpha2, float alphaRate, int alphaRateStart,
float rotation1, float rotation2, float rotationRate, int rotationRateStart,
float rotationX1, float rotationX2, float rotationXRate, int rotationXRateStart,
float rotationY1, float rotationY2, float rotationYRate, int rotationYRateStart,
float rotationZ1, float rotationZ2, float rotationZRate, int rotationZRateStart
) { ) {
int entityID = entity.getEntityId(); int entityID = entity.getEntityId();
NoppesUtilServer.spawnScriptedParticle(entity, directory, HEXcolor, amount, maxAge, NoppesUtilServer.spawnScriptedParticle(directory, HEXcolor, amount, maxAge,
x, y, z, x, y, z,
motionX, motionY, motionZ, gravity, motionX, motionY, motionZ, gravity,
scale1, scale2, scaleRate, scaleRateStart, scale1, scale2, scaleRate, scaleRateStart,
alpha1, alpha2, alphaRate, alphaRateStart, alpha1, alpha2, alphaRate, alphaRateStart,
rotationX1, rotationX2, rotationXRate, rotationXRateStart,
rotationY1, rotationY2, rotationYRate, rotationYRateStart,
rotationZ1, rotationZ2, rotationZRate, rotationZRateStart,
entityID
);
}
public void spawnParticle(String directory, int HEXcolor, int amount, int maxAge,
double x, double y, double z,
double motionX, double motionY, double motionZ, float gravity,
float scale1, float scale2, float scaleRate, int scaleRateStart,
float alpha1, float alpha2, float alphaRate, int alphaRateStart
) {
int entityID = entity.getEntityId();
NoppesUtilServer.spawnScriptedParticle(directory, HEXcolor, amount, maxAge,
x, y, z,
motionX, motionY, motionZ, gravity,
scale1, scale2, scaleRate, scaleRateStart,
alpha1, alpha2, alphaRate, alphaRateStart,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
entityID
);
}
public void spawnParticle(String directory, int HEXcolor, int amount, int maxAge,
double x, double y, double z,
double motionX, double motionY, double motionZ, float gravity,
float scale1, float scale2, float scaleRate, int scaleRateStart
) {
int entityID = entity.getEntityId();
NoppesUtilServer.spawnScriptedParticle(directory, HEXcolor, amount, maxAge,
x, y, z,
motionX, motionY, motionZ, gravity,
scale1, scale2, scaleRate, scaleRateStart,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
entityID
);
}
public void spawnParticle(String directory, int HEXcolor, int amount, int maxAge,
double x, double y, double z,
double motionX, double motionY, double motionZ, float gravity
) {
int entityID = entity.getEntityId();
NoppesUtilServer.spawnScriptedParticle(directory, HEXcolor, amount, maxAge,
x, y, z,
motionX, motionY, motionZ, gravity,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
entityID
);
}
public void spawnParticle(String directory, int HEXcolor, int amount, int maxAge,
double x, double y, double z
) {
int entityID = entity.getEntityId();
NoppesUtilServer.spawnScriptedParticle(directory, HEXcolor, amount, maxAge,
x, y, z,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
entityID
);
}
public void spawnParticle(String directory, int HEXcolor, int amount, int maxAge
) {
int entityID = entity.getEntityId();
NoppesUtilServer.spawnScriptedParticle(directory, HEXcolor, amount, maxAge,
0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
entityID entityID
); );
} }
@@ -106,7 +106,11 @@ public class ScriptLivingBase<T extends EntityLivingBase> extends ScriptEntity<T
public T getMCEntity(){ public T getMCEntity(){
return entity; return entity;
} }
public T getMinecraftEntity(){
return getMCEntity();
}
/** /**
* Makes the entity swing its hand * Makes the entity swing its hand
*/ */
@@ -74,7 +74,11 @@ public class ScriptPlayer<T extends EntityPlayerMP> extends ScriptLivingBase<T>
} }
public void setHunger(int hunger){ public void setHunger(int hunger){
player.getFoodStats().setFoodLevel(hunger); int prevHunger = this.getHunger();
if(hunger < 0)
hunger = 0;
player.getFoodStats().addStats(hunger-prevHunger,0);
} }
public float getSaturation(){ public float getSaturation(){
@@ -82,7 +86,11 @@ public class ScriptPlayer<T extends EntityPlayerMP> extends ScriptLivingBase<T>
} }
public void setSaturation(float saturation){ public void setSaturation(float saturation){
player.getFoodStats().setFoodSaturationLevel(saturation); float prevSaturation = this.getHunger();
if(saturation < 0)
saturation = 0;
player.getFoodStats().addStats(0,saturation-prevSaturation);
} }
public int getDimension(){ public int getDimension(){
@@ -105,7 +113,7 @@ public class ScriptPlayer<T extends EntityPlayerMP> extends ScriptLivingBase<T>
if(dialog == null) if(dialog == null)
return; return;
NoppesUtilServer.openDialog(player, new EntityDialogNpc(this.player.worldObj), dialog); NoppesUtilServer.openDialog(player, new EntityDialogNpc(this.player.worldObj), dialog, 0);
} }
public boolean hasReadDialog(int id){ public boolean hasReadDialog(int id){
@@ -13,4 +13,10 @@ public class CustomNPCsEvent extends Event{
public CustomNPCsEvent() { public CustomNPCsEvent() {
} }
public void setCancelled(boolean bo){
this.setCanceled(bo);
}
public boolean isCancelled(){return this.isCanceled();}
} }
@@ -10,6 +10,7 @@ import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.DamageSource; import net.minecraft.util.DamageSource;
import noppes.npcs.controllers.Dialog;
import noppes.npcs.scripted.NpcAPI; import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.scripted.interfaces.*; import noppes.npcs.scripted.interfaces.*;
@@ -51,6 +52,10 @@ public class NpcEvent extends CustomNPCsEvent {
this.damage = damage; this.damage = damage;
this.damageSource = NpcAPI.Instance().getIDamageSource(damagesource); this.damageSource = NpcAPI.Instance().getIDamageSource(damagesource);
} }
public String getType(){
return damageSource.getMCDamageSource().damageType;
}
} }
public static class RangedLaunchedEvent extends NpcEvent { public static class RangedLaunchedEvent extends NpcEvent {
@@ -58,7 +63,7 @@ public class NpcEvent extends CustomNPCsEvent {
public float damage; public float damage;
//public List<IProjectile> projectiles = new ArrayList(); //public List<IProjectile> projectiles = new ArrayList();
public RangedLaunchedEvent(ICustomNpc npc, EntityLivingBase target, float damage) { public RangedLaunchedEvent(ICustomNpc npc, float damage, EntityLivingBase target) {
super(npc); super(npc);
this.target = (IEntityLivingBase)NpcAPI.Instance().getIEntity(target); this.target = (IEntityLivingBase)NpcAPI.Instance().getIEntity(target);
this.damage = damage; this.damage = damage;
@@ -70,7 +75,7 @@ public class NpcEvent extends CustomNPCsEvent {
public final IEntityLivingBase target; public final IEntityLivingBase target;
public float damage; public float damage;
public MeleeAttackEvent(ICustomNpc npc, EntityLivingBase target, float damage) { public MeleeAttackEvent(ICustomNpc npc, float damage, EntityLivingBase target) {
super(npc); super(npc);
this.target = (IEntityLivingBase)NpcAPI.Instance().getIEntity(target); this.target = (IEntityLivingBase)NpcAPI.Instance().getIEntity(target);
this.damage = damage; this.damage = damage;
@@ -99,6 +104,10 @@ public class NpcEvent extends CustomNPCsEvent {
this.type = damagesource.damageType; this.type = damagesource.damageType;
this.source = NpcAPI.Instance().getIEntity(entity); this.source = NpcAPI.Instance().getIEntity(entity);
} }
public String getType(){
return damageSource.getMCDamageSource().damageType;
}
} }
@Cancelable @Cancelable
@@ -111,6 +120,36 @@ public class NpcEvent extends CustomNPCsEvent {
} }
} }
public static class DialogEvent extends NpcEvent {
public final IPlayer player;
public final int id;
public final int optionId;
public final Dialog dialog;
public DialogEvent(ICustomNpc npc, EntityPlayer player, int id, int optionId, Dialog dialog) {
super(npc);
this.player = (IPlayer)NpcAPI.Instance().getIEntity(player);
this.id = id;
this.optionId = optionId;
this.dialog = dialog;
}
}
public static class DialogClosedEvent extends NpcEvent {
public final IPlayer player;
public final int id;
public final int optionId;
public final Dialog dialog;
public DialogClosedEvent(ICustomNpc npc, EntityPlayer player, int id, int optionId, Dialog dialog) {
super(npc);
this.player = (IPlayer)NpcAPI.Instance().getIEntity(player);
this.id = id;
this.optionId = optionId;
this.dialog = dialog;
}
}
@Cancelable @Cancelable
public static class TargetLostEvent extends NpcEvent { public static class TargetLostEvent extends NpcEvent {
public final IEntityLivingBase entity; public final IEntityLivingBase entity;
@@ -11,4 +11,12 @@ class ScriptEvent{
public boolean isCancelled(){ public boolean isCancelled(){
return isCancelled; return isCancelled;
} }
public void setCanceled(boolean bo){
isCancelled = bo;
}
public boolean isCanceled(){
return isCancelled;
}
} }
@@ -1,7 +1,39 @@
package noppes.npcs.scripted.event; package noppes.npcs.scripted.event;
import net.minecraft.entity.player.EntityPlayer;
import noppes.npcs.controllers.Dialog;
import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.scripted.interfaces.IPlayer;
public class ScriptEventDialog extends ScriptEvent{ public class ScriptEventDialog extends ScriptEvent{
public IPlayer player;
public int dialog;
public int option;
public Dialog dialogObj;
public ScriptEventDialog(EntityPlayer player, int dialog, int option, Dialog dialogObj){
this.player = (IPlayer)NpcAPI.Instance().getIEntity(player);
this.dialog = dialog;
this.option = option;
this.dialogObj = dialogObj;
}
public IPlayer getPlayer() {
return player;
}
public Dialog getDialog() {
return dialogObj;
}
public int getDialogId() {
return dialog;
}
public int getOptionId() {
return option;
}
/** /**
* @deprecated * @deprecated
*/ */
@@ -1,7 +1,6 @@
package noppes.npcs.scripted.gui; package noppes.npcs.scripted.gui;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.client.gui.custom.GuiCustom;
import noppes.npcs.scripted.interfaces.ITexturedRect; import noppes.npcs.scripted.interfaces.ITexturedRect;
public class ScriptGuiTexturedRect extends ScriptGuiComponent implements ITexturedRect { public class ScriptGuiTexturedRect extends ScriptGuiComponent implements ITexturedRect {
@@ -34,12 +34,36 @@ public interface IEntity<T extends Entity> {
* @param alpha2 The particle's ending transparency * @param alpha2 The particle's ending transparency
* @param scaleRate Multiplier for the particle's transparency growth rate * @param scaleRate Multiplier for the particle's transparency growth rate
* @param alphaRateStart The time at which the particle begins appearing/fading * @param alphaRateStart The time at which the particle begins appearing/fading
*
* @param rotation1 The particle's starting rotation angle with respect to the player's vision
* @param rotation2 The particle's final rotation angle with respect to the player's vision
* @param rotationRate The rate at which the particle rotates with respect to the player's vision
* @param rotationRateStart The time at which the particle begins rotating
* @param rotationX1 The particle's starting rotation angle with respect to the X-axis
* @param rotationX2 The particle's final rotation angle with respect to the X-axis
* @param rotationXRate The rate at which the particle rotates with respect to the X-axis
* @param rotationXRateStart The time at which the particle begins rotating over the X-axis
* @param rotationY1 The particle's starting rotation angle with respect to the Y-axis
* @param rotationY2 The particle's final rotation angle with respect to the Y-axis
* @param rotationYRate The rate at which the particle rotates with respect to the Y-axis
* @param rotationYRateStart The time at which the particle begins rotating over the Y-axis
* @param rotationZ1 The particle's starting rotation angle with respect to the Z-axis
* @param rotationZ2 The particle's final rotation angle with respect to the Z-axis
* @param rotationZRate The rate at which the particle rotates with respect to the Z-axis
* @param rotationZRateStart The time at which the particle begins rotating over the Z-axis
*/ */
public void spawnParticle(String directory, int HEXcolor, int amount, int maxAge, void spawnParticle(String directory, int HEXcolor, int amount, int maxAge,
double x, double y, double z, double x, double y, double z,
double motionX, double motionY, double motionZ, float gravity, double motionX, double motionY, double motionZ, float gravity,
float scale1, float scale2, float scaleRate, int scaleRateStart, float scale1, float scale2, float scaleRate, int scaleRateStart,
float alpha1, float alpha2, float alphaRate, int alphaRateStart float alpha1, float alpha2, float alphaRate, int alphaRateStart,
float rotation1, float rotation2, float rotationRate, int rotationRateStart,
float rotationX1, float rotationX2, float rotationXRate, int rotationXRateStart,
float rotationY1, float rotationY2, float rotationYRate, int rotationYRateStart,
float rotationZ1, float rotationZ2, float rotationZRate, int rotationZRateStart
); );
public double getYOffset(); public double getYOffset();
@@ -18,5 +18,17 @@ public interface ITimers {
void clear(); void clear();
int ticks(int id);
void setTicks(int id, int ticks);
int maxTicks(int id);
void setMaxTicks(int id, int maxTicks);
boolean repeats(int id);
void setRepeats(int id, boolean repeat);
int size(); int size();
} }
@@ -121,7 +121,7 @@ remote.freeze=NPCs einfrieren
spawner.entities=Unternehmen spawner.entities=Unternehmen
spawner.clones=Klone spawner.clones=Klone
spawner.mobspawner=MobSpawner spawner.mobspawner=Spawner
spawner.mount=Geritten von... spawner.mount=Geritten von...
spawner.mountplayer=Geritten von selbst spawner.mountplayer=Geritten von selbst
@@ -128,7 +128,7 @@ spawner.clones=Clones
spawner.clones2=Clones 2 spawner.clones2=Clones 2
spawner.clones3=Clones 3 spawner.clones3=Clones 3
spawner.clones4=Clones 4 spawner.clones4=Clones 4
spawner.mobspawner=MobSpawner spawner.mobspawner=Spawner
spawner.mount=Mount by spawner.mount=Mount by
spawner.mountplayer=Player mounts spawner.mountplayer=Player mounts
@@ -55,7 +55,7 @@ remote.freeze=Geler Pnj
spawner.entities=Entités spawner.entities=Entités
spawner.clones=Clones spawner.clones=Clones
spawner.mobspawner=MobSpawner spawner.mobspawner=Spawner
display.model=Modèle display.model=Modèle
display.show=Montrer display.show=Montrer
@@ -54,7 +54,7 @@ remote.freeze=NPC-lefagyasztása
spawner.entities=Entitások spawner.entities=Entitások
spawner.clones=Klónok spawner.clones=Klónok
spawner.mobspawner=MobSpawner spawner.mobspawner=Spawner
display.model=Model display.model=Model
display.show=Mutat display.show=Mutat
Binary file not shown.

Before

Width:  |  Height:  |  Size: 367 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 430 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 333 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 300 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 339 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 308 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 280 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 433 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 412 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 311 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 285 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 306 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 426 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 503 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 257 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 304 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 402 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 380 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 380 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 380 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 380 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 380 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 380 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 380 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 380 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 380 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 380 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 380 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 380 B

Loaded 100 of 244 files, more files were not shown because too many files have changed in this diff. Show more