Compare commits

..
307 Commits
Author SHA1 Message Date
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
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 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
KAMKEEL 6d6daeb345 Update build.gradle 2022-02-02 19:26:24 -05:00
KAMKEEL 3844a26e8b Merge branch 'dev' 2022-02-02 19:25:29 -05:00
KAMKEEL 2a4ace286e Quick Patch 2022-02-02 19:25:17 -05:00
Kamron Vaswani 79ef0e07a1 Merge pull request #33 from c0508383/master
Removed println statement please forgive me oh god
2022-02-02 19:22:35 -05:00
luisc 7e0ff3c836 Removed println statement please forgive me oh god 2022-02-02 18:21:08 -06:00
KAMKEEL e3e55e4256 Merge branch 'dev' 2022-02-02 17:44:46 -05:00
KAMKEEL 0c4ead5752 Merge branch 'dev' of https://github.com/KAMKEEL/CustomNPC-Plus into dev 2022-02-02 16:20:17 -05:00
KAMKEEL 5d39c5b356 Fixed Disable Block Error 2022-02-02 16:20:11 -05:00
Kamron Vaswani 19ccdd60d2 Merge pull request #32 from c0508383/master
Bug fixes & GUI rotations
2022-02-02 15:43:23 -05:00
luisc d3145f4868 Added config for how often a player's quests are checked for completion. 2022-02-02 07:53:42 -06:00
luisc 70536de655 Removed checkQuestCompleted from ScriptPlayer, now redundant with new quest checks that happen periodically. 2022-02-02 07:21:45 -06:00
luisc 1ebf747302 Optimized NBT access of player data when checking quest completion, player data variable is passed down to lower functions.
Player's quests are checked for completion every couple seconds now.
2022-02-02 07:18:33 -06:00
luisc 632e92f82e Added set/getPitch to ScriptEntity 2022-02-01 05:10:38 -06:00
luisc 90ca1a0200 Added isAirborne() function to ScriptEntity 2022-02-01 02:30:50 -06:00
luisc 9109c134c1 Added more general setMotion function with x y and z parameters. 2022-01-31 23:59:15 -06:00
luisc 1af875aea9 Fixed concurrent modification bug with NPC tasks. 2022-01-31 23:01:52 -06:00
luisc 7de585843d Added get/setHunger, and get/setSaturation functions for ScriptPlayer.
The player KeyPressed event now sends a list of keys that are currently pressed by the player.
2022-01-31 20:16:00 -06:00
luisc 67c83b1ce9 Added rotation for custom GUI lines, labels, and textured rectangles 2022-01-31 15:39:21 -06:00
Kamron Vaswani bc54e8cd7b Merge pull request #31 from c0508383/master
Increased NPC Inventory & Other Additions.
2022-01-31 16:27:15 -05:00
Kamron Vaswani 8675d22ebb Merge pull request #30 from PewDizinho/patch-1
Update README.md
2022-01-31 16:27:01 -05:00
luisc 83e13285f9 Added rotation to overlay components, and color codes to overlay labels 2022-01-31 14:51:06 -06:00
luisc 3be088c4cc Moved OpenGL lines to within the loop that renders each component, fixing some weird alpha errors. 2022-01-30 22:58:12 -06:00
luisc 54fadbe63f Implemented label, alpha, and formatting for Custom GUI labels. 2022-01-30 22:49:03 -06:00
luisc da3b04e78e Implemented MC chat formatting for color codes: &l, &m, &r, &o, and &k all affect overlay labels. 2022-01-30 22:41:55 -06:00
luisc e7a19264b2 Added alpha and style options for overlay labels. 2022-01-30 14:22:29 -06:00
luisc 966ab4bf72 Custom Overlays and GUIs now properly set alpha values for some components. 2022-01-30 13:29:00 -06:00
luisc e5e1aa1972 Made color and alpha components global among ScriptGui classes. 2022-01-30 05:20:45 -06:00
luisc be61bd4e17 Made color and alpha components global among ScriptOverlay classes. 2022-01-30 04:33:00 -06:00
luisc 534f716991 Implemented Scripted Overlays which stay on the player's screen. Overlays persist in the client, and can be removed from the screen as well. 2022-01-30 04:05:01 -06:00
luisc 8b24dad211 Added Custom GUI Lines, with configurable thickness & color. Draws a line between one point defined by (x1,y1), and another defined by (x2,y2) 2022-01-28 03:21:00 -06:00
PewDizinho 6974476d92 Update README.md 2022-01-27 14:36:20 -03:00
luisc fcaafe4b26 Fixed NBT issue with the new quest kill amounts. 2022-01-27 06:14:03 -06:00
luisc f876f13d77 Added 9 more slots for quest kill objectives, and an option for kill quests to progress only if a player kills an NPC with that name.
Added quest interface support to get and modify data from specific quest types.
2022-01-27 05:40:51 -06:00
luisc 989effb5c5 Added more a full inventory to NPCs, selectable on two tabs and double-point values for NPC droprates. 2022-01-27 03:50:36 -06:00
luisc f14337f1bb Added config for NPC sizes, default 100. 2022-01-25 14:54:15 -06:00
luisc eb45a6a959 Added several more dialog functions for the rest of the dialog options. 2022-01-25 14:44:24 -06:00
Kamron Vaswani a04f023d53 Merge pull request #28 from c0508383/master
Custom GUI fixes
2022-01-24 01:06:56 -05:00
luisc 092b3ce0c1 Fixed overloaded hurt(damage,entity) function not working when an entity is to be hurt by a player 2022-01-22 22:50:01 -06:00
KAMKEEL 971010bda8 Darken Screen Dialog Fix 2022-01-21 18:31:32 -05:00
luisc 06c730b166 Fixed scale & color issues for custom GUI textured rectangles. 2022-01-21 01:15:21 -06:00
luisc b9bc1e5ed7 Merge remote-tracking branch 'origin/master' 2022-01-20 20:27:39 -06:00
luisc 83756381e4 Added toggleable shadows and scaling to custom GUI labels. 2022-01-20 20:27:26 -06:00
Luis C.M 52f342302c Merge branch 'KAMKEEL:master' into master 2022-01-20 16:32:16 -06:00
luisc 0788b2750f Quick fix for custom GUI textured rectangles, now with working x and y offsets. 2022-01-20 00:15:21 -06:00
KAMKEEL 8a9defd3a1 Part Data Texture Fix for Upgrading from CNPC
Issue where already saved NPCs cannot locate texture if upgrading from CNPC to CNPC+
2022-01-19 18:21:12 -05:00
KAMKEEL dff71c5a98 Update 1.5-beta
💯
Starting new version
2022-01-18 00:20:50 -05:00
Kamron Vaswani cb72f6c50e Merge pull request #26 from c0508383/master
Compatibility fix pt.2
2022-01-15 23:54:55 -05:00
luisc dd22f604cc Compatibility fix for mods that initialize player or worldobj fields as null. 2022-01-15 22:52:27 -06:00
Kamron Vaswani 05e6a97721 Merge pull request #25 from c0508383/master
Compatibility fix for mods that initialize player or worldobj fields as null.
2022-01-15 23:50:33 -05:00
luisc f8a6fe3d75 Compatibility fix for mods that initialize player or worldobj fields as null. 2022-01-15 22:49:07 -06:00
KAMKEEL f9ab885ddd Update Version 1.4.2
Fixed Faction Dupe Glitch
Fixed Darken Screen not saving
2022-01-15 16:51:46 -05:00
Kamron Vaswani e0f77bdcff Merge pull request #24 from c0508383/master
Fixed a faction duplication glitch
2022-01-15 16:50:07 -05:00
luisc 6ff2678f26 Fixed a faction duplication glitch 2022-01-15 15:14:55 -06:00
KAMKEEL a1a0864692 Wrong Button ID Darken Screen 2022-01-15 15:24:37 -05:00
KAMKEEL b3098053ec Fixing Dark Screen not savning 2022-01-15 15:21:20 -05:00
KAMKEEL 2155566113 Hotfix 2022-01-15 04:45:51 -05:00
Kamron Vaswani 9d88da30cf Merge pull request #23 from c0508383/master
Hotfix to Custom GUI Labels for servers
2022-01-15 04:22:33 -05:00
luisc 24e8648a1d Merge remote-tracking branch 'origin/master' 2022-01-15 03:16:37 -06:00
luisc e1c283a19e Hotfix to Custom GUI labels for servers 2022-01-15 03:16:22 -06:00
Kamron Vaswani aba9dd250a Merge pull request #22 from c0508383/master
Added collision options for CNPCs.
2022-01-14 21:51:16 -05:00
KAMKEEL f508fbed1a 1.4
Fix Decimal Display
2022-01-14 21:48:15 -05:00
luisc 007660f16f Added collision options for CNPCs. 2022-01-14 19:07:41 -06:00
Kamron Vaswani e10aa09728 Merge pull request #21 from c0508383/master
Custom GUI slot fix & Custom Particle fix
2022-01-14 19:11:15 -05:00
luisc 4f38edc147 Limited config NpcNavRange to 96. Added darken screen option to dialogs. 2022-01-14 17:37:09 -06:00
luisc 6a6548845b Fixed textfield focus event running when textfield is unfocused 2022-01-14 16:50:13 -06:00
luisc 0aef0827ec Fixed scripted particles not spawning on some NPCs. Custom particle packets are now sent to all players. 2022-01-14 16:39:24 -06:00
luisc 791adfc1b4 Implemented textfield unfocused event 2022-01-14 16:09:27 -06:00
luisc 2874643c84 Fixed textured rectangles in custom GUIs not being placed relative to the GUIs' position. 2022-01-14 15:41:27 -06:00
luisc b0da137db5 Custom GUI slot fix 2022-01-14 15:06:25 -06:00
luisc c28a9156d5 Custom GUI slot fix 2022-01-14 15:06:04 -06:00
Kamron Vaswani 4ba6f3086f Merge pull request #20 from c0508383/master
Flight Fix and API update
2022-01-13 20:31:09 -05:00
luisc 555ceb741f Added a modifiable and toggleable flying height limit to NPCs 2022-01-13 05:28:20 -06:00
luisc 04def38b63 Added dialog events to scripted player events 2022-01-12 22:59:03 -06:00
luisc b024f800ae Added quest start, complete, and turnin events, and a faction points event to scripted player events. 2022-01-12 20:12:16 -06:00
luisc 8919a182c5 Added removeTags() function to ScriptItemStack and isCustomGUI function to ScriptContainer 2022-01-12 04:54:07 -06:00
luisc 6b9cfb9d25 Implemented custom GUIs. 2022-01-12 04:44:08 -06:00
luisc d50f51e208 Added handler support to NPC API. 2022-01-10 15:21:48 -06:00
luisc 69f96519dc Fixed forge events registering twice. 2022-01-10 12:37:26 -06:00
luisc 7808e4a433 getTag() and hasTag() functions from ScriptItemStack no longer write the item stack NBT tag on call. 2022-01-09 17:50:36 -06:00
luisc d74a1f2bee Added ScriptBlockPos functionality with get/setPos to ScriptEntity 2022-01-04 03:50:50 -06:00
luisc c3541df1dc Fix to getFormLevel() in ScriptDBCPlayer 2022-01-04 00:06:48 -06:00
luisc 32792e7d6f Added updateClient() function to ScriptNpc. 2022-01-03 21:30:38 -06:00
luisc 73db2da124 Fixed flying not working in small enclosed spaces. 2022-01-03 15:50:31 -06:00
luisc 6459e7fe2a Added solid render option for bodywear. 2022-01-02 18:13:01 -06:00
luisc a32db79a0b Added solid render option for bodywear 2021-12-30 08:27:04 -06:00
luisc de5f119fd7 Added setJob and setRole functions to ScriptNpc 2021-12-29 22:34:51 -06:00
luisc b330678104 Added several projectile functions to ScriptNpc. 2021-12-29 17:17:06 -06:00
luisc e6f97784ff Added get/setRotationType to ScriptNpc. Added get/setMotion for x, y, z components to ScriptEntity. Fixed an NPC wand crash. 2021-12-29 16:22:05 -06:00
luisc e676c808e3 Fixed getFormLevel not working when player form NBT is "pty". ScriptBlock now correctly sets its tile field, allowing players to access blocks as chests, crates, etc. 2021-12-26 21:08:35 -06:00
luisc e5edbe002e Registered forge events on both MinecraftForge.EVENT_BUS and FMLCommonHandler.instance().bus(). 2021-12-23 10:26:46 -06:00
luisc ce9b9fb59d Merge remote-tracking branch 'origin/master' 2021-12-22 03:34:06 -06:00
luisc c8f6a24baf Added command forge event 2021-12-22 03:33:50 -06:00
luisc 2743fa17d8 Added command forge event 2021-12-22 03:30:01 -06:00
KAMKEEL 5409e4e924 Beta 1.4 2021-12-21 23:57:35 -05:00
KAMKEEL 6573970840 Update build.gradle 2021-12-21 23:55:10 -05:00
KAMKEEL efdd1d6679 Merge branch 'dev' of https://github.com/KAMKEEL/CustomNPC-Plus into dev 2021-12-21 23:52:54 -05:00
KAMKEEL 4cca8e562c Update Build Gradle 2021-12-21 23:51:36 -05:00
Kamron Vaswani 4c31236590 Merge pull request #18 from c0508383/master
December Pull Request
2021-12-21 23:51:07 -05:00
Kamron Vaswani b62149d5f6 Merge branch 'dev' into master 2021-12-21 23:50:51 -05:00
luisc ff810cbc8d Full console output is now shown again for script errors. 2021-12-20 17:03:54 -06:00
luisc 69d4fb20ff Modified client and server packet sending a little bit for player and forge scripts. 2021-12-20 16:57:05 -06:00
luisc 953f6e0459 Fixed server-side lag caused by player events. THIS IS BIG. 2021-12-18 08:34:30 -06:00
luisc 1a78b2dad7 Timers are only updated if a timer exists for a player. 2021-12-17 17:30:50 -06:00
luisc d46d0aba7e Player events and Forge events run in their own separate buses without redundant registering. 2021-12-17 15:14:52 -06:00
luisc 03ee733620 Forge tick events only run if they are in the starting phase. 2021-12-17 14:26:52 -06:00
luisc 7d94e0e210 Removed forge chunk and terrain gen events. 2021-12-17 08:25:02 -06:00
luisc f03516b00f Fixed console and console spam with scripted player events. 2021-12-17 08:10:21 -06:00
luisc 23384d1d67 Fixed some server-side lag caused by player events. Player ticks now execute every 10 MC ticks. 2021-12-16 21:54:05 -06:00
luisc 6bdc68337c Revert "Made player script implementation closer to that of 1.12."
This reverts commit 3a9789b3fd.
2021-12-16 04:05:05 -06:00
luisc 3a9789b3fd Made player script implementation closer to that of 1.12. 2021-12-16 02:53:17 -06:00
luisc 69b7a9aab4 Fixed errors in remove and clear functions for bonusAttribute in ScriptDBCPlayer 2021-12-15 06:46:27 -06:00
luisc 9d9c481bdd Added alternative bonusAttribute function for just get remove and clear, as well as dedicated functions for all bonus attribute functions. 2021-12-15 06:19:16 -06:00
luisc 98d2d943ae Added bonusAttribute function, which works the same as the command. 2021-12-15 05:43:07 -06:00
luisc e9a4471cd2 Added getSkills and setSkills functions to ScriptDBCPlayer 2021-12-15 03:19:34 -06:00
luisc 934d5a69d6 Added getFormLevel and setFormLevel to ScriptDBCPlayer 2021-12-15 03:14:48 -06:00
luisc 12cb6a2937 Added blocking() function to ScriptPlayer to check whether the player is blocking. 2021-12-15 00:02:27 -06:00
luisc cad275e845 Added isBlocking, set/getHairCode, set/getExtraCode, and getInventory functions to ScriptDBCPlayer 2021-12-14 21:41:57 -06:00
luisc 816445bccd Script error output shortened to just the error description and line number. 2021-12-13 22:51:33 -06:00
luisc cf91d8638f Fixed getDBCPlayer not returning a DBC Player instance. 2021-12-13 18:33:20 -06:00
luisc 03395ad750 Added getWorld() function to ScriptEntity. 2021-12-13 16:47:15 -06:00
luisc f2da93451f Re-added hasEnchant, addEnchant, setAttribute, getAttribute, hasAttribute, getLore, and setLore to ScriptItemStack after they were lost in a commit A LONG TIME AGO 2021-12-13 03:11:24 -06:00
luisc 00557df9a7 Fixed players being able to push NPCs around. 2021-12-13 00:16:06 -06:00
luisc 541958b630 Fixed "world" keyword in for NPC scripting and API.getIWorld not returning the same instance. 2021-12-12 23:43:44 -06:00
luisc eac3d2c214 Added getSpeed() and setSpeed(speed) functions to ScriptNpc 2021-12-12 23:10:55 -06:00
luisc ba0f21dc26 Revert "Added npc.setPoweredTexture(directory) and npc.getPoweredTexture() functions, along with a new powered texture resource."
This reverts commit ba4bf107b5.
2021-12-11 08:41:54 -06:00
luisc 743cdb9db7 Revert "Fixed powered texture not showing up when changing NPC model attributes."
This reverts commit 9560228ba8.
2021-12-11 08:38:38 -06:00
luisc fc1c16032f Added RGB and alpha powered texture modifiers:
setPoweredRGBA(r,g,b,alpha)
getPoweredR(),getPoweredG(),getPoweredB(),getPoweredAlpha()
2021-12-10 00:08:47 -06:00
luisc b7d2dab905 Added parameters for texture translation when the NPC is powered, namely npc.display.poweredTranslateX, poweredTranslateY, and poweredTranslateZ, which can all be changed by setPoweredXYZ(x,y,z), and gotten with getPoweredX(), getPoweredY(), and getPoweredZ(). 2021-12-09 23:37:04 -06:00
luisc 9560228ba8 Fixed powered texture not showing up when changing NPC model attributes. 2021-12-09 23:24:36 -06:00
luisc ba4bf107b5 Added npc.setPoweredTexture(directory) and npc.getPoweredTexture() functions, along with a new powered texture resource.
Sample code:
npc.setPoweredTexture("customnpcs:textures/entity/npc_armor.png");
2021-12-08 23:29:08 -06:00
luisc 81881e6e19 Reset aggro range to Integer.MAX_VALUE. Sustainable aggro ranges seem to correlate to client/server RAM, and people should decide what max range is suitable for their client/server. 2021-12-08 20:52:39 -06:00
luisc 909f69575a Set max aggro range to 100. 2021-12-08 20:46:02 -06:00
luisc 34f6f670eb Y velocity when calling entity.knockback() is no longer decreased drastically. 2021-12-08 17:48:35 -06:00
luisc 8c602c4d16 Adjusted floating: NPCs don't float when they're knocked back or hurt. 2021-12-08 17:43:27 -06:00
luisc d66f532643 Made entity field in FlyingMoveHelper final 2021-12-08 15:50:58 -06:00
luisc d37e986006 Fixed NPCs bobbing in the air when flying. 2021-12-08 15:34:41 -06:00
luisc 29db4bfe33 Fixed flying aggro range now working for larger aggro ranges 2021-12-08 06:25:28 -06:00
luisc 90eec7a57b Added GUI fields for setting flying properties of NPCs. Updated en_lang file to add GUI texts. 2021-12-08 05:26:32 -06:00
luisc 94c7df410b Added fly gravity for NPCs, configurable with npc.setFlyGravity(gravity) and npc.getFlyGravity() 2021-12-08 04:50:23 -06:00
luisc c2564de470 NPCs properly stay floating when not navigating and in the air. 2021-12-08 04:41:41 -06:00
luisc 2147bd00d0 Pathing classes for NPC flying added. NPCs can now follow tactical variants while flying, and their pathing is a LOT better. 2021-12-08 04:00:28 -06:00
luisc 922708bf97 Changed npc field in ScriptNpc to EntityNPCInterface 2021-12-07 23:52:57 -06:00
luisc 43b3241801 Implemented path navigator and move helper for flying NPCs (npc.getNavigator() and npc.getMoveHelper() used to return the default navigator and move helper, added override function).
Improved Flying AI getting stuck when trying to get over a block towards the enemy.
2021-12-07 03:57:57 -06:00
luisc 12333de3a1 knockback() function for ScriptEntity now *only* knocks the entity back instead of hitting it.
Flying NPC's get knocked back properly, and their vertical speed has been increased.

Flying NPC's vertical flying speed can be changed by npc.setFlySpeed(double speed) from ScriptNpc.
2021-12-06 00:10:10 -06:00
luisc 3cd1410c19 Added new ScriptDBCPlayer class for manipulating Dragon Block C attributes.
Flying NPCs no longer chase you down if you're dead, or if they're dead.
2021-12-05 15:04:03 -06:00
luisc 3c1bc30e44 Floor values are set for max health, combat regen, health regen, melee damage, and projectile damage when changing them now. 2021-12-04 12:46:53 -06:00
luisc cd5b4c0633 Removed shadow when rendering an NPC that shouldn't be visible to a specific player after using setVisibleTo(). 2021-12-03 21:54:13 -06:00
luisc f14bc107d3 Double clicking events in the hook list will now paste them into your code. More scripting functions added for NPCs. 2021-12-03 21:13:56 -06:00
luisc 547f5ab82d Container event spam when no container is open fixed. Fixed scripted player and forge events not launching after merging ScriptContainer and EventScriptContainer. 2021-12-03 18:17:52 -06:00
luisc 23686dc3b8 Enabled fly button in movement, and extended max values for several NPC attributes, converting some to floats and doubles.
NPCs fly with speed based on their movement speed now.
2021-12-03 00:49:10 -06:00
luisc 44d4e74279 Enabled fly button in movement, and set max value for fields as Integer.MAX_VALUE for various fields. 2021-12-01 18:46:48 -06:00
luisc 17eb612fb8 Fixed NPC Script GUI error not saving/accessing scripts correctly. 2021-12-01 17:42:48 -06:00
luisc 72869e6a78 Consolidated EventScriptContainer and ScriptContainer into a single ScriptContainer class. NPCs are now able to fly when ai.movementType == 1. 2021-12-01 15:31:05 -06:00
KAMKEEL e8dd3e7ddc V 1.3.2
This is just a small change to the way the
pedestal works.
2021-11-29 23:15:42 -05:00
KAMKEEL 3dd8a60702 Version Update 2021-11-29 22:28:54 -05:00
KAMKEEL 71c81bce27 Merge branch 'dev' 2021-11-29 22:26:48 -05:00
Kamron Vaswani f39ed1fd37 Merge pull request #15 from c0508383/master
Critical fix to NBT loading when loading entities into chunks from a …
2021-11-29 22:26:22 -05:00
luisc f3ebf86b1e Critical fix to NBT loading when loading entities into chunks from a different version. 2021-11-29 21:21:49 -06:00
KAMKEEL f64399e40d Create Scripting_Documentation.pdf 2021-11-28 23:48:16 -05:00
KAMKEEL d79ec52994 Update Version 2021-11-26 04:37:33 -05:00
KAMKEEL 3069488c54 Merge branch 'dev' 2021-11-26 04:35:09 -05:00
KAMKEEL 24790b7952 Add Disabling All Damage
Cleaned Up some Lang Code
Added Disabling All Damage to Stats
Moved Disable Damage from Resistances to Stats
Added Disable Damage Message
2021-11-26 04:34:47 -05:00
Kamron Vaswani edabe3890f Merge pull request #13 from c0508383/master
Scripting Update Approved
2021-11-26 04:06:37 -05:00
luisc ecbfd7dab0 Fixed some console spam caused by a NullPointerException when checking scriptVisibleToPlayer(player) in ModelMPM 2021-11-23 15:08:35 -06:00
luisc d24422c3a1 Added setVisibleTo(player,visible) and isVisibleTo(player) to ScriptNpc 2021-11-22 23:34:02 -06:00
luisc 8a7f40189e Fixed redundant function calls for saving player data in NoppesUtilServer when using isGUIOpen(). Added getServerTime() to NpcAPI. 2021-11-22 02:33:28 -06:00
luisc 77c2897109 Added getAllServerPlayers, createItem & createEntityParticle to NPC API. Added getDimensionID() to ScriptWorld. 2021-11-22 01:10:27 -06:00
luisc d5c13ae65f Fixed scripted particle texture replacing in-world vanilla particle effects while alive. 2021-11-20 13:12:21 -06:00
luisc d2fe832508 Removed playerLevel parameter from PlayerData 2021-11-18 01:16:11 -06:00
luisc 03e4400b2e Small custom particle null pointer error fix 2021-11-18 01:13:42 -06:00
luisc 0d807b36d9 Added isGUIOpen() function, and setPosition function with a dimensionId parameter to ScriptPlayer. 2021-11-16 10:41:04 -06:00
luisc 27b88c1fce Player key events now detect key presses as well, not just releases. 2021-11-13 13:32:33 -06:00
luisc 40b39d3b20 Player key and mouse scripts now execute even when the player has a GUI open. 2021-11-13 12:52:21 -06:00
luisc 70f1ff2613 Added API to NPC script engine. 2021-11-10 02:21:03 -06:00
luisc 6b2a9d92b1 Added hasCollided() function to ScriptEntity. 2021-10-28 16:54:41 -05:00
luisc 2ffa9bfcfa Added setImmune() function to ScriptEntity. 2021-10-28 16:46:09 -05:00
luisc 27dce4a90a Small parameter adjustment to ScriptLivingBase.hurt() 2021-10-25 01:07:31 -05:00
luisc 1478841098 Added hurt functions to ScriptLivingBase 2021-10-25 00:58:03 -05:00
luisc 6fcf566ef7 Made setRotation work for players, with yaw and pitch parameters. 2021-10-24 23:33:22 -05:00
luisc 18aa2d099f Added updatePlayerInventory to ScriptPlayer 2021-10-24 01:53:20 -05:00
luisc b068c76fc8 Fixed some forge events not working from being registered on the wrong event bus. 2021-10-23 02:43:28 -05:00
luisc a29058d696 Fixed timers on the server-side. 2021-10-22 02:22:45 -05:00
luisc d1c4adf371 ScriptEntity instances are now properly retrieved in event scripts 2021-10-21 22:14:12 -05:00
luisc 4de969f6c9 Implemented scripted timers for players and NPCs. 2021-10-20 23:04:52 -05:00
luisc a993c8feff Fixed forge scripts on the server side. getIEntity() now correctly returns an IPlayer when given a player as a parameter. 2021-10-20 20:27:42 -05:00
luisc 5515f5ef83 Fixed executeCommand() function for scripting API on the server-side. 2021-10-19 19:49:43 -05:00
luisc 8b710ed520 Fixed executeCommand() function for scripting API. 2021-10-19 16:59:09 -05:00
luisc b15f5221fd Added getAllNbt function to ScriptEntity. 2021-10-19 14:48:59 -05:00
luisc 40e738384f Disabled invulnerability during knockback() for ScriptEntity. 2021-10-19 03:44:41 -05:00
luisc f88cbb8b51 Server-side compatibility changes 2021-10-19 02:49:46 -05:00
luisc c8f917d8fb Merge branch 'master' into ScriptingUpdate
Undoing a previous pull request that changed too many files for the pull
request from this branch to be read easily.
2021-10-19 02:46:37 -05:00
luisc bb1da8376d Implemented 1.12 event scripting API. 2021-10-18 22:01:15 -05:00
luisc feeef71b5a Added more player events. 2021-10-18 20:50:54 -05:00
luisc 15bfbcdbd1 Added storeAsClone function. Made some fields in Script Entity, NPC, and Player public because of the refactoring. 2021-10-18 07:02:19 -05:00
luisc 72f2c3c60a Implemented global Forge events. Reorganized NPC API files. 2021-10-18 06:33:39 -05:00
luisc c5ed7497c8 Added console output and correct script halting to scripted player events. Renamed PlayerScriptContainer to EventScriptContainer. 2021-10-17 16:11:29 -05:00
luisc a9bce4a3e3 Fixed player script enabled button not working right on servers. Added more player events and a getDimension() method to ScriptPlayer. Set player scripts to be off by default. 2021-10-15 09:17:31 -05:00
KAMKEEL 2d70b0091b Fix Custom Shields and Daggers 2021-10-14 00:08:05 -04:00
luisc 047552d9e5 Made constant BlockPos calculateLogBaseTwo calculation explicit, enabled player events by default. 2021-10-12 04:20:33 -05:00
luisc 699182f4c0 Added ScriptBlock and ScriptNbt support to scripting API 2021-10-12 03:23:56 -05:00
luisc 6752f8baec Implemented several more events for players, including a click event, key event, fall event, and the basic entity living hurt, killed, and kills events, among others. 2021-10-12 02:57:32 -05:00
luisc 6c8c7671b8 Implemented KeyPressed event. 2021-10-11 07:16:10 -05:00
luisc 1ee14920ff Scripted player tick events are functional, GUI for player events is complete. Global player events run as they should now, just need to start implementing more of them. 2021-10-11 06:49:30 -05:00
luisc 6aa98aecf3 Work on Player Event Script GUIs 2021-10-02 08:47:13 -05:00
luisc 44bd1692d1 GUI's properly implemented, script data still needs work. 2021-10-01 01:17:12 -05:00
luisc 95d2814651 Backported GUI features and necessary classes from 1.12. 2021-09-30 21:44:30 -05:00
luisc 8b6e84a8d4 Removed many unnecessary/redundant backported files. Focused only on classes that make events work. 2021-09-30 01:48:54 -05:00
luisc 5a1c4757cf Went down huge rabbit hole to attempt adding scripted events for players. Chock full of errors, trying to backport classes from the 1.12 version. 2021-09-30 00:56:49 -05:00
KAMKEEL 69877e8edf 1.2.2
Bow Fix
2021-09-24 17:00:41 -04:00
KAMKEEL 79339be79a Bow Change
Attempting to Fix Custom Bows
2021-09-24 16:50:28 -04:00
luisc 58a1ccc3e7 Added new knockback function with x y and z knockback power parameters. 2021-09-23 03:02:58 -05:00
luisc a5f9ec103f GiveItem and RemoveItem methods now update the player's server-side inventory to client changes 2021-09-15 14:06:20 -05:00
luisc 4ba0460a16 Added NBT tag support to ScriptEntity, ScriptItemStack, and ScriptWorld 2021-09-15 13:24:46 -05:00
luisc 71e13a177f Removed Entity field from ScriptEntityParticle 2021-09-08 13:45:50 -05:00
luisc c39ebc4909 Added ScriptEntityParticle class to store and modify scripted particle objects in code. Added support for this calss to ScriptWorld and ScriptEntity. 2021-09-08 13:41:57 -05:00
luisc f6d9149038 Undid removing screen darken from NPC dialogues. 2021-09-06 13:40:25 -05:00
luisc 50e3ae7f83 Removed screen darken from NPC dialogues. 2021-09-06 13:37:36 -05:00
luisc b43d89f91e Removed redundant/unused imports from EntityCustomFX 2021-09-06 13:36:28 -05:00
luisc 1c2534bfc4 Removed ModelPartData parameter from EntityCustomFX. Reverted ModelPartData to its original version, no longer storing particle attributes. 2021-09-06 13:33:09 -05:00
luisc 61ad3dc849 Removed ModelPartData parameter from EntityCustomFX. Reverted ModelPartData to its original version, no longer storing particle attributes. 2021-09-06 12:47:51 -05:00
luisc 6e9c693d49 Changed entity search method for custom particles to solely use entity IDs instead of entities near the closest player. 2021-09-06 12:28:14 -05:00
luisc fbc22fdef2 Added Custom Particles for scripted entities that work on server and client sides. 2021-09-06 01:24:38 -05:00
luisc 9f4ab7f01e Added getWidth() getHeight() and getYOffset() functions to ScriptEntity 2021-09-05 23:01:25 -05:00
luisc 2a378190ae Added EntityCustomFX class, used for spawning custom particles on entities. 2021-09-05 21:53:58 -05:00
luisc 459976c54d Modified giveItem() method to give the player item(s) with all attributes of the ScriptItemStack parameter. 2021-09-05 21:48:36 -05:00
317 changed files with 22127 additions and 1634 deletions

No files matched your search

Binary file not shown.
+39 -29
View File
@@ -1,43 +1,47 @@
## 👋 Welcome to the CustomNPC+ Repository.
![](images/logo.png) ![](images/logo.png)
Welcome to the CustomNPC+ Repository. > CustomNPC+ is a [Minecraft](https://minecraft.net/) mod that allows you to add custom NPCs to your world. It is developed for creative and storytelling players who want to make their Minecraft worlds more in-depth and unique. CustomNPC+ is only a branch version of the **1.7.10** Forge version of the original (down below) and has no plans to add or update any other version. This is not an official version of CustomNPC.
CustomNPC+ is a [Minecraft](https://minecraft.net/) mod that allows you to add custom NPCs to your world. It is developed for creative and storytelling players who want to make their Minecraft worlds more in-depth and unique. CustomNPC+ is only a branch version of the **1.7.10** Forge version of the original (down below) and has no plans to add or update any other version. This is not an official version of CustomNPC.
Link to CurseForge: [HERE](https://www.curseforge.com/minecraft/mc-mods/customnpc-plus) Link to CurseForge: [HERE](https://www.curseforge.com/minecraft/mc-mods/customnpc-plus)
#### 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:
- [x] More Wing Types - More Wing Types
- [x] More Fin Types - More Fin Types
- [x] More Capes* - More Capes*
- [x] More Overlays - More Overlays
- [x] Added Horns - Added Horns
- [x] Added Dolphin Tail - Added Dolphin Tail
- [x] Larger Clone GUI - Larger Clone GUI
- [x] More Clone Tabs - More Clone Tabs
- [x] Increased Resolution to Additional Body Parts - Increased Resolution to Additional Body Parts
- [x] ~~Update Local Skin Textures (64x64) [WIP]~~ - ~~Update Local Skin Textures (64x64) [WIP]~~
- [x] Added (New) Local 64x64 Skin Textures - Added (New) Local 64x64 Skin Textures
- [x] 1.8 Skins (64x64) - 1.8 Skins (64x64)
- [x] Alex Model (64x64) - Alex Model (64x64)
- [x] Fix Part Rendering - Fix Part Rendering
- [x] Backported GUI Features - Backported GUI Features
- [x] Backported New Part Models - Backported New Part Models
- [X] Custom Part Disabling - Custom Part Disabling
- [X] Markov Name Generator - Markov Name Generator
- [ ] Flying NPCS [WIP] - Flying NPCS
- PlayerData Storage Options [JSON/Zstd]
- Script Enchanments and Fixes
- Scripting Additions: [Documentation](https://github.com/PewDizinho/CustomNPCPlus-Script-Documentation)
--- Please Suggest New Features! --- Please Suggest New Features!
###### **Majority of these cape designs are taken from the internet with fair-usage.*
#### Skin Model Feature: ## 🔰 Skin Model Feature:
##### Please note all *local* skins in this version of CustomNPC, must match the model selected. ###### **Majority of these cape designs are taken from the internet with fair-usage.*
##### ❔ Please note all *local* skins in this version of CustomNPC, must match the model selected.
<img src="images/skinAnimation.gif" width="474" height="260"/> <img src="images/skinAnimation.gif" width="474" height="260"/>
#### Scale/Puppet Reset: #### Scale/Puppet Reset:
@@ -47,6 +51,12 @@ This mod is an ***update*** to CustomNPC and not an add-on. Do not install Custo
<img src="images/Url64Example.gif" width="474" height="260"/> <img src="images/Url64Example.gif" width="474" height="260"/>
#### Want to check out my other mods? ## 🔗 Want to check out my other mods?
[Plugin Mod](https://github.com/KAMKEEL/Plugin-Mod) is a mod designed to add more aesthetic items for RPG and storytelling. It is compatible with CustomNPC+ and has many items intended to be used and wielded by created NPCs. [Plugin Mod](https://github.com/KAMKEEL/Plugin-Mod) is a mod designed to add more aesthetic items for RPG and storytelling. It is compatible with CustomNPC+ and has many items intended to be used and wielded by created NPCs.
[![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)
[![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 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>
+38 -1
View File
@@ -17,7 +17,7 @@ buildscript {
apply plugin: 'forge' apply plugin: 'forge'
version = "1.2.1" version = "1.5.3"
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"
@@ -26,6 +26,24 @@ minecraft {
runDir = "eclipse" runDir = "eclipse"
} }
sourceCompatibility = 1.8
targetCompatibility = 1.8
configurations {
shade
compile.extendsFrom shade
}
// List of all supported OS for zstd compression (This is include only for anyone which is not using the default compression)
def supportedOS = [
"linux_amd64",
"linux_i386",
"win_amd64",
"win_x86",
"darwin_x86_64",
"darwin_aarch64"
]
dependencies { dependencies {
// you may put jars on which you depend on in ./libs // you may put jars on which you depend on in ./libs
// or you may define them like so.. // or you may define them like so..
@@ -39,6 +57,11 @@ 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
// shade 'com.github.luben:zstd-jni:1.5.2-2' - Remove almost implementations of zstd
for (os in supportedOS) {
shade ("com.github.luben:zstd-jni:1.5.2-2:${os}")
}
} }
@@ -61,3 +84,17 @@ processResources
exclude 'mcmod.info' exclude 'mcmod.info'
} }
} }
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
jar {
configurations.shade.each { dep ->
from(project.zipTree(dep)) {
exclude 'META-INF', 'META-INF/**'
}
}
}
sourceSets {main { output.resourcesDir = output.classesDir }}
@@ -0,0 +1,187 @@
package foxz.command;
import foxz.commandhelper.ChMcLogger;
import foxz.commandhelper.annotations.Command;
import foxz.commandhelper.annotations.SubCommand;
import foxz.commandhelper.permissions.OpOnly;
import luizotavio.compressor.ZstdCompressor;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.controllers.PlayerDataController;
import noppes.npcs.util.NBTJsonUtil;
import java.io.File;
import java.io.RandomAccessFile;
import java.nio.file.Files;
import java.nio.file.StandardOpenOption;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import static luizotavio.compressor.executor.IOExecutor.IO_EXECUTOR;
@Command(
name = "compressor",
desc = "Convert a file to a compressed file or back to json",
usage = "update [file|all] [json|zstd]"
)
public class CmdCompressor extends ChMcLogger {
public CmdCompressor(Object sender) {
super(sender);
}
@SubCommand(
name = "update",
desc = "Convert all files in the current directory to compressed files",
permissions = {OpOnly.class}
)
public boolean onConvert(String[] args) throws ExecutionException, InterruptedException, TimeoutException {
if (args.length == 0) {
sendmessage("Usage: /noppes compressor update [<filename>|all] [json|zstd]");
return true;
}
if (args.length == 1) {
sendmessage("Please specify the type of compression to use");
return true;
}
String type;
if (args[1].equalsIgnoreCase("json")) {
type = "json";
} else if (args[1].equalsIgnoreCase("zstd")) {
type = "zstd";
} else {
sendmessage("Please specify the type of compression to use");
return true;
}
File directory = PlayerDataController.instance.getSaveDir();
if (args[0].equalsIgnoreCase("all")) {
sendmessage("Converting all files in the current directory to " + type + " files");
for (File file : directory.listFiles()) {
if (file.isDirectory()) {
continue;
}
if (file.getName().endsWith(".json") && type.equalsIgnoreCase("zstd")) {
submit(() -> {
try {
NBTTagCompound compound = NBTJsonUtil.LoadFile(file);
File compressed = new File(file.getParentFile(), file.getName().replace(".json", ".zstd"));
byte[] bytes = ZstdCompressor.writeCompound(compound);
Files.write(
compressed.toPath(),
bytes,
StandardOpenOption.CREATE,
StandardOpenOption.WRITE
);
} catch (Exception exception) {
exception.printStackTrace();
}
});
}
if (file.getName().endsWith(".zstd") && type.equalsIgnoreCase("json")) {
submit(() -> {
try {
NBTTagCompound compound = ZstdCompressor.readCompressCompound(
new RandomAccessFile(file, "r")
);
File compressed = new File(file.getParentFile(), file.getName().replace(".zstd", ".json"));
NBTJsonUtil.SaveFile(compressed, compound);
} catch (Exception e) {
e.printStackTrace();
}
});
}
}
sendmessage("Done! All files were converted.");
} else {
File file = new File(directory, args[0] + ".json");
if (!file.exists()) {
file = new File(directory, args[0] + ".zstd");
}
if (!file.exists()) {
sendmessage("File not found");
return true;
}
File finalFile = file;
if (file.getName().endsWith(".json")) {
if (type.equalsIgnoreCase("json")) {
sendmessage("File is already in json format");
return true;
}
submit(() -> {
try {
NBTTagCompound compound = NBTJsonUtil.LoadFile(finalFile);
File compressed = new File(finalFile.getParentFile(), finalFile.getName().replace(".json", ".zstd"));
byte[] bytes = ZstdCompressor.writeCompound(compound);
Files.write(
compressed.toPath(),
bytes,
StandardOpenOption.CREATE,
StandardOpenOption.WRITE
);
sendmessage("File compressed to zstd!");
} catch (Exception exception) {
exception.printStackTrace();
}
});
}
if (file.getName().endsWith(".zstd")) {
if (type.equalsIgnoreCase("zstd")) {
sendmessage("File is already in zstd format");
return true;
}
submit(() -> {
try {
NBTTagCompound compound = ZstdCompressor.readCompressCompound(
new RandomAccessFile(finalFile, "r")
);
if (compound == null) {
return;
}
File compressed = new File(finalFile.getParentFile(), finalFile.getName().replace(".zstd", ".json"));
NBTJsonUtil.SaveFile(compressed, compound);
sendmessage("File converted to json!");
} catch (Exception e) {
e.printStackTrace();
}
});
}
}
return true;
}
private void submit(Runnable runnable) throws ExecutionException, InterruptedException, TimeoutException {
CompletableFuture.runAsync(runnable, IO_EXECUTOR).get(5, TimeUnit.MINUTES);
}
}
+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);
} }
} }
+7 -2
View File
@@ -2,7 +2,10 @@ package foxz.command;
import java.util.List; import java.util.List;
import net.minecraft.entity.player.EntityPlayerMP;
import noppes.npcs.EventHooks;
import noppes.npcs.controllers.Faction; import noppes.npcs.controllers.Faction;
import noppes.npcs.controllers.FactionController;
import noppes.npcs.controllers.PlayerData; import noppes.npcs.controllers.PlayerData;
import noppes.npcs.controllers.PlayerFactionData; import noppes.npcs.controllers.PlayerFactionData;
import foxz.commandhelper.ChMcLogger; import foxz.commandhelper.ChMcLogger;
@@ -10,6 +13,8 @@ import foxz.commandhelper.annotations.Command;
import foxz.commandhelper.annotations.SubCommand; import foxz.commandhelper.annotations.SubCommand;
import foxz.commandhelper.permissions.OpOnly; import foxz.commandhelper.permissions.OpOnly;
import foxz.commandhelper.permissions.ParamCheck; import foxz.commandhelper.permissions.ParamCheck;
import noppes.npcs.scripted.entity.ScriptPlayer;
import noppes.npcs.scripted.event.FactionEvent;
@Command( @Command(
name = "faction", name = "faction",
@@ -43,7 +48,7 @@ public class CmdFaction extends ChMcLogger {
for(PlayerData playerdata : data){ for(PlayerData playerdata : data){
PlayerFactionData playerfactiondata = playerdata.factionData; PlayerFactionData playerfactiondata = playerdata.factionData;
playerfactiondata.increasePoints(factionid, points); playerfactiondata.increasePoints(factionid, points, playerdata.player);
} }
return true; return true;
} }
@@ -64,7 +69,7 @@ public class CmdFaction extends ChMcLogger {
int factionid = this.selectedFaction.id; int factionid = this.selectedFaction.id;
for(PlayerData playerdata : data){ for(PlayerData playerdata : data){
PlayerFactionData playerfactiondata = playerdata.factionData; PlayerFactionData playerfactiondata = playerdata.factionData;
playerfactiondata.increasePoints(factionid, -points); playerfactiondata.increasePoints(factionid, -points, playerdata.player);
} }
return true; return true;
} }
+2 -3
View File
@@ -33,12 +33,11 @@ import foxz.commandhelper.annotations.SubCommand;
import foxz.commandhelper.permissions.OpOnly; import foxz.commandhelper.permissions.OpOnly;
import foxz.commandhelper.permissions.ParamCheck; import foxz.commandhelper.permissions.ParamCheck;
import foxz.commandhelper.permissions.PlayerOnly; import foxz.commandhelper.permissions.PlayerOnly;
import foxz.utils.Utils;
@Command( @Command(
name = "noppes", name = "noppes",
desc = "noppes root command", desc = "noppes root command",
sub = {CmdClone.class, CmdScript.class, CmdQuest.class, CmdDialog.class, CmdConfig.class} sub = {CmdClone.class, CmdScript.class, CmdQuest.class, CmdDialog.class, CmdConfig.class, CmdCompressor.class}
) )
public class CmdNoppes extends ChMcLogger { public class CmdNoppes extends ChMcLogger {
@@ -89,7 +88,7 @@ public class CmdNoppes extends ChMcLogger {
return false; return false;
} }
try{ try{
cmdfaction.selectedFaction = FactionController.getInstance().getFaction(Integer.parseInt(factionname)); cmdfaction.selectedFaction = FactionController.getInstance().get(Integer.parseInt(factionname));
} }
catch(NumberFormatException e){ catch(NumberFormatException e){
cmdfaction.selectedFaction = FactionController.getInstance().getFactionFromName(factionname); // get faction data cmdfaction.selectedFaction = FactionController.getInstance().getFactionFromName(factionname); // get faction data
@@ -0,0 +1,61 @@
package luizotavio.compressor;
import com.github.luben.zstd.Zstd;
import net.minecraft.nbt.CompressedStreamTools;
import net.minecraft.nbt.NBTSizeTracker;
import net.minecraft.nbt.NBTTagCompound;
import java.io.*;
public class ZstdCompressor {
public static byte[] readCompressed(DataInput inputStream) throws IOException {
int compressedLength = inputStream.readInt();
int uncompressedLength = inputStream.readInt();
if (compressedLength < 0 || uncompressedLength < 0) {
throw new IllegalArgumentException("Invalid length");
}
byte[] compressed = new byte[compressedLength];
inputStream.readFully(compressed);
return Zstd.decompress(compressed, uncompressedLength);
}
public static NBTTagCompound readCompressCompound(DataInput inputStream) throws IOException {
NBTTagCompound compound;
byte[] compressed = readCompressed(inputStream);
try (DataInputStream dataInputStream = new DataInputStream(new ByteArrayInputStream(compressed))) {
compound = CompressedStreamTools.func_152456_a(dataInputStream, NBTSizeTracker.field_152451_a);
}
return compound;
}
public static byte[] writeCompound(NBTTagCompound compound) throws IOException {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(),
copy = new ByteArrayOutputStream();
try (DataOutputStream dataOutputStream = new DataOutputStream(outputStream)) {
CompressedStreamTools.write(compound, dataOutputStream);
}
byte[] uncompressed = outputStream.toByteArray();
byte[] compress = Zstd.compress(uncompressed);
try (DataOutputStream dataOutputStream = new DataOutputStream(copy)) {
dataOutputStream.writeInt(compress.length);
dataOutputStream.writeInt(uncompressed.length);
dataOutputStream.write(compress);
return copy.toByteArray();
}
}
}
@@ -0,0 +1,16 @@
package luizotavio.compressor.executor;
import java.util.concurrent.ExecutorService;
public class IOExecutor {
/**
* Please, do not change this value unless you know what you are doing.
* This value is used to define the number of threads that will be used to
* compress the files.
*
* If you want to change this value, please, do it with care.
*/
public static ExecutorService IO_EXECUTOR;
}
@@ -4,7 +4,6 @@ import com.google.common.collect.AbstractIterator;
import java.util.Iterator; import java.util.Iterator;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.MathHelper;
import net.minecraft.util.Vec3; import net.minecraft.util.Vec3;
import net.minecraft.util.Vec3i; import net.minecraft.util.Vec3i;
@@ -13,7 +12,7 @@ import net.minecraft.util.Vec3i;
public class BlockPos extends Vec3i{ public class BlockPos extends Vec3i{
/** The BlockPos with all coordinates 0 */ /** The BlockPos with all coordinates 0 */
public static final BlockPos ORIGIN = new BlockPos(0, 0, 0); public static final BlockPos ORIGIN = new BlockPos(0, 0, 0);
private static final int NUM_X_BITS = 1 + MathHelper.calculateLogBaseTwo(MathHelper.roundUpToPowerOfTwo(30000000)); private static final int NUM_X_BITS = 1 + 25;//MathHelper.calculateLogBaseTwo(MathHelper.roundUpToPowerOfTwo(30000000));
private static final int NUM_Z_BITS = NUM_X_BITS; private static final int NUM_Z_BITS = NUM_X_BITS;
private static final int NUM_Y_BITS = 64 - NUM_X_BITS - NUM_Z_BITS; private static final int NUM_Y_BITS = 64 - NUM_X_BITS - NUM_Z_BITS;
private static final int Y_SHIFT = 0 + NUM_Z_BITS; private static final int Y_SHIFT = 0 + NUM_Z_BITS;
+41 -38
View File
@@ -4,32 +4,19 @@ import net.minecraft.client.model.ModelBiped;
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.inventory.Container; import net.minecraft.inventory.Container;
import net.minecraft.inventory.InventoryBasic;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.stats.Achievement;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.util.FakePlayer;
import noppes.npcs.blocks.tiles.TileNpcContainer; import noppes.npcs.blocks.tiles.TileNpcContainer;
import noppes.npcs.constants.EnumGuiType; import noppes.npcs.constants.EnumGuiType;
import noppes.npcs.containers.ContainerCarpentryBench; import noppes.npcs.containers.*;
import noppes.npcs.containers.ContainerCrate; import noppes.npcs.controllers.PlayerData;
import noppes.npcs.containers.ContainerMail; import noppes.npcs.entity.EntityCustomNpc;
import noppes.npcs.containers.ContainerManageBanks;
import noppes.npcs.containers.ContainerManageRecipes;
import noppes.npcs.containers.ContainerMerchantAdd;
import noppes.npcs.containers.ContainerNPCBankLarge;
import noppes.npcs.containers.ContainerNPCBankSmall;
import noppes.npcs.containers.ContainerNPCBankUnlock;
import noppes.npcs.containers.ContainerNPCBankUpgrade;
import noppes.npcs.containers.ContainerNPCCompanion;
import noppes.npcs.containers.ContainerNPCFollower;
import noppes.npcs.containers.ContainerNPCFollowerHire;
import noppes.npcs.containers.ContainerNPCFollowerSetup;
import noppes.npcs.containers.ContainerNPCInv;
import noppes.npcs.containers.ContainerNPCTrader;
import noppes.npcs.containers.ContainerNPCTraderSetup;
import noppes.npcs.containers.ContainerNpcItemGiver;
import noppes.npcs.containers.ContainerNpcQuestReward;
import noppes.npcs.containers.ContainerNpcQuestTypeItem;
import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.entity.EntityNPCInterface;
import cpw.mods.fml.common.network.IGuiHandler; import cpw.mods.fml.common.network.IGuiHandler;
import noppes.npcs.scripted.interfaces.IWorld;
public class CommonProxy implements IGuiHandler { public class CommonProxy implements IGuiHandler {
@@ -41,6 +28,10 @@ public class CommonProxy implements IGuiHandler {
CustomNpcs.ChannelPlayer.register(new PacketHandlerPlayer()); CustomNpcs.ChannelPlayer.register(new PacketHandlerPlayer());
} }
public PlayerData getPlayerData(EntityPlayer player) {
return null;
}
@Override @Override
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
if(ID > EnumGuiType.values().length) if(ID > EnumGuiType.values().length)
@@ -50,36 +41,39 @@ public class CommonProxy implements IGuiHandler {
return getContainer(gui, player, x, y, z, npc); return getContainer(gui, player, x, y, z, npc);
} }
public Container getContainer(EnumGuiType gui,EntityPlayer player, int x, int y, int z,EntityNPCInterface npc){ public Container getContainer(EnumGuiType gui,EntityPlayer player, int x, int y, int z,EntityNPCInterface npc){
if(gui == EnumGuiType.CustomGui)
return new ContainerCustomGui(new InventoryBasic("", false, x));
if(gui == EnumGuiType.MainMenuInv) if(gui == EnumGuiType.MainMenuInv)
return new ContainerNPCInv(npc, player); return new ContainerNPCInv(npc, player);
if(gui == EnumGuiType.PlayerBankSmall) if(gui == EnumGuiType.PlayerBankSmall)
return new ContainerNPCBankSmall(player, x , y); return new ContainerNPCBankSmall(player, x , y);
if(gui == EnumGuiType.PlayerBankUnlock) if(gui == EnumGuiType.PlayerBankUnlock)
return new ContainerNPCBankUnlock(player, x , y); return new ContainerNPCBankUnlock(player, x , y);
if(gui == EnumGuiType.PlayerBankUprade) if(gui == EnumGuiType.PlayerBankUprade)
return new ContainerNPCBankUpgrade(player, x , y); return new ContainerNPCBankUpgrade(player, x , y);
if(gui == EnumGuiType.PlayerBankLarge) if(gui == EnumGuiType.PlayerBankLarge)
return new ContainerNPCBankLarge(player, x , y); return new ContainerNPCBankLarge(player, x , y);
if(gui == EnumGuiType.PlayerFollowerHire) if(gui == EnumGuiType.PlayerFollowerHire)
return new ContainerNPCFollowerHire(npc, player); return new ContainerNPCFollowerHire(npc, player);
if(gui == EnumGuiType.PlayerFollower) if(gui == EnumGuiType.PlayerFollower)
return new ContainerNPCFollower(npc, player); return new ContainerNPCFollower(npc, player);
if(gui == EnumGuiType.PlayerTrader) if(gui == EnumGuiType.PlayerTrader)
return new ContainerNPCTrader(npc, player); return new ContainerNPCTrader(npc, player);
if(gui == EnumGuiType.PlayerAnvil) if(gui == EnumGuiType.PlayerAnvil)
return new ContainerCarpentryBench(player.inventory, player.worldObj, x, y, z); return new ContainerCarpentryBench(player.inventory, player.worldObj, x, y, z);
if(gui == EnumGuiType.SetupItemGiver) if(gui == EnumGuiType.SetupItemGiver)
return new ContainerNpcItemGiver(npc, player); return new ContainerNpcItemGiver(npc, player);
if(gui == EnumGuiType.SetupTrader) if(gui == EnumGuiType.SetupTrader)
return new ContainerNPCTraderSetup(npc, player); return new ContainerNPCTraderSetup(npc, player);
@@ -88,10 +82,10 @@ public class CommonProxy implements IGuiHandler {
if(gui == EnumGuiType.QuestReward) if(gui == EnumGuiType.QuestReward)
return new ContainerNpcQuestReward(player); return new ContainerNpcQuestReward(player);
if(gui == EnumGuiType.QuestItem) if(gui == EnumGuiType.QuestItem)
return new ContainerNpcQuestTypeItem(player); return new ContainerNpcQuestTypeItem(player);
if(gui == EnumGuiType.ManageRecipes) if(gui == EnumGuiType.ManageRecipes)
return new ContainerManageRecipes(player,x); return new ContainerManageRecipes(player,x);
@@ -103,13 +97,13 @@ public class CommonProxy implements IGuiHandler {
if(gui == EnumGuiType.Crate) if(gui == EnumGuiType.Crate)
return new ContainerCrate(player.inventory, (TileNpcContainer)player.worldObj.getTileEntity(x, y, z)); return new ContainerCrate(player.inventory, (TileNpcContainer)player.worldObj.getTileEntity(x, y, z));
if(gui == EnumGuiType.PlayerMailman) if(gui == EnumGuiType.PlayerMailman)
return new ContainerMail(player, x == 1, y == 1); return new ContainerMail(player, x == 1, y == 1);
if(gui == EnumGuiType.CompanionInv) if(gui == EnumGuiType.CompanionInv)
return new ContainerNPCCompanion(npc, player); return new ContainerNPCCompanion(npc, player);
return null; return null;
} }
@@ -129,19 +123,21 @@ public class CommonProxy implements IGuiHandler {
public void openGui(int i, int j, int k, EnumGuiType gui, EntityPlayer player) { public void openGui(int i, int j, int k, EnumGuiType gui, EntityPlayer player) {
} }
public void openGui(EntityPlayer player, Object guiscreen) { public void openGui(EntityPlayer player, Object guiscreen) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
} }
public void spawnParticle(EntityLivingBase player, String string, Object... ob) { public void spawnParticle(EntityLivingBase player, String string, Object... ob) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
} }
public FakePlayer getCommandPlayer(IWorld world) { return null; }
public boolean hasClient() { public boolean hasClient() {
return false; return false;
} }
@@ -152,7 +148,7 @@ public class CommonProxy implements IGuiHandler {
public void registerItem(Item item) { public void registerItem(Item item) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
} }
public ModelBiped getSkirtModel() { public ModelBiped getSkirtModel() {
@@ -160,8 +156,15 @@ public class CommonProxy implements IGuiHandler {
} }
public void spawnParticle(String particle, double x, double y, double z, public void spawnParticle(String particle, double x, double y, double z,
double motionX, double motionY, double motionZ, float scale) { double motionX, double motionY, double motionZ, float scale) {
} }
} public String getAchievementDesc(Achievement achievement) {
return "";
}
public boolean isGUIOpen(){
return false;
}
}
+3 -2
View File
@@ -445,6 +445,9 @@ public class CustomItems {
Item.getItemFromBlock(sign).setHasSubtypes(true); Item.getItemFromBlock(sign).setHasSubtypes(true);
Item.getItemFromBlock(beam).setHasSubtypes(true); Item.getItemFromBlock(beam).setHasSubtypes(true);
Item.getItemFromBlock(pedestal).setHasSubtypes(true); Item.getItemFromBlock(pedestal).setHasSubtypes(true);
tabBlocks.item = Item.getItemFromBlock(couchWool);
tabBlocks.meta = 1;
} }
banjo = new ItemMusicBanjo().setUnlocalizedName("npcBanjo").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcBanjo"); banjo = new ItemMusicBanjo().setUnlocalizedName("npcBanjo").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcBanjo");
@@ -887,8 +890,6 @@ public class CustomItems {
tabArmor.item = cowarmor; tabArmor.item = cowarmor;
tabWeapon.item = CustomItems.shuriken; tabWeapon.item = CustomItems.shuriken;
tabMisc.item = CustomItems.coinGold; tabMisc.item = CustomItems.coinGold;
tabBlocks.item = Item.getItemFromBlock(couchWool);
tabBlocks.meta = 1;
} }
tab.item = wand; tab.item = wand;
+95 -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;
@@ -12,6 +10,7 @@ import cpw.mods.fml.common.network.FMLEventChannel;
import cpw.mods.fml.common.network.NetworkRegistry; import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.registry.EntityRegistry; import cpw.mods.fml.common.registry.EntityRegistry;
import foxz.command.CommandNoppes; import foxz.command.CommandNoppes;
import luizotavio.compressor.executor.IOExecutor;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockIce; import net.minecraft.block.BlockIce;
import net.minecraft.block.BlockLeavesBase; import net.minecraft.block.BlockLeavesBase;
@@ -25,55 +24,53 @@ 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.scripted.wrapper.WrapperNpcAPI;
import noppes.npcs.entity.old.EntityNPCElfFemale; import java.io.File;
import noppes.npcs.entity.old.EntityNPCElfMale; import java.util.Set;
import noppes.npcs.entity.old.EntityNPCEnderman; import java.util.concurrent.Executors;
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;
@Mod(modid = "customnpcs", name = "CustomNpcs", version = "1.2.1") @Mod(modid = "customnpcs", name = "CustomNpcs", version = "1.5.3")
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 = "Navigation search range for NPCs. Not recommended to increase if you have a slow pc or on a server") @ConfigProp(info = "*BACKUP BEFORE CHANGING* File Type used with PlayerData. Converting files may reduce lag. To convert existing files: /noppes compressor update [<filename>|all] [json|zstd]")
public static String CompressorType = "json";
@ConfigProp(info = "The size of IO executors used for compression and decompression. This is the number of threads used for compression and decompression. If you are experiencing issues with the server lagging/crashing, try changing this to a higher number.")
public static int CompressorThreads = 2;
@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.")
public static int NpcNavRange = 32; public static int NpcNavRange = 32;
@ConfigProp(info = "Size limit for NPCs. Default 100, larger sizes may cause lag on clients and servers that can't take it!")
public static int NpcSizeLimit = 100;
@ConfigProp(info = "Set to true if you want the dialog command option to be able to use op commands like tp etc") @ConfigProp(info = "Set to true if you want the dialog command option to be able to use op commands like tp etc")
public static boolean NpcUseOpCommands = false; public static boolean NpcUseOpCommands = false;
@ConfigProp(info = "The amount of time that passes before a player's quests are checked for completion in seconds.")
public static int PlayerQuestCheck = 300;
@ConfigProp @ConfigProp
public static boolean InventoryGuiEnabled = true; public static boolean InventoryGuiEnabled = true;
@@ -166,6 +163,16 @@ public class CustomNpcs {
if (NpcNavRange < 16) { if (NpcNavRange < 16) {
NpcNavRange = 16; NpcNavRange = 16;
} }
if (NpcNavRange > 96) {
NpcNavRange = 96;
}
if(NpcSizeLimit < 1)
NpcSizeLimit = 1;
if(PlayerQuestCheck < 1)
PlayerQuestCheck = 1;
EnchantInterface.load(); EnchantInterface.load();
CustomItems.load(); CustomItems.load();
@@ -175,6 +182,14 @@ public class CustomNpcs {
MinecraftForge.EVENT_BUS.register(new ServerEventsHandler()); MinecraftForge.EVENT_BUS.register(new ServerEventsHandler());
MinecraftForge.EVENT_BUS.register(new ScriptController()); MinecraftForge.EVENT_BUS.register(new ScriptController());
ScriptPlayerEventHandler scriptPlayerEventHandler = new ScriptPlayerEventHandler();
MinecraftForge.EVENT_BUS.register(scriptPlayerEventHandler);
FMLCommonHandler.instance().bus().register(scriptPlayerEventHandler);
ScriptForgeEventHandler forgeEventHandler = (new ScriptForgeEventHandler()).registerForgeEvents();
MinecraftForge.EVENT_BUS.register(forgeEventHandler);
FMLCommonHandler.instance().bus().register(forgeEventHandler);
FMLCommonHandler.instance().bus().register(new ServerTickHandler()); FMLCommonHandler.instance().bus().register(new ServerTickHandler());
registerNpc(EntityNPCHumanMale.class, "npchumanmale"); registerNpc(EntityNPCHumanMale.class, "npchumanmale");
@@ -202,14 +217,19 @@ public class CustomNpcs {
registerNpc(EntityNPCGolem.class, "npcGolem"); registerNpc(EntityNPCGolem.class, "npcGolem");
registerNpc(EntityCustomNpc.class, "CustomNpc"); registerNpc(EntityCustomNpc.class, "CustomNpc");
IOExecutor.IO_EXECUTOR = Executors.newFixedThreadPool(
CompressorThreads,
new ThreadFactoryBuilder()
.setNameFormat("CustomNpcs-IO-%d")
.build()
);
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();
@@ -244,7 +264,11 @@ public class CustomNpcs {
new SpawnController(); new SpawnController();
new LinkedNpcController(); new LinkedNpcController();
ScriptController.Instance.loadStoredData(); ScriptController.Instance.loadStoredData();
ScriptController.Instance.loadForgeScripts();
ScriptController.Instance.loadNPCScripts();
ScriptController.Instance.loadPlayerScripts();
ScriptController.HasStart = false; ScriptController.HasStart = false;
WrapperNpcAPI.clearCache();
Set<String> names = Block.blockRegistry.getKeys(); Set<String> names = Block.blockRegistry.getKeys();
for(String name : names){ for(String name : names){
@@ -308,4 +332,33 @@ public class CustomNpcs {
return null; return null;
} }
public static File getWorldSaveDirectory(String s) {
try {
File dir = new File(".");
if (getServer() != null) {
if (!getServer().isDedicatedServer()) {
dir = new File(Minecraft.getMinecraft().mcDataDir, "saves");
}
dir = new File(new File(dir, getServer().getFolderName()), "customnpcs");
}
if (s != null) {
dir = new File(dir, s);
}
if (!dir.exists()) {
dir.mkdirs();
}
return dir;
} catch (Exception var2) {
LogWriter.error("Error getting worldsave", var2);
return null;
}
}
public static MinecraftServer getServer(){
return MinecraftServer.getServer();
}
} }
+31 -2
View File
@@ -35,6 +35,10 @@ public class DataAI {
// Fly Change // Fly Change
public int movementType = 0; public int movementType = 0;
public double flySpeed = 1.0D;
public double flyGravity = 0.0D;
public boolean hasFlyLimit = true;
public int flyHeightLimit = 2;
public EnumAnimation animationType = EnumAnimation.NONE; public EnumAnimation animationType = EnumAnimation.NONE;
public EnumStandingType standingType = EnumStandingType.RotateBody; public EnumStandingType standingType = EnumStandingType.RotateBody;
@@ -96,8 +100,28 @@ public class DataAI {
setMovingPath(NBTTags.getIntegerArraySet(compound.getTagList("MovingPathNew",10))); setMovingPath(NBTTags.getIntegerArraySet(compound.getTagList("MovingPathNew",10)));
movingPos = compound.getInteger("MovingPos"); movingPos = compound.getInteger("MovingPos");
movingPattern = compound.getInteger("MovingPatern"); movingPattern = compound.getInteger("MovingPatern");
movementType = compound.getInteger("MovingType"); movementType = compound.getInteger("MovingType");
if(!compound.hasKey("FlySpeed"))
flySpeed = 1.0D;
else
flySpeed = compound.getDouble("FlySpeed");
if(!compound.hasKey("FlyGravity"))
flyGravity = 0.0D;
else
flyGravity = compound.getDouble("FlyGravity");
if(!compound.hasKey("HasFlyLimit"))
hasFlyLimit = false;
else
hasFlyLimit = compound.getBoolean("HasFlyLimit");
if(!compound.hasKey("FlyHeightLimit"))
flyHeightLimit = 5;
else
flyHeightLimit = compound.getInteger("FlyHeightLimit");
startPos = compound.getIntArray("StartPosNew"); startPos = compound.getIntArray("StartPosNew");
if (startPos == null || startPos.length != 3){ if (startPos == null || startPos.length != 3){
startPos = new int[] { startPos = new int[] {
@@ -143,8 +167,13 @@ public class DataAI {
compound.setTag("MovingPathNew", NBTTags.nbtIntegerArraySet(movingPath)); compound.setTag("MovingPathNew", NBTTags.nbtIntegerArraySet(movingPath));
compound.setInteger("MovingPos", movingPos); compound.setInteger("MovingPos", movingPos);
compound.setInteger("MovingPatern", movingPattern); compound.setInteger("MovingPatern", movingPattern);
compound.setInteger("MovingType", movementType); compound.setInteger("MovingType", movementType);
compound.setDouble("FlySpeed",flySpeed);
compound.setDouble("FlyGravity",flyGravity);
compound.setBoolean("HasFlyLimit",hasFlyLimit);
compound.setInteger("FlyHeightLimit", flyHeightLimit);
npc.setAvoidWater(avoidsWater); npc.setAvoidWater(avoidsWater);
compound.setIntArray("StartPosNew", npc.getStartPos()); compound.setIntArray("StartPosNew", npc.getStartPos());
+42 -33
View File
@@ -1,8 +1,15 @@
package noppes.npcs; package noppes.npcs;
import java.util.ArrayList;
import java.util.List;
import java.util.Random; import java.util.Random;
import java.util.UUID;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.nbt.NBTTagString;
import net.minecraft.nbt.NBTUtil; import net.minecraft.nbt.NBTUtil;
import net.minecraft.server.MinecraftServer; import net.minecraft.server.MinecraftServer;
import net.minecraft.util.StringUtils; import net.minecraft.util.StringUtils;
@@ -43,42 +50,15 @@ public class DataDisplay {
public byte showBossBar = 0; public byte showBossBar = 0;
public ArrayList<UUID> invisibleToList = new ArrayList<>();
//0 - Yes, 1 - No, 2 - Only NPCs, 3 - Only Players, 4 - NPCs and Players
public int collidesWith = 1;
public DataDisplay(EntityNPCInterface npc){ public DataDisplay(EntityNPCInterface npc){
this.npc = npc; this.npc = npc;
/*
Implementing MarkovNames generator. You can blame this blunder on Nikedemos.
Please refer to nikedemos.markovnames.generators.MarkovCustomNPCsClassic.java
String[] names = { "Noppes", "Noppes", "Noppes", "Noppes", "Atesson",
"Rothcersul", "Achdranys", "Pegato", "Chald", "Gareld",
"Nalworche", "Ineald", "Tia'kim", "Torerod", "Turturdar",
"Ranler", "Dyntan", "Oldrake", "Gharis", "Elmn", "Tanal",
"Waran-ess", "Ach-aldhat", "Athi", "Itageray", "Tasr",
"Ightech", "Gakih", "Adkal", "Qua'an", "Sieq", "Urnp", "Rods",
"Vorbani", "Smaik", "Fian", "Hir", "Ristai", "Kineth", "Naif",
"Issraya", "Arisotura", "Honf", "Rilfom", "Estz", "Ghatroth",
"Yosil", "Darage", "Aldny", "Tyltran", "Armos", "Loxiku",
"Burhat", "Tinlt", "Ightyd", "Mia",
"Ken", "Karla", "Lily", "Carina", "Daniel", "Slater", "Zidane", "Valentine", "Eirina",
"Carnow", "Grave", "Shadow", "Drakken", "Kaoz", "Silk", "Drake", "Oldam", "Lynxx", "Lenyx",
"Winter", "Seth", "Apolitho", "Amethyst", "Ankin", "Seinkan", "Ayumu", "Sakamoto", "Divina",
"Div", "Magia", "Magnus", "Tiakono", "Ruin", "Hailinx", "Ethan", "Wate", "Carter", "William",
"Brion", "Sparrow", "Basrrelen", "Gyaku", "Claire", "Crowfeather", "Blackwell", "Raven", "Farcri",
"Lucas", "Bangheart", "Kamoku", "Kyoukan", "Blaze", "Benjamin", "Larianne", "Kakaragon",
"Melancholy", "Epodyno", "Thanato", "Mika", "Dacks", "Ylander", "Neve", "Meadow", "Cuero",
"Embrera", "Eldamore", "Faolan", "Chim", "Nasu", "Kathrine", "Ariel", "Arei", "Demytrix",
"Kora", "Ava", "Larson", "Leonardo", "Wyrl", "Sakiama", "Lambton", "Kederath", "Malus", "Riplette",
"Andern", "Ezall", "Lucien", "Droco", "Cray", "Tymen", "Zenix", "Entranger",
"Saenorath", "Chris", "Christine", "Marble", "Mable", "Ross", "Rose", "Xalgan ", "Kennet", "Kamkeel"
};
name = names[new Random().nextInt(names.length)];
*/
markovGeneratorId = new Random().nextInt(CustomNpcs.MARKOV_GENERATOR.length-1); markovGeneratorId = new Random().nextInt(CustomNpcs.MARKOV_GENERATOR.length-1);
name = getRandomName(); name = getRandomName();
} }
public String getRandomName() { public String getRandomName() {
@@ -112,6 +92,15 @@ public class DataDisplay {
nbttagcompound.setBoolean("NoLivingAnimation", disableLivingAnimation); nbttagcompound.setBoolean("NoLivingAnimation", disableLivingAnimation);
nbttagcompound.setByte("BossBar", showBossBar); nbttagcompound.setByte("BossBar", showBossBar);
nbttagcompound.setInteger("CollidesWith",collidesWith);
NBTTagList list = new NBTTagList();
for(UUID uuid : invisibleToList){
list.appendTag(new NBTTagString(uuid.toString()));
}
nbttagcompound.setTag("InvisibleToList", list);
return nbttagcompound; return nbttagcompound;
} }
public void readToNBT(NBTTagCompound nbttagcompound) { public void readToNBT(NBTTagCompound nbttagcompound) {
@@ -143,7 +132,10 @@ public class DataDisplay {
cloakTexture = nbttagcompound.getString("CloakTexture"); cloakTexture = nbttagcompound.getString("CloakTexture");
glowTexture = nbttagcompound.getString("GlowTexture"); glowTexture = nbttagcompound.getString("GlowTexture");
modelSize = ValueUtil.CorrectInt(nbttagcompound.getInteger("Size"), 1, 30); modelSize = ValueUtil.CorrectInt(nbttagcompound.getInteger("Size"), 1, Integer.MAX_VALUE);
if(modelSize > CustomNpcs.NpcSizeLimit)
modelSize = CustomNpcs.NpcSizeLimit;
modelType = nbttagcompound.getInteger("modelType"); modelType = nbttagcompound.getInteger("modelType");
showName = nbttagcompound.getInteger("ShowName"); showName = nbttagcompound.getInteger("ShowName");
@@ -152,6 +144,23 @@ public class DataDisplay {
disableLivingAnimation = nbttagcompound.getBoolean("NoLivingAnimation"); disableLivingAnimation = nbttagcompound.getBoolean("NoLivingAnimation");
showBossBar = nbttagcompound.getByte("BossBar"); showBossBar = nbttagcompound.getByte("BossBar");
NBTTagList tagList = (NBTTagList)nbttagcompound.getTag("InvisibleToList");
if(tagList != null) {
invisibleToList.clear();
for (int i = 0; i < tagList.tagCount(); i++) {
String nbtTagString = tagList.getStringTagAt(i);
invisibleToList.add(UUID.fromString(nbtTagString));
}
}
else {
invisibleToList = new ArrayList<>();
}
if(nbttagcompound.hasKey("CollidesWith"))
collidesWith = nbttagcompound.getInteger("CollidesWith");
else
collidesWith = 1;
if(prevSkinType != skinType || !texture.equals(prevTexture)) if(prevSkinType != skinType || !texture.equals(prevTexture))
npc.textureLocation = null; npc.textureLocation = null;
npc.textureGlowLocation = null; npc.textureGlowLocation = null;
+15 -5
View File
@@ -18,7 +18,7 @@ import noppes.npcs.entity.EntityNPCInterface;
public class DataInventory implements IInventory{ public class DataInventory implements IInventory{
public HashMap<Integer,ItemStack> items = new HashMap<Integer,ItemStack>(); public HashMap<Integer,ItemStack> items = new HashMap<Integer,ItemStack>();
public HashMap<Integer,Integer> dropchance = new HashMap<Integer,Integer>(); public HashMap<Integer,Double> dropchance = new HashMap<Integer,Double>();
public HashMap<Integer, ItemStack> weapons = new HashMap<Integer, ItemStack>(); public HashMap<Integer, ItemStack> weapons = new HashMap<Integer, ItemStack>();
public HashMap<Integer, ItemStack> armor = new HashMap<Integer, ItemStack>(); public HashMap<Integer, ItemStack> armor = new HashMap<Integer, ItemStack>();
@@ -38,7 +38,7 @@ public class DataInventory implements IInventory{
nbttagcompound.setTag("NpcInv", NBTTags.nbtItemStackList(items)); nbttagcompound.setTag("NpcInv", NBTTags.nbtItemStackList(items));
nbttagcompound.setTag("Armor", NBTTags.nbtItemStackList(getArmor())); nbttagcompound.setTag("Armor", NBTTags.nbtItemStackList(getArmor()));
nbttagcompound.setTag("Weapons", NBTTags.nbtItemStackList(getWeapons())); nbttagcompound.setTag("Weapons", NBTTags.nbtItemStackList(getWeapons()));
nbttagcompound.setTag("DropChance", NBTTags.nbtIntegerIntegerMap(dropchance)); nbttagcompound.setTag("DoubleDropChance", NBTTags.nbtIntegerDoubleMap(dropchance));
nbttagcompound.setInteger("LootMode", lootMode); nbttagcompound.setInteger("LootMode", lootMode);
return nbttagcompound; return nbttagcompound;
@@ -49,7 +49,17 @@ public class DataInventory implements IInventory{
items = NBTTags.getItemStackList(nbttagcompound.getTagList("NpcInv", 10)); items = NBTTags.getItemStackList(nbttagcompound.getTagList("NpcInv", 10));
setArmor(NBTTags.getItemStackList(nbttagcompound.getTagList("Armor", 10))); setArmor(NBTTags.getItemStackList(nbttagcompound.getTagList("Armor", 10)));
setWeapons(NBTTags.getItemStackList(nbttagcompound.getTagList("Weapons", 10))); setWeapons(NBTTags.getItemStackList(nbttagcompound.getTagList("Weapons", 10)));
dropchance = NBTTags.getIntegerIntegerMap(nbttagcompound.getTagList("DropChance", 10));
if(!nbttagcompound.hasKey("DoubleDropChance")) {
dropchance.clear();
HashMap<Integer, Integer> oldDropChance = NBTTags.getIntegerIntegerMap(nbttagcompound.getTagList("DropChance", 10));
for(int i = 0; i < oldDropChance.entrySet().size(); i++){
dropchance.put(i, Double.valueOf(oldDropChance.get(i)));
}
} else {
dropchance = NBTTags.getIntegerDoubleMap(nbttagcompound.getTagList("DoubleDropChance", 10));
}
lootMode = nbttagcompound.getInteger("LootMode"); lootMode = nbttagcompound.getInteger("LootMode");
} }
public HashMap<Integer, ItemStack> getWeapons() { public HashMap<Integer, ItemStack> getWeapons() {
@@ -89,10 +99,10 @@ public class DataInventory implements IInventory{
ItemStack item = items.get(i); ItemStack item = items.get(i);
if(item == null) if(item == null)
continue; continue;
int dchance = 100; double dchance = 100;
if(dropchance.containsKey(i)) if(dropchance.containsKey(i))
dchance = dropchance.get(i); dchance = dropchance.get(i);
int chance = npc.worldObj.rand.nextInt(100) + dchance; double chance = Math.random()*100 + dchance;
if(chance >= 100){ if(chance >= 100){
EntityItem e = getEntityItem(item.copy()); EntityItem e = getEntityItem(item.copy());
if(e != null) if(e != null)
+107 -24
View File
@@ -1,10 +1,10 @@
package noppes.npcs; package noppes.npcs;
import java.util.HashMap; import java.util.*;
import java.util.Map;
import javax.script.ScriptEngine; import javax.script.ScriptEngine;
import cpw.mods.fml.common.eventhandler.Event;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList; import net.minecraft.nbt.NBTTagList;
@@ -12,18 +12,23 @@ import net.minecraft.world.World;
import net.minecraft.world.WorldServer; import net.minecraft.world.WorldServer;
import noppes.npcs.constants.EnumScriptType; import noppes.npcs.constants.EnumScriptType;
import noppes.npcs.controllers.ScriptContainer; import noppes.npcs.controllers.ScriptContainer;
import noppes.npcs.controllers.IScriptHandler;
import noppes.npcs.controllers.ScriptController; import noppes.npcs.controllers.ScriptController;
import noppes.npcs.entity.EntityCustomNpc; import noppes.npcs.entity.EntityCustomNpc;
import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.scripted.ScriptEvent; import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.scripted.ScriptNpc; import noppes.npcs.scripted.event.ScriptEvent;
import noppes.npcs.scripted.entity.ScriptNpc;
import noppes.npcs.scripted.ScriptWorld; import noppes.npcs.scripted.ScriptWorld;
import noppes.npcs.scripted.constants.EntityType; import noppes.npcs.scripted.constants.EntityType;
import noppes.npcs.scripted.constants.JobType; import noppes.npcs.scripted.constants.JobType;
import noppes.npcs.scripted.constants.RoleType; import noppes.npcs.scripted.constants.RoleType;
import noppes.npcs.scripted.interfaces.ICustomNpc;
import noppes.npcs.scripted.interfaces.IWorld;
import noppes.npcs.scripted.wrapper.WrapperNpcAPI;
public class DataScript { public class DataScript implements IScriptHandler {
public Map<Integer,ScriptContainer> scripts = new HashMap<Integer,ScriptContainer>(); public List<ScriptContainer> scripts = new ArrayList();
private final static EntityType entities = new EntityType(); private final static EntityType entities = new EntityType();
private final static JobType jobs = new JobType(); private final static JobType jobs = new JobType();
private final static RoleType roles = new RoleType(); private final static RoleType roles = new RoleType();
@@ -32,18 +37,22 @@ public class DataScript {
private EntityNPCInterface npc; private EntityNPCInterface npc;
public boolean enabled = false; public boolean enabled = false;
public ScriptNpc dummyNpc; public ICustomNpc dummyNpc;
public ScriptWorld dummyWorld; public IWorld dummyWorld;
public boolean clientNeedsUpdate = false; public boolean clientNeedsUpdate = false;
public boolean aiNeedsUpdate = false; public boolean aiNeedsUpdate = false;
public boolean hasInited = false; public boolean hasInited = false;
public DataScript(EntityNPCInterface npc) { public DataScript(EntityNPCInterface npc) {
for (int i = 0; i < 12; i++) {
scripts.add(new ScriptContainer(this));
}
this.npc = npc; this.npc = npc;
if(npc instanceof EntityCustomNpc) dummyNpc = new ScriptNpc<>(npc);
dummyNpc = new ScriptNpc((EntityCustomNpc) npc);
if(npc.worldObj instanceof WorldServer) if(npc.worldObj instanceof WorldServer)
dummyWorld = new ScriptWorld((WorldServer) npc.worldObj); dummyWorld = NpcAPI.Instance().getIWorld((WorldServer) npc.worldObj);//new ScriptWorld((WorldServer) npc.worldObj);
} }
public void readFromNBT(NBTTagCompound compound) { public void readFromNBT(NBTTagCompound compound) {
@@ -59,21 +68,25 @@ public class DataScript {
return compound; return compound;
} }
private Map<Integer,ScriptContainer> readScript(NBTTagList list){ private List<ScriptContainer> readScript(NBTTagList list){
Map<Integer,ScriptContainer> scripts = new HashMap<Integer,ScriptContainer>(); List<ScriptContainer> scripts = new ArrayList<>();
for (int i = 0; i < 12; i++) {
scripts.add(new ScriptContainer(this));
}
for(int i = 0; i < list.tagCount(); i++){ for(int i = 0; i < list.tagCount(); i++){
NBTTagCompound compoundd = list.getCompoundTagAt(i); NBTTagCompound compoundd = list.getCompoundTagAt(i);
ScriptContainer script = new ScriptContainer(); ScriptContainer script = new ScriptContainer(this);
script.readFromNBT(compoundd); script.readFromNBT(compoundd);
if(script.hasCode() || npc.isRemote()) if(script.hasCode() || npc.isRemote())
scripts.put(compoundd.getInteger("Type"), script); scripts.set(compoundd.getInteger("Type"), script);
} }
return scripts; return scripts;
} }
private NBTTagList writeScript(Map<Integer,ScriptContainer> scripts){ private NBTTagList writeScript(List<ScriptContainer> scripts){
NBTTagList list = new NBTTagList(); NBTTagList list = new NBTTagList();
for(Integer type : scripts.keySet()){ for(int type = 0; type < scripts.size(); type++){
NBTTagCompound compoundd = new NBTTagCompound(); NBTTagCompound compoundd = new NBTTagCompound();
compoundd.setInteger("Type", type); compoundd.setInteger("Type", type);
ScriptContainer script = scripts.get(type); ScriptContainer script = scripts.get(type);
@@ -96,6 +109,7 @@ public class DataScript {
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());
@@ -113,11 +127,7 @@ public class DataScript {
return callScript(script); return callScript(script);
} }
public boolean isEnabled(){
return enabled && ScriptController.HasStart && !npc.worldObj.isRemote && !scripts.isEmpty();
}
private boolean callScript(ScriptContainer script){ private boolean callScript(ScriptContainer script){
ScriptEngine engine = script.engine; ScriptEngine engine = script.engine;
engine.put("npc", dummyNpc); engine.put("npc", dummyNpc);
@@ -125,11 +135,12 @@ public class DataScript {
ScriptEvent result = (ScriptEvent) engine.get("event"); ScriptEvent result = (ScriptEvent) engine.get("event");
if(result == null) if(result == null)
engine.put("event", result = new ScriptEvent()); engine.put("event", result = new ScriptEvent());
engine.put("API", new WrapperNpcAPI());
engine.put("EntityType", entities); engine.put("EntityType", entities);
engine.put("RoleType", roles); engine.put("RoleType", roles);
engine.put("JobType", jobs); engine.put("JobType", jobs);
script.run(engine); script.run(engine);
if(clientNeedsUpdate){ if(clientNeedsUpdate){
npc.updateClient = true; npc.updateClient = true;
clientNeedsUpdate = false; clientNeedsUpdate = false;
@@ -140,6 +151,78 @@ public class DataScript {
} }
return result.isCancelled(); return result.isCancelled();
} }
public boolean isEnabled(){
return enabled && ScriptController.HasStart && !npc.worldObj.isRemote && !scripts.isEmpty();
}
public void callScript(EnumScriptType var1, Event var2, Object... obs) {
}
public Map<Long, String> getConsoleText() {
Map<Long, String> map = new TreeMap();
int tab = 0;
Iterator var3 = this.getScripts().iterator();
while(var3.hasNext()) {
ScriptContainer script = (ScriptContainer)var3.next();
++tab;
Iterator var5 = script.console.entrySet().iterator();
while(var5.hasNext()) {
Map.Entry<Long, String> entry = (Map.Entry)var5.next();
map.put(entry.getKey(), " tab " + tab + ":\n" + (String)entry.getValue());
}
}
return map;
}
public void clearConsole() {
Iterator var1 = this.getScripts().iterator();
while(var1.hasNext()) {
ScriptContainer script = (ScriptContainer)var1.next();
script.console.clear();
}
}
@Override
public void callScript(EnumScriptType var1, Event var2) {
}
public boolean isClient() {
return this.npc.isRemote();
}
public boolean getEnabled() {
return this.enabled;
}
public void setEnabled(boolean bo) {
this.enabled = bo;
}
public String getLanguage() {
return this.scriptLanguage;
}
public void setLanguage(String lang) {
this.scriptLanguage = lang;
}
public List<ScriptContainer> getScripts() {
return this.scripts;
}
public String noticeString() {
//BlockPos pos = this.npc.func_180425_c();
//return MoreObjects.toStringHelper(this.npc).add("x", pos.func_177958_n()).add("y", pos.func_177956_o()).add("z", pos.func_177952_p()).toString();
return "";
}
public void setWorld(World world) { public void setWorld(World world) {
if(world instanceof WorldServer) if(world instanceof WorldServer)
+25 -21
View File
@@ -8,9 +8,12 @@ import noppes.npcs.constants.EnumPotionType;
import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.util.ValueUtil; import noppes.npcs.util.ValueUtil;
import java.math.RoundingMode;
import java.text.DecimalFormat;
public class DataStats { public class DataStats {
private int attackStrength = 5; private float attackStrength = 5;
public int attackSpeed = 20, attackRange = 2, knockback = 0; public int attackSpeed = 20, attackRange = 2, knockback = 0;
public int minDelay = 20, maxDelay = 40, rangedRange = 15, fireRate = 5, burstCount = 1, shotCount = 1, accuracy = 60; public int minDelay = 20, maxDelay = 40, rangedRange = 15, fireRate = 5, burstCount = 1, shotCount = 1, accuracy = 60;
public int aggroRange = 16; public int aggroRange = 16;
@@ -19,7 +22,7 @@ public class DataStats {
public int potionDuration = 5; //20 = 1 second public int potionDuration = 5; //20 = 1 second
public int potionAmp = 0; public int potionAmp = 0;
public int maxHealth = 20; public double maxHealth = 20;
public int respawnTime = 20; public int respawnTime = 20;
public int spawnCycle = 0; public int spawnCycle = 0;
public boolean hideKilledBody = false; public boolean hideKilledBody = false;
@@ -32,10 +35,11 @@ public class DataStats {
public boolean canDrown = true; public boolean canDrown = true;
public boolean burnInSun = false; public boolean burnInSun = false;
public boolean noFallDamage = false; public boolean noFallDamage = false;
public int healthRegen = 1; public float healthRegen = 1;
public int combatRegen = 0; public float combatRegen = 0;
public int pDamage = 4, pImpact = 0, pSize = 5, pSpeed = 10, pArea = 0, pDur = 5; public float pDamage = 4;
public int pImpact = 0, pSize = 5, pSpeed = 10, pArea = 0, pDur = 5;
public boolean pPhysics = true, pXlr8 = false, pGlows = false, pExplode = false; public boolean pPhysics = true, pXlr8 = false, pGlows = false, pExplode = false;
public boolean pRender3D = false, pSpin = false, pStick = false; public boolean pRender3D = false, pSpin = false, pStick = false;
public EnumPotionType pEffect = EnumPotionType.None; public EnumPotionType pEffect = EnumPotionType.None;
@@ -55,16 +59,16 @@ public class DataStats {
public NBTTagCompound writeToNBT(NBTTagCompound compound) public NBTTagCompound writeToNBT(NBTTagCompound compound)
{ {
compound.setTag("Resistances", resistances.writeToNBT()); compound.setTag("Resistances", resistances.writeToNBT());
compound.setInteger("MaxHealth", maxHealth); compound.setDouble("MaxHealth", maxHealth);
compound.setInteger("AggroRange", aggroRange); compound.setInteger("AggroRange", aggroRange);
compound.setBoolean("HideBodyWhenKilled", hideKilledBody); compound.setBoolean("HideBodyWhenKilled", hideKilledBody);
compound.setInteger("RespawnTime", respawnTime); compound.setInteger("RespawnTime", respawnTime);
compound.setInteger("SpawnCycle", spawnCycle); compound.setInteger("SpawnCycle", spawnCycle);
compound.setInteger("CreatureType", creatureType.ordinal()); compound.setInteger("CreatureType", creatureType.ordinal());
compound.setInteger("HealthRegen", healthRegen); compound.setFloat("HealthRegen", healthRegen);
compound.setInteger("CombatRegen", combatRegen); compound.setFloat("CombatRegen", combatRegen);
compound.setInteger("AttackStrenght", attackStrength); compound.setFloat("AttackStrenght", attackStrength);
compound.setInteger("AttackRange", attackRange); compound.setInteger("AttackRange", attackRange);
compound.setInteger("AttackSpeed", attackSpeed); compound.setInteger("AttackSpeed", attackSpeed);
compound.setInteger("KnockBack", knockback); compound.setInteger("KnockBack", knockback);
@@ -80,7 +84,7 @@ public class DataStats {
compound.setInteger("ShotCount", shotCount); compound.setInteger("ShotCount", shotCount);
compound.setInteger("Accuracy", accuracy); compound.setInteger("Accuracy", accuracy);
compound.setInteger("pDamage", pDamage); compound.setFloat("pDamage", pDamage);
compound.setInteger("pImpact", pImpact); compound.setInteger("pImpact", pImpact);
compound.setInteger("pSize", pSize); compound.setInteger("pSize", pSize);
compound.setInteger("pSpeed", pSpeed); compound.setInteger("pSpeed", pSpeed);
@@ -113,16 +117,16 @@ public class DataStats {
public void readToNBT(NBTTagCompound compound) public void readToNBT(NBTTagCompound compound)
{ {
resistances.readToNBT(compound.getCompoundTag("Resistances")); resistances.readToNBT(compound.getCompoundTag("Resistances"));
setMaxHealth(compound.getInteger("MaxHealth")); setMaxHealth(compound.getDouble("MaxHealth"));
hideKilledBody = compound.getBoolean("HideBodyWhenKilled"); hideKilledBody = compound.getBoolean("HideBodyWhenKilled");
aggroRange = compound.getInteger("AggroRange"); aggroRange = compound.getInteger("AggroRange");
respawnTime = compound.getInteger("RespawnTime"); respawnTime = compound.getInteger("RespawnTime");
spawnCycle = compound.getInteger("SpawnCycle"); spawnCycle = compound.getInteger("SpawnCycle");
creatureType = EnumCreatureAttribute.values()[compound.getInteger("CreatureType") % EnumPotionType.values().length]; creatureType = EnumCreatureAttribute.values()[compound.getInteger("CreatureType") % EnumPotionType.values().length];
healthRegen = compound.getInteger("HealthRegen"); healthRegen = compound.getFloat("HealthRegen");
combatRegen = compound.getInteger("CombatRegen"); combatRegen = compound.getFloat("CombatRegen");
setAttackStrength(compound.getInteger("AttackStrenght")); setAttackStrength(compound.getFloat("AttackStrenght"));
attackSpeed = compound.getInteger("AttackSpeed"); attackSpeed = compound.getInteger("AttackSpeed");
attackRange = compound.getInteger("AttackRange"); attackRange = compound.getInteger("AttackRange");
knockback = compound.getInteger("KnockBack"); knockback = compound.getInteger("KnockBack");
@@ -138,7 +142,7 @@ public class DataStats {
shotCount = ValueUtil.CorrectInt(compound.getInteger("ShotCount"), 1, 10); shotCount = ValueUtil.CorrectInt(compound.getInteger("ShotCount"), 1, 10);
accuracy = compound.getInteger("Accuracy"); accuracy = compound.getInteger("Accuracy");
pDamage = compound.getInteger("pDamage"); pDamage = compound.getFloat("pDamage");
pImpact = compound.getInteger("pImpact"); pImpact = compound.getInteger("pImpact");
pSize = compound.getInteger("pSize"); pSize = compound.getInteger("pSize");
pSpeed = compound.getInteger("pSpeed"); pSpeed = compound.getInteger("pSpeed");
@@ -168,16 +172,16 @@ public class DataStats {
npc.setImmuneToFire(immuneToFire); npc.setImmuneToFire(immuneToFire);
} }
public int getAttackStrength(){ public float getAttackStrength(){
return attackStrength; return attackStrength;
} }
public void setAttackStrength(int strength){ public void setAttackStrength(float strength){
attackStrength = strength; attackStrength = (float)(Math.floor(strength));
npc.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(attackStrength); npc.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(attackStrength);
} }
public void setMaxHealth(int maxHealth) { public void setMaxHealth(double maxHealth) {
this.maxHealth = maxHealth; this.maxHealth = Math.floor(maxHealth);
npc.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(maxHealth); npc.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(maxHealth);
} }
} }
+516
View File
@@ -0,0 +1,516 @@
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package noppes.npcs;
import cpw.mods.fml.common.eventhandler.Event;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.item.EntityXPOrb;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.inventory.Container;
import net.minecraft.item.ItemStack;
import net.minecraft.util.DamageSource;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import net.minecraftforge.event.entity.EntityEvent;
import net.minecraftforge.event.world.WorldEvent;
import noppes.npcs.controllers.*;
import noppes.npcs.controllers.data.ForgeDataScript;
import noppes.npcs.controllers.data.NPCDataScript;
import noppes.npcs.controllers.data.PlayerDataScript;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.scripted.*;
import noppes.npcs.scripted.entity.ScriptNpc;
import noppes.npcs.scripted.entity.ScriptPlayer;
import noppes.npcs.scripted.event.*;
import noppes.npcs.scripted.event.PlayerEvent.ChatEvent;
import noppes.npcs.scripted.event.PlayerEvent.ContainerOpen;
import noppes.npcs.scripted.event.PlayerEvent.DamagedEntityEvent;
import noppes.npcs.scripted.event.PlayerEvent.KeyPressedEvent;
import noppes.npcs.scripted.event.PlayerEvent.LoginEvent;
import noppes.npcs.scripted.event.PlayerEvent.LogoutEvent;
import noppes.npcs.scripted.event.PlayerEvent.PickUpEvent;
import noppes.npcs.scripted.event.PlayerEvent.DropEvent;
import noppes.npcs.scripted.interfaces.ICustomGui;
import noppes.npcs.scripted.interfaces.IEntity;
import noppes.npcs.scripted.interfaces.IItemStack;
import noppes.npcs.scripted.interfaces.IWorld;
import noppes.npcs.scripted.wrapper.WrapperNpcAPI;
import noppes.npcs.constants.EnumScriptType;
import org.apache.commons.lang3.StringUtils;
import java.util.ArrayList;
public class 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);
npc.script.callScript(EnumScriptType.DIALOG, "event", new ScriptEventDialog(player,dialogId,optionId,dialog));
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);
npc.script.callScript(EnumScriptType.DIALOG_CLOSE, "event", new ScriptEventDialog(player,dialogId,optionId,dialog));
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) {
if(npc == null || npc.wrappedNPC == null)
return;
NpcEvent.TimerEvent event = new NpcEvent.TimerEvent(npc.wrappedNPC, id);
ScriptEventTimer scriptEvent = new ScriptEventTimer(id);
npc.script.callScript(EnumScriptType.TIMER, "event", scriptEvent);
ScriptController.Instance.npcScripts.callScript(EnumScriptType.TIMER, event);
WrapperNpcAPI.EVENT_BUS.post(event);
}
public static void onPlayerInit(PlayerDataScript handler, ScriptPlayer player) {
noppes.npcs.scripted.event.PlayerEvent.InitEvent event = new noppes.npcs.scripted.event.PlayerEvent.InitEvent(player);
handler.callScript(EnumScriptType.INIT, event);
WrapperNpcAPI.EVENT_BUS.post(event);
}
public static void onPlayerTick(PlayerDataScript handler, ScriptPlayer player) {
noppes.npcs.scripted.event.PlayerEvent.UpdateEvent event = new noppes.npcs.scripted.event.PlayerEvent.UpdateEvent(player);
handler.callScript(EnumScriptType.TICK, event);
WrapperNpcAPI.EVENT_BUS.post(event);
}
public static boolean onPlayerInteract(PlayerDataScript handler, noppes.npcs.scripted.event.PlayerEvent.InteractEvent event) {
handler.callScript(EnumScriptType.INTERACT, event);
return WrapperNpcAPI.EVENT_BUS.post(event);
}
public static boolean onStartUsingItem(PlayerDataScript handler, ScriptPlayer player, int duration, ItemStack item){
PlayerEvent.StartUsingItem event = new PlayerEvent.StartUsingItem(player, item, duration);
handler.callScript(EnumScriptType.START_USING_ITEM, event);
return WrapperNpcAPI.EVENT_BUS.post(event);
}
public static boolean onUsingItem(PlayerDataScript handler, ScriptPlayer player, int duration, ItemStack item){
PlayerEvent.UsingItem event = new PlayerEvent.UsingItem(player, item, duration);
handler.callScript(EnumScriptType.USING_ITEM, event);
return WrapperNpcAPI.EVENT_BUS.post(event);
}
public static boolean onStopUsingItem(PlayerDataScript handler, ScriptPlayer player, int duration, ItemStack item){
PlayerEvent.StopUsingItem event = new PlayerEvent.StopUsingItem(player, item, duration);
handler.callScript(EnumScriptType.STOP_USING_ITEM, event);
return WrapperNpcAPI.EVENT_BUS.post(event);
}
public static void onFinishUsingItem(PlayerDataScript handler, ScriptPlayer player, int duration, ItemStack item){
PlayerEvent.FinishUsingItem event = new PlayerEvent.FinishUsingItem(player, item, duration);
handler.callScript(EnumScriptType.FINISH_USING_ITEM, event);
WrapperNpcAPI.EVENT_BUS.post(event);
}
public static boolean onPlayerDropItems(PlayerDataScript handler, ScriptPlayer player, ArrayList<EntityItem> entityItems) {
IItemStack[] items = new IItemStack[entityItems.size()];
for(int i = 0; i < entityItems.size(); i++){ items[i] = NpcAPI.Instance().getIItemStack(entityItems.get(i).getEntityItem()); }
DropEvent event = new DropEvent(player, items);
handler.callScript(EnumScriptType.DROP, event);
return WrapperNpcAPI.EVENT_BUS.post(event);
}
public static void onPlayerPickupXP(PlayerDataScript handler, ScriptPlayer player, EntityXPOrb orb) {
PlayerEvent.PickupXPEvent event = new PlayerEvent.PickupXPEvent(player, orb);
handler.callScript(EnumScriptType.PICKUP_XP, event);
WrapperNpcAPI.EVENT_BUS.post(event);
}
public static boolean onPlayerToss(PlayerDataScript handler, ScriptPlayer player, EntityItem entityItem) {
PlayerEvent.TossEvent event = new PlayerEvent.TossEvent(player, NpcAPI.Instance().getIItemStack(entityItem.getEntityItem()));
handler.callScript(EnumScriptType.TOSS, event);
return WrapperNpcAPI.EVENT_BUS.post(event);
}
public static boolean onPlayerPickUp(PlayerDataScript handler, ScriptPlayer player, EntityItem entityItem) {
PickUpEvent event = new PickUpEvent(player, new ScriptItemStack(entityItem.getEntityItem()));//NpcAPI.Instance().getIItemStack(entityItem.getEntityItem()));
handler.callScript(EnumScriptType.PICKUP, event);
return WrapperNpcAPI.EVENT_BUS.post(event);
}
public static void onPlayerContainerOpen(PlayerDataScript handler, ScriptPlayer player, Container container) {
ContainerOpen event = new ContainerOpen(player, NpcAPI.Instance().getIContainer(container));
handler.callScript(EnumScriptType.CONTAINER_OPEN, event);
WrapperNpcAPI.EVENT_BUS.post(event);
}
public static void onPlayerUseHoe(PlayerDataScript handler, ScriptPlayer player, ItemStack hoe, int x, int y, int z) {
noppes.npcs.scripted.event.PlayerEvent.UseHoe event = new noppes.npcs.scripted.event.PlayerEvent.UseHoe(player, hoe, x, y, z);
handler.callScript(EnumScriptType.USE_HOE, event);
WrapperNpcAPI.EVENT_BUS.post(event);
}
public static void onPlayerSleep(PlayerDataScript handler, ScriptPlayer player, int x, int y, int z) {
noppes.npcs.scripted.event.PlayerEvent.Sleep event = new noppes.npcs.scripted.event.PlayerEvent.Sleep(player, x, y, z);
handler.callScript(EnumScriptType.SLEEP, event);
WrapperNpcAPI.EVENT_BUS.post(event);
}
public static void onPlayerWakeUp(PlayerDataScript handler, ScriptPlayer player, boolean setSpawn) {
noppes.npcs.scripted.event.PlayerEvent.WakeUp event = new noppes.npcs.scripted.event.PlayerEvent.WakeUp(player, setSpawn);
handler.callScript(EnumScriptType.WAKE_UP, event);
WrapperNpcAPI.EVENT_BUS.post(event);
}
public static void onPlayerDeath(PlayerDataScript handler, ScriptPlayer player, DamageSource source, Entity entity) {
noppes.npcs.scripted.event.PlayerEvent.DiedEvent event = new noppes.npcs.scripted.event.PlayerEvent.DiedEvent(player, source, entity);
handler.callScript(EnumScriptType.KILLED, event);
WrapperNpcAPI.EVENT_BUS.post(event);
}
public static void onPlayerKills(PlayerDataScript handler, ScriptPlayer player, EntityLivingBase entityLiving) {
noppes.npcs.scripted.event.PlayerEvent.KilledEntityEvent event = new noppes.npcs.scripted.event.PlayerEvent.KilledEntityEvent(player, entityLiving);
handler.callScript(EnumScriptType.KILLS, event);
WrapperNpcAPI.EVENT_BUS.post(event);
}
public static boolean onPlayerDamaged(PlayerDataScript handler, noppes.npcs.scripted.event.PlayerEvent.DamagedEvent event) {
handler.callScript(EnumScriptType.DAMAGED, event);
return WrapperNpcAPI.EVENT_BUS.post(event);
}
public static boolean onPlayerLightning(PlayerDataScript handler, ScriptPlayer player) {
PlayerEvent.LightningEvent event = new PlayerEvent.LightningEvent(player);
handler.callScript(EnumScriptType.LIGHTNING, event);
return WrapperNpcAPI.EVENT_BUS.post(event);
}
public static boolean onPlayerSound(PlayerDataScript handler, ScriptPlayer player, String name, float pitch, float volume) {
PlayerEvent.SoundEvent event = new PlayerEvent.SoundEvent(player, name, pitch, volume);
handler.callScript(EnumScriptType.PLAYSOUND, event);
return WrapperNpcAPI.EVENT_BUS.post(event);
}
public static void onPlayerFall(PlayerDataScript handler, ScriptPlayer player, float distance) {
PlayerEvent.FallEvent event = new PlayerEvent.FallEvent(player,distance);
handler.callScript(EnumScriptType.FALL, event);
WrapperNpcAPI.EVENT_BUS.post(event);
}
public static void onPlayerJump(PlayerDataScript handler, ScriptPlayer player) {
PlayerEvent.JumpEvent event = new PlayerEvent.JumpEvent(player);
handler.callScript(EnumScriptType.JUMP, event);
WrapperNpcAPI.EVENT_BUS.post(event);
}
public static void onPlayerLogin(PlayerDataScript handler, ScriptPlayer player) {
LoginEvent event = new LoginEvent(player);
handler.callScript(EnumScriptType.LOGIN, event);
WrapperNpcAPI.EVENT_BUS.post(event);
}
public static void onPlayerAchievement(PlayerDataScript handler, ScriptPlayer player, String description) {
PlayerEvent.Achievement event = new PlayerEvent.Achievement(player, description);
handler.callScript(EnumScriptType.ACHIEVEMENT, event);
WrapperNpcAPI.EVENT_BUS.post(event);
}
public static void onPlayerFillBucket(PlayerDataScript handler, ScriptPlayer player, ItemStack current, ItemStack result) {
PlayerEvent.FillBucket event = new PlayerEvent.FillBucket(player, current, result);
handler.callScript(EnumScriptType.FILL_BUCKET, event);
WrapperNpcAPI.EVENT_BUS.post(event);
}
public static void onPlayerBonemeal(PlayerDataScript handler, ScriptPlayer player, int x, int y, int z, World world) {
PlayerEvent.Bonemeal event = new PlayerEvent.Bonemeal(player, x, y, z, world);
handler.callScript(EnumScriptType.BONEMEAL, event);
WrapperNpcAPI.EVENT_BUS.post(event);
}
public static void onPlayerRespawn(PlayerDataScript handler, ScriptPlayer player) {
PlayerEvent.RespawnEvent event = new PlayerEvent.RespawnEvent(player);
handler.callScript(EnumScriptType.RESPAWN, event);
WrapperNpcAPI.EVENT_BUS.post(event);
}
public static void onPlayerLogout(PlayerDataScript handler, ScriptPlayer player) {
LogoutEvent event = new LogoutEvent(player);
handler.callScript(EnumScriptType.LOGOUT, event);
WrapperNpcAPI.EVENT_BUS.post(event);
}
public static void onPlayerChat(PlayerDataScript handler, ChatEvent event) {
handler.callScript(EnumScriptType.CHAT, event);
WrapperNpcAPI.EVENT_BUS.post(event);
}
public static boolean onPlayerBowCharge(PlayerDataScript handler, noppes.npcs.scripted.event.PlayerEvent.RangedChargeEvent event) {
handler.callScript(EnumScriptType.RANGED_CHARGE, event);
return WrapperNpcAPI.EVENT_BUS.post(event);
}
public static boolean onPlayerRanged(PlayerDataScript handler, noppes.npcs.scripted.event.PlayerEvent.RangedLaunchedEvent event) {
handler.callScript(EnumScriptType.RANGED_LAUNCHED, event);
return WrapperNpcAPI.EVENT_BUS.post(event);
}
public static boolean onPlayerDamagedEntity(PlayerDataScript handler, DamagedEntityEvent event) {
handler.callScript(EnumScriptType.DAMAGED_ENTITY, event);
return WrapperNpcAPI.EVENT_BUS.post(event);
}
public static void onPlayerChangeDim(PlayerDataScript handler, ScriptPlayer player, int fromDim, int toDim) {
PlayerEvent.ChangedDimension event = new PlayerEvent.ChangedDimension(player, fromDim, toDim);
handler.callScript(EnumScriptType.CHANGED_DIM, event);
WrapperNpcAPI.EVENT_BUS.post(event);
}
public static void onPlayerMouseClicked(EntityPlayerMP player, int button, int mouseWheel, boolean buttonDown) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
PlayerEvent.MouseClickedEvent event = new PlayerEvent.MouseClickedEvent((ScriptPlayer)ScriptController.Instance.getScriptForEntity(player), button, mouseWheel, buttonDown);
handler.callScript(EnumScriptType.MOUSE_CLICKED, event);
WrapperNpcAPI.EVENT_BUS.post(event);
}
public static void onPlayerKeyPressed(EntityPlayerMP player, int button, boolean isCtrlPressed, boolean isShiftPressed, boolean isAltPressed, boolean isMetaPressed, boolean buttonDown, int[] heldKeys) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
KeyPressedEvent event = new KeyPressedEvent((ScriptPlayer)ScriptController.Instance.getScriptForEntity(player), button, isCtrlPressed, isAltPressed, isShiftPressed, isMetaPressed, buttonDown, heldKeys);
handler.callScript(EnumScriptType.KEY_PRESSED, event);
WrapperNpcAPI.EVENT_BUS.post(event);
}
public static void onPlayerTimer(PlayerData data, int id) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
noppes.npcs.scripted.event.PlayerEvent.TimerEvent event = new noppes.npcs.scripted.event.PlayerEvent.TimerEvent((ScriptPlayer)ScriptController.Instance.getScriptForEntity(data.player), id);
handler.callScript(EnumScriptType.TIMER, event);
WrapperNpcAPI.EVENT_BUS.post(event);
}
public static boolean onPlayerBreak(PlayerDataScript handler, PlayerEvent.BreakEvent event) {
handler.callScript(EnumScriptType.BREAK_BLOCK, event);
return WrapperNpcAPI.EVENT_BUS.post(event);
}
public static void onForgeEntityEvent(EntityEvent event) {
IEntity e = NpcAPI.Instance().getIEntity(event.entity);
onForgeEvent(new noppes.npcs.scripted.event.ForgeEvent.EntityEvent(event, e), event);
}
public static void onForgeWorldEvent(WorldEvent event) {
if(ScriptController.Instance.forgeScripts.isEnabled()) {
IWorld e = NpcAPI.Instance().getIWorld((WorldServer)event.world);
onForgeEvent(new noppes.npcs.scripted.event.ForgeEvent.WorldEvent(event, e), event);
}
}
public static void onForgeInit(ForgeDataScript handler) {
noppes.npcs.scripted.event.ForgeEvent.InitEvent event = new noppes.npcs.scripted.event.ForgeEvent.InitEvent();
handler.callScript("init", event);
WrapperNpcAPI.EVENT_BUS.post(event);
}
public static void onForgeEvent(ForgeEvent ev, Event event) {
ForgeDataScript handler = ScriptController.Instance.forgeScripts;
if(handler.isEnabled()) {
String eventName = event.getClass().getName();
int i = eventName.lastIndexOf(".");
eventName = StringUtils.uncapitalize(eventName.substring(i + 1).replace("$", ""));
if(event.isCancelable()) {
ev.setCanceled(event.isCanceled());
}
handler.callScript(eventName, event);
WrapperNpcAPI.EVENT_BUS.post(ev);
if(event.isCancelable()) {
event.setCanceled(ev.isCanceled());
}
}
}
public static void onCustomGuiButton(ScriptPlayer player, ICustomGui gui, int buttonId) {
CustomGuiEvent.ButtonEvent event = new CustomGuiEvent.ButtonEvent(player, gui, buttonId);
CustomGuiController.onButton(event);
}
public static void onCustomGuiSlot(ScriptPlayer player, ICustomGui gui, int slotId) {
CustomGuiEvent.SlotEvent event = new CustomGuiEvent.SlotEvent(player, gui, slotId, player.getOpenContainer().getSlot(slotId));
CustomGuiController.onSlotChange(event);
}
public static void onCustomGuiUnfocused(ScriptPlayer player, ICustomGui gui, int textfieldId) {
CustomGuiEvent.UnfocusedEvent event = new CustomGuiEvent.UnfocusedEvent(player, gui, textfieldId);
CustomGuiController.onCustomGuiUnfocused(event);
}
public static void onCustomGuiScrollClick(ScriptPlayer player, ICustomGui gui, int scrollId, int scrollIndex, String[] selection, boolean doubleClick) {
CustomGuiEvent.ScrollEvent event = new CustomGuiEvent.ScrollEvent(player, gui, scrollId, scrollIndex, selection, doubleClick);
CustomGuiController.onScrollClick(event);
}
public static void onCustomGuiClose(ScriptPlayer player, ICustomGui gui) {
noppes.npcs.scripted.event.CustomGuiEvent.CloseEvent event = new noppes.npcs.scripted.event.CustomGuiEvent.CloseEvent(player, gui);
CustomGuiController.onClose(event);
}
public static void onQuestFinished(EntityPlayer player, Quest quest){
PlayerDataScript handler = ScriptController.Instance.playerScripts;
QuestEvent.QuestCompletedEvent event = new QuestEvent.QuestCompletedEvent(new ScriptPlayer((EntityPlayerMP) player), quest);
handler.callScript(EnumScriptType.QUEST_COMPLETED, event);
WrapperNpcAPI.EVENT_BUS.post(event);
}
public static boolean onQuestStarted(EntityPlayer player, Quest quest){
PlayerDataScript handler = ScriptController.Instance.playerScripts;
QuestEvent.QuestStartEvent event = new QuestEvent.QuestStartEvent(new ScriptPlayer((EntityPlayerMP) player), quest);
handler.callScript(EnumScriptType.QUEST_START, event);
return WrapperNpcAPI.EVENT_BUS.post(event);
}
public static void onQuestTurnedIn(QuestEvent.QuestTurnedInEvent event){
PlayerDataScript handler = ScriptController.Instance.playerScripts;
handler.callScript(EnumScriptType.QUEST_TURNIN, event);
WrapperNpcAPI.EVENT_BUS.post(event);
}
public static void onFactionPoints(FactionEvent.FactionPoints event){
PlayerDataScript handler = ScriptController.Instance.playerScripts;
handler.callScript(EnumScriptType.FACTION_POINTS, event);
WrapperNpcAPI.EVENT_BUS.post(event);
}
public static void onDialogOpen(DialogEvent.DialogOpen event){
PlayerDataScript handler = ScriptController.Instance.playerScripts;
handler.callScript(EnumScriptType.DIALOG_OPEN, event);
WrapperNpcAPI.EVENT_BUS.post(event);
}
public static void onDialogOption(DialogEvent.DialogOption event){
PlayerDataScript handler = ScriptController.Instance.playerScripts;
handler.callScript(EnumScriptType.DIALOG_OPTION, event);
WrapperNpcAPI.EVENT_BUS.post(event);
}
public static void onDialogClosed(DialogEvent.DialogClosed event){
PlayerDataScript handler = ScriptController.Instance.playerScripts;
handler.callScript(EnumScriptType.DIALOG_CLOSE, event);
WrapperNpcAPI.EVENT_BUS.post(event);
}
}
@@ -34,6 +34,10 @@ public class ModelDataShared{
public byte armwear = 0; public byte armwear = 0;
public byte legwear = 0; public byte legwear = 0;
// Solid or normal arm/legwear [0: None, 1: Both, 2: Right, 3: Left]
public byte solidArmwear = 0;
public byte solidLegwear = 0;
// Hide Body Parts [0: None, 1: Both, 2: Right, 3: Left], // Hide Body Parts [0: None, 1: Both, 2: Right, 3: Left],
public byte hideHead = 0; public byte hideHead = 0;
public byte hideBody = 0; public byte hideBody = 0;
@@ -58,6 +62,9 @@ public class ModelDataShared{
compound.setByte("Armwear", armwear); compound.setByte("Armwear", armwear);
compound.setByte("Legwear", legwear); compound.setByte("Legwear", legwear);
compound.setByte("SolidArmwear", solidArmwear);
compound.setByte("SolidLegwear", solidLegwear);
compound.setByte("hideHead", hideHead); compound.setByte("hideHead", hideHead);
compound.setByte("hideBody", hideBody); compound.setByte("hideBody", hideBody);
compound.setByte("hideArms", hideArms); compound.setByte("hideArms", hideArms);
@@ -92,6 +99,9 @@ public class ModelDataShared{
armwear = compound.getByte("Armwear"); armwear = compound.getByte("Armwear");
legwear = compound.getByte("Legwear"); legwear = compound.getByte("Legwear");
solidArmwear = compound.getByte("SolidArmwear");
solidLegwear = compound.getByte("SolidLegwear");
hideHead = compound.getByte("hideHead"); hideHead = compound.getByte("hideHead");
hideBody = compound.getByte("hideBody"); hideBody = compound.getByte("hideBody");
hideArms = compound.getByte("hideArms"); hideArms = compound.getByte("hideArms");
+13 -12
View File
@@ -8,9 +8,9 @@ public class ModelPartData {
public String texture; public String texture;
public byte type = 0; public byte type = 0;
public boolean playerTexture; public boolean playerTexture;
private ResourceLocation location; private ResourceLocation location;
public ModelPartData(){ public ModelPartData(){
playerTexture = true; playerTexture = true;
} }
@@ -24,12 +24,13 @@ public class ModelPartData {
NBTTagCompound compound = new NBTTagCompound(); NBTTagCompound compound = new NBTTagCompound();
compound.setByte("Type", type); compound.setByte("Type", type);
compound.setInteger("Color", color); compound.setInteger("Color", color);
if(texture != null && !texture.isEmpty()) if(texture != null && !texture.isEmpty()) {
compound.setString("Texture", texture); compound.setString("Texture", texture);
}
compound.setBoolean("PlayerTexture", playerTexture); compound.setBoolean("PlayerTexture", playerTexture);
return compound; return compound;
} }
public void readFromNBT(NBTTagCompound compound){ public void readFromNBT(NBTTagCompound compound){
type = compound.getByte("Type"); type = compound.getByte("Type");
color = compound.getInteger("Color"); color = compound.getInteger("Color");
@@ -37,13 +38,13 @@ public class ModelPartData {
playerTexture = compound.getBoolean("PlayerTexture"); playerTexture = compound.getBoolean("PlayerTexture");
location = null; location = null;
} }
public ResourceLocation getResource(){ public ResourceLocation getResource(){
if(texture.isEmpty()) if(texture.isEmpty())
return null; return null;
if(location != null) if(location != null)
return location; return location;
location = new ResourceLocation(texture); location = new ResourceLocation(texture);
return location; return location;
} }
@@ -59,7 +60,7 @@ public class ModelPartData {
playerTexture = false; playerTexture = false;
} }
} }
public String toString(){ public String toString(){
return "Color: " + color + " Type: " + type; return "Color: " + color + " Type: " + type;
} }
@@ -67,9 +68,9 @@ public class ModelPartData {
public String getColor() { public String getColor() {
String str = Integer.toHexString(color); String str = Integer.toHexString(color);
while(str.length() < 6) while(str.length() < 6)
str = "0" + str; str = "0" + str;
return str; return str;
} }
} }
+83 -7
View File
@@ -1,18 +1,14 @@
package noppes.npcs; package noppes.npcs;
import java.util.ArrayList; import java.util.*;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.Vector;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagDouble; import net.minecraft.nbt.NBTTagDouble;
import net.minecraft.nbt.NBTTagInt;
import net.minecraft.nbt.NBTTagList; import net.minecraft.nbt.NBTTagList;
import noppes.npcs.controllers.ScriptContainer;
import noppes.npcs.controllers.IScriptHandler;
public class NBTTags { public class NBTTags {
@@ -73,6 +69,17 @@ public class NBTTags {
} }
return list; return list;
} }
public static HashMap<Integer, Double> getIntegerDoubleMap(
NBTTagList tagList) {
HashMap<Integer, Double> list = new HashMap<Integer, Double>();
for(int i = 0; i < tagList.tagCount(); i++)
{
NBTTagCompound nbttagcompound = tagList.getCompoundTagAt(i);
list.put(nbttagcompound.getInteger("Slot"), nbttagcompound.getDouble("Double"));
}
return list;
}
public static HashMap<Integer, Long> getIntegerLongMap( public static HashMap<Integer, Long> getIntegerLongMap(
NBTTagList tagList) { NBTTagList tagList) {
@@ -243,6 +250,19 @@ public class NBTTags {
return nbttaglist; return nbttaglist;
} }
public static NBTTagList nbtIntegerDoubleMap(HashMap<Integer, Double> lines) {
NBTTagList nbttaglist = new NBTTagList();
if(lines == null)
return nbttaglist;
for (int slot : lines.keySet()) {
NBTTagCompound nbttagcompound = new NBTTagCompound();
nbttagcompound.setInteger("Slot", slot);
nbttagcompound.setDouble("Double", lines.get(slot));
nbttaglist.appendTag(nbttagcompound);
}
return nbttaglist;
}
public static NBTTagList nbtIntegerLongMap(HashMap<Integer, Long> lines) { public static NBTTagList nbtIntegerLongMap(HashMap<Integer, Long> lines) {
NBTTagList nbttaglist = new NBTTagList(); NBTTagList nbttaglist = new NBTTagList();
if(lines == null) if(lines == null)
@@ -383,4 +403,60 @@ public class NBTTags {
return compound; return compound;
} }
public static TreeMap<Long, String> GetLongStringMap(NBTTagList tagList) {
TreeMap list = new TreeMap();
for(int i = 0; i < tagList.tagCount(); ++i) {
NBTTagCompound nbttagcompound = tagList.getCompoundTagAt(i);
list.put(Long.valueOf(nbttagcompound.getLong("Long")), nbttagcompound.getString("String"));
}
return list;
}
public static NBTTagList NBTLongStringMap(Map<Long, String> map) {
NBTTagList nbttaglist = new NBTTagList();
if(map == null) {
return nbttaglist;
} else {
Iterator var2 = map.keySet().iterator();
while(var2.hasNext()) {
long slot = ((Long)var2.next()).longValue();
NBTTagCompound nbttagcompound = new NBTTagCompound();
nbttagcompound.setLong("Long", slot);
nbttagcompound.setString("String", (String) map.get(Long.valueOf(slot)));
nbttaglist.appendTag(nbttagcompound);
}
return nbttaglist;
}
}
public static List<ScriptContainer> GetScript(NBTTagList list, IScriptHandler handler) {
ArrayList scripts = new ArrayList();
for(int i = 0; i < list.tagCount(); ++i) {
NBTTagCompound compoundd = list.getCompoundTagAt(i);
ScriptContainer script = new ScriptContainer(handler);
script.readFromNBT(compoundd);
scripts.add(script);
}
return scripts;
}
public static NBTTagList NBTScript(List<ScriptContainer> scripts) {
NBTTagList list = new NBTTagList();
Iterator var2 = scripts.iterator();
while(var2.hasNext()) {
ScriptContainer script = (ScriptContainer)var2.next();
NBTTagCompound compound = new NBTTagCompound();
script.writeToNBT(compound);
list.appendTag(compound);
}
return list;
}
} }
+109 -42
View File
@@ -6,6 +6,7 @@ import io.netty.buffer.Unpooled;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator;
import java.util.List; import java.util.List;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
@@ -25,24 +26,15 @@ import noppes.npcs.constants.EnumScriptType;
import noppes.npcs.containers.ContainerNPCBankInterface; import noppes.npcs.containers.ContainerNPCBankInterface;
import noppes.npcs.containers.ContainerNPCFollower; import noppes.npcs.containers.ContainerNPCFollower;
import noppes.npcs.containers.ContainerNPCFollowerHire; import noppes.npcs.containers.ContainerNPCFollowerHire;
import noppes.npcs.controllers.Bank; import noppes.npcs.controllers.*;
import noppes.npcs.controllers.BankController;
import noppes.npcs.controllers.BankData;
import noppes.npcs.controllers.Dialog;
import noppes.npcs.controllers.DialogController;
import noppes.npcs.controllers.DialogOption;
import noppes.npcs.controllers.Line;
import noppes.npcs.controllers.PlayerBankData;
import noppes.npcs.controllers.PlayerDataController;
import noppes.npcs.controllers.PlayerQuestController;
import noppes.npcs.controllers.PlayerQuestData;
import noppes.npcs.controllers.PlayerTransportData;
import noppes.npcs.controllers.QuestData;
import noppes.npcs.controllers.TransportController;
import noppes.npcs.controllers.TransportLocation;
import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.roles.RoleFollower; import noppes.npcs.roles.RoleFollower;
import cpw.mods.fml.common.network.internal.FMLProxyPacket; import cpw.mods.fml.common.network.internal.FMLProxyPacket;
import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.scripted.entity.ScriptPlayer;
import noppes.npcs.scripted.event.DialogEvent;
import noppes.npcs.scripted.event.QuestEvent;
import noppes.npcs.scripted.interfaces.IItemStack;
public class NoppesUtilPlayer { public class NoppesUtilPlayer {
@@ -110,6 +102,28 @@ public class NoppesUtilPlayer {
} }
player.worldObj.updateEntityWithOptionalForce(player, false); player.worldObj.updateEntityWithOptionalForce(player, false);
} }
public static void teleportPlayer(EntityPlayerMP player, double posX, double posY, double posZ, float yaw, float pitch, int dimension){
if(player.dimension != dimension){
int dim = player.dimension;
MinecraftServer server = MinecraftServer.getServer();
WorldServer wor = server.worldServerForDimension(dimension);
if(wor == null){
player.addChatMessage(new ChatComponentText("Broken transporter. Dimenion does not exist"));
return;
}
player.setLocationAndAngles(posX, posY, posZ, yaw, pitch);
server.getConfigurationManager().transferPlayerToDimension(player, dimension, new CustomTeleporter(wor));
player.playerNetServerHandler.setPlayerLocation(posX, posY, posZ, yaw, pitch);
if(!wor.playerEntities.contains(player))
wor.spawnEntityInWorld(player);
}
else{
player.playerNetServerHandler.setPlayerLocation(posX, posY, posZ, yaw, pitch);
}
player.worldObj.updateEntityWithOptionalForce(player, false);
}
private static void followerBuy(RoleFollower role,IInventory currencyInv,EntityPlayerMP player, EntityNPCInterface npc){ private static void followerBuy(RoleFollower role,IInventory currencyInv,EntityPlayerMP player, EntityNPCInterface npc){
ItemStack currency = currencyInv.getStackInSlot(0); ItemStack currency = currencyInv.getStackInSlot(0);
@@ -237,13 +251,19 @@ public class NoppesUtilPlayer {
Dialog dialog = DialogController.instance.dialogs.get(dialogId); Dialog dialog = DialogController.instance.dialogs.get(dialogId);
if(dialog == null) if(dialog == null)
return; return;
npc.script.callScript(EnumScriptType.DIALOG_OPTION, "player", player, "dialog", dialogId, "option", optionId + 1);
EventHooks.onDialogOption(new DialogEvent.DialogOption(new ScriptPlayer((EntityPlayerMP) player), dialog));
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));
return; return;
}
DialogOption option = dialog.options.get(optionId); DialogOption option = dialog.options.get(optionId);
if(option == null || option.optionType == EnumOptionType.DialogOption && (!option.isAvailable(player) || !option.hasDialog()) || option.optionType == EnumOptionType.Disabled || option.optionType == EnumOptionType.QuitOption) if(option == null || option.optionType == EnumOptionType.DialogOption && (!option.isAvailable(player) || !option.hasDialog()) || option.optionType == EnumOptionType.Disabled || option.optionType == EnumOptionType.QuitOption) {
return; EventHooks.onDialogClosed(new DialogEvent.DialogClosed(new ScriptPlayer((EntityPlayerMP) player), dialog));
return;
}
if(option.optionType == EnumOptionType.RoleOption){ if(option.optionType == EnumOptionType.RoleOption){
if(npc.roleInterface != null) if(npc.roleInterface != null)
npc.roleInterface.interact(player); npc.roleInterface.interact(player);
@@ -251,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);
@@ -269,43 +289,61 @@ public class NoppesUtilPlayer {
Server.sendData(player, EnumPacketClient.GUI_DATA, data.writeNBT()); Server.sendData(player, EnumPacketClient.GUI_DATA, data.writeNBT());
} }
public static void questCompletion(EntityPlayerMP player, int questId) { public static void questCompletion(EntityPlayerMP player, int questId) {
PlayerQuestData playerdata = PlayerDataController.instance.getPlayerData(player).questData; PlayerData playerData = PlayerDataController.instance.getPlayerData(player);
QuestData data = playerdata.activeQuests.get(questId); PlayerQuestData questData = playerData.questData;
QuestData data = questData.activeQuests.get(questId);
if(data == null) if(data == null)
return; return;
if(!data.quest.questInterface.isCompleted(player)) if(!data.quest.questInterface.isCompleted(playerData))
return; return;
QuestEvent.QuestTurnedInEvent event = new QuestEvent.QuestTurnedInEvent(new ScriptPlayer(player), data.quest);
event.expReward = data.quest.rewardExp;
List<IItemStack> list = new ArrayList();
Iterator var8 = data.quest.rewardItems.items.values().iterator();
while(var8.hasNext()) {
ItemStack item = (ItemStack)var8.next();
if (item.stackSize > 0) {
list.add(NpcAPI.Instance().getIItemStack(item));
}
}
if (!data.quest.randomReward) {
event.itemRewards = (IItemStack[])list.toArray(new IItemStack[list.size()]);
} else if (!list.isEmpty()) {
event.itemRewards = new IItemStack[]{(IItemStack)list.get(player.getRNG().nextInt(list.size()))};
}
EventHooks.onQuestTurnedIn(event);
IItemStack[] var12 = event.itemRewards;
int var14 = var12.length;
for(int var10 = 0; var10 < var14; ++var10) {
IItemStack item = var12[var10];
if (item != null) {
NoppesUtilServer.GivePlayerItem(player, player, item.getMCItemStack());
}
}
data.quest.questInterface.handleComplete(player); data.quest.questInterface.handleComplete(player);
if(data.quest.rewardExp > 0){ if(data.quest.rewardExp > 0){
player.worldObj.playSoundAtEntity(player, "random.orb", 0.1F, 0.5F * ((player.worldObj.rand.nextFloat() - player.worldObj.rand.nextFloat()) * 0.7F + 1.8F)); player.worldObj.playSoundAtEntity(player, "random.orb", 0.1F, 0.5F * ((player.worldObj.rand.nextFloat() - player.worldObj.rand.nextFloat()) * 0.7F + 1.8F));
player.addExperience(data.quest.rewardExp); player.addExperience(data.quest.rewardExp);
} }
data.quest.factionOptions.addPoints(player); data.quest.factionOptions.addPoints(player);
if(data.quest.mail.isValid()){ if(data.quest.mail.isValid()){
PlayerDataController.instance.addPlayerMessage(player.getCommandSenderName(), data.quest.mail); PlayerDataController.instance.addPlayerMessage(player.getCommandSenderName(), data.quest.mail);
} }
if(!data.quest.randomReward){
for(ItemStack item : data.quest.rewardItems.items.values()){
NoppesUtilServer.GivePlayerItem(player, player, item);
}
}
else{
List<ItemStack> list = new ArrayList<ItemStack>();
for(ItemStack item : data.quest.rewardItems.items.values()){
if(item != null && item.getItem() != null)
list.add(item);
}
if(!list.isEmpty()){
NoppesUtilServer.GivePlayerItem(player, player, list.get(player.getRNG().nextInt(list.size())));
}
}
if(!data.quest.command.isEmpty()){ if(!data.quest.command.isEmpty()){
NoppesUtilServer.runCommand(player, "QuestCompletion", data.quest.command); NoppesUtilServer.runCommand(player, "QuestCompletion", data.quest.command);
} }
PlayerQuestController.setQuestFinished(data.quest, player); PlayerQuestController.setQuestFinished(data.quest, player);
if(data.quest.hasNewQuest()) PlayerQuestController.addActiveQuest(data.quest.getNextQuest(), player); if(data.quest.hasNewQuest()) PlayerQuestController.addActiveQuest(data.quest.getNextQuest(), player);
} }
@@ -375,5 +413,34 @@ public class NoppesUtilPlayer {
} }
} }
} }
public static void isGUIOpen(EntityPlayerMP player){
Server.sendData(player, EnumPacketClient.ISGUIOPEN);
}
public static List<ItemStack> countStacks(IInventory inv, boolean ignoreDamage, boolean ignoreNBT) {
List<ItemStack> list = new ArrayList();
for(int i = 0; i < inv.getSizeInventory(); ++i) {
ItemStack item = inv.getStackInSlot(i);
if (!NoppesUtilServer.IsItemStackNull(item)) {
boolean found = false;
Iterator var7 = list.iterator();
while(var7.hasNext()) {
ItemStack is = (ItemStack)var7.next();
if (compareItems(item, is, ignoreDamage, ignoreNBT)) {
is.stackSize = is.stackSize + item.stackSize;
found = true;
break;
}
}
if (!found) {
list.add(item.copy());
}
}
}
return list;
}
} }
@@ -14,6 +14,7 @@ import java.util.Map;
import java.util.UUID; import java.util.UUID;
import java.util.zip.GZIPOutputStream; import java.util.zip.GZIPOutputStream;
import net.minecraft.command.ICommandSender;
import net.minecraft.command.server.CommandBlockLogic; import net.minecraft.command.server.CommandBlockLogic;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityList; import net.minecraft.entity.EntityList;
@@ -21,6 +22,8 @@ import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.entity.projectile.EntityThrowable;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@@ -31,8 +34,8 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityCommandBlock; import net.minecraft.tileentity.TileEntityCommandBlock;
import net.minecraft.tileentity.TileEntityMobSpawner; import net.minecraft.tileentity.TileEntityMobSpawner;
import net.minecraft.util.ChatComponentTranslation; import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MathHelper; import net.minecraft.util.MathHelper;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World; import net.minecraft.world.World;
import noppes.npcs.constants.EnumGuiType; import noppes.npcs.constants.EnumGuiType;
import noppes.npcs.constants.EnumPacketClient; import noppes.npcs.constants.EnumPacketClient;
@@ -69,7 +72,9 @@ import noppes.npcs.controllers.TransportLocation;
import noppes.npcs.entity.EntityDialogNpc; import noppes.npcs.entity.EntityDialogNpc;
import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.roles.RoleTransporter; import noppes.npcs.roles.RoleTransporter;
import noppes.npcs.scripted.ScriptEventDialog; import noppes.npcs.scripted.entity.ScriptPlayer;
import noppes.npcs.scripted.event.DialogEvent;
import noppes.npcs.scripted.event.ScriptEventDialog;
public class NoppesUtilServer { public class NoppesUtilServer {
private static HashMap<String,Quest> editingQuests = new HashMap<String,Quest>(); private static HashMap<String,Quest> editingQuests = new HashMap<String,Quest>();
@@ -175,8 +180,11 @@ 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));
if(npc instanceof EntityDialogNpc){ if(npc instanceof EntityDialogNpc){
dialog.hideNPC = true; dialog.hideNPC = true;
Server.sendData((EntityPlayerMP)player, EnumPacketClient.DIALOG_DUMMY, npc.getCommandSenderName(), dialog.writeToNBT(new NBTTagCompound())); Server.sendData((EntityPlayerMP)player, EnumPacketClient.DIALOG_DUMMY, npc.getCommandSenderName(), dialog.writeToNBT(new NBTTagCompound()));
@@ -195,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);
@@ -216,6 +224,19 @@ public class NoppesUtilServer {
logic.func_145754_b("@"+name); logic.func_145754_b("@"+name);
logic.func_145755_a(executer.worldObj); logic.func_145755_a(executer.worldObj);
} }
public static void runCommand(World world, String name, String command) {
TileEntityCommandBlock tile = new TileEntityCommandBlock();
tile.setWorldObj(world.provider.worldObj);
tile.xCoord = 0;
tile.yCoord = 0;
tile.zCoord = 0;
CommandBlockLogic logic = tile.func_145993_a();
logic.func_145752_a(command);
logic.func_145754_b("@"+name);
logic.func_145755_a(world);
}
public static void consumeItemStack(int i, EntityPlayer player){ public static void consumeItemStack(int i, EntityPlayer player){
ItemStack item = player.inventory.getCurrentItem(); ItemStack item = player.inventory.getCurrentItem();
@@ -291,6 +312,28 @@ 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(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,
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
){
Server.sendToAll(EnumPacketClient.SCRIPTED_PARTICLE,
directory, HEXcolor, amount, maxAge,
x, y, z,
motionX, motionY, motionZ, gravity,
scale1, scale2, scaleRate, scaleRateStart,
alpha1, alpha2, alphaRate, alphaRateStart,
rotationX1, rotationX2, rotationXRate, rotationXRateStart,
rotationY1, rotationY2, rotationYRate, rotationYRateStart,
rotationZ1, rotationZ2, rotationZRate, rotationZRateStart,
entityID
);
}
public static void deleteNpc(EntityNPCInterface npc,EntityPlayer player) { public static void deleteNpc(EntityNPCInterface npc,EntityPlayer player) {
Server.sendAssociatedData(npc, EnumPacketClient.DELETE_NPC, npc.getEntityId()); Server.sendAssociatedData(npc, EnumPacketClient.DELETE_NPC, npc.getEntityId());
@@ -658,4 +701,29 @@ public class NoppesUtilServer {
} }
return null; return null;
} }
public static Entity GetDamageSourcee(DamageSource damagesource) {
Object entity = damagesource.getEntity();
if(entity == null) {
entity = damagesource.getSourceOfDamage();
}
if(entity instanceof EntityArrow && ((EntityArrow)entity).shootingEntity instanceof EntityLivingBase) {
entity = ((EntityArrow)entity).shootingEntity;
} else if(entity instanceof EntityThrowable) {
entity = ((EntityThrowable)entity).getThrower();
}
return (Entity)entity;
}
public static void isGUIOpen(ByteBuf buffer, EntityPlayer player) throws IOException {
PlayerData playerdata = PlayerDataController.instance.getPlayerData(player);
boolean isGUIOpen = buffer.readBoolean();
playerdata.setGUIOpen(isGUIOpen);
}
public static boolean IsItemStackNull(ItemStack is) {
return is == null || is.stackSize == 0 || is.getItem() == null;
}
} }
@@ -3,6 +3,8 @@ package noppes.npcs;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator; import java.util.Iterator;
import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.EntityPlayerMP;
@@ -16,19 +18,9 @@ import net.minecraft.network.NetHandlerPlayServer;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import noppes.npcs.blocks.tiles.TileBigSign; import noppes.npcs.blocks.tiles.TileBigSign;
import noppes.npcs.blocks.tiles.TileBook; import noppes.npcs.blocks.tiles.TileBook;
import noppes.npcs.constants.EnumCompanionTalent; import noppes.npcs.constants.*;
import noppes.npcs.constants.EnumGuiType;
import noppes.npcs.constants.EnumPacketClient;
import noppes.npcs.constants.EnumPlayerPacket;
import noppes.npcs.constants.EnumRoleType;
import noppes.npcs.containers.ContainerMail; import noppes.npcs.containers.ContainerMail;
import noppes.npcs.controllers.BankData; import noppes.npcs.controllers.*;
import noppes.npcs.controllers.PlayerDataController;
import noppes.npcs.controllers.PlayerFactionData;
import noppes.npcs.controllers.PlayerMail;
import noppes.npcs.controllers.PlayerMailData;
import noppes.npcs.controllers.PlayerQuestController;
import noppes.npcs.controllers.PlayerQuestData;
import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.roles.RoleCompanion; import noppes.npcs.roles.RoleCompanion;
import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.eventhandler.SubscribeEvent;
@@ -67,17 +59,55 @@ public class PacketHandlerPlayer{
return; return;
NoppesUtilServer.sendOpenGui(player, EnumGuiType.CompanionInv, npc); NoppesUtilServer.sendOpenGui(player, EnumGuiType.CompanionInv, npc);
} }
else if(type == EnumPlayerPacket.KeyPressed) {
if(ScriptController.Instance.languages.isEmpty()) {
return;
}
int button = buffer.readInt();
boolean isCtrlPressed = buffer.readBoolean();
boolean isShiftPressed = buffer.readBoolean();
boolean isAltPressed = buffer.readBoolean();
boolean isMetaPressed = buffer.readBoolean();
boolean buttonDown = buffer.readBoolean();
String ints = Server.readString(buffer);
String[] split = ints.split(",");
int[] keysDown;
if(ints.length() > 0) {
keysDown = new int[split.length];
try {
for (int i = 0; i < split.length; i++) {
keysDown[i] = Integer.parseInt(split[i]);
}
}
catch (NumberFormatException ignored){
}
} else {
keysDown = new int[0];
}
EventHooks.onPlayerKeyPressed(player, button, isCtrlPressed, isShiftPressed, isAltPressed, isMetaPressed, buttonDown, keysDown);
}
else if(type == EnumPlayerPacket.MouseClicked) {
if(ScriptController.Instance.languages.isEmpty()) {
return;
}
EventHooks.onPlayerMouseClicked(player, buffer.readInt(), buffer.readInt(), buffer.readBoolean());
}
else if(type == EnumPlayerPacket.FollowerHire){ else if(type == EnumPlayerPacket.FollowerHire){
EntityNPCInterface npc = NoppesUtilServer.getEditingNpc(player); EntityNPCInterface npc = NoppesUtilServer.getEditingNpc(player);
if(npc == null || npc.advanced.role != EnumRoleType.Follower) if(npc == null || npc.advanced.role != EnumRoleType.Follower)
return; return;
NoppesUtilPlayer.hireFollower(player,npc); NoppesUtilPlayer.hireFollower(player, npc);
} }
else if(type == EnumPlayerPacket.FollowerExtend){ else if(type == EnumPlayerPacket.FollowerExtend){
EntityNPCInterface npc = NoppesUtilServer.getEditingNpc(player); EntityNPCInterface npc = NoppesUtilServer.getEditingNpc(player);
if(npc == null || npc.advanced.role != EnumRoleType.Follower) if(npc == null || npc.advanced.role != EnumRoleType.Follower)
return; return;
NoppesUtilPlayer.extendFollower(player,npc); NoppesUtilPlayer.extendFollower(player, npc);
Server.sendData(player, EnumPacketClient.GUI_DATA, npc.roleInterface.writeToNBT(new NBTTagCompound())); Server.sendData(player, EnumPacketClient.GUI_DATA, npc.roleInterface.writeToNBT(new NBTTagCompound()));
} }
else if(type == EnumPlayerPacket.FollowerState){ else if(type == EnumPlayerPacket.FollowerState){
@@ -124,17 +154,18 @@ public class PacketHandlerPlayer{
EntityNPCInterface npc = NoppesUtilServer.getEditingNpc(player); EntityNPCInterface npc = NoppesUtilServer.getEditingNpc(player);
if(npc == null) if(npc == null)
return; return;
NoppesUtilPlayer.dialogSelected(buffer.readInt(),buffer.readInt(),player,npc); NoppesUtilPlayer.dialogSelected(buffer.readInt(), buffer.readInt(), player, npc);
} }
else if(type == EnumPlayerPacket.CheckQuestCompletion){ else if(type == EnumPlayerPacket.CheckQuestCompletion){
PlayerQuestData playerdata = PlayerDataController.instance.getPlayerData(player).questData; PlayerData playerData = PlayerDataController.instance.getPlayerData(player);
playerdata.checkQuestCompletion(player,null); PlayerQuestData questData = PlayerDataController.instance.getPlayerData(player).questData;
questData.checkQuestCompletion(playerData, null);
} }
else if(type == EnumPlayerPacket.QuestLog){ else if(type == EnumPlayerPacket.QuestLog){
NoppesUtilPlayer.sendQuestLogData(player); NoppesUtilPlayer.sendQuestLogData(player);
} }
else if(type == EnumPlayerPacket.QuestCompletion){ else if(type == EnumPlayerPacket.QuestCompletion){
NoppesUtilPlayer.questCompletion(player,buffer.readInt()); NoppesUtilPlayer.questCompletion(player, buffer.readInt());
} }
else if(type == EnumPlayerPacket.FactionsGet){ else if(type == EnumPlayerPacket.FactionsGet){
PlayerFactionData data = PlayerDataController.instance.getPlayerData(player).factionData; PlayerFactionData data = PlayerDataController.instance.getPlayerData(player).factionData;
@@ -9,7 +9,6 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityList; import net.minecraft.entity.EntityList;
import net.minecraft.entity.passive.EntityVillager; import net.minecraft.entity.passive.EntityVillager;
@@ -37,31 +36,13 @@ import noppes.npcs.constants.EnumPacketClient;
import noppes.npcs.constants.EnumPacketServer; import noppes.npcs.constants.EnumPacketServer;
import noppes.npcs.constants.EnumPlayerData; import noppes.npcs.constants.EnumPlayerData;
import noppes.npcs.constants.EnumRoleType; import noppes.npcs.constants.EnumRoleType;
import noppes.npcs.containers.ContainerCustomGui;
import noppes.npcs.containers.ContainerMail; import noppes.npcs.containers.ContainerMail;
import noppes.npcs.controllers.Bank; import noppes.npcs.controllers.*;
import noppes.npcs.controllers.BankController;
import noppes.npcs.controllers.Dialog;
import noppes.npcs.controllers.DialogCategory;
import noppes.npcs.controllers.DialogController;
import noppes.npcs.controllers.DialogOption;
import noppes.npcs.controllers.Faction;
import noppes.npcs.controllers.FactionController;
import noppes.npcs.controllers.LinkedNpcController;
import noppes.npcs.controllers.LinkedNpcController.LinkedData; import noppes.npcs.controllers.LinkedNpcController.LinkedData;
import noppes.npcs.controllers.PlayerData; import noppes.npcs.controllers.data.ForgeDataScript;
import noppes.npcs.controllers.PlayerDataController; import noppes.npcs.controllers.data.NPCDataScript;
import noppes.npcs.controllers.PlayerMail; import noppes.npcs.controllers.data.PlayerDataScript;
import noppes.npcs.controllers.Quest;
import noppes.npcs.controllers.QuestCategory;
import noppes.npcs.controllers.QuestController;
import noppes.npcs.controllers.RecipeCarpentry;
import noppes.npcs.controllers.RecipeController;
import noppes.npcs.controllers.ScriptController;
import noppes.npcs.controllers.ServerCloneController;
import noppes.npcs.controllers.SpawnController;
import noppes.npcs.controllers.SpawnData;
import noppes.npcs.controllers.TransportController;
import noppes.npcs.controllers.TransportLocation;
import noppes.npcs.entity.EntityCustomNpc; import noppes.npcs.entity.EntityCustomNpc;
import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.roles.JobSpawner; import noppes.npcs.roles.JobSpawner;
@@ -70,6 +51,9 @@ import noppes.npcs.roles.RoleTrader;
import noppes.npcs.roles.RoleTransporter; import noppes.npcs.roles.RoleTransporter;
import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.network.FMLNetworkEvent.ServerCustomPacketEvent; import cpw.mods.fml.common.network.FMLNetworkEvent.ServerCustomPacketEvent;
import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.scripted.entity.ScriptPlayer;
import noppes.npcs.scripted.gui.ScriptGui;
public class PacketHandlerServer{ public class PacketHandlerServer{
@@ -88,33 +72,72 @@ public class PacketHandlerServer{
ItemStack item = player.inventory.getCurrentItem(); ItemStack item = player.inventory.getCurrentItem();
EntityNPCInterface npc = NoppesUtilServer.getEditingNpc(player); EntityNPCInterface npc = NoppesUtilServer.getEditingNpc(player);
if(type == EnumPacketServer.IsGuiOpen) {
isGuiOpenPacket(buffer, player);
return;
} else if (type == EnumPacketServer.CustomGuiButton && player.openContainer instanceof ContainerCustomGui) {
((ContainerCustomGui)player.openContainer).customGui.fromNBT(Server.readNBT(buffer));
EventHooks.onCustomGuiButton((ScriptPlayer)NpcAPI.Instance().getIEntity(player), ((ContainerCustomGui)player.openContainer).customGui, buffer.readInt());
return;
} else if (type == EnumPacketServer.CustomGuiSlotChange && player.openContainer instanceof ContainerCustomGui) {
((ContainerCustomGui)player.openContainer).customGui.fromNBT(Server.readNBT(buffer));
EventHooks.onCustomGuiSlot((ScriptPlayer) NpcAPI.Instance().getIEntity(player), ((ContainerCustomGui)player.openContainer).customGui, buffer.readInt());
return;
} else if(type == EnumPacketServer.CustomGuiUnfocused && player.openContainer instanceof ContainerCustomGui) {
((ContainerCustomGui)player.openContainer).customGui.fromNBT(Server.readNBT(buffer));
EventHooks.onCustomGuiUnfocused((ScriptPlayer) NpcAPI.Instance().getIEntity(player), ((ContainerCustomGui) player.openContainer).customGui, buffer.readInt());
return;
} else if (type == EnumPacketServer.CustomGuiScrollClick && player.openContainer instanceof ContainerCustomGui) {
((ContainerCustomGui) player.openContainer).customGui.fromNBT(Server.readNBT(buffer));
EventHooks.onCustomGuiScrollClick((ScriptPlayer) NpcAPI.Instance().getIEntity(player), ((ContainerCustomGui) player.openContainer).customGui, buffer.readInt(), buffer.readInt(), CustomGuiController.readScrollSelection(buffer), buffer.readBoolean());
return;
} else if (type == EnumPacketServer.CustomGuiClose) {
EventHooks.onCustomGuiClose((ScriptPlayer)NpcAPI.Instance().getIEntity(player), (new ScriptGui()).fromNBT(Server.readNBT(buffer)));
return;
}
if(type.needsNpc && npc == null){ if(type.needsNpc && npc == null){
} }
else if(type.hasPermission() && !CustomNpcsPermissions.Instance.hasPermission(player, type.permission)){ else if(type.hasPermission() && !CustomNpcsPermissions.Instance.hasPermission(player, type.permission)){
//player doesnt have permission todo this //player doesnt have permission to do this
} }
else if(item == null ) 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 if(item.getItem() == CustomItems.wand) else {
wandPackets(type, buffer, player, npc); if (item != null) {
else if(item.getItem() == CustomItems.moving) if (item.getItem() == CustomItems.wand)
movingPackets(type, buffer, player, npc); wandPackets(type, buffer, player, npc);
else if(item.getItem() == CustomItems.mount) else if (item.getItem() == CustomItems.moving)
mountPackets(type, buffer, player); movingPackets(type, buffer, player, npc);
else if(item.getItem() == CustomItems.cloner) else if (item.getItem() == CustomItems.mount)
clonePackets(type, buffer, player); mountPackets(type, buffer, player);
else if(item.getItem() == CustomItems.teleporter) else if (item.getItem() == CustomItems.cloner)
featherPackets(type, buffer, player); clonePackets(type, buffer, player);
else if(item.getItem() == CustomItems.scripter) else if (item.getItem() == CustomItems.teleporter)
scriptPackets(type, buffer, player, npc); featherPackets(type, buffer, player);
else if(item.getItem() == Item.getItemFromBlock(CustomItems.waypoint) || item.getItem() == Item.getItemFromBlock(CustomItems.border) || item.getItem() == Item.getItemFromBlock(CustomItems.redstoneBlock)) else if (type == EnumPacketServer.ScriptPlayerGet || type == EnumPacketServer.ScriptPlayerSave)
blockPackets(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)
forgeScriptPackets(type, buffer, player);
else if (item.getItem() == CustomItems.scripter)
scriptPackets(type, buffer, player, npc);
else if (item.getItem() == Item.getItemFromBlock(CustomItems.waypoint) || item.getItem() == Item.getItemFromBlock(CustomItems.border) || item.getItem() == Item.getItemFromBlock(CustomItems.redstoneBlock))
blockPackets(type, buffer, player);
}
}
} catch (Exception e) { } catch (Exception e) {
LogWriter.error("Error with EnumPacketServer." + type, e); LogWriter.error("Error with EnumPacketServer." + type, e);
} }
} }
private void isGuiOpenPacket(ByteBuf buffer, EntityPlayerMP player) throws IOException {
NoppesUtilServer.isGUIOpen(buffer, player);
}
private void scriptPackets(EnumPacketServer type, ByteBuf buffer, EntityPlayerMP player, EntityNPCInterface npc) throws Exception { private void scriptPackets(EnumPacketServer type, ByteBuf buffer, EntityPlayerMP player, EntityNPCInterface npc) throws Exception {
if(type == EnumPacketServer.ScriptDataSave){ if(type == EnumPacketServer.ScriptDataSave){
npc.script.readFromNBT(Server.readNBT(buffer)); npc.script.readFromNBT(Server.readNBT(buffer));
@@ -128,6 +151,42 @@ public class PacketHandlerServer{
} }
} }
private void playerScriptPackets(EnumPacketServer type, ByteBuf buffer, EntityPlayerMP player) throws Exception {
NBTTagCompound compound;
if(type == EnumPacketServer.ScriptPlayerGet) {
PlayerDataScript data = ScriptController.Instance.playerScripts;
compound = data.writeToNBT(new NBTTagCompound());
compound.setTag("Languages", ScriptController.Instance.nbtLanguages());
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
} else if(type == EnumPacketServer.ScriptPlayerSave) {
ScriptController.Instance.setPlayerScripts(Server.readNBT(buffer));
}
}
private void forgeScriptPackets(EnumPacketServer type, ByteBuf buffer, EntityPlayerMP player) throws Exception {
NBTTagCompound compound;
if (type == EnumPacketServer.ScriptForgeGet) {
ForgeDataScript data = ScriptController.Instance.forgeScripts;
compound = data.writeToNBT(new NBTTagCompound());
compound.setTag("Languages", ScriptController.Instance.nbtLanguages());
Server.sendData(player, EnumPacketClient.GUI_DATA, new Object[]{compound});
} else if (type == EnumPacketServer.ScriptForgeSave) {
ScriptController.Instance.setForgeScripts(Server.readNBT(buffer));
}
}
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>();
@@ -225,7 +284,7 @@ public class PacketHandlerServer{
} }
else if(type == EnumPacketServer.FactionGet){ else if(type == EnumPacketServer.FactionGet){
NBTTagCompound compound = new NBTTagCompound(); NBTTagCompound compound = new NBTTagCompound();
Faction faction = FactionController.getInstance().getFaction(buffer.readInt()); Faction faction = FactionController.getInstance().get(buffer.readInt());
faction.writeNBT(compound); faction.writeNBT(compound);
Server.sendData(player, EnumPacketClient.GUI_DATA, compound); Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
} }
@@ -341,7 +400,7 @@ public class PacketHandlerServer{
NoppesUtilServer.setRecipeGui(player,recipe); NoppesUtilServer.setRecipeGui(player,recipe);
} }
else if(type == EnumPacketServer.RecipeRemove){ else if(type == EnumPacketServer.RecipeRemove){
RecipeCarpentry recipe = RecipeController.instance.removeRecipe(buffer.readInt()); RecipeCarpentry recipe = RecipeController.instance.delete(buffer.readInt());
NoppesUtilServer.sendRecipeData(player, recipe.isGlobal?3:4); NoppesUtilServer.sendRecipeData(player, recipe.isGlobal?3:4);
NoppesUtilServer.setRecipeGui(player,new RecipeCarpentry("")); NoppesUtilServer.setRecipeGui(player,new RecipeCarpentry(""));
} }
@@ -523,7 +582,7 @@ public class PacketHandlerServer{
Server.sendData(player, EnumPacketClient.GUI_DATA, compound); Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
} }
else if(type == EnumPacketServer.FactionRemove){ else if(type == EnumPacketServer.FactionRemove){
FactionController.getInstance().removeFaction(buffer.readInt()); FactionController.getInstance().delete(buffer.readInt());
NoppesUtilServer.sendFactionDataAll(player); NoppesUtilServer.sendFactionDataAll(player);
NBTTagCompound compound = new NBTTagCompound(); NBTTagCompound compound = new NBTTagCompound();
(new Faction()).writeNBT(compound); (new Faction()).writeNBT(compound);
+4 -2
View File
@@ -6,6 +6,8 @@ import java.util.Vector;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.constants.EnumQuestCompletion; import noppes.npcs.constants.EnumQuestCompletion;
import noppes.npcs.controllers.PlayerData;
import noppes.npcs.controllers.PlayerDataController;
import noppes.npcs.controllers.PlayerQuestController; import noppes.npcs.controllers.PlayerQuestController;
import noppes.npcs.controllers.Quest; import noppes.npcs.controllers.Quest;
@@ -34,7 +36,7 @@ public class QuestLogData {
} }
public void setData(EntityPlayer player){ public void setData(EntityPlayer player){
PlayerData playerData = PlayerDataController.instance.getPlayerData(player);
for(Quest quest : PlayerQuestController.getActiveQuests(player)) for(Quest quest : PlayerQuestController.getActiveQuests(player))
{ {
String category = quest.category.title; String category = quest.category.title;
@@ -46,7 +48,7 @@ public class QuestLogData {
questText.put(category + ":" + quest.title, quest.logText); questText.put(category + ":" + quest.title, quest.logText);
questStatus.put(category + ":" + quest.title, quest.questInterface.getQuestLogStatus(player)); questStatus.put(category + ":" + quest.title, quest.questInterface.getQuestLogStatus(player));
if(quest.completion == EnumQuestCompletion.Npc && quest.questInterface.isCompleted(player)) if(quest.completion == EnumQuestCompletion.Npc && quest.questInterface.isCompleted(playerData))
finish.put(category + ":" + quest.title, quest.completerNpc); finish.put(category + ":" + quest.title, quest.completerNpc);
} }
} }
@@ -9,6 +9,8 @@ public class Resistances {
public float arrow = 1f; public float arrow = 1f;
public float playermelee = 1f; public float playermelee = 1f;
public float explosion = 1f; public float explosion = 1f;
public boolean disableDamage = false;
public NBTTagCompound writeToNBT() { public NBTTagCompound writeToNBT() {
NBTTagCompound compound = new NBTTagCompound(); NBTTagCompound compound = new NBTTagCompound();
@@ -16,6 +18,7 @@ public class Resistances {
compound.setFloat("Arrow", arrow); compound.setFloat("Arrow", arrow);
compound.setFloat("Melee", playermelee); compound.setFloat("Melee", playermelee);
compound.setFloat("Explosion", explosion); compound.setFloat("Explosion", explosion);
compound.setBoolean("disableDamage", disableDamage);
return compound; return compound;
} }
@@ -24,9 +27,14 @@ public class Resistances {
arrow = compound.getFloat("Arrow"); arrow = compound.getFloat("Arrow");
playermelee = compound.getFloat("Melee"); playermelee = compound.getFloat("Melee");
explosion = compound.getFloat("Explosion"); explosion = compound.getFloat("Explosion");
disableDamage = compound.getBoolean("disableDamage");
} }
public float applyResistance(DamageSource source, float damage) { public float applyResistance(DamageSource source, float damage) {
if(disableDamage){
return 0;
}
if(source.damageType.equals("arrow") || source.damageType.equals("thrown")){ if(source.damageType.equals("arrow") || source.damageType.equals("thrown")){
damage *= (2 - arrow); damage *= (2 - arrow);
} }
@@ -0,0 +1,126 @@
package noppes.npcs;
import com.google.common.reflect.ClassPath;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.ModContainer;
import cpw.mods.fml.common.eventhandler.Event;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.PlayerEvent;
import cpw.mods.fml.common.gameevent.TickEvent;
import cpw.mods.fml.common.network.FMLNetworkEvent;
import cpw.mods.fml.relauncher.Side;
import net.minecraft.world.WorldServer;
import net.minecraftforge.event.entity.EntityEvent;
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
import net.minecraftforge.event.world.ChunkDataEvent;
import net.minecraftforge.event.world.ChunkEvent;
import net.minecraftforge.event.world.ChunkWatchEvent;
import net.minecraftforge.event.world.WorldEvent;
import noppes.npcs.controllers.PixelmonHelper;
import noppes.npcs.controllers.ScriptController;
import noppes.npcs.scripted.event.ForgeEvent;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.Vector;
public class ScriptForgeEventHandler {
public ScriptForgeEventHandler() {
}
@SubscribeEvent
public void forgeEntity(Event event) {
if(CustomNpcs.getServer() != null && ScriptController.Instance.forgeScripts.isEnabled()) {
if(event instanceof TickEvent && !(((TickEvent)event).side == Side.SERVER && ((TickEvent)event).phase == TickEvent.Phase.START)) {
return;
}
if(event instanceof EntityEvent) {
EntityEvent ev2 = (EntityEvent)event;
if(ev2.entity != null && ev2.entity.worldObj instanceof WorldServer) {
EventHooks.onForgeEntityEvent(ev2);
}
} else if(event instanceof WorldEvent) {
WorldEvent ev1 = (WorldEvent)event;
if(ev1.world instanceof WorldServer) {
EventHooks.onForgeWorldEvent(ev1);
}
} else if(!(event instanceof TickEvent) || ((TickEvent)event).side != Side.CLIENT) {
if (event instanceof PlayerEvent) {
PlayerEvent ev = (PlayerEvent) event;
if (ev.player == null || !(ev.player.worldObj instanceof WorldServer)) {
return;
}
}
EventHooks.onForgeEvent(new ForgeEvent(event), event);
}
}
}
public ScriptForgeEventHandler registerForgeEvents() {
try {
Method e = this.getClass().getMethod("forgeEntity", new Class[]{Event.class});
Method register = FMLCommonHandler.instance().bus().getClass().getDeclaredMethod("register", new Class[]{Class.class, Object.class, Method.class, ModContainer.class});
register.setAccessible(true);
ArrayList list = new ArrayList();
list.addAll(ClassPath.from(this.getClass().getClassLoader()).getTopLevelClassesRecursive("cpw.mods.fml.common.gameevent"));
list.addAll(ClassPath.from(this.getClass().getClassLoader()).getTopLevelClassesRecursive("net.minecraftforge.event"));
list.removeAll(ClassPath.from(this.getClass().getClassLoader()).getTopLevelClassesRecursive("net.minecraftforge.event.terraingen"));
Iterator e1 = list.iterator();
while(true) {
ClassPath.ClassInfo classLoader;
String classes;
do {
if(!e1.hasNext()) {
if(PixelmonHelper.Enabled) {
try {
Field e2 = ClassLoader.class.getDeclaredField("classes");
e2.setAccessible(true);
ClassLoader classLoader1 = Thread.currentThread().getContextClassLoader();
ArrayList classes1 = new ArrayList((Vector)e2.get(classLoader1));
Iterator infoClass1 = classes1.iterator();
while(infoClass1.hasNext()) {
Class c2 = (Class)infoClass1.next();
}
} catch (Exception var12) {
var12.printStackTrace();
}
return this;
}
return this;
}
classLoader = (ClassPath.ClassInfo)e1.next();
classes = classLoader.getName();
} while(classes.startsWith("net.minecraftforge.event.terraingen"));
Class infoClass = classLoader.load();
ArrayList c = new ArrayList(Arrays.asList(infoClass.getDeclaredClasses()));
if(c.isEmpty()) {
c.add(infoClass);
}
Iterator var10 = c.iterator();
while(var10.hasNext()) {
Class c1 = (Class)var10.next();
if(!EntityEvent.EntityConstructing.class.isAssignableFrom(c1) && !WorldEvent.PotentialSpawns.class.isAssignableFrom(c1) && !TickEvent.RenderTickEvent.class.isAssignableFrom(c1) && !TickEvent.ClientTickEvent.class.isAssignableFrom(c1) && !FMLNetworkEvent.ClientCustomPacketEvent.class.isAssignableFrom(c1) && !ItemTooltipEvent.class.isAssignableFrom(c1) && Event.class.isAssignableFrom(c1) && !Modifier.isAbstract(c1.getModifiers()) && Modifier.isPublic(c1.getModifiers()) && !ChunkEvent.class.isAssignableFrom(c1) && !ChunkWatchEvent.class.isAssignableFrom(c1) && !ChunkDataEvent.class.isAssignableFrom(c1)) {
register.invoke(FMLCommonHandler.instance().bus(), new Object[]{c1, this, e, Loader.instance().activeModContainer()});
}
}
}
} catch (Exception var13) {
var13.printStackTrace();
return this;
}
}
}
@@ -0,0 +1,488 @@
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package noppes.npcs;
import com.google.common.reflect.ClassPath;
import com.google.common.reflect.ClassPath.ClassInfo;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.Vector;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.ModContainer;
import cpw.mods.fml.common.eventhandler.Event;
import cpw.mods.fml.common.eventhandler.EventPriority;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.InputEvent;
import cpw.mods.fml.common.gameevent.PlayerEvent;
import cpw.mods.fml.common.gameevent.TickEvent;
import cpw.mods.fml.common.network.FMLNetworkEvent;
import cpw.mods.fml.relauncher.Side;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ContainerPlayer;
import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.WorldServer;
import net.minecraftforge.common.ForgeHooks;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.EntityEvent;
import net.minecraftforge.event.entity.EntityEvent.EntityConstructing;
import net.minecraftforge.event.entity.EntityStruckByLightningEvent;
import net.minecraftforge.event.entity.PlaySoundAtEntityEvent;
import net.minecraftforge.event.entity.item.ItemTossEvent;
import net.minecraftforge.event.entity.living.LivingDeathEvent;
import net.minecraftforge.event.entity.living.LivingEvent;
import net.minecraftforge.event.entity.living.LivingFallEvent;
import net.minecraftforge.event.entity.living.LivingHurtEvent;
import net.minecraftforge.event.entity.player.*;
import net.minecraftforge.event.world.*;
import net.minecraftforge.event.world.WorldEvent.PotentialSpawns;
import noppes.npcs.constants.EnumQuestType;
import noppes.npcs.controllers.*;
import noppes.npcs.controllers.data.PlayerDataScript;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.scripted.entity.ScriptPlayer;
import noppes.npcs.scripted.event.ForgeEvent;
import org.lwjgl.input.Mouse;
public class ScriptPlayerEventHandler {
public ScriptPlayerEventHandler() {
}
@SubscribeEvent
public void onServerTick(TickEvent.PlayerTickEvent event) {
if(event.player == null || event.player.worldObj == null)
return;
if(event.side == Side.SERVER && event.phase == TickEvent.Phase.START) {
EntityPlayer player = event.player;
if(player.ticksExisted%10 == 0) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(player);
EventHooks.onPlayerTick(handler, scriptPlayer);
}
PlayerData playerData = PlayerDataController.instance.getPlayerData(player);
if(PlayerDataController.instance != null) {
if(playerData.timers.size() > 0)
playerData.timers.update();
}
if(player.ticksExisted%(20*CustomNpcs.PlayerQuestCheck) == 0){
PlayerQuestData questData = playerData.questData;
for(EnumQuestType e : EnumQuestType.values())
questData.checkQuestCompletion(playerData, e);
}
}
}
@SubscribeEvent
public void invoke(EntityInteractEvent event) {
if(event.entityPlayer == null || event.entityPlayer.worldObj == null)
return;
if(!event.entityPlayer.worldObj.isRemote && event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
noppes.npcs.scripted.event.PlayerEvent.InteractEvent ev = new noppes.npcs.scripted.event.PlayerEvent.InteractEvent(scriptPlayer, 1, NpcAPI.Instance().getIEntity(event.target));
event.setCanceled(EventHooks.onPlayerInteract(handler, ev));
}
}
@SubscribeEvent
public void invoke(ArrowNockEvent event) {
if(event.entityPlayer == null || event.entityPlayer.worldObj == null)
return;
if(!event.entityPlayer.worldObj.isRemote && event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
noppes.npcs.scripted.event.PlayerEvent.RangedChargeEvent ev = new noppes.npcs.scripted.event.PlayerEvent.RangedChargeEvent(scriptPlayer);
EventHooks.onPlayerBowCharge(handler, ev);
}
}
@SubscribeEvent
public void invoke(ArrowLooseEvent event) {
if(event.entityPlayer == null || event.entityPlayer.worldObj == null)
return;
if(!event.entityPlayer.worldObj.isRemote && event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
noppes.npcs.scripted.event.PlayerEvent.RangedLaunchedEvent ev = new noppes.npcs.scripted.event.PlayerEvent.RangedLaunchedEvent(scriptPlayer, event.bow, event.charge);
EventHooks.onPlayerRanged(handler, ev);
}
}
@SubscribeEvent
public void invoke(BlockEvent.BreakEvent event) {
if(event.getPlayer() == null || event.getPlayer().worldObj == null)
return;
if(!event.getPlayer().worldObj.isRemote && event.world instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.getPlayer());
noppes.npcs.scripted.event.PlayerEvent.BreakEvent ev = new noppes.npcs.scripted.event.PlayerEvent.BreakEvent(scriptPlayer, NpcAPI.Instance().getIBlock(event.world, new BlockPos(event.x,event.y,event.z)), event.getExpToDrop());
event.setCanceled(EventHooks.onPlayerBreak(handler, ev));
event.setExpToDrop(ev.exp);
}
}
@SubscribeEvent
public void invoke(PlayerUseItemEvent.Start event) {
if(event.entityPlayer == null || event.entityPlayer.worldObj == null)
return;
if(event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
event.setCanceled(EventHooks.onStartUsingItem(handler, scriptPlayer, event.duration, event.item));
}
}
@SubscribeEvent
public void invoke(PlayerUseItemEvent.Tick event) {
if(event.entityPlayer == null || event.entityPlayer.worldObj == null)
return;
if(event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
event.setCanceled(EventHooks.onUsingItem(handler, scriptPlayer, event.duration, event.item));
}
}
@SubscribeEvent
public void invoke(PlayerUseItemEvent.Stop event) {
if(event.entityPlayer == null || event.entityPlayer.worldObj == null)
return;
if(event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
event.setCanceled(EventHooks.onStopUsingItem(handler, scriptPlayer, event.duration, event.item));
}
}
@SubscribeEvent
public void invoke(PlayerUseItemEvent.Finish event) {
if(event.entityPlayer == null || event.entityPlayer.worldObj == null)
return;
if(event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
EventHooks.onFinishUsingItem(handler, scriptPlayer, event.duration, event.item);
}
}
@SubscribeEvent
public void invoke(PlayerDropsEvent event) {
if(event.entityPlayer == null || event.entityPlayer.worldObj == null)
return;
if(event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
event.setCanceled(EventHooks.onPlayerDropItems(handler, scriptPlayer, event.drops));
}
}
@SubscribeEvent
public void invoke(PlayerPickupXpEvent event) {
if(event.entityPlayer == null || event.entityPlayer.worldObj == null)
return;
if(event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
EventHooks.onPlayerPickupXP(handler, scriptPlayer, event.orb);
}
}
@SubscribeEvent
public void invoke(PlayerEvent.PlayerChangedDimensionEvent event) {
if(event.player == null || event.player.worldObj == null)
return;
if(event.player.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.player);
EventHooks.onPlayerChangeDim(handler, scriptPlayer, event.fromDim, event.toDim);
}
}
@SubscribeEvent
public void invoke(PlayerEvent.ItemPickupEvent event) {
if(event.player == null || event.player.worldObj == null)
return;
if(event.player.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.player);
EventHooks.onPlayerPickUp(handler, scriptPlayer, event.pickedUp);
}
}
@SubscribeEvent
public void invoke(PlayerOpenContainerEvent event) {
if(event.entityPlayer == null || event.entityPlayer.worldObj == null)
return;
if(event.entityPlayer.worldObj instanceof WorldServer && !(event.entityPlayer.openContainer instanceof ContainerPlayer)) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
EventHooks.onPlayerContainerOpen(handler, scriptPlayer, event.entityPlayer.openContainer);
}
}
@SubscribeEvent
public void invoke(UseHoeEvent event) {
if(event.entityPlayer == null || event.entityPlayer.worldObj == null)
return;
if(event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
EventHooks.onPlayerUseHoe(handler, scriptPlayer, event.current, event.x, event.y, event.z);
}
}
@SubscribeEvent
public void invoke(PlayerSleepInBedEvent event) {
if(event.entityPlayer == null || event.entityPlayer.worldObj == null)
return;
if(event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
EventHooks.onPlayerSleep(handler, scriptPlayer, event.x, event.y, event.z);
}
}
@SubscribeEvent
public void invoke(PlayerWakeUpEvent event) {
if(event.entityPlayer == null || event.entityPlayer.worldObj == null)
return;
if(event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
EventHooks.onPlayerWakeUp(handler, scriptPlayer, event.setSpawn);
}
}
@SubscribeEvent
public void invoke(FillBucketEvent event) {
if(event.entityPlayer == null || event.entityPlayer.worldObj == null)
return;
if(event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
EventHooks.onPlayerFillBucket(handler, scriptPlayer, event.current, event.result);
}
}
@SubscribeEvent
public void invoke(BonemealEvent event) {
if(event.entityPlayer == null || event.entityPlayer.worldObj == null)
return;
if(event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
EventHooks.onPlayerBonemeal(handler, scriptPlayer, event.x, event.y, event.z, event.world);
}
}
@SubscribeEvent
public void invoke(AchievementEvent event) {
if(event.entityPlayer == null || event.entityPlayer.worldObj == null)
return;
if(event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
EventHooks.onPlayerAchievement(handler, scriptPlayer, CustomNpcs.proxy.getAchievementDesc(event.achievement));
}
}
@SubscribeEvent
public void invoke(ItemTossEvent event) {
if(event.player == null || event.player.worldObj == null)
return;
if(event.player.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.player);
EventHooks.onPlayerToss(handler, scriptPlayer, event.entityItem);
}
}
@SubscribeEvent
public void invoke(LivingFallEvent event) {
if(event.entityLiving == null || event.entityLiving.worldObj == null)
return;
if(event.entityLiving.worldObj instanceof WorldServer) {
if (event.entityLiving instanceof EntityPlayer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityLiving);
EventHooks.onPlayerFall(handler, scriptPlayer, event.distance);
}
}
}
@SubscribeEvent
public void invoke(LivingEvent.LivingJumpEvent event) {
if(event.entityLiving == null || event.entityLiving.worldObj == null)
return;
if(event.entityLiving.worldObj instanceof WorldServer) {
if (event.entityLiving instanceof EntityPlayer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityLiving);
EventHooks.onPlayerJump(handler, scriptPlayer);
}
}
}
@SubscribeEvent
public void invoke(EntityStruckByLightningEvent event) {
if(event.entity == null || event.entity.worldObj == null)
return;
if(event.entity.worldObj instanceof WorldServer) {
if (event.entity instanceof EntityPlayer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entity);
EventHooks.onPlayerLightning(handler, scriptPlayer);
}
}
}
@SubscribeEvent
public void invoke(PlaySoundAtEntityEvent event) {
if(event.entity == null || event.entity.worldObj == null)
return;
if(event.entity.worldObj instanceof WorldServer) {
if (event.entity instanceof EntityPlayer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entity);
EventHooks.onPlayerSound(handler,scriptPlayer,event.name,event.pitch,event.volume);
}
}
}
@SubscribeEvent
public void invoke(LivingDeathEvent event) {
if(event.entityLiving == null || event.entityLiving.worldObj == null)
return;
if(event.entityLiving.worldObj instanceof WorldServer) {
Entity source = NoppesUtilServer.GetDamageSourcee(event.source);
PlayerDataScript handler = ScriptController.Instance.playerScripts;
if(event.entityLiving instanceof EntityPlayer) {
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityLiving);
EventHooks.onPlayerDeath(handler,scriptPlayer, event.source, source);
}
if(source instanceof EntityPlayer) {
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.source.getEntity());
EventHooks.onPlayerKills(handler,scriptPlayer, event.entityLiving);
}
}
}
@SubscribeEvent
public void invoke(LivingHurtEvent event) {
if(event.entityLiving == null || event.entityLiving.worldObj == null)
return;
if(event.entityLiving.worldObj instanceof WorldServer) {
Entity source = NoppesUtilServer.GetDamageSourcee(event.source);
PlayerDataScript handler = ScriptController.Instance.playerScripts;
if(event.entityLiving instanceof EntityPlayer) {
noppes.npcs.scripted.event.PlayerEvent.DamagedEvent pevent = new noppes.npcs.scripted.event.PlayerEvent.DamagedEvent((ScriptPlayer)ScriptController.Instance.getScriptForEntity((EntityPlayer)event.entityLiving), source, event.ammount, event.source);
event.setCanceled(EventHooks.onPlayerDamaged(handler, pevent));
event.ammount = pevent.damage;
}
if(source instanceof EntityPlayer) {
noppes.npcs.scripted.event.PlayerEvent.DamagedEntityEvent pevent1 = new noppes.npcs.scripted.event.PlayerEvent.DamagedEntityEvent((ScriptPlayer)ScriptController.Instance.getScriptForEntity((EntityPlayer)event.source.getEntity()), event.entityLiving, event.ammount, event.source);
event.setCanceled(EventHooks.onPlayerDamagedEntity(handler, pevent1));
event.ammount = pevent1.damage;
}
}
}
@SubscribeEvent
public void invoke(PlayerEvent.PlayerRespawnEvent event) {
if(event.player == null || event.player.worldObj == null)
return;
if(event.player.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.player);
EventHooks.onPlayerRespawn(handler, scriptPlayer);
}
}
@SubscribeEvent
public void invoke(PlayerEvent.PlayerLoggedInEvent event) {
if(event.player == null || event.player.worldObj == null)
return;
if(event.player.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.player);
EventHooks.onPlayerLogin(handler, scriptPlayer);
}
}
@SubscribeEvent
public void invoke(PlayerEvent.PlayerLoggedOutEvent event) {
if(event.player == null || event.player.worldObj == null)
return;
if(event.player.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.player);
EventHooks.onPlayerLogout(handler, scriptPlayer);
}
}
@SubscribeEvent(
priority = EventPriority.HIGHEST
)
public void invoke(net.minecraftforge.event.ServerChatEvent event) {
if(event.player == null || event.player.worldObj == null)
return;
if(event.player.worldObj instanceof WorldServer && !event.player.equals(EntityNPCInterface.chateventPlayer)) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.player);
String message = event.message;
noppes.npcs.scripted.event.PlayerEvent.ChatEvent ev = new noppes.npcs.scripted.event.PlayerEvent.ChatEvent(scriptPlayer, event.message);
EventHooks.onPlayerChat(handler, ev);
event.setCanceled(ev.isCanceled());
if(!message.equals(ev.message)) {
ChatComponentTranslation chat = new ChatComponentTranslation("", new Object[0]);
chat.appendSibling(ForgeHooks.newChatWithLinks(ev.message));
event.component = chat;
}
}
}
}
@@ -35,14 +35,7 @@ import noppes.npcs.constants.EnumPacketClient;
import noppes.npcs.constants.EnumQuestType; import noppes.npcs.constants.EnumQuestType;
import noppes.npcs.constants.EnumRoleType; import noppes.npcs.constants.EnumRoleType;
import noppes.npcs.constants.EnumScriptType; import noppes.npcs.constants.EnumScriptType;
import noppes.npcs.controllers.Line; import noppes.npcs.controllers.*;
import noppes.npcs.controllers.PlayerData;
import noppes.npcs.controllers.PlayerDataController;
import noppes.npcs.controllers.PlayerQuestData;
import noppes.npcs.controllers.QuestData;
import noppes.npcs.controllers.RecipeCarpentry;
import noppes.npcs.controllers.RecipeController;
import noppes.npcs.controllers.ServerCloneController;
import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.items.ItemExcalibur; import noppes.npcs.items.ItemExcalibur;
import noppes.npcs.items.ItemShield; import noppes.npcs.items.ItemShield;
@@ -54,7 +47,7 @@ public class ServerEventsHandler {
public static EntityVillager Merchant; public static EntityVillager Merchant;
public static Entity mounted; public static Entity mounted;
// private HashMap<String, Integer> exps = new HashMap<String, Integer>(); // private HashMap<String, Integer> exps = new HashMap<String, Integer>();
// //
// @SubscribeEvent // @SubscribeEvent
@@ -64,10 +57,10 @@ public class ServerEventsHandler {
// EntityPlayer player = (EntityPlayer) event.entityLiving; // EntityPlayer player = (EntityPlayer) event.entityLiving;
// if(exps.containsKey(player.getCommandSenderName())){ // if(exps.containsKey(player.getCommandSenderName())){
// int prevExp = exps.get(player.getCommandSenderName()); // int prevExp = exps.get(player.getCommandSenderName());
// if(prevExp > player.experienceTotal){ // if(prevExp > player.experienceTotal){
// player.addChatMessage(new ChatComponentText("Omg exp was gotten:" + (player.experienceTotal - prevExp))); // player.addChatMessage(new ChatComponentText("Omg exp was gotten:" + (player.experienceTotal - prevExp)));
// } // }
// else if(prevExp < player.experienceTotal){ // else if(prevExp < player.experienceTotal){
// player.addChatMessage(new ChatComponentText("Omg exp was lost:" + (prevExp - player.experienceTotal))); // player.addChatMessage(new ChatComponentText("Omg exp was lost:" + (prevExp - player.experienceTotal)));
// } // }
// } // }
@@ -85,11 +78,11 @@ public class ServerEventsHandler {
if(!isRemote && CustomNpcs.OpsOnly && !MinecraftServer.getServer().getConfigurationManager().func_152596_g(event.entityPlayer.getGameProfile())){ if(!isRemote && CustomNpcs.OpsOnly && !MinecraftServer.getServer().getConfigurationManager().func_152596_g(event.entityPlayer.getGameProfile())){
return; return;
} }
if(!isRemote && item.getItem() == CustomItems.soulstoneEmpty && event.target instanceof EntityLivingBase) { if(!isRemote && item.getItem() == CustomItems.soulstoneEmpty && event.target instanceof EntityLivingBase) {
((ItemSoulstoneEmpty)item.getItem()).store((EntityLivingBase)event.target, item, event.entityPlayer); ((ItemSoulstoneEmpty)item.getItem()).store((EntityLivingBase)event.target, item, event.entityPlayer);
} }
if(item.getItem() == CustomItems.wand && npcInteracted && !isRemote){ if(item.getItem() == CustomItems.wand && npcInteracted && !isRemote){
if (!CustomNpcsPermissions.Instance.hasPermission(event.entityPlayer, CustomNpcsPermissions.NPC_GUI)){ if (!CustomNpcsPermissions.Instance.hasPermission(event.entityPlayer, CustomNpcsPermissions.NPC_GUI)){
return; return;
@@ -111,43 +104,43 @@ public class ServerEventsHandler {
else if(item.getItem() == CustomItems.scripter && !isRemote && npcInteracted){ else if(item.getItem() == CustomItems.scripter && !isRemote && npcInteracted){
if(!CustomNpcsPermissions.Instance.hasPermission(event.entityPlayer, CustomNpcsPermissions.NPC_GUI)) if(!CustomNpcsPermissions.Instance.hasPermission(event.entityPlayer, CustomNpcsPermissions.NPC_GUI))
return; return;
NoppesUtilServer.setEditingNpc(event.entityPlayer, (EntityNPCInterface)event.target); NoppesUtilServer.setEditingNpc(event.entityPlayer, (EntityNPCInterface)event.target);
event.setCanceled(true); event.setCanceled(true);
Server.sendData((EntityPlayerMP)event.entityPlayer, EnumPacketClient.GUI, EnumGuiType.Script.ordinal()); Server.sendData((EntityPlayerMP)event.entityPlayer, EnumPacketClient.GUI, EnumGuiType.Script.ordinal());
} }
else if(item.getItem() == CustomItems.mount){ else if(item.getItem() == CustomItems.mount){
if(!CustomNpcsPermissions.Instance.hasPermission(event.entityPlayer, CustomNpcsPermissions.TOOL_MOUNTER)) if(!CustomNpcsPermissions.Instance.hasPermission(event.entityPlayer, CustomNpcsPermissions.TOOL_MOUNTER))
return; return;
event.setCanceled(true); event.setCanceled(true);
mounted = event.target; mounted = event.target;
if(isRemote) if(isRemote)
CustomNpcs.proxy.openGui(MathHelper.floor_double(mounted.posX), MathHelper.floor_double(mounted.posY), MathHelper.floor_double(mounted.posZ), EnumGuiType.MobSpawnerMounter, event.entityPlayer); CustomNpcs.proxy.openGui(MathHelper.floor_double(mounted.posX), MathHelper.floor_double(mounted.posY), MathHelper.floor_double(mounted.posZ), EnumGuiType.MobSpawnerMounter, event.entityPlayer);
} }
else if(item.getItem() == CustomItems.wand && event.target instanceof EntityVillager){ else if(item.getItem() == CustomItems.wand && event.target instanceof EntityVillager){
if(!CustomNpcsPermissions.Instance.hasPermission(event.entityPlayer, CustomNpcsPermissions.EDIT_VILLAGER)) if(!CustomNpcsPermissions.Instance.hasPermission(event.entityPlayer, CustomNpcsPermissions.EDIT_VILLAGER))
return; return;
event.setCanceled(true); event.setCanceled(true);
Merchant = (EntityVillager)event.target; Merchant = (EntityVillager)event.target;
if(!isRemote){ if(!isRemote){
EntityPlayerMP player = (EntityPlayerMP) event.entityPlayer; EntityPlayerMP player = (EntityPlayerMP) event.entityPlayer;
player.openGui(CustomNpcs.instance, EnumGuiType.MerchantAdd.ordinal(), player.worldObj, 0, 0, 0); player.openGui(CustomNpcs.instance, EnumGuiType.MerchantAdd.ordinal(), player.worldObj, 0, 0, 0);
MerchantRecipeList merchantrecipelist = Merchant.getRecipes(player); MerchantRecipeList merchantrecipelist = Merchant.getRecipes(player);
if (merchantrecipelist != null) if (merchantrecipelist != null)
{ {
Server.sendData(player, EnumPacketClient.VILLAGER_LIST, merchantrecipelist); Server.sendData(player, EnumPacketClient.VILLAGER_LIST, merchantrecipelist);
} }
} }
} }
} }
@SubscribeEvent @SubscribeEvent
public void invoke(LivingHurtEvent event) { public void invoke(LivingHurtEvent event) {
if(!(event.entityLiving instanceof EntityPlayer)) if(!(event.entityLiving instanceof EntityPlayer))
return; return;
EntityPlayer player = (EntityPlayer) event.entityLiving; EntityPlayer player = (EntityPlayer) event.entityLiving;
if(event.source.isUnblockable() || event.source.isFireDamage()) if(event.source.isUnblockable() || event.source.isFireDamage())
return; return;
@@ -159,7 +152,7 @@ public class ServerEventsHandler {
if(((ItemShield)item.getItem()).material.getDamageVsEntity() < player.getRNG().nextInt(9)) if(((ItemShield)item.getItem()).material.getDamageVsEntity() < player.getRNG().nextInt(9))
return; return;
float damage = item.getItemDamage() + event.ammount; float damage = item.getItemDamage() + event.ammount;
item.damageItem((int) event.ammount, player); item.damageItem((int) event.ammount, player);
if(damage > item.getMaxDamage()) if(damage > item.getMaxDamage())
@@ -169,7 +162,7 @@ public class ServerEventsHandler {
event.setCanceled(true); event.setCanceled(true);
} }
} }
@SubscribeEvent @SubscribeEvent
public void invoke(PlayerInteractEvent event) { public void invoke(PlayerInteractEvent event) {
EntityPlayer player = event.entityPlayer; EntityPlayer player = event.entityPlayer;
@@ -177,50 +170,50 @@ public class ServerEventsHandler {
if(event.action == Action.LEFT_CLICK_BLOCK && player.getHeldItem() != null && player.getHeldItem().getItem() == CustomItems.teleporter){ if(event.action == Action.LEFT_CLICK_BLOCK && player.getHeldItem() != null && player.getHeldItem().getItem() == CustomItems.teleporter){
event.setCanceled(true); event.setCanceled(true);
} }
if(block == Blocks.crafting_table && event.action == Action.RIGHT_CLICK_BLOCK && !player.worldObj.isRemote){ if(block == Blocks.crafting_table && event.action == Action.RIGHT_CLICK_BLOCK && !player.worldObj.isRemote){
RecipeController controller = RecipeController.instance; RecipeController controller = RecipeController.instance;
NBTTagList list = new NBTTagList(); NBTTagList list = new NBTTagList();
int i = 0; int i = 0;
for(RecipeCarpentry recipe : controller.globalRecipes.values()){ for(RecipeCarpentry recipe : controller.globalRecipes.values()){
list.appendTag(recipe.writeNBT()); list.appendTag(recipe.writeNBT());
i++; i++;
if(i % 10 == 0){ if(i % 10 == 0){
NBTTagCompound compound = new NBTTagCompound(); NBTTagCompound compound = new NBTTagCompound();
compound.setTag("recipes", list); compound.setTag("recipes", list);
Server.sendData((EntityPlayerMP)player, EnumPacketClient.SYNCRECIPES_ADD, compound); Server.sendData((EntityPlayerMP)player, EnumPacketClient.SYNCRECIPES_ADD, compound);
list = new NBTTagList(); list = new NBTTagList();
} }
} }
if(i % 10 != 0){ if(i % 10 != 0){
NBTTagCompound compound = new NBTTagCompound(); NBTTagCompound compound = new NBTTagCompound();
compound.setTag("recipes", list); compound.setTag("recipes", list);
Server.sendData((EntityPlayerMP)player, EnumPacketClient.SYNCRECIPES_ADD, compound); Server.sendData((EntityPlayerMP)player, EnumPacketClient.SYNCRECIPES_ADD, compound);
} }
Server.sendData((EntityPlayerMP)player, EnumPacketClient.SYNCRECIPES_WORKBENCH); Server.sendData((EntityPlayerMP)player, EnumPacketClient.SYNCRECIPES_WORKBENCH);
} }
if(block == CustomItems.carpentyBench && event.action == Action.RIGHT_CLICK_BLOCK && !player.worldObj.isRemote){ if(block == CustomItems.carpentyBench && event.action == Action.RIGHT_CLICK_BLOCK && !player.worldObj.isRemote){
RecipeController controller = RecipeController.instance; RecipeController controller = RecipeController.instance;
NBTTagList list = new NBTTagList(); NBTTagList list = new NBTTagList();
int i = 0; int i = 0;
for(RecipeCarpentry recipe : controller.anvilRecipes.values()){ for(RecipeCarpentry recipe : controller.anvilRecipes.values()){
list.appendTag(recipe.writeNBT()); list.appendTag(recipe.writeNBT());
i++; i++;
if(i % 10 == 0){ if(i % 10 == 0){
NBTTagCompound compound = new NBTTagCompound(); NBTTagCompound compound = new NBTTagCompound();
compound.setTag("recipes", list); compound.setTag("recipes", list);
Server.sendData((EntityPlayerMP)player, EnumPacketClient.SYNCRECIPES_ADD, compound); Server.sendData((EntityPlayerMP)player, EnumPacketClient.SYNCRECIPES_ADD, compound);
list = new NBTTagList(); list = new NBTTagList();
} }
} }
if(i % 10 != 0){ if(i % 10 != 0){
NBTTagCompound compound = new NBTTagCompound(); NBTTagCompound compound = new NBTTagCompound();
compound.setTag("recipes", list); compound.setTag("recipes", list);
Server.sendData((EntityPlayerMP)player, EnumPacketClient.SYNCRECIPES_ADD, compound); Server.sendData((EntityPlayerMP)player, EnumPacketClient.SYNCRECIPES_ADD, compound);
} }
Server.sendData((EntityPlayerMP)player, EnumPacketClient.SYNCRECIPES_CARPENTRYBENCH); Server.sendData((EntityPlayerMP)player, EnumPacketClient.SYNCRECIPES_CARPENTRYBENCH);
} }
if((block == CustomItems.banner || block == CustomItems.wallBanner || block == CustomItems.sign) && event.action == Action.RIGHT_CLICK_BLOCK){ if((block == CustomItems.banner || block == CustomItems.wallBanner || block == CustomItems.sign) && event.action == Action.RIGHT_CLICK_BLOCK){
ItemStack item = player.inventory.getCurrentItem(); ItemStack item = player.inventory.getCurrentItem();
@@ -232,20 +225,20 @@ public class ServerEventsHandler {
y--; y--;
TileBanner tile = (TileBanner)player.worldObj.getTileEntity(event.x, y, event.z); TileBanner tile = (TileBanner)player.worldObj.getTileEntity(event.x, y, event.z);
if(!tile.canEdit()){ if(!tile.canEdit()){
if(item.getItem() == CustomItems.wand && CustomNpcsPermissions.hasPermission(player, CustomNpcsPermissions.EDIT_BLOCKS)){ if(item.getItem() == CustomItems.wand && CustomNpcsPermissions.hasPermission(player, CustomNpcsPermissions.EDIT_BLOCKS)){
tile.time = System.currentTimeMillis(); tile.time = System.currentTimeMillis();
if(player.worldObj.isRemote) if(player.worldObj.isRemote)
player.addChatComponentMessage(new ChatComponentTranslation("availability.editIcon")); player.addChatComponentMessage(new ChatComponentTranslation("availability.editIcon"));
} }
return; return;
} }
if(!player.worldObj.isRemote){ if(!player.worldObj.isRemote){
tile.icon = item.copy(); tile.icon = item.copy();
player.worldObj.markBlockForUpdate(event.x, y, event.z); player.worldObj.markBlockForUpdate(event.x, y, event.z);
event.setCanceled(true); event.setCanceled(true);
} }
} }
} }
@@ -257,16 +250,16 @@ public class ServerEventsHandler {
if(event.source.getEntity() instanceof EntityPlayer){ if(event.source.getEntity() instanceof EntityPlayer){
doExcalibur((EntityPlayer) event.source.getEntity(),event.entityLiving); doExcalibur((EntityPlayer) event.source.getEntity(),event.entityLiving);
} }
if(event.source.getEntity() instanceof EntityNPCInterface && event.entityLiving != null){ if(event.source.getEntity() instanceof EntityNPCInterface && event.entityLiving != null){
EntityNPCInterface npc = (EntityNPCInterface) event.source.getEntity(); EntityNPCInterface npc = (EntityNPCInterface) event.source.getEntity();
Line line = npc.advanced.getKillLine(); Line line = npc.advanced.getKillLine();
if(line != null) if(line != null)
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;
if(event.source.getEntity() instanceof EntityPlayer) if(event.source.getEntity() instanceof EntityPlayer)
player = (EntityPlayer) event.source.getEntity(); player = (EntityPlayer) event.source.getEntity();
@@ -274,7 +267,7 @@ public class ServerEventsHandler {
player = ((RoleFollower)((EntityNPCInterface)event.source.getEntity()).roleInterface).owner; player = ((RoleFollower)((EntityNPCInterface)event.source.getEntity()).roleInterface).owner;
if(player != null){ if(player != null){
doQuest(player, event.entityLiving, true); doQuest(player, event.entityLiving, true);
if(event.entityLiving instanceof EntityNPCInterface) if(event.entityLiving instanceof EntityNPCInterface)
doFactionPoints(player, (EntityNPCInterface)event.entityLiving); doFactionPoints(player, (EntityNPCInterface)event.entityLiving);
} }
@@ -298,11 +291,12 @@ public class ServerEventsHandler {
} }
private void doQuest(EntityPlayer player, EntityLivingBase entity, boolean all) { private void doQuest(EntityPlayer player, EntityLivingBase entity, boolean all) {
PlayerQuestData playerdata = PlayerDataController.instance.getPlayerData(player).questData; PlayerData playerData = PlayerDataController.instance.getPlayerData(player);
PlayerQuestData questData = playerData.questData;
boolean change = false; boolean change = false;
String entityName = EntityList.getEntityString(entity); String entityName = EntityList.getEntityString(entity);
for(QuestData data : playerdata.activeQuests.values()){ for(QuestData data : questData.activeQuests.values()){
if(data.quest.type != EnumQuestType.Kill && data.quest.type != EnumQuestType.AreaKill) if(data.quest.type != EnumQuestType.Kill && data.quest.type != EnumQuestType.AreaKill)
continue; continue;
if(data.quest.type == EnumQuestType.AreaKill && all){ if(data.quest.type == EnumQuestType.AreaKill && all){
@@ -310,10 +304,21 @@ public class ServerEventsHandler {
for(EntityPlayer pl : list) for(EntityPlayer pl : list)
if(pl != player) if(pl != player)
doQuest(pl, entity, false); doQuest(pl, entity, false);
} }
String name = entityName; String name = entityName;
QuestKill quest = (QuestKill) data.quest.questInterface; QuestKill quest = (QuestKill) data.quest.questInterface;
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;
if(quest.targets.containsKey(entity.getCommandSenderName())) if(quest.targets.containsKey(entity.getCommandSenderName()))
name = entity.getCommandSenderName(); name = entity.getCommandSenderName();
else if(!quest.targets.containsKey(name)) else if(!quest.targets.containsKey(name))
@@ -330,16 +335,17 @@ public class ServerEventsHandler {
} }
if(!change) if(!change)
return; return;
playerdata.checkQuestCompletion(player,EnumQuestType.Kill); questData.checkQuestCompletion(playerData,EnumQuestType.Kill);
} }
@SubscribeEvent @SubscribeEvent
public void pickUp(EntityItemPickupEvent event){ public void pickUp(EntityItemPickupEvent event){
if(event.entityPlayer.worldObj.isRemote) if(event.entityPlayer.worldObj.isRemote)
return; return;
PlayerQuestData playerdata = PlayerDataController.instance.getPlayerData(event.entityPlayer).questData; PlayerData playerData = PlayerDataController.instance.getPlayerData(event.entityPlayer);
playerdata.checkQuestCompletion(event.entityPlayer, EnumQuestType.Item); PlayerQuestData questData = playerData.questData;
questData.checkQuestCompletion(playerData, EnumQuestType.Item);
} }
@SubscribeEvent @SubscribeEvent
@@ -12,11 +12,21 @@ 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 = 17;
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 < 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()));
@@ -1,10 +1,12 @@
package noppes.npcs.ai; package noppes.npcs.ai;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityAIBase; import net.minecraft.entity.ai.EntityAIBase;
import net.minecraft.pathfinding.PathEntity; import net.minecraft.pathfinding.PathEntity;
import net.minecraft.util.MathHelper; import net.minecraft.util.MathHelper;
import net.minecraft.world.World; import net.minecraft.world.World;
import noppes.npcs.CustomNpcs;
import noppes.npcs.constants.AiMutex; import noppes.npcs.constants.AiMutex;
import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.entity.EntityNPCInterface;
@@ -55,7 +57,9 @@ public class EntityAIAttackTarget extends EntityAIBase
} }
else{ else{
this.entityTarget = entitylivingbase; this.entityTarget = entitylivingbase;
this.attacker.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(((EntityNPCInterface) this.attacker).stats.aggroRange);
this.entityPathEntity = this.attacker.getNavigator().getPathToEntityLiving(entitylivingbase); this.entityPathEntity = this.attacker.getNavigator().getPathToEntityLiving(entitylivingbase);
this.attacker.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(CustomNpcs.NpcNavRange);
return this.entityPathEntity != null; return this.entityPathEntity != null;
} }
} }
@@ -0,0 +1,173 @@
package noppes.npcs.ai.pathfinder;
public class FlyPath {
private FlyPathPoint[] pathPoints = new FlyPathPoint[1024];
/** The number of points in this path */
private int count;
private static final String __OBFID = "CL_00000573";
/**
* Adds a point to the path
*/
public FlyPathPoint addPoint(FlyPathPoint p_75849_1_)
{
if (p_75849_1_.index >= 0)
{
throw new IllegalStateException("OW KNOWS!");
}
else
{
if (this.count == this.pathPoints.length)
{
FlyPathPoint[] apathpoint = new FlyPathPoint[this.count << 1];
System.arraycopy(this.pathPoints, 0, apathpoint, 0, this.count);
this.pathPoints = apathpoint;
}
this.pathPoints[this.count] = p_75849_1_;
p_75849_1_.index = this.count;
this.sortBack(this.count++);
return p_75849_1_;
}
}
/**
* Clears the path
*/
public void clearPath()
{
this.count = 0;
}
/**
* Returns and removes the first point in the path
*/
public FlyPathPoint dequeue()
{
FlyPathPoint pathpoint = this.pathPoints[0];
this.pathPoints[0] = this.pathPoints[--this.count];
this.pathPoints[this.count] = null;
if (this.count > 0)
{
this.sortForward(0);
}
pathpoint.index = -1;
return pathpoint;
}
/**
* Changes the provided point's distance to target
*/
public void changeDistance(FlyPathPoint p_75850_1_, float p_75850_2_)
{
float f1 = p_75850_1_.distanceToTarget;
p_75850_1_.distanceToTarget = p_75850_2_;
if (p_75850_2_ < f1)
{
this.sortBack(p_75850_1_.index);
}
else
{
this.sortForward(p_75850_1_.index);
}
}
/**
* Sorts a point to the left
*/
private void sortBack(int p_75847_1_)
{
FlyPathPoint pathpoint = this.pathPoints[p_75847_1_];
int j;
for (float f = pathpoint.distanceToTarget; p_75847_1_ > 0; p_75847_1_ = j)
{
j = p_75847_1_ - 1 >> 1;
FlyPathPoint pathpoint1 = this.pathPoints[j];
if (f >= pathpoint1.distanceToTarget)
{
break;
}
this.pathPoints[p_75847_1_] = pathpoint1;
pathpoint1.index = p_75847_1_;
}
this.pathPoints[p_75847_1_] = pathpoint;
pathpoint.index = p_75847_1_;
}
/**
* Sorts a point to the right
*/
private void sortForward(int p_75846_1_)
{
FlyPathPoint pathpoint = this.pathPoints[p_75846_1_];
float f = pathpoint.distanceToTarget;
while (true)
{
int j = 1 + (p_75846_1_ << 1);
int k = j + 1;
if (j >= this.count)
{
break;
}
FlyPathPoint pathpoint1 = this.pathPoints[j];
float f1 = pathpoint1.distanceToTarget;
FlyPathPoint pathpoint2;
float f2;
if (k >= this.count)
{
pathpoint2 = null;
f2 = Float.POSITIVE_INFINITY;
}
else
{
pathpoint2 = this.pathPoints[k];
f2 = pathpoint2.distanceToTarget;
}
if (f1 < f2)
{
if (f1 >= f)
{
break;
}
this.pathPoints[p_75846_1_] = pathpoint1;
pathpoint1.index = p_75846_1_;
p_75846_1_ = j;
}
else
{
if (f2 >= f)
{
break;
}
this.pathPoints[p_75846_1_] = pathpoint2;
pathpoint2.index = p_75846_1_;
p_75846_1_ = k;
}
}
this.pathPoints[p_75846_1_] = pathpoint;
pathpoint.index = p_75846_1_;
}
/**
* Returns true if this path contains no points
*/
public boolean isPathEmpty()
{
return this.count == 0;
}
}
@@ -0,0 +1,130 @@
package noppes.npcs.ai.pathfinder;
import net.minecraft.entity.Entity;
import net.minecraft.pathfinding.PathEntity;
import net.minecraft.pathfinding.PathPoint;
import net.minecraft.util.Vec3;
public class FlyPathEntity extends PathEntity{
public final PathPoint[] points;
/** PathEntity Array Index the Entity is currently targeting */
public int currentPathIndex;
/** The total length of the path */
public int pathLength;
private static final String __OBFID = "CL_00000575";
public FlyPathEntity(PathPoint[] p_i2136_1_)
{
super(p_i2136_1_);
this.points = p_i2136_1_;
this.pathLength = p_i2136_1_.length;
}
/**
* Directs this path to the next point in its array
*/
public void incrementPathIndex()
{
++this.currentPathIndex;
}
/**
* Returns true if this path has reached the end
*/
public boolean isFinished()
{
return this.currentPathIndex >= this.pathLength;
}
/**
* returns the last PathPoint of the Array
*/
public PathPoint getFinalPathPoint()
{
return this.pathLength > 0 ? this.points[this.pathLength - 1] : null;
}
/**
* return the PathPoint located at the specified PathIndex, usually the current one
*/
public PathPoint getPathPointFromIndex(int p_75877_1_)
{
return this.points[p_75877_1_];
}
public int getCurrentPathLength()
{
return this.pathLength;
}
public void setCurrentPathLength(int p_75871_1_)
{
this.pathLength = p_75871_1_;
}
public int getCurrentPathIndex()
{
return this.currentPathIndex;
}
public void setCurrentPathIndex(int p_75872_1_)
{
this.currentPathIndex = p_75872_1_;
}
/**
* Gets the vector of the PathPoint associated with the given index.
*/
public Vec3 getVectorFromIndex(Entity p_75881_1_, int p_75881_2_)
{
double d0 = (double)this.points[p_75881_2_].xCoord + (double)((int)(p_75881_1_.width + 1.0F)) * 0.5D;
double d1 = (double)this.points[p_75881_2_].yCoord;
double d2 = (double)this.points[p_75881_2_].zCoord + (double)((int)(p_75881_1_.width + 1.0F)) * 0.5D;
return Vec3.createVectorHelper(d0, d1, d2);
}
/**
* returns the current PathEntity target node as Vec3D
*/
public Vec3 getPosition(Entity p_75878_1_)
{
return this.getVectorFromIndex(p_75878_1_, this.currentPathIndex);
}
/**
* Returns true if the EntityPath are the same. Non instance related equals.
*/
public boolean isSamePath(PathEntity pathEntity)
{
FlyPathEntity p_75876_1_ = (FlyPathEntity) pathEntity;
if (p_75876_1_ == null)
{
return false;
}
else if (p_75876_1_.points.length != this.points.length)
{
return false;
}
else
{
for (int i = 0; i < this.points.length; ++i)
{
if (this.points[i].xCoord != p_75876_1_.points[i].xCoord || this.points[i].yCoord != p_75876_1_.points[i].yCoord || this.points[i].zCoord != p_75876_1_.points[i].zCoord)
{
return false;
}
}
return true;
}
}
/**
* Returns true if the final PathPoint in the PathEntity is equal to Vec3D coords.
*/
public boolean isDestinationSame(Vec3 p_75880_1_)
{
PathPoint pathpoint = this.getFinalPathPoint();
return pathpoint == null ? false : pathpoint.xCoord == (int)p_75880_1_.xCoord && pathpoint.zCoord == (int)p_75880_1_.zCoord;
}
}
@@ -0,0 +1,396 @@
package noppes.npcs.ai.pathfinder;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.Entity;
import net.minecraft.init.Blocks;
import net.minecraft.pathfinding.PathFinder;
import net.minecraft.util.IntHashMap;
import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
public class FlyPathFinder extends PathFinder
{
/** Used to find obstacles */
private IBlockAccess worldMap;
/** The path being generated */
private FlyPath path = new FlyPath();
/** The points in the path */
private IntHashMap pointMap = new IntHashMap();
/** Selection of path points to add to the path */
private FlyPathPoint[] pathOptions = new FlyPathPoint[32];
/** should the PathFinder go through wodden door blocks */
private boolean isWoddenDoorAllowed;
/** should the PathFinder disregard BlockMovement type materials in its path */
private boolean isMovementBlockAllowed;
private boolean isPathingInWater;
/** tells the FathFinder to not stop pathing underwater */
private boolean canEntityDrown;
private static final String __OBFID = "CL_00000576";
public FlyPathFinder(IBlockAccess p_i2137_1_, boolean p_i2137_2_, boolean p_i2137_3_, boolean p_i2137_4_, boolean p_i2137_5_)
{
super(p_i2137_1_,p_i2137_2_,p_i2137_3_,p_i2137_4_,p_i2137_5_);
this.worldMap = p_i2137_1_;
this.isWoddenDoorAllowed = p_i2137_2_;
this.isMovementBlockAllowed = p_i2137_3_;
this.isPathingInWater = p_i2137_4_;
this.canEntityDrown = p_i2137_5_;
}
/**
* Creates a path from one entity to another within a minimum distance
*/
public FlyPathEntity createEntityPathTo(Entity p_75856_1_, Entity p_75856_2_, float p_75856_3_)
{
return this.createEntityPathTo(p_75856_1_, p_75856_2_.posX, p_75856_2_.boundingBox.minY, p_75856_2_.posZ, p_75856_3_);
}
/**
* Creates a path from an entity to a specified location within a minimum distance
*/
public FlyPathEntity createEntityPathTo(Entity p_75859_1_, int p_75859_2_, int p_75859_3_, int p_75859_4_, float p_75859_5_)
{
return this.createEntityPathTo(p_75859_1_, (double)((float)p_75859_2_ + 0.5F), (double)((float)p_75859_3_ + 0.5F), (double)((float)p_75859_4_ + 0.5F), p_75859_5_);
}
/**
* Internal implementation of creating a path from an entity to a point
*/
private FlyPathEntity createEntityPathTo(Entity p_75857_1_, double p_75857_2_, double p_75857_4_, double p_75857_6_, float p_75857_8_)
{
this.path.clearPath();
this.pointMap.clearMap();
boolean flag = this.isPathingInWater;
int i = MathHelper.floor_double(p_75857_1_.boundingBox.minY + 0.5D);
if (this.canEntityDrown && p_75857_1_.isInWater())
{
i = (int)p_75857_1_.boundingBox.minY;
for (Block block = this.worldMap.getBlock(MathHelper.floor_double(p_75857_1_.posX), i, MathHelper.floor_double(p_75857_1_.posZ)); block == Blocks.flowing_water || block == Blocks.water; block = this.worldMap.getBlock(MathHelper.floor_double(p_75857_1_.posX), i, MathHelper.floor_double(p_75857_1_.posZ)))
{
++i;
}
flag = this.isPathingInWater;
this.isPathingInWater = false;
}
else
{
i = MathHelper.floor_double(p_75857_1_.boundingBox.minY + 0.5D);
}
FlyPathPoint pathpoint2 = this.openPoint(MathHelper.floor_double(p_75857_1_.boundingBox.minX), i, MathHelper.floor_double(p_75857_1_.boundingBox.minZ));
FlyPathPoint pathpoint = this.openPoint(MathHelper.floor_double(p_75857_2_ - (double)(p_75857_1_.width / 2.0F)), MathHelper.floor_double(p_75857_4_), MathHelper.floor_double(p_75857_6_ - (double)(p_75857_1_.width / 2.0F)));
FlyPathPoint pathpoint1 = new FlyPathPoint(MathHelper.floor_float(p_75857_1_.width + 1.0F), MathHelper.floor_float(p_75857_1_.height + 1.0F), MathHelper.floor_float(p_75857_1_.width + 1.0F));
FlyPathEntity pathentity = this.addToPath(p_75857_1_, pathpoint2, pathpoint, pathpoint1, p_75857_8_);
this.isPathingInWater = flag;
return pathentity;
}
/**
* Adds a path from start to end and returns the whole path (args: unused, start, end, unused, maxDistance)
*/
private FlyPathEntity addToPath(Entity p_75861_1_, FlyPathPoint p_75861_2_, FlyPathPoint p_75861_3_, FlyPathPoint p_75861_4_, float p_75861_5_)
{
p_75861_2_.totalPathDistance = 0.0F;
p_75861_2_.distanceToNext = p_75861_2_.distanceToSquared(p_75861_3_);
p_75861_2_.distanceToTarget = p_75861_2_.distanceToNext;
this.path.clearPath();
this.path.addPoint(p_75861_2_);
FlyPathPoint pathpoint3 = p_75861_2_;
while (!this.path.isPathEmpty())
{
FlyPathPoint pathpoint4 = this.path.dequeue();
if (pathpoint4.equals(p_75861_3_))
{
return this.createEntityPath(p_75861_2_, p_75861_3_);
}
if (pathpoint4.distanceToSquared(p_75861_3_) < pathpoint3.distanceToSquared(p_75861_3_))
{
pathpoint3 = pathpoint4;
}
pathpoint4.isFirst = true;
int i = this.findPathOptions(p_75861_1_, pathpoint4, p_75861_4_, p_75861_3_, p_75861_5_);
for (int j = 0; j < i; ++j)
{
FlyPathPoint pathpoint5 = this.pathOptions[j];
float f1 = pathpoint4.totalPathDistance + pathpoint4.distanceToSquared(pathpoint5);
if (!pathpoint5.isAssigned() || f1 < pathpoint5.totalPathDistance)
{
pathpoint5.previous = pathpoint4;
pathpoint5.totalPathDistance = f1;
pathpoint5.distanceToNext = pathpoint5.distanceToSquared(p_75861_3_);
if (pathpoint5.isAssigned())
{
this.path.changeDistance(pathpoint5, pathpoint5.totalPathDistance + pathpoint5.distanceToNext);
}
else
{
pathpoint5.distanceToTarget = pathpoint5.totalPathDistance + pathpoint5.distanceToNext;
this.path.addPoint(pathpoint5);
}
}
}
}
if (pathpoint3 == p_75861_2_)
{
return null;
}
else
{
return this.createEntityPath(p_75861_2_, pathpoint3);
}
}
/**
* populates pathOptions with available points and returns the number of options found (args: unused1, currentPoint,
* unused2, targetPoint, maxDistance)
*/
private int findPathOptions(Entity p_75860_1_, FlyPathPoint p_75860_2_, FlyPathPoint p_75860_3_, FlyPathPoint p_75860_4_, float p_75860_5_)
{
int i = 0;
byte b0 = 0;
if (this.getVerticalOffset(p_75860_1_, p_75860_2_.xCoord, p_75860_2_.yCoord + 1, p_75860_2_.zCoord, p_75860_3_) == 1)
{
b0 = 1;
}
for(int y = -1; y <= 1; y ++) {
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 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 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);
if (pathpoint3 != null && !pathpoint3.isFirst && pathpoint3.distanceTo(p_75860_4_) < p_75860_5_) {
this.pathOptions[i++] = pathpoint3;
}
if (pathpoint4 != null && !pathpoint4.isFirst && pathpoint4.distanceTo(p_75860_4_) < p_75860_5_) {
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;
}
}
return i;
}
/**
* Returns a point that the entity can safely move to
*/
private FlyPathPoint getSafePoint(Entity entity, int blockX, int blockY, int blockZ, FlyPathPoint pathPoint, int verticalOffsetFlag)
{
FlyPathPoint pathpoint1 = null;
int verticalOffset = this.getVerticalOffset(entity, blockX, blockY, blockZ, pathPoint);
if (verticalOffset == 2)
{
return this.openPoint(blockX, blockY, blockZ);
}
else
{
if (verticalOffset == 1)
{
pathpoint1 = this.openPoint(blockX, blockY, blockZ);
}
if (pathpoint1 == null && verticalOffsetFlag > 0 && verticalOffset != -3 && verticalOffset != -4 && this.getVerticalOffset(entity, blockX, blockY + verticalOffsetFlag, blockZ, pathPoint) == 1)
{
pathpoint1 = this.openPoint(blockX, blockY + verticalOffsetFlag, blockZ);
blockY += verticalOffsetFlag;
}
if (pathpoint1 != null)
{
int j1 = 0;
int k1 = 0;
while (blockY > 0)
{
k1 = this.getVerticalOffset(entity, blockX, blockY - 1, blockZ, pathPoint);
if (this.isPathingInWater && k1 == -1)
{
return null;
}
if (k1 != 1)
{
break;
}
if (j1++ >= entity.getMaxSafePointTries())
{
return null;
}
--blockY;
if (blockY > 0)
{
pathpoint1 = this.openPoint(blockX, blockY, blockZ);
}
}
if (k1 == -2)
{
return null;
}
}
return pathpoint1;
}
}
/**
* Returns a mapped point or creates and adds one
*/
private final FlyPathPoint openPoint(int p_75854_1_, int p_75854_2_, int p_75854_3_)
{
int l = FlyPathPoint.makeHash(p_75854_1_, p_75854_2_, p_75854_3_);
FlyPathPoint pathpoint = (FlyPathPoint)this.pointMap.lookup(l);
if (pathpoint == null)
{
pathpoint = new FlyPathPoint(p_75854_1_, p_75854_2_, p_75854_3_);
this.pointMap.addKey(l, pathpoint);
}
return pathpoint;
}
/**
* Checks if an entity collides with blocks at a position. Returns 1 if clear, 0 for colliding with any solid block,
* -1 for water(if avoiding water) but otherwise clear, -2 for lava, -3 for fence, -4 for closed trapdoor, 2 if
* otherwise clear except for open trapdoor or water(if not avoiding)
*/
public int getVerticalOffset(Entity p_75855_1_, int p_75855_2_, int p_75855_3_, int p_75855_4_, FlyPathPoint p_75855_5_)
{
return canEntityStandAt(p_75855_1_, p_75855_2_, p_75855_3_, p_75855_4_, p_75855_5_, this.isPathingInWater, this.isMovementBlockAllowed, this.isWoddenDoorAllowed);
}
public static int canEntityStandAt(Entity entity, int blockX, int blockY, int blockZ, FlyPathPoint pathPoint, boolean isPathingInWater, boolean isMovementBlockAllowed, boolean isWoddenDoorAllowed)
{
boolean flag3 = false;
for (int l = blockX; l < blockX + pathPoint.xCoord; ++l)
{
for (int i1 = blockY; i1 < blockY + pathPoint.yCoord; ++i1)
{
for (int j1 = blockZ; j1 < blockZ + pathPoint.zCoord; ++j1)
{
Block block = entity.worldObj.getBlock(l, i1, j1);
if(block == Blocks.air)
{
return 2;
}
if (block == Blocks.trapdoor)
{
flag3 = true;
}
else if (block != Blocks.flowing_water && block != Blocks.water)
{
if (!isWoddenDoorAllowed && block == Blocks.wooden_door)
{
return 0;
}
}
else
{
if (isPathingInWater)
{
return -1;
}
flag3 = true;
}
int k1 = block.getRenderType();
if (entity.worldObj.getBlock(l, i1, j1).getRenderType() == 9)
{
int j2 = MathHelper.floor_double(entity.posX);
int l1 = MathHelper.floor_double(entity.posY);
int i2 = MathHelper.floor_double(entity.posZ);
if (entity.worldObj.getBlock(j2, l1, i2).getRenderType() != 9 && entity.worldObj.getBlock(j2, l1 - 1, i2).getRenderType() != 9)
{
return -3;
}
}
else if (!block.getBlocksMovement(entity.worldObj, l, i1, j1) && (!isMovementBlockAllowed || block != Blocks.wooden_door))
{
if (k1 == 11 || block == Blocks.fence_gate || k1 == 32)
{
return -3;
}
if (block == Blocks.trapdoor)
{
return -4;
}
Material material = block.getMaterial();
if (material != Material.lava)
{
return 0;
}
if (!entity.handleLavaMovement())
{
return -2;
}
}
}
}
}
return flag3 ? 2 : 1;
}
/**
* Returns a new FlyPathEntity for a given start and end point
*/
private FlyPathEntity createEntityPath(FlyPathPoint p_75853_1_, FlyPathPoint p_75853_2_)
{
int i = 1;
FlyPathPoint pathpoint2;
for (pathpoint2 = p_75853_2_; pathpoint2.previous != null; pathpoint2 = pathpoint2.previous)
{
++i;
}
FlyPathPoint[] apathpoint = new FlyPathPoint[i];
pathpoint2 = p_75853_2_;
--i;
for (apathpoint[i] = p_75853_2_; pathpoint2.previous != null; apathpoint[i] = pathpoint2)
{
pathpoint2 = pathpoint2.previous;
--i;
}
return new FlyPathEntity(apathpoint);
}
}
@@ -0,0 +1,96 @@
package noppes.npcs.ai.pathfinder;
import net.minecraft.pathfinding.PathPoint;
import net.minecraft.util.MathHelper;
public class FlyPathPoint extends PathPoint
{
/** The x coordinate of this point */
public final int xCoord;
/** The y coordinate of this point */
public final int yCoord;
/** The z coordinate of this point */
public final int zCoord;
/** A hash of the coordinates used to identify this point */
public final int hash;
/** The index of this point in its assigned path */
public int index = -1;
/** The distance along the path to this point */
public float totalPathDistance;
/** The linear distance to the next point */
public float distanceToNext;
/** The distance to the target */
public float distanceToTarget;
/** The point preceding this in its assigned path */
public FlyPathPoint previous;
/** Indicates this is the origin */
public boolean isFirst;
private static final String __OBFID = "CL_00000574";
public FlyPathPoint(int p_i2135_1_, int p_i2135_2_, int p_i2135_3_)
{
super(p_i2135_1_,p_i2135_2_,p_i2135_3_);
this.xCoord = p_i2135_1_;
this.yCoord = p_i2135_2_;
this.zCoord = p_i2135_3_;
this.hash = makeHash(p_i2135_1_, p_i2135_2_, p_i2135_3_);
}
public static int makeHash(int p_75830_0_, int p_75830_1_, int p_75830_2_)
{
return p_75830_1_ & 255 | (p_75830_0_ & 32767) << 8 | (p_75830_2_ & 32767) << 24 | (p_75830_0_ < 0 ? Integer.MIN_VALUE : 0) | (p_75830_2_ < 0 ? 32768 : 0);
}
/**
* Returns the linear distance to another path point
*/
public float distanceTo(net.minecraft.pathfinding.PathPoint p_75829_1_)
{
float f = (float)(p_75829_1_.xCoord - this.xCoord);
float f1 = (float)(p_75829_1_.yCoord - this.yCoord);
float f2 = (float)(p_75829_1_.zCoord - this.zCoord);
return MathHelper.sqrt_float(f * f + f1 * f1 + f2 * f2);
}
/**
* Returns the squared distance to another path point
*/
public float distanceToSquared(net.minecraft.pathfinding.PathPoint p_75832_1_)
{
float f = (float)(p_75832_1_.xCoord - this.xCoord);
float f1 = (float)(p_75832_1_.yCoord - this.yCoord);
float f2 = (float)(p_75832_1_.zCoord - this.zCoord);
return f * f + f1 * f1 + f2 * f2;
}
public boolean equals(Object p_equals_1_)
{
if (!(p_equals_1_ instanceof FlyPathPoint))
{
return false;
}
else
{
FlyPathPoint pathpoint = (FlyPathPoint)p_equals_1_;
return this.hash == pathpoint.hash && this.xCoord == pathpoint.xCoord && this.yCoord == pathpoint.yCoord && this.zCoord == pathpoint.zCoord;
}
}
public int hashCode()
{
return this.hash;
}
/**
* Returns true if this point has already been assigned to a path
*/
public boolean isAssigned()
{
return this.index >= 0;
}
public String toString()
{
return this.xCoord + ", " + this.yCoord + ", " + this.zCoord;
}
}
@@ -2,66 +2,102 @@ package noppes.npcs.ai.pathfinder;
import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityMoveHelper; import net.minecraft.entity.ai.EntityMoveHelper;
import net.minecraft.util.AxisAlignedBB; import net.minecraft.init.Blocks;
import net.minecraft.util.MathHelper; import net.minecraft.util.MathHelper;
import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.entity.EntityNPCInterface;
// Fly Change // Fly Change
public class FlyingMoveHelper extends EntityMoveHelper { public class FlyingMoveHelper extends EntityMoveHelper{
private EntityNPCInterface entity; private final EntityNPCInterface entity;
private int field_179928_h; private double posX;
protected boolean update; private double posY;
private double posZ;
public double posX; private double speed;
public double posY; private boolean update;
public double posZ;
public FlyingMoveHelper(EntityNPCInterface entity){ public FlyingMoveHelper(EntityNPCInterface entity){
super(entity); super(entity);
this.entity = entity; this.entity = entity;
this.posX = entity.posX;
this.posY = entity.posY;
this.posZ = entity.posZ;
} }
public void onUpdateMoveHelper(){ public void onUpdateMoveHelper() {
if (this.update){ if (this.update) {
this.update = false;
double speed = this.speed * this.entity.getEntityAttribute(SharedMonsterAttributes.movementSpeed).getAttributeValue() * this.entity.ai.flySpeed;
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 d3 = d0 * d0 + d1 * d1 + d2 * d2; double d4 = d0 * d0 + d1 * d1 + d2 * d2;
double d5 = MathHelper.sqrt_double(d4);
if (this.field_179928_h-- <= 0){
this.field_179928_h += this.entity.getRNG().nextInt(5) + 2;
d3 = (double) MathHelper.sqrt_double(d3);
if (d3 > 1 && this.func_179926_b(this.posX, this.posY, this.posZ, d3)){ double heightOffGround = 0;
double speed = entity.getEntityAttribute(SharedMonsterAttributes.movementSpeed).getAttributeValue() / 2.5; if(this.entity.ai.hasFlyLimit) {
this.entity.motionX += d0 / d3 * speed; for (int blockY = (int) this.posY; blockY > 0; blockY--) {
this.entity.motionY += d1 / d3 * speed; heightOffGround = this.posY - blockY;
this.entity.motionZ += d2 / d3 * speed; if (this.entity.worldObj.getBlock((int) this.posX, blockY, (int) this.posZ) != Blocks.air || heightOffGround > this.entity.ai.flyHeightLimit){
this.entity.renderYawOffset = this.entity.rotationYaw = -((float)Math.atan2(this.entity.motionX, this.entity.motionZ)) * 180.0F / (float)Math.PI; break;
} }
else{
this.update = false;
} }
} }
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);
} }
} }
private boolean func_179926_b(double p_179926_1_, double p_179926_3_, double p_179926_5_, double p_179926_7_){ private float limitAngle(float p_75639_1_, float p_75639_2_, float p_75639_3_)
double d4 = (p_179926_1_ - this.entity.posX) / p_179926_7_; {
double d5 = (p_179926_3_ - this.entity.posY) / p_179926_7_; float f3 = MathHelper.wrapAngleTo180_float(p_75639_2_ - p_75639_1_);
double d6 = (p_179926_5_ - this.entity.posZ) / p_179926_7_;
AxisAlignedBB axisalignedbb = this.entity.getBoundingBox();
for (int i = 1; (double)i < p_179926_7_; ++i){ if (f3 > p_75639_3_)
axisalignedbb = axisalignedbb.offset(d4, d5, d6); {
f3 = p_75639_3_;
if (!this.entity.worldObj.getCollidingBoundingBoxes(this.entity, axisalignedbb).isEmpty()){
return false;
}
} }
return true; if (f3 < -p_75639_3_)
{
f3 = -p_75639_3_;
}
return p_75639_1_ + f3;
}
/**
* Sets the speed and location to move to
*/
public void setMoveTo(double p_75642_1_, double p_75642_3_, double p_75642_5_, double p_75642_7_)
{
this.posX = p_75642_1_;
this.posY = p_75642_3_;
this.posZ = p_75642_5_;
this.speed = p_75642_7_;
this.update = true;
}
public boolean isUpdating()
{
return this.update;
}
public double getSpeed()
{
return this.speed;
} }
} }
@@ -1,25 +1,491 @@
package noppes.npcs.ai.pathfinder; package noppes.npcs.ai.pathfinder;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLiving;
import net.minecraft.pathfinding.PathFinder; import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.attributes.IAttributeInstance;
import net.minecraft.init.Blocks;
import net.minecraft.pathfinding.PathEntity;
import net.minecraft.pathfinding.PathNavigate;
import net.minecraft.pathfinding.PathPoint;
import net.minecraft.util.MathHelper;
import net.minecraft.util.Vec3;
import net.minecraft.world.ChunkCache;
import net.minecraft.world.World; import net.minecraft.world.World;
import noppes.npcs.entity.EntityNPCInterface;
public class PathNavigateFlying extends PathNavigateSwimmer { public class PathNavigateFlying extends PathNavigate {
private EntityNPCInterface theEntity;
private World worldObj;
/** The PathEntity being followed. */
private FlyPathEntity currentPath;
private double speed;
/** The number of blocks (extra) +/- in each axis that get pulled out as cache for the pathfinder's search space */
private IAttributeInstance pathSearchRange;
private boolean noSunPathfind;
/** Time, in number of ticks, following the current path */
private int totalTicks;
/** The time when the last position check was done (to detect successful movement) */
private int ticksAtLastPos;
/** Coordinates of the entity's position last time a check was done (part of monitoring getting 'stuck') */
private Vec3 lastPosCheck = Vec3.createVectorHelper(0.0D, 0.0D, 0.0D);
/** Specifically, if a wooden door block is even considered to be passable by the pathfinder */
private boolean canPassOpenWoodenDoors = true;
/** If door blocks are considered passable even when closed */
private boolean canPassClosedWoodenDoors;
/** If water blocks are avoided (at least by the pathfinder) */
private boolean avoidsWater;
/**
* If the entity can swim. Swimming AI enables this and the pathfinder will also cause the entity to swim straight
* upwards when underwater
*/
private boolean canSwim;
private static final String __OBFID = "CL_00001627";
public PathNavigateFlying(EntityLiving p_i45873_1_, World worldIn) { public PathNavigateFlying(EntityLiving p_i45873_1_, World worldIn) {
super(p_i45873_1_, worldIn); super(p_i45873_1_, worldIn);
} this.theEntity = (EntityNPCInterface)p_i45873_1_;
this.worldObj = worldIn;
protected PathFinder func_179679_a() this.pathSearchRange = p_i45873_1_.getEntityAttribute(SharedMonsterAttributes.followRange);
}
public void setAvoidsWater(boolean p_75491_1_)
{ {
return new NPCPathFinder(new FlyNodeProcessor()); this.avoidsWater = p_75491_1_;
}
public boolean getAvoidsWater()
{
return this.avoidsWater;
}
public void setBreakDoors(boolean p_75498_1_)
{
this.canPassClosedWoodenDoors = p_75498_1_;
}
/**
* Sets if the entity can enter open doors
*/
public void setEnterDoors(boolean p_75490_1_)
{
this.canPassOpenWoodenDoors = p_75490_1_;
}
/**
* Returns true if the entity can break doors, false otherwise
*/
public boolean getCanBreakDoors()
{
return this.canPassClosedWoodenDoors;
}
/**
* Sets if the path should avoid sunlight
*/
public void setAvoidSun(boolean p_75504_1_)
{
this.noSunPathfind = p_75504_1_;
}
/**
* Sets the speed
*/
public void setSpeed(double p_75489_1_)
{
this.speed = p_75489_1_;
}
/**
* Sets if the entity can swim
*/
public void setCanSwim(boolean p_75495_1_)
{
this.canSwim = p_75495_1_;
}
/**
* Gets the maximum distance that the path finding will search in.
*/
public float getPathSearchRange()
{
return (float)this.pathSearchRange.getAttributeValue();
}
/**
* Returns the path to the given coordinates
*/
public FlyPathEntity getPathToXYZ(double p_75488_1_, double p_75488_3_, double p_75488_5_)
{
return !this.canNavigate() ? null : this.getEntityPathToXYZ(this.theEntity, MathHelper.floor_double(p_75488_1_), (int)p_75488_3_, MathHelper.floor_double(p_75488_5_), this.getPathSearchRange(), this.canPassOpenWoodenDoors, this.canPassClosedWoodenDoors, this.avoidsWater, this.canSwim);
}
/**
* Try to find and set a path to XYZ. Returns true if successful.
*/
public boolean tryMoveToXYZ(double p_75492_1_, double p_75492_3_, double p_75492_5_, double p_75492_7_)
{
FlyPathEntity pathentity = this.getPathToXYZ((double)MathHelper.floor_double(p_75492_1_), (double)((int)p_75492_3_), (double)MathHelper.floor_double(p_75492_5_));
return this.setPath(pathentity, p_75492_7_);
}
/**
* Returns the path to the given EntityLiving
*/
public FlyPathEntity getPathToEntityLiving(Entity p_75494_1_)
{
return !this.canNavigate() ? null : this.getPathEntityToEntity(this.theEntity, p_75494_1_, this.getPathSearchRange(), this.canPassOpenWoodenDoors, this.canPassClosedWoodenDoors, this.avoidsWater, this.canSwim);
}
/**
* Try to find and set a path to EntityLiving. Returns true if successful.
*/
public boolean tryMoveToEntityLiving(Entity p_75497_1_, double p_75497_2_)
{
FlyPathEntity pathentity = this.getPathToEntityLiving(p_75497_1_);
return pathentity != null && this.setPath(pathentity, p_75497_2_);
}
/**
* sets the active path data if path is 100% unique compared to old path, checks to adjust path for sun avoiding
* ents and stores end coords
*/
public boolean setPath(PathEntity pathEntity, double p_75484_2_)
{
FlyPathEntity p_75484_1_ = (FlyPathEntity) pathEntity;
if (p_75484_1_ == null)
{
this.currentPath = null;
return false;
}
else
{
if (!p_75484_1_.isSamePath(this.currentPath))
{
this.currentPath = p_75484_1_;
}
if (this.noSunPathfind)
{
this.removeSunnyPath();
}
if (this.currentPath.getCurrentPathLength() == 0)
{
return false;
}
else
{
this.speed = p_75484_2_;
Vec3 vec3 = this.getEntityPosition();
this.ticksAtLastPos = this.totalTicks;
this.lastPosCheck.xCoord = vec3.xCoord;
this.lastPosCheck.yCoord = vec3.yCoord;
this.lastPosCheck.zCoord = vec3.zCoord;
return true;
}
}
}
/**
* gets the actively used PathEntity
*/
public PathEntity getPath()
{
return this.currentPath;
}
public void onUpdateNavigation()
{
++this.totalTicks;
if (!this.noPath())
{
if (this.canNavigate())
{
this.pathFollow();
}
if (!this.noPath())
{
Vec3 vec3 = this.currentPath.getPosition(this.theEntity);
if (vec3 != null)
{
this.theEntity.getMoveHelper().setMoveTo(vec3.xCoord, vec3.yCoord, vec3.zCoord, this.speed);
}
}
}
}
private void pathFollow()
{
Vec3 vec3 = this.getEntityPosition();
int i = this.currentPath.getCurrentPathLength();
for (int j = this.currentPath.getCurrentPathIndex(); j < this.currentPath.getCurrentPathLength(); ++j)
{
if (this.currentPath.getPathPointFromIndex(j).yCoord != (int)vec3.yCoord)
{
i = j;
break;
}
}
float f = this.theEntity.width * this.theEntity.width;
int k;
for (k = this.currentPath.getCurrentPathIndex(); k < i; ++k)
{
if (vec3.squareDistanceTo(this.currentPath.getVectorFromIndex(this.theEntity, k)) < (double)f)
{
this.currentPath.setCurrentPathIndex(k + 1);
}
}
k = MathHelper.ceiling_float_int(this.theEntity.width);
int l = (int)this.theEntity.height + 1;
int i1 = k;
for (int j1 = i - 1; j1 >= this.currentPath.getCurrentPathIndex(); --j1)
{
if (this.isDirectPathBetweenPoints(vec3, this.currentPath.getVectorFromIndex(this.theEntity, j1), k, l, i1))
{
this.currentPath.setCurrentPathIndex(j1);
break;
}
}
if (this.totalTicks - this.ticksAtLastPos > 100)
{
if (vec3.squareDistanceTo(this.lastPosCheck) < 2.25D)
{
this.clearPathEntity();
}
this.ticksAtLastPos = this.totalTicks;
this.lastPosCheck.xCoord = vec3.xCoord;
this.lastPosCheck.yCoord = vec3.yCoord;
this.lastPosCheck.zCoord = vec3.zCoord;
}
}
/**
* If null path or reached the end
*/
public boolean noPath()
{
return this.currentPath == null || this.currentPath.isFinished();
}
/**
* sets active PathEntity to null
*/
public void clearPathEntity()
{
this.currentPath = null;
}
private Vec3 getEntityPosition()
{
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
*/
private double getPathableYPos()
{
return this.theEntity.boundingBox.minY + 0.05D;
} }
/** /**
* If on ground or swimming and can swim * If on ground or swimming and can swim
*/ */
protected boolean canNavigate() private boolean canNavigate()
{ {
return true; return true;
} }
/**
* Returns true when an entity could stand at a position, including solid blocks under the entire entity. Args:
* xOffset, yOffset, zOffset, entityXSize, entityYSize, entityZSize, originPosition, vecX, vecZ
*/
private boolean isSafeToStandAt(int p_75483_1_, int p_75483_2_, int p_75483_3_, int p_75483_4_, int p_75483_5_, int p_75483_6_, Vec3 p_75483_7_, double p_75483_8_, double p_75483_10_)
{
return true;
}
/**
* Trims path data from the end to the first sun covered block
*/
private void removeSunnyPath()
{
if (!this.worldObj.canBlockSeeTheSky(MathHelper.floor_double(this.theEntity.posX), (int)(this.theEntity.boundingBox.minY + 0.5D), MathHelper.floor_double(this.theEntity.posZ)))
{
for (int i = 0; i < this.currentPath.getCurrentPathLength(); ++i)
{
PathPoint pathpoint = this.currentPath.getPathPointFromIndex(i);
if (this.worldObj.canBlockSeeTheSky(pathpoint.xCoord, pathpoint.yCoord, pathpoint.zCoord))
{
this.currentPath.setCurrentPathLength(i - 1);
return;
}
}
}
}
/**
* Returns true when an entity of specified size could safely walk in a straight line between the two points. Args:
* pos1, pos2, entityXSize, entityYSize, entityZSize
*/
private boolean isDirectPathBetweenPoints(Vec3 p_75493_1_, Vec3 p_75493_2_, int p_75493_3_, int p_75493_4_, int p_75493_5_)
{
int l = MathHelper.floor_double(p_75493_1_.xCoord);
int i1 = MathHelper.floor_double(p_75493_1_.zCoord);
double d0 = p_75493_2_.xCoord - p_75493_1_.xCoord;
double d1 = p_75493_2_.zCoord - p_75493_1_.zCoord;
double d2 = d0 * d0 + d1 * d1;
if (d2 < 1.0E-8D)
{
return false;
}
else
{
double d3 = 1.0D / Math.sqrt(d2);
d0 *= d3;
d1 *= d3;
p_75493_3_ += 2;
p_75493_5_ += 2;
if (!this.isSafeToStandAt(l, (int)p_75493_1_.yCoord, i1, p_75493_3_, p_75493_4_, p_75493_5_, p_75493_1_, d0, d1))
{
return false;
}
else
{
p_75493_3_ -= 2;
p_75493_5_ -= 2;
double d4 = 1.0D / Math.abs(d0);
double d5 = 1.0D / Math.abs(d1);
double d6 = (double)(l * 1) - p_75493_1_.xCoord;
double d7 = (double)(i1 * 1) - p_75493_1_.zCoord;
if (d0 >= 0.0D)
{
++d6;
}
if (d1 >= 0.0D)
{
++d7;
}
d6 /= d0;
d7 /= d1;
int j1 = d0 < 0.0D ? -1 : 1;
int k1 = d1 < 0.0D ? -1 : 1;
int l1 = MathHelper.floor_double(p_75493_2_.xCoord);
int i2 = MathHelper.floor_double(p_75493_2_.zCoord);
int j2 = l1 - l;
int k2 = i2 - i1;
do
{
if (j2 * j1 <= 0 && k2 * k1 <= 0)
{
return true;
}
if (d6 < d7)
{
d6 += d4;
l += j1;
j2 = l1 - l;
}
else
{
d7 += d5;
i1 += k1;
k2 = i2 - i1;
}
}
while (this.isSafeToStandAt(l, (int)p_75493_1_.yCoord, i1, p_75493_3_, p_75493_4_, p_75493_5_, p_75493_1_, d0, d1));
return false;
}
}
}
/**
* Returns true if an entity does not collide with any solid blocks at the position. Args: xOffset, yOffset,
* zOffset, entityXSize, entityYSize, entityZSize, originPosition, vecX, vecZ
*/
private boolean isPositionClear(int p_75496_1_, int p_75496_2_, int p_75496_3_, int p_75496_4_, int p_75496_5_, int p_75496_6_, Vec3 p_75496_7_, double p_75496_8_, double p_75496_10_)
{
for (int k1 = p_75496_1_; k1 < p_75496_1_ + p_75496_4_; ++k1)
{
for (int l1 = p_75496_2_; l1 < p_75496_2_ + p_75496_5_; ++l1)
{
for (int i2 = p_75496_3_; i2 < p_75496_3_ + p_75496_6_; ++i2)
{
double d2 = (double)k1 + 0.5D - p_75496_7_.xCoord;
double d3 = (double)i2 + 0.5D - p_75496_7_.zCoord;
if (d2 * p_75496_8_ + d3 * p_75496_10_ >= 0.0D)
{
Block block = this.worldObj.getBlock(k1, l1, i2);
if (!block.getBlocksMovement(this.worldObj, k1, l1, i2))
{
return false;
}
}
}
}
}
return true;
}
public FlyPathEntity getPathEntityToEntity(Entity p_72865_1_, Entity p_72865_2_, float p_72865_3_, boolean p_72865_4_, boolean p_72865_5_, boolean p_72865_6_, boolean p_72865_7_)
{
this.theEntity.worldObj.theProfiler.startSection("pathfind");
int i = MathHelper.floor_double(p_72865_1_.posX);
int j = MathHelper.floor_double(p_72865_1_.posY + 1.0D);
int k = MathHelper.floor_double(p_72865_1_.posZ);
int l = (int)(p_72865_3_ + 16.0F);
int i1 = i - l;
int j1 = j - l;
int k1 = k - l;
int l1 = i + l;
int i2 = j + l;
int j2 = k + l;
ChunkCache chunkcache = new ChunkCache(this.theEntity.worldObj, i1, j1, k1, l1, i2, j2, 0);
FlyPathEntity pathentity = (new FlyPathFinder(chunkcache, p_72865_4_, p_72865_5_, p_72865_6_, p_72865_7_)).createEntityPathTo(p_72865_1_, p_72865_2_, p_72865_3_);
this.theEntity.worldObj.theProfiler.endSection();
return pathentity;
}
public FlyPathEntity getEntityPathToXYZ(Entity p_72844_1_, int p_72844_2_, int p_72844_3_, int p_72844_4_, float p_72844_5_, boolean p_72844_6_, boolean p_72844_7_, boolean p_72844_8_, boolean p_72844_9_)
{
this.theEntity.worldObj.theProfiler.startSection("pathfind");
int l = MathHelper.floor_double(p_72844_1_.posX);
int i1 = MathHelper.floor_double(p_72844_1_.posY);
int j1 = MathHelper.floor_double(p_72844_1_.posZ);
int k1 = (int)(p_72844_5_ + 8.0F);
int l1 = l - k1;
int i2 = i1 - k1;
int j2 = j1 - k1;
int k2 = l + k1;
int l2 = i1 + k1;
int i3 = j1 + k1;
ChunkCache chunkcache = new ChunkCache(this.theEntity.worldObj, l1, i2, j2, k2, l2, i3, 0);
FlyPathEntity pathentity = (new FlyPathFinder(chunkcache, p_72844_6_, p_72844_7_, p_72844_8_, p_72844_9_)).createEntityPathTo(p_72844_1_, p_72844_2_, p_72844_3_, p_72844_4_, p_72844_5_);
this.theEntity.worldObj.theProfiler.endSection();
return pathentity;
}
} }
@@ -6,10 +6,13 @@ import java.util.List;
import net.minecraft.command.IEntitySelector; import net.minecraft.command.IEntitySelector;
import net.minecraft.entity.EntityCreature; import net.minecraft.entity.EntityCreature;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityAINearestAttackableTarget; import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
import net.minecraft.entity.ai.EntityAITarget; import net.minecraft.entity.ai.EntityAITarget;
import net.minecraft.entity.monster.EntityMob; import net.minecraft.entity.monster.EntityMob;
import net.minecraft.util.MathHelper; import net.minecraft.util.MathHelper;
import noppes.npcs.CustomNpcs;
import noppes.npcs.entity.EntityNPCInterface;
public class EntityAIClosestTarget extends EntityAITarget public class EntityAIClosestTarget extends EntityAITarget
{ {
@@ -52,10 +55,11 @@ public class EntityAIClosestTarget extends EntityAITarget
} }
else else
{ {
taskOwner.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(((EntityNPCInterface) taskOwner).stats.aggroRange);
double d0 = this.getTargetDistance(); double d0 = this.getTargetDistance();
List list = this.taskOwner.worldObj.selectEntitiesWithinAABB(this.targetClass, this.taskOwner.boundingBox.expand(d0, MathHelper.ceiling_double_int(d0 / 2.0D), d0), this.field_82643_g); List list = this.taskOwner.worldObj.selectEntitiesWithinAABB(this.targetClass, this.taskOwner.boundingBox.expand(d0, MathHelper.ceiling_double_int(d0 / 2.0D), d0), this.field_82643_g);
Collections.sort(list, this.theNearestAttackableTargetSorter); Collections.sort(list, this.theNearestAttackableTargetSorter);
taskOwner.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(CustomNpcs.NpcNavRange);
if (list.isEmpty()) if (list.isEmpty())
{ {
return false; return false;
@@ -8,6 +8,7 @@ import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemSword; import net.minecraft.item.ItemSword;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
@@ -41,7 +42,7 @@ public class BlockPedestal extends BlockTrigger{
par1World.markBlockForUpdate(i, j, k); par1World.markBlockForUpdate(i, j, k);
updateSurrounding(par1World, i, j, k); updateSurrounding(par1World, i, j, k);
} }
else if(item == null || item.getItem() == null || !(item.getItem() instanceof ItemSword)) else if(item == null || item.getItem() == null || item.getItem() instanceof ItemBlock)
return true; return true;
else if(item != null && weapon == null){ else if(item != null && weapon == null){
tile.setInventorySlotContents(0, item); tile.setInventorySlotContents(0, item);
@@ -10,6 +10,7 @@ import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.ChatComponentTranslation; import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.util.StatCollector; import net.minecraft.util.StatCollector;
import noppes.npcs.constants.EnumQuestType; import noppes.npcs.constants.EnumQuestType;
import noppes.npcs.controllers.PlayerData;
import noppes.npcs.controllers.PlayerDataController; import noppes.npcs.controllers.PlayerDataController;
import noppes.npcs.controllers.PlayerQuestData; import noppes.npcs.controllers.PlayerQuestData;
import noppes.npcs.controllers.QuestData; import noppes.npcs.controllers.QuestData;
@@ -43,15 +44,16 @@ public class TileWaypoint extends TileEntity {
if(toCheck.isEmpty()) if(toCheck.isEmpty())
return; return;
for(EntityPlayer player : toCheck){ for(EntityPlayer player : toCheck){
PlayerQuestData playerdata = PlayerDataController.instance.getPlayerData(player).questData; PlayerData playerData = PlayerDataController.instance.getPlayerData(player);
for(QuestData data : playerdata.activeQuests.values()){ PlayerQuestData questData = playerData.questData;
for(QuestData data : questData.activeQuests.values()){
if(data.quest.type != EnumQuestType.Location) if(data.quest.type != EnumQuestType.Location)
continue; continue;
QuestLocation quest = (QuestLocation) data.quest.questInterface; QuestLocation quest = (QuestLocation) data.quest.questInterface;
if(quest.setFound(data, name)){ if(quest.setFound(data, name)){
player.addChatMessage(new ChatComponentTranslation(name + " " + StatCollector.translateToLocal("quest.found"))); player.addChatMessage(new ChatComponentTranslation(name + " " + StatCollector.translateToLocal("quest.found")));
playerdata.checkQuestCompletion(player, EnumQuestType.Location); questData.checkQuestCompletion(playerData, EnumQuestType.Location);
} }
} }
} }
@@ -4,13 +4,16 @@ import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled; import io.netty.buffer.Unpooled;
import java.io.IOException; import java.io.IOException;
import java.util.HashMap;
import noppes.npcs.CustomNpcs; import noppes.npcs.CustomNpcs;
import noppes.npcs.Server; import noppes.npcs.Server;
import noppes.npcs.client.gui.customoverlay.OverlayCustom;
import noppes.npcs.constants.EnumPacketServer; import noppes.npcs.constants.EnumPacketServer;
import cpw.mods.fml.common.network.internal.FMLProxyPacket; import cpw.mods.fml.common.network.internal.FMLProxyPacket;
public class Client { public class Client {
public static HashMap<Integer, OverlayCustom> customOverlays = new HashMap<>();
public static void sendData(EnumPacketServer enu, Object... obs) { public static void sendData(EnumPacketServer enu, Object... obs) {
ByteBuf buffer = Unpooled.buffer(); ByteBuf buffer = Unpooled.buffer();
@@ -1,5 +1,18 @@
package noppes.npcs.client; package noppes.npcs.client;
public class ClientEventHandler { import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
import noppes.npcs.client.gui.customoverlay.OverlayCustom;
import org.lwjgl.opengl.GL11;
public class ClientEventHandler {
@SubscribeEvent
public void onOverlayRender(RenderGameOverlayEvent.Post event){
if(event.type == RenderGameOverlayEvent.ElementType.ALL) {
for (OverlayCustom overlayCustom : Client.customOverlays.values()) {
overlayCustom.renderGameOverlay(event.partialTicks);
}
}
}
} }
+144 -126
View File
@@ -21,12 +21,14 @@ import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container; import net.minecraft.inventory.Container;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.stats.Achievement;
import net.minecraft.util.ChatComponentText; import net.minecraft.util.ChatComponentText;
import net.minecraft.util.ReportedException; import net.minecraft.util.ReportedException;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.client.MinecraftForgeClient; import net.minecraftforge.client.MinecraftForgeClient;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.util.FakePlayer;
import noppes.npcs.CommonProxy; import noppes.npcs.CommonProxy;
import noppes.npcs.CustomNpcs; import noppes.npcs.CustomNpcs;
import noppes.npcs.LogWriter; import noppes.npcs.LogWriter;
@@ -62,16 +64,8 @@ import noppes.npcs.client.controllers.PresetController;
import noppes.npcs.client.fx.EntityElementalStaffFX; import noppes.npcs.client.fx.EntityElementalStaffFX;
import noppes.npcs.client.fx.EntityEnderFX; import noppes.npcs.client.fx.EntityEnderFX;
import noppes.npcs.client.fx.EntityRainbowFX; import noppes.npcs.client.fx.EntityRainbowFX;
import noppes.npcs.client.gui.GuiBorderBlock; import noppes.npcs.client.gui.*;
import noppes.npcs.client.gui.GuiMerchantAdd; import noppes.npcs.client.gui.custom.GuiCustom;
import noppes.npcs.client.gui.GuiNpcDimension;
import noppes.npcs.client.gui.GuiNpcMobSpawner;
import noppes.npcs.client.gui.GuiNpcMobSpawnerMounter;
import noppes.npcs.client.gui.GuiNpcPather;
import noppes.npcs.client.gui.GuiNpcRedstoneBlock;
import noppes.npcs.client.gui.GuiNpcRemoteEditor;
import noppes.npcs.client.gui.GuiNpcWaypoint;
import noppes.npcs.client.gui.GuiScript;
import noppes.npcs.client.gui.global.GuiNPCManageBanks; import noppes.npcs.client.gui.global.GuiNPCManageBanks;
import noppes.npcs.client.gui.global.GuiNPCManageDialogs; import noppes.npcs.client.gui.global.GuiNPCManageDialogs;
import noppes.npcs.client.gui.global.GuiNPCManageFactions; import noppes.npcs.client.gui.global.GuiNPCManageFactions;
@@ -105,6 +99,7 @@ import noppes.npcs.client.gui.roles.GuiNpcFollowerSetup;
import noppes.npcs.client.gui.roles.GuiNpcItemGiver; import noppes.npcs.client.gui.roles.GuiNpcItemGiver;
import noppes.npcs.client.gui.roles.GuiNpcTraderSetup; import noppes.npcs.client.gui.roles.GuiNpcTraderSetup;
import noppes.npcs.client.gui.roles.GuiNpcTransporter; import noppes.npcs.client.gui.roles.GuiNpcTransporter;
import noppes.npcs.client.gui.script.GuiScriptGlobal;
import noppes.npcs.client.model.*; import noppes.npcs.client.model.*;
import noppes.npcs.client.renderer.*; import noppes.npcs.client.renderer.*;
import noppes.npcs.client.renderer.blocks.BlockBannerRenderer; import noppes.npcs.client.renderer.blocks.BlockBannerRenderer;
@@ -134,24 +129,11 @@ import noppes.npcs.client.renderer.blocks.BlockWallBannerRenderer;
import noppes.npcs.client.renderer.blocks.BlockWeaponRackRenderer; import noppes.npcs.client.renderer.blocks.BlockWeaponRackRenderer;
import noppes.npcs.config.StringCache; import noppes.npcs.config.StringCache;
import noppes.npcs.constants.EnumGuiType; import noppes.npcs.constants.EnumGuiType;
import noppes.npcs.containers.ContainerCarpentryBench; import noppes.npcs.containers.*;
import noppes.npcs.containers.ContainerCrate; import noppes.npcs.controllers.PlayerData;
import noppes.npcs.containers.ContainerMail;
import noppes.npcs.containers.ContainerManageBanks;
import noppes.npcs.containers.ContainerManageRecipes;
import noppes.npcs.containers.ContainerNPCBankInterface;
import noppes.npcs.containers.ContainerNPCCompanion;
import noppes.npcs.containers.ContainerNPCFollower;
import noppes.npcs.containers.ContainerNPCFollowerHire;
import noppes.npcs.containers.ContainerNPCFollowerSetup;
import noppes.npcs.containers.ContainerNPCInv;
import noppes.npcs.containers.ContainerNPCTrader;
import noppes.npcs.containers.ContainerNPCTraderSetup;
import noppes.npcs.containers.ContainerNpcItemGiver;
import noppes.npcs.containers.ContainerNpcQuestReward;
import noppes.npcs.containers.ContainerNpcQuestTypeItem;
import noppes.npcs.entity.*; import noppes.npcs.entity.*;
import noppes.npcs.scripted.interfaces.IWorld;
import org.lwjgl.input.Keyboard; import org.lwjgl.input.Keyboard;
import tconstruct.client.tabs.InventoryTabFactions; import tconstruct.client.tabs.InventoryTabFactions;
@@ -165,9 +147,9 @@ import cpw.mods.fml.common.ObfuscationReflectionHelper;
public class ClientProxy extends CommonProxy { public class ClientProxy extends CommonProxy {
public static KeyBinding QuestLog; public static KeyBinding QuestLog;
public static FontContainer Font; public static FontContainer Font;
public void load() { public void load() {
Font = new FontContainer(CustomNpcs.FontType, CustomNpcs.FontSize); Font = new FontContainer(CustomNpcs.FontType, CustomNpcs.FontSize);
createFolders(); createFolders();
@@ -217,43 +199,47 @@ public class ClientProxy extends CommonProxy {
RenderingRegistry.registerBlockHandler(new BlockBloodRenderer()); RenderingRegistry.registerBlockHandler(new BlockBloodRenderer());
} }
Minecraft mc = Minecraft.getMinecraft(); Minecraft mc = Minecraft.getMinecraft();
QuestLog = new KeyBinding("Quest Log", Keyboard.KEY_L, "key.categories.gameplay"); QuestLog = new KeyBinding("Quest Log", Keyboard.KEY_L, "key.categories.gameplay");
ClientRegistry.registerKeyBinding(QuestLog); ClientRegistry.registerKeyBinding(QuestLog);
mc.gameSettings.loadOptions(); mc.gameSettings.loadOptions();
new PresetController(CustomNpcs.Dir); new PresetController(CustomNpcs.Dir);
if(CustomNpcs.EnableUpdateChecker){ if(CustomNpcs.EnableUpdateChecker){
VersionChecker checker = new VersionChecker(); VersionChecker checker = new VersionChecker();
checker.start(); checker.start();
} }
ClientCloneController.Instance = new ClientCloneController(); ClientCloneController.Instance = new ClientCloneController();
MinecraftForge.EVENT_BUS.register(new ClientEventHandler()); MinecraftForge.EVENT_BUS.register(new ClientEventHandler());
if(CustomNpcs.InventoryGuiEnabled){ if(CustomNpcs.InventoryGuiEnabled){
MinecraftForge.EVENT_BUS.register(new TabRegistry()); MinecraftForge.EVENT_BUS.register(new TabRegistry());
if (TabRegistry.getTabList().size() < 2){ if (TabRegistry.getTabList().size() < 2){
TabRegistry.registerTab(new InventoryTabVanilla()); TabRegistry.registerTab(new InventoryTabVanilla());
} }
TabRegistry.registerTab(new InventoryTabFactions()); TabRegistry.registerTab(new InventoryTabFactions());
TabRegistry.registerTab(new InventoryTabQuests()); TabRegistry.registerTab(new InventoryTabQuests());
} }
}
public FakePlayer getCommandPlayer(IWorld world) {
return (FakePlayer)(new EntityCustomNpc(world.getMCWorld())).getFakePlayer();
} }
private void createFolders() { private void createFolders() {
File file = new File(CustomNpcs.Dir,"assets/customnpcs"); File file = new File(CustomNpcs.Dir,"assets/customnpcs");
if(!file.exists()) if(!file.exists())
file.mkdirs(); file.mkdirs();
File check = new File(file,"sounds"); File check = new File(file,"sounds");
if(!check.exists()) if(!check.exists())
check.mkdir(); check.mkdir();
File json = new File(file, "sounds.json"); File json = new File(file, "sounds.json");
if(!json.exists()){ if(!json.exists()){
try { try {
@@ -268,16 +254,30 @@ public class ClientProxy extends CommonProxy {
check = new File(file,"textures"); check = new File(file,"textures");
if(!check.exists()) if(!check.exists())
check.mkdir(); check.mkdir();
File cache = new File(check,"cache"); File cache = new File(check,"cache");
if(!cache.exists()) if(!cache.exists())
cache.mkdir(); cache.mkdir();
((IReloadableResourceManager)Minecraft.getMinecraft().getResourceManager()).registerReloadListener(new CustomNpcResourceListener()); ((IReloadableResourceManager)Minecraft.getMinecraft().getResourceManager()).registerReloadListener(new CustomNpcResourceListener());
} }
public static PlayerData playerData = new PlayerData();
@Override
public PlayerData getPlayerData(EntityPlayer player) {
if (player.getUniqueID() == Minecraft.getMinecraft().thePlayer.getUniqueID()) {
if (playerData.player != player) {
playerData.player = player;
}
return playerData;
} else {
return null;
}
}
@Override @Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
if (ID > EnumGuiType.values().length) if (ID > EnumGuiType.values().length)
return null; return null;
EnumGuiType gui = EnumGuiType.values()[ID]; EnumGuiType gui = EnumGuiType.values()[ID];
@@ -286,6 +286,8 @@ public class ClientProxy extends CommonProxy {
return getGui(npc, gui, container, x, y, z); return getGui(npc, gui, container, x, y, z);
} }
private GuiScreen getGui(EntityNPCInterface npc, EnumGuiType gui, Container container, int x, int y, int z) { private GuiScreen getGui(EntityNPCInterface npc, EnumGuiType gui, Container container, int x, int y, int z) {
if (gui == EnumGuiType.MainMenuDisplay){ if (gui == EnumGuiType.MainMenuDisplay){
if(npc != null) if(npc != null)
@@ -304,16 +306,16 @@ public class ClientProxy extends CommonProxy {
else if(gui == EnumGuiType.QuestReward) else if(gui == EnumGuiType.QuestReward)
return new GuiNpcQuestReward(npc, (ContainerNpcQuestReward) container); return new GuiNpcQuestReward(npc, (ContainerNpcQuestReward) container);
else if(gui == EnumGuiType.QuestItem) else if(gui == EnumGuiType.QuestItem)
return new GuiNpcQuestTypeItem(npc, (ContainerNpcQuestTypeItem) container); return new GuiNpcQuestTypeItem(npc, (ContainerNpcQuestTypeItem) container);
else if (gui == EnumGuiType.MovingPath) else if (gui == EnumGuiType.MovingPath)
return new GuiNpcPather(npc); return new GuiNpcPather(npc);
else if (gui == EnumGuiType.ManageFactions) else if (gui == EnumGuiType.ManageFactions)
return new GuiNPCManageFactions(npc); return new GuiNPCManageFactions(npc);
else if (gui == EnumGuiType.ManageLinked) else if (gui == EnumGuiType.ManageLinked)
return new GuiNPCManageLinkedNpc(npc); return new GuiNPCManageLinkedNpc(npc);
@@ -322,15 +324,15 @@ public class ClientProxy extends CommonProxy {
else if (gui == EnumGuiType.ManageRecipes) else if (gui == EnumGuiType.ManageRecipes)
return new GuiNpcManageRecipes(npc,(ContainerManageRecipes) container); return new GuiNpcManageRecipes(npc,(ContainerManageRecipes) container);
else if (gui == EnumGuiType.ManageDialogs) else if (gui == EnumGuiType.ManageDialogs)
return new GuiNPCManageDialogs(npc); return new GuiNPCManageDialogs(npc);
else if (gui == EnumGuiType.ManageQuests) else if (gui == EnumGuiType.ManageQuests)
return new GuiNPCManageQuest(npc); return new GuiNPCManageQuest(npc);
else if(gui == EnumGuiType.ManageBanks) else if(gui == EnumGuiType.ManageBanks)
return new GuiNPCManageBanks(npc,(ContainerManageBanks) container); return new GuiNPCManageBanks(npc,(ContainerManageBanks) container);
else if (gui == EnumGuiType.MainMenuGlobal) else if (gui == EnumGuiType.MainMenuGlobal)
return new GuiNPCGlobalMainMenu(npc); return new GuiNPCGlobalMainMenu(npc);
@@ -343,84 +345,91 @@ public class ClientProxy extends CommonProxy {
else if (gui == EnumGuiType.PlayerFollower) else if (gui == EnumGuiType.PlayerFollower)
return new GuiNpcFollower(npc, (ContainerNPCFollower) container); return new GuiNpcFollower(npc, (ContainerNPCFollower) container);
else if(gui == EnumGuiType.PlayerTrader) else if(gui == EnumGuiType.PlayerTrader)
return new GuiNPCTrader(npc, (ContainerNPCTrader) container); return new GuiNPCTrader(npc, (ContainerNPCTrader) container);
else if(gui == EnumGuiType.PlayerBankSmall || gui == EnumGuiType.PlayerBankUnlock || gui == EnumGuiType.PlayerBankUprade || gui == EnumGuiType.PlayerBankLarge) else if(gui == EnumGuiType.PlayerBankSmall || gui == EnumGuiType.PlayerBankUnlock || gui == EnumGuiType.PlayerBankUprade || gui == EnumGuiType.PlayerBankLarge)
return new GuiNPCBankChest(npc, (ContainerNPCBankInterface) container); return new GuiNPCBankChest(npc, (ContainerNPCBankInterface) container);
else if(gui == EnumGuiType.PlayerTransporter) else if(gui == EnumGuiType.PlayerTransporter)
return new GuiTransportSelection(npc); return new GuiTransportSelection(npc);
else if(gui == EnumGuiType.Script) 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)
return new GuiNpcCarpentryBench((ContainerCarpentryBench) container); return new GuiNpcCarpentryBench((ContainerCarpentryBench) container);
else if (gui == EnumGuiType.SetupFollower) else if (gui == EnumGuiType.SetupFollower)
return new GuiNpcFollowerSetup(npc, (ContainerNPCFollowerSetup) container); return new GuiNpcFollowerSetup(npc, (ContainerNPCFollowerSetup) container);
else if (gui == EnumGuiType.SetupItemGiver) else if (gui == EnumGuiType.SetupItemGiver)
return new GuiNpcItemGiver(npc, (ContainerNpcItemGiver) container); return new GuiNpcItemGiver(npc, (ContainerNpcItemGiver) container);
else if(gui == EnumGuiType.SetupTrader) else if(gui == EnumGuiType.SetupTrader)
return new GuiNpcTraderSetup(npc, (ContainerNPCTraderSetup) container); return new GuiNpcTraderSetup(npc, (ContainerNPCTraderSetup) container);
else if(gui == EnumGuiType.SetupTransporter) else if(gui == EnumGuiType.SetupTransporter)
return new GuiNpcTransporter(npc); return new GuiNpcTransporter(npc);
else if(gui == EnumGuiType.SetupBank) else if(gui == EnumGuiType.SetupBank)
return new GuiNpcBankSetup(npc); return new GuiNpcBankSetup(npc);
else if(gui == EnumGuiType.NpcRemote && Minecraft.getMinecraft().currentScreen == null) else if(gui == EnumGuiType.NpcRemote && Minecraft.getMinecraft().currentScreen == null)
return new GuiNpcRemoteEditor(); return new GuiNpcRemoteEditor();
else if(gui == EnumGuiType.ScriptEvent && Minecraft.getMinecraft().currentScreen == null)
return new GuiScriptGlobal();
else if(gui == EnumGuiType.PlayerMailman) else if(gui == EnumGuiType.PlayerMailman)
return new GuiMailmanWrite((ContainerMail) container, x == 1, y == 1); return new GuiMailmanWrite((ContainerMail) container, x == 1, y == 1);
else if(gui == EnumGuiType.PlayerMailbox) else if(gui == EnumGuiType.PlayerMailbox)
return new GuiMailbox(); return new GuiMailbox();
else if(gui == EnumGuiType.MerchantAdd) else if(gui == EnumGuiType.MerchantAdd)
return new GuiMerchantAdd(); return new GuiMerchantAdd();
else if(gui == EnumGuiType.Crate) else if(gui == EnumGuiType.Crate)
return new GuiCrate((ContainerCrate)container); return new GuiCrate((ContainerCrate)container);
else if(gui == EnumGuiType.NpcDimensions) else if(gui == EnumGuiType.NpcDimensions)
return new GuiNpcDimension(); return new GuiNpcDimension();
else if(gui == EnumGuiType.Border) else if(gui == EnumGuiType.Border)
return new GuiBorderBlock(x, y, z); return new GuiBorderBlock(x, y, z);
else if(gui == EnumGuiType.BigSign) else if(gui == EnumGuiType.BigSign)
return new GuiBigSign(x, y, z); return new GuiBigSign(x, y, z);
else if (gui == EnumGuiType.RedstoneBlock) else if (gui == EnumGuiType.RedstoneBlock)
return new GuiNpcRedstoneBlock(x, y, z); return new GuiNpcRedstoneBlock(x, y, z);
else if(gui == EnumGuiType.MobSpawner) else if(gui == EnumGuiType.MobSpawner)
return new GuiNpcMobSpawner(x, y, z); return new GuiNpcMobSpawner(x, y, z);
else if(gui == EnumGuiType.MobSpawnerMounter) else if(gui == EnumGuiType.MobSpawnerMounter)
return new GuiNpcMobSpawnerMounter(x, y, z); return new GuiNpcMobSpawnerMounter(x, y, z);
else if (gui == EnumGuiType.Waypoint) else if (gui == EnumGuiType.Waypoint)
return new GuiNpcWaypoint(x, y, z); return new GuiNpcWaypoint(x, y, z);
else if (gui == EnumGuiType.Companion) else if (gui == EnumGuiType.Companion)
return new GuiNpcCompanionStats(npc); return new GuiNpcCompanionStats(npc);
else if (gui == EnumGuiType.CompanionTalent) else if (gui == EnumGuiType.CompanionTalent)
return new GuiNpcCompanionTalents(npc); return new GuiNpcCompanionTalents(npc);
else if (gui == EnumGuiType.CompanionInv) else if (gui == EnumGuiType.CompanionInv)
return new GuiNpcCompanionInv(npc, (ContainerNPCCompanion) container); return new GuiNpcCompanionInv(npc, (ContainerNPCCompanion) container);
else if (gui == EnumGuiType.CustomGui)
return new GuiCustom((ContainerCustomGui)container);
return null; return null;
} }
@Override @Override
public void openGui(int i, int j, int k, EnumGuiType gui, EntityPlayer player) { public void openGui(int i, int j, int k, EnumGuiType gui, EntityPlayer player) {
Minecraft minecraft = Minecraft.getMinecraft(); Minecraft minecraft = Minecraft.getMinecraft();
@@ -428,7 +437,7 @@ public class ClientProxy extends CommonProxy {
return; return;
GuiScreen guiscreen = getGui(null, gui, null, i, j, k); GuiScreen guiscreen = getGui(null, gui, null, i, j, k);
if (guiscreen != null) { if (guiscreen != null) {
minecraft.displayGuiScreen(guiscreen); minecraft.displayGuiScreen(guiscreen);
@@ -459,7 +468,7 @@ public class ClientProxy extends CommonProxy {
if (guiscreen != null) { if (guiscreen != null) {
minecraft.displayGuiScreen((GuiScreen)guiscreen); minecraft.displayGuiScreen((GuiScreen)guiscreen);
} }
} }
@Override @Override
@@ -467,18 +476,18 @@ public class ClientProxy extends CommonProxy {
if(string.equals("Spell")){ if(string.equals("Spell")){
int color = (Integer) ob[0]; int color = (Integer) ob[0];
int number = (Integer) ob[1]; int number = (Integer) ob[1];
for(int i = 0; i < number; i++){ for(int i = 0; i < number; i++){
Random rand = player.worldObj.rand; Random rand = player.worldObj.rand;
double x = (rand.nextDouble() - 0.5D) * (double)player.width; double x = (rand.nextDouble() - 0.5D) * (double)player.width;
double y = player.getEyeHeight(); double y = player.getEyeHeight();
double z = (rand.nextDouble() - 0.5D) * (double)player.width; double z = (rand.nextDouble() - 0.5D) * (double)player.width;
double f = (rand.nextDouble() - 0.5D) * 2D; double f = (rand.nextDouble() - 0.5D) * 2D;
double f1 = -rand.nextDouble(); double f1 = -rand.nextDouble();
double f2 = (rand.nextDouble() - 0.5D) * 2D; double f2 = (rand.nextDouble() - 0.5D) * 2D;
Minecraft.getMinecraft().effectRenderer.addEffect(new EntityElementalStaffFX(player, x, y, z, f, f1, f2, color)); Minecraft.getMinecraft().effectRenderer.addEffect(new EntityElementalStaffFX(player, x, y, z, f, f1, f2, color));
} }
} }
else if(string.equals("ModelData")){ else if(string.equals("ModelData")){
ModelData data = (ModelData) ob[0]; ModelData data = (ModelData) ob[0];
@@ -492,21 +501,21 @@ public class ClientProxy extends CommonProxy {
EntityEnderFX fx = new EntityEnderFX(npc, (rand.nextDouble() - 0.5D) * (double)player.width, (rand.nextDouble() * (double)player.height) - height - 0.25D, (rand.nextDouble() - 0.5D) * (double)player.width, (rand.nextDouble() - 0.5D) * 2D, -rand.nextDouble(), (rand.nextDouble() - 0.5D) * 2D, particles); EntityEnderFX fx = new EntityEnderFX(npc, (rand.nextDouble() - 0.5D) * (double)player.width, (rand.nextDouble() * (double)player.height) - height - 0.25D, (rand.nextDouble() - 0.5D) * (double)player.width, (rand.nextDouble() - 0.5D) * 2D, -rand.nextDouble(), (rand.nextDouble() - 0.5D) * 2D, particles);
minecraft.effectRenderer.addEffect(fx); minecraft.effectRenderer.addEffect(fx);
} }
} }
else if(particles.type == 1){ else if(particles.type == 1){
for(int i = 0; i < 2; i++){ for(int i = 0; i < 2; i++){
double x = player.posX + (rand.nextDouble() - 0.5D) * 0.9; double x = player.posX + (rand.nextDouble() - 0.5D) * 0.9;
double y = (player.posY + rand.nextDouble() * 1.9) - 0.25D - height; double y = (player.posY + rand.nextDouble() * 1.9) - 0.25D - height;
double z = player.posZ + (rand.nextDouble() - 0.5D) * 0.9; double z = player.posZ + (rand.nextDouble() - 0.5D) * 0.9;
double f = (rand.nextDouble() - 0.5D) * 2D; double f = (rand.nextDouble() - 0.5D) * 2D;
double f1 = -rand.nextDouble(); double f1 = -rand.nextDouble();
double f2 = (rand.nextDouble() - 0.5D) * 2D; double f2 = (rand.nextDouble() - 0.5D) * 2D;
minecraft.effectRenderer.addEffect(new EntityRainbowFX(player.worldObj, x, y, z, f, f1, f2)); minecraft.effectRenderer.addEffect(new EntityRainbowFX(player.worldObj, x, y, z, f, f1, f2));
} }
} }
} }
} }
@@ -519,7 +528,7 @@ public class ClientProxy extends CommonProxy {
public boolean hasClient() { public boolean hasClient() {
return true; return true;
} }
public EntityPlayer getPlayer() { public EntityPlayer getPlayer() {
return Minecraft.getMinecraft().thePlayer; return Minecraft.getMinecraft().thePlayer;
} }
@@ -534,54 +543,63 @@ public class ClientProxy extends CommonProxy {
try{ try{
if(location == null) if(location == null)
return; return;
TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager(); TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager();
if(location != null) if(location != null)
texturemanager.bindTexture((ResourceLocation) location); texturemanager.bindTexture((ResourceLocation) location);
} }
catch(NullPointerException ex){ catch(NullPointerException ex){
} }
catch(ReportedException ex){ catch(ReportedException ex){
} }
} }
@Override @Override
public void spawnParticle(String particle, double x, double y, double z, public void spawnParticle(String particle, double x, double y, double z,
double motionX, double motionY, double motionZ, float scale) { double motionX, double motionY, double motionZ, float scale) {
RenderGlobal render = Minecraft.getMinecraft().renderGlobal; RenderGlobal render = Minecraft.getMinecraft().renderGlobal;
EntityFX fx = render.doSpawnParticle(particle, x, y, z, motionX, motionY, motionZ); EntityFX fx = render.doSpawnParticle(particle, x, y, z, motionX, motionY, motionZ);
if(fx == null) if(fx == null)
return; return;
if (particle.equals("flame")){ if (particle.equals("flame")){
ObfuscationReflectionHelper.setPrivateValue(EntityFlameFX.class, (EntityFlameFX)fx, scale, 0); ObfuscationReflectionHelper.setPrivateValue(EntityFlameFX.class, (EntityFlameFX)fx, scale, 0);
} }
else if (particle.equals("smoke")){ else if (particle.equals("smoke")){
ObfuscationReflectionHelper.setPrivateValue(EntitySmokeFX.class, (EntitySmokeFX)fx, scale, 0); ObfuscationReflectionHelper.setPrivateValue(EntitySmokeFX.class, (EntitySmokeFX)fx, scale, 0);
} }
}
@Override
public String getAchievementDesc(Achievement achievement) {
return achievement.getDescription();
}
@Override
public boolean isGUIOpen(){
return Minecraft.getMinecraft().currentScreen != null;
} }
public static class FontContainer { public static class FontContainer {
private StringCache textFont = null; private StringCache textFont = null;
public boolean useCustomFont = true; public boolean useCustomFont = true;
private FontContainer(){ private FontContainer(){
} }
public FontContainer(String fontType, int fontSize) { public FontContainer(String fontType, int fontSize) {
textFont = new StringCache(); textFont = new StringCache();
textFont.setDefaultFont("Arial", fontSize, true); textFont.setDefaultFont("Arial", fontSize, true);
useCustomFont = !fontType.equalsIgnoreCase("minecraft"); useCustomFont = !fontType.equalsIgnoreCase("minecraft");
try { try {
if(!useCustomFont || fontType.isEmpty() || fontType.equalsIgnoreCase("default")) if(!useCustomFont || fontType.isEmpty() || fontType.equalsIgnoreCase("default"))
textFont.setCustomFont(new ResourceLocation("customnpcs","OpenSans.ttf"), fontSize, true); textFont.setCustomFont(new ResourceLocation("customnpcs","OpenSans.ttf"), fontSize, true);
else else
textFont.setDefaultFont(fontType, fontSize, true); textFont.setDefaultFont(fontType, fontSize, true);
} catch (Exception e) { } catch (Exception e) {
LogWriter.info("Failed loading font so using Arial"); LogWriter.info("Failed loading font so using Arial");
} }
@@ -592,7 +610,7 @@ public class ClientProxy extends CommonProxy {
return textFont.fontHeight; return textFont.fontHeight;
return Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT; return Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT;
} }
public int width(String text){ public int width(String text){
if(useCustomFont) if(useCustomFont)
return textFont.getStringWidth(text); return textFont.getStringWidth(text);
@@ -622,4 +640,4 @@ public class ClientProxy extends CommonProxy {
return textFont.usedFont().getFontName(); return textFont.usedFont().getFontName();
} }
} }
} }
@@ -14,11 +14,15 @@ import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.InputEvent; import cpw.mods.fml.common.gameevent.InputEvent;
import cpw.mods.fml.common.gameevent.TickEvent; import cpw.mods.fml.common.gameevent.TickEvent;
import cpw.mods.fml.common.gameevent.TickEvent.Phase; import cpw.mods.fml.common.gameevent.TickEvent.Phase;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
public class ClientTickHandler{ public class ClientTickHandler{
private World prevWorld; private World prevWorld;
private boolean otherContainer = false; private boolean otherContainer = false;
private int buttonPressed = -1;
private long buttonTime = 0L;
private final int[] ignoreKeys = new int[]{157, 29, 54, 42, 184, 56, 220, 219};
@SubscribeEvent(priority = EventPriority.LOWEST) @SubscribeEvent(priority = EventPriority.LOWEST)
public void onClientTick(TickEvent.ClientTickEvent event){ public void onClientTick(TickEvent.ClientTickEvent event){
@@ -41,6 +45,14 @@ public class ClientTickHandler{
} }
} }
@SubscribeEvent
public void onMouse(InputEvent.MouseInputEvent event){
if(Mouse.getEventButton() == -1 && Mouse.getDWheel() == 0)
return;
NoppesUtilPlayer.sendData(EnumPlayerPacket.MouseClicked, new Object[]{Mouse.getEventButton(),Mouse.getEventDWheel(),Mouse.isButtonDown(Mouse.getEventButton())});
}
@SubscribeEvent @SubscribeEvent
public void onKey(InputEvent.KeyInputEvent event){ public void onKey(InputEvent.KeyInputEvent event){
if(ClientProxy.QuestLog.isPressed()){ if(ClientProxy.QuestLog.isPressed()){
@@ -50,6 +62,48 @@ public class ClientTickHandler{
else if(mc.currentScreen instanceof GuiQuestLog) else if(mc.currentScreen instanceof GuiQuestLog)
mc.setIngameFocus(); mc.setIngameFocus();
} }
int key = Keyboard.getEventKey();
long time = Keyboard.getEventNanoseconds();
if(Keyboard.getEventKeyState()) {
if(!this.isIgnoredKey(key)) {
this.buttonTime = time;
}
}
if(time-this.buttonTime == 0 || !Keyboard.getEventKeyState()) {
boolean isCtrlPressed = Keyboard.isKeyDown(157) || Keyboard.isKeyDown(29);
boolean isShiftPressed = Keyboard.isKeyDown(54) || Keyboard.isKeyDown(42);
boolean isAltPressed = Keyboard.isKeyDown(184) || Keyboard.isKeyDown(56);
boolean isMetaPressed = Keyboard.isKeyDown(220) || Keyboard.isKeyDown(219);
boolean keyDown = Keyboard.isKeyDown(key);
StringBuilder keysDownString = new StringBuilder();
for(int i = 0; i < Keyboard.getKeyCount(); i++){//Creates a comma separated string of the integer IDs of held keys
if(Keyboard.isKeyDown(i)){
keysDownString.append(Integer.valueOf(i)).append(",");
}
}
if(keysDownString.length() > 0){//Removes last comma for later parsing
keysDownString.deleteCharAt(keysDownString.length()-1);
}
NoppesUtilPlayer.sendData(EnumPlayerPacket.KeyPressed, new Object[]{Integer.valueOf(key), Boolean.valueOf(isCtrlPressed), Boolean.valueOf(isShiftPressed), Boolean.valueOf(isAltPressed), Boolean.valueOf(isMetaPressed), Boolean.valueOf(keyDown), keysDownString.toString()});
}
} }
private boolean isIgnoredKey(int key) {
int[] var2 = this.ignoreKeys;
int var3 = var2.length;
for(int var4 = 0; var4 < var3; ++var4) {
int i = var2[var4];
if(i == key) {
return true;
}
}
return false;
}
} }
@@ -6,12 +6,14 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.net.URI; import java.net.URI;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Random; import java.util.Random;
import java.util.Vector; import java.util.Vector;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.audio.PositionedSoundRecord; import net.minecraft.client.audio.PositionedSoundRecord;
import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.GuiScreen;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
@@ -21,6 +23,7 @@ import net.minecraft.world.World;
import noppes.npcs.CustomNpcs; import noppes.npcs.CustomNpcs;
import noppes.npcs.NoppesUtilPlayer; import noppes.npcs.NoppesUtilPlayer;
import noppes.npcs.Server; import noppes.npcs.Server;
import noppes.npcs.client.fx.EntityCustomFX;
import noppes.npcs.client.gui.player.GuiDialogInteract; import noppes.npcs.client.gui.player.GuiDialogInteract;
import noppes.npcs.client.gui.player.GuiQuestCompletion; import noppes.npcs.client.gui.player.GuiQuestCompletion;
import noppes.npcs.client.gui.util.GuiContainerNPCInterface; import noppes.npcs.client.gui.util.GuiContainerNPCInterface;
@@ -67,6 +70,75 @@ public class NoppesUtil {
} }
} }
public static void spawnScriptedParticle(ByteBuf buffer){
Minecraft minecraft = Minecraft.getMinecraft();
String directory = Server.readString(buffer);
int HEXcolor = buffer.readInt();
int amount = buffer.readInt();
int maxAge = buffer.readInt();
double x = buffer.readDouble();
double y = buffer.readDouble();
double z = buffer.readDouble();
double motionX = buffer.readDouble();
double motionY = buffer.readDouble();
double motionZ = buffer.readDouble();
float gravity = buffer.readFloat();
float scale1 = buffer.readFloat();
float scale2 = buffer.readFloat();
float scaleRate = buffer.readFloat();
int scaleRateStart = buffer.readInt();
float alpha1 = buffer.readFloat();
float alpha2 = buffer.readFloat();
float alphaRate = buffer.readFloat();
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();
World worldObj = Minecraft.getMinecraft().theWorld;
Entity entity = worldObj.getEntityByID(entityID);
if(entity == null)
return;
EntityCustomFX fx = new EntityCustomFX(
entity,
directory, HEXcolor,
x, y, z,
motionX, motionY, motionZ, gravity,
scale1, scale2, scaleRate, scaleRateStart,
alpha1, alpha2, alphaRate, alphaRateStart,
rotationX1, rotationX2, rotationXRate, rotationXRateStart,
rotationY1, rotationY2, rotationYRate, rotationYRateStart,
rotationZ1, rotationZ2, rotationZRate, rotationZRateStart,
maxAge
);
for(int i = 0; i < amount; i++){
minecraft.effectRenderer.addEffect(fx);
}
}
public static void clickSound() { public static void clickSound() {
Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F)); Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F));
} }
@@ -237,4 +309,7 @@ public class NoppesUtil {
CustomNpcs.proxy.openGui(x, y, z, EnumGuiType.Waypoint, player); CustomNpcs.proxy.openGui(x, y, z, EnumGuiType.Waypoint, player);
} }
public static void isGUIOpen(boolean isGUIOpen) {
Client.sendData(EnumPacketServer.IsGuiOpen, isGUIOpen);
}
} }
@@ -26,6 +26,7 @@ import noppes.npcs.ServerEventsHandler;
import noppes.npcs.client.ClientProxy.FontContainer; import noppes.npcs.client.ClientProxy.FontContainer;
import noppes.npcs.client.controllers.MusicController; import noppes.npcs.client.controllers.MusicController;
import noppes.npcs.client.gui.GuiNpcMobSpawnerAdd; import noppes.npcs.client.gui.GuiNpcMobSpawnerAdd;
import noppes.npcs.client.gui.customoverlay.OverlayCustom;
import noppes.npcs.client.gui.player.GuiBook; import noppes.npcs.client.gui.player.GuiBook;
import noppes.npcs.client.gui.util.GuiContainerNPCInterface; import noppes.npcs.client.gui.util.GuiContainerNPCInterface;
import noppes.npcs.client.gui.util.GuiNPCInterface; import noppes.npcs.client.gui.util.GuiNPCInterface;
@@ -151,6 +152,9 @@ public class PacketHandlerClient extends PacketHandlerServer{
EnumGuiType gui = EnumGuiType.values()[buffer.readInt()]; EnumGuiType gui = EnumGuiType.values()[buffer.readInt()];
CustomNpcs.proxy.openGui(NoppesUtil.getLastNpc(), gui, buffer.readInt(), buffer.readInt(), buffer.readInt()); CustomNpcs.proxy.openGui(NoppesUtil.getLastNpc(), gui, buffer.readInt(), buffer.readInt(), buffer.readInt());
} }
else if(type == EnumPacketClient.SCRIPTED_PARTICLE){
NoppesUtil.spawnScriptedParticle(buffer);
}
else if(type == EnumPacketClient.PARTICLE){ else if(type == EnumPacketClient.PARTICLE){
NoppesUtil.spawnParticle(buffer); NoppesUtil.spawnParticle(buffer);
} }
@@ -251,8 +255,20 @@ public class PacketHandlerClient extends PacketHandlerServer{
player.addChatMessage(new ChatComponentTranslation("Current font is %s", ClientProxy.Font.getName())); player.addChatMessage(new ChatComponentTranslation("Current font is %s", ClientProxy.Font.getName()));
} }
} }
else if(type == EnumPacketClient.ISGUIOPEN){
boolean isGUIOpen = Minecraft.getMinecraft().currentScreen != null;
NoppesUtil.isGUIOpen(isGUIOpen);
}
else if(type == EnumPacketClient.OVERLAY_DATA){
OverlayCustom overlayCustom = new OverlayCustom(Minecraft.getMinecraft());
overlayCustom.setOverlayData(Server.readNBT(buffer));
Client.customOverlays.put(overlayCustom.overlay.getID(),overlayCustom);
}
else if(type == EnumPacketClient.OVERLAY_CLOSE){
int id = buffer.readInt();
Client.customOverlays.remove(id);
}
} }
} }
@@ -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();
} }
} }
@@ -0,0 +1,212 @@
package noppes.npcs.client.fx;
import net.minecraft.client.Minecraft;
import net.minecraft.client.particle.EntityFX;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ResourceLocation;
import noppes.npcs.client.ClientProxy;
import org.lwjgl.opengl.GL11;
public class EntityCustomFX extends EntityFX {
private Entity entity;
private final ResourceLocation location;
private static final ResourceLocation resource = new ResourceLocation("textures/particle/particles.png");
private boolean move = true;
private float startX = 0, startY = 0, startZ = 0;
public float scale1 = 1.0F;
public float scale2 = 1.0F;
public float scaleRate = 1.0F;
public int scaleRateStart = 0;
public float alpha1 = 1.0F;
public float alpha2 = 0;
public float alphaRate = 0.0F;
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,
double motionX, double motionY, double motionZ, float gravity,
float scale1, float scale2, float scaleRate, int scaleRateStart,
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) {
super(entity.worldObj, x, y, z, motionX, motionY, motionZ);
this.scale1 = scale1;
this.scale2 = scale2;
this.scaleRate = Math.abs(scaleRate);
this.scaleRateStart = scaleRateStart;
particleScale = scale1;
if(scale1 > scale2)
this.scaleRate *= -1;
this.alpha1 = alpha1;
this.alpha2 = alpha2;
this.alphaRate = Math.abs(alphaRate);
this.alphaRateStart = alphaRateStart;
particleAlpha = alpha1;
if(alpha1 > alpha2)
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;
particleMaxAge = age;
this.motionX = motionX;
this.motionY = motionY;
this.motionZ = motionZ;
this.entity = entity;
noClip = true;
particleRed = (HEXColor >> 16 & 255) / 255f;
particleGreen = (HEXColor >> 8 & 255) / 255f;
particleBlue = (HEXColor & 255) / 255f;
if(Math.floor(Math.random()*3) == 1){
move = false;
this.startX = (float) entity.posX;
this.startY = (float) entity.posY;
this.startZ = (float) entity.posZ;
}
location = new ResourceLocation(directory);
}
@Override
public void renderParticle(Tessellator tessellator, float partialTick, float cosYaw, float cosPitch, float sinYaw, float sinSinPitch, float cosSinPitch)
{
tessellator.draw();
GL11.glPushMatrix();
ClientProxy.bindTexture(location);
if(move){
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();
GL11.glPopMatrix();
GL11.glColor4f(1, 1, 1, 1.0F);
ClientProxy.bindTexture(resource);
tessellator.startDrawingQuads();
}
public int getFXLayer(){
return 0;
}
}
@@ -0,0 +1,103 @@
package noppes.npcs.client.gui;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.client.gui.GuiButton;
import noppes.npcs.controllers.ScriptContainer;
import noppes.npcs.client.gui.util.GuiCustomScroll;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.SubGuiInterface;
public class EventGuiScriptList extends SubGuiInterface{
private GuiCustomScroll scroll1;
private GuiCustomScroll scroll2;
private ScriptContainer container;
private List<String> scripts;
public EventGuiScriptList(List<String> scripts, ScriptContainer container){
this.container = container;
setBackground("menubg.png");
xSize = 346;
ySize = 216;
if(scripts == null)
scripts = new ArrayList<String>();
this.scripts = scripts;
}
@Override
public void initGui(){
super.initGui();
if(scroll1 == null){
scroll1 = new GuiCustomScroll(this,0);
scroll1.setSize(140, 180);
}
scroll1.guiLeft = guiLeft + 4;
scroll1.guiTop = guiTop + 14;
this.addScroll(scroll1);
addLabel(new GuiNpcLabel(1, "script.availableScripts", guiLeft + 4, guiTop + 4));
if(scroll2 == null){
scroll2 = new GuiCustomScroll(this,1);
scroll2.setSize(140, 180);
}
scroll2.guiLeft = guiLeft + 200;
scroll2.guiTop = guiTop + 14;
this.addScroll(scroll2);
addLabel(new GuiNpcLabel(2, "script.loadedScripts", guiLeft + 200, guiTop + 4));
List<String> temp = new ArrayList<String>(scripts);
temp.removeAll(container.scripts);
scroll1.setList(temp);
scroll2.setList(container.scripts);
addButton(new GuiNpcButton(1, guiLeft + 145, guiTop + 40, 55, 20, ">"));
addButton(new GuiNpcButton(2, guiLeft + 145, guiTop + 62, 55, 20, "<"));
addButton(new GuiNpcButton(3, guiLeft + 145, guiTop + 90, 55, 20, ">>"));
addButton(new GuiNpcButton(4, guiLeft + 145, guiTop + 112, 55, 20, "<<"));
addButton(new GuiNpcButton(66, guiLeft + 260, guiTop + 194, 60, 20, "gui.done"));
}
protected void actionPerformed(GuiButton guibutton){
GuiNpcButton button = (GuiNpcButton) guibutton;
if(button.id == 1){
if(scroll1.hasSelected()){
container.scripts.add(scroll1.getSelected());
scroll1.selected = -1;
scroll1.selected = -1;
initGui();
}
}
if(button.id == 2){
if(scroll2.hasSelected()){
container.scripts.remove(scroll2.getSelected());
scroll2.selected = -1;
initGui();
}
}
if(button.id == 3){
container.scripts.clear();
for(String script : scripts){
container.scripts.add(script);
}
scroll1.selected = -1;
scroll1.selected = -1;
initGui();
}
if(button.id == 4){
container.scripts.clear();
scroll1.selected = -1;
scroll1.selected = -1;
initGui();
}
if(button.id == 66){
close();
}
}
@Override
public void save() {
}
}
@@ -4,7 +4,6 @@ import net.minecraft.client.gui.GuiButton;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.blocks.tiles.TileBorder; import noppes.npcs.blocks.tiles.TileBorder;
import noppes.npcs.client.Client; import noppes.npcs.client.Client;
import noppes.npcs.client.NoppesUtil;
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 noppes.npcs.client.gui.util.GuiNpcLabel; import noppes.npcs.client.gui.util.GuiNpcLabel;
@@ -30,7 +29,7 @@ public class GuiBorderBlock extends GuiNPCInterface implements IGuiData{
addLabel(new GuiNpcLabel(0,"Height", guiLeft+ 1, guiTop + 76, 0xffffff)); addLabel(new GuiNpcLabel(0,"Height", guiLeft+ 1, guiTop + 76, 0xffffff));
addTextField(new GuiNpcTextField(0, this, fontRendererObj, guiLeft+ 60, guiTop + 71,40,20, tile.height + "")); addTextField(new GuiNpcTextField(0, this, fontRendererObj, guiLeft+ 60, guiTop + 71,40,20, tile.height + ""));
getTextField(0).numbersOnly = true; getTextField(0).integersOnly = true;
getTextField(0).setMinMaxDefault(0, 500, 6); getTextField(0).setMinMaxDefault(0, 500, 6);
addLabel(new GuiNpcLabel(1,"Message", guiLeft+ 1, guiTop + 100, 0xffffff)); addLabel(new GuiNpcLabel(1,"Message", guiLeft+ 1, guiTop + 100, 0xffffff));
@@ -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();
@@ -12,11 +12,7 @@ import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.client.Client; import noppes.npcs.client.Client;
import noppes.npcs.client.NoppesUtil; import noppes.npcs.client.NoppesUtil;
import noppes.npcs.client.controllers.ClientCloneController; import noppes.npcs.client.controllers.ClientCloneController;
import noppes.npcs.client.gui.util.GuiNPCInterface; import noppes.npcs.client.gui.util.*;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.GuiNpcTextField;
import noppes.npcs.client.gui.util.IGuiData;
import noppes.npcs.constants.EnumPacketServer; import noppes.npcs.constants.EnumPacketServer;
import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.entity.EntityNPCInterface;
@@ -44,7 +40,8 @@ public class GuiNpcMobSpawnerAdd extends GuiNPCInterface implements GuiYesNoCall
addLabel(new GuiNpcLabel(1, "Tab", guiLeft + 10, guiTop + 50)); addLabel(new GuiNpcLabel(1, "Tab", guiLeft + 10, guiTop + 50));
addButton(new GuiNpcButton(2, guiLeft + 40, guiTop + 45, 20, 20, new String[]{"1","2","3","4","5","6","7","8","9","10","11","12","13","14","15"}, tab - 1)); // addButton(new GuiNpcButton(2, guiLeft + 40, guiTop + 45, 20, 20, new String[]{"1","2","3","4","5","6","7","8","9","10","11","12","13","14","15"}, tab - 1));
addButton(new GuiButtonBiDirectional(2, guiLeft + 40, guiTop + 45, 60, 20, new String[]{"1","2","3","4","5","6","7","8","9","10","11","12","13","14","15"}, tab - 1));
addButton(new GuiNpcButton(3, guiLeft + 4, guiTop + 95, new String[]{"Client side", "Server side"}, serverSide?1:0)); addButton(new GuiNpcButton(3, guiLeft + 4, guiTop + 95, new String[]{"Client side", "Server side"}, serverSide?1:0));
@@ -5,7 +5,6 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.StatCollector; import net.minecraft.util.StatCollector;
import noppes.npcs.blocks.tiles.TileRedstoneBlock; import noppes.npcs.blocks.tiles.TileRedstoneBlock;
import noppes.npcs.client.Client; import noppes.npcs.client.Client;
import noppes.npcs.client.NoppesUtil;
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 noppes.npcs.client.gui.util.GuiNpcLabel; import noppes.npcs.client.gui.util.GuiNpcLabel;
@@ -33,39 +32,39 @@ public class GuiNpcRedstoneBlock extends GuiNPCInterface{
if(tile.isDetailed){ if(tile.isDetailed){
addLabel(new GuiNpcLabel(0,StatCollector.translateToLocal("bard.ondistance") + " X:", guiLeft+ 1, guiTop + 76, 0xffffff)); addLabel(new GuiNpcLabel(0,StatCollector.translateToLocal("bard.ondistance") + " X:", guiLeft+ 1, guiTop + 76, 0xffffff));
addTextField(new GuiNpcTextField(0, this, fontRendererObj, guiLeft+ 80, guiTop + 71,30,20, tile.onRangeX + "")); addTextField(new GuiNpcTextField(0, this, fontRendererObj, guiLeft+ 80, guiTop + 71,30,20, tile.onRangeX + ""));
getTextField(0).numbersOnly = true; getTextField(0).integersOnly = true;
getTextField(0).setMinMaxDefault(0, 50, 6); getTextField(0).setMinMaxDefault(0, 50, 6);
addLabel(new GuiNpcLabel(1,"Y:", guiLeft+ 113, guiTop + 76, 0xffffff)); addLabel(new GuiNpcLabel(1,"Y:", guiLeft+ 113, guiTop + 76, 0xffffff));
addTextField(new GuiNpcTextField(1, this, fontRendererObj, guiLeft+ 122, guiTop + 71,30,20, tile.onRangeY + "")); addTextField(new GuiNpcTextField(1, this, fontRendererObj, guiLeft+ 122, guiTop + 71,30,20, tile.onRangeY + ""));
getTextField(1).numbersOnly = true; getTextField(1).integersOnly = true;
getTextField(1).setMinMaxDefault(0, 50, 6); getTextField(1).setMinMaxDefault(0, 50, 6);
addLabel(new GuiNpcLabel(2,"Z:", guiLeft+ 155, guiTop + 76, 0xffffff)); addLabel(new GuiNpcLabel(2,"Z:", guiLeft+ 155, guiTop + 76, 0xffffff));
addTextField(new GuiNpcTextField(2, this, fontRendererObj, guiLeft+ 164, guiTop + 71,30,20, tile.onRangeZ + "")); addTextField(new GuiNpcTextField(2, this, fontRendererObj, guiLeft+ 164, guiTop + 71,30,20, tile.onRangeZ + ""));
getTextField(2).numbersOnly = true; getTextField(2).integersOnly = true;
getTextField(2).setMinMaxDefault(0, 50, 6); getTextField(2).setMinMaxDefault(0, 50, 6);
addLabel(new GuiNpcLabel(3,StatCollector.translateToLocal("bard.offdistance") + " X:", guiLeft - 3, guiTop + 99, 0xffffff)); addLabel(new GuiNpcLabel(3,StatCollector.translateToLocal("bard.offdistance") + " X:", guiLeft - 3, guiTop + 99, 0xffffff));
addTextField(new GuiNpcTextField(3, this, fontRendererObj, guiLeft+ 80, guiTop + 94,30,20, tile.offRangeX + "")); addTextField(new GuiNpcTextField(3, this, fontRendererObj, guiLeft+ 80, guiTop + 94,30,20, tile.offRangeX + ""));
getTextField(3).numbersOnly = true; getTextField(3).integersOnly = true;
getTextField(3).setMinMaxDefault(0, 50, 10); getTextField(3).setMinMaxDefault(0, 50, 10);
addLabel(new GuiNpcLabel(4,"Y:", guiLeft+ 113, guiTop + 99, 0xffffff)); addLabel(new GuiNpcLabel(4,"Y:", guiLeft+ 113, guiTop + 99, 0xffffff));
addTextField(new GuiNpcTextField(4, this, fontRendererObj, guiLeft+ 122, guiTop + 94,30,20, tile.offRangeY + "")); addTextField(new GuiNpcTextField(4, this, fontRendererObj, guiLeft+ 122, guiTop + 94,30,20, tile.offRangeY + ""));
getTextField(4).numbersOnly = true; getTextField(4).integersOnly = true;
getTextField(4).setMinMaxDefault(0, 50, 10); getTextField(4).setMinMaxDefault(0, 50, 10);
addLabel(new GuiNpcLabel(5,"Z:", guiLeft+ 155, guiTop + 99, 0xffffff)); addLabel(new GuiNpcLabel(5,"Z:", guiLeft+ 155, guiTop + 99, 0xffffff));
addTextField(new GuiNpcTextField(5, this, fontRendererObj, guiLeft+ 164, guiTop + 94,30,20, tile.offRangeZ + "")); addTextField(new GuiNpcTextField(5, this, fontRendererObj, guiLeft+ 164, guiTop + 94,30,20, tile.offRangeZ + ""));
getTextField(5).numbersOnly = true; getTextField(5).integersOnly = true;
getTextField(5).setMinMaxDefault(0, 50, 10); getTextField(5).setMinMaxDefault(0, 50, 10);
} }
else{ else{
addLabel(new GuiNpcLabel(0,"bard.ondistance", guiLeft+ 1, guiTop + 76, 0xffffff)); addLabel(new GuiNpcLabel(0,"bard.ondistance", guiLeft+ 1, guiTop + 76, 0xffffff));
addTextField(new GuiNpcTextField(0, this, fontRendererObj, guiLeft+ 80, guiTop + 71,30,20, tile.onRange + "")); addTextField(new GuiNpcTextField(0, this, fontRendererObj, guiLeft+ 80, guiTop + 71,30,20, tile.onRange + ""));
getTextField(0).numbersOnly = true; getTextField(0).integersOnly = true;
getTextField(0).setMinMaxDefault(0, 50, 6); getTextField(0).setMinMaxDefault(0, 50, 6);
addLabel(new GuiNpcLabel(3,"bard.offdistance", guiLeft - 3, guiTop + 99, 0xffffff)); addLabel(new GuiNpcLabel(3,"bard.offdistance", guiLeft - 3, guiTop + 99, 0xffffff));
addTextField(new GuiNpcTextField(3, this, fontRendererObj, guiLeft+ 80, guiTop + 94,30,20, tile.offRange + "")); addTextField(new GuiNpcTextField(3, this, fontRendererObj, guiLeft+ 80, guiTop + 94,30,20, tile.offRange + ""));
getTextField(3).numbersOnly = true; getTextField(3).integersOnly = true;
getTextField(3).setMinMaxDefault(0, 50, 10); getTextField(3).setMinMaxDefault(0, 50, 10);
} }
addButton(new GuiNpcButton(0, guiLeft + 40, guiTop + 190,120,20, "Done")); addButton(new GuiNpcButton(0, guiLeft + 40, guiTop + 190,120,20, "Done"));
@@ -29,7 +29,7 @@ public class GuiNpcWaypoint extends GuiNPCInterface{
addLabel(new GuiNpcLabel(1,"gui.range", guiLeft+ 1, guiTop + 97, 0xffffff)); addLabel(new GuiNpcLabel(1,"gui.range", guiLeft+ 1, guiTop + 97, 0xffffff));
addTextField(new GuiNpcTextField(1, this, fontRendererObj, guiLeft+ 60, guiTop + 92,200,20, tile.range + "")); addTextField(new GuiNpcTextField(1, this, fontRendererObj, guiLeft+ 60, guiTop + 92,200,20, tile.range + ""));
getTextField(1).numbersOnly = true; getTextField(1).integersOnly = true;
getTextField(1).setMinMaxDefault(2, 60, 10); getTextField(1).setMinMaxDefault(2, 60, 10);
addButton(new GuiNpcButton(0, guiLeft + 40, guiTop + 190,120,20, "Done")); addButton(new GuiNpcButton(0, guiLeft + 40, guiTop + 190,120,20, "Done"));
@@ -1,9 +1,6 @@
package noppes.npcs.client.gui; package noppes.npcs.client.gui;
import java.util.ArrayList; import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiConfirmOpenLink; import net.minecraft.client.gui.GuiConfirmOpenLink;
@@ -11,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;
@@ -30,23 +28,23 @@ import noppes.npcs.controllers.ScriptContainer;
import noppes.npcs.controllers.ScriptController; import noppes.npcs.controllers.ScriptController;
import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.entity.EntityNPCInterface;
public class GuiScript extends GuiNPCInterface implements IGuiData, GuiYesNoCallback, ICustomScrollListener, IJTextAreaListener { public class GuiScript extends GuiNPCInterface implements IGuiData, GuiYesNoCallback, ICustomScrollListener, IJTextAreaListener {
public boolean showScript = false; public boolean showScript = false;
private int activeTab = 0; private int activeTab = 0;
public DataScript script; public DataScript script;
public Map<String,List<String>> languages = new HashMap<String,List<String>>(); public Map<String,List<String>> languages = new HashMap<String,List<String>>();
private static int activeConsole = 0; private static int activeConsole = 0;
public GuiScript(EntityNPCInterface npc) { public GuiScript(EntityNPCInterface npc) {
super(npc); super(npc);
script = npc.script; script = npc.script;
drawDefaultBackground = true; drawDefaultBackground = true;
closeOnEsc = true; closeOnEsc = true;
xSize = 420; xSize = 420;
setBackground("menubg.png"); setBackground("menubg.png");
Client.sendData(EnumPacketServer.ScriptDataGet); Client.sendData(EnumPacketServer.ScriptDataGet);
} }
public void initGui() { public void initGui() {
@@ -59,37 +57,38 @@ public class GuiScript extends GuiNPCInterface implements IGuiData, GuiYesNoCall
top.active = !showScript; top.active = !showScript;
addTopButton(new GuiMenuTopButton(15, top, "gui.website")); addTopButton(new GuiMenuTopButton(15, top, "gui.website"));
List<String> list = new ArrayList<String>(); List<String> list = new ArrayList<String>();
list.add("script.init"); list.add("script.init");
list.add("script.update"); list.add("script.update");
list.add("script.interact"); list.add("script.interact");
list.add("dialog.dialog"); list.add("dialog.dialog");
list.add("script.damaged"); list.add("script.damaged");
list.add("script.killed"); list.add("script.killed");
list.add("script.attack"); list.add("script.attack");
list.add("script.target"); list.add("script.target");
list.add("script.collide"); list.add("script.collide");
list.add("script.kills"); list.add("script.kills");
list.add("script.dialog_closed"); list.add("script.dialog_closed");
list.add("script.timer");
if(showScript){ if(showScript){
addLabel(new GuiNpcLabel(0, "script.hooks", guiLeft + 4, guiTop + 5)); addLabel(new GuiNpcLabel(0, "script.hooks", guiLeft + 4, guiTop + 5));
GuiCustomScroll hooks = new GuiCustomScroll(this, 1); GuiCustomScroll hooks = new GuiCustomScroll(this, 1);
hooks.setSize(68, 198); hooks.setSize(68, 198);
hooks.guiLeft = guiLeft + 4; hooks.guiLeft = guiLeft + 4;
hooks.guiTop = guiTop + 14; hooks.guiTop = guiTop + 14;
hooks.setUnsortedList(list); hooks.setUnsortedList(list);
hooks.selected = activeTab; hooks.selected = activeTab;
addScroll(hooks); addScroll(hooks);
ScriptContainer container = script.scripts.get(activeTab); ScriptContainer container = script.scripts.get(activeTab);
addTextField(new GuiNpcTextArea(2, this, guiLeft + 74, guiTop + 4, 239, 208, container == null?"":container.script)); addTextField(new GuiNpcTextArea(2, this, guiLeft + 74, guiTop + 4, 239, 208, container == null?"":container.script));
addButton(new GuiNpcButton(102, guiLeft + 315, guiTop + 4, 50, 20, "gui.clear")); addButton(new GuiNpcButton(102, guiLeft + 315, guiTop + 4, 50, 20, "gui.clear"));
addButton(new GuiNpcButton(101, guiLeft + 366, guiTop + 4, 50, 20, "gui.paste")); addButton(new GuiNpcButton(101, guiLeft + 366, guiTop + 4, 50, 20, "gui.paste"));
addButton(new GuiNpcButton(100, guiLeft + 315, guiTop + 25, 50, 20, "gui.copy")); addButton(new GuiNpcButton(100, guiLeft + 315, guiTop + 25, 50, 20, "gui.copy"));
addButton(new GuiNpcButton(108, guiLeft + 315, guiTop + 47, 80, 20, "gui.editor")); addButton(new GuiNpcButton(108, guiLeft + 315, guiTop + 47, 80, 20, "gui.editor"));
addButton(new GuiNpcButton(107, guiLeft + 315, guiTop + 70, 80, 20, "script.loadscript")); addButton(new GuiNpcButton(107, guiLeft + 315, guiTop + 70, 80, 20, "script.loadscript"));
@@ -114,14 +113,14 @@ public class GuiScript extends GuiNPCInterface implements IGuiData, GuiYesNoCall
l.add("All"); l.add("All");
l.addAll(list); l.addAll(list);
addButton(new GuiNpcButton(105, guiLeft + 60, guiTop + 4, 80, 20, l.toArray(new String[l.size()]), activeConsole)); addButton(new GuiNpcButton(105, guiLeft + 60, guiTop + 4, 80, 20, l.toArray(new String[l.size()]), activeConsole));
addLabel(new GuiNpcLabel(1, "script.language", guiLeft + 232, guiTop + 30)); addLabel(new GuiNpcLabel(1, "script.language", guiLeft + 232, guiTop + 30));
addButton(new GuiNpcButton(103, guiLeft + 294, guiTop + 25, 80, 20, languages.keySet().toArray(new String[languages.keySet().size()]), getScriptIndex())); addButton(new GuiNpcButton(103, guiLeft + 294, guiTop + 25, 80, 20, languages.keySet().toArray(new String[languages.keySet().size()]), getScriptIndex()));
getButton(103).enabled = languages.size() > 0; getButton(103).enabled = languages.size() > 0;
addLabel(new GuiNpcLabel(2, "gui.enabled", guiLeft + 232, guiTop + 53)); addLabel(new GuiNpcLabel(2, "gui.enabled", guiLeft + 232, guiTop + 53));
addButton(new GuiNpcButton(104, guiLeft + 294, guiTop + 48, 50, 20, new String[]{"gui.no","gui.yes"}, script.enabled?1:0)); addButton(new GuiNpcButton(104, guiLeft + 294, guiTop + 48, 50, 20, new String[]{"gui.no","gui.yes"}, script.enabled?1:0));
if(MinecraftServer.getServer() != null) if(MinecraftServer.getServer() != null)
addButton(new GuiNpcButton(106, guiLeft + 232, guiTop + 71, 150, 20, "script.openfolder")); addButton(new GuiNpcButton(106, guiLeft + 232, guiTop + 71, 150, 20, "script.openfolder"));
} }
@@ -138,27 +137,24 @@ public class GuiScript extends GuiNPCInterface implements IGuiData, GuiYesNoCall
} }
private String getConsoleText() { private String getConsoleText() {
String console = ""; Map<Long, String> map = this.script.getConsoleText();
if(activeConsole == 0){ StringBuilder builder = new StringBuilder();
for(ScriptContainer container : script.scripts.values()){ Iterator var3 = map.entrySet().iterator();
if(!container.console.isEmpty())
console += container.console + '\n'; while(var3.hasNext()) {
} Map.Entry<Long, String> entry = (Map.Entry)var3.next();
builder.insert(0, new Date((Long)entry.getKey()) + (String)entry.getValue() + "\n");
} }
else{
ScriptContainer container = script.scripts.get(activeConsole - 1); return builder.toString();
if(container != null)
console = container.console;
}
return console;
} }
@Override @Override
public void confirmClicked(boolean flag, int i){ public void confirmClicked(boolean flag, int i){
if(flag) if(flag)
openLink("http://www.kodevelopment.nl/minecraft/customnpcs/scripting"); openLink("http://www.kodevelopment.nl/minecraft/customnpcs/scripting");
displayGuiScreen(this); displayGuiScreen(this);
} }
@Override @Override
protected void actionPerformed(GuiButton guibutton) { protected void actionPerformed(GuiButton guibutton) {
@@ -173,7 +169,7 @@ public class GuiScript extends GuiNPCInterface implements IGuiData, GuiYesNoCall
} }
if(guibutton.id == 15){ if(guibutton.id == 15){
GuiConfirmOpenLink guiyesno = new GuiConfirmOpenLink(this, "http://www.kodevelopment.nl/minecraft/customnpcs/scripting", 0, true); GuiConfirmOpenLink guiyesno = new GuiConfirmOpenLink(this, "http://www.kodevelopment.nl/minecraft/customnpcs/scripting", 0, true);
mc.displayGuiScreen(guiyesno); mc.displayGuiScreen(guiyesno);
} }
if (guibutton.id == 100) { if (guibutton.id == 100) {
NoppesStringUtils.setClipboardContents(getTextField(2).getText()); NoppesStringUtils.setClipboardContents(getTextField(2).getText());
@@ -185,13 +181,13 @@ public class GuiScript extends GuiNPCInterface implements IGuiData, GuiYesNoCall
getTextField(2).setText(""); getTextField(2).setText("");
if(!showScript){ if(!showScript){
if(activeConsole == 0){ if(activeConsole == 0){
for(ScriptContainer container : script.scripts.values()) for(ScriptContainer container : script.scripts)
container.console = ""; container.console.clear();
} }
else{ else{
ScriptContainer container = script.scripts.get(activeConsole - 1); ScriptContainer container = script.scripts.get(activeConsole - 1);
if(container != null) if(container != null)
container.console = ""; container.console.clear();
} }
} }
} }
@@ -211,7 +207,7 @@ public class GuiScript extends GuiNPCInterface implements IGuiData, GuiYesNoCall
if (guibutton.id == 107) { if (guibutton.id == 107) {
ScriptContainer container = script.scripts.get(activeTab); ScriptContainer container = script.scripts.get(activeTab);
if(container == null) if(container == null)
script.scripts.put(activeTab, container = new ScriptContainer()); script.scripts.set(activeTab, container = new ScriptContainer(this.script));
setSubGui(new GuiScriptList(languages.get(script.scriptLanguage), container)); setSubGui(new GuiScriptList(languages.get(script.scriptLanguage), container));
} }
if (guibutton.id == 108) { if (guibutton.id == 108) {
@@ -222,12 +218,12 @@ public class GuiScript extends GuiNPCInterface implements IGuiData, GuiYesNoCall
} }
} }
} }
private void setScript(){ private void setScript(){
if(showScript){ if(showScript){
ScriptContainer container = script.scripts.get(activeTab); ScriptContainer container = script.scripts.get(activeTab);
if(container == null) if(container == null)
script.scripts.put(activeTab, container = new ScriptContainer()); script.scripts.set(activeTab, container = new ScriptContainer(this.script));
String text = getTextField(2).getText(); String text = getTextField(2).getText();
text = text.replace("\r\n", "\n"); text = text.replace("\r\n", "\n");
text = text.replace("\r", "\n"); text = text.replace("\r", "\n");
@@ -256,7 +252,7 @@ public class GuiScript extends GuiNPCInterface implements IGuiData, GuiYesNoCall
@Override @Override
public void save() { public void save() {
setScript(); setScript();
Client.sendData(EnumPacketServer.ScriptDataSave, script.writeToNBT(new NBTTagCompound())); Client.sendData(EnumPacketServer.ScriptDataSave, script.writeToNBT(new NBTTagCompound()));
} }
@Override @Override
@@ -277,3 +273,4 @@ public class GuiScript extends GuiNPCInterface implements IGuiData, GuiYesNoCall
} }
} }
@@ -4,14 +4,11 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiButton;
import net.minecraft.world.biome.BiomeGenBase;
import noppes.npcs.client.gui.util.GuiCustomScroll; import noppes.npcs.client.gui.util.GuiCustomScroll;
import noppes.npcs.client.gui.util.GuiNPCInterface;
import noppes.npcs.client.gui.util.GuiNpcButton; import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcLabel; import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.SubGuiInterface; import noppes.npcs.client.gui.util.SubGuiInterface;
import noppes.npcs.controllers.ScriptContainer; import noppes.npcs.controllers.ScriptContainer;
import noppes.npcs.entity.EntityNPCInterface;
public class GuiScriptList extends SubGuiInterface{ public class GuiScriptList extends SubGuiInterface{
private GuiCustomScroll scroll1; private GuiCustomScroll scroll1;
@@ -1,11 +1,9 @@
package noppes.npcs.client.gui; package noppes.npcs.client.gui;
import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.client.Client; import noppes.npcs.client.Client;
import noppes.npcs.client.NoppesUtil; import noppes.npcs.client.NoppesUtil;
import noppes.npcs.client.gui.global.GuiNPCQuestSelection;
import noppes.npcs.client.gui.util.GuiNpcButton; import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcLabel; import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.GuiNpcTextField; import noppes.npcs.client.gui.util.GuiNpcTextField;
@@ -13,15 +11,11 @@ import noppes.npcs.client.gui.util.GuiSelectionListener;
import noppes.npcs.client.gui.util.ITextfieldListener; import noppes.npcs.client.gui.util.ITextfieldListener;
import noppes.npcs.client.gui.util.IGuiData; import noppes.npcs.client.gui.util.IGuiData;
import noppes.npcs.client.gui.util.SubGuiInterface; import noppes.npcs.client.gui.util.SubGuiInterface;
import noppes.npcs.constants.EnumAvailabilityDialog;
import noppes.npcs.constants.EnumAvailabilityFactionType; import noppes.npcs.constants.EnumAvailabilityFactionType;
import noppes.npcs.constants.EnumAvailabilityQuest;
import noppes.npcs.constants.EnumDayTime; import noppes.npcs.constants.EnumDayTime;
import noppes.npcs.constants.EnumPacketServer; import noppes.npcs.constants.EnumPacketServer;
import noppes.npcs.controllers.Availability; import noppes.npcs.controllers.Availability;
import noppes.npcs.controllers.Dialog;
import noppes.npcs.controllers.Faction; import noppes.npcs.controllers.Faction;
import noppes.npcs.controllers.Quest;
public class SubGuiNpcAvailability extends SubGuiInterface implements ITextfieldListener, GuiSelectionListener, IGuiData public class SubGuiNpcAvailability extends SubGuiInterface implements ITextfieldListener, GuiSelectionListener, IGuiData
{ {
@@ -66,7 +60,7 @@ public class SubGuiNpcAvailability extends SubGuiInterface implements ITextfield
addLabel(new GuiNpcLabel(51,"availability.minlevel", guiLeft + 4 , guiTop + 175)); addLabel(new GuiNpcLabel(51,"availability.minlevel", guiLeft + 4 , guiTop + 175));
this.addTextField(new GuiNpcTextField(51, this, fontRendererObj, guiLeft + 50, guiTop + 170,90, 20, availabitily.minPlayerLevel + "")); this.addTextField(new GuiNpcTextField(51, this, fontRendererObj, guiLeft + 50, guiTop + 170,90, 20, availabitily.minPlayerLevel + ""));
this.getTextField(51).numbersOnly = true; this.getTextField(51).integersOnly = true;
this.getTextField(51).setMinMaxDefault(0, Integer.MAX_VALUE, 0); this.getTextField(51).setMinMaxDefault(0, Integer.MAX_VALUE, 0);
this.addButton(new GuiNpcButton(66, guiLeft + 82, guiTop + 192,98, 20, "gui.done")); this.addButton(new GuiNpcButton(66, guiLeft + 82, guiTop + 192,98, 20, "gui.done"));
@@ -55,6 +55,9 @@ public class SubGuiNpcDialogExtra extends SubGuiInterface implements ISubGuiList
addButton(new GuiNpcButtonYesNo(15, guiLeft + 120, y += 22, dialog.disableEsc)); addButton(new GuiNpcButtonYesNo(15, guiLeft + 120, y += 22, dialog.disableEsc));
addLabel(new GuiNpcLabel(15, "dialog.disableEsc", guiLeft + 4, y + 5)); addLabel(new GuiNpcLabel(15, "dialog.disableEsc", guiLeft + 4, y + 5));
addButton(new GuiNpcButtonYesNo(16, guiLeft + 120, y += 22, dialog.darkenScreen));
addLabel(new GuiNpcLabel(16, "Darken Screen", guiLeft + 4, y + 5));
this.addButton(new GuiNpcButton(66, guiLeft + 82, guiTop + 192,98, 20, "gui.done")); this.addButton(new GuiNpcButton(66, guiLeft + 82, guiTop + 192,98, 20, "gui.done"));
@@ -76,6 +79,9 @@ public class SubGuiNpcDialogExtra extends SubGuiInterface implements ISubGuiList
if(button.id == 15){ if(button.id == 15){
dialog.disableEsc = button.getValue() == 1; dialog.disableEsc = button.getValue() == 1;
} }
if(button.id == 16){
dialog.darkenScreen = button.getValue() == 1;
}
if(button.id == 13){ if(button.id == 13){
setSubGui(new SubGuiMailmanSendSetup(dialog.mail, getParent())); setSubGui(new SubGuiMailmanSendSetup(dialog.mail, getParent()));
} }
@@ -80,7 +80,7 @@ public class SubGuiNpcFactionOptions extends SubGuiInterface implements IScrollD
addButton(new GuiNpcButton(2, guiLeft + 4, guiTop + 60, 90, 20, new String[]{"gui.increase","gui.decrease"},0)); addButton(new GuiNpcButton(2, guiLeft + 4, guiTop + 60, 90, 20, new String[]{"gui.increase","gui.decrease"},0));
addTextField(new GuiNpcTextField(1, this, fontRendererObj, guiLeft + 4, guiTop + 82, 110, 20, "10")); addTextField(new GuiNpcTextField(1, this, fontRendererObj, guiLeft + 4, guiTop + 82, 110, 20, "10"));
getTextField(1).numbersOnly = true; getTextField(1).integersOnly = true;
getTextField(1).setMinMaxDefault(1, 100000, 10); getTextField(1).setMinMaxDefault(1, 100000, 10);
addButton(new GuiNpcButton(3, guiLeft + 4, guiTop + 104, 60, 20, "gui.add")); addButton(new GuiNpcButton(3, guiLeft + 4, guiTop + 104, 60, 20, "gui.add"));
@@ -28,7 +28,7 @@ public class SubGuiNpcFactionPoints extends SubGuiInterface implements ITextfiel
this.addTextField(new GuiNpcTextField(2, this, guiLeft + 8 + fontRendererObj.getStringWidth(getLabel(2).label), guiTop + 28, 70, 20, faction.defaultPoints + "")); this.addTextField(new GuiNpcTextField(2, this, guiLeft + 8 + fontRendererObj.getStringWidth(getLabel(2).label), guiTop + 28, 70, 20, faction.defaultPoints + ""));
getTextField(2).setMaxStringLength(6); getTextField(2).setMaxStringLength(6);
getTextField(2).numbersOnly = true; getTextField(2).integersOnly = true;
String title = StatCollector.translateToLocal("faction.unfriendly") + "<->" + StatCollector.translateToLocal("faction.neutral"); String title = StatCollector.translateToLocal("faction.unfriendly") + "<->" + StatCollector.translateToLocal("faction.neutral");
addLabel(new GuiNpcLabel(3, title, guiLeft + 4, guiTop + 80)); addLabel(new GuiNpcLabel(3, title, guiLeft + 4, guiTop + 80));
@@ -38,8 +38,8 @@ public class SubGuiNpcFactionPoints extends SubGuiInterface implements ITextfiel
addLabel(new GuiNpcLabel(4, title, guiLeft + 4, guiTop + 105)); addLabel(new GuiNpcLabel(4, title, guiLeft + 4, guiTop + 105));
addTextField(new GuiNpcTextField(4, this, guiLeft + 8 + fontRendererObj.getStringWidth(title), guiTop + 100, 70, 20, faction.friendlyPoints + "")); addTextField(new GuiNpcTextField(4, this, guiLeft + 8 + fontRendererObj.getStringWidth(title), guiTop + 100, 70, 20, faction.friendlyPoints + ""));
getTextField(3).numbersOnly = true; getTextField(3).integersOnly = true;
getTextField(4).numbersOnly = true; getTextField(4).integersOnly = true;
if(getTextField(3).xPosition > getTextField(4).xPosition) if(getTextField(3).xPosition > getTextField(4).xPosition)
getTextField(4).xPosition = getTextField(3).xPosition; getTextField(4).xPosition = getTextField(3).xPosition;
@@ -27,30 +27,30 @@ public class SubGuiNpcMeleeProperties extends SubGuiInterface implements ITextfi
{ {
super.initGui(); super.initGui();
addLabel(new GuiNpcLabel(1,"stats.meleestrength", guiLeft + 5, guiTop + 15)); addLabel(new GuiNpcLabel(1,"stats.meleestrength", guiLeft + 5, guiTop + 15));
addTextField(new GuiNpcTextField(1,this, fontRendererObj, guiLeft + 85, guiTop + 10, 50, 18, stats.getAttackStrength()+"")); addTextField(new GuiNpcTextField(1,this, fontRendererObj, guiLeft + 85, guiTop + 10, 50, 18, String.format("%.0f", stats.getAttackStrength()) + ""));
getTextField(1).numbersOnly = true; getTextField(1).floatsOnly = true;
getTextField(1).setMinMaxDefault(0, 99999, 5); getTextField(1).setMinMaxDefaultFloat(0,Float.MAX_VALUE,5);
addLabel(new GuiNpcLabel(2,"stats.meleerange", guiLeft + 5, guiTop + 45)); addLabel(new GuiNpcLabel(2,"stats.meleerange", guiLeft + 5, guiTop + 45));
addTextField(new GuiNpcTextField(2,this, fontRendererObj, guiLeft + 85, guiTop + 40, 50, 18, stats.attackRange+"")); addTextField(new GuiNpcTextField(2,this, fontRendererObj, guiLeft + 85, guiTop + 40, 50, 18, stats.attackRange+""));
getTextField(2).numbersOnly = true; getTextField(2).integersOnly = true;
getTextField(2).setMinMaxDefault(1, 30, 2); getTextField(2).setMinMaxDefault(1, Integer.MAX_VALUE, 2);
addLabel(new GuiNpcLabel(3,"stats.meleespeed", guiLeft + 5, guiTop + 75)); addLabel(new GuiNpcLabel(3,"stats.meleespeed", guiLeft + 5, guiTop + 75));
addTextField(new GuiNpcTextField(3,this, fontRendererObj, guiLeft + 85, guiTop + 70, 50, 18, stats.attackSpeed+"")); addTextField(new GuiNpcTextField(3,this, fontRendererObj, guiLeft + 85, guiTop + 70, 50, 18, stats.attackSpeed+""));
getTextField(3).numbersOnly = true; getTextField(3).integersOnly = true;
getTextField(3).setMinMaxDefault(1, 1000, 20); getTextField(3).setMinMaxDefault(1, Integer.MAX_VALUE, 20);
addLabel(new GuiNpcLabel(4,"enchantment.knockback", guiLeft + 5, guiTop + 105)); addLabel(new GuiNpcLabel(4,"enchantment.knockback", guiLeft + 5, guiTop + 105));
addTextField(new GuiNpcTextField(4,this, fontRendererObj, guiLeft + 85, guiTop + 100, 50, 18, stats.knockback + "")); addTextField(new GuiNpcTextField(4,this, fontRendererObj, guiLeft + 85, guiTop + 100, 50, 18, stats.knockback + ""));
getTextField(4).numbersOnly = true; getTextField(4).integersOnly = true;
getTextField(4).setMinMaxDefault(0, 4, 0); getTextField(4).setMinMaxDefault(0, Integer.MAX_VALUE, 0);
addLabel(new GuiNpcLabel(5,"stats.meleeeffect", guiLeft + 5, guiTop + 135)); addLabel(new GuiNpcLabel(5,"stats.meleeeffect", guiLeft + 5, guiTop + 135));
addButton(new GuiNpcButton(5,guiLeft + 85, guiTop + 130, 52, 20, potionNames, stats.potionType.ordinal())); addButton(new GuiNpcButton(5,guiLeft + 85, guiTop + 130, 52, 20, potionNames, stats.potionType.ordinal()));
if(stats.potionType != EnumPotionType.None) { if(stats.potionType != EnumPotionType.None) {
addLabel(new GuiNpcLabel(6,"gui.time", guiLeft + 5, guiTop + 165)); addLabel(new GuiNpcLabel(6,"gui.time", guiLeft + 5, guiTop + 165));
addTextField(new GuiNpcTextField(6,this, fontRendererObj, guiLeft + 85, guiTop + 160, 50, 18, stats.potionDuration + "")); addTextField(new GuiNpcTextField(6,this, fontRendererObj, guiLeft + 85, guiTop + 160, 50, 18, stats.potionDuration + ""));
getTextField(6).numbersOnly = true; getTextField(6).integersOnly = true;
getTextField(6).setMinMaxDefault(1, 99999, 5); getTextField(6).setMinMaxDefault(1, Integer.MAX_VALUE, 5);
if(stats.potionType != EnumPotionType.Fire) { if(stats.potionType != EnumPotionType.Fire) {
addLabel(new GuiNpcLabel(7,"stats.amplify", guiLeft + 5, guiTop + 195)); addLabel(new GuiNpcLabel(7,"stats.amplify", guiLeft + 5, guiTop + 195));
addButton(new GuiNpcButton(7,guiLeft + 85, guiTop + 190, 52, 20, new String[]{"gui.no", "gui.yes"} ,stats.potionAmp)); addButton(new GuiNpcButton(7,guiLeft + 85, guiTop + 190, 52, 20, new String[]{"gui.no", "gui.yes"} ,stats.potionAmp));
@@ -61,7 +61,7 @@ public class SubGuiNpcMeleeProperties extends SubGuiInterface implements ITextfi
public void unFocused(GuiNpcTextField textfield) { public void unFocused(GuiNpcTextField textfield) {
if(textfield.id == 1){ if(textfield.id == 1){
stats.setAttackStrength(textfield.getInteger()); stats.setAttackStrength(Float.parseFloat(textfield.getText()));
} }
else if(textfield.id == 2){ else if(textfield.id == 2){
stats.attackRange = textfield.getInteger(); stats.attackRange = textfield.getInteger();
@@ -30,12 +30,34 @@ public class SubGuiNpcMovement extends SubGuiInterface implements ITextfieldList
this.addButton(new GuiNpcButton(0, guiLeft + 80, y, 100, 20, EnumMovingType.names(), ai.movingType.ordinal())); this.addButton(new GuiNpcButton(0, guiLeft + 80, y, 100, 20, EnumMovingType.names(), ai.movingType.ordinal()));
// Fly Change // Fly Change
// this.addButton(new GuiNpcButton(15, guiLeft + 80, y += 22, 100, 20, new String[]{"movement.ground","movement.flying"}, ai.movementType)); this.addButton(new GuiNpcButton(15, guiLeft + 80, y += 22, 100, 20, new String[]{"movement.ground","movement.flying"}, ai.movementType));
if(ai.movementType == 1){
this.addLabel(new GuiNpcLabel(18, "fly.speed", guiLeft + 4, y + 140));
addTextField(new GuiNpcTextField(18,this, guiLeft + 80, y + 135, 40, 20, ai.flySpeed + ""));
getTextField(18).doublesOnly = true;
getTextField(18).setMinMaxDefaultDouble(0.0D,Double.MAX_VALUE,1.0D);
this.addLabel(new GuiNpcLabel(19, "fly.gravity", guiLeft + 4, y + 160));
addTextField(new GuiNpcTextField(19,this, guiLeft + 80, y + 155, 40, 20, ai.flyGravity + ""));
getTextField(19).doublesOnly = true;
getTextField(19).setMinMaxDefaultDouble(0.0D,1.0D,0.0D);
this.addLabel(new GuiNpcLabel(20, "Limit Height", guiLeft + 150, y + 116));
addButton(new GuiNpcButton(20, guiLeft + 210, y + 110, 40, 20, new String[]{"gui.no","gui.yes"}, ai.hasFlyLimit?1:0));
if(ai.hasFlyLimit) {
this.addLabel(new GuiNpcLabel(21, "Height", guiLeft + 150, y + 140));
addTextField(new GuiNpcTextField(21, this, guiLeft + 185, y + 135, 40, 20, ai.flyHeightLimit + ""));
getTextField(21).integersOnly = true;
getTextField(21).setMinMaxDefaultDouble(0.0D, Double.MAX_VALUE, 1.0D);
}
}
if(ai.movingType == EnumMovingType.Wandering){ if(ai.movingType == EnumMovingType.Wandering){
addTextField(new GuiNpcTextField(4,this, guiLeft + 100, y += 22, 40, 20, ai.walkingRange + "")); addTextField(new GuiNpcTextField(4,this, guiLeft + 100, y += 22, 40, 20, ai.walkingRange + ""));
getTextField(4).numbersOnly = true; getTextField(4).integersOnly = true;
getTextField(4).setMinMaxDefault(0, 1000, 5); getTextField(4).setMinMaxDefault(0, Integer.MAX_VALUE, 5);
addLabel(new GuiNpcLabel(4,"gui.range", guiLeft + 4, y + 5)); addLabel(new GuiNpcLabel(4,"gui.range", guiLeft + 4, y + 5));
addButton(new GuiNpcButton(5, guiLeft + 100, y += 22, 50, 20, new String[]{"gui.no","gui.yes"}, ai.npcInteracting?1:0)); addButton(new GuiNpcButton(5, guiLeft + 100, y += 22, 50, 20, new String[]{"gui.no","gui.yes"}, ai.npcInteracting?1:0));
@@ -45,15 +67,15 @@ public class SubGuiNpcMovement extends SubGuiInterface implements ITextfieldList
addTextField(new GuiNpcTextField(7,this, guiLeft + 99, y += 22, 24, 20, (int)ai.bodyOffsetX + "")); addTextField(new GuiNpcTextField(7,this, guiLeft + 99, y += 22, 24, 20, (int)ai.bodyOffsetX + ""));
addLabel(new GuiNpcLabel(17, "spawner.posoffset", guiLeft + 4, y + 5)); addLabel(new GuiNpcLabel(17, "spawner.posoffset", guiLeft + 4, y + 5));
addLabel(new GuiNpcLabel(7,"X:", guiLeft + 115, y + 5)); addLabel(new GuiNpcLabel(7,"X:", guiLeft + 115, y + 5));
getTextField(7).numbersOnly = true; getTextField(7).integersOnly = true;
getTextField(7).setMinMaxDefault(0, 10, 5); getTextField(7).setMinMaxDefault(0, 10, 5);
addLabel(new GuiNpcLabel(8,"Y:", guiLeft + 125, y + 5)); addLabel(new GuiNpcLabel(8,"Y:", guiLeft + 125, y + 5));
addTextField(new GuiNpcTextField(8,this, guiLeft + 135, y, 24, 20, (int)ai.bodyOffsetY + "")); addTextField(new GuiNpcTextField(8,this, guiLeft + 135, y, 24, 20, (int)ai.bodyOffsetY + ""));
getTextField(8).numbersOnly = true; getTextField(8).integersOnly = true;
getTextField(8).setMinMaxDefault(0, 10, 5); getTextField(8).setMinMaxDefault(0, 10, 5);
addLabel(new GuiNpcLabel(9,"Z:", guiLeft + 161, y + 5)); addLabel(new GuiNpcLabel(9,"Z:", guiLeft + 161, y + 5));
addTextField(new GuiNpcTextField(9,this, guiLeft + 171, y, 24, 20, (int)ai.bodyOffsetZ + "")); addTextField(new GuiNpcTextField(9,this, guiLeft + 171, y, 24, 20, (int)ai.bodyOffsetZ + ""));
getTextField(9).numbersOnly = true; getTextField(9).integersOnly = true;
getTextField(9).setMinMaxDefault(0, 10, 5); getTextField(9).setMinMaxDefault(0, 10, 5);
this.addButton(new GuiNpcButton(3, guiLeft + 80, y += 22, 100, 20, new String[]{"stats.normal","movement.sitting","movement.lying","movement.sneaking","movement.dancing","movement.aiming", "movement.crawling", "movement.hug"},ai.animationType.ordinal())); this.addButton(new GuiNpcButton(3, guiLeft + 80, y += 22, 100, 20, new String[]{"stats.normal","movement.sitting","movement.lying","movement.sneaking","movement.dancing","movement.aiming", "movement.crawling", "movement.hug"},ai.animationType.ordinal()));
@@ -65,14 +87,14 @@ public class SubGuiNpcMovement extends SubGuiInterface implements ITextfieldList
} }
else{ else{
addTextField(new GuiNpcTextField(5,this, guiLeft + 99, y += 22, 40, 20, ai.orientation + "")); addTextField(new GuiNpcTextField(5,this, guiLeft + 99, y += 22, 40, 20, ai.orientation + ""));
getTextField(5).numbersOnly = true; getTextField(5).integersOnly = true;
getTextField(5).setMinMaxDefault(0, 359, 0); getTextField(5).setMinMaxDefault(0, 359, 0);
this.addLabel(new GuiNpcLabel(6, "movement.rotation", guiLeft + 4, y + 5)); this.addLabel(new GuiNpcLabel(6, "movement.rotation", guiLeft + 4, y + 5));
addLabel(new GuiNpcLabel(5,"(0-359)", guiLeft + 142, y + 5)); addLabel(new GuiNpcLabel(5,"(0-359)", guiLeft + 142, y + 5));
} }
if(ai.standingType == EnumStandingType.NoRotation || ai.standingType == EnumStandingType.HeadRotation){ if(ai.standingType == EnumStandingType.NoRotation || ai.standingType == EnumStandingType.HeadRotation){
addTextField(new GuiNpcTextField(5,this, guiLeft + 165, y, 40, 20, ai.orientation + "")); addTextField(new GuiNpcTextField(5,this, guiLeft + 165, y, 40, 20, ai.orientation + ""));
getTextField(5).numbersOnly = true; getTextField(5).integersOnly = true;
getTextField(5).setMinMaxDefault(0, 359, 0); getTextField(5).setMinMaxDefault(0, 359, 0);
addLabel(new GuiNpcLabel(5,"(0-359)", guiLeft + 207, y + 5)); addLabel(new GuiNpcLabel(5,"(0-359)", guiLeft + 207, y + 5));
} }
@@ -92,8 +114,8 @@ public class SubGuiNpcMovement extends SubGuiInterface implements ITextfieldList
addLabel(new GuiNpcLabel(13,"movement.stopinteract", guiLeft + 4, y + 5)); addLabel(new GuiNpcLabel(13,"movement.stopinteract", guiLeft + 4, y + 5));
addTextField(new GuiNpcTextField(14,this, guiLeft + 80, y += 22, 50, 18, ai.getWalkingSpeed()+"")); addTextField(new GuiNpcTextField(14,this, guiLeft + 80, y += 22, 50, 18, ai.getWalkingSpeed()+""));
getTextField(14).numbersOnly = true; getTextField(14).integersOnly = true;
getTextField(14).setMinMaxDefault(0, 10, 4); getTextField(14).setMinMaxDefault(0, Integer.MAX_VALUE, 4);
addLabel(new GuiNpcLabel(14,"stats.walkspeed", guiLeft + 5, y + 5)); addLabel(new GuiNpcLabel(14,"stats.walkspeed", guiLeft + 5, y + 5));
addButton(new GuiNpcButton(66, guiLeft + 190, guiTop + 190, 60, 20, "gui.done")); addButton(new GuiNpcButton(66, guiLeft + 190, guiTop + 190, 60, 20, "gui.done"));
@@ -146,10 +168,13 @@ public class SubGuiNpcMovement extends SubGuiInterface implements ITextfieldList
} }
else if (button.id == 15) { else if (button.id == 15) {
ai.movementType = button.getValue(); ai.movementType = button.getValue();
initGui();
} else if (button.id == 20) {
ai.hasFlyLimit = button.getValue() == 1;
initGui();
} else if (button.id == 66) {
close();
} }
else if(button.id == 66){
close();
}
} }
@Override @Override
@@ -172,6 +197,15 @@ public class SubGuiNpcMovement extends SubGuiInterface implements ITextfieldList
else if(textfield.id == 14){ else if(textfield.id == 14){
ai.setWalkingSpeed(textfield.getInteger()); ai.setWalkingSpeed(textfield.getInteger());
} }
else if(textfield.id == 18){
ai.flySpeed = textfield.getDouble();
}
else if(textfield.id == 19){
ai.flyGravity = textfield.getDouble();
}
else if(textfield.id == 21){
ai.flyHeightLimit = textfield.getInteger();
}
} }
} }
@@ -7,7 +7,6 @@ import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.GuiNpcTextField; import noppes.npcs.client.gui.util.GuiNpcTextField;
import noppes.npcs.client.gui.util.ITextfieldListener; import noppes.npcs.client.gui.util.ITextfieldListener;
import noppes.npcs.client.gui.util.SubGuiInterface; import noppes.npcs.client.gui.util.SubGuiInterface;
import noppes.npcs.constants.EnumAnimation;
import noppes.npcs.constants.EnumPotionType; import noppes.npcs.constants.EnumPotionType;
import noppes.npcs.constants.EnumParticleType; import noppes.npcs.constants.EnumParticleType;
@@ -29,21 +28,21 @@ public class SubGuiNpcProjectiles extends SubGuiInterface implements ITextfieldL
{ {
super.initGui(); super.initGui();
addLabel(new GuiNpcLabel(1,"enchantment.arrowDamage", guiLeft + 5, guiTop + 15)); addLabel(new GuiNpcLabel(1,"enchantment.arrowDamage", guiLeft + 5, guiTop + 15));
addTextField(new GuiNpcTextField(1,this, fontRendererObj, guiLeft + 45, guiTop + 10, 50, 18, stats.pDamage+"")); addTextField(new GuiNpcTextField(1,this, fontRendererObj, guiLeft + 45, guiTop + 10, 50, 18, String.format("%.0f", stats.pDamage) +""));
getTextField(1).numbersOnly = true; getTextField(1).setFloatsOnly();
getTextField(1).setMinMaxDefault(0, 9999, 5); getTextField(1).setMinMaxDefaultFloat(0, Float.MAX_VALUE, 5);
addLabel(new GuiNpcLabel(2,"enchantment.arrowKnockback", guiLeft + 110, guiTop + 15)); addLabel(new GuiNpcLabel(2,"enchantment.arrowKnockback", guiLeft + 110, guiTop + 15));
addTextField(new GuiNpcTextField(2,this, fontRendererObj, guiLeft + 150, guiTop + 10, 50, 18, stats.pImpact+"")); addTextField(new GuiNpcTextField(2,this, fontRendererObj, guiLeft + 150, guiTop + 10, 50, 18, stats.pImpact+""));
getTextField(2).numbersOnly = true; getTextField(2).integersOnly = true;
getTextField(2).setMinMaxDefault(0, 3, 0); getTextField(2).setMinMaxDefault(0, Integer.MAX_VALUE, 0);
addLabel(new GuiNpcLabel(3,"stats.size", guiLeft + 5, guiTop + 45)); addLabel(new GuiNpcLabel(3,"stats.size", guiLeft + 5, guiTop + 45));
addTextField(new GuiNpcTextField(3,this, fontRendererObj, guiLeft + 45, guiTop + 40, 50, 18, stats.pSize+"")); addTextField(new GuiNpcTextField(3,this, fontRendererObj, guiLeft + 45, guiTop + 40, 50, 18, stats.pSize+""));
getTextField(3).numbersOnly = true; getTextField(3).integersOnly = true;
getTextField(3).setMinMaxDefault(1, 10, 10); getTextField(3).setMinMaxDefault(1, Integer.MAX_VALUE, 10);
addLabel(new GuiNpcLabel(4,"stats.speed", guiLeft + 5, guiTop + 75)); addLabel(new GuiNpcLabel(4,"stats.speed", guiLeft + 5, guiTop + 75));
addTextField(new GuiNpcTextField(4,this, fontRendererObj, guiLeft + 45, guiTop + 70, 50, 18, stats.pSpeed+"")); addTextField(new GuiNpcTextField(4,this, fontRendererObj, guiLeft + 45, guiTop + 70, 50, 18, stats.pSpeed+""));
getTextField(4).numbersOnly = true; getTextField(4).integersOnly = true;
getTextField(4).setMinMaxDefault(1, 50, 10); getTextField(4).setMinMaxDefault(1, Integer.MAX_VALUE, 10);
addLabel(new GuiNpcLabel(5,"stats.hasgravity", guiLeft + 5, guiTop + 105)); addLabel(new GuiNpcLabel(5,"stats.hasgravity", guiLeft + 5, guiTop + 105));
addButton(new GuiNpcButton(0, guiLeft + 60, guiTop + 100, 60, 20, new String[]{"gui.no", "gui.yes"} ,stats.pPhysics ? 1:0)); addButton(new GuiNpcButton(0, guiLeft + 60, guiTop + 100, 60, 20, new String[]{"gui.no", "gui.yes"} ,stats.pPhysics ? 1:0));
@@ -59,8 +58,8 @@ public class SubGuiNpcProjectiles extends SubGuiInterface implements ITextfieldL
addButton(new GuiNpcButton(4,guiLeft + 60, guiTop + 160, 60, 20, potionNames, stats.pEffect.ordinal())); addButton(new GuiNpcButton(4,guiLeft + 60, guiTop + 160, 60, 20, potionNames, stats.pEffect.ordinal()));
if(stats.pEffect != EnumPotionType.None) { if(stats.pEffect != EnumPotionType.None) {
addTextField(new GuiNpcTextField(5,this, fontRendererObj, guiLeft + 140, guiTop + 160, 60, 18, stats.pDur + "")); addTextField(new GuiNpcTextField(5,this, fontRendererObj, guiLeft + 140, guiTop + 160, 60, 18, stats.pDur + ""));
getTextField(5).numbersOnly = true; getTextField(5).integersOnly = true;
getTextField(5).setMinMaxDefault(1, 99999, 5); getTextField(5).setMinMaxDefault(1, Integer.MAX_VALUE, 5);
if(stats.pEffect != EnumPotionType.Fire) { if(stats.pEffect != EnumPotionType.Fire) {
addButton(new GuiNpcButton(10, guiLeft + 210, guiTop + 160, 40, 20, new String[]{"stats.regular", "stats.amplified"} ,stats.pEffAmp)); addButton(new GuiNpcButton(10, guiLeft + 210, guiTop + 160, 40, 20, new String[]{"stats.regular", "stats.amplified"} ,stats.pEffAmp));
} }
@@ -82,7 +81,7 @@ public class SubGuiNpcProjectiles extends SubGuiInterface implements ITextfieldL
public void unFocused(GuiNpcTextField textfield) { public void unFocused(GuiNpcTextField textfield) {
if(textfield.id == 1){ if(textfield.id == 1){
stats.pDamage = textfield.getInteger(); stats.pDamage = (float)(Math.floor(Float.parseFloat(textfield.getText())));
} }
else if(textfield.id == 2){ else if(textfield.id == 2){
stats.pImpact = textfield.getInteger(); stats.pImpact = textfield.getInteger();
@@ -29,36 +29,36 @@ public class SubGuiNpcRangeProperties extends SubGuiInterface implements ITextfi
int y = guiTop + 4; int y = guiTop + 4;
addTextField(new GuiNpcTextField(1,this, fontRendererObj, guiLeft + 85, y, 50, 18, stats.accuracy+"")); addTextField(new GuiNpcTextField(1,this, fontRendererObj, guiLeft + 85, y, 50, 18, stats.accuracy+""));
addLabel(new GuiNpcLabel(1,"stats.accuracy", guiLeft + 5, y + 5)); addLabel(new GuiNpcLabel(1,"stats.accuracy", guiLeft + 5, y + 5));
getTextField(1).numbersOnly = true; getTextField(1).integersOnly = true;
getTextField(1).setMinMaxDefault(0, 100, 90); getTextField(1).setMinMaxDefault(0, 100, 90);
addTextField(new GuiNpcTextField(2,this, fontRendererObj, guiLeft + 85, y += 22, 50, 18, stats.rangedRange+"")); addTextField(new GuiNpcTextField(2,this, fontRendererObj, guiLeft + 85, y += 22, 50, 18, stats.rangedRange+""));
addLabel(new GuiNpcLabel(2,"stats.rangedrange", guiLeft + 5, y + 5)); addLabel(new GuiNpcLabel(2,"stats.rangedrange", guiLeft + 5, y + 5));
getTextField(2).numbersOnly = true; getTextField(2).integersOnly = true;
getTextField(2).setMinMaxDefault(1, 64, 2); getTextField(2).setMinMaxDefault(1, Integer.MAX_VALUE, 2);
addTextField(new GuiNpcTextField(3,this, fontRendererObj, guiLeft + 85, y += 22, 50, 18, stats.minDelay+"")); addTextField(new GuiNpcTextField(3,this, fontRendererObj, guiLeft + 85, y += 22, 50, 18, stats.minDelay+""));
addLabel(new GuiNpcLabel(3,"stats.mindelay", guiLeft + 5, y + 5)); addLabel(new GuiNpcLabel(3,"stats.mindelay", guiLeft + 5, y + 5));
getTextField(3).numbersOnly = true; getTextField(3).integersOnly = true;
getTextField(3).setMinMaxDefault(1, 9999, 20); getTextField(3).setMinMaxDefault(1, Integer.MAX_VALUE, 20);
addTextField(new GuiNpcTextField(4,this, fontRendererObj, guiLeft + 85, y += 22, 50, 18, stats.maxDelay+"")); addTextField(new GuiNpcTextField(4,this, fontRendererObj, guiLeft + 85, y += 22, 50, 18, stats.maxDelay+""));
addLabel(new GuiNpcLabel(4,"stats.maxdelay", guiLeft + 5, y + 5)); addLabel(new GuiNpcLabel(4,"stats.maxdelay", guiLeft + 5, y + 5));
getTextField(4).numbersOnly = true; getTextField(4).integersOnly = true;
getTextField(4).setMinMaxDefault(1, 9999, 20); getTextField(4).setMinMaxDefault(1, Integer.MAX_VALUE, 20);
addTextField(new GuiNpcTextField(5, this, fontRendererObj, guiLeft + 85, y += 22, 50, 18, stats.fireRate + "")); addTextField(new GuiNpcTextField(5, this, fontRendererObj, guiLeft + 85, y += 22, 50, 18, stats.fireRate + ""));
addLabel(new GuiNpcLabel(5, "stats.burstspeed", guiLeft + 5, y + 5)); addLabel(new GuiNpcLabel(5, "stats.burstspeed", guiLeft + 5, y + 5));
getTextField(5).numbersOnly = true; getTextField(5).integersOnly = true;
getTextField(5).setMinMaxDefault(0, 30, 0); getTextField(5).setMinMaxDefault(0, Integer.MAX_VALUE, 0);
addTextField(new GuiNpcTextField(6, this, fontRendererObj, guiLeft + 85, y += 22, 50, 18, stats.burstCount + "")); addTextField(new GuiNpcTextField(6, this, fontRendererObj, guiLeft + 85, y += 22, 50, 18, stats.burstCount + ""));
addLabel(new GuiNpcLabel(6, "stats.burstcount", guiLeft + 5, y + 5)); addLabel(new GuiNpcLabel(6, "stats.burstcount", guiLeft + 5, y + 5));
getTextField(6).numbersOnly = true; getTextField(6).integersOnly = true;
getTextField(6).setMinMaxDefault(1, 100, 20); getTextField(6).setMinMaxDefault(1, Integer.MAX_VALUE, 20);
addTextField(new GuiNpcTextField(7,this, fontRendererObj, guiLeft + 85, y += 22, 100, 20, stats.fireSound)); addTextField(new GuiNpcTextField(7,this, fontRendererObj, guiLeft + 85, y += 22, 100, 20, stats.fireSound));
addLabel(new GuiNpcLabel(7, "stats.firesound:", guiLeft + 5, y + 5)); addLabel(new GuiNpcLabel(7, "stats.firesound:", guiLeft + 5, y + 5));
addButton(new GuiNpcButton(7, guiLeft + 187, y, 60, 20, "mco.template.button.select")); addButton(new GuiNpcButton(7, guiLeft + 187, y, 60, 20, "mco.template.button.select"));
addTextField(new GuiNpcTextField(8, this, fontRendererObj, guiLeft + 85, y += 22, 50, 18, stats.shotCount + "")); addTextField(new GuiNpcTextField(8, this, fontRendererObj, guiLeft + 85, y += 22, 50, 18, stats.shotCount + ""));
addLabel(new GuiNpcLabel(8, "stats.shotcount", guiLeft + 5, y + 5)); addLabel(new GuiNpcLabel(8, "stats.shotcount", guiLeft + 5, y + 5));
getTextField(8).numbersOnly = true; getTextField(8).integersOnly = true;
getTextField(8).setMinMaxDefault(1, 10, 1); getTextField(8).setMinMaxDefault(1, Integer.MAX_VALUE, 1);
addButton(new GuiNpcButtonYesNo(9, guiLeft + 100, y += 22, stats.aimWhileShooting)); addButton(new GuiNpcButtonYesNo(9, guiLeft + 100, y += 22, stats.aimWhileShooting));
addLabel(new GuiNpcLabel(9, "stats.aimWhileShooting", guiLeft + 5, y + 5)); addLabel(new GuiNpcLabel(9, "stats.aimWhileShooting", guiLeft + 5, y + 5));
@@ -35,7 +35,11 @@ public class SubGuiNpcResistanceProperties extends SubGuiInterface implements IS
addLabel(new GuiNpcLabel(3,"stats.explosion", guiLeft + 4, guiTop + 81)); addLabel(new GuiNpcLabel(3,"stats.explosion", guiLeft + 4, guiTop + 81));
addSlider(new GuiNpcSlider(this, 3, guiLeft + 94, guiTop + 76, (int)(resistances.explosion * 100 - 100) + "%", resistances.explosion / 2)); addSlider(new GuiNpcSlider(this, 3, guiLeft + 94, guiTop + 76, (int)(resistances.explosion * 100 - 100) + "%", resistances.explosion / 2));
addButton(new GuiNpcButton(66, guiLeft + 190, guiTop + 190, 60, 20, "gui.done")); if(resistances.disableDamage){
addLabel(new GuiNpcLabel(4,"stats.disabletrue", guiLeft + 4, guiTop + 103));
}
addButton(new GuiNpcButton(66, guiLeft + 190, guiTop + 190, 60, 20, "gui.done"));
} }
protected void actionPerformed(GuiButton guibutton) protected void actionPerformed(GuiButton guibutton)
@@ -27,7 +27,7 @@ public class SubGuiNpcRespawn extends SubGuiInterface implements ITextfieldListe
if(stats.respawnTime > 0){ if(stats.respawnTime > 0){
addLabel(new GuiNpcLabel(3,"gui.time", guiLeft + 5, guiTop + 57)); addLabel(new GuiNpcLabel(3,"gui.time", guiLeft + 5, guiTop + 57));
addTextField(new GuiNpcTextField(2,this, fontRendererObj, guiLeft + 122, guiTop + 53, 50, 18, stats.respawnTime + "")); addTextField(new GuiNpcTextField(2,this, fontRendererObj, guiLeft + 122, guiTop + 53, 50, 18, stats.respawnTime + ""));
getTextField(2).numbersOnly = true; getTextField(2).integersOnly = true;
getTextField(2).setMinMaxDefault(1, Integer.MAX_VALUE, 20); getTextField(2).setMinMaxDefault(1, Integer.MAX_VALUE, 20);
addLabel(new GuiNpcLabel(4,"stats.deadbody", guiLeft + 4, guiTop + 79)); addLabel(new GuiNpcLabel(4,"stats.deadbody", guiLeft + 4, guiTop + 79));
@@ -0,0 +1,910 @@
package noppes.npcs.client.gui.custom;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.GuiTextField;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.nbt.NBTTagString;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
import net.minecraft.util.ResourceLocation;
import noppes.npcs.client.Client;
import noppes.npcs.client.gui.custom.components.*;
import noppes.npcs.client.gui.custom.interfaces.IClickListener;
import noppes.npcs.client.gui.custom.interfaces.IDataHolder;
import noppes.npcs.client.gui.custom.interfaces.IGuiComponent;
import noppes.npcs.client.gui.util.GuiCustomScroll;
import noppes.npcs.client.gui.util.ICustomScrollListener;
import noppes.npcs.client.gui.util.IGuiData;
import noppes.npcs.constants.EnumPacketServer;
import noppes.npcs.containers.ContainerCustomGui;
import noppes.npcs.scripted.gui.*;
import noppes.npcs.scripted.interfaces.ICustomGuiComponent;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import java.util.*;
public class GuiCustom extends GuiScreen implements ICustomScrollListener, IGuiData {
ScriptGui gui;
int xSize;
int ySize;
public static int guiLeft;
public static int guiTop;
ResourceLocation background;
public String[] hoverText;
Map<Integer, IGuiComponent> components = new HashMap();
List<IClickListener> clickListeners = new ArrayList();
List<CustomGuiTextField> keyListeners = new ArrayList();
List<IDataHolder> dataHolders = new ArrayList();
public Container inventorySlots;
private Slot theSlot;
private Slot clickedSlot;
private boolean isRightMouseClick;
private ItemStack draggedStack;
private int field_147011_y;
private int field_147010_z;
private Slot returningStackDestSlot;
private long returningStackTime;
private ItemStack returningStack;
private Slot field_146985_D;
private long field_146986_E;
protected final Set field_147008_s = new HashSet();
protected boolean field_147007_t;
private int field_146987_F;
private int field_146988_G;
private boolean field_146995_H;
private int field_146996_I;
private long field_146997_J;
private Slot field_146998_K;
private int field_146992_L;
private boolean field_146993_M;
private ItemStack field_146994_N;
public GuiCustom(ContainerCustomGui container) {
this.inventorySlots = container;
this.field_146995_H = true;
this.allowUserInput = true;
}
public void initGui() {
super.initGui();
this.mc.thePlayer.openContainer = this.inventorySlots;
if (this.gui != null) {
guiLeft = (this.width - this.xSize)/2;
guiTop = (this.height - this.ySize)/2;
this.components.clear();
this.clickListeners.clear();
this.keyListeners.clear();
this.dataHolders.clear();
Iterator var1 = this.gui.getComponents().iterator();
while(var1.hasNext()) {
ICustomGuiComponent c = (ICustomGuiComponent)var1.next();
this.addComponent(c);
}
}
}
public void updateScreen() {
super.updateScreen();
Iterator var1 = this.dataHolders.iterator();
while(var1.hasNext()) {
IDataHolder component = (IDataHolder)var1.next();
if (component instanceof GuiTextField) {
((GuiTextField)component).updateCursorCounter();
}
}
if (!this.mc.thePlayer.isEntityAlive() || this.mc.thePlayer.isDead)
{
this.mc.thePlayer.closeScreen();
}
}
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
this.hoverText = null;
//this.drawDefaultBackground();
if (this.background != null) {
this.drawBackgroundTexture();
}
Iterator var4 = this.components.values().iterator();
while(var4.hasNext()) {
GL11.glEnable(GL11.GL_BLEND);
OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0);
GL11.glDisable(GL11.GL_ALPHA_TEST);
IGuiComponent component = (IGuiComponent)var4.next();
component.onRender(this.mc, mouseX, mouseY, Mouse.getDWheel(), partialTicks);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_ALPHA_TEST);
}
if (this.hoverText != null) {
this.func_146283_a(Arrays.asList(this.hoverText), mouseX, mouseY);
}
drawScreenSuper(mouseX, mouseY, partialTicks);
}
public void drawScreenSuper(int mouseX, int mouseY, float partialTicks)
{
//this.drawDefaultBackground();
int k = this.guiLeft;
int l = this.guiTop;
//this.drawGuiContainerBackgroundLayer(partialTicks, mouseX, mouseY);
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
RenderHelper.disableStandardItemLighting();
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_DEPTH_TEST);
super.drawScreen(mouseX, mouseY, partialTicks);
RenderHelper.enableGUIStandardItemLighting();
GL11.glPushMatrix();
GL11.glTranslatef((float)k, (float)l, 0.0F);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
this.theSlot = null;
short short1 = 240;
short short2 = 240;
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)short1 / 1.0F, (float)short2 / 1.0F);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
int k1;
for (int i1 = 0; i1 < this.inventorySlots.inventorySlots.size(); ++i1)
{
Slot slot = (Slot)this.inventorySlots.inventorySlots.get(i1);
this.drawSlot(slot);
if (this.isMouseOverSlot(slot, mouseX, mouseY) && slot.func_111238_b())
{
this.theSlot = slot;
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_DEPTH_TEST);
int j1 = slot.xDisplayPosition;
k1 = slot.yDisplayPosition;
GL11.glColorMask(true, true, true, false);
this.drawGradientRect(j1, k1, j1 + 16, k1 + 16, -2130706433, -2130706433);
GL11.glColorMask(true, true, true, true);
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_DEPTH_TEST);
}
}
//Forge: Force lighting to be disabled as there are some issue where lighting would
//incorrectly be applied based on items that are in the inventory.
GL11.glDisable(GL11.GL_LIGHTING);
//this.drawGuiContainerForegroundLayer(mouseX, mouseY);
GL11.glEnable(GL11.GL_LIGHTING);
InventoryPlayer inventoryplayer = this.mc.thePlayer.inventory;
ItemStack itemstack = this.draggedStack == null ? inventoryplayer.getItemStack() : this.draggedStack;
if (itemstack != null)
{
byte b0 = 8;
k1 = this.draggedStack == null ? 8 : 16;
String s = null;
if (this.draggedStack != null && this.isRightMouseClick)
{
itemstack = itemstack.copy();
itemstack.stackSize = MathHelper.ceiling_float_int((float)itemstack.stackSize / 2.0F);
}
else if (this.field_147007_t && this.field_147008_s.size() > 1)
{
itemstack = itemstack.copy();
itemstack.stackSize = this.field_146996_I;
if (itemstack.stackSize == 0)
{
s = "" + EnumChatFormatting.YELLOW + "0";
}
}
this.drawItemStack(itemstack, mouseX - k - b0, mouseY - l - k1, s);
}
if (this.returningStack != null)
{
float f1 = (float)(Minecraft.getSystemTime() - this.returningStackTime) / 100.0F;
if (f1 >= 1.0F)
{
f1 = 1.0F;
this.returningStack = null;
}
k1 = this.returningStackDestSlot.xDisplayPosition - this.field_147011_y;
int j2 = this.returningStackDestSlot.yDisplayPosition - this.field_147010_z;
int l1 = this.field_147011_y + (int)((float)k1 * f1);
int i2 = this.field_147010_z + (int)((float)j2 * f1);
this.drawItemStack(this.returningStack, l1, i2, (String)null);
}
GL11.glPopMatrix();
if (inventoryplayer.getItemStack() == null && this.theSlot != null && this.theSlot.getHasStack())
{
ItemStack itemstack1 = this.theSlot.getStack();
this.renderToolTip(itemstack1, mouseX, mouseY);
}
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_DEPTH_TEST);
RenderHelper.enableStandardItemLighting();
}
private void drawItemStack(ItemStack p_146982_1_, int p_146982_2_, int p_146982_3_, String p_146982_4_)
{
GL11.glTranslatef(0.0F, 0.0F, 32.0F);
this.zLevel = 200.0F;
itemRender.zLevel = 200.0F;
FontRenderer font = null;
if (p_146982_1_ != null) font = p_146982_1_.getItem().getFontRenderer(p_146982_1_);
if (font == null) font = fontRendererObj;
itemRender.renderItemAndEffectIntoGUI(font, this.mc.getTextureManager(), p_146982_1_, p_146982_2_, p_146982_3_);
itemRender.renderItemOverlayIntoGUI(font, this.mc.getTextureManager(), p_146982_1_, p_146982_2_, p_146982_3_ - (this.draggedStack == null ? 0 : 8), p_146982_4_);
this.zLevel = 0.0F;
itemRender.zLevel = 0.0F;
}
private boolean isMouseOverSlot(Slot slot, int posX, int posY)
{
return this.isPointInRegion(slot.xDisplayPosition, slot.yDisplayPosition, 16, 16, posX, posY);
}
protected boolean isPointInRegion(int slotDisplayX, int slotDisplayY, int slotSizeX, int slotSizeY, int posX, int posY)
{
int k1 = this.guiLeft;
int l1 = this.guiTop;
posX -= k1;
posY -= l1;
return posX >= slotDisplayX - 1 && posX < slotDisplayX + slotSizeX + 1 && posY >= slotDisplayY - 1 && posY < slotDisplayY + slotSizeY + 1;
}
private void drawSlot(Slot p_146977_1_)
{
int i = p_146977_1_.xDisplayPosition;
int j = p_146977_1_.yDisplayPosition;
ItemStack itemstack = p_146977_1_.getStack();
boolean flag = false;
boolean flag1 = p_146977_1_ == this.clickedSlot && this.draggedStack != null && !this.isRightMouseClick;
ItemStack itemstack1 = this.mc.thePlayer.inventory.getItemStack();
String s = null;
if (p_146977_1_ == this.clickedSlot && this.draggedStack != null && this.isRightMouseClick && itemstack != null)
{
itemstack = itemstack.copy();
itemstack.stackSize /= 2;
}
else if (this.field_147007_t && this.field_147008_s.contains(p_146977_1_) && itemstack1 != null)
{
if (this.field_147008_s.size() == 1)
{
return;
}
if (Container.func_94527_a(p_146977_1_, itemstack1, true) && this.inventorySlots.canDragIntoSlot(p_146977_1_))
{
itemstack = itemstack1.copy();
flag = true;
Container.func_94525_a(this.field_147008_s, this.field_146987_F, itemstack, p_146977_1_.getStack() == null ? 0 : p_146977_1_.getStack().stackSize);
if (itemstack.stackSize > itemstack.getMaxStackSize())
{
s = EnumChatFormatting.YELLOW + "" + itemstack.getMaxStackSize();
itemstack.stackSize = itemstack.getMaxStackSize();
}
if (itemstack.stackSize > p_146977_1_.getSlotStackLimit())
{
s = EnumChatFormatting.YELLOW + "" + p_146977_1_.getSlotStackLimit();
itemstack.stackSize = p_146977_1_.getSlotStackLimit();
}
}
else
{
this.field_147008_s.remove(p_146977_1_);
this.func_146980_g();
}
}
this.zLevel = 100.0F;
itemRender.zLevel = 100.0F;
if (itemstack == null)
{
IIcon iicon = p_146977_1_.getBackgroundIconIndex();
if (iicon != null)
{
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_BLEND); // Forge: Blending needs to be enabled for this.
this.mc.getTextureManager().bindTexture(TextureMap.locationItemsTexture);
this.drawTexturedModelRectFromIcon(i, j, iicon, 16, 16);
GL11.glDisable(GL11.GL_BLEND); // Forge: And clean that up
GL11.glEnable(GL11.GL_LIGHTING);
flag1 = true;
}
}
if (!flag1)
{
if (flag)
{
drawRect(i, j, i + 16, j + 16, -2130706433);
}
GL11.glEnable(GL11.GL_DEPTH_TEST);
itemRender.renderItemAndEffectIntoGUI(this.fontRendererObj, this.mc.getTextureManager(), itemstack, i, j);
itemRender.renderItemOverlayIntoGUI(this.fontRendererObj, this.mc.getTextureManager(), itemstack, i, j, s);
}
itemRender.zLevel = 0.0F;
this.zLevel = 0.0F;
}
private void func_146980_g()
{
ItemStack itemstack = this.mc.thePlayer.inventory.getItemStack();
if (itemstack != null && this.field_147007_t)
{
this.field_146996_I = itemstack.stackSize;
ItemStack itemstack1;
int i;
for (Iterator iterator = this.field_147008_s.iterator(); iterator.hasNext(); this.field_146996_I -= itemstack1.stackSize - i)
{
Slot slot = (Slot)iterator.next();
itemstack1 = itemstack.copy();
i = slot.getStack() == null ? 0 : slot.getStack().stackSize;
Container.func_94525_a(this.field_147008_s, this.field_146987_F, itemstack1, i);
if (itemstack1.stackSize > itemstack1.getMaxStackSize())
{
itemstack1.stackSize = itemstack1.getMaxStackSize();
}
if (itemstack1.stackSize > slot.getSlotStackLimit())
{
itemstack1.stackSize = slot.getSlotStackLimit();
}
}
}
}
protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {
}
void drawBackgroundTexture() {
this.mc.getTextureManager().bindTexture(this.background);
this.drawTexturedModalRect(guiLeft, guiTop, 0, 0, this.xSize, this.ySize);
}
private void addComponent(ICustomGuiComponent component) {
ScriptGuiComponent c = (ScriptGuiComponent)component;
switch(c.getType()) {
case 0:
CustomGuiButton button = CustomGuiButton.fromComponent((ScriptGuiButton)component);
button.setParent(this);
this.components.put(button.getID(), button);
this.addClickListener(button);
break;
case 1:
CustomGuiLabel lbl = CustomGuiLabel.fromComponent((ScriptGuiLabel)component);
lbl.setParent(this);
this.components.put(lbl.getID(), lbl);
break;
case 2:
CustomGuiTexturedRect rect = CustomGuiTexturedRect.fromComponent((ScriptGuiTexturedRect)component);
rect.setParent(this);
this.components.put(rect.getID(), rect);
break;
case 3:
CustomGuiTextField textField = CustomGuiTextField.fromComponent((ScriptGuiTextField)component);
textField.setParent(this);
this.components.put(textField.getID(), textField);
this.addDataHolder(textField);
this.addClickListener(textField);
this.addKeyListener(textField);
break;
case 4:
CustomGuiScrollComponent scroll = new CustomGuiScrollComponent(this.mc, this, component.getID(), ((ScriptGuiScroll)component).isMultiSelect());
scroll.fromComponent((ScriptGuiScroll)component);
scroll.setParent(this);
this.components.put(scroll.getID(), scroll);
this.addDataHolder(scroll);
this.addClickListener(scroll);
break;
case 6:
CustomGuiLine line = CustomGuiLine.fromComponent((ScriptGuiLine) component);
this.components.put(line.getID(),line);
break;
}
}
protected void actionPerformed(GuiButton button) {
super.actionPerformed(button);
Client.sendData(EnumPacketServer.CustomGuiButton, new Object[]{this.updateGui().toNBT(), button.id});
}
public void buttonClick(CustomGuiButton button) {
Client.sendData(EnumPacketServer.CustomGuiButton, new Object[]{this.updateGui().toNBT(), button.id});
}
public void slotChange(CustomGuiSlot slot) {
Client.sendData(EnumPacketServer.CustomGuiSlotChange, new Object[]{this.updateGui().toNBT(), slot.slotNumber});
}
public String prevScrollClicked = null;
public void customScrollClicked(int i, int j, int k, GuiCustomScroll scroll) {
Client.sendData(EnumPacketServer.CustomGuiScrollClick, new Object[]{this.updateGui().toNBT(), scroll.id, scroll.selected, this.getScrollSelection((CustomGuiScrollComponent)scroll), false});
if(Integer.toString(scroll.selected).equals(prevScrollClicked)){
Client.sendData(EnumPacketServer.CustomGuiScrollClick, new Object[]{this.updateGui().toNBT(), scroll.id, scroll.selected, this.getScrollSelection((CustomGuiScrollComponent)scroll), true});
}
prevScrollClicked = Integer.toString(scroll.selected);
}
public void onGuiClosed() {
if (this.gui != null) {
Client.sendData(EnumPacketServer.CustomGuiClose, new Object[]{this.updateGui().toNBT()});
}
if (this.mc.thePlayer != null)
{
this.inventorySlots.onContainerClosed(this.mc.thePlayer);
}
}
public void onTextFieldUnfocused(CustomGuiTextField textField){
Client.sendData(EnumPacketServer.CustomGuiUnfocused, new Object[]{this.updateGui().toNBT(), textField.getID()});
}
ScriptGui updateGui() {
Iterator var1 = this.dataHolders.iterator();
while(var1.hasNext()) {
IDataHolder component = (IDataHolder)var1.next();
this.gui.updateComponent(component.toComponent());
}
return this.gui;
}
NBTTagCompound getScrollSelection(CustomGuiScrollComponent scroll) {
NBTTagList list = new NBTTagList();
if (scroll.multiSelect) {
Iterator var3 = scroll.getSelectedList().iterator();
while(var3.hasNext()) {
String s = (String)var3.next();
list.appendTag(new NBTTagString(s));
}
} else {
list.appendTag(new NBTTagString(scroll.getSelected()));
}
NBTTagCompound selection = new NBTTagCompound();
selection.setTag("selection", list);
return selection;
}
protected void keyTyped(char typedChar, int keyCode) {
if (keyCode == 1)
{
this.mc.thePlayer.closeScreen();
}
this.checkHotbarKeys(keyCode);
if (this.theSlot != null && this.theSlot.getHasStack())
{
if (keyCode == this.mc.gameSettings.keyBindPickBlock.getKeyCode())
{
this.handleMouseClick(this.theSlot, this.theSlot.slotNumber, 0, 3);
}
else if (keyCode == this.mc.gameSettings.keyBindDrop.getKeyCode())
{
this.handleMouseClick(this.theSlot, this.theSlot.slotNumber, isCtrlKeyDown() ? 1 : 0, 4);
}
}
Iterator var3 = this.keyListeners.iterator();
while(var3.hasNext()) {
CustomGuiTextField listener = (CustomGuiTextField) var3.next();
listener.keyTyped(typedChar, keyCode);
}
if (this.mc.gameSettings.keyBindInventory.getKeyCode() != keyCode && !this.mc.gameSettings.keyBindInventory.getIsKeyPressed()) {
super.keyTyped(typedChar, keyCode);
}
}
public void mouseClicked(int mouseX, int mouseY, int mouseButton) {
super.mouseClicked(mouseX, mouseY, mouseButton);
boolean flag = mouseButton == this.mc.gameSettings.keyBindPickBlock.getKeyCode() + 100;
Slot slot = this.getSlotAtPosition(mouseX, mouseY);
long l = Minecraft.getSystemTime();
this.field_146993_M = this.field_146998_K == slot && l - this.field_146997_J < 250L && this.field_146992_L == mouseButton;
this.field_146995_H = false;
if (mouseButton == 0 || mouseButton == 1 || flag) {
boolean flag1 = true;
int k1 = -1;
for (int i = 0; i < this.inventorySlots.inventorySlots.size(); ++i)
{
Slot invSlot = (Slot)this.inventorySlots.inventorySlots.get(i);
if (invSlot.equals(slot))
{
flag1 = false;
}
}
if (slot != null) {
k1 = slot.slotNumber;
}
if (flag1) {
k1 = -999;
}
if (this.mc.gameSettings.touchscreen && flag1 && this.mc.thePlayer.inventory.getItemStack() == null) {
this.mc.displayGuiScreen((GuiScreen) null);
return;
}
if (k1 != -1) {
if (this.mc.gameSettings.touchscreen) {
if (slot != null && slot.getHasStack()) {
this.clickedSlot = slot;
this.draggedStack = null;
this.isRightMouseClick = mouseButton == 1;
} else {
this.clickedSlot = null;
}
} else if (!this.field_147007_t) {
if (this.mc.thePlayer.inventory.getItemStack() == null) {
if (mouseButton == this.mc.gameSettings.keyBindPickBlock.getKeyCode() + 100) {
this.handleMouseClick(slot, k1, mouseButton, 3);
} else {
boolean flag2 = k1 != -999 && (Keyboard.isKeyDown(42) || Keyboard.isKeyDown(54));
byte b0 = 0;
if (flag2) {
this.field_146994_N = slot != null && slot.getHasStack() ? slot.getStack() : null;
b0 = 1;
} else if (k1 == -999) {
b0 = 4;
}
this.handleMouseClick(slot, k1, mouseButton, b0);
}
this.field_146995_H = true;
} else {
this.field_147007_t = true;
this.field_146988_G = mouseButton;
this.field_147008_s.clear();
if (mouseButton == 0) {
this.field_146987_F = 0;
} else if (mouseButton == 1) {
this.field_146987_F = 1;
}
}
}
}
}
this.field_146998_K = slot;
this.field_146997_J = l;
this.field_146992_L = mouseButton;
Iterator var4 = this.clickListeners.iterator();
while(var4.hasNext()) {
IClickListener listener = (IClickListener)var4.next();
listener.mouseClicked(this, mouseX, mouseY, mouseButton);
}
}
public boolean doesGuiPauseGame() {
return this.gui == null || this.gui.getDoesPauseGame();
}
public void addDataHolder(IDataHolder component) {
this.dataHolders.add(component);
}
public void addKeyListener(CustomGuiTextField component) {
this.keyListeners.add(component);
}
public void addClickListener(IClickListener component) {
this.clickListeners.add(component);
}
public void setGuiData(NBTTagCompound compound) {
Minecraft mc = Minecraft.getMinecraft();
ScriptGui gui = (ScriptGui)(new ScriptGui()).fromNBT(compound);
((ContainerCustomGui)this.inventorySlots).setGui(gui, mc.thePlayer);
this.gui = gui;
this.xSize = gui.getWidth();
this.ySize = gui.getHeight();
if (!gui.getBackgroundTexture().isEmpty()) {
this.background = new ResourceLocation(gui.getBackgroundTexture());
}
this.initGui();
}
/**
* This function is what controls the hotbar shortcut check when you press a number key when hovering a stack.
*/
protected boolean checkHotbarKeys(int p_146983_1_)
{
if (this.mc.thePlayer.inventory.getItemStack() == null && this.theSlot != null)
{
for (int j = 0; j < 9; ++j)
{
if (p_146983_1_ == this.mc.gameSettings.keyBindsHotbar[j].getKeyCode())
{
this.handleMouseClick(this.theSlot, this.theSlot.slotNumber, j, 2);
return true;
}
}
}
return false;
}
protected void handleMouseClick(Slot slot, int index, int p_146984_3_, int p_146984_4_)
{
if (slot != null)
{
index = slot.slotNumber;
}
this.mc.playerController.windowClick(this.inventorySlots.windowId, index, p_146984_3_, p_146984_4_, this.mc.thePlayer);
}
protected void mouseMovedOrUp(int p_146286_1_, int p_146286_2_, int p_146286_3_)
{
super.mouseMovedOrUp(p_146286_1_, p_146286_2_, p_146286_3_); //Forge, Call parent to release buttons
Slot slot = this.getSlotAtPosition(p_146286_1_, p_146286_2_);
int l = this.guiLeft;
int i1 = this.guiTop;
boolean flag = p_146286_1_ < l || p_146286_2_ < i1 || p_146286_1_ >= l + this.xSize || p_146286_2_ >= i1 + this.ySize;
int j1 = -1;
if (slot != null)
{
j1 = slot.slotNumber;
}
if (flag)
{
j1 = -999;
}
Slot slot1;
Iterator iterator;
if (this.field_146993_M && slot != null && p_146286_3_ == 0 && this.inventorySlots.func_94530_a((ItemStack)null, slot))
{
if (isShiftKeyDown())
{
if (slot != null && slot.inventory != null && this.field_146994_N != null)
{
iterator = this.inventorySlots.inventorySlots.iterator();
while (iterator.hasNext())
{
slot1 = (Slot)iterator.next();
if (slot1 != null && slot1.canTakeStack(this.mc.thePlayer) && slot1.getHasStack() && slot1.inventory == slot.inventory && Container.func_94527_a(slot1, this.field_146994_N, true))
{
this.handleMouseClick(slot1, slot1.slotNumber, p_146286_3_, 1);
}
}
}
}
else
{
this.handleMouseClick(slot, j1, p_146286_3_, 6);
}
this.field_146993_M = false;
this.field_146997_J = 0L;
}
else
{
if (this.field_147007_t && this.field_146988_G != p_146286_3_)
{
this.field_147007_t = false;
this.field_147008_s.clear();
this.field_146995_H = true;
return;
}
if (this.field_146995_H)
{
this.field_146995_H = false;
return;
}
boolean flag1;
if (this.clickedSlot != null && this.mc.gameSettings.touchscreen)
{
if (p_146286_3_ == 0 || p_146286_3_ == 1)
{
if (this.draggedStack == null && slot != this.clickedSlot)
{
this.draggedStack = this.clickedSlot.getStack();
}
flag1 = Container.func_94527_a(slot, this.draggedStack, false);
if (j1 != -1 && this.draggedStack != null && flag1)
{
this.handleMouseClick(this.clickedSlot, this.clickedSlot.slotNumber, p_146286_3_, 0);
this.handleMouseClick(slot, j1, 0, 0);
if (this.mc.thePlayer.inventory.getItemStack() != null)
{
this.handleMouseClick(this.clickedSlot, this.clickedSlot.slotNumber, p_146286_3_, 0);
this.field_147011_y = p_146286_1_ - l;
this.field_147010_z = p_146286_2_ - i1;
this.returningStackDestSlot = this.clickedSlot;
this.returningStack = this.draggedStack;
this.returningStackTime = Minecraft.getSystemTime();
}
else
{
this.returningStack = null;
}
}
else if (this.draggedStack != null)
{
this.field_147011_y = p_146286_1_ - l;
this.field_147010_z = p_146286_2_ - i1;
this.returningStackDestSlot = this.clickedSlot;
this.returningStack = this.draggedStack;
this.returningStackTime = Minecraft.getSystemTime();
}
this.draggedStack = null;
this.clickedSlot = null;
}
}
else if (this.field_147007_t && !this.field_147008_s.isEmpty())
{
this.handleMouseClick((Slot)null, -999, Container.func_94534_d(0, this.field_146987_F), 5);
iterator = this.field_147008_s.iterator();
while (iterator.hasNext())
{
slot1 = (Slot)iterator.next();
this.handleMouseClick(slot1, slot1.slotNumber, Container.func_94534_d(1, this.field_146987_F), 5);
}
this.handleMouseClick((Slot)null, -999, Container.func_94534_d(2, this.field_146987_F), 5);
}
else if (this.mc.thePlayer.inventory.getItemStack() != null)
{
if (p_146286_3_ == this.mc.gameSettings.keyBindPickBlock.getKeyCode() + 100)
{
this.handleMouseClick(slot, j1, p_146286_3_, 3);
}
else
{
flag1 = j1 != -999 && (Keyboard.isKeyDown(42) || Keyboard.isKeyDown(54));
if (flag1)
{
this.field_146994_N = slot != null && slot.getHasStack() ? slot.getStack() : null;
}
this.handleMouseClick(slot, j1, p_146286_3_, flag1 ? 1 : 0);
}
}
}
if (this.mc.thePlayer.inventory.getItemStack() == null)
{
this.field_146997_J = 0L;
}
this.field_147007_t = false;
}
private Slot getSlotAtPosition(int posX, int posY)
{
for (int k = 0; k < this.inventorySlots.inventorySlots.size(); ++k)
{
Slot slot = (Slot)this.inventorySlots.inventorySlots.get(k);
if (this.isMouseOverSlot(slot, posX, posY))
{
return slot;
}
}
return null;
}
protected void mouseClickMove(int p_146273_1_, int p_146273_2_, int p_146273_3_, long p_146273_4_)
{
Slot slot = this.getSlotAtPosition(p_146273_1_, p_146273_2_);
ItemStack itemstack = this.mc.thePlayer.inventory.getItemStack();
if (this.clickedSlot != null && this.mc.gameSettings.touchscreen)
{
if (p_146273_3_ == 0 || p_146273_3_ == 1)
{
if (this.draggedStack == null)
{
if (slot != this.clickedSlot)
{
this.draggedStack = this.clickedSlot.getStack().copy();
}
}
else if (this.draggedStack.stackSize > 1 && slot != null && Container.func_94527_a(slot, this.draggedStack, false))
{
long i1 = Minecraft.getSystemTime();
if (this.field_146985_D == slot)
{
if (i1 - this.field_146986_E > 500L)
{
this.handleMouseClick(this.clickedSlot, this.clickedSlot.slotNumber, 0, 0);
this.handleMouseClick(slot, slot.slotNumber, 1, 0);
this.handleMouseClick(this.clickedSlot, this.clickedSlot.slotNumber, 0, 0);
this.field_146986_E = i1 + 750L;
--this.draggedStack.stackSize;
}
}
else
{
this.field_146985_D = slot;
this.field_146986_E = i1;
}
}
}
}
else if (this.field_147007_t && slot != null && itemstack != null && itemstack.stackSize > this.field_147008_s.size() && Container.func_94527_a(slot, itemstack, true) && slot.isItemValid(itemstack) && this.inventorySlots.canDragIntoSlot(slot))
{
this.field_147008_s.add(slot);
this.func_146980_g();
}
}
}
@@ -0,0 +1,168 @@
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
package noppes.npcs.client.gui.custom.components;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.renderer.texture.ITextureObject;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.client.resources.SkinManager;
import net.minecraft.util.ResourceLocation;
import noppes.npcs.client.ImageDownloadAlt;
import noppes.npcs.client.gui.custom.GuiCustom;
import noppes.npcs.client.gui.custom.interfaces.IClickListener;
import noppes.npcs.client.renderer.ImageBufferDownloadAlt;
import noppes.npcs.scripted.gui.ScriptGuiButton;
import noppes.npcs.scripted.interfaces.ICustomGuiComponent;
import org.lwjgl.opengl.GL11;
public class CustomGuiButton extends GuiButton implements IClickListener {
GuiCustom parent;
ResourceLocation texture;
public int textureX;
public int textureY;
boolean field_146123_n;
String label;
String[] hoverText;
int color;
float alpha;
public CustomGuiButton(int id, String buttonText, int x, int y) {
super(id, GuiCustom.guiLeft + x, GuiCustom.guiTop + y, buttonText);
}
public CustomGuiButton(int id, String buttonText, int x, int y, int width, int height) {
super(id, GuiCustom.guiLeft + x, GuiCustom.guiTop + y, width, height, buttonText);
}
public CustomGuiButton(int buttonId, String buttonText, int x, int y, int width, int height, String texture) {
this(buttonId, buttonText, x, y, width, height, texture, 0, 0);
}
public CustomGuiButton(int buttonId, String buttonText, int x, int y, int width, int height, String texture, int textureX, int textureY) {
this(buttonId, buttonText, x, y, width, height);
this.textureX = textureX;
this.textureY = textureY;
this.label = buttonText;
this.texture = new ResourceLocation(texture);
if(texture.startsWith("https://")){
TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager();
ITextureObject object = new ImageDownloadAlt(null, texture, SkinManager.field_152793_a, new ImageBufferDownloadAlt(false));
texturemanager.loadTexture(this.texture, object);
}
}
public void setParent(GuiCustom parent) {
this.parent = parent;
}
public static CustomGuiButton fromComponent(ScriptGuiButton component) {
CustomGuiButton btn;
if (component.hasTexture()) {
if (component.getTextureX() >= 0 && component.getTextureY() >= 0) {
btn = new CustomGuiButton(component.getID(), component.getLabel(), component.getPosX(), component.getPosY(), component.getWidth(), component.getHeight(), component.getTexture(), component.getTextureX(), component.getTextureY());
} else {
btn = new CustomGuiButton(component.getID(), component.getLabel(), component.getPosX(), component.getPosY(), component.getWidth(), component.getHeight(), component.getTexture());
}
} else if (component.getWidth() >= 0 && component.getHeight() >= 0) {
btn = new CustomGuiButton(component.getID(), component.getLabel(), component.getPosX(), component.getPosY(), component.getWidth(), component.getHeight());
} else {
btn = new CustomGuiButton(component.getID(), component.getLabel(), component.getPosX(), component.getPosY());
}
btn.color = component.getColor();
btn.alpha = component.getAlpha();
if (component.hasHoverText()) {
btn.hoverText = component.getHoverText();
}
return btn;
}
public int getID() {
return this.id;
}
public void onRender(Minecraft mc, int mouseX, int mouseY, int mouseWheel, float partialTicks) {
//GL11.func_179094_E();
//GL11.func_179109_b(0.0F, 0.0F, (float)this.id);
GL11.glPushMatrix();
float red = (color >> 16 & 255) / 255f;
float green = (color >> 8 & 255) / 255f;
float blue = (color & 255) / 255f;
GL11.glColor4f(red,green,blue,this.alpha);
GL11.glTranslatef(0.0F, 0.0F, (float)this.id);
FontRenderer fontRenderer = mc.fontRenderer;
int i;
if (this.texture == null) {
mc.getTextureManager().bindTexture(buttonTextures);
this.field_146123_n = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height;
i = this.getHoverState(this.field_146123_n);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
//GL11.func_187428_a(SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA, SourceFactor.ONE, DestFactor.ZERO);
//GL11.func_187401_a(SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA);
this.drawTexturedModalRect(this.xPosition, this.yPosition, 0, 46 + i * 20, this.width / 2, this.height);
this.drawTexturedModalRect(this.xPosition + this.width / 2, this.yPosition, 200 - this.width / 2, 46 + i * 20, this.width / 2, this.height);
this.mouseDragged(mc, mouseX, mouseY);
int j = 14737632;
if (this.packedFGColour != 0) {
j = this.packedFGColour;
} else if (!this.enabled) {
j = 10526880;
} else if (this.field_146123_n) {
j = 16777120;
}
GL11.glTranslated(0.0D, 0.0D, 0.1D);
this.drawCenteredString(fontRenderer, this.displayString, this.xPosition + this.width / 2, this.yPosition + (this.height - 8) / 2, j);
} else {
mc.getTextureManager().bindTexture(this.texture);
this.field_146123_n = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height;
i = this.hoverState(this.field_146123_n);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
//GL11.func_187428_a(SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA, SourceFactor.ONE, DestFactor.ZERO);
//GL11.func_187401_a(SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA);
this.drawTexturedModalRect(this.xPosition, this.yPosition, this.textureX, this.textureY + i * this.height, this.width, this.height);
this.drawCenteredString(fontRenderer, this.label, this.xPosition + this.width / 2, this.yPosition + (this.height - 8) / 2, this.color);
if (this.field_146123_n && this.hoverText != null && this.hoverText.length > 0) {
this.parent.hoverText = this.hoverText;
}
}
GL11.glPopMatrix();
}
public ICustomGuiComponent toComponent() {
ScriptGuiButton component = new ScriptGuiButton(this.id, this.label, this.xPosition, this.yPosition, this.width, this.height, this.texture.toString(), this.textureX, this.textureY);
component.setHoverText(this.hoverText);
component.setColor(this.color);
component.setAlpha(this.alpha);
return component;
}
protected int hoverState(boolean mouseOver) {
int i = 0;
if (mouseOver) {
i = 1;
}
return i;
}
public boolean mouseClicked(GuiCustom gui, int mouseX, int mouseY, int mouseButton) {
if (mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height) {
//Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.func_147673_a(SoundEvents.field_187909_gi, 1.0F));
gui.buttonClick(this);
return true;
} else {
return false;
}
}
}
@@ -0,0 +1,570 @@
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
package noppes.npcs.client.gui.custom.components;
import com.ibm.icu.text.ArabicShaping;
import com.ibm.icu.text.ArabicShapingException;
import com.ibm.icu.text.Bidi;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.GuiLabel;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.util.ResourceLocation;
import noppes.npcs.client.gui.custom.GuiCustom;
import noppes.npcs.client.gui.custom.interfaces.IGuiComponent;
import noppes.npcs.scripted.gui.ScriptGuiLabel;
import noppes.npcs.scripted.interfaces.ICustomGuiComponent;
import org.lwjgl.opengl.GL11;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
public class CustomGuiLabel extends Gui implements IGuiComponent {
int x, y, width, height;
GuiCustom parent;
String fullLabel;
String[] hoverText;
float scale;
int id;
int border = 2;
boolean labelBgEnabled = true;
boolean labelShadowEnabled = false;
int color;
float alpha;
float rotation;
protected int field_146167_a;
protected int field_146161_f;
public int field_146162_g;
public int field_146174_h;
private boolean randomStyle = false;
private boolean boldStyle = false;
private boolean italicStyle = false;
private boolean underlineStyle = false;
private boolean strikethroughStyle = false;
private boolean bidiFlag = false;
private boolean unicodeFlag = false;
private static final ResourceLocation[] unicodePageLocations = new ResourceLocation[256];
protected final ResourceLocation locationFontTexture;
protected int[] charWidth = new int[256];
protected byte[] glyphWidth = new byte[65536];
private final int[] colorCode = new int[32];
private float red;
private float green;
private float blue;
private float posX;
private float posY;
public CustomGuiLabel(int id, String fullLabel, int x, int y, int width, int height, boolean shadow){
this.id = id;
this.fullLabel = fullLabel;
this.x = x;
this.y = y;
this.width = width;
this.height = height;
this.labelShadowEnabled = shadow;
locationFontTexture = new ResourceLocation("textures/font/ascii.png");
readFontTexture();
readGlyphSizes();
for (int i = 0; i < 32; ++i)
{
int j = (i >> 3 & 1) * 85;
int k = (i >> 2 & 1) * 170 + j;
int l = (i >> 1 & 1) * 170 + j;
int i1 = (i >> 0 & 1) * 170 + j;
if (i == 6)
{
k += 85;
}
if (Minecraft.getMinecraft().gameSettings.anaglyph)
{
int j1 = (k * 30 + l * 59 + i1 * 11) / 100;
int k1 = (k * 30 + l * 70) / 100;
int l1 = (k * 30 + i1 * 70) / 100;
k = j1;
l = k1;
i1 = l1;
}
if (i >= 16)
{
k /= 4;
l /= 4;
i1 /= 4;
}
this.colorCode[i] = (k & 255) << 16 | (l & 255) << 8 | i1 & 255;
}
}
public void setParent(GuiCustom parent) {
this.parent = parent;
}
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.field_146167_a && mouseY < this.y + this.field_146161_f;
this.drawLabel();
if (hovered && this.hoverText != null && this.hoverText.length > 0) {
this.parent.hoverText = this.hoverText;
}
}
public int getID() {
return this.id;
}
public void setScale(float scale) {
this.scale = scale;
}
public static CustomGuiLabel fromComponent(ScriptGuiLabel component) {
CustomGuiLabel lbl = new CustomGuiLabel(component.getID(), component.getText(), GuiCustom.guiLeft + component.getPosX(), GuiCustom.guiTop + component.getPosY(), component.getWidth(), component.getHeight(), component.hasShadow());
lbl.scale = 1.0F;
lbl.color = component.getColor();
lbl.setScale(component.getScale());
if (component.hasHoverText()) {
lbl.hoverText = component.getHoverText();
}
lbl.labelShadowEnabled = component.hasShadow();
lbl.color = component.getColor();
lbl.alpha = component.getAlpha();
lbl.rotation = component.getRotation();
lbl.field_146167_a = component.getWidth();
lbl.field_146161_f = component.getHeight();
return lbl;
}
public ICustomGuiComponent toComponent() {
ScriptGuiLabel component = new ScriptGuiLabel(this.id, this.fullLabel, this.field_146162_g, this.field_146174_h, this.field_146167_a, this.field_146161_f, this.color);
component.setHoverText(this.hoverText);
component.enableShadow(this.labelShadowEnabled);
component.setColor(this.color);
component.setAlpha(this.alpha);
component.setRotation(this.rotation);
return component;
}
public void drawLabel()
{
GL11.glPushMatrix();
red = (color >> 16 & 255) / 255f;
green = (color >> 8 & 255) / 255f;
blue = (color & 255) / 255f;
GL11.glTranslatef(this.x,this.y,0.0F);
GL11.glRotated(rotation,0.0D,0.0D,1.0D);
GL11.glScalef(this.scale, this.scale, this.scale);
this.drawString(fullLabel, 0, 0, this.color, this.labelShadowEnabled);
GL11.glPopMatrix();
}
public int drawString(String p_85187_1_, int p_85187_2_, int p_85187_3_, int p_85187_4_, boolean p_85187_5_)
{
this.resetStyles();
int l;
if (p_85187_5_)
{
l = this.renderString(p_85187_1_, p_85187_2_ + 1, p_85187_3_ + 1, p_85187_4_, true);
l = Math.max(l, this.renderString(p_85187_1_, p_85187_2_, p_85187_3_, p_85187_4_, false));
}
else
{
l = this.renderString(p_85187_1_, p_85187_2_, p_85187_3_, p_85187_4_, false);
}
return l;
}
private void resetStyles()
{
this.randomStyle = false;
this.boldStyle = false;
this.italicStyle = false;
this.underlineStyle = false;
this.strikethroughStyle = false;
}
private int renderString(String p_78258_1_, int p_78258_2_, int p_78258_3_, int p_78258_4_, boolean p_78258_5_)
{
if (p_78258_1_ == null)
{
return 0;
}
else
{
if (this.bidiFlag)
{
p_78258_1_ = this.bidiReorder(p_78258_1_);
}
setColor(this.red, this.green, this.blue, this.alpha);
this.posX = (float)p_78258_2_;
this.posY = (float)p_78258_3_;
this.renderStringAtPos(p_78258_1_, p_78258_5_);
return (int)this.posX;
}
}
private void renderStringAtPos(String p_78255_1_, boolean p_78255_2_)
{
for (int i = 0; i < p_78255_1_.length(); ++i)
{
char c0 = p_78255_1_.charAt(i);
int j;
int k;
if (c0 == 38 && i + 1 < p_78255_1_.length())
{
j = "0123456789abcdefklmnor".indexOf(p_78255_1_.toLowerCase().charAt(i + 1));
if(j < 16){
this.randomStyle = false;
this.boldStyle = false;
this.strikethroughStyle = false;
this.underlineStyle = false;
this.italicStyle = false;
if (j < 0 || j > 15)
{
j = 15;
}
if (p_78255_2_)
{
j += 16;
}
k = this.colorCode[j];
setColor((float)(k >> 16) / 255.0F, (float)(k >> 8 & 255) / 255.0F, (float)(k & 255) / 255.0F, this.alpha);
}
else if (j == 16)
{
this.randomStyle = true;
}
else if (j == 17)
{
this.boldStyle = true;
}
else if (j == 18)
{
this.strikethroughStyle = true;
}
else if (j == 19)
{
this.underlineStyle = true;
}
else if (j == 20)
{
this.italicStyle = true;
}
else if (j == 21)
{
this.randomStyle = false;
this.boldStyle = false;
this.strikethroughStyle = false;
this.underlineStyle = false;
this.italicStyle = false;
}
++i;
}
else
{
j = "\u00c0\u00c1\u00c2\u00c8\u00ca\u00cb\u00cd\u00d3\u00d4\u00d5\u00da\u00df\u00e3\u00f5\u011f\u0130\u0131\u0152\u0153\u015e\u015f\u0174\u0175\u017e\u0207\u0000\u0000\u0000\u0000\u0000\u0000\u0000 !\"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u0000\u00c7\u00fc\u00e9\u00e2\u00e4\u00e0\u00e5\u00e7\u00ea\u00eb\u00e8\u00ef\u00ee\u00ec\u00c4\u00c5\u00c9\u00e6\u00c6\u00f4\u00f6\u00f2\u00fb\u00f9\u00ff\u00d6\u00dc\u00f8\u00a3\u00d8\u00d7\u0192\u00e1\u00ed\u00f3\u00fa\u00f1\u00d1\u00aa\u00ba\u00bf\u00ae\u00ac\u00bd\u00bc\u00a1\u00ab\u00bb\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255d\u255c\u255b\u2510\u2514\u2534\u252c\u251c\u2500\u253c\u255e\u255f\u255a\u2554\u2569\u2566\u2560\u2550\u256c\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256b\u256a\u2518\u250c\u2588\u2584\u258c\u2590\u2580\u03b1\u03b2\u0393\u03c0\u03a3\u03c3\u03bc\u03c4\u03a6\u0398\u03a9\u03b4\u221e\u2205\u2208\u2229\u2261\u00b1\u2265\u2264\u2320\u2321\u00f7\u2248\u00b0\u2219\u00b7\u221a\u207f\u00b2\u25a0\u0000".indexOf(c0);
if (this.randomStyle && j != -1)
{
do
{
k = Minecraft.getMinecraft().fontRenderer.fontRandom.nextInt(this.charWidth.length);
}
while (this.charWidth[j] != this.charWidth[k]);
j = k;
}
float f1 = this.unicodeFlag ? 0.5F : 1.0F;
boolean flag1 = (c0 == 0 || j == -1 || this.unicodeFlag) && p_78255_2_;
if (flag1)
{
this.posX -= f1;
this.posY -= f1;
}
float f = this.renderCharAtPos(j, c0, this.italicStyle);
if (flag1)
{
this.posX += f1;
this.posY += f1;
}
if (this.boldStyle)
{
this.posX += f1;
if (flag1)
{
this.posX -= f1;
this.posY -= f1;
}
this.renderCharAtPos(j, c0, this.italicStyle);
this.posX -= f1;
if (flag1)
{
this.posX += f1;
this.posY += f1;
}
++f;
}
doDraw(f);
}
}
}
protected void doDraw(float f)
{
{
{
Tessellator tessellator;
if (this.strikethroughStyle)
{
tessellator = Tessellator.instance;
GL11.glDisable(GL11.GL_TEXTURE_2D);
tessellator.startDrawingQuads();
tessellator.addVertex((double)this.posX, (double)(this.posY + (float)(Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT / 2)), 0.0D);
tessellator.addVertex((double)(this.posX + f), (double)(this.posY + (float)(Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT / 2)), 0.0D);
tessellator.addVertex((double)(this.posX + f), (double)(this.posY + (float)(Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT / 2) - 1.0F), 0.0D);
tessellator.addVertex((double)this.posX, (double)(this.posY + (float)(Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT / 2) - 1.0F), 0.0D);
tessellator.draw();
GL11.glEnable(GL11.GL_TEXTURE_2D);
}
if (this.underlineStyle)
{
tessellator = Tessellator.instance;
GL11.glDisable(GL11.GL_TEXTURE_2D);
tessellator.startDrawingQuads();
int l = this.underlineStyle ? -1 : 0;
tessellator.addVertex((double)(this.posX + (float)l), (double)(this.posY + (float)Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT), 0.0D);
tessellator.addVertex((double)(this.posX + f), (double)(this.posY + (float)Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT), 0.0D);
tessellator.addVertex((double)(this.posX + f), (double)(this.posY + (float)Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT - 1.0F), 0.0D);
tessellator.addVertex((double)(this.posX + (float)l), (double)(this.posY + (float)Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT - 1.0F), 0.0D);
tessellator.draw();
GL11.glEnable(GL11.GL_TEXTURE_2D);
}
this.posX += (float)((int)f);
}
}
}
private float renderCharAtPos(int p_78278_1_, char p_78278_2_, boolean p_78278_3_)
{
return p_78278_2_ == 32 ? 4.0F : ("\u00c0\u00c1\u00c2\u00c8\u00ca\u00cb\u00cd\u00d3\u00d4\u00d5\u00da\u00df\u00e3\u00f5\u011f\u0130\u0131\u0152\u0153\u015e\u015f\u0174\u0175\u017e\u0207\u0000\u0000\u0000\u0000\u0000\u0000\u0000 !\"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u0000\u00c7\u00fc\u00e9\u00e2\u00e4\u00e0\u00e5\u00e7\u00ea\u00eb\u00e8\u00ef\u00ee\u00ec\u00c4\u00c5\u00c9\u00e6\u00c6\u00f4\u00f6\u00f2\u00fb\u00f9\u00ff\u00d6\u00dc\u00f8\u00a3\u00d8\u00d7\u0192\u00e1\u00ed\u00f3\u00fa\u00f1\u00d1\u00aa\u00ba\u00bf\u00ae\u00ac\u00bd\u00bc\u00a1\u00ab\u00bb\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255d\u255c\u255b\u2510\u2514\u2534\u252c\u251c\u2500\u253c\u255e\u255f\u255a\u2554\u2569\u2566\u2560\u2550\u256c\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256b\u256a\u2518\u250c\u2588\u2584\u258c\u2590\u2580\u03b1\u03b2\u0393\u03c0\u03a3\u03c3\u03bc\u03c4\u03a6\u0398\u03a9\u03b4\u221e\u2205\u2208\u2229\u2261\u00b1\u2265\u2264\u2320\u2321\u00f7\u2248\u00b0\u2219\u00b7\u221a\u207f\u00b2\u25a0\u0000".indexOf(p_78278_2_) != -1 && !this.unicodeFlag ? this.renderDefaultChar(p_78278_1_, p_78278_3_) : this.renderUnicodeChar(p_78278_2_, p_78278_3_));
}
protected float renderDefaultChar(int p_78266_1_, boolean p_78266_2_)
{
float f = (float)(p_78266_1_ % 16 * 8);
float f1 = (float)(p_78266_1_ / 16 * 8);
float f2 = p_78266_2_ ? 1.0F : 0.0F;
bindTexture(this.locationFontTexture);
float f3 = (float)this.charWidth[p_78266_1_] - 0.01F;
GL11.glBegin(GL11.GL_TRIANGLE_STRIP);
GL11.glTexCoord2f(f / 128.0F, f1 / 128.0F);
GL11.glVertex3f(this.posX + f2, this.posY, 0.0F);
GL11.glTexCoord2f(f / 128.0F, (f1 + 7.99F) / 128.0F);
GL11.glVertex3f(this.posX - f2, this.posY + 7.99F, 0.0F);
GL11.glTexCoord2f((f + f3 - 1.0F) / 128.0F, f1 / 128.0F);
GL11.glVertex3f(this.posX + f3 - 1.0F + f2, this.posY, 0.0F);
GL11.glTexCoord2f((f + f3 - 1.0F) / 128.0F, (f1 + 7.99F) / 128.0F);
GL11.glVertex3f(this.posX + f3 - 1.0F - f2, this.posY + 7.99F, 0.0F);
GL11.glEnd();
return (float)this.charWidth[p_78266_1_];
}
private ResourceLocation getUnicodePageLocation(int p_111271_1_)
{
if (unicodePageLocations[p_111271_1_] == null)
{
unicodePageLocations[p_111271_1_] = new ResourceLocation(String.format("textures/font/unicode_page_%02x.png", new Object[] {Integer.valueOf(p_111271_1_)}));
}
return unicodePageLocations[p_111271_1_];
}
private void loadGlyphTexture(int p_78257_1_)
{
bindTexture(this.getUnicodePageLocation(p_78257_1_));
}
/**
* Render a single Unicode character at current (posX,posY) location using one of the /font/glyph_XX.png files...
*/
protected float renderUnicodeChar(char p_78277_1_, boolean p_78277_2_)
{
if (this.glyphWidth[p_78277_1_] == 0)
{
return 0.0F;
}
else
{
int i = p_78277_1_ / 256;
this.loadGlyphTexture(i);
int j = this.glyphWidth[p_78277_1_] >>> 4;
int k = this.glyphWidth[p_78277_1_] & 15;
float f = (float)j;
float f1 = (float)(k + 1);
float f2 = (float)(p_78277_1_ % 16 * 16) + f;
float f3 = (float)((p_78277_1_ & 255) / 16 * 16);
float f4 = f1 - f - 0.02F;
float f5 = p_78277_2_ ? 1.0F : 0.0F;
GL11.glBegin(GL11.GL_TRIANGLE_STRIP);
GL11.glTexCoord2f(f2 / 256.0F, f3 / 256.0F);
GL11.glVertex3f(this.posX + f5, this.posY, 0.0F);
GL11.glTexCoord2f(f2 / 256.0F, (f3 + 15.98F) / 256.0F);
GL11.glVertex3f(this.posX - f5, this.posY + 7.99F, 0.0F);
GL11.glTexCoord2f((f2 + f4) / 256.0F, f3 / 256.0F);
GL11.glVertex3f(this.posX + f4 / 2.0F + f5, this.posY, 0.0F);
GL11.glTexCoord2f((f2 + f4) / 256.0F, (f3 + 15.98F) / 256.0F);
GL11.glVertex3f(this.posX + f4 / 2.0F - f5, this.posY + 7.99F, 0.0F);
GL11.glEnd();
return (f1 - f) / 2.0F + 1.0F;
}
}
protected void setColor(float r, float g, float b, float a)
{
GL11.glColor4f(r, g, b, a);
}
protected void bindTexture(ResourceLocation location)
{
Minecraft.getMinecraft().renderEngine.bindTexture(location);
}
private void readFontTexture()
{
BufferedImage bufferedimage;
try
{
bufferedimage = ImageIO.read(getResourceInputStream(this.locationFontTexture));
}
catch (IOException ioexception)
{
throw new RuntimeException(ioexception);
}
int i = bufferedimage.getWidth();
int j = bufferedimage.getHeight();
int[] aint = new int[i * j];
bufferedimage.getRGB(0, 0, i, j, aint, 0, i);
int k = j / 16;
int l = i / 16;
byte b0 = 1;
float f = 8.0F / (float)l;
int i1 = 0;
while (i1 < 256)
{
int j1 = i1 % 16;
int k1 = i1 / 16;
if (i1 == 32)
{
this.charWidth[i1] = 3 + b0;
}
int l1 = l - 1;
while (true)
{
if (l1 >= 0)
{
int i2 = j1 * l + l1;
boolean flag = true;
for (int j2 = 0; j2 < k && flag; ++j2)
{
int k2 = (k1 * l + j2) * i;
if ((aint[i2 + k2] >> 24 & 255) != 0)
{
flag = false;
}
}
if (flag)
{
--l1;
continue;
}
}
++l1;
this.charWidth[i1] = (int)(0.5D + (double)((float)l1 * f)) + b0;
++i1;
break;
}
}
}
private void readGlyphSizes()
{
try
{
InputStream inputstream = getResourceInputStream(new ResourceLocation("font/glyph_sizes.bin"));
inputstream.read(this.glyphWidth);
}
catch (IOException ioexception)
{
throw new RuntimeException(ioexception);
}
}
protected InputStream getResourceInputStream(ResourceLocation location) throws IOException
{
return Minecraft.getMinecraft().getResourceManager().getResource(location).getInputStream();
}
private String bidiReorder(String p_147647_1_)
{
try
{
Bidi bidi = new Bidi((new ArabicShaping(8)).shape(p_147647_1_), 127);
bidi.setReorderingMode(0);
return bidi.writeReordered(2);
}
catch (ArabicShapingException arabicshapingexception)
{
return p_147647_1_;
}
}
}
@@ -0,0 +1,79 @@
package noppes.npcs.client.gui.custom.components;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.util.ResourceLocation;
import noppes.npcs.client.gui.custom.GuiCustom;
import noppes.npcs.client.gui.custom.interfaces.IGuiComponent;
import noppes.npcs.scripted.gui.ScriptGuiLine;
import noppes.npcs.scripted.interfaces.ICustomGuiComponent;
import org.lwjgl.opengl.GL11;
import static org.lwjgl.opengl.GL11.GL_ONE_MINUS_SRC_ALPHA;
import static org.lwjgl.opengl.GL11.GL_SRC_ALPHA;
public class CustomGuiLine extends Gui implements IGuiComponent {
int id;
GuiCustom parent;
int x1;
int y1;
int x2;
int y2;
int color;
float alpha;
float rotation;
int thickness;
public CustomGuiLine(int id, int x1, int y1, int x2, int y2, int color, int thickness){
this.id = id;
this.x1 = x1;
this.y1 = y1;
this.x2 = x2;
this.y2 = y2;
this.color = color;
this.thickness = thickness;
}
public void setParent(GuiCustom parent) {
this.parent = parent;
}
@Override
public int getID() {
return this.id;
}
public void onRender(Minecraft mc, int mouseX, int mouseY, int mouseWheel, float partialTicks) {
double distance = Math.sqrt(Math.pow(x1-x2,2)+Math.pow(y1-y2,2));
mc.getTextureManager().bindTexture(new ResourceLocation("customnpcs:textures/gui/misc.png"));
GL11.glPushMatrix();
float red = (color >> 16 & 255) / 255f;
float green = (color >> 8 & 255) / 255f;
float blue = (color & 255) / 255f;
GL11.glColor4f(red,green,blue,this.alpha);
GL11.glTranslatef(GuiCustom.guiLeft+this.x1,GuiCustom.guiTop+this.y1,0.0F);
GL11.glRotated(-Math.toDegrees(Math.atan2(x2-x1,y2-y1)),0.0F,0.0F,1.0F);
GL11.glRotated(rotation,0.0D,0.0D,1.0D);
GL11.glScaled(thickness, distance,0.0D);
this.drawTexturedModalRect(0,0,0,0, 1, 1);
GL11.glPopMatrix();
}
public ICustomGuiComponent toComponent() {
ScriptGuiLine line = new ScriptGuiLine(this.id, this.x1,this.y1,this.x2,this.y2,this.color,this.thickness);
line.setColor(this.color);
line.setAlpha(this.alpha);
line.setRotation(this.rotation);
return line;
}
public static CustomGuiLine fromComponent(ScriptGuiLine component) {
CustomGuiLine line = new CustomGuiLine(component.getID(), component.getX1(), component.getY1(), component.getX2(), component.getY2(), component.getColor(), component.getThickness());
line.color = component.getColor();
line.alpha = component.getAlpha();
line.rotation = component.getRotation();
return line;
}
}
@@ -0,0 +1,122 @@
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
package noppes.npcs.client.gui.custom.components;
import java.util.Arrays;
import java.util.Iterator;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.nbt.NBTTagString;
import noppes.npcs.client.gui.custom.GuiCustom;
import noppes.npcs.client.gui.custom.interfaces.IClickListener;
import noppes.npcs.client.gui.custom.interfaces.IDataHolder;
import noppes.npcs.client.gui.util.GuiCustomScroll;
import noppes.npcs.scripted.gui.ScriptGuiScroll;
import noppes.npcs.scripted.interfaces.ICustomGuiComponent;
import org.lwjgl.opengl.GL11;
public class CustomGuiScrollComponent extends GuiCustomScroll implements IDataHolder, IClickListener {
GuiCustom parent;
String[] hoverText;
public boolean multiSelect = false;
int color;
float alpha;
public CustomGuiScrollComponent(Minecraft mc, GuiScreen parent, int id) {
super(parent, id);
this.mc = mc;
this.fontRendererObj = mc.fontRenderer;
}
public CustomGuiScrollComponent(Minecraft mc, GuiScreen parent, int id, boolean multiSelect) {
super(parent, id, multiSelect);
this.mc = mc;
this.fontRendererObj = mc.fontRenderer;
this.multiSelect = multiSelect;
}
public void setParent(GuiCustom parent) {
this.parent = parent;
}
public int getID() {
return this.id;
}
public void onRender(Minecraft mc, int mouseX, int mouseY, int mouseWheel, float partialTicks) {
GL11.glPushMatrix();
float red = (color >> 16 & 255) / 255f;
float green = (color >> 8 & 255) / 255f;
float blue = (color & 255) / 255f;
GL11.glColor4f(red,green,blue,this.alpha);
GL11.glTranslatef(0.0F, 0.0F, (float)this.id);
boolean hovered = mouseX >= this.guiLeft && mouseY >= this.guiTop && mouseX < this.guiLeft + this.xSize && mouseY < this.guiTop + this.ySize;
super.drawScreen(mouseX, mouseY, partialTicks, mouseWheel);
if (hovered && this.hoverText != null && this.hoverText.length > 0) {
this.parent.hoverText = this.hoverText;
}
GL11.glPopMatrix();
}
public boolean mouseClicked(GuiCustom gui, int mouseX, int mouseY, int mouseButton) {
super.mouseClicked(mouseX, mouseY, mouseButton);
return this.isMouseOver(mouseX, mouseY);
}
public void fromComponent(ScriptGuiScroll component) {
this.guiLeft = GuiCustom.guiLeft + component.getPosX();
this.guiTop = GuiCustom.guiTop + component.getPosY();
this.setSize(component.getWidth(), component.getHeight());
this.setUnsortedList(Arrays.asList(component.getList()));
if (component.getDefaultSelection() >= 0) {
int defaultSelect = component.getDefaultSelection();
if (defaultSelect < this.getList().size()) {
this.selected = defaultSelect;
}
}
if (component.hasHoverText()) {
this.hoverText = component.getHoverText();
}
this.color = component.getColor();
this.alpha = component.getAlpha();
}
public ICustomGuiComponent toComponent() {
ScriptGuiScroll component = new ScriptGuiScroll(this.id, this.guiLeft - GuiCustom.guiLeft, this.guiTop - GuiCustom.guiTop, this.width, this.height, (String[])this.getList().toArray(new String[0]));
component.setHoverText(this.hoverText);
component.setColor(color);
component.setAlpha(alpha);
return component;
}
public NBTTagCompound toNBT() {
NBTTagCompound nbt = new NBTTagCompound();
nbt.setInteger("id", this.id);
if (!this.getSelectedList().isEmpty()) {
NBTTagList tagList = new NBTTagList();
Iterator var3 = this.getSelectedList().iterator();
while(var3.hasNext()) {
String s = (String)var3.next();
tagList.appendTag(new NBTTagString(s));
}
nbt.setTag("selectedList", tagList);
} else if (this.getSelected() != null && !this.getSelected().isEmpty()) {
nbt.setString("selected", this.getSelected());
} else {
nbt.setString("selected", "Null");
}
return nbt;
}
}
@@ -0,0 +1,30 @@
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
package noppes.npcs.client.gui.custom.components;
import net.minecraft.client.Minecraft;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import noppes.npcs.client.gui.custom.GuiCustom;
public class CustomGuiSlot extends Slot {
public boolean clientSide;
public int slotNumber;
public CustomGuiSlot(IInventory inventoryIn, int index, int xPosition, int yPosition, boolean clientSide) {
super(inventoryIn, index, xPosition, yPosition);
this.clientSide = clientSide;
this.slotNumber = index;
}
public void onSlotChanged() {
if (this.clientSide) {
((GuiCustom)Minecraft.getMinecraft().currentScreen).slotChange(this);
}
super.onSlotChanged();
}
}
@@ -0,0 +1,103 @@
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
package noppes.npcs.client.gui.custom.components;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiTextField;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.client.Client;
import noppes.npcs.client.gui.custom.GuiCustom;
import noppes.npcs.client.gui.custom.interfaces.IClickListener;
import noppes.npcs.client.gui.custom.interfaces.IDataHolder;
import noppes.npcs.client.gui.custom.interfaces.IKeyListener;
import noppes.npcs.constants.EnumPacketServer;
import noppes.npcs.scripted.gui.ScriptGuiTextField;
import noppes.npcs.scripted.interfaces.ICustomGuiComponent;
import org.lwjgl.opengl.GL11;
public class CustomGuiTextField extends GuiTextField implements IKeyListener, IDataHolder, IClickListener {
GuiCustom parent;
String[] hoverText;
int id;
int color;
float alpha;
public CustomGuiTextField(int id, int x, int y, int width, int height) {
super(Minecraft.getMinecraft().fontRenderer, GuiCustom.guiLeft + x, GuiCustom.guiTop + y, width, height);
this.id = id;
this.setMaxStringLength(500);
}
public void keyTyped(char typedChar, int keyCode) {
this.textboxKeyTyped(typedChar, keyCode);
}
public void onRender(Minecraft mc, int mouseX, int mouseY, int mouseWheel, float partialTicks) {
boolean hovered = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height;
float red = (color >> 16 & 255) / 255f;
float green = (color >> 8 & 255) / 255f;
float blue = (color & 255) / 255f;
GL11.glColor4f(red,green,blue,this.alpha);
this.drawTextBox();
GL11.glColor4f(1.0F,1.0F,1.0F,1.0F);
if (hovered && this.hoverText != null && this.hoverText.length > 0) {
this.parent.hoverText = this.hoverText;
}
}
public void setParent(GuiCustom parent) {
this.parent = parent;
}
public int getID() {
return this.id;
}
public NBTTagCompound toNBT() {
NBTTagCompound tag = new NBTTagCompound();
tag.setInteger("id", this.id);
tag.setString("text", this.getText());
return tag;
}
public ICustomGuiComponent toComponent() {
ScriptGuiTextField component = new ScriptGuiTextField(this.id, this.xPosition - GuiCustom.guiLeft, this.yPosition - GuiCustom.guiTop, this.width, this.height);
component.setText(this.getText());
component.setHoverText(this.hoverText);
component.setColor(color);
component.setAlpha(alpha);
return component;
}
public static CustomGuiTextField fromComponent(ScriptGuiTextField component) {
CustomGuiTextField txt = new CustomGuiTextField(component.getID(), component.getPosX(), component.getPosY(), component.getWidth(), component.getHeight());
if (component.hasHoverText()) {
txt.hoverText = component.getHoverText();
}
if (component.getText() != null && !component.getText().isEmpty()) {
txt.setText(component.getText());
}
txt.color = component.getColor();
txt.alpha = component.getAlpha();
return txt;
}
public boolean mouseClicked(GuiCustom gui, int mouseX, int mouseY, int mouseButton) {
boolean flag = mouseX >= this.xPosition && mouseX < this.xPosition + this.width && mouseY >= this.yPosition && mouseY < this.yPosition + this.height;
if (this.isFocused() && mouseButton == 0 && !flag){
parent.onTextFieldUnfocused(this);
}
this.mouseClicked(mouseX, mouseY, mouseButton);
return true;
}
}
@@ -0,0 +1,141 @@
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
package noppes.npcs.client.gui.custom.components;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.texture.ITextureObject;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.client.resources.SkinManager;
import net.minecraft.util.ResourceLocation;
import noppes.npcs.client.ImageDownloadAlt;
import noppes.npcs.client.gui.custom.GuiCustom;
import noppes.npcs.client.gui.custom.interfaces.IGuiComponent;
import noppes.npcs.client.renderer.ImageBufferDownloadAlt;
import noppes.npcs.scripted.gui.ScriptGuiTexturedRect;
import noppes.npcs.scripted.interfaces.ICustomGuiComponent;
import org.lwjgl.opengl.GL11;
import static org.lwjgl.opengl.GL11.GL_ONE_MINUS_SRC_ALPHA;
import static org.lwjgl.opengl.GL11.GL_SRC_ALPHA;
public class CustomGuiTexturedRect extends Gui implements IGuiComponent {
GuiCustom parent;
ResourceLocation texture;
int id;
int x;
int y;
int width;
int height;
int textureX;
int textureY;
float scale;
String[] hoverText;
int color;
float alpha;
float rotation;
public CustomGuiTexturedRect(int id, String texture, int x, int y, int width, int height) {
this(id, texture, x, y, width, height, 0, 0);
}
public CustomGuiTexturedRect(int id, String texture, int x, int y, int width, int height, int textureX, int textureY) {
this.scale = 1.0F;
this.id = id;
this.texture = new ResourceLocation(texture);
this.x = x;
this.y = y;
this.width = width;
this.height = height;
this.textureX = textureX;
this.textureY = textureY;
if(texture.startsWith("https://")){
TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager();
ITextureObject object = new ImageDownloadAlt(null, texture, SkinManager.field_152793_a, new ImageBufferDownloadAlt(false));
texturemanager.loadTexture(this.texture, object);
}
}
public void setParent(GuiCustom parent) {
this.parent = parent;
}
public int getID() {
return this.id;
}
public void onRender(Minecraft mc, int mouseX, int mouseY, int mouseWheel, float partialTicks) {
boolean hovered = mouseX >= this.x + GuiCustom.guiLeft && mouseY >= this.y + GuiCustom.guiTop && mouseX < this.x + GuiCustom.guiLeft + this.width && mouseY < this.y + GuiCustom.guiTop + this.height;
mc.getTextureManager().bindTexture(this.texture);
GL11.glPushMatrix();
float red = (color >> 16 & 255) / 255f;
float green = (color >> 8 & 255) / 255f;
float blue = (color & 255) / 255f;
GL11.glColor4f(red,green,blue,this.alpha);
GL11.glTranslatef(GuiCustom.guiLeft,GuiCustom.guiTop,0.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_2_ = (int) (this.y/this.scale);
int p_73729_3_ = this.textureX;
int p_73729_4_ = this.textureY;
int p_73729_5_ = (int)(this.width);
int p_73729_6_ = (int)(this.height);
float f = 0.00390625F;
float f1 = 0.00390625F;
Tessellator tessellator = Tessellator.instance;
tessellator.startDrawingQuads();
tessellator.setColorOpaque_F(1, 1, 1);
tessellator.setColorRGBA_F(red, green, blue, alpha);
tessellator.addVertexWithUV((double)(p_73729_1_ + 0), (double)(p_73729_2_ + p_73729_6_), (double)this.zLevel, (double)((float)(p_73729_3_ + 0) * f), (double)((float)(p_73729_4_ + p_73729_6_) * f1));
tessellator.addVertexWithUV((double)(p_73729_1_ + p_73729_5_), (double)(p_73729_2_ + p_73729_6_), (double)this.zLevel, (double)((float)(p_73729_3_ + p_73729_5_) * f), (double)((float)(p_73729_4_ + p_73729_6_) * f1));
tessellator.addVertexWithUV((double)(p_73729_1_ + p_73729_5_), (double)(p_73729_2_ + 0), (double)this.zLevel, (double)((float)(p_73729_3_ + p_73729_5_) * f), (double)((float)(p_73729_4_ + 0) * f1));
tessellator.addVertexWithUV((double)(p_73729_1_ + 0), (double)(p_73729_2_ + 0), (double)this.zLevel, (double)((float)(p_73729_3_ + 0) * f), (double)((float)(p_73729_4_ + 0) * f1));
tessellator.draw();
GL11.glPopMatrix();
if (hovered && this.hoverText != null && this.hoverText.length > 0) {
this.parent.hoverText = this.hoverText;
}
}
public ICustomGuiComponent toComponent() {
ScriptGuiTexturedRect component = new ScriptGuiTexturedRect(this.id, this.texture.toString(), this.x, this.y, this.width, this.height, this.textureX, this.textureY);
component.setHoverText(this.hoverText);
component.setScale(this.scale);
component.setColor(color);
component.setAlpha(alpha);
component.setRotation(rotation);
return component;
}
public static CustomGuiTexturedRect fromComponent(ScriptGuiTexturedRect component) {
CustomGuiTexturedRect rect;
if (component.getTextureX() >= 0 && component.getTextureY() >= 0) {
rect = new CustomGuiTexturedRect(component.getID(), component.getTexture(), component.getPosX(), component.getPosY(), component.getWidth(), component.getHeight(), component.getTextureX(), component.getTextureY());
} else {
rect = new CustomGuiTexturedRect(component.getID(), component.getTexture(), component.getPosX(), component.getPosY(), component.getWidth(), component.getHeight());
}
rect.scale = component.getScale();
if (component.hasHoverText()) {
rect.hoverText = component.getHoverText();
}
rect.color = component.getColor();
rect.alpha = component.getAlpha();
rect.rotation = component.getRotation();
return rect;
}
}
@@ -0,0 +1,12 @@
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
package noppes.npcs.client.gui.custom.interfaces;
import noppes.npcs.client.gui.custom.GuiCustom;
public interface IClickListener extends IGuiComponent {
boolean mouseClicked(GuiCustom var1, int var2, int var3, int var4);
}
@@ -0,0 +1,12 @@
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
package noppes.npcs.client.gui.custom.interfaces;
import net.minecraft.nbt.NBTTagCompound;
public interface IDataHolder extends IGuiComponent {
NBTTagCompound toNBT();
}
@@ -0,0 +1,17 @@
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
package noppes.npcs.client.gui.custom.interfaces;
import net.minecraft.client.Minecraft;
import noppes.npcs.scripted.interfaces.ICustomGuiComponent;
public interface IGuiComponent {
int getID();
void onRender(Minecraft var1, int var2, int var3, int var4, float var5);
ICustomGuiComponent toComponent();
}
@@ -0,0 +1,10 @@
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
package noppes.npcs.client.gui.custom.interfaces;
public interface IKeyListener extends IGuiComponent {
void keyTyped(char var1, int var2);
}
@@ -0,0 +1,97 @@
package noppes.npcs.client.gui.customoverlay;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ResourceLocation;
import noppes.npcs.client.gui.customoverlay.components.CustomOverlayLabel;
import noppes.npcs.client.gui.customoverlay.components.CustomOverlayLine;
import noppes.npcs.client.gui.customoverlay.components.CustomOverlayTexturedRect;
import noppes.npcs.client.gui.customoverlay.interfaces.IOverlayComponent;
import noppes.npcs.scripted.interfaces.ICustomOverlayComponent;
import noppes.npcs.scripted.overlay.*;
import org.lwjgl.opengl.GL11;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
public class OverlayCustom extends Gui {
protected final Minecraft mc;
private ScaledResolution res = null;
public static int scaledWidth = 0;
public static int scaledHeight = 0;
public ScriptOverlay overlay;
Map<Integer, IOverlayComponent> components = new HashMap();
public OverlayCustom(Minecraft mc) {
this.mc = mc;
}
public void initOverlay(){
res = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
if(this.overlay != null){
scaledWidth = res.getScaledWidth();
scaledHeight = res.getScaledHeight();
this.components.clear();
Iterator var1 = this.overlay.getComponents().iterator();
while(var1.hasNext()) {
ICustomOverlayComponent c = (ICustomOverlayComponent)var1.next();
this.addComponent(c);
}
}
}
private void addComponent(ICustomOverlayComponent component) {
ScriptOverlayComponent c = (ScriptOverlayComponent)component;
switch(c.getType()) {
case 0:
CustomOverlayTexturedRect rect = CustomOverlayTexturedRect.fromComponent((ScriptOverlayTexturedRect) component);
rect.setParent(this);
this.components.put(rect.getID(), rect);
break;
case 1:
CustomOverlayLabel lbl = CustomOverlayLabel.fromComponent((ScriptOverlayLabel)component);
lbl.setParent(this);
this.components.put(lbl.getID(), lbl);
break;
case 2:
CustomOverlayLine line = CustomOverlayLine.fromComponent((ScriptOverlayLine) component);
line.setParent(this);
this.components.put(line.getID(), line);
break;
}
}
public void renderGameOverlay(float partialTicks){
res = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
scaledWidth = res.getScaledWidth();
scaledHeight = res.getScaledHeight();
Iterator var4 = this.components.values().iterator();
while(var4.hasNext()) {
GL11.glEnable(GL11.GL_BLEND);
OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0);
GL11.glDisable(GL11.GL_ALPHA_TEST);
IOverlayComponent component = (IOverlayComponent)var4.next();
component.onRender(this.mc, partialTicks);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_ALPHA_TEST);
}
}
public void setOverlayData(NBTTagCompound compound) {
this.overlay = (ScriptOverlay)(new ScriptOverlay()).fromNBT(compound);
this.initOverlay();
}
}
@@ -0,0 +1,553 @@
package noppes.npcs.client.gui.customoverlay.components;
import com.ibm.icu.text.ArabicShaping;
import com.ibm.icu.text.ArabicShapingException;
import com.ibm.icu.text.Bidi;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.util.ResourceLocation;
import noppes.npcs.client.gui.customoverlay.OverlayCustom;
import noppes.npcs.client.gui.customoverlay.interfaces.IOverlayComponent;
import noppes.npcs.scripted.interfaces.ICustomOverlayComponent;
import noppes.npcs.scripted.overlay.ScriptOverlayLabel;
import org.lwjgl.opengl.GL11;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.InputStream;
public class CustomOverlayLabel extends Gui implements IOverlayComponent {
OverlayCustom parent;
int id;
String fullLabel;
int x, y, width, height, alignment;
float scale, rotation;
int color;
float alpha;
int border = 2;
boolean labelBgEnabled = true;
boolean labelShadowEnabled = false;
protected int field_146167_a;
protected int field_146161_f;
public int field_146162_g;
public int field_146174_h;
private boolean randomStyle = false;
private boolean boldStyle = false;
private boolean italicStyle = false;
private boolean underlineStyle = false;
private boolean strikethroughStyle = false;
private boolean bidiFlag = false;
private boolean unicodeFlag = false;
private static final ResourceLocation[] unicodePageLocations = new ResourceLocation[256];
protected final ResourceLocation locationFontTexture;
protected int[] charWidth = new int[256];
protected byte[] glyphWidth = new byte[65536];
private final int[] colorCode = new int[32];
private float red;
private float green;
private float blue;
private float posX;
private float posY;
public CustomOverlayLabel(int id, String fullLabel, int x, int y, int width, int height, boolean shadow){
this.id = id;
this.fullLabel = fullLabel;
this.x = x;
this.y = y;
this.width = width;
this.height = height;
this.labelShadowEnabled = shadow;
locationFontTexture = new ResourceLocation("textures/font/ascii.png");
readFontTexture();
readGlyphSizes();
for (int i = 0; i < 32; ++i)
{
int j = (i >> 3 & 1) * 85;
int k = (i >> 2 & 1) * 170 + j;
int l = (i >> 1 & 1) * 170 + j;
int i1 = (i >> 0 & 1) * 170 + j;
if (i == 6)
{
k += 85;
}
if (Minecraft.getMinecraft().gameSettings.anaglyph)
{
int j1 = (k * 30 + l * 59 + i1 * 11) / 100;
int k1 = (k * 30 + l * 70) / 100;
int l1 = (k * 30 + i1 * 70) / 100;
k = j1;
l = k1;
i1 = l1;
}
if (i >= 16)
{
k /= 4;
l /= 4;
i1 /= 4;
}
this.colorCode[i] = (k & 255) << 16 | (l & 255) << 8 | i1 & 255;
}
}
public void setParent(OverlayCustom parent) {
this.parent = parent;
}
public void onRender(Minecraft mc, float partialTicks) {
this.drawLabel();
}
public int getID() {
return this.id;
}
public void setScale(float scale) {
this.scale = scale;
}
public static CustomOverlayLabel fromComponent(ScriptOverlayLabel component) {
CustomOverlayLabel lbl = new CustomOverlayLabel(component.getID(), component.getText(), component.getPosX(), component.getPosY(), component.getWidth(), component.getHeight(), component.getShadow());
lbl.scale = 1.0F;
lbl.color = component.getColor();
lbl.labelShadowEnabled = component.getShadow();
lbl.alignment = component.getAlignment();
lbl.alpha = component.getAlpha();
lbl.rotation = component.getRotation();
lbl.setScale(component.getScale());
return lbl;
}
public ICustomOverlayComponent toComponent() {
ScriptOverlayLabel component = new ScriptOverlayLabel(this.id, this.fullLabel, this.field_146162_g, this.field_146174_h, this.field_146167_a, this.field_146161_f, this.color);
component.setShadow(this.labelShadowEnabled);
component.setAlignment(alignment);
component.setAlpha(alpha);
component.setColor(color);
component.setRotation(rotation);
return component;
}
public void drawLabel()
{
GL11.glPushMatrix();
GL11.glTranslatef(this.alignment%3*((float)(OverlayCustom.scaledWidth)/2), (float) (Math.floor((float)(alignment/3))*((float)(OverlayCustom.scaledHeight)/2)),0.0F);//alignment%3 * width/2 Math.floor(alignment/3) * height/2
red = (color >> 16 & 255) / 255f;
green = (color >> 8 & 255) / 255f;
blue = (color & 255) / 255f;
GL11.glTranslatef(this.x,this.y,0.0F);
GL11.glRotated(rotation,0.0D,0.0D,1.0D);
GL11.glScalef(this.scale, this.scale, this.scale);
this.drawString(fullLabel, 0, 0, this.color, this.labelShadowEnabled);
GL11.glPopMatrix();
}
public int drawString(String p_85187_1_, int p_85187_2_, int p_85187_3_, int p_85187_4_, boolean p_85187_5_)
{
this.resetStyles();
int l;
if (p_85187_5_)
{
l = this.renderString(p_85187_1_, p_85187_2_ + 1, p_85187_3_ + 1, p_85187_4_, true);
l = Math.max(l, this.renderString(p_85187_1_, p_85187_2_, p_85187_3_, p_85187_4_, false));
}
else
{
l = this.renderString(p_85187_1_, p_85187_2_, p_85187_3_, p_85187_4_, false);
}
return l;
}
private void resetStyles()
{
this.randomStyle = false;
this.boldStyle = false;
this.italicStyle = false;
this.underlineStyle = false;
this.strikethroughStyle = false;
}
private int renderString(String p_78258_1_, int p_78258_2_, int p_78258_3_, int p_78258_4_, boolean p_78258_5_)
{
if (p_78258_1_ == null)
{
return 0;
}
else
{
if (this.bidiFlag)
{
p_78258_1_ = this.bidiReorder(p_78258_1_);
}
setColor(this.red, this.green, this.blue, this.alpha);
this.posX = (float)p_78258_2_;
this.posY = (float)p_78258_3_;
this.renderStringAtPos(p_78258_1_, p_78258_5_);
return (int)this.posX;
}
}
private void renderStringAtPos(String p_78255_1_, boolean p_78255_2_)
{
for (int i = 0; i < p_78255_1_.length(); ++i)
{
char c0 = p_78255_1_.charAt(i);
int j;
int k;
if (c0 == 38 && i + 1 < p_78255_1_.length())
{
j = "0123456789abcdefklmnor".indexOf(p_78255_1_.toLowerCase().charAt(i + 1));
if(j < 16){
this.randomStyle = false;
this.boldStyle = false;
this.strikethroughStyle = false;
this.underlineStyle = false;
this.italicStyle = false;
if (j < 0 || j > 15)
{
j = 15;
}
if (p_78255_2_)
{
j += 16;
}
k = this.colorCode[j];
setColor((float)(k >> 16) / 255.0F, (float)(k >> 8 & 255) / 255.0F, (float)(k & 255) / 255.0F, this.alpha);
}
else if (j == 16)
{
this.randomStyle = true;
}
else if (j == 17)
{
this.boldStyle = true;
}
else if (j == 18)
{
this.strikethroughStyle = true;
}
else if (j == 19)
{
this.underlineStyle = true;
}
else if (j == 20)
{
this.italicStyle = true;
}
else if (j == 21)
{
this.randomStyle = false;
this.boldStyle = false;
this.strikethroughStyle = false;
this.underlineStyle = false;
this.italicStyle = false;
}
++i;
}
else
{
j = "\u00c0\u00c1\u00c2\u00c8\u00ca\u00cb\u00cd\u00d3\u00d4\u00d5\u00da\u00df\u00e3\u00f5\u011f\u0130\u0131\u0152\u0153\u015e\u015f\u0174\u0175\u017e\u0207\u0000\u0000\u0000\u0000\u0000\u0000\u0000 !\"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u0000\u00c7\u00fc\u00e9\u00e2\u00e4\u00e0\u00e5\u00e7\u00ea\u00eb\u00e8\u00ef\u00ee\u00ec\u00c4\u00c5\u00c9\u00e6\u00c6\u00f4\u00f6\u00f2\u00fb\u00f9\u00ff\u00d6\u00dc\u00f8\u00a3\u00d8\u00d7\u0192\u00e1\u00ed\u00f3\u00fa\u00f1\u00d1\u00aa\u00ba\u00bf\u00ae\u00ac\u00bd\u00bc\u00a1\u00ab\u00bb\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255d\u255c\u255b\u2510\u2514\u2534\u252c\u251c\u2500\u253c\u255e\u255f\u255a\u2554\u2569\u2566\u2560\u2550\u256c\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256b\u256a\u2518\u250c\u2588\u2584\u258c\u2590\u2580\u03b1\u03b2\u0393\u03c0\u03a3\u03c3\u03bc\u03c4\u03a6\u0398\u03a9\u03b4\u221e\u2205\u2208\u2229\u2261\u00b1\u2265\u2264\u2320\u2321\u00f7\u2248\u00b0\u2219\u00b7\u221a\u207f\u00b2\u25a0\u0000".indexOf(c0);
if (this.randomStyle && j != -1)
{
do
{
k = Minecraft.getMinecraft().fontRenderer.fontRandom.nextInt(this.charWidth.length);
}
while (this.charWidth[j] != this.charWidth[k]);
j = k;
}
float f1 = this.unicodeFlag ? 0.5F : 1.0F;
boolean flag1 = (c0 == 0 || j == -1 || this.unicodeFlag) && p_78255_2_;
if (flag1)
{
this.posX -= f1;
this.posY -= f1;
}
float f = this.renderCharAtPos(j, c0, this.italicStyle);
if (flag1)
{
this.posX += f1;
this.posY += f1;
}
if (this.boldStyle)
{
this.posX += f1;
if (flag1)
{
this.posX -= f1;
this.posY -= f1;
}
this.renderCharAtPos(j, c0, this.italicStyle);
this.posX -= f1;
if (flag1)
{
this.posX += f1;
this.posY += f1;
}
++f;
}
doDraw(f);
}
}
}
protected void doDraw(float f)
{
{
{
Tessellator tessellator;
if (this.strikethroughStyle)
{
tessellator = Tessellator.instance;
GL11.glDisable(GL11.GL_TEXTURE_2D);
tessellator.startDrawingQuads();
tessellator.addVertex((double)this.posX, (double)(this.posY + (float)(Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT / 2)), 0.0D);
tessellator.addVertex((double)(this.posX + f), (double)(this.posY + (float)(Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT / 2)), 0.0D);
tessellator.addVertex((double)(this.posX + f), (double)(this.posY + (float)(Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT / 2) - 1.0F), 0.0D);
tessellator.addVertex((double)this.posX, (double)(this.posY + (float)(Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT / 2) - 1.0F), 0.0D);
tessellator.draw();
GL11.glEnable(GL11.GL_TEXTURE_2D);
}
if (this.underlineStyle)
{
tessellator = Tessellator.instance;
GL11.glDisable(GL11.GL_TEXTURE_2D);
tessellator.startDrawingQuads();
int l = this.underlineStyle ? -1 : 0;
tessellator.addVertex((double)(this.posX + (float)l), (double)(this.posY + (float)Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT), 0.0D);
tessellator.addVertex((double)(this.posX + f), (double)(this.posY + (float)Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT), 0.0D);
tessellator.addVertex((double)(this.posX + f), (double)(this.posY + (float)Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT - 1.0F), 0.0D);
tessellator.addVertex((double)(this.posX + (float)l), (double)(this.posY + (float)Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT - 1.0F), 0.0D);
tessellator.draw();
GL11.glEnable(GL11.GL_TEXTURE_2D);
}
this.posX += (float)((int)f);
}
}
}
private float renderCharAtPos(int p_78278_1_, char p_78278_2_, boolean p_78278_3_)
{
return p_78278_2_ == 32 ? 4.0F : ("\u00c0\u00c1\u00c2\u00c8\u00ca\u00cb\u00cd\u00d3\u00d4\u00d5\u00da\u00df\u00e3\u00f5\u011f\u0130\u0131\u0152\u0153\u015e\u015f\u0174\u0175\u017e\u0207\u0000\u0000\u0000\u0000\u0000\u0000\u0000 !\"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u0000\u00c7\u00fc\u00e9\u00e2\u00e4\u00e0\u00e5\u00e7\u00ea\u00eb\u00e8\u00ef\u00ee\u00ec\u00c4\u00c5\u00c9\u00e6\u00c6\u00f4\u00f6\u00f2\u00fb\u00f9\u00ff\u00d6\u00dc\u00f8\u00a3\u00d8\u00d7\u0192\u00e1\u00ed\u00f3\u00fa\u00f1\u00d1\u00aa\u00ba\u00bf\u00ae\u00ac\u00bd\u00bc\u00a1\u00ab\u00bb\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255d\u255c\u255b\u2510\u2514\u2534\u252c\u251c\u2500\u253c\u255e\u255f\u255a\u2554\u2569\u2566\u2560\u2550\u256c\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256b\u256a\u2518\u250c\u2588\u2584\u258c\u2590\u2580\u03b1\u03b2\u0393\u03c0\u03a3\u03c3\u03bc\u03c4\u03a6\u0398\u03a9\u03b4\u221e\u2205\u2208\u2229\u2261\u00b1\u2265\u2264\u2320\u2321\u00f7\u2248\u00b0\u2219\u00b7\u221a\u207f\u00b2\u25a0\u0000".indexOf(p_78278_2_) != -1 && !this.unicodeFlag ? this.renderDefaultChar(p_78278_1_, p_78278_3_) : this.renderUnicodeChar(p_78278_2_, p_78278_3_));
}
protected float renderDefaultChar(int p_78266_1_, boolean p_78266_2_)
{
float f = (float)(p_78266_1_ % 16 * 8);
float f1 = (float)(p_78266_1_ / 16 * 8);
float f2 = p_78266_2_ ? 1.0F : 0.0F;
bindTexture(this.locationFontTexture);
float f3 = (float)this.charWidth[p_78266_1_] - 0.01F;
GL11.glBegin(GL11.GL_TRIANGLE_STRIP);
GL11.glTexCoord2f(f / 128.0F, f1 / 128.0F);
GL11.glVertex3f(this.posX + f2, this.posY, 0.0F);
GL11.glTexCoord2f(f / 128.0F, (f1 + 7.99F) / 128.0F);
GL11.glVertex3f(this.posX - f2, this.posY + 7.99F, 0.0F);
GL11.glTexCoord2f((f + f3 - 1.0F) / 128.0F, f1 / 128.0F);
GL11.glVertex3f(this.posX + f3 - 1.0F + f2, this.posY, 0.0F);
GL11.glTexCoord2f((f + f3 - 1.0F) / 128.0F, (f1 + 7.99F) / 128.0F);
GL11.glVertex3f(this.posX + f3 - 1.0F - f2, this.posY + 7.99F, 0.0F);
GL11.glEnd();
return (float)this.charWidth[p_78266_1_];
}
private ResourceLocation getUnicodePageLocation(int p_111271_1_)
{
if (unicodePageLocations[p_111271_1_] == null)
{
unicodePageLocations[p_111271_1_] = new ResourceLocation(String.format("textures/font/unicode_page_%02x.png", new Object[] {Integer.valueOf(p_111271_1_)}));
}
return unicodePageLocations[p_111271_1_];
}
private void loadGlyphTexture(int p_78257_1_)
{
bindTexture(this.getUnicodePageLocation(p_78257_1_));
}
/**
* Render a single Unicode character at current (posX,posY) location using one of the /font/glyph_XX.png files...
*/
protected float renderUnicodeChar(char p_78277_1_, boolean p_78277_2_)
{
if (this.glyphWidth[p_78277_1_] == 0)
{
return 0.0F;
}
else
{
int i = p_78277_1_ / 256;
this.loadGlyphTexture(i);
int j = this.glyphWidth[p_78277_1_] >>> 4;
int k = this.glyphWidth[p_78277_1_] & 15;
float f = (float)j;
float f1 = (float)(k + 1);
float f2 = (float)(p_78277_1_ % 16 * 16) + f;
float f3 = (float)((p_78277_1_ & 255) / 16 * 16);
float f4 = f1 - f - 0.02F;
float f5 = p_78277_2_ ? 1.0F : 0.0F;
GL11.glBegin(GL11.GL_TRIANGLE_STRIP);
GL11.glTexCoord2f(f2 / 256.0F, f3 / 256.0F);
GL11.glVertex3f(this.posX + f5, this.posY, 0.0F);
GL11.glTexCoord2f(f2 / 256.0F, (f3 + 15.98F) / 256.0F);
GL11.glVertex3f(this.posX - f5, this.posY + 7.99F, 0.0F);
GL11.glTexCoord2f((f2 + f4) / 256.0F, f3 / 256.0F);
GL11.glVertex3f(this.posX + f4 / 2.0F + f5, this.posY, 0.0F);
GL11.glTexCoord2f((f2 + f4) / 256.0F, (f3 + 15.98F) / 256.0F);
GL11.glVertex3f(this.posX + f4 / 2.0F - f5, this.posY + 7.99F, 0.0F);
GL11.glEnd();
return (f1 - f) / 2.0F + 1.0F;
}
}
protected void setColor(float r, float g, float b, float a)
{
GL11.glColor4f(r, g, b, a);
}
protected void bindTexture(ResourceLocation location)
{
Minecraft.getMinecraft().renderEngine.bindTexture(location);
}
private void readFontTexture()
{
BufferedImage bufferedimage;
try
{
bufferedimage = ImageIO.read(getResourceInputStream(this.locationFontTexture));
}
catch (IOException ioexception)
{
throw new RuntimeException(ioexception);
}
int i = bufferedimage.getWidth();
int j = bufferedimage.getHeight();
int[] aint = new int[i * j];
bufferedimage.getRGB(0, 0, i, j, aint, 0, i);
int k = j / 16;
int l = i / 16;
byte b0 = 1;
float f = 8.0F / (float)l;
int i1 = 0;
while (i1 < 256)
{
int j1 = i1 % 16;
int k1 = i1 / 16;
if (i1 == 32)
{
this.charWidth[i1] = 3 + b0;
}
int l1 = l - 1;
while (true)
{
if (l1 >= 0)
{
int i2 = j1 * l + l1;
boolean flag = true;
for (int j2 = 0; j2 < k && flag; ++j2)
{
int k2 = (k1 * l + j2) * i;
if ((aint[i2 + k2] >> 24 & 255) != 0)
{
flag = false;
}
}
if (flag)
{
--l1;
continue;
}
}
++l1;
this.charWidth[i1] = (int)(0.5D + (double)((float)l1 * f)) + b0;
++i1;
break;
}
}
}
private void readGlyphSizes()
{
try
{
InputStream inputstream = getResourceInputStream(new ResourceLocation("font/glyph_sizes.bin"));
inputstream.read(this.glyphWidth);
}
catch (IOException ioexception)
{
throw new RuntimeException(ioexception);
}
}
protected InputStream getResourceInputStream(ResourceLocation location) throws IOException
{
return Minecraft.getMinecraft().getResourceManager().getResource(location).getInputStream();
}
private String bidiReorder(String p_147647_1_)
{
try
{
Bidi bidi = new Bidi((new ArabicShaping(8)).shape(p_147647_1_), 127);
bidi.setReorderingMode(0);
return bidi.writeReordered(2);
}
catch (ArabicShapingException arabicshapingexception)
{
return p_147647_1_;
}
}
}
@@ -0,0 +1,104 @@
package noppes.npcs.client.gui.customoverlay.components;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.util.ResourceLocation;
import noppes.npcs.client.gui.customoverlay.OverlayCustom;
import noppes.npcs.client.gui.customoverlay.interfaces.IOverlayComponent;
import noppes.npcs.scripted.interfaces.ICustomOverlayComponent;
import noppes.npcs.scripted.overlay.ScriptOverlayLine;
import org.lwjgl.opengl.GL11;
import static org.lwjgl.opengl.GL11.GL_ONE_MINUS_SRC_ALPHA;
import static org.lwjgl.opengl.GL11.GL_SRC_ALPHA;
public class CustomOverlayLine extends Gui implements IOverlayComponent {
OverlayCustom parent;
int alignment;
int id;
int x1;
int y1;
int x2;
int y2;
int color;
int thickness;
float alpha;
float rotation;
public CustomOverlayLine(int id, int x1, int y1, int x2, int y2, int color, int thickness){
this.id = id;
this.x1 = x1;
this.y1 = y1;
this.x2 = x2;
this.y2 = y2;
this.color = color;
this.thickness = thickness;
}
public void setParent(OverlayCustom parent) {
this.parent = parent;
}
public int getID() {
return this.id;
}
public void onRender(Minecraft mc, float partialTicks) {
double distance = Math.hypot(x1-x2, y1-y2);
mc.getTextureManager().bindTexture(new ResourceLocation("customnpcs:textures/gui/misc.png"));
GL11.glPushMatrix();
float red = (color >> 16 & 255) / 255f;
float green = (color >> 8 & 255) / 255f;
float blue = (color & 255) / 255f;
GL11.glTranslatef(this.alignment%3*((float)(OverlayCustom.scaledWidth)/2), (float) (Math.floor((float)(alignment/3))*((float)(OverlayCustom.scaledHeight)/2)),0.0F);//alignment%3 * width/2 Math.floor(alignment/3) * height/2
GL11.glTranslatef(this.x1,this.y1,0.0F);
GL11.glRotated(-Math.toDegrees(Math.atan2(x2-x1,y2-y1)),0.0F,0.0F,1.0F);
GL11.glRotated(rotation,0.0D,0.0D,1.0D);
GL11.glScaled(thickness, distance,0.0D);
int p_73729_1_ = 0;
int p_73729_2_ = 0;
int p_73729_3_ = 0;
int p_73729_4_ = 0;
int p_73729_5_ = 1;
int p_73729_6_ = 1;
float f = 0.00390625F;
float f1 = 0.00390625F;
Tessellator tessellator = Tessellator.instance;
tessellator.startDrawingQuads();
tessellator.setColorOpaque_F(1, 1, 1);
tessellator.setColorRGBA_F(red, green, blue, alpha);
tessellator.addVertexWithUV((double)(p_73729_1_ + 0), (double)(p_73729_2_ + p_73729_6_), (double)this.zLevel, (double)((float)(p_73729_3_ + 0) * f), (double)((float)(p_73729_4_ + p_73729_6_) * f1));
tessellator.addVertexWithUV((double)(p_73729_1_ + p_73729_5_), (double)(p_73729_2_ + p_73729_6_), (double)this.zLevel, (double)((float)(p_73729_3_ + p_73729_5_) * f), (double)((float)(p_73729_4_ + p_73729_6_) * f1));
tessellator.addVertexWithUV((double)(p_73729_1_ + p_73729_5_), (double)(p_73729_2_ + 0), (double)this.zLevel, (double)((float)(p_73729_3_ + p_73729_5_) * f), (double)((float)(p_73729_4_ + 0) * f1));
tessellator.addVertexWithUV((double)(p_73729_1_ + 0), (double)(p_73729_2_ + 0), (double)this.zLevel, (double)((float)(p_73729_3_ + 0) * f), (double)((float)(p_73729_4_ + 0) * f1));
tessellator.draw();
GL11.glPopMatrix();
}
public ICustomOverlayComponent toComponent() {
ScriptOverlayLine line = new ScriptOverlayLine(this.id, this.x1,this.y1,this.x2,this.y2,this.color,this.thickness);
line.setAlignment(alignment);
line.setAlpha(alpha);
line.setColor(color);
line.setRotation(rotation);
return line;
}
public static CustomOverlayLine fromComponent(ScriptOverlayLine component) {
CustomOverlayLine line = new CustomOverlayLine(component.getID(), component.getX1(), component.getY1(), component.getX2(), component.getY2(), component.getColor(), component.getThickness());
line.alignment = component.getAlignment();
line.alpha = component.getAlpha();
line.color = component.getColor();
line.rotation = component.getRotation();
return line;
}
}
@@ -0,0 +1,132 @@
package noppes.npcs.client.gui.customoverlay.components;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.texture.ITextureObject;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.client.resources.SkinManager;
import net.minecraft.util.ResourceLocation;
import noppes.npcs.client.ImageDownloadAlt;
import noppes.npcs.client.gui.customoverlay.OverlayCustom;
import noppes.npcs.client.gui.customoverlay.interfaces.IOverlayComponent;
import noppes.npcs.client.renderer.ImageBufferDownloadAlt;
import noppes.npcs.scripted.interfaces.ICustomOverlayComponent;
import noppes.npcs.scripted.overlay.ScriptOverlayTexturedRect;
import org.lwjgl.opengl.GL11;
import static org.lwjgl.opengl.GL11.*;
import static org.lwjgl.opengl.GL14.glBlendFuncSeparate;
public class CustomOverlayTexturedRect extends Gui implements IOverlayComponent {
OverlayCustom parent;
int alignment;
int id;
ResourceLocation texture;
int x;
int y;
int width;
int height;
int textureX;
int textureY;
float scale;
int color;
float alpha;
float rotation;
public CustomOverlayTexturedRect(int id, String texture, int x, int y, int width, int height) {
this(id, texture, x, y, width, height, 0, 0);
}
public CustomOverlayTexturedRect(int id, String texture, int x, int y, int width, int height, int textureX, int textureY) {
this.scale = 1.0F;
this.alignment = 0;
this.id = id;
this.texture = new ResourceLocation(texture);
this.x = x;
this.y = y;
this.width = width;
this.height = height;
this.textureX = textureX;
this.textureY = textureY;
if(texture.startsWith("https://")){
TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager();
ITextureObject object = new ImageDownloadAlt(null, texture, SkinManager.field_152793_a, new ImageBufferDownloadAlt(false));
texturemanager.loadTexture(this.texture, object);
}
}
public void setParent(OverlayCustom parent) {
this.parent = parent;
}
public int getID() {
return this.id;
}
public void onRender(Minecraft mc, float partialTicks) {
mc.getTextureManager().bindTexture(this.texture);
GL11.glPushMatrix();
float red = (color >> 16 & 255) / 255f;
float green = (color >> 8 & 255) / 255f;
float blue = (color & 255) / 255f;
GL11.glTranslatef(this.alignment%3*((float)(OverlayCustom.scaledWidth)/2), (float) (Math.floor((float)(alignment/3))*((float)(OverlayCustom.scaledHeight)/2)),0.0F);//alignment%3 * width/2 Math.floor(alignment/3) * height/2
GL11.glScalef(this.scale, this.scale, this.scale);
GL11.glRotatef(this.rotation,0.0F,0.0F,1.0F);
int p_73729_1_ = (int) (this.x/this.scale);
int p_73729_2_ = (int) (this.y/this.scale);
int p_73729_3_ = this.textureX;
int p_73729_4_ = this.textureY;
int p_73729_5_ = (int)(this.width);
int p_73729_6_ = (int)(this.height);
float f = 0.00390625F;
float f1 = 0.00390625F;
Tessellator tessellator = Tessellator.instance;
tessellator.startDrawingQuads();
tessellator.setColorOpaque_F(1, 1, 1);
tessellator.setColorRGBA_F(red, green, blue, alpha);
tessellator.addVertexWithUV((double)(p_73729_1_ + 0), (double)(p_73729_2_ + p_73729_6_), (double)this.zLevel, (double)((float)(p_73729_3_ + 0) * f), (double)((float)(p_73729_4_ + p_73729_6_) * f1));
tessellator.addVertexWithUV((double)(p_73729_1_ + p_73729_5_), (double)(p_73729_2_ + p_73729_6_), (double)this.zLevel, (double)((float)(p_73729_3_ + p_73729_5_) * f), (double)((float)(p_73729_4_ + p_73729_6_) * f1));
tessellator.addVertexWithUV((double)(p_73729_1_ + p_73729_5_), (double)(p_73729_2_ + 0), (double)this.zLevel, (double)((float)(p_73729_3_ + p_73729_5_) * f), (double)((float)(p_73729_4_ + 0) * f1));
tessellator.addVertexWithUV((double)(p_73729_1_ + 0), (double)(p_73729_2_ + 0), (double)this.zLevel, (double)((float)(p_73729_3_ + 0) * f), (double)((float)(p_73729_4_ + 0) * f1));
tessellator.draw();
GL11.glPopMatrix();
}
public ICustomOverlayComponent toComponent() {
ScriptOverlayTexturedRect component = new ScriptOverlayTexturedRect(this.id, this.texture.toString(), this.x, this.y, this.width, this.height, this.textureX, this.textureY);
component.setScale(scale);
component.setAlignment(alignment);
component.setAlpha(alpha);
component.setColor(color);
component.setRotation(rotation);
return component;
}
public static CustomOverlayTexturedRect fromComponent(ScriptOverlayTexturedRect component) {
CustomOverlayTexturedRect rect;
if (component.getTextureX() >= 0 && component.getTextureY() >= 0) {
rect = new CustomOverlayTexturedRect(component.getID(), component.getTexture(), component.getPosX(), component.getPosY(), component.getWidth(), component.getHeight(), component.getTextureX(), component.getTextureY());
} else {
rect = new CustomOverlayTexturedRect(component.getID(), component.getTexture(), component.getPosX(), component.getPosY(), component.getWidth(), component.getHeight());
}
rect.scale = component.getScale();
rect.alignment = component.getAlignment();
rect.alpha = component.getAlpha();
rect.color = component.getColor();
rect.rotation = component.getRotation();
return rect;
}
}
@@ -0,0 +1,7 @@
package noppes.npcs.client.gui.customoverlay.interfaces;
import net.minecraft.client.Minecraft;
public interface IOverlayComponent {
void onRender(Minecraft mc, float partialTicks);
}
@@ -7,7 +7,6 @@ import net.minecraft.client.gui.GuiButton;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.client.Client; import noppes.npcs.client.Client;
import noppes.npcs.client.CustomNpcResourceListener; import noppes.npcs.client.CustomNpcResourceListener;
import noppes.npcs.client.NoppesUtil;
import noppes.npcs.client.gui.util.GuiContainerNPCInterface2; import noppes.npcs.client.gui.util.GuiContainerNPCInterface2;
import noppes.npcs.client.gui.util.GuiCustomScroll; import noppes.npcs.client.gui.util.GuiCustomScroll;
import noppes.npcs.client.gui.util.ICustomScrollListener; import noppes.npcs.client.gui.util.ICustomScrollListener;
@@ -63,11 +62,11 @@ public class GuiNPCManageBanks extends GuiContainerNPCInterface2 implements IScr
getTextField(0).setMaxStringLength(20); getTextField(0).setMaxStringLength(20);
addTextField(new GuiNpcTextField(1,this, this.fontRendererObj, guiLeft+10, guiTop + 80, 16, 16, "")); addTextField(new GuiNpcTextField(1,this, this.fontRendererObj, guiLeft+10, guiTop + 80, 16, 16, ""));
getTextField(1).numbersOnly = true; getTextField(1).integersOnly = true;
getTextField(1).setMaxStringLength(1); getTextField(1).setMaxStringLength(1);
addTextField(new GuiNpcTextField(2,this, this.fontRendererObj, guiLeft+10, guiTop + 110, 16, 16, "")); addTextField(new GuiNpcTextField(2,this, this.fontRendererObj, guiLeft+10, guiTop + 110, 16, 16, ""));
getTextField(2).numbersOnly = true; getTextField(2).integersOnly = true;
getTextField(2).setMaxStringLength(1); getTextField(2).setMaxStringLength(1);
} }
@@ -32,8 +32,8 @@ public class GuiNpcQuestReward extends GuiContainerNPCInterface implements IText
addLabel(new GuiNpcLabel(1, "quest.exp", guiLeft + 4, guiTop + 45)); addLabel(new GuiNpcLabel(1, "quest.exp", guiLeft + 4, guiTop + 45));
addTextField(new GuiNpcTextField(0, this, this.fontRendererObj, guiLeft + 4, guiTop + 55, 60, 20, quest.rewardExp + "")); addTextField(new GuiNpcTextField(0, this, this.fontRendererObj, guiLeft + 4, guiTop + 55, 60, 20, quest.rewardExp + ""));
getTextField(0).numbersOnly = true; getTextField(0).integersOnly = true;
getTextField(0).setMinMaxDefault(0, 99999, 0); getTextField(0).setMinMaxDefault(0, Integer.MAX_VALUE, 0);
} }
public void actionPerformed(GuiButton guibutton){ public void actionPerformed(GuiButton guibutton){
@@ -6,30 +6,30 @@ import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot; import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.IIcon;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector; import net.minecraft.util.StatCollector;
import noppes.npcs.client.Client; import noppes.npcs.client.Client;
import noppes.npcs.client.NoppesUtil; import noppes.npcs.client.gui.util.*;
import noppes.npcs.client.gui.util.GuiContainerNPCInterface2;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.GuiNpcSlider;
import noppes.npcs.client.gui.util.GuiNpcTextField;
import noppes.npcs.client.gui.util.IGuiData;
import noppes.npcs.client.gui.util.ISliderListener;
import noppes.npcs.constants.EnumPacketServer; import noppes.npcs.constants.EnumPacketServer;
import noppes.npcs.containers.ContainerNPCInv; import noppes.npcs.containers.ContainerNPCInv;
import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.entity.EntityNPCInterface;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
public class GuiNPCInv extends GuiContainerNPCInterface2 implements ISliderListener, IGuiData public class GuiNPCInv extends GuiContainerNPCInterface2 implements IGuiData, ITextfieldListener
{ {
private HashMap<Integer,Integer> chances = new HashMap<Integer, Integer>(); private HashMap<Integer,Double> chances = new HashMap<Integer, Double>();
private ContainerNPCInv container; private ContainerNPCInv container;
private ResourceLocation slot; private ResourceLocation slot;
private int inventoryTab = 0;
public GuiNPCInv(EntityNPCInterface npc,ContainerNPCInv container) public GuiNPCInv(EntityNPCInterface npc,ContainerNPCInv container)
{ {
super(npc,container,3); super(npc,container,3);
@@ -45,37 +45,71 @@ public class GuiNPCInv extends GuiContainerNPCInterface2 implements ISliderListe
super.initGui(); super.initGui();
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).numbersOnly = true; getTextField(0).integersOnly = true;
getTextField(0).setMinMaxDefault(0, Short.MAX_VALUE, 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).numbersOnly = true; getTextField(1).integersOnly = true;
getTextField(1).setMinMaxDefault(0, 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));
addLabel(new GuiNpcLabel(3,"inv.inventory", guiLeft + 8, guiTop + 101)); addLabel(new GuiNpcLabel(3,"inv.inventory", guiLeft + 8, guiTop + 101));
for(int i = 0; i < 9; i++){ addLabel(new GuiNpcLabel(4,"Tab", guiLeft + 381, guiTop + 5));
int chance = 100; addButton(new GuiNpcButton(11, guiLeft + 375, guiTop + 13, 30, 20, "1"));
if(npc.inventory.dropchance.containsKey(i)){ addButton(new GuiNpcButton(12, guiLeft + 375, guiTop + 34, 30, 20, "2"));
chance = npc.inventory.dropchance.get(i);
} for(int c = 0; c < 4; c++) {
if(chance <= 0 || chance > 100) for (int r = 0; r < 9; r++) {
chance = 100; double chance = 100;
chances.put(i, chance); if (npc.inventory.dropchance.containsKey(r + c*9)) {
GuiNpcSlider slider = new GuiNpcSlider(this, i, guiLeft + 211, guiTop + 14 + i * 21, ((float)chance)/100); chance = npc.inventory.dropchance.get(r + c*9);
addSlider(slider); }
if (chance <= 0 || chance > 100)
chance = 100;
chances.put(r + c*9, chance);
if(Math.floor((float)c/2) != this.inventoryTab) {
container.getSlot(r + c*9 + 7).xDisplayPosition = 10000;
container.getSlot(r + c*9 + 7).yDisplayPosition = 10000;
continue;
} else {
container.getSlot(r + c*9 + 7).xDisplayPosition = 191 + (c-this.inventoryTab*2) * 90;
container.getSlot(r + c*9 + 7).yDisplayPosition = 16 + r * 21;
}
GuiNpcTextField textField = new GuiNpcTextField(2 + r + c*9, this, fontRendererObj, guiLeft + 210 + (c-this.inventoryTab*2)*90, guiTop + 14 + r * 21, 60, 18, chance + "");
addLabel(new GuiNpcLabel(c*9 + r + 5,"%", guiLeft + 272 + (c-this.inventoryTab*2)*90, guiTop + 16 + r * 21));
textField.doublesOnly = true;
textField.setMinMaxDefaultDouble(0, 100, 100);
addTextField(textField);
}
} }
} }
private void drawSlot(int x, int y)
{
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_BLEND); // Forge: Blending needs to be enabled for this.
this.mc.getTextureManager().bindTexture(slot);
this.drawTexturedModalRect(x, y, 0,0,18, 18);
GL11.glDisable(GL11.GL_BLEND); // Forge: And clean that up
GL11.glEnable(GL11.GL_LIGHTING);
}
@Override @Override
protected void actionPerformed(GuiButton guibutton) { protected void actionPerformed(GuiButton guibutton) {
if(guibutton.id == 10){ if(guibutton.id == 10){
npc.inventory.lootMode = ((GuiNpcButton)guibutton).getValue(); npc.inventory.lootMode = ((GuiNpcButton)guibutton).getValue();
} }
if(guibutton.id == 11 || guibutton.id == 12){
this.inventoryTab = Integer.parseInt(guibutton.displayString)-1;
initGui();
}
} }
protected void drawGuiContainerBackgroundLayer(float f, int i, int j) protected void drawGuiContainerBackgroundLayer(float f, int i, int j)
@@ -83,12 +117,18 @@ public class GuiNPCInv extends GuiContainerNPCInterface2 implements ISliderListe
super.drawGuiContainerBackgroundLayer(f, i, j); super.drawGuiContainerBackgroundLayer(f, i, j);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
mc.renderEngine.bindTexture(slot); mc.renderEngine.bindTexture(slot);
for(int id = 4; id <= 6;id++){ for(int id = 4; id <= 6;id++){
Slot slot = container.getSlot(id); Slot slot = container.getSlot(id);
if(slot.getHasStack()) if(slot.getHasStack())
drawTexturedModalRect(guiLeft + slot.xDisplayPosition - 1, guiTop + slot.yDisplayPosition -1, 0, 0, 18, 18); drawTexturedModalRect(guiLeft + slot.xDisplayPosition - 1, guiTop + slot.yDisplayPosition -1, 0, 0, 18, 18);
} }
for(int c = 0; c < 2; c++) {
for (int r = 0; r < 9; r++) {
this.drawSlot(guiLeft + 190 + c*90, guiTop + 15 + r * 21);
}
}
} }
public void drawScreen(int i, int j, float f) public void drawScreen(int i, int j, float f)
{ {
@@ -150,18 +190,14 @@ public class GuiNPCInv extends GuiContainerNPCInterface2 implements ISliderListe
npc.inventory.readEntityFromNBT(compound); npc.inventory.readEntityFromNBT(compound);
initGui(); initGui();
} }
@Override @Override
public void mouseDragged(GuiNpcSlider guiNpcSlider) { public void unFocused(GuiNpcTextField textfield) {
guiNpcSlider.displayString = StatCollector.translateToLocal("inv.dropChance") + ": " + (int) (guiNpcSlider.sliderValue * 100) + "%"; if(textfield.id >= 2){
} chances.put(textfield.id-2, Double.parseDouble(textfield.getText()));
}
@Override getTextField(0).setMinMaxDefault(0, getTextField(1).getInteger(), 0);
public void mousePressed(GuiNpcSlider guiNpcSlider) { getTextField(1).setMinMaxDefault(getTextField(0).getInteger(), Short.MAX_VALUE, 0);
} this.save();
}
@Override
public void mouseReleased(GuiNpcSlider guiNpcSlider) {
chances.put(guiNpcSlider.id, (int) (guiNpcSlider.sliderValue * 100));
}
} }
@@ -52,7 +52,7 @@ public class GuiNpcAI extends GuiNPCInterface2 implements ITextfieldListener, IG
if (ai.useRangeMelee >= 1){ if (ai.useRangeMelee >= 1){
addLabel(new GuiNpcLabel(20,"gui.minrange", guiLeft + 300, guiTop + 115)); addLabel(new GuiNpcLabel(20,"gui.minrange", guiLeft + 300, guiTop + 115));
addTextField(new GuiNpcTextField(6,this, fontRendererObj, guiLeft + 380, guiTop + 110, 30, 20, ai.distanceToMelee + "")); addTextField(new GuiNpcTextField(6,this, fontRendererObj, guiLeft + 380, guiTop + 110, 30, 20, ai.distanceToMelee + ""));
getTextField(6).numbersOnly = true; getTextField(6).integersOnly = true;
getTextField(6).setMinMaxDefault(1, npc.stats.aggroRange, 5); getTextField(6).setMinMaxDefault(1, npc.stats.aggroRange, 5);
} }
addLabel(new GuiNpcLabel(19,"ai.tacticalvariant", guiLeft + 150, guiTop + 140)); addLabel(new GuiNpcLabel(19,"ai.tacticalvariant", guiLeft + 150, guiTop + 140));
@@ -70,7 +70,7 @@ public class GuiNpcAI extends GuiNPCInterface2 implements ITextfieldListener, IG
} }
addLabel(new GuiNpcLabel(21, label, guiLeft + 300, guiTop + 140)); addLabel(new GuiNpcLabel(21, label, guiLeft + 300, guiTop + 140));
addTextField(new GuiNpcTextField(3,this, fontRendererObj, guiLeft + 380, guiTop + 135, 30, 20, ai.tacticalRadius + "")); addTextField(new GuiNpcTextField(3,this, fontRendererObj, guiLeft + 380, guiTop + 135, 30, 20, ai.tacticalRadius + ""));
getTextField(3).numbersOnly = true; getTextField(3).integersOnly = true;
getTextField(3).setMinMaxDefault(1, npc.stats.aggroRange, 5); getTextField(3).setMinMaxDefault(1, npc.stats.aggroRange, 5);
} }
@@ -141,7 +141,7 @@ public class GuiNpcAI extends GuiNPCInterface2 implements ITextfieldListener, IG
} }
else if (button.id == 17) { else if (button.id == 17) {
ai.tacticalVariant = EnumNavType.values()[button.getValue()]; ai.tacticalVariant = EnumNavType.values()[button.getValue()];
ai.directLOS = EnumNavType.values()[button.getValue()] == EnumNavType.Stalk ? false : this.ai.directLOS; ai.directLOS = EnumNavType.values()[button.getValue()] != EnumNavType.Stalk && this.ai.directLOS;
initGui(); initGui();
} }
else if (button.id == 22) { else if (button.id == 22) {
@@ -4,6 +4,7 @@ import com.mojang.authlib.GameProfile;
import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiButton;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.CustomNpcs;
import noppes.npcs.DataDisplay; import noppes.npcs.DataDisplay;
import noppes.npcs.client.Client; import noppes.npcs.client.Client;
import noppes.npcs.client.NoppesUtil; import noppes.npcs.client.NoppesUtil;
@@ -55,9 +56,9 @@ public class GuiNpcDisplay extends GuiNPCInterface2 implements ITextfieldListene
this.addButton(new GuiNpcButton(1, guiLeft + 50, y,110,20, "selectServer.edit")); this.addButton(new GuiNpcButton(1, guiLeft + 50, y,110,20, "selectServer.edit"));
addLabel(new GuiNpcLabel(2,"display.size", guiLeft + 175, y + 5)); addLabel(new GuiNpcLabel(2,"display.size", guiLeft + 175, y + 5));
addTextField(new GuiNpcTextField(2,this, fontRendererObj, guiLeft + 203, y, 40, 20, display.modelSize + "")); addTextField(new GuiNpcTextField(2,this, fontRendererObj, guiLeft + 203, y, 40, 20, display.modelSize + ""));
getTextField(2).numbersOnly = true; getTextField(2).integersOnly = true;
getTextField(2).setMinMaxDefault(1, 30, 5); getTextField(2).setMinMaxDefault(1, CustomNpcs.NpcSizeLimit, 5);
addLabel(new GuiNpcLabel(3,"(1-30)", guiLeft + 246 , y + 5)); //addLabel(new GuiNpcLabel(3,"(1-30)", guiLeft + 246 , y + 5));
y+=23; y+=23;
addLabel(new GuiNpcLabel(4,"display.texture", guiLeft + 5, y + 5)); addLabel(new GuiNpcLabel(4,"display.texture", guiLeft + 5, y + 5));
@@ -82,6 +83,9 @@ public class GuiNpcDisplay extends GuiNPCInterface2 implements ITextfieldListene
addLabel(new GuiNpcLabel(5,"display.livingAnimation", guiLeft + 5, y + 5)); addLabel(new GuiNpcLabel(5,"display.livingAnimation", guiLeft + 5, y + 5));
this.addButton(new GuiNpcButton(5, guiLeft + 120, y, 50, 20, new String[]{"gui.yes","gui.no"}, display.disableLivingAnimation?1:0)); this.addButton(new GuiNpcButton(5, guiLeft + 120, y, 50, 20, new String[]{"gui.yes","gui.no"}, display.disableLivingAnimation?1:0));
addLabel(new GuiNpcLabel(6,"Collides With Entities", guiLeft + 185, y + 5));
this.addButton(new GuiNpcButton(6, guiLeft + 300, y, 100, 20, new String[]{"gui.yes","gui.no","Only CNPCs","Only Players","CNPCs & Players"}, display.collidesWith));
y+=23; y+=23;
addLabel(new GuiNpcLabel(7,"display.visible", guiLeft + 5, y + 5)); addLabel(new GuiNpcLabel(7,"display.visible", guiLeft + 5, y + 5));
this.addButton(new GuiNpcButton(7, guiLeft + 120, y, 50, 20, new String[]{"gui.yes","gui.no","gui.partly"}, display.visible)); this.addButton(new GuiNpcButton(7, guiLeft + 120, y, 50, 20, new String[]{"gui.yes","gui.no","gui.partly"}, display.visible));
@@ -155,6 +159,9 @@ public class GuiNpcDisplay extends GuiNPCInterface2 implements ITextfieldListene
else if(button.id == 5){ else if(button.id == 5){
display.disableLivingAnimation = button.getValue() == 1; display.disableLivingAnimation = button.getValue() == 1;
} }
else if(button.id == 6){
display.collidesWith = button.getValue();
}
else if(button.id == 7){ else if(button.id == 7){
display.visible = button.getValue(); display.visible = button.getValue();
} }
@@ -33,39 +33,40 @@ public class GuiNpcStats extends GuiNPCInterface2 implements ITextfieldListener,
super.initGui(); super.initGui();
int y = guiTop + 10; int y = guiTop + 10;
addLabel(new GuiNpcLabel(0,"stats.health", guiLeft + 5, y + 5)); addLabel(new GuiNpcLabel(0,"stats.health", guiLeft + 5, y + 5));
addTextField(new GuiNpcTextField(0,this, guiLeft + 85, y, 50, 18, stats.maxHealth+"")); addTextField(new GuiNpcTextField(0,this, guiLeft + 85, y, 50, 18, String.format("%.0f", stats.maxHealth) + ""));
getTextField(0).numbersOnly = true; getTextField(0).doublesOnly = true;
getTextField(0).setMinMaxDefault(1, Integer.MAX_VALUE, 20); getTextField(0).setMinMaxDefaultDouble(0, Double.MAX_VALUE,20);
addLabel(new GuiNpcLabel(1,"stats.aggro", guiLeft + 140, y + 5)); addLabel(new GuiNpcLabel(1,"stats.aggro", guiLeft + 140, y + 5));
addTextField(new GuiNpcTextField(1, this, fontRendererObj, guiLeft + 220, y, 50, 18, stats.aggroRange+"")); addTextField(new GuiNpcTextField(1, this, fontRendererObj, guiLeft + 220, y, 50, 18, stats.aggroRange+""));
getTextField(1).numbersOnly = true; getTextField(1).integersOnly = true;
getTextField(1).setMinMaxDefault(1, 64, 2); getTextField(1).setMinMaxDefault(1, 96, 2); // Doesn't work past 32 technically (MC Limitations)
addLabel(new GuiNpcLabel(34,"stats.creaturetype", guiLeft + 275, y + 5)); addLabel(new GuiNpcLabel(34,"stats.creaturetype", guiLeft + 275, y + 5));
addButton(new GuiNpcButton(8,guiLeft + 355, y, 56, 20, new String[]{"stats.normal","stats.undead","stats.arthropod"} ,stats.creatureType.ordinal())); addButton(new GuiNpcButton(8,guiLeft + 355, y, 56, 20, new String[]{"stats.normal","stats.undead","stats.arthropod"} ,stats.creatureType.ordinal()));
addButton(new GuiNpcButton(0,guiLeft + 82, y+=22, 56, 20, "selectServer.edit")); addButton(new GuiNpcButton(0,guiLeft + 82, y+=22, 56, 20, "selectServer.edit"));
addLabel(new GuiNpcLabel(2,"stats.respawn", guiLeft + 5, y + 5)); addLabel(new GuiNpcLabel(2,"stats.respawn", guiLeft + 5, y + 5));
this.addButton(new GuiNpcButton(2, guiLeft + 82, y+=22, 56, 20, "selectServer.edit")); this.addButton(new GuiNpcButton(2, guiLeft + 82, y+=22, 56, 20, "selectServer.edit"));
addLabel(new GuiNpcLabel(5,"stats.meleeproperties", guiLeft + 5, y + 5)); addLabel(new GuiNpcLabel(5,"stats.meleeproperties", guiLeft + 5, y + 5));
this.addButton(new GuiNpcButton(3, guiLeft + 82, y+=22, 56, 20, "selectServer.edit")); this.addButton(new GuiNpcButton(3, guiLeft + 82, y+=22, 56, 20, "selectServer.edit"));
addLabel(new GuiNpcLabel(6,"stats.rangedproperties", guiLeft + 5, y + 5)); addLabel(new GuiNpcLabel(6,"stats.rangedproperties", guiLeft + 5, y + 5));
this.addButton(new GuiNpcButton(9, guiLeft + 217, y, 56, 20, "selectServer.edit")); this.addButton(new GuiNpcButton(9, guiLeft + 217, y, 56, 20, "selectServer.edit"));
addLabel(new GuiNpcLabel(7,"stats.projectileproperties", guiLeft + 140, y + 5)); addLabel(new GuiNpcLabel(7,"stats.projectileproperties", guiLeft + 140, y + 5));
this.addButton(new GuiNpcButton(15, guiLeft + 82, y+=34, 56, 20, "selectServer.edit"));
addLabel(new GuiNpcLabel(15,"potion.resistance", guiLeft + 5, y + 5));
this.addButton(new GuiNpcButton(15, guiLeft + 82, y+=34, 56, 20, "selectServer.edit"));
addButton(new GuiNpcButton(4,guiLeft + 82, y+=34, 56, 20, new String[]{"gui.no","gui.yes"} ,npc.isImmuneToFire()? 1:0)); addLabel(new GuiNpcLabel(15,"potion.resistance", guiLeft + 5, y + 5));
this.addButton(new GuiNpcButton(21, guiLeft + 217, y, 56, 20, new String[]{"gui.no","gui.yes"}, this.stats.resistances.disableDamage? 1:0));
addLabel(new GuiNpcLabel(21,"stats.disabledamage", guiLeft + 140, y + 5));
addButton(new GuiNpcButton(4,guiLeft + 82, y+=34, 56, 20, new String[]{"gui.no","gui.yes"} ,npc.isImmuneToFire()? 1:0));
addLabel(new GuiNpcLabel(10,"stats.fireimmune", guiLeft + 5, y + 5)); addLabel(new GuiNpcLabel(10,"stats.fireimmune", guiLeft + 5, y + 5));
addButton(new GuiNpcButton(5,guiLeft + 217, y, 56, 20, new String[]{"gui.no","gui.yes"} ,stats.canDrown? 1:0)); addButton(new GuiNpcButton(5,guiLeft + 217, y, 56, 20, new String[]{"gui.no","gui.yes"} ,stats.canDrown? 1:0));
addLabel(new GuiNpcLabel(11,"stats.candrown", guiLeft + 140, y + 5)); addLabel(new GuiNpcLabel(11,"stats.candrown", guiLeft + 140, y + 5));
addTextField(new GuiNpcTextField(14, this, guiLeft + 355, y, 56, 20, stats.healthRegen + "").setNumbersOnly()); addTextField(new GuiNpcTextField(14, this, guiLeft + 355, y, 56, 20, String.format("%.0f", stats.healthRegen) + "").setFloatsOnly());
addLabel(new GuiNpcLabel(14,"stats.regenhealth", guiLeft + 275, y + 5)); addLabel(new GuiNpcLabel(14,"stats.regenhealth", guiLeft + 275, y + 5));
addTextField(new GuiNpcTextField(16, this, guiLeft + 355, y+=22, 56, 20, stats.combatRegen + "").setNumbersOnly()); addTextField(new GuiNpcTextField(16, this, guiLeft + 355, y+=22, 56, 20, String.format("%.0f", stats.combatRegen) + "").setFloatsOnly());
addLabel(new GuiNpcLabel(16,"stats.combatregen", guiLeft + 275, y + 5)); addLabel(new GuiNpcLabel(16,"stats.combatregen", guiLeft + 275, y + 5));
addButton(new GuiNpcButton(6,guiLeft + 82, y, 56, 20, new String[]{"gui.no","gui.yes"} ,stats.burnInSun? 1:0)); addButton(new GuiNpcButton(6,guiLeft + 82, y, 56, 20, new String[]{"gui.no","gui.yes"} ,stats.burnInSun? 1:0));
addLabel(new GuiNpcLabel(12,"stats.burninsun", guiLeft + 5, y + 5)); addLabel(new GuiNpcLabel(12,"stats.burninsun", guiLeft + 5, y + 5));
@@ -81,17 +82,17 @@ public class GuiNpcStats extends GuiNPCInterface2 implements ITextfieldListener,
@Override @Override
public void unFocused(GuiNpcTextField textfield){ public void unFocused(GuiNpcTextField textfield){
if(textfield.id == 0){ if(textfield.id == 0){
stats.maxHealth = textfield.getInteger(); stats.maxHealth = Math.floor(Double.parseDouble(textfield.getText()));
npc.heal(stats.maxHealth); npc.heal((float)(stats.maxHealth));
} }
else if(textfield.id == 1){ else if(textfield.id == 1){
stats.aggroRange = textfield.getInteger(); stats.aggroRange = textfield.getInteger();
} }
else if(textfield.id == 14){ else if(textfield.id == 14){
stats.healthRegen = textfield.getInteger(); stats.healthRegen = (float)(Math.floor(Float.parseFloat(textfield.getText())));
} }
else if(textfield.id == 16){ else if(textfield.id == 16){
stats.combatRegen = textfield.getInteger(); stats.combatRegen = (float)(Math.floor(Float.parseFloat(textfield.getText())));
} }
} }
@@ -134,6 +135,9 @@ public class GuiNpcStats extends GuiNPCInterface2 implements ITextfieldListener,
else if (button.id == 18) { else if (button.id == 18) {
stats.potionImmune = ((GuiNpcButtonYesNo)guibutton).getBoolean(); stats.potionImmune = ((GuiNpcButtonYesNo)guibutton).getBoolean();
} }
else if(button.id == 21){
stats.resistances.disableDamage = ((GuiNpcButton)guibutton).getValue() == 1;
}
} }
@Override @Override
public void save() { public void save() {
@@ -12,6 +12,7 @@ public class GuiModelArms extends GuiModelInterface{
private final String[] arrArm = new String[]{"gui.no","Both","Right","Left"}; private final String[] arrArm = new String[]{"gui.no","Both","Right","Left"};
private final String[] arrArmwear = new String[]{"gui.no","Both","Left","Right"}; private final String[] arrArmwear = new String[]{"gui.no","Both","Left","Right"};
private final String[] arrSolidArmwear = new String[]{"gui.no","Both","Left","Right"};
private final String[] arrClaws = new String[]{"gui.no","Both","Left","Right"}; private final String[] arrClaws = new String[]{"gui.no","Both","Left","Right"};
private GuiScreen parent; private GuiScreen parent;
@@ -32,6 +33,9 @@ public class GuiModelArms extends GuiModelInterface{
if (npc.display.modelType == 1 || npc.display.modelType == 2) { if (npc.display.modelType == 1 || npc.display.modelType == 2) {
addButton(new GuiNpcButton(8, guiLeft + 50, y += 22, 70, 20, arrArmwear, playerdata.armwear)); addButton(new GuiNpcButton(8, guiLeft + 50, y += 22, 70, 20, arrArmwear, playerdata.armwear));
addLabel(new GuiNpcLabel(8, "Armwear", guiLeft, y + 5, 0xFFFFFF)); addLabel(new GuiNpcLabel(8, "Armwear", guiLeft, y + 5, 0xFFFFFF));
addButton(new GuiNpcButton(9, guiLeft + 50, y += 22, 70, 20, arrSolidArmwear, playerdata.solidArmwear));
addLabel(new GuiNpcLabel(9, "Solid", guiLeft, y + 5, 0xFFFFFF));
} }
ModelPartData claws = playerdata.getPartData("claws"); ModelPartData claws = playerdata.getPartData("claws");
@@ -50,6 +54,9 @@ public class GuiModelArms extends GuiModelInterface{
if(button.id == 8){ if(button.id == 8){
playerdata.armwear = (byte) button.getValue(); playerdata.armwear = (byte) button.getValue();
} }
if(button.id == 9){
playerdata.solidArmwear = (byte) button.getValue();
}
if(button.id == 30){ if(button.id == 30){
playerdata.hideArms = (byte) button.getValue(); playerdata.hideArms = (byte) button.getValue();
} }
@@ -12,7 +12,7 @@ public class GuiModelBody extends GuiModelInterface{
private GuiScreen parent; private GuiScreen parent;
private final String[] arrBody = new String[]{"gui.no","gui.yes"}; private final String[] arrBody = new String[]{"gui.no","gui.yes"};
private final String[] arrBodywear = new String[]{"gui.no","gui.yes"}; private final String[] arrBodywear = new String[]{"gui.no","gui.yes","Solid"};
private final String[] arrWing = new String[]{"gui.no","Player","Type1","Type2","Type3","Type4","Type5","Type6","Type7","Type8","Type9", private final String[] arrWing = new String[]{"gui.no","Player","Type1","Type2","Type3","Type4","Type5","Type6","Type7","Type8","Type9",
"Type10","Type11","Type12","Type13"}; "Type10","Type11","Type12","Type13"};
private final String[] arrBreasts = new String[]{"gui.no","Type1","Type2","Type3"}; private final String[] arrBreasts = new String[]{"gui.no","Type1","Type2","Type3"};
@@ -13,6 +13,7 @@ public class GuiModelLegs extends GuiModelInterface{
private GuiScreen parent; private GuiScreen parent;
private final String[] arrLeg = new String[]{"gui.no","Both","Right","Left"}; private final String[] arrLeg = new String[]{"gui.no","Both","Right","Left"};
private final String[] arrLegwear = new String[]{"gui.no","Both","Left","Right"}; private final String[] arrLegwear = new String[]{"gui.no","Both","Left","Right"};
private final String[] arrSolidLegwear = new String[]{"gui.no","Both","Left","Right"};
private final String[] arrLegs = new String[]{"gui.no","Player","Player Naga","Spider","Horse","Naga", "Mermaid", "Mermaid 2", "Digitigrade"}; private final String[] arrLegs = new String[]{"gui.no","Player","Player Naga","Spider","Horse","Naga", "Mermaid", "Mermaid 2", "Digitigrade"};
private final String[] arrTail = new String[]{"gui.no","Player", "Player Dragon","Cat","Wolf","Horse","Dragon", "Squirrel", "Fin", "Rodent", "Feather"}; private final String[] arrTail = new String[]{"gui.no","Player", "Player Dragon","Cat","Wolf","Horse","Dragon", "Squirrel", "Fin", "Rodent", "Feather"};
public GuiModelLegs(GuiScreen parent, EntityCustomNpc npc){ public GuiModelLegs(GuiScreen parent, EntityCustomNpc npc){
@@ -32,6 +33,9 @@ public class GuiModelLegs extends GuiModelInterface{
if (npc.display.modelType == 1 || npc.display.modelType == 2) { if (npc.display.modelType == 1 || npc.display.modelType == 2) {
addButton(new GuiNpcButton(8, guiLeft + 50, y += 22, 70, 20, arrLegwear, playerdata.legwear)); addButton(new GuiNpcButton(8, guiLeft + 50, y += 22, 70, 20, arrLegwear, playerdata.legwear));
addLabel(new GuiNpcLabel(8, "Legwear", guiLeft, y + 5, 0xFFFFFF)); addLabel(new GuiNpcLabel(8, "Legwear", guiLeft, y + 5, 0xFFFFFF));
addButton(new GuiNpcButton(9, guiLeft + 50, y += 22, 70, 20, arrSolidLegwear, playerdata.solidLegwear));
addLabel(new GuiNpcLabel(9, "Solid", guiLeft, y + 5, 0xFFFFFF));
} }
addButton(new GuiNpcButton(1, guiLeft + 50, y += 22, 70, 20, arrLegs, getLegIndex(playerdata.legParts))); addButton(new GuiNpcButton(1, guiLeft + 50, y += 22, 70, 20, arrLegs, getLegIndex(playerdata.legParts)));
@@ -91,6 +95,9 @@ public class GuiModelLegs extends GuiModelInterface{
if(button.id == 8){ if(button.id == 8){
playerdata.legwear = (byte) button.getValue(); playerdata.legwear = (byte) button.getValue();
} }
if(button.id == 9){
playerdata.solidLegwear = (byte) button.getValue();
}
if(button.id == 30){ if(button.id == 30){
playerdata.hideLegs = (byte) button.getValue(); playerdata.hideLegs = (byte) button.getValue();
} }
@@ -64,6 +64,7 @@ public class GuiDialogInteract extends GuiNPCInterface implements IGuiClose
grabMouse(dialog.showWheel); grabMouse(dialog.showWheel);
guiTop = (height - ySize); guiTop = (height - ySize);
calculateRowHeight(); calculateRowHeight();
this.drawDefaultBackground = dialog.darkenScreen;
} }
public void grabMouse(boolean grab){ public void grabMouse(boolean grab){
@@ -240,7 +240,7 @@ public class GuiMailmanWrite extends GuiContainerNPCInterface implements ITextfi
*/ */
public void keyTyped(char par1, int par2) public void keyTyped(char par1, int par2)
{ {
if(!GuiNpcTextField.isActive() && canEdit) if(!GuiNpcTextField.isFieldActive() && canEdit)
this.keyTypedInBook(par1, par2); this.keyTypedInBook(par1, par2);
else else
super.keyTyped(par1, par2); super.keyTyped(par1, par2);
@@ -10,10 +10,8 @@ import net.minecraft.client.gui.GuiScreen;
import net.minecraft.entity.EntityList; import net.minecraft.entity.EntityList;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
import net.minecraft.world.World; import net.minecraft.world.World;
import noppes.npcs.client.NoppesUtil;
import noppes.npcs.client.gui.util.GuiCustomScroll; import noppes.npcs.client.gui.util.GuiCustomScroll;
import noppes.npcs.client.gui.util.ICustomScrollListener; import noppes.npcs.client.gui.util.ICustomScrollListener;
import noppes.npcs.client.gui.util.GuiNPCInterface;
import noppes.npcs.client.gui.util.GuiNpcButton; import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcLabel; import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.GuiNpcTextField; import noppes.npcs.client.gui.util.GuiNpcTextField;
@@ -39,29 +37,35 @@ public class GuiNpcQuestTypeKill extends SubGuiInterface implements ITextfieldLi
quest = (QuestKill) q.questInterface; quest = (QuestKill) q.questInterface;
setBackground("menubg.png"); setBackground("largebg.png");
xSize = 356; bgScale = 1.7F;
ySize = 216; bgScaleX = 1.1F;
xSize = 300;
ySize = 300;
closeOnEsc = true; closeOnEsc = true;
} }
public void initGui() { public void initGui() {
super.initGui(); super.initGui();
guiTop -= 20;
int i = 0; int i = 0;
addLabel(new GuiNpcLabel(0, "You can fill in npc or player names too", guiLeft + 4, guiTop + 50)); addLabel(new GuiNpcLabel(0, "You can fill in npc or player names too", guiLeft + 4, guiTop + 20));
for (String name : quest.targets.keySet()) { for (String name : quest.targets.keySet()) {
this.addTextField(new GuiNpcTextField(i, this, fontRendererObj, guiLeft + 4, guiTop + 70 + i * 22, 180, 20, name)); this.addTextField(new GuiNpcTextField(i, this, fontRendererObj, guiLeft + 4, guiTop + 40 + i * 22, 180, 20, name));
this.addTextField(new GuiNpcTextField(i + 3, this, fontRendererObj, guiLeft + 186, guiTop + 70 + i * 22, 24, 20, quest.targets.get(name) + "")); this.addTextField(new GuiNpcTextField(i + 12, this, fontRendererObj, guiLeft + 186, guiTop + 40 + i * 22, 24, 20, quest.targets.get(name) + ""));
this.getTextField(i+3).numbersOnly = true; this.getTextField(i+12).integersOnly = true;
this.getTextField(i+3).setMinMaxDefault(1, Integer.MAX_VALUE, 1); this.getTextField(i+12).setMinMaxDefault(1, Integer.MAX_VALUE, 1);
i++; i++;
} }
for(;i < 3; i++){ for(;i < 12; i++){
this.addTextField(new GuiNpcTextField(i, this, fontRendererObj, guiLeft + 4, guiTop + 70 + i * 22, 180, 20, "")); this.addTextField(new GuiNpcTextField(i, this, fontRendererObj, guiLeft + 4, guiTop + 40 + i * 22, 180, 20, ""));
this.addTextField(new GuiNpcTextField(i + 3, this, fontRendererObj, guiLeft + 186, guiTop + 70 + i * 22, 24, 20, "1")); this.addTextField(new GuiNpcTextField(i + 12, this, fontRendererObj, guiLeft + 186, guiTop + 40 + i * 22, 24, 20, "1"));
this.getTextField(i+3).numbersOnly = true; this.getTextField(i+12).integersOnly = true;
this.getTextField(i+3).setMinMaxDefault(1, Integer.MAX_VALUE, 1); this.getTextField(i+12).setMinMaxDefault(1, Integer.MAX_VALUE, 1);
} }
Map<?,?> data = EntityList.stringToClassMapping; Map<?,?> data = EntityList.stringToClassMapping;
ArrayList<String> list = new ArrayList<String>(); ArrayList<String> list = new ArrayList<String>();
@@ -80,11 +84,19 @@ public class GuiNpcQuestTypeKill extends SubGuiInterface implements ITextfieldLi
scroll.setList(list); scroll.setList(list);
scroll.setSize(130, 198); scroll.setSize(130, 198);
scroll.guiLeft = guiLeft + 220; scroll.guiLeft = guiLeft + 220;
scroll.guiTop = guiTop + 14; scroll.guiTop = guiTop + 40;
addScroll(scroll); addScroll(scroll);
this.addButton(new GuiNpcButton(0, guiLeft + 4, guiTop + 140, 98, 20, "gui.back"));
scroll.visible = GuiNpcTextField.isActive(); guiTop += 50;
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", "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;
scroll.visible = GuiNpcTextField.isFieldActive();
} }
protected void actionPerformed(GuiButton guibutton) { protected void actionPerformed(GuiButton guibutton) {
@@ -92,29 +104,36 @@ public class GuiNpcQuestTypeKill extends SubGuiInterface implements ITextfieldLi
if (guibutton.id == 0) { if (guibutton.id == 0) {
close(); close();
} }
if (guibutton.id == 1) {
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)
{ {
super.mouseClicked(i, j, k); super.mouseClicked(i, j, k);
scroll.visible = GuiNpcTextField.isActive(); scroll.visible = GuiNpcTextField.isFieldActive();
} }
public void save() { public void save() {
} }
@Override @Override
public void unFocused(GuiNpcTextField guiNpcTextField) { public void unFocused(GuiNpcTextField guiNpcTextField) {
if(guiNpcTextField.id < 3) if(guiNpcTextField.id < 12)
lastSelected = guiNpcTextField; lastSelected = guiNpcTextField;
if(guiNpcTextField.id == 36)
quest.customTargetType = guiNpcTextField.getText();
saveTargets(); saveTargets();
} }
private void saveTargets(){ private void saveTargets(){
HashMap<String,Integer> map = new HashMap<String,Integer>(); HashMap<String,Integer> map = new HashMap<String,Integer>();
for(int i = 0; i< 3; i++){ for(int i = 0; i< 12; i++){
String name = getTextField(i).getText(); String name = getTextField(i).getText();
if(name.isEmpty()) if(name.isEmpty())
continue; continue;
map.put(name, getTextField(i+3).getInteger()); map.put(name, getTextField(i+12).getInteger());
} }
quest.targets = map; quest.targets = map;
} }
@@ -39,16 +39,16 @@ public class GuiNpcBard extends GuiNPCInterface2
addLabel(new GuiNpcLabel(2,"bard.ondistance", guiLeft + 60, guiTop + 143)); addLabel(new GuiNpcLabel(2,"bard.ondistance", guiLeft + 60, guiTop + 143));
addTextField(new GuiNpcTextField(2,this, this.fontRendererObj, guiLeft+160, guiTop + 138, 40, 20, job.minRange + "")); addTextField(new GuiNpcTextField(2,this, this.fontRendererObj, guiLeft+160, guiTop + 138, 40, 20, job.minRange + ""));
getTextField(2).numbersOnly = true; getTextField(2).integersOnly = true;
getTextField(2).setMinMaxDefault(2, 64, 5); getTextField(2).setMinMaxDefault(2, Integer.MAX_VALUE, 5);
addLabel(new GuiNpcLabel(4,"bard.hasoff", guiLeft + 60, guiTop + 166)); addLabel(new GuiNpcLabel(4,"bard.hasoff", guiLeft + 60, guiTop + 166));
addButton(new GuiNpcButton(4, guiLeft + 160, guiTop + 161, 60, 20, new String[]{"gui.no","gui.yes"}, job.hasOffRange?1:0)); addButton(new GuiNpcButton(4, guiLeft + 160, guiTop + 161, 60, 20, new String[]{"gui.no","gui.yes"}, job.hasOffRange?1:0));
addLabel(new GuiNpcLabel(3,"bard.offdistance", guiLeft + 60, guiTop + 189)); addLabel(new GuiNpcLabel(3,"bard.offdistance", guiLeft + 60, guiTop + 189));
addTextField(new GuiNpcTextField(3,this, this.fontRendererObj, guiLeft+160, guiTop + 184, 40, 20, job.maxRange + "")); addTextField(new GuiNpcTextField(3,this, this.fontRendererObj, guiLeft+160, guiTop + 184, 40, 20, job.maxRange + ""));
getTextField(3).numbersOnly = true; getTextField(3).integersOnly = true;
getTextField(3).setMinMaxDefault(2, 64, 10); getTextField(3).setMinMaxDefault(2, Integer.MAX_VALUE, 10);
getLabel(3).enabled = job.hasOffRange; getLabel(3).enabled = job.hasOffRange;
getTextField(3).enabled = job.hasOffRange; getTextField(3).enabled = job.hasOffRange;
@@ -42,7 +42,7 @@ public class GuiNpcCompanion extends GuiNPCInterface2 implements ITextfieldListe
addLabel(new GuiNpcLabel(2, "companion.age", guiLeft + 4, y + 5)); addLabel(new GuiNpcLabel(2, "companion.age", guiLeft + 4, y + 5));
if(role.canAge){ if(role.canAge){
addTextField(new GuiNpcTextField(2, this, guiLeft + 162, y, 140, 20, role.ticksActive + "")); addTextField(new GuiNpcTextField(2, this, guiLeft + 162, y, 140, 20, role.ticksActive + ""));
getTextField(2).numbersOnly = true; getTextField(2).integersOnly = true;
getTextField(2).setMinMaxDefault(0, Integer.MAX_VALUE, 0); getTextField(2).setMinMaxDefault(0, Integer.MAX_VALUE, 0);
} }
@@ -48,19 +48,19 @@ public class GuiNpcConversation extends GuiNPCInterface2 implements ITextfieldLi
if(i > 0){ if(i > 0){
this.addTextField(new GuiNpcTextField(i + 14, this, this.fontRendererObj, guiLeft + 164 + offset, guiTop + 13 + i % 7 * 22, 30, 20, line.delay + "")); this.addTextField(new GuiNpcTextField(i + 14, this, this.fontRendererObj, guiLeft + 164 + offset, guiTop + 13 + i % 7 * 22, 30, 20, line.delay + ""));
this.getTextField(i + 14).numbersOnly = true; this.getTextField(i + 14).integersOnly = true;
this.getTextField(i + 14).setMinMaxDefault(5, 1000, 40); this.getTextField(i + 14).setMinMaxDefault(5, 1000, 40);
} }
} }
addLabel(new GuiNpcLabel(50, "conversation.delay", guiLeft + 202, guiTop + 175)); addLabel(new GuiNpcLabel(50, "conversation.delay", guiLeft + 202, guiTop + 175));
addTextField(new GuiNpcTextField(50, this, fontRendererObj, guiLeft + 260, guiTop + 170, 40, 20, job.generalDelay + "")); addTextField(new GuiNpcTextField(50, this, fontRendererObj, guiLeft + 260, guiTop + 170, 40, 20, job.generalDelay + ""));
getTextField(50).numbersOnly = true; getTextField(50).integersOnly = true;
getTextField(50).setMinMaxDefault(10, 1000000, 12000); getTextField(50).setMinMaxDefault(10, Integer.MAX_VALUE, 12000);
addLabel(new GuiNpcLabel(54, "gui.range", guiLeft + 202, guiTop + 196)); addLabel(new GuiNpcLabel(54, "gui.range", guiLeft + 202, guiTop + 196));
addTextField(new GuiNpcTextField(54, this, fontRendererObj, guiLeft + 260, guiTop + 191, 40, 20, job.range + "")); addTextField(new GuiNpcTextField(54, this, fontRendererObj, guiLeft + 260, guiTop + 191, 40, 20, job.range + ""));
getTextField(54).numbersOnly = true; getTextField(54).integersOnly = true;
getTextField(54).setMinMaxDefault(4, 60, 20); getTextField(54).setMinMaxDefault(4, Integer.MAX_VALUE, 20);
addLabel(new GuiNpcLabel(51, "quest.quest", guiLeft + 13, guiTop + 175)); addLabel(new GuiNpcLabel(51, "quest.quest", guiLeft + 13, guiTop + 175));
String title = job.questTitle; String title = job.questTitle;
Loaded 100 of 317 files, more files were not shown because too many files have changed in this diff. Show more