Compare commits

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

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

NoppesUtilPlayer:
-questCompletion() now saves player data right before its return statement.
2023-05-21 02:48:30 -05:00
Luis C.M dc42beee15 Merge branch 'dev' into patch
# Conflicts:
#	src/api
2023-05-20 21:15:14 -05:00
Luis C.M b49402f8bd Implemented ImageData object caching for custom GUI button & rect elements 2023-05-20 19:23:54 -05:00
Luis C.M 8df94aaf67 IDBCPlayer:
-Created separate mastery functions for racial and non-racial forms.
2023-05-20 16:13:15 -05:00
Luis C.M ed5cfad00d IDBCPlayer:
-Changed mastery functions to use a boolean for racial or non-racial forms.
2023-05-20 15:00:58 -05:00
Kam a9961ed740 Update to 1.8.4-beta 2023-05-19 14:29:08 -04:00
Kam 6700030890 Fix Animation on Players not finding body parts 2023-05-19 14:28:55 -04:00
Kam 02b44953cb Remove duplicate Quest Completed Message 2023-05-17 16:18:09 -04:00
Kam b8c3e9bef2 QuestData Null check for QuestKill 2023-05-17 12:21:38 -04:00
Kam 5b361d779f Fix Crate Crash 2023-05-17 11:43:43 -04:00
Kam 6df7d3643f Remove runTack() 2023-05-16 19:16:34 -04:00
Luis C.M e7ed34a591 Merge remote-tracking branch 'origin/dev' into dev 2023-05-16 18:02:19 -05:00
Kam a6cd55fcea Merge branch 'master' into patch 2023-05-16 17:46:42 -04:00
Kam 13b153d922 1.8.3 2023-05-16 17:46:34 -04:00
Kam f77a2ff101 Remove more threading 2023-05-16 17:45:23 -04:00
Kam 49fab85291 Revert lots of multithreading for better threaded saving and data synchronization 2023-05-16 17:43:54 -04:00
Kam 6f1914c002 Remove ClientSide 2023-05-16 17:33:28 -04:00
Kam d1901dcf0c Spoof 1.8.3 2023-05-16 17:17:47 -04:00
Kam 204e7a9c15 Revert Some Multithreading for Synchronization 2023-05-16 17:17:11 -04:00
Kam 892d11b89b Synchronized savePlayerDataMap 2023-05-16 14:40:16 -04:00
Kam b965d2e097 1.8.3 - version change 2023-05-16 14:33:06 -04:00
Kam 3c1d7e6689 oops 2023-05-16 12:59:08 -04:00
Kam 99298226f7 Faster Quest/Faction Menu loading 2023-05-16 12:58:28 -04:00
Kam 0306cff24e Fast Quest Log Loading 2023-05-16 12:51:14 -04:00
Kam b77d98eba5 revert 2023-05-16 12:41:06 -04:00
Kam 44f4301239 Fix Permission crash 2023-05-16 12:39:55 -04:00
Kam b82177d8d9 Merge branch 'patch' 2023-05-16 11:36:33 -04:00
Kam eb77ae3b99 1.8.2 2023-05-16 11:36:25 -04:00
Kam 2b1449b5f3 Fix and Remove Universal Permissions 2023-05-16 11:34:48 -04:00
Kam 221f00ccf4 Make Save PlayerData within PlayerData. More multithreaded saving 2023-05-15 23:06:21 -04:00
Kam cf82314181 Final & Synchronized Data sending with slight delays to heavily improve server performance 2023-05-15 20:03:52 -04:00
Kam ee33a57323 send Associated Data to all 2023-05-15 19:40:53 -04:00
Kam ae1f33d327 Utilize a One Thread and Synchronized attribute to better control data integrity and prevent data loss 2023-05-15 19:31:40 -04:00
Kam 60dbcc7146 Ensure Tracked Quest does not equal null when updating 2023-05-15 16:02:44 -04:00
Kam 0b7bd2f009 Add Update Tracked Quest Frequency for ITEM QUESTs 2023-05-15 15:55:41 -04:00
Kam 8e247f8232 Deobf Jar options 2023-05-15 15:25:49 -04:00
Luis C.M 92097769d9 ScriptPlayerEventHandler:
-Temporary fix to updating tracked item quests.

Fixed more tracked quest issues.
2023-05-14 19:14:43 -05:00
Kam 13953edaaf Update LICENSE 2023-05-13 17:24:50 -04:00
Kam 9db86d0870 Update LICENSE
More appropriate license
2023-05-13 16:53:42 -04:00
Kam 8d21291e7b Add Universal Developer support to Commands 2023-05-12 20:34:02 -04:00
Kam 88eb96e784 Change Mod name to CustomNPC+ 2023-05-12 20:32:55 -04:00
Kam 78978bda92 Reorganize File System Commands 2023-05-12 20:32:44 -04:00
Kam 314bc462f0 Better Permission handling for /KAMKEEL Commands 2023-05-12 18:06:55 -04:00
Kam b04ac96690 Beta2 2023-05-12 17:39:13 -04:00
Kam 97c97cf939 Fix ModelRenderer cast for Child Models causing render corruption 2023-05-12 17:38:40 -04:00
Kam d4a62b1334 Fix Mixin Model Cast Issue 2023-05-12 17:01:15 -04:00
Kam ceac11d251 Fix Tracked Quest null crash 2023-05-12 14:26:45 -04:00
Kam f2faf3513d ___playermap.dat_old not being found 2023-05-12 12:52:39 -04:00
Kam 515a6e8550 Crate Null Checks 2023-05-12 12:52:29 -04:00
Luis C.M 142fbe51e2 Fixed quest not tracking from previous commit. 2023-05-11 20:27:00 -05:00
Luis C.M e0360f9a6e Made tracked quest a private field, clearer intent in code for bug fixing. 2023-05-11 20:17:16 -05:00
Luis C.M f5bae9099d Merge remote-tracking branch 'origin/patch' into patch 2023-05-11 18:29:49 -05:00
Luis C.M 241120c32a Fixes to quest tracking and setting alerts. 2023-05-11 18:29:44 -05:00
Kam 9ff341bd17 Fix Quest Completion Message 2023-05-11 16:58:03 -04:00
Kam dd5ca106bc Fix Quest Cooldown string results 2023-05-11 16:45:25 -04:00
Kam 3cba19cea2 Fix UUIDS not saving when spawning an NPC 2023-05-11 13:19:53 -04:00
Kam 6859b2da47 1.8.2-beta 2023-05-11 12:14:09 -04:00
Kam fa7fb7f734 ??? Fix Quest Cooldown Times ??? 2023-05-11 11:57:39 -04:00
Kam 6f7ea7340c Remove Blank Named recipes and items 2023-05-11 11:24:25 -04:00
Kam 1183f7d91b Fix NullPointer Crash with Carpentry Search bench and BLANK recipes 2023-05-11 11:19:36 -04:00
Kam 9e7e3c8e5d Merge pull request #76 from Dreamfinity/better-json-to-nbt-parsing
More NBT serialising and deserialising
2023-05-11 01:28:31 -04:00
Luis C.M 0c07260999 Merge branch 'dev' into patch 2023-05-10 23:03:44 -05:00
Luis C.M 8a4c9f6f6b DataScript:
-Fixed loading error on NPC scripts causing index oob exceptions when reading event scripts.
2023-05-10 22:57:58 -05:00
Kam 6ea7244a25 Update api 2023-05-10 19:04:57 -04:00
Kam 809b1f269c Merge branch 'dev' 2023-05-10 19:03:52 -04:00
Kam 6ee79f181f Renovate Slay Command 2023-05-10 18:57:34 -04:00
Kam 110a7c71fb Fix NPC Tab Completion and String Format for Decimals 2023-05-10 18:54:07 -04:00
Kam f7c0f2bdf9 Add Space to Error Message 2023-05-10 18:27:16 -04:00
Kam 8cd4cfd82c Renovate Script Command 2023-05-10 18:01:43 -04:00
Kam 745bebaf73 Renovate NPC Command 2023-05-10 18:01:01 -04:00
Kam e1c4c2b786 Renovate Help Command 2023-05-10 17:27:04 -04:00
Kam d08e4fc925 Renovate Faction Command 2023-05-10 17:25:39 -04:00
Kam a6c0acdbcf Renovate Dialog Command 2023-05-10 17:11:49 -04:00
Kam bad130b937 Renovate Config Command 2023-05-10 17:03:07 -04:00
Kam b25a598580 Renovate CloneCommand 2023-05-10 16:58:46 -04:00
Kam e2e7b660d9 Renovate KAMKEEL Quest Command 2023-05-10 16:46:57 -04:00
Kam 7e88ebb696 Modify SendError 2023-05-10 16:46:42 -04:00
Kam 05926667c6 Renovate Tab Completion for KAMKEEL Command 2023-05-10 16:33:10 -04:00
Kam 5ed264f3bd sendErrror(), sendResult() for KamkeelBase Command 2023-05-10 16:32:45 -04:00
Kam 9c8ae316ff Finish Quest Command Fix 2023-05-10 15:34:14 -04:00
Kam 8ed683800f Fix Title length to match Name Length 2023-05-10 15:17:58 -04:00
Kam ed97534e67 Add PlayerDataMap + Regenerating PlayerData button 2023-05-10 15:06:07 -04:00
Luis C.M dd14f3ded0 PlayerDataController:
-Fixed retrieving player data from usernames.
2023-05-10 01:17:17 -05:00
Luis C.M d95f2476f9 Merge remote-tracking branch 'origin/dev' into dev 2023-05-09 23:28:23 -05:00
Luis C.M 6f7e2e8b18 EventHooks:
-Fixed incorrect return value, was messing with natural spawns.
2023-05-09 23:28:16 -05:00
Kam e38e592acb Version Update 1.8.1 2023-05-09 22:37:18 -04:00
Kam de6fb94562 Remove Mixin Config from Client and create seperate ConfigMixin for loading Mixins Earlier 2023-05-09 18:24:51 -04:00
Kam 96c621fb14 Change Mixinless Format 2023-05-09 18:24:14 -04:00
Kam 8e389a66b9 Merge branch 'dev' 2023-05-09 16:12:00 -04:00
Kam f56358f4f9 Add Images 2023-05-09 15:30:24 -04:00
Kam 960c60f5c7 Update api 2023-05-09 14:36:18 -04:00
Kam f5de82bb4e Update 1.8 Version + VersionCompatibility 2023-05-09 14:19:54 -04:00
Kam e9fbc4ad8d Disable Animation Command 2023-05-09 14:09:07 -04:00
Kam dfa8ca7533 Merge branch 'dev' of https://github.com/KAMKEEL/CustomNPC-Plus into dev 2023-05-09 14:08:47 -04:00
Kam 2bd5f25410 Animation Command 2023-05-09 14:08:45 -04:00
Kam 3ec10e9c49 Merge pull request #79 from Pilzinsel64/fix-de-typo
Update de_DE.lang
2023-05-09 13:30:42 -04:00
Kam ee72d22593 Allow for Quick Tag adding when Saving NPCs in Mass 2023-05-08 23:47:45 -04:00
Kam f7d62f6cdd Save Tags only when relevant 2023-05-08 23:47:28 -04:00
Kam 8ca2cc58f0 cleanTagList() add Clones and Merge Temporary Tags while saving 2023-05-08 23:47:16 -04:00
Kam adec63c763 CloneAllTagsShort for Quicker Server Interaction 2023-05-08 23:46:38 -04:00
Kam e6786a985e Update en_US.lang 2023-05-08 22:38:09 -04:00
Kam 9b82769d22 Unused ICustomScrollListener 2023-05-08 22:38:00 -04:00
Kam 867a8a3d82 Display Tags Alphabetically in Cloner 2023-05-06 15:59:45 -04:00
Kam 2c6fb0d15b Add NPC name to NPC Quick Tags 2023-05-06 15:26:30 -04:00
Kam 6e1e9c189d Update README.md
Better README wording
2023-05-06 14:35:33 -04:00
Kam 6d187fdada Center Buttons 2023-05-04 18:30:08 -04:00
Kam 6914f670bd Add Search to NPC Cloner Tags and Remove useless NPC parameter 2023-05-04 18:30:03 -04:00
Kam aced231b55 Merge branch 'dev' of https://github.com/KAMKEEL/CustomNPC-Plus into dev 2023-05-04 17:08:50 -04:00
Kam 996969bd2c Remodel Tag Setup to have search bar and better organize Tag Information 2023-05-04 16:13:59 -04:00
Kam 2fe39c98fc Useless Data / Packet Information removed 2023-05-04 16:13:44 -04:00
Kam 99aa6bf7c1 Update README.md
Added Modrinth Link
2023-05-04 13:52:54 -04:00
Kam 1e8d578222 Banner 2023-05-04 13:31:12 -04:00
Kam 660573d891 Logo New 2023-05-04 13:30:05 -04:00
Kam f828e96674 fix logo 2023-05-04 13:29:43 -04:00
Kam 2031d462bd logo 2023-05-04 13:29:26 -04:00
Kam 0d3418af47 Update Logo 2023-05-04 13:28:17 -04:00
Kam 5d738987b2 Add Sort Settings - Filter/Order/Type to Cloner GUI 2023-05-03 15:01:23 -04:00
Kam 36cd81e6e4 Fix NPC Tag Modifier not saving and isNPC Crash 2023-05-02 19:07:47 -04:00
Luis C.M 17566031d7 IDBCPlayer:
-Implemented form mastery functions.
2023-04-14 15:42:43 -05:00
Luis C.M a3de45cd55 IDBCPlayer:
-Implemented form mastery functions.
2023-04-14 15:42:34 -05:00
Pilzinsel64 a7b9043021 Update de_DE.lang
Fix some typos and improve a few texts.
2023-04-13 13:25:41 +02:00
Luis C.M c27cdf7950 Implemented sub-GUI for editing NPC tags in the cloner 2023-04-12 14:22:22 -05:00
Luis C.M 8b0431340c Crash fixes for custom items 2023-04-12 00:18:43 -05:00
Luis C.M a10e427c1c More IPos implementations for IWorld and IPos scripted objects 2023-04-11 23:26:10 -05:00
Luis C.M 116dc23f2b Added functions for safeguarding scripted item textures erroring. 2023-04-11 23:25:29 -05:00
KAMKEEL 09f36bb56c Quick Tags Sub GUI 2023-04-08 18:03:12 -04:00
KAMKEEL e102e652ae Load Tags into CLoner 2023-04-08 18:03:05 -04:00
KAMKEEL 81b4715dca Add Labels to Advanced Tag Menu 2023-04-08 18:01:14 -04:00
Luis C.M 406a8012fc Fixed Global NPC phantom NPC bug 2023-04-02 21:12:56 -05:00
Luis C.M 0ceb5dc3e2 Changed JS code execution in the ScriptContainer, more similar to 1.12 now. 2023-04-02 18:44:56 -05:00
Luis C.M 0cabe6b623 Fixed NullPointerException. 2023-03-31 00:01:41 -05:00
Luis C.M 22a768b8c2 Fixed NullPointerException when the quest editor is opened through the NPC wand's global button. 2023-03-30 23:55:41 -05:00
Luis C.M 864ce6befc NullPointerException fix when an NPC misses a projectile. 2023-03-29 22:13:58 -05:00
Luis C.M 947314787f Removed console from NBT data for scripted items 2023-03-29 21:35:16 -05:00
Luis C.M fc9e85c35a Changed implementation of custom items' tick event to be more similar to 1.12's. 2023-03-29 21:23:09 -05:00
Luis C.M 7b1b304f75 Merge remote-tracking branch 'origin/dev' into dev 2023-03-29 02:19:29 -05:00
Luis C.M ef4ec4aca0 Removed scala import 2023-03-29 02:19:04 -05:00
KAMKEEL 319d7b0503 Reorganize Tag Maker to be more organized 2023-03-23 23:21:27 -04:00
KAMKEEL ffd25430c9 Fix Lang not Working with "Hidden" 2023-03-23 23:07:21 -04:00
KAMKEEL c30a9014f8 Add Tag Search / Fix Tags not Updating from Server / Few Crash Fixes 2023-03-23 21:27:30 -04:00
KAMKEEL f9a4fc0d54 Add Ascending/Descending SetList 2023-03-23 21:26:47 -04:00
KAMKEEL 7dc5cc5e8c Compress Display Tag Statements 2023-03-23 21:26:34 -04:00
KAMKEEL d3551dda36 Add Lang Update 2023-03-23 21:26:22 -04:00
KAMKEEL 53070b47c4 Fix ReadNBT Tag Error 2023-03-22 22:36:41 -04:00
KAMKEEL c4b9a5ca21 Sort of Working 2023-03-22 22:03:01 -04:00
KAMKEEL 9d68a5e079 Fix UUIDs not saving to NPCs - Revert TagMapUUID List 2023-03-22 21:27:20 -04:00
KAMKEEL aa02580c28 Add RemoveFromTagMap Override for ClientSide 2023-03-22 20:18:09 -04:00
KAMKEEL fcfc01b2ab Fix Tag Filtering - Send All Tags to Client 2023-03-22 20:17:56 -04:00
KAMKEEL 30b3f55e7c Send All Tags to Client for Viewing 2023-03-22 20:13:36 -04:00
KAMKEEL ac87f2c2c2 Fix TagMap UUID List 2023-03-22 20:01:05 -04:00
KAMKEEL abb2d13e6e Remove From TagMap 2023-03-22 19:47:13 -04:00
KAMKEEL cc2e8805d8 Create Tag Map 2023-03-22 19:43:36 -04:00
KAMKEEL 81c752c483 Tag Code Cleanup 2023-03-22 19:14:13 -04:00
KAMKEEL df45247c89 Add ShowingClones Get 2023-03-22 18:56:42 -04:00
KAMKEEL 6882838cf8 Remove Useless Comment 2023-03-22 18:56:04 -04:00
KAMKEEL 8842fdfbf6 Catch Null Pointer 2023-03-22 18:32:53 -04:00
KAMKEEL 41c4fc66d0 Send Valid Tags to Client that correlate with UUIDs found on the Server. No longer needs the Clones Data 2023-03-22 17:58:02 -04:00
KAMKEEL 0943299384 Fix ReadNBT TagMap 2023-03-22 17:31:32 -04:00
KAMKEEL f8b182008c Fix Filter / Search Selection Clone GUI 2023-03-22 17:13:49 -04:00
KAMKEEL 270a9cbd46 Refactor Tags to work with TagMap on Filter Tab 2023-03-22 17:01:46 -04:00
KAMKEEL a9f2fe4a0e Useless List 2023-03-22 17:00:55 -04:00
KAMKEEL 214f0a4c00 Add UUID to Int HashMap in TagController 2023-03-22 16:07:42 -04:00
KAMKEEL 69154bec24 Send ServerTag Map through packet 2023-03-22 16:07:09 -04:00
KAMKEEL 2c349cb34c Ignore Exception 2023-03-22 16:06:32 -04:00
KAMKEEL 573aab23e5 Register TagMap Controllers 2023-03-22 16:06:22 -04:00
KAMKEEL 89efe67f44 hasClone for TagMap 2023-03-22 13:37:09 -04:00
KAMKEEL 33e5071b11 Convert Set to HashSet 2023-03-22 13:35:49 -04:00
KAMKEEL 418d345293 Create ClientTagMapController.java 2023-03-22 13:19:08 -04:00
KAMKEEL 8ef4276865 ServerTagMap Controller 2023-03-22 13:18:24 -04:00
KAMKEEL f2190b350d Update TagMap NBT Tag 2023-03-22 13:18:17 -04:00
KAMKEEL 1fc7c8ea50 Fix TagMap to use "CloneMap" as its Tag Value 2023-03-22 12:52:49 -04:00
KAMKEEL a2af8ca0b2 Apply isKilled() to update AI Tasks if NPC dies 2023-03-22 11:52:33 -04:00
KAMKEEL eb11170a9b TagMap writeToNBT 2023-03-22 04:52:16 -04:00
KAMKEEL 6714daa60a TagMap initial commit 2023-03-22 04:34:02 -04:00
KAMKEEL 6e74bc0597 Remove SubGUI Button 2023-03-22 04:33:53 -04:00
KAMKEEL de4b169754 Refactor 2023-03-22 04:32:06 -04:00
KAMKEEL 7b239ea6bd Add Filters Tab to Cloner 2023-03-22 04:32:00 -04:00
KAMKEEL 87949b62fa Delete SubGUI Filters 2023-03-22 04:31:47 -04:00
KAMKEEL 7bd14b06dd Move InnDoorData to proper directory 2023-03-21 19:37:04 -04:00
KAMKEEL 5d6da34717 Merge branch 'dev' of https://github.com/KAMKEEL/CustomNPC-Plus into dev 2023-03-21 19:34:33 -04:00
KAMKEEL 44c0ecc3fd Animation Command framework 2023-03-21 19:34:30 -04:00
KAMKEEL 3df8acfaee GetAnimation / AnimationNames 2023-03-21 19:34:24 -04:00
KAMKEEL 545cece3e4 Fix Spacing/Indentation Faction Controller 2023-03-21 19:34:04 -04:00
Luis C.M 0f619d710a Implemented tag filters 2023-03-21 03:16:52 -05:00
Luis C.M aba24fc93c Tags can now be added through a new sub gui in the NPC advanced tab. 2023-03-20 22:29:58 -05:00
KAMKEEL 9a6cf94c73 Natural Spawn IDs - Integers Only 2023-03-20 18:02:29 -04:00
KAMKEEL 49edeee673 Add Search Bar to Recipe GUI 2023-03-20 17:32:09 -04:00
Luis C.M 84433df94b NPC script GUI:
- Added "X" GUI close button at the top right corner
2023-03-20 14:22:06 -05:00
Luis C.M 8753c97a8e NPC Inventory menu:
- The button corresponding to the current inventory tab being viewed will now be disabled.
2023-03-20 14:13:41 -05:00
KAMKEEL f52af0b19d Fix Global PlayerData Menu crashing when too much NBT data is loaded 2023-03-20 14:04:08 -04:00
KAMKEEL 891a3101c9 Add TagController Spacing 2023-03-20 11:49:14 -04:00
KAMKEEL 4302ac4a2b Merge branch 'dev' of https://github.com/KAMKEEL/CustomNPC-Plus into dev 2023-03-20 11:16:33 -04:00
Luis C.M f91e62ee0f As many slots as possible can be added to natural spawn entries now. 2023-03-20 02:01:11 -05:00
Luis C.M f27599075a As many slots as possible can be added to natural spawn entries now. 2023-03-20 02:00:58 -05:00
Luis C.M 84286794aa Fixes to recent custom item changes, width wasn't rendering properly 2023-03-19 02:32:09 -05:00
Luis C.M 39a40c9603 Fixed URL support for scripted items, weird 3d visibility bug still present that needs to be fixed. 2023-03-19 02:04:47 -05:00
Luis C.M 7fdfd14174 Scripted items now support URLs 2023-03-18 20:37:45 -05:00
KAMKEEL c818f6ee4e Merge branch 'dev' of https://github.com/KAMKEEL/CustomNPC-Plus into dev 2023-03-18 17:31:44 -04:00
KAMKEEL c8d676c764 1.8 Beta Tag 2023-03-18 17:31:40 -04:00
Luis C.M 45217f3afc Fixed custom gui slot behavior 2023-03-18 15:58:17 -05:00
Luis C.M 80352741b9 Fixed custom gui slot behavior 2023-03-18 15:52:50 -05:00
Luis C.M e3405d22e9 Fixed null pointer exceptions from new custom gui slot commit. 2023-03-18 03:47:24 -05:00
Luis C.M 586c451f06 ICustomGui:
-Added IDs to custom GUI slots.
2023-03-18 03:04:46 -05:00
Luis C.M 2c012f2693 Fixed puppet behavior when used with animations 2023-03-18 02:07:37 -05:00
Luis C.M f7576ffc90 Added armwear functions 2023-03-17 04:34:22 -05:00
Luis C.M b04a35efc4 Added armwear functions 2023-03-17 04:34:14 -05:00
Luis C.M 6a5d84b9aa IModelData:
-Added hidePart() comment
2023-03-17 03:04:39 -05:00
Luis C.M 58aaaa158a IModelData:
-Added hidePart() comment
2023-03-17 03:04:26 -05:00
Luis C.M f5aa6b58db IModelData:
-Implemented hidePart() abd hidden() functions
2023-03-17 02:59:42 -05:00
Luis C.M 6913cadc79 IModelData:
-Implemented hidePart() abd hidden() functions
2023-03-17 02:59:33 -05:00
Luis C.M 9a77e2f146 Made setRotation() function in ModelRotatePart clamp float values. 2023-03-17 02:38:15 -05:00
Luis C.M 992e6fd169 Added NPC model data interfaces to the API. 2023-03-17 02:36:39 -05:00
Luis C.M f0b33cf913 Moved model scale parts into a single ModelScale class, similar to ModelRotate.
Added NPC model data interfaces to the API.
2023-03-17 02:36:28 -05:00
Luis C.M 2ef93dd35f Fixed index out of bounds exception 2023-03-16 23:58:45 -05:00
Luis C.M df069c82c2 Added a quest alert toggle for each quest in the quest log.
Fixed instant complete quests not finishing sometimes.
2023-03-16 23:37:57 -05:00
Luis C.M e58b494979 All global NPC scripts are now called before local NPC scripts
Fixed event NPC scripts not running after erroring, and not outputting to the console
2023-03-16 16:43:05 -05:00
Luis C.M 57bd628357 IEntityItem added 2023-03-16 05:07:46 -05:00
Luis C.M fd7f550316 IEntityItem added 2023-03-16 05:07:38 -05:00
Luis C.M f5cf78e1fb Added target lost event. Added all new NPC events to the old 1.7.10 script system. 2023-03-16 04:56:42 -05:00
Luis C.M fe780d69ee Added target lost event. Added all new NPC events to the old 1.7.10 script system. 2023-03-16 04:56:33 -05:00
Luis C.M 29935a1c6d Implemented local NPC event scripts. 2023-03-16 04:27:19 -05:00
Luis C.M 46d668f44c Added IProjectile and its events. 2023-03-16 02:51:40 -05:00
Luis C.M 19e14983aa IWorld:
-Fixed isPlaceCancelled and isBreakCancelled functions
2023-03-15 23:10:03 -05:00
Luis C.M 22a4082890 IWorld:
-Added isPlaceCancelled and isBreakCancelled functions
2023-03-15 22:50:50 -05:00
Luis C.M c12bb6508c Added global data menu to the NPC wand when right clicking the air 2023-03-15 22:24:47 -05:00
Luis C.M daada3cb8a IEntity:
-Added setDimension function for all entities (not just players now).
2023-03-15 19:17:39 -05:00
KAMKEEL fb09c8c39e Remove Debug Prints 2023-03-02 23:47:23 -05:00
KAMKEEL c16a90424a Change PuppetEnabled to AllowAnimation 2023-03-02 23:45:38 -05:00
KAMKEEL 9eb2052bdb Redo All Puppet Conversions from Old Puppet Job to New ModelRotate 2023-03-02 23:29:09 -05:00
KAMKEEL 4976e059f5 Enable/Disable Rotation GUI 2023-03-02 21:44:03 -05:00
KAMKEEL cc0c83835c Make Rotations Active 2023-03-02 16:22:38 -05:00
KAMKEEL f788257b7d GuiModelRotate (new Puppet Rotation Menu for NPCs) 2023-03-02 16:10:39 -05:00
KAMKEEL 7db4d2649b Typo correction: "companion" 2023-03-02 16:10:22 -05:00
KAMKEEL b0c2dff2fe model.* is already made these were duplicates 2023-03-02 16:05:32 -05:00
KAMKEEL 4cd6ac6b51 Fix Naming again... 2023-03-02 15:52:53 -05:00
KAMKEEL bfb771211f Fix Naming 2023-03-02 15:52:19 -05:00
KAMKEEL 5b84a01c74 Add Right Arm/Leg and Puppet Instructions 2023-03-02 15:51:33 -05:00
KAMKEEL 377e18a445 Remove unused Translation Data, add Rotation to Body Parts for Puppet Conversion 2023-03-02 15:51:18 -05:00
KAMKEEL 23916e88d8 Fix Lang 2023-03-02 15:49:46 -05:00
KAMKEEL e003e375db Rename Commands 2023-03-02 02:35:46 -05:00
KAMKEEL 33dd07d941 Add Lang 2023-03-02 02:34:44 -05:00
KAMKEEL daf06e8d55 Update Save Playerdata 2023-02-28 16:27:05 -05:00
KAMKEEL d2612657c3 Update Permission Nodes 2023-02-28 16:26:50 -05:00
KAMKEEL ae4b95731b Fix CREATE Command 2023-02-28 04:52:24 -05:00
KAMKEEL e33d3fc5e4 KAMKEEL Renovated Commands 2023-02-28 04:26:52 -05:00
KAMKEEL fc94b851c1 getFaction 2023-02-28 04:26:35 -05:00
KAMKEEL c2d0b5322d Public Load Categories 2023-02-28 04:26:28 -05:00
KAMKEEL 1207a592d7 KAMKEEL Commands 2023-02-28 04:26:16 -05:00
KAMKEEL 116c3db201 Add Universal PlayerData Receiver 2023-02-28 03:35:56 -05:00
KAMKEEL dc678bee86 Fix Config Naming 2023-02-28 03:35:44 -05:00
KAMKEEL 8b89711403 Fix URL Links 2023-02-28 03:35:37 -05:00
KAMKEEL 3250a9e02b Spelling Errors 2023-02-28 03:32:35 -05:00
Luis C.M d28a523c49 ScriptSoundController:
-Fixed ConcurrentModificationException by using an Iterator to remove inactive sounds
2023-02-24 10:54:46 -06:00
Luis C.M 58e129e0df IDBCPlayer:
-Had to remove getMaxMeleeStrength and getMeleeStrength functions.
2023-02-24 10:42:46 -06:00
Luis C.M f165e5172c IDBCPlayer:
-Had to remove getMaxMeleeStrength and getMeleeStrength functions.
2023-02-21 22:03:14 -06:00
Luis C.M 5eeefedf6e IDBCPlayer:
-Made getMeleeStrength an overriding function to IEntityLivingBase
2023-02-21 12:55:15 -06:00
Luis C.M 23cfe66ecb IDBCPlayer:
-Made getMeleeStrength an overriding function to IEntityLivingBase
2023-02-21 12:55:04 -06:00
Luis C.M 5b589768f6 Player, Forge, & NPC script console changes, & further fix to concurrent modification exception on script container. 2023-02-21 12:45:48 -06:00
Luis C.M 9b330007fd IDBCPlayer:
-Added getMeleeDamage() and getMaxMeleeDamage() functions
2023-02-21 12:43:09 -06:00
Luis C.M 397620f36e IPlayer:
-Fixed % character causing client-side crashes when sent with player.sendMessage
2023-02-19 19:35:41 -06:00
Luis C.M 0db96f9040 Fixed forge, player, & npc scripts not being able to be deleted or added. 2023-02-19 16:22:28 -06:00
Luis C.M de6375c4cb Fixed script console not appearing with the new global script tab saving method. 2023-02-19 15:20:51 -06:00
Luis C.M 79e13dfade Changes to the animation GUI and part/frame saving. 2023-02-19 13:46:37 -06:00
Luis C.M b8dc090db8 Player, Forge, & NPC scripts are saved in separate packets for separate tabs now, so script save/get packets aren't too big for the server. 2023-02-19 13:38:43 -06:00
Luis C.M 0ddcd15162 Fixed concurrent modification exception when saving scripts. 2023-02-19 12:48:40 -06:00
Luis C.M bcfd44d8fe Fixed scripted GUI button text alignments. 2023-02-17 11:28:37 -06:00
Luis C.M cacb4ebf85 Added X & Y scale functions for particles, replaces overall scale. 2023-02-16 18:43:22 -06:00
Luis C.M e65ba59b8e Fix to setting animation names. 2023-02-14 01:26:40 -06:00
Luis C.M 354c9808e4 Important animation editor fixes 2023-02-14 01:07:31 -06:00
Luis C.M cfca59a48e Implemented animation GUI 2023-02-06 23:17:05 -06:00
Luis C.M 30d73f91cf Fixed textured GUI buttons not working with images of different sizes. 2023-02-04 11:14:49 -06:00
georgii.imeshkenov 112305f059 wow looks like this string was not committed 2023-02-03 00:23:22 +03:00
georgii.imeshkenov 45f006b7bf de- and serialization of NBTTagByteArray from json based on post-array "b" suffix 2023-02-02 21:24:34 +03:00
Luis C.M 60ed5ab607 Fixed empty tabs breaking all following tab scripts on scripted items. 2023-01-29 18:01:00 -06:00
Luis C.M c90a5d9713 Added has() function 2023-01-28 01:19:57 -06:00
Luis C.M 1a47b68621 Removed animation IDs, added animation controller. 2023-01-26 14:15:00 -06:00
Luis C.M 0787a71197 Removed animation IDs, added animation controller. 2023-01-26 14:14:13 -06:00
Luis C.M 6a7ce1bb5b Added animation IDs 2023-01-25 23:18:41 -06:00
Luis C.M 60f8645c84 Created animation controller 2023-01-25 23:18:27 -06:00
Luis C.M e558292360 Added animation looping. 2023-01-25 22:06:46 -06:00
Luis C.M 74b0114555 Added animation looping. 2023-01-25 22:05:11 -06:00
Luis C.M 667486fd71 Merge remote-tracking branch 'origin/dev' into dev 2023-01-25 21:54:33 -06:00
Luis C.M 78357165a2 Marked events that can be cancelled as cancellable if they didn't have the annotation. 2023-01-25 21:54:25 -06:00
luisc 9c7767312d Fixed empty scripting tabs making all following tabs not run code in player scripts. 2023-01-25 11:01:35 -06:00
Luis C.M 1ddc316230 Replaced placeholder parameter names with clearer names. 2023-01-24 22:19:21 -06:00
Luis C.M b8a3740ad2 Fixed player animations not updating after re-logging. 2023-01-23 22:58:55 -06:00
Luis C.M 96caf6e033 Simplified player animation code and removed unused fields. 2023-01-23 22:31:04 -06:00
Luis C.M 07175758a7 Small fix for model part compatibility. 2023-01-23 18:47:23 -06:00
Luis C.M 9f02d118cd Fixed player animations not syncing correctly in multiplayer. 2023-01-19 00:00:03 -06:00
Luis C.M d149b018e9 Added render ticks option for frames, inherited from its animation parent if not customized. 2023-01-18 21:35:49 -06:00
Luis C.M 5e5bf2eb1c Added render ticks option for frames, inherited from its animation parent if not customized. 2023-01-18 21:35:39 -06:00
Luis C.M f504424fd2 Added a declared field reflection cache, improving render times for NPC models that have many fields. 2023-01-18 21:28:16 -06:00
Luis C.M cb143be559 More compatibility fixes for MixinModelRenderer, removed another unused function from ModelScaleRenderer 2023-01-18 21:13:36 -06:00
Luis C.M 3884b662fd Removed some unused functions from ModelScaleRenderer 2023-01-18 20:27:14 -06:00
luisc 7ff568b1be Fixed full body model rotations 2023-01-18 12:48:27 -06:00
luisc 755dcbab03 Torso rotations no longer affect other parts' pivots in ModelMPM 2023-01-18 11:55:06 -06:00
luisc bab359ea2b Fix to the previous frame part rotation fix. 2023-01-18 11:49:38 -06:00
luisc 0d36c19c22 Small fix to client-sided fields so frame parts don't freak out when an animation first starts. 2023-01-18 11:44:43 -06:00
luisc 46ea214b64 Fixed animation times not resetting, causing some animations to get stuck if still enabled when in the middle of a frame that lasts a very long time. 2023-01-18 09:26:50 -06:00
luisc 17c6fe9728 Merge branch 'dev' of https://github.com/KAMKEEL/CustomNPC-Plus 2023-01-18 09:17:23 -06:00
Luis C.M e2c8550dc1 Fixed some DBC models rendering their heads wrong with the model renderer mixin. 2023-01-18 00:23:40 -06:00
Luis C.M 564a6ab6ba Small changes to the modelrenderer mixin for NPCs. 2023-01-18 00:03:57 -06:00
Luis C.M 477cf03f1b Fixed NPC part type searching in the mixin 2023-01-17 16:58:39 -06:00
Luis C.M 4e5a12690e Fixed a frame part NBT issue and DBC player compatibility. 2023-01-17 14:08:19 -06:00
Luis C.M 8f206ba500 IFramePart:
-Rotations and pivots are now saved as and use floats.
2023-01-17 13:08:33 -06:00
Luis C.M f61001d32a Changed mixin to support players with animations better. Rotations and pivots are now saved as and use floats. 2023-01-17 13:08:10 -06:00
Luis C.M 9797a52af1 Improved animation NBT reading/writing. 2023-01-16 23:03:11 -06:00
Luis C.M be18e756fc Animation overhaul, along with animation changes to the API. 2023-01-16 13:53:15 -06:00
KAMKEEL bda76bafe6 Optimize Imports 2023-01-12 21:33:06 -05:00
KAMKEEL 569c7790fc Read/Write NBT for Animation/Frame/FramePart 2023-01-12 20:34:07 -05:00
KAMKEEL 3e6e28d857 More Constructors 2023-01-12 19:40:06 -05:00
KAMKEEL 91bcd43942 Animation/Frame Data Classes with a EnumAnimationPart 2023-01-12 19:32:40 -05:00
Luis C.M 54d53041ac Animation Data overhaul 2023-01-12 15:07:45 -06:00
KAMKEEL 1d94e5f1e7 Animation Booleans and Read/Write NBT Fixes 2023-01-12 03:32:49 -05:00
KAMKEEL adb581ea64 Full Animation File Makeup
> Remove JobPuppet
> Remove PlayerModelData
> REWORK IAnimationPart
and IAnimation
2023-01-12 03:13:39 -05:00
Luis C.M 8e3440bc73 Saved enabled to NBT 2023-01-12 00:12:10 -06:00
Luis C.M 074f3ee88b Changes to ModelPartConfigNEW 2023-01-12 00:11:12 -06:00
KAMKEEL 816873dcd8 Incomplete Animate Move 2023-01-11 23:27:24 -05:00
KAMKEEL 29f529a711 Add the declaration public because it bothers me 2023-01-11 22:43:41 -05:00
KAMKEEL 8f62daba3e Refactor JobPuppet and PartConfig 2023-01-11 22:42:36 -05:00
KAMKEEL c35c3cbb1d Things 2023-01-11 21:51:03 -05:00
Luis C.M 8905f5f42e Moved NPC puppet data to display data.
Improved mixin functionality, offsets and rotations always reset if the puppet "job" (not a job anymore, always in display) is disabled.
2023-01-11 19:12:53 -06:00
KAMKEEL 974bf2ca66 Packet Handling 2023-01-10 17:17:15 -05:00
KAMKEEL 4c2f033a04 Merge branch 'dev' of https://github.com/KAMKEEL/CustomNPC-Plus into dev 2023-01-10 16:54:52 -05:00
KAMKEEL 26a1ad1dba Manage Tags GUI hooked to and working (Not Final) 2023-01-10 16:54:49 -05:00
KAMKEEL 5388a56b53 Update api 2023-01-10 16:54:31 -05:00
KAMKEEL 95f559c36b Fix TagController import in Tag File 2023-01-10 16:51:46 -05:00
KAMKEEL 352a79d94c Create Global Tag Permssions 2023-01-10 16:48:26 -05:00
KAMKEEL b203a244ec Add TagController instance to CustomNpcs Main file 2023-01-10 16:48:14 -05:00
KAMKEEL 309f912f10 Tag and Tag Controller 2023-01-10 16:47:49 -05:00
KAMKEEL 0772f427ef Tag Packets 2023-01-10 16:35:12 -05:00
Luis C.M 6897512a01 Removed redundant client-side fields from puppet parts. 2023-01-10 15:21:58 -06:00
Luis C.M a1a382b67f Undid previous commit, messed with offsets too much. 2023-01-10 15:09:06 -06:00
Luis C.M 3b69da5ef6 Merge remote-tracking branch 'origin/dev' into dev
# Conflicts:
#	src/main/java/noppes/npcs/client/renderer/RenderCustomNpc.java
#	src/main/java/noppes/npcs/mixin/MixinModelRenderer.java
2023-01-10 15:07:03 -06:00
Luis C.M cbc0b82356 Undid previous commit, messed with offsets too much. 2023-01-10 15:06:37 -06:00
Luis C.M 1aee4c06fc Small optimizations for the NPC puppet mixin. 2023-01-10 13:25:21 -06:00
Luis C.M 7f407c3c44 Fixed puppet model rotations/offsets crossing over NPCs when they shouldn't. 2023-01-10 13:10:22 -06:00
Luis C.M 06ff9fc482 Mixin NPC fix for alternate NPC biped models. 2023-01-09 23:13:26 -06:00
Luis C.M 42c29f1d47 Added support for other models that inherit from ModelBiped to NPC puppet rendering. 2023-01-09 21:08:22 -06:00
Luis C.M 3573b7e71e Fixed NPC 2D armor being offset weirdly. 2023-01-09 17:39:16 -06:00
Luis C.M 25eafab3b1 Created a new config to enable/disable animation mixins. 2023-01-09 15:20:36 -06:00
Luis C.M d7d43f74b9 Merge branch 'dev' into player-anims 2023-01-09 15:11:04 -06:00
Luis C.M c3b3fc8370 Merge remote-tracking branch 'origin/dev' into dev 2023-01-09 14:13:26 -06:00
Luis C.M 4d17df936a Fix for player overlay speeds. 2023-01-09 14:13:20 -06:00
KAMKEEL 6779bbc93f Ignore Empty Bytes Data from Modded Blocks 2023-01-09 13:57:14 -05:00
Luis C.M f29de8aaa3 Merge branch 'dev' into player-anims 2023-01-09 01:27:47 -06:00
Luis C.M 9dfd562841 Fixed uninterpolated NPC puppet part offsets. 2023-01-09 01:22:48 -06:00
Luis C.M 8b07aa41cd Merge branch 'dev' into player-anims 2023-01-09 00:44:18 -06:00
Luis C.M 4375222a67 PartConfig:
-Angle fix for setRotation functions.
2023-01-09 00:44:00 -06:00
Luis C.M d87a37e017 Added PlayerModelData as a parent of its parts when constructing them. 2023-01-09 00:03:09 -06:00
Luis C.M 6b0da818c6 Merge branch 'dev' into player-anims
# Conflicts:
#	src/main/java/noppes/npcs/roles/JobPuppet.java
2023-01-09 00:02:12 -06:00
Luis C.M a5903c24b9 Fixed rotation and offset functions setting values that are too high. 2023-01-09 00:00:18 -06:00
Luis C.M 780d382b3f IPlayerModelData:
-Re-implemented some previously removed functions.
2023-01-08 23:49:27 -06:00
Luis C.M 94127e5fa4 IPlayerModelData:
-Re-implemented some previously removed functions.
2023-01-08 23:49:14 -06:00
Luis C.M 5f595fa7b6 Merge branch 'dev' into player-anims 2023-01-08 23:30:02 -06:00
Luis C.M 01848e82c8 IJobPuppet:
-Added allEnabled function for setting all parts as enabled.
2023-01-08 23:29:31 -06:00
Luis C.M c9ebeea7f9 IPlayerModelData:
-Added allEnabled function for setting all parts as enabled.
2023-01-08 23:28:17 -06:00
Luis C.M bfb262a487 IPlayerModelData:
-Added allEnabled function for setting all parts as enabled.
2023-01-08 23:28:08 -06:00
Luis C.M 76761c4f3d MixinModelRenderer:
-Removed some unused imports & casts
2023-01-08 23:22:17 -06:00
Luis C.M 1ac1cbcc2a IPlayerModelData:
-Renamed some functions to better reflect them changing all parts of JobPuppet
2023-01-08 23:05:09 -06:00
Luis C.M 0b5ffce55f IPlayerModelData:
-Renamed some functions to better reflect them changing all parts of JobPuppet
2023-01-08 23:04:57 -06:00
Luis C.M a1c036c4bf IJobPuppet:
-Renamed some functions to better reflect them changing all parts of JobPuppet
2023-01-08 23:01:41 -06:00
Luis C.M ddbf84bc74 Merge branch 'dev' into player-anims 2023-01-08 23:01:24 -06:00
Luis C.M 54d89bab39 IJobPuppet:
-Renamed some functions to better reflect them changing all parts of JobPuppet
2023-01-08 23:00:25 -06:00
Luis C.M c146a973f0 IPlayerModelData:
-Restructured to implement the new IModelPart interface
2023-01-08 22:57:52 -06:00
Luis C.M f98a1af2b2 IJobPuppet:
-Now restructured to use IModelPart to modify puppet parts.
-Old functions have been marked as deprecated, but still work.
2023-01-08 22:46:12 -06:00
Luis C.M 0750f12a32 IJobPuppet:
-Now restructured to use IModelPart to modify puppet parts.
-Old functions have been marked as deprecated, but still work.
2023-01-08 22:45:20 -06:00
Luis C.M aed45fc119 IJobPuppet:
-Now restructured to use IModelPart to modify puppet parts.
-Old functions have been marked as deprecated, but still work.
2023-01-08 22:34:54 -06:00
Luis C.M 928232fdd2 Merge remote-tracking branch 'origin/dev' into dev 2023-01-08 22:32:50 -06:00
Luis C.M 49f93dfce2 IJobPuppet:
-Now restructured to use IModelPart to modify puppet parts.
-Old functions have been marked as deprecated, but still work.
2023-01-08 22:32:36 -06:00
KAMKEEL 763a388947 Update api 2023-01-08 17:32:25 -05:00
KAMKEEL 83a13b96c4 setMovingType and getMovingType
Allows script to change types between
0 = standing, 1 = wandering, 2 = moving path
2023-01-08 17:27:37 -05:00
Luis C.M ed284eb658 Fixed uninterpolated model part offsets for NPCs. 2023-01-07 17:31:11 -06:00
Luis C.M c522c08ac5 Merge branch 'dev' into player-anims 2023-01-07 17:23:10 -06:00
KAMKEEL 0b809e8210 Merge branch 'dev' of https://github.com/KAMKEEL/CustomNPC-Plus into dev 2023-01-07 18:07:58 -05:00
KAMKEEL bc6cc35fd6 Automatic Legacy Config Converter 2023-01-07 18:07:23 -05:00
Luis C.M 2656081b1a Commented out a few lines that were giving errors in LoadConfiguration. 2023-01-07 15:50:00 -06:00
Luis C.M 06b938069a Very small change, grouped client-sided fields better. 2023-01-07 14:12:51 -06:00
Luis C.M 7ba95807e7 Removed unused array fields. 2023-01-07 14:11:35 -06:00
Luis C.M 3b11ddb4b4 Simplified player animation rendering, similar to the NPC puppet part commit on dev. 2023-01-07 14:10:36 -06:00
Luis C.M cfd724edf6 Merge branch 'dev' into player-anims
# Conflicts:
#	src/main/java/noppes/npcs/roles/JobPuppet.java
2023-01-07 14:02:47 -06:00
Luis C.M 0db7ef8e66 Simplified puppet rendering code, iterates over puppet parts and their corresponding model renderers instead of having several if statements. 2023-01-07 14:01:04 -06:00
Luis C.M 235ddaa1ea Implemented interpolation options for player model animations. 2023-01-07 13:38:44 -06:00
Luis C.M d6ed069862 Merge branch 'dev' into player-anims
# Conflicts:
#	src/api
2023-01-07 13:15:45 -06:00
Luis C.M 99403257f5 Merge remote-tracking branch 'origin/dev' into dev 2023-01-07 13:13:56 -06:00
Luis C.M 4346992f14 IJobPuppet:
-Added the option to not interpolate between angles and move from one value to another at a constant speed.
2023-01-07 13:13:44 -06:00
Luis C.M c9426682c0 Added another mixin necessary for rendering model rotations for players in MP. 2023-01-06 23:47:55 -06:00
KAMKEEL 6e92f08851 Config Overhaul 2023-01-07 00:21:08 -05:00
Luis C.M ef01b700da Merge remote-tracking branch 'origin/player-anims' into player-anims 2023-01-06 14:46:31 -06:00
Luis C.M 7564498cdf Hard reset to previous commit 2023-01-06 14:46:21 -06:00
Luis C.M b4cb69000e IJobPuppet:
-Regrouped functions in the interface, a little easier to follow.
-Rotation & Offset setters now use floats as parameters instead of ints.
2023-01-06 14:41:32 -06:00
Luis C.M e89e4d4c2b IJobPuppet:
-Regrouped functions in the interface, a little easier to follow.
-Rotation & Offset setters now use floats as parameters instead of ints.
2023-01-06 14:41:16 -06:00
Luis C.M ff3b9131cf IPlayerModelData:
-Regrouped functions in the interface, a little easier to follow.
-Rotation & Offset setters now use floats as parameters instead of ints.
2023-01-06 14:28:23 -06:00
Luis C.M 2e745fbda1 IPlayerModelData:
-Regrouped functions in the interface, a little easier to follow.
-Rotation & Offset setters now use floats as parameters instead of ints.
2023-01-06 14:28:15 -06:00
Luis C.M 27b80037bd Added total model rotation functionality to player model data. 2023-01-06 13:43:49 -06:00
Luis C.M 58afabc43b Small fix to avoid popping matrices when not needed. 2023-01-05 18:21:38 -06:00
Luis C.M ad689440aa Implemented complete model rotations. 2023-01-05 18:18:28 -06:00
Luis C.M de92c6055d Removed IPlayerModelData interface from dev. 2023-01-05 17:59:37 -06:00
Luis C.M 3bb1b4fcb0 Added general model rotation functions to PlayerModelData. 2023-01-05 17:58:32 -06:00
Luis C.M 695dfce7d0 Merge branch 'dev' into player-anims 2023-01-05 16:47:36 -06:00
Luis C.M 28a1650c05 Added setRotation(float rotationYaw, float rotationPitch) function for IEntity & ICustomNpc 2023-01-03 23:36:53 -06:00
Luis C.M bb5b3f5f00 Merge branch 'dev' into player-anims 2023-01-03 19:35:43 -06:00
Luis C.M 612a2d7593 Merge remote-tracking branch 'origin/dev' into dev
# Conflicts:
#	src/api
2023-01-03 19:31:04 -06:00
Luis C.M d2611385de ITimers:
-Added timerIds() function, listing all active timer IDs
2023-01-03 19:30:15 -06:00
Luis C.M 7b3dd8e7bd Removed unused IPlayerModelData interface. 2023-01-01 23:54:39 -06:00
Luis C.M 3c856458c4 Added player rotations/pivots/animations, similar to NPC's. 2023-01-01 23:51:37 -06:00
Luis C.M 51263a9f82 Added player rotations/pivots/animations, similar to NPC's. 2023-01-01 23:50:38 -06:00
Luis C.M b167755cc0 Fixed a small puppet offset client update bug. 2022-12-31 18:47:13 -06:00
Luis C.M d638c98d81 Added alternate distanceTo function using three double values instead of an IPos object. 2022-12-28 00:45:27 -06:00
Luis C.M 1df7819931 Added a few more functions having to do with capturing picked up drops to IEntity. 2022-12-27 20:27:36 -06:00
Luis C.M 828d03a0cb ScriptEntity:
-Fix to getStoredDataKeys()
2022-12-27 17:29:22 -06:00
Luis C.M 7d4a59d45a IEntity & IWorld:
-Added getStoredDataKeys() & getTempDataKeys() functions.
2022-12-27 16:46:59 -06:00
Luis C.M 5e8c234ac7 Added more functions to IPlayer, IEntityLiving, IEntityLivingBase, and IAnimal. 2022-12-26 01:13:37 -06:00
Luis C.M 1ac0b3b0a3 Added more functions to IPlayer, IEntityLiving, IEntityLivingBase, and IAnimal. 2022-12-26 01:13:28 -06:00
Luis C.M 25dcc975df Added more functions to IEntityLivingBase for setting entity attributes. For the functions that apply, INpc's functions to set these values override IEntityLivingBase's. 2022-12-24 01:48:26 -06:00
Luis C.M 699b24e467 More fixes to global NPC scripts not executing on servers, and added more functions to IEntityLivingBase. 2022-12-24 01:46:43 -06:00
Luis C.M 8d52e9356c Fixed Global NPC script tabs not working on the server-side after being errored. 2022-12-23 20:45:04 -06:00
Luis C.M a82a06fe4d Fixed resetting NPC body part pivots and rotations. 2022-12-22 23:34:13 -06:00
Luis C.M dbe956d973 Changed the functionality of the new variable that allows for larger angles. 2022-12-22 17:15:48 -06:00
Luis C.M 2588f14105 Changed the functionality of the new variable that allows for larger angles. 2022-12-22 17:15:40 -06:00
Luis C.M 5c81f3dd2e Added more API functions to the IJobPuppet interface 2022-12-22 17:05:10 -06:00
Luis C.M 678ee8fc02 Added more API functions to IJobPuppet, and a "limitAngles" variable that lets puppet parts use full angles. 2022-12-22 17:04:53 -06:00
Luis C.M c950dcfa5a Adjusted puppet arm pivots based on body angles. 2022-12-22 16:31:28 -06:00
Luis C.M bb7b33bf95 Added puppet offsets and adjusted puppet leg pivots based on body angles. 2022-12-22 15:24:39 -06:00
Luis C.M 4f553a9ee4 Fixed legs being dislocated from body for puppet NPCs when the body's Y-rotation is modified. 2022-12-22 10:54:56 -06:00
Luis C.M 343721c87a Fixed arms being dislocated from body for puppet NPCs when the body's Y-rotation is modified. 2022-12-22 10:40:54 -06:00
Luis C.M 74ed9d9de9 Very small fix to setRotation function 2022-12-22 10:15:08 -06:00
Luis C.M c0ad318573 Added setRotation function to set all three rotations for parts. 2022-12-22 10:02:21 -06:00
Luis C.M 037711893d Added more functions for the IJobPuppet interface. 2022-12-22 01:37:05 -06:00
Luis C.M 1d6499ea48 Added puppet animations and more functions for the IJobPuppet interface. 2022-12-22 01:36:50 -06:00
Luis C.M 5d520837b1 Implemented a way to play ISound(s) to players without using a sound ID. 2022-12-21 19:07:19 -06:00
Luis C.M a895c8bd24 NpcAPI:
-Added millisToTime(long) and ticksToTime(long) functions to return time formatted strings from long values.

IPlayerQuestData:
-Added last completed time functions for repeating quests.

IQuest:
-Added repeat functions for repeating quests.

ServerCloneController:
-Fixed cloned NPCs having identical UUIDs.
2022-12-20 09:21:39 -06:00
Luis C.M 73ceeab907 Tracked quest data is sent for the next quest when a quest is completed now. 2022-12-19 17:18:28 -06:00
Luis C.M 808de24db4 Player data is now saved to disk when a quest is finished. Removed an unused packet. 2022-12-19 17:07:50 -06:00
Luis C.M cfac349265 Fixed quest reward null pointer exception. 2022-12-19 16:09:18 -06:00
Luis C.M 3d498814f9 Implemented custom commands. 2022-12-18 15:54:14 -06:00
Luis C.M a47af08d0f Fixed spawning clones without checking for region protection. 2022-12-18 02:58:12 -06:00
Luis C.M 51a556db23 NpcAPI:
++ hasGlobalObject(String)
2022-12-16 19:36:47 -06:00
Luis C.M 6f33b9df92 NpcAPI:
++ hasGlobalObject(String)
2022-12-16 19:36:39 -06:00
Luis C.M 7a715ef308 NpcAPI:
Added functions for adding keywords to global script running
++ addGlobalObject(String,Object)
++ removeGlobalObject(String)
++ getEngineObjects()
2022-12-14 17:53:57 -06:00
Luis C.M 718a867411 NpcAPI:
Added createItemFromNBT(INbt) function.
2022-12-14 16:44:23 -06:00
Luis C.M 3945e7ffb8 NpcAPI:
Added createItemFromNBT(INbt) function.
2022-12-14 16:44:13 -06:00
Luis C.M 3152cf2379 ScriptController:
-Fixed engine test null pointer exception.
2022-12-14 01:55:32 -06:00
Luis C.M 958aeea46a ScriptNpc:
-Fixed setRole and setJob functions.
2022-12-07 23:38:15 -06:00
Luis C.M 68600d7d00 Added additional GraalJS flags 2022-11-27 23:56:38 -06:00
Luis C.M 57920b02b7 Merge remote-tracking branch 'origin/dev' into dev 2022-11-27 21:43:36 -06:00
Luis C.M 8e6f5b10d1 Implemented GraalJS support. 2022-11-27 21:43:29 -06:00
630 changed files with 14285 additions and 6300 deletions

No files matched your search

+50 -17
View File
@@ -1,21 +1,54 @@
MIT License CustomNPC+ is distributed under a reasonably open license. You probably want to have a read through this if you want to do something with it other than just play.
Copyright (c) 2021 KAMKEEL You are completely free and have the right to Use, Share and Adapt the mod. These rights can not be removed from you as long as follow the license terms.
If you simply wish to play with the mod and do nothing else, go for it, this license is of no use to you.
Permission is hereby granted, free of charge, to any person obtaining a copy TL;DR
of this software and associated documentation files (the "Software"), to deal > You CAN
in the Software without restriction, including without limitation the rights -- Fork and modify the code.
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -- Submit Pull Requests to this repository.
copies of the Software, and to permit persons to whom the Software is -- Copy portions of this code for use in other projects.
furnished to do so, subject to the following conditions: -- Write your own code that uses this code as a dependency. (addon mods!)
The above copyright notice and this permission notice shall be included in all > You CANNOT
copies or substantial portions of the Software. -- Redistribute this in its entirety as source or compiled code.
-- Create or distribute code which contains 50% or more Functionally Equivalent Statements* from this repository.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR > You MUST
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -- Maintain a visible repository of your code which is inspired by, derived from, or copied from this code. Basically, if you use it, pay it forward. You keep rights to your OWN code, but you still must make your source visible.
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER General Clauses
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, Clauses that apply in general to any of the uses that follow.
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - Personal Permission Clause
SOFTWARE. I will only give personal permission if I, KAMKEEL, am directly asked. If personal permission is given this does not imply endorsement.
- Waive Clause
All restrictive clauses in this license can be ignored with personal permission. Read the above clause.
- Extensive Clause
This license applies to CustomNPC+, the CustomNPC+ website, the legacy CustomNPC+ website and all other code, assets or binaries found on this website or the github repository unless otherwise indicated.
- Informal Clause
This license will not hold up in court. I have no intention of suing anyone for breaking it, the worst that can happen to you if you do is that I'll get annoyed and ask you to rectify your mistake. If you use a public distribution platform (such as CurseForge) it's also possible your project will get taken down. Breaking the license also makes you a jerk, and you don't want to be a jerk, do you?
If you want to Distribute CustomNPC+
"Distribution" refers to making available binaries, assets, or source of the mod available from the original sources as part of your modpack or otherwise.
- Attribution Clause
You must give appropriate credit to KAMKEEL as the creator of CustomNPC+ or the parts of it you're using. Noppes can also be credit as the original Mod Author. If you do any alterations the fact that you do so should also be indicated. A link back is optional but it would be cool if you would do so.
- Redistribution Clause
You may not redistribute the enitirity of the source code provided, unless heavy modifications are made to it as a whole. More than 50% of the code cannot be redistributed unless direct permission is provided from either KAMKEEL or Noppes.
- Non-Monetary Clause
You may not charge for access to the distribution itself or gain money through it, this includes any type of inline advertisement, such as url shorteners (adf.ly or otherwise) or ads in your service slowing the download down. This includes restricting any amount of access behind a paywall. Charging for ingame goods such as mod items or cosmetic features on a server does not count as distribution and falls purely under the Mojang Terms of Service.
If you want to Feature CustomNPC+
"Featuring" refers to using CustomNPC+ in an environment where you do not distribute binaries, assets, or source. An example would be a YouTube Let's Play.
- Thief Clause
You must not claim that you made CustomNPC+. Giving appropriate credit to KAMKEEL as the creator of CustomNPC+ makes you cooler, but you don't have to do it if you don't want to.
If you want to Use CustomNPC+ Code or Assets
Usage of code or assets falls under the Extensive Clause.
- External Clause
Certain parts of the codebase are indicated to be licensed under alternative licenses. You must obey those licenses.
- Attribution Clause
You must give appropriate credit to KAMKEEL as the creator of CustomNPC+ or the parts of it you're using. Noppes can also be credit as the original Mod Author. If you do any alterations the fact that you do so should also be indicated. A link back is optional but it would be cool if you would do so.
- Copyleft Clause
Your project must be open source (have its source visible and allow for redistribution and modification) and include a clause similar to this one in its license.
- API Clause
Any of the other clauses under this section do not apply to any CustomNPC+ API code (the subdirectory src/api or https://github.com/KAMKEEL/CustomNPC-Plus-API). However, if CustomNPC+ API code is used, it must be included verbatim as it was obtained.
+19 -12
View File
@@ -1,38 +1,43 @@
## 👋 Welcome to the CustomNPC+ Repository. ## 👋 Welcome to the CustomNPC+ Repository.
![](images/logo.png) ![](images/logo_banner.png)
> 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.
**CurseForge**: [Download](https://www.curseforge.com/minecraft/mc-mods/customnpc-plus) ----------------
[![Discord Badge](https://img.shields.io/badge/KAMKEEL_Discord-7289DA?style=for-the-badge&logo=discord&logoColor=white)](https://discord.gg/pQqRTvFeJ5) <a href="https://discord.gg/pQqRTvFeJ5"> <img src="https://img.shields.io/badge/KAMKEEL_Discord-7289DA?style=for-the-badge&logo=discord&logoColor=white" width="400" height="60"> </a>
[![Download CustomNPC+](https://img.shields.io/badge/CustomNPC+-0081CB?style=for-the-badge&logo=material-ui&logoColor=white)](https://www.curseforge.com/minecraft/mc-mods/customnpc-plus) <a href="https://ko-fi.com/kamkeel"> <img src="https://img.shields.io/badge/Support_Me_|_Ko--fi-F16061?style=for-the-badge&logo=ko-fi&logoColor=white" alt="Support Me" width="400" height="60"> </a>
[![Download CustomNPC+](https://img.shields.io/badge/MorePlayerModels+-0081CB?style=for-the-badge&logo=material-ui&logoColor=white)](https://www.curseforge.com/minecraft/mc-mods/moreplayermodels-plus)
[![Download CustomNPC+](https://img.shields.io/badge/CustomNPC+-0081CB?style=for-the-badge&logo=material-ui&logoColor=white)](https://modrinth.com/mod/customnpc-plus)
[![Download MPM+](https://img.shields.io/badge/MorePlayerModels+-0081CB?style=for-the-badge&logo=material-ui&logoColor=white)](https://www.curseforge.com/minecraft/mc-mods/moreplayermodels-plus)
[![Download PluginMod](https://img.shields.io/badge/Plugin_Mod-0081CB?style=for-the-badge&logo=material-ui&logoColor=white)](https://github.com/KAMKEEL/Plugin-Mod) [![Download PluginMod](https://img.shields.io/badge/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" width="180" height="27"> </a>
----------------
### ❗ 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 and develop my own branch version for 1.7.10. 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)
### ⬇️ Downloads
- **Modrinth**: [Download](https://modrinth.com/mod/customnpc-plus)
- **CurseForge**: [Download](https://www.curseforge.com/minecraft/mc-mods/customnpc-plus)
### 🔹 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:
- Flying NPC (Smart Pathfinding) - Flying NPC (Smart Pathfinding)
- 1.8 Skin Support (64x64) (3D Bodywear) - 1.8 Skin Support (64x64) (Alex/Steve64)
- Full URL64 Selector (Downloads FULL Size Images for Custom Mob Skins) - Full URL64 Selector (Downloads FULL Size Images for Custom Mob Skins)
- Alex Model (64x64)
- Additional Parts: [Wings, Fins, Capes, Horns, Tail] - Additional Parts: [Wings, Fins, Capes, Horns, Tail]
- Hide Body Parts [Arms, Legs, Head, Body] - Hide Body Parts [Arms, Legs, Head, Body]
- Custom Overlays - Custom Overlays
- Updated Cloner GUI (with more Tabs!) - Animation Maker
- Enhanced Cloner GUI (More Tabs, Filters, Tags)
- Markov Name Generator - Markov Name Generator
- Backported GUI Features
- Dark Mode GUI (Link Below) - Dark Mode GUI (Link Below)
- 1.12 Scripting Features (Details below) - 1.12 Scripting Features (Details below)
- Script Logging (See Config)
#### Scripting: #### Scripting:
- CustomNPC+ Api: [API](https://github.com/KAMKEEL/CustomNPC-Plus-API) - CustomNPC+ Api: [API](https://github.com/KAMKEEL/CustomNPC-Plus-API)
@@ -41,7 +46,9 @@ This mod is an ***update*** to CustomNPC and not an add-on. Do not install Custo
- Player Overlays - Player Overlays
- Script Timers - Script Timers
- Global Scripts - Global Scripts
- Script Logging
- GUI Overlays - GUI Overlays
- Event Scripting
(We never remove script functionality, only add on existing functions) (We never remove script functionality, only add on existing functions)
## 🔰 Skin Model Feature: ## 🔰 Skin Model Feature:
+7 -4
View File
@@ -34,7 +34,7 @@ configurations {
apply plugin: 'forge' apply plugin: 'forge'
version = "1.7" version = "1.8.4"
group= "com.kamkeel.customnpc-plus" // http://maven.apache.org/guides/mini/guide-naming-conventions.html group= "com.kamkeel.customnpc-plus" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "CustomNPC-Plus" archivesBaseName = "CustomNPC-Plus"
@@ -89,8 +89,6 @@ processResources
} }
} }
sourceSets {main { output.resourcesDir = output.classesDir }}
jar { jar {
from sourceSets.api.output from sourceSets.api.output
@@ -113,7 +111,7 @@ def refMapForYourConfig = 'customnpcs.refmap.json'
def relativePathToMixinAP = 'tools/mixin-0.8-SNAPSHOT.jar' def relativePathToMixinAP = 'tools/mixin-0.8-SNAPSHOT.jar'
if(!embedMixin){ if(!embedMixin){
version += "+nomixin" version += "-nomixin"
} }
repositories { repositories {
@@ -197,6 +195,11 @@ afterEvaluate {
} }
} }
task deobfJar(type: Jar) {
classifier = 'dev'
from sourceSets.main.output
}
sourceSets { sourceSets {
main { main {
ext.refMap = refMapForYourConfig ext.refMap = refMapForYourConfig
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 775 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

+1 -1
Submodule src/api updated: 3f8d6e5581...8c61d07b10.
+45 -28
View File
@@ -3,6 +3,7 @@ package foxz.command;
import java.util.Arrays; import java.util.Arrays;
import java.util.Set; import java.util.Set;
import jdk.nashorn.internal.runtime.regexp.joni.Config;
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;
@@ -10,6 +11,7 @@ import net.minecraft.block.BlockVine;
import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.EntityPlayerMP;
import noppes.npcs.CustomNpcs; import noppes.npcs.CustomNpcs;
import noppes.npcs.Server; import noppes.npcs.Server;
import noppes.npcs.config.ConfigMain;
import noppes.npcs.constants.EnumPacketClient; import noppes.npcs.constants.EnumPacketClient;
import noppes.npcs.controllers.ChunkController; import noppes.npcs.controllers.ChunkController;
import foxz.commandhelper.ChMcLogger; import foxz.commandhelper.ChMcLogger;
@@ -37,19 +39,22 @@ public class CmdConfig extends ChMcLogger {
) )
public boolean leavesdecay(String[] args){ public boolean leavesdecay(String[] args){
if(args.length == 0){ if(args.length == 0){
sendmessage("LeavesDecay: " + CustomNpcs.LeavesDecayEnabled); sendmessage("LeavesDecay: " + ConfigMain.LeavesDecayEnabled);
} }
else{ else{
CustomNpcs.LeavesDecayEnabled = Boolean.parseBoolean(args[0]); ConfigMain.LeavesDecayEnabled = Boolean.parseBoolean(args[0]);
CustomNpcs.Config.updateConfig(); ConfigMain.LeavesDecayEnabledProperty.set(ConfigMain.LeavesDecayEnabled);
if(ConfigMain.config.hasChanged()){
ConfigMain.config.save();
}
Set<String> names = Block.blockRegistry.getKeys(); Set<String> names = Block.blockRegistry.getKeys();
for(String name : names){ for(String name : names){
Block block = (Block) Block.blockRegistry.getObject(name); Block block = (Block) Block.blockRegistry.getObject(name);
if(block instanceof BlockLeavesBase){ if(block instanceof BlockLeavesBase){
block.setTickRandomly(CustomNpcs.LeavesDecayEnabled); block.setTickRandomly(ConfigMain.LeavesDecayEnabled);
} }
} }
sendmessage("LeavesDecay is now " + CustomNpcs.LeavesDecayEnabled); sendmessage("LeavesDecay is now " + ConfigMain.LeavesDecayEnabled);
} }
return true; return true;
} }
@@ -62,19 +67,22 @@ public class CmdConfig extends ChMcLogger {
) )
public boolean vinegrowth(String[] args){ public boolean vinegrowth(String[] args){
if(args.length == 0){ if(args.length == 0){
sendmessage("VineGrowth: " + CustomNpcs.VineGrowthEnabled); sendmessage("VineGrowth: " + ConfigMain.VineGrowthEnabled);
} }
else{ else{
CustomNpcs.VineGrowthEnabled = Boolean.parseBoolean(args[0]); ConfigMain.VineGrowthEnabled = Boolean.parseBoolean(args[0]);
CustomNpcs.Config.updateConfig(); ConfigMain.VineGrowthEnabledProperty.set(ConfigMain.VineGrowthEnabled);
if(ConfigMain.config.hasChanged()){
ConfigMain.config.save();
}
Set<String> names = Block.blockRegistry.getKeys(); Set<String> names = Block.blockRegistry.getKeys();
for(String name : names){ for(String name : names){
Block block = (Block) Block.blockRegistry.getObject(name); Block block = (Block) Block.blockRegistry.getObject(name);
if(block instanceof BlockVine){ if(block instanceof BlockVine){
block.setTickRandomly(CustomNpcs.VineGrowthEnabled); block.setTickRandomly(ConfigMain.VineGrowthEnabled);
} }
} }
sendmessage("VineGrowth is now " + CustomNpcs.VineGrowthEnabled); sendmessage("VineGrowth is now " + ConfigMain.VineGrowthEnabled);
} }
return true; return true;
} }
@@ -87,19 +95,22 @@ public class CmdConfig extends ChMcLogger {
) )
public boolean icemelts(String[] args){ public boolean icemelts(String[] args){
if(args.length == 0){ if(args.length == 0){
sendmessage("IceMelts: " + CustomNpcs.IceMeltsEnabled); sendmessage("IceMelts: " + ConfigMain.IceMeltsEnabled);
} }
else{ else{
CustomNpcs.IceMeltsEnabled = Boolean.parseBoolean(args[0]); ConfigMain.IceMeltsEnabled = Boolean.parseBoolean(args[0]);
CustomNpcs.Config.updateConfig(); ConfigMain.IceMeltsEnabledProperty.set(ConfigMain.IceMeltsEnabled);
if(ConfigMain.config.hasChanged()){
ConfigMain.config.save();
}
Set<String> names = Block.blockRegistry.getKeys(); Set<String> names = Block.blockRegistry.getKeys();
for(String name : names){ for(String name : names){
Block block = (Block) Block.blockRegistry.getObject(name); Block block = (Block) Block.blockRegistry.getObject(name);
if(block instanceof BlockIce){ if(block instanceof BlockIce){
block.setTickRandomly(CustomNpcs.IceMeltsEnabled); block.setTickRandomly(ConfigMain.IceMeltsEnabled);
} }
} }
sendmessage("IceMelts is now " + CustomNpcs.IceMeltsEnabled); sendmessage("IceMelts is now " + ConfigMain.IceMeltsEnabled);
} }
return true; return true;
} }
@@ -112,12 +123,15 @@ public class CmdConfig extends ChMcLogger {
) )
public boolean guns(String[] args){ public boolean guns(String[] args){
if(args.length == 0){ if(args.length == 0){
sendmessage("GunsEnabled: " + CustomNpcs.GunsEnabled); sendmessage("GunsEnabled: " + ConfigMain.GunsEnabled);
} }
else{ else{
CustomNpcs.GunsEnabled = Boolean.parseBoolean(args[0]); ConfigMain.GunsEnabled = Boolean.parseBoolean(args[0]);
CustomNpcs.Config.updateConfig(); ConfigMain.GunsEnabledProperty.set(ConfigMain.GunsEnabled);
sendmessage("GunsEnabled is now " + CustomNpcs.GunsEnabled); if(ConfigMain.config.hasChanged()){
ConfigMain.config.save();
}
sendmessage("GunsEnabled is now " + ConfigMain.GunsEnabled);
} }
return true; return true;
} }
@@ -147,24 +161,27 @@ public class CmdConfig extends ChMcLogger {
) )
public boolean chunkloaders(String[] args){ public boolean chunkloaders(String[] args){
if(args.length == 0){ if(args.length == 0){
sendmessage("ChunkLoaders: " + ChunkController.instance.size() + "/" + CustomNpcs.ChunkLoaders); sendmessage("ChunkLoaders: " + ChunkController.instance.size() + "/" + ConfigMain.ChunkLoaders);
} }
else{ else{
try{ try{
CustomNpcs.ChunkLoaders = Integer.parseInt(args[0]); ConfigMain.ChunkLoaders = Integer.parseInt(args[0]);
} }
catch(NumberFormatException ex){ catch(NumberFormatException ex){
sendmessage("Didnt get a number"); sendmessage("Didnt get a number");
return false; return false;
} }
CustomNpcs.Config.updateConfig();
ConfigMain.ChunkLoadersProperty.set(ConfigMain.ChunkLoaders);
int size = ChunkController.instance.size(); if(ConfigMain.config.hasChanged()){
if(size > CustomNpcs.ChunkLoaders){ ConfigMain.config.save();
ChunkController.instance.unload(size - CustomNpcs.ChunkLoaders);
sendmessage(size - CustomNpcs.ChunkLoaders + " chunksloaders unloaded");
} }
sendmessage("ChunkLoaders: " + ChunkController.instance.size() + "/" + CustomNpcs.ChunkLoaders); int size = ChunkController.instance.size();
if(size > ConfigMain.ChunkLoaders){
ChunkController.instance.unload(size - ConfigMain.ChunkLoaders);
sendmessage(size - ConfigMain.ChunkLoaders + " chunksloaders unloaded");
}
sendmessage("ChunkLoaders: " + ChunkController.instance.size() + "/" + ConfigMain.ChunkLoaders);
} }
return true; return true;
} }
+2 -2
View File
@@ -50,7 +50,7 @@ public class CmdDialog extends ChMcLogger {
} }
for(PlayerData playerdata : data){ for(PlayerData playerdata : data){
playerdata.dialogData.dialogsRead.add(diagid); playerdata.dialogData.dialogsRead.add(diagid);
playerdata.savePlayerDataOnFile(); playerdata.save();
} }
return true; return true;
} }
@@ -76,7 +76,7 @@ public class CmdDialog extends ChMcLogger {
} }
for(PlayerData playerdata : data){ for(PlayerData playerdata : data){
playerdata.dialogData.dialogsRead.remove(diagid); playerdata.dialogData.dialogsRead.remove(diagid);
playerdata.savePlayerDataOnFile(); playerdata.save();
} }
return true; return true;
} }
+124 -163
View File
@@ -41,173 +41,170 @@ import foxz.commandhelper.permissions.PlayerOnly;
) )
public class CmdNoppes extends ChMcLogger { public class CmdNoppes extends ChMcLogger {
public CmdFaction cmdfaction = new CmdFaction(ctorParm); public CmdFaction cmdfaction = new CmdFaction(ctorParm);
public CmdNpc cmdnpc= new CmdNpc(ctorParm); public CmdNpc cmdnpc = new CmdNpc(ctorParm);
public static Map<String,Class<?>> SlayMap = new LinkedHashMap<String,Class<?>>(); public static Map<String, Class<?>> SlayMap = new LinkedHashMap<String, Class<?>>();
public CmdNoppes(Object sender) { public CmdNoppes(Object sender) {
super(sender); super(sender);
SlayMap.clear(); SlayMap.clear();
SlayMap.put("all",EntityLivingBase.class); SlayMap.put("all", EntityLivingBase.class);
SlayMap.put("mobs",EntityMob.class); SlayMap.put("mobs", EntityMob.class);
SlayMap.put("animals", EntityAnimal.class); SlayMap.put("animals", EntityAnimal.class);
SlayMap.put("items", EntityItem.class); SlayMap.put("items", EntityItem.class);
SlayMap.put("xporbs", EntityXPOrb.class); SlayMap.put("xporbs", EntityXPOrb.class);
SlayMap.put("npcs", EntityNPCInterface.class); SlayMap.put("npcs", EntityNPCInterface.class);
HashMap<String,Class<?>> list = new HashMap<String,Class<?>>(EntityList.stringToClassMapping); HashMap<String, Class<?>> list = new HashMap<String, Class<?>>(EntityList.stringToClassMapping);
for(String name : list.keySet()){ for (String name : list.keySet()) {
Class<?> cls = list.get(name); Class<?> cls = list.get(name);
if(EntityNPCInterface.class.isAssignableFrom(cls)) if (EntityNPCInterface.class.isAssignableFrom(cls))
continue; continue;
if(!EntityLivingBase.class.isAssignableFrom(cls)) if (!EntityLivingBase.class.isAssignableFrom(cls))
continue; continue;
SlayMap.put(name.toLowerCase(), list.get(name)); SlayMap.put(name.toLowerCase(), list.get(name));
} }
SlayMap.remove("monster"); SlayMap.remove("monster");
SlayMap.remove("mob"); SlayMap.remove("mob");
} }
@SubCommand( @SubCommand(
name = "faction", name = "faction",
desc = "Faction operations", desc = "Faction operations",
usage = "<player> <faction> <command>", usage = "<player> <faction> <command>",
permissions = {OpOnly.class, ParamCheck.class} permissions = {OpOnly.class, ParamCheck.class}
) )
public Boolean faction(String[] args) { public Boolean faction(String[] args) {
String playername = args[0]; String playername = args[0];
String factionname = args[1]; String factionname = args[1];
cmdfaction.data = getPlayersData(playername); cmdfaction.data = getPlayersData(playername);
if (cmdfaction.data.isEmpty()) { if (cmdfaction.data.isEmpty()) {
sendmessage(String.format("Unknow player '%s'", playername)); sendmessage(String.format("Unknow player '%s'", playername));
return false; return false;
} }
try{ try {
cmdfaction.selectedFaction = FactionController.getInstance().get(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 }
} if (cmdfaction.selectedFaction == null) {
if (cmdfaction.selectedFaction == null) { sendmessage(String.format("Unknow facion '%s", factionname));
sendmessage(String.format("Unknow facion '%s", factionname)); return false;
return false; }
} args = Arrays.copyOfRange(args, 2, args.length);
args = Arrays.copyOfRange(args, 2, args.length); cmdfaction.processCommand(this.pcParam, args);
cmdfaction.processCommand(this.pcParam, args);
for (PlayerData playerdata : cmdfaction.data) {
for(PlayerData playerdata : cmdfaction.data){ playerdata.save();
playerdata.savePlayerDataOnFile(); }
} return true;
return true; }
}
@SubCommand(
@SubCommand( desc = "NPC manipulations",
desc="NPC manipulations", usage = "<npc> <command>",
usage="<npc> <command>", permissions = {OpOnly.class, ParamCheck.class}
permissions={OpOnly.class,ParamCheck.class} )
) public boolean npc(String[] args) {
public boolean npc(String[] args){ String npcname = args[0].replace("%", " ");
String npcname=args[0].replace("%", " "); args = Arrays.copyOfRange(args, 1, args.length);
args = Arrays.copyOfRange(args, 1, args.length); if (args[0].equalsIgnoreCase("create")) {
if(args[0].equalsIgnoreCase("create")){ cmdnpc.processCommand(this.pcParam, new String[]{args[0], npcname});
cmdnpc.processCommand(this.pcParam, new String[]{args[0], npcname}); return true;
return true; }
} int x = pcParam.getPlayerCoordinates().posX;
int x = pcParam.getPlayerCoordinates().posX; int y = pcParam.getPlayerCoordinates().posY;
int y = pcParam.getPlayerCoordinates().posY; int z = pcParam.getPlayerCoordinates().posZ;
int z = pcParam.getPlayerCoordinates().posZ; List<EntityNPCInterface> list = getNearbeEntityFromPlayer(EntityNPCInterface.class, pcParam.getEntityWorld(), x, y, z, 80);
List<EntityNPCInterface> list = getNearbeEntityFromPlayer(EntityNPCInterface.class, pcParam.getEntityWorld(), x, y, z, 80); EntityNPCInterface closest = null;
EntityNPCInterface closest = null; for (EntityNPCInterface npc : list) {
for (EntityNPCInterface npc : list) { String name = npc.display.name.replace(" ", "_");
String name = npc.display.name.replace(" ", "_"); if (name.equalsIgnoreCase(npcname)) {
if (name.equalsIgnoreCase(npcname)){ if (closest == null || closest.getDistanceSq(x, y, z) > npc.getDistanceSq(x, y, z))
if(closest == null || closest.getDistanceSq(x, y, z) > npc.getDistanceSq(x, y, z)) closest = npc;
closest = npc; }
} }
} if (closest != null) {
if(closest != null){ cmdnpc.selectedNpc = closest;
cmdnpc.selectedNpc=closest; cmdnpc.processCommand(this.pcParam, args);
cmdnpc.processCommand(this.pcParam, args); cmdnpc.selectedNpc = null;
cmdnpc.selectedNpc = null; } else
} sendmessage(String.format("NPC '%s' was not found", npcname));
else return true;
sendmessage(String.format("NPC '%s' was not found",npcname)); }
return true;
} @SubCommand(
name = "slay",
@SubCommand( desc = "Kills given entity within range. Also has all, mobs, animal options. Can have multiple types",
name = "slay", usage = "<type>.. [range]",
desc = "Kills given entity within range. Also has all, mobs, animal options. Can have multiple types", permissions = {PlayerOnly.class, OpOnly.class, ParamCheck.class}
usage = "<type>.. [range]", )
permissions = {PlayerOnly.class, OpOnly.class, ParamCheck.class} public Boolean slay(String[] args) {
) EntityPlayerMP player = (EntityPlayerMP) pcParam;
public Boolean slay(String[] args) {
EntityPlayerMP player = (EntityPlayerMP) pcParam;
ArrayList<Class<?>> toDelete = new ArrayList<Class<?>>(); ArrayList<Class<?>> toDelete = new ArrayList<Class<?>>();
boolean deleteNPCs = false; boolean deleteNPCs = false;
for(String delete : args){ for (String delete : args) {
delete = delete.toLowerCase(); delete = delete.toLowerCase();
Class<?> cls = SlayMap.get(delete); Class<?> cls = SlayMap.get(delete);
if(cls != null) if (cls != null)
toDelete.add(cls); toDelete.add(cls);
if(delete.equals("mobs")){ if (delete.equals("mobs")) {
toDelete.add(EntityGhast.class); toDelete.add(EntityGhast.class);
toDelete.add(EntityDragon.class); toDelete.add(EntityDragon.class);
} }
if(delete.equals("npcs")) if (delete.equals("npcs"))
deleteNPCs = true; deleteNPCs = true;
} }
int count = 0; int count = 0;
int range = 120; int range = 120;
try{ try {
range = Integer.parseInt(args[args.length - 1]); range = Integer.parseInt(args[args.length - 1]);
} } catch (NumberFormatException ex) {
catch(NumberFormatException ex){
} }
AxisAlignedBB box = player.boundingBox.expand(range, range, range); AxisAlignedBB box = player.boundingBox.expand(range, range, range);
List<Entity> list = player.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, box); List<Entity> list = player.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, box);
for(Entity entity : list){ for (Entity entity : list) {
if(entity instanceof EntityPlayer) if (entity instanceof EntityPlayer)
continue; continue;
if(entity instanceof EntityTameable && ((EntityTameable)entity).isTamed()) if (entity instanceof EntityTameable && ((EntityTameable) entity).isTamed())
continue; continue;
if(entity instanceof EntityNPCInterface && !deleteNPCs) if (entity instanceof EntityNPCInterface && !deleteNPCs)
continue; continue;
if(delete(entity,toDelete)) if (delete(entity, toDelete))
count++; count++;
} }
if(toDelete.contains(EntityXPOrb.class)){ if (toDelete.contains(EntityXPOrb.class)) {
list = player.worldObj.getEntitiesWithinAABB(EntityXPOrb.class, box); list = player.worldObj.getEntitiesWithinAABB(EntityXPOrb.class, box);
for(Entity entity : list){ for (Entity entity : list) {
entity.isDead = true; entity.isDead = true;
count++; count++;
} }
} }
if(toDelete.contains(EntityItem.class)){ if (toDelete.contains(EntityItem.class)) {
list = player.worldObj.getEntitiesWithinAABB(EntityItem.class, box); list = player.worldObj.getEntitiesWithinAABB(EntityItem.class, box);
for(Entity entity : list){ for (Entity entity : list) {
entity.isDead = true; entity.isDead = true;
count++; count++;
} }
} }
player.addChatMessage(new ChatComponentTranslation(count + " entities deleted")); player.addChatMessage(new ChatComponentTranslation(count + " entities deleted"));
return true; return true;
} }
private boolean delete(Entity entity, ArrayList<Class<?>> toDelete) { private boolean delete(Entity entity, ArrayList<Class<?>> toDelete) {
for(Class<?> delete : toDelete){ for (Class<?> delete : toDelete) {
if(delete == EntityAnimal.class && (entity instanceof EntityHorse)){ if (delete == EntityAnimal.class && (entity instanceof EntityHorse)) {
continue; continue;
} }
if(delete.isAssignableFrom(entity.getClass())){ if (delete.isAssignableFrom(entity.getClass())) {
entity.isDead = true; entity.isDead = true;
return true; return true;
} }
@@ -215,53 +212,17 @@ public class CmdNoppes extends ChMcLogger {
return false; return false;
} }
@Override @Override
public List addTabCompletion(ICommandSender par1, String[] args) { public List addTabCompletion(ICommandSender par1, String[] args) {
if(args[0].equalsIgnoreCase("slay")){ if (args[0].equalsIgnoreCase("slay")) {
return CommandBase.getListOfStringsMatchingLastWord(args, SlayMap.keySet().toArray(new String[SlayMap.size()])); return CommandBase.getListOfStringsMatchingLastWord(args, SlayMap.keySet().toArray(new String[SlayMap.size()]));
} }
if(args[0].equalsIgnoreCase("npc") && args.length == 3){ if (args[0].equalsIgnoreCase("npc") && args.length == 3) {
return cmdnpc.addTabCompletion(par1, Arrays.copyOfRange(args, 1, args.length)); return cmdnpc.addTabCompletion(par1, Arrays.copyOfRange(args, 1, args.length));
} }
if(args[0].equalsIgnoreCase("faction") && args.length == 4){ if (args[0].equalsIgnoreCase("faction") && args.length == 4) {
return CommandBase.getListOfStringsMatchingLastWord(args, new String[]{"add", "subtract", "set", "reset", "drop", "create"}); return CommandBase.getListOfStringsMatchingLastWord(args, new String[]{"add", "subtract", "set", "reset", "drop", "create"});
} }
return super.addTabCompletion(par1, args); return super.addTabCompletion(par1, args);
} }
//<editor-fold desc="--- FoxZ fork (keep it pls)"> }
// @SubCommand(
// desc = "Save AltPlayerInv",
// usage = "{player} {inv}",
// permissions={OpOnly.class}
// )
// public boolean sapi(String[] args) {
// EntityPlayer p = getOnlinePlayer(args[0]);
// sendmessage(String.format("noppes.sapi:%s %s", args[0], args[1]));
// if (p == null) {
// sendmessage("noppes.sapi:unkow " + args[0]);
// return false;
// }
// savePlayerAltInv(p, args[1]);
// sendmessage("noppes.sapi:saved");
// return true;
// }
//
// @SubCommand(
// desc = "Load AltPlayerInv",
// usage = "{player} {inv}",
// permissions={OpOnly.class}
// )
// public boolean lapi(String[] args) {
// EntityPlayer p = getOnlinePlayer(args[0]);
// sendmessage(String.format("noppes.lapi:%s %s", args[0], args[1]));
// if (p == null) {
// sendmessage("noppes.sapi:unknow " + args[0]);
// return false;
// }
//
// loadPlayerAltInv(p, args[1]);
// sendmessage("noppes.lapi:loaded");
// return true;
// }
//</editor-fold>
}
+4 -4
View File
@@ -56,7 +56,7 @@ public class CmdQuest extends ChMcLogger{
continue; continue;
QuestData questdata = new QuestData(quest); QuestData questdata = new QuestData(quest);
playerdata.questData.activeQuests.put(questid, questdata); playerdata.questData.activeQuests.put(questid, questdata);
playerdata.savePlayerDataOnFile(); playerdata.save();
if(playerdata.player != null){ if(playerdata.player != null){
Server.sendData((EntityPlayerMP)playerdata.player, EnumPacketClient.MESSAGE, "quest.newquest", quest.title); Server.sendData((EntityPlayerMP)playerdata.player, EnumPacketClient.MESSAGE, "quest.newquest", quest.title);
Server.sendData((EntityPlayerMP)playerdata.player, EnumPacketClient.CHAT, "quest.newquest", ": ", quest.title); Server.sendData((EntityPlayerMP)playerdata.player, EnumPacketClient.CHAT, "quest.newquest", ": ", quest.title);
@@ -93,7 +93,7 @@ public class CmdQuest extends ChMcLogger{
} }
for(PlayerData playerdata : data){ for(PlayerData playerdata : data){
playerdata.questData.finishedQuests.put(questid, System.currentTimeMillis()); playerdata.questData.finishedQuests.put(questid, System.currentTimeMillis());
playerdata.savePlayerDataOnFile(); playerdata.save();
} }
return true; return true;
} }
@@ -124,7 +124,7 @@ public class CmdQuest extends ChMcLogger{
} }
for(PlayerData playerdata : data){ for(PlayerData playerdata : data){
playerdata.questData.activeQuests.remove(questid); playerdata.questData.activeQuests.remove(questid);
playerdata.savePlayerDataOnFile(); playerdata.save();
} }
return true; return true;
} }
@@ -156,7 +156,7 @@ public class CmdQuest extends ChMcLogger{
for(PlayerData playerdata : data){ for(PlayerData playerdata : data){
playerdata.questData.activeQuests.remove(questid); playerdata.questData.activeQuests.remove(questid);
playerdata.questData.finishedQuests.remove(questid); playerdata.questData.finishedQuests.remove(questid);
playerdata.savePlayerDataOnFile(); playerdata.save();
} }
return true; return true;
} }
@@ -0,0 +1,80 @@
package foxz.command;
import net.minecraft.command.CommandBase;
import net.minecraft.command.ICommandSender;
import noppes.npcs.api.ICommand;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class ScriptedCommand extends CommandBase implements ICommand {
private String commandName;
private int permissionLevel;
private String commandUsage;
private ArrayList<String> aliases;
public ScriptedCommand(String commandName, int permissionLevel) {
this.commandName = commandName;
this.permissionLevel = permissionLevel;
this.commandUsage = "";
this.aliases = new ArrayList<>();
}
public void setCommandName(String commandName) {
this.commandName = commandName;
}
public void setCommandUsage(String commandUsage) {
this.commandUsage = commandUsage;
}
public void setPermissionLevel(int permissionLevel) {
this.permissionLevel = permissionLevel;
}
@Override
public String getCommandName() {
return this.commandName;
}
@Override
public String getCommandUsage(ICommandSender p_71518_1_) {
return this.commandUsage;
}
public String getCommandUsage() {
return this.commandUsage;
}
@Override
public void processCommand(ICommandSender p_71515_1_, String[] p_71515_2_) {
}
public int getRequiredPermissionLevel()
{
return this.permissionLevel;
}
public int getPermissionLevel() { return this.getRequiredPermissionLevel(); }
public List<?> getCommandAliases() {
return this.aliases;
}
public String[] getAliases() {
return this.aliases.toArray(new String[0]);
}
public void addAliases(String... aliases) {
this.aliases.addAll(Arrays.asList(aliases));
}
public boolean hasAlias(String alias) {
return this.aliases.contains(alias);
}
public void removeAlias(String alias) {
this.aliases.remove(alias);
}
}
@@ -0,0 +1,90 @@
package kamkeel.command;
import net.minecraft.command.CommandException;
import net.minecraft.command.ICommandSender;
import noppes.npcs.controllers.AnimationController;
import noppes.npcs.controllers.PlayerDataController;
import noppes.npcs.controllers.data.Animation;
import noppes.npcs.controllers.data.PlayerData;
import java.util.Arrays;
import java.util.List;
public class AnimationCommand extends CommandKamkeelBase {
public Animation selectedAnimation;
public List<PlayerData> data;
@Override
public String getCommandName() {
return "animation";
}
@Override
public String getDescription() {
return "Animation operations";
}
@Override
public String getUsage() {
return "<player> <subcommand>";
}
@Override
public boolean runSubCommands(){
return false;
}
@Override
public void processCommand(ICommandSender sender, String[] args) throws CommandException {
String playername = args[0];
data = PlayerDataController.instance.getPlayersData(sender, playername);
if (data.isEmpty()) {
throw new CommandException("Unknown player: " + playername);
}
processSubCommand(sender, args[1], Arrays.copyOfRange(args, 2, args.length));
data.get(0).animationData.updateClient();
data.get(0).save();
}
@SubCommand(desc = "enable animation")
public void on(ICommandSender sender, String[] args) throws CommandException {
data.get(0).animationData.setEnabled(true);
sendMessage(sender, String.format("Animations enabled for Player %s", data.get(0).player.getCommandSenderName()));
}
@SubCommand(
desc = "Set animation",
usage = "<animation>"
)
public void set(ICommandSender sender, String[] args) throws CommandException {
if(args.length != 1){
throw new CommandException("Please include the animation name:" + "<player> set <animation name>");
}
String animationName = args[0];
selectedAnimation = AnimationController.getInstance().getAnimationFromName(animationName);
if (selectedAnimation == null) {
throw new CommandException("Unknown animation: " + animationName);
}
data.get(0).animationData.setAnimation(selectedAnimation);
sendMessage(sender, String.format("Animation %s set for Player %s", selectedAnimation.getName(), data.get(0).player.getCommandSenderName()));
}
@SubCommand(desc = "disable animation")
public void off(ICommandSender sender, String[] args) throws CommandException {
data.get(0).animationData.setEnabled(false);
sendMessage(sender, String.format("Animations disabled for Player %s", data.get(0).player.getCommandSenderName()));
}
@SubCommand(desc = "play animation")
public void clear(ICommandSender sender, String[] args) throws CommandException {
data.get(0).animationData.setEnabled(false);
data.get(0).animationData.setAnimation(null);
sendMessage(sender, String.format("Animations cleared for Player %s", data.get(0).player.getCommandSenderName()));
}
}
@@ -0,0 +1,340 @@
package kamkeel.command;
import java.util.List;
import foxz.utils.Utils;
import net.minecraft.block.Block;
import net.minecraft.command.CommandBase;
import net.minecraft.command.CommandException;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityList;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import noppes.npcs.controllers.ServerCloneController;
import noppes.npcs.entity.EntityNPCInterface;
public class CloneCommand extends CommandKamkeelBase {
@Override
public String getCommandName() {
return "clone";
}
@Override
public String getDescription() {
return "Clone operation (server side)";
}
@SubCommand(
desc = "Add NPC(s) to clone storage",
usage = "<npc> <tab> [clonedname]",
permission = 4
)
public void add(ICommandSender sender, String[] args) {
int tab = 0;
try{
tab = Integer.parseInt(args[1]);
if(tab < 0 || tab > 15){
sendError(sender, "Tab must be within 1-15");
return;
}
}
catch(NumberFormatException ex){
sendError(sender, String.format("Tab is not a number: %s", args[1]));
return;
}
int x = sender.getPlayerCoordinates().posX;
int y = sender.getPlayerCoordinates().posY;
int z = sender.getPlayerCoordinates().posZ;
List<EntityNPCInterface> list = getEntities(EntityNPCInterface.class, sender.getEntityWorld(), x, y, z, 80);
for (EntityNPCInterface npc : list) {
if (npc.display.getName().equalsIgnoreCase(args[0])) {
String name = npc.display.getName();
if (args.length > 2) {
name = args[2];
}
NBTTagCompound compound = new NBTTagCompound();
if(!npc.writeToNBTOptional(compound))
return;
ServerCloneController.Instance.addClone(compound, name, tab);
sendResult(sender, String.format("Added NPC \u00A7e%s\u00A77 to Tab \u00A7b%d\u00A77", name, tab));
}
}
}
@SubCommand(
desc = "List NPC from clone storage",
usage = "<tab>",
permission = 2
)
public void list(ICommandSender sender, String[] args) {
sendMessage(sender, "--- Stored NPCs --- (server side)");
int tab = 0;
try{
tab = Integer.parseInt(args[1]);
if(tab < 0 || tab > 15){
sendError(sender, "Tab must be within 1-15");
return;
}
}
catch(NumberFormatException ex){
sendError(sender, String.format("Tab is not a number: %s", args[1]));
return;
}
for (String name : ServerCloneController.Instance.getClones(tab)) {
sendMessage(sender, name);
}
sendMessage(sender, "------------------------------------");
}
@SubCommand(
desc = "Remove NPC from clone storage",
usage = "<name> <tab>",
permission = 4
)
public void del(ICommandSender sender, String[] args) throws CommandException {
String nametodel = args[0];
int tab = 0;
try{
tab = Integer.parseInt(args[1]);
if(tab < 0 || tab > 15){
sendError(sender, String.format("Tab must be within 1-15"));
return;
}
}
catch(NumberFormatException ex){
sendError(sender, String.format("Tab is not a number: %s", args[1]));
return;
}
boolean deleted = false;
for(String name : ServerCloneController.Instance.getClones(tab)){
if(nametodel.equalsIgnoreCase(name)){
ServerCloneController.Instance.removeClone(name, tab);
deleted = true;
break;
}
}
if (!ServerCloneController.Instance.removeClone(nametodel, tab)) {
sendError(sender, String.format("NPC '%s' was not found", nametodel));
} else {
sendResult(sender, String.format("Removed NPC \u00A7e%s\u00A77 from Tab \u00A7b%d\u00A77", nametodel, tab));
}
}
@SubCommand(
desc = "Spawn cloned NPC",
usage = "<name> <tab> [[world:]x,y,z]] [newname]",
permission = 2
)
public void spawn(ICommandSender sender, String[] args) throws CommandException {
String name = args[0].replaceAll("%", " "); // if name of npc separed by space, user must use % in place of space
int tab = 0;
try{
tab = Integer.parseInt(args[1]);
if(tab < 0 || tab > 15){
sendError(sender, String.format("Tab must be within 1-15"));
return;
}
}
catch(NumberFormatException ex){
sendError(sender, String.format("Tab is not a number: %s", args[1]));
return;
}
String newname=null;
NBTTagCompound compound = ServerCloneController.Instance.getCloneData(sender, name, tab);
if(compound == null){
sendError(sender, "Unknown npc");
return;
}
World world = sender.getEntityWorld();
double posX = sender.getPlayerCoordinates().posX;
double posY = sender.getPlayerCoordinates().posY;
double posZ = sender.getPlayerCoordinates().posZ;
if(args.length > 2){
String location = args[2];
String[] par;
if (location.contains(":")){
par = location.split(":");
location = par[1];
world = Utils.getWorld(par[0]);
if (world == null){
sendError(sender, String.format("'%s' is an unknown world", par[0]));
return;
}
}
if (location.contains(",")){
par = location.split(",");
if (par.length != 3){
sendError(sender, "Location need be x,y,z");
return;
}
try{
posX = CommandBase.func_110666_a(sender, posX, par[0]);
posY = CommandBase.func_110665_a(sender, posY, par[1].trim(), 0, 0);
posZ = CommandBase.func_110666_a(sender, posZ, par[2]);
} catch(NumberFormatException ex){
sendError(sender, "Location should be in numbers");
return;
}
if (args.length > 3){
newname = args[3];
}
} else {
newname = location;
}
}
if (posX == 0 && posY == 0 && posZ == 0){//incase it was called from the console and not pos was given
sendError(sender, "Location needed");
return;
}
Entity entity = EntityList.createEntityFromNBT(compound, world);
entity.setPosition(posX + 0.5, posY + 1, posZ + 0.5);
if(entity instanceof EntityNPCInterface){
EntityNPCInterface npc = (EntityNPCInterface) entity;
npc.ai.startPos = new int[]{MathHelper.floor_double(posX), MathHelper.floor_double(posY), MathHelper.floor_double(posZ)};
if(newname != null && !newname.isEmpty())
npc.display.name = newname.replaceAll("%", " "); // like name, newname must use % in place of space to keep a logical way
}
world.spawnEntityInWorld(entity);
}
@SubCommand(
desc = "Spawn cloned NPC",
usage = "<name> <tab> [[world:]x,y,z]] [newname]",
permission = 2
)
public void grid(ICommandSender sender, String[] args) throws CommandException {
String name = args[0].replaceAll("%", " "); // if name of npc separed by space, user must use % in place of space
int tab = 0;
try{
tab = Integer.parseInt(args[1]);
if(tab < 0 || tab > 15){
sendError(sender, String.format("Tab must be within 1-15"));
return;
}
}
catch(NumberFormatException ex){
sendError(sender, String.format("Tab is not a number: %s", args[1]));
return;
}
int width, height;
try{
width = Integer.parseInt(args[2]);
height = Integer.parseInt(args[3]);
}
catch(NumberFormatException ex){
sendError(sender, "length or width was not a number");
return;
}
String newname=null;
NBTTagCompound compound = ServerCloneController.Instance.getCloneData(sender, name, tab);
if(compound == null){
sendError(sender, "Unknown npc");
return;
}
World world = sender.getEntityWorld();
double posX = sender.getPlayerCoordinates().posX;
double posY = sender.getPlayerCoordinates().posY;
double posZ = sender.getPlayerCoordinates().posZ;
if(args.length > 4){
String location = args[4];
String[] par;
if (location.contains(":")){
par = location.split(":");
location = par[1];
world = Utils.getWorld(par[0]);
if (world == null){
sendError(sender, String.format("'%s' is an unknown world", par[0]));
}
}
if (location.contains(",")){
par = location.split(",");
if (par.length != 3){
sendError(sender, "Location need be x,y,z");
return;
}
try{
posX = CommandBase.func_110666_a(sender, posX, par[0]);
posY = CommandBase.func_110665_a(sender, posY, par[1].trim(), 0, 0);
posZ = CommandBase.func_110666_a(sender, posZ, par[2]);
} catch(NumberFormatException ex){
sendError(sender, "Location should be in numbers");
return;
}
if (args.length > 5){
newname = args[5];
}
} else {
newname = location;
}
}
if (posX == 0 && posY == 0 && posZ == 0){//incase it was called from the console and not pos was given
sendError(sender, "Location needed");
return;
}
for(int x = 0; x < width; x++){
for(int z = 0; z < height; z++){
Entity entity = EntityList.createEntityFromNBT(compound, world);
int xx = MathHelper.floor_double(posX) + x;
int yy = Math.max(MathHelper.floor_double(posY) - 2, 1);
int zz = MathHelper.floor_double(posZ) + z;
for(int y = 0; y < 10; y++){
Block b = world.getBlock(xx, yy + y, zz);
Block b2 = world.getBlock(xx, yy + y + 1, zz);
if(b != null && (b2 == null || b2.getCollisionBoundingBoxFromPool(world, xx, yy + y + 1, zz) == null)){
yy += y;
break;
}
}
entity.setPosition(posX + 0.5 + x, yy + 1, posZ + 0.5 + z);
if(entity instanceof EntityNPCInterface){
EntityNPCInterface npc = (EntityNPCInterface) entity;
npc.ai.startPos = new int[]{xx, yy, zz};
if(newname != null && !newname.isEmpty())
npc.display.name = newname.replaceAll("%", " "); // like name, newname must use % in place of space to keep a logical way
}
world.spawnEntityInWorld(entity);
}
}
return;
}
public World getWorld(String t){
WorldServer[] ws=MinecraftServer.getServer().worldServers;
for (WorldServer w:ws){
if (w!=null){
if ((w.provider.dimensionId + "").equalsIgnoreCase(t)){
return w;
}
}
}
return null;
}
public <T extends Entity> List<T> getEntities(Class<? extends T> cls, World world, int x, int y, int z, int range) {
AxisAlignedBB bb = AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 1, z + 1).expand(range, range, range);
List<T> list = world.getEntitiesWithinAABB(cls, bb);
return list;
}
}
@@ -0,0 +1,142 @@
package kamkeel.command;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import kamkeel.developer.Developer;
import net.minecraft.command.CommandBase;
import net.minecraft.command.CommandException;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.server.MinecraftServer;
import noppes.npcs.CustomNpcsPermissions;
import noppes.npcs.scripted.CustomNPCsException;
public class CommandKamkeel extends CommandBase{
public Map<String, CommandKamkeelBase> map = new HashMap<String, CommandKamkeelBase>();
public HelpCommand help = new HelpCommand(this);
public CommandKamkeel(){
registerCommand(help);
registerCommand(new ScriptCommand());
registerCommand(new SlayCommand());
registerCommand(new QuestCommand());
registerCommand(new DialogCommand());
registerCommand(new FactionCommand());
registerCommand(new NpcCommand());
registerCommand(new CloneCommand());
registerCommand(new ConfigCommand());
}
public void registerCommand(CommandKamkeelBase command){
String name = command.getCommandName().toLowerCase();
if(map.containsKey(name))
throw new CustomNPCsException("Already a subcommand with the name: " + name);
map.put(name, command);
}
@Override
public String getCommandName() {
return "kamkeel";
}
@Override
public String getCommandUsage(ICommandSender sender) {
return "Use as /kamkeel subcommand";
}
@Override
public void processCommand(ICommandSender sender, String[] args) throws CommandException {
if(args.length == 0){
help.processCommand(sender, args);
return;
}
CommandKamkeelBase command = getCommand(args);
if(command == null)
throw new CommandException("Unknown command " + args[0]);
args = Arrays.copyOfRange(args, 1, args.length);
if(command.subcommands.isEmpty() || !command.runSubCommands()){
if(!canSendCommand(sender, command))
throw new CommandException("You are not allowed to use this command: " + command);
command.canRun(sender, command.getUsage(), args);
command.processCommand(sender, args);
return;
}
if(args.length == 0){
help.processCommand(sender, new String[]{command.getCommandName()});
return;
}
command.processSubCommand(sender, args[0], Arrays.copyOfRange(args, 1, args.length));
}
@Override
public List addTabCompletionOptions(ICommandSender sender, String[] args){
if(args.length == 1)
return CommandBase.getListOfStringsMatchingLastWord(args, map.keySet().toArray(new String[map.size()]));
CommandKamkeelBase command = getCommand(args);
if(command == null)
return null;
if(args.length == 2 && command.runSubCommands())
return CommandBase.getListOfStringsMatchingLastWord(args, command.subcommands.keySet().toArray(new String[command.subcommands.keySet().size()]));
String[] useArgs = command.getUsage().split(" ");
if(command.runSubCommands()) {
Method m = command.subcommands.get(args[1].toLowerCase());
if(m != null) {
useArgs = m.getAnnotation(CommandKamkeelBase.SubCommand.class).usage().split(" ");
}
}
if(args.length <= useArgs.length + 2) {
if(args.length - 3 >= 0){
String usage = useArgs[args.length - 3];
if(usage.equals("<player>") || usage.equals("[player]")) {
return CommandBase.getListOfStringsMatchingLastWord(args, MinecraftServer.getServer().getAllUsernames());
}
}
}
return command.addTabCompletionOptions(sender, Arrays.copyOfRange(args, 1, args.length));
}
public CommandKamkeelBase getCommand(String[] args){
if(args.length == 0)
return null;
return map.get(args[0].toLowerCase());
}
@Override
public int getRequiredPermissionLevel(){
return 2;
}
public static String getCommandPermission(String command){
return "cnpc.kamkeel." + command.toLowerCase();
}
public static String getUniversalPermission(){
return "cnpc.kamkeel.*";
}
public static boolean canSendCommand(ICommandSender sender, CommandKamkeelBase command){
if(sender.canCommandSenderUseCommand(command.getRequiredPermissionLevel(), getUniversalPermission())){
return true;
}
if(sender.canCommandSenderUseCommand(command.getRequiredPermissionLevel(), getCommandPermission(command.getCommandName()))){
return true;
}
if(sender instanceof EntityPlayer){
return CustomNpcsPermissions.hasCustomPermission((EntityPlayer) sender, getCommandPermission(command.getCommandName()));
}
return false;
}
}
@@ -0,0 +1,149 @@
package kamkeel.command;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import kamkeel.developer.Developer;
import net.minecraft.command.CommandBase;
import net.minecraft.command.CommandException;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ChatComponentTranslation;
import noppes.npcs.CustomNpcsPermissions;
public abstract class CommandKamkeelBase extends CommandBase{
public Map<String, Method> subcommands = new HashMap<String, Method>();
public CommandKamkeelBase(){
for (Method m : this.getClass().getDeclaredMethods()) {
SubCommand sc = m.getAnnotation(SubCommand.class);
if (sc != null) {
String name = sc.name();
if (name.equals(""))
name = m.getName();
subcommands.put(name.toLowerCase(), m);
}
}
}
@Override
public void processCommand(ICommandSender sender, String[] args) throws CommandException {
}
@Override
public String getCommandUsage(ICommandSender sender) {
return getDescription();
}
public abstract String getDescription();
/**
* @return Should return a string in the format of <arg> <arg2> <arg3> [arg4] where <> is a required parameter and [] optional
*/
public String getUsage(){
return "";
}
public boolean runSubCommands(){
return !subcommands.isEmpty();
}
protected void sendMessage(ICommandSender sender, String message, Object... obs) {
sender.addChatMessage(new ChatComponentTranslation(message, obs));
}
protected void sendResult(ICommandSender sender, String message, Object... obs) {
sender.addChatMessage(new ChatComponentTranslation("\u00A76[\u00A7eCNPC+\u00A76]\u00A77 " + message, obs));
}
protected static void sendError(ICommandSender sender, String message, Object... obs) {
sender.addChatMessage(new ChatComponentTranslation("\u00A76[\u00A7eCNPC+\u00A76]\u00A74 Error:\u00A7c " + message, obs));
}
@Retention(value = RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface SubCommand {
String name() default "";
/**
* @return Should return a string in the format of <arg> <arg2> <arg3> [arg4] where <> is a required parameter and [] optional
*/
String usage() default "";
String desc();
int permission() default 2;
}
public void processSubCommand(ICommandSender sender, String command, String[] args) throws CommandException {
Method m = subcommands.get(command.toLowerCase());
if(m == null)
throw new CommandException("Unknown subcommand " + command);
SubCommand sc = m.getAnnotation(SubCommand.class);
if(!canSendCommand(sender, sc, command))
throw new CommandException("You are not allowed to use this command: " + command);
canRun(sender, sc.usage(), args);
try {
m.invoke(this, sender, args);
} catch (Exception e) {
e.printStackTrace();
}
}
public void canRun(ICommandSender sender, String usage, String[] args) throws CommandException{
String[] np = usage.split(" ");
List<String> required = new ArrayList<String>();
for(int i = 0; i < np.length; i++){
String command = np[i];
if(command.startsWith("<")){
required.add(command);
}
if(command.equals("<player>") && args.length > i){
CommandBase.getPlayer(sender, args[i]); //throws PlayerNotFoundException if no player is found
}
}
if (args.length < required.size()) {
throw new CommandException("Missing parameter: " + required.get(args.length));
}
}
public int getRequiredPermissionLevel(){
return 2;
}
public String getSubCommandPermission(String subCommand){
return "cnpc.kamkeel." + getCommandName().toLowerCase() + "." + subCommand.toLowerCase();
}
public String getSubUniversalPermission(){
return "cnpc.kamkeel." + getCommandName().toLowerCase() + "*";
}
public boolean canSendCommand(ICommandSender sender, SubCommand command, String subCommand){
if(sender.canCommandSenderUseCommand(command.permission(), getSubUniversalPermission())){
return true;
}
if(sender.canCommandSenderUseCommand(command.permission(), getSubCommandPermission(subCommand))){
return true;
}
if(sender instanceof EntityPlayer){
return CustomNpcsPermissions.hasCustomPermission((EntityPlayer) sender, getSubCommandPermission(subCommand));
}
return false;
}
}
@@ -0,0 +1,202 @@
package kamkeel.command;
import net.minecraft.block.Block;
import net.minecraft.block.BlockIce;
import net.minecraft.block.BlockLeavesBase;
import net.minecraft.block.BlockVine;
import net.minecraft.command.CommandException;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.util.ResourceLocation;
import noppes.npcs.CustomNpcs;
import noppes.npcs.Server;
import noppes.npcs.config.ConfigMain;
import noppes.npcs.constants.EnumPacketClient;
import noppes.npcs.controllers.ChunkController;
import java.util.Arrays;
import java.util.Set;
public class ConfigCommand extends CommandKamkeelBase {
@Override
public String getCommandName() {
return "config";
}
@Override
public String getDescription() {
return "Some config things you can set";
}
@SubCommand(
desc = "Disable/Enable the natural leaves decay",
usage = "[true/false]",
permission = 4
)
public void leavesdecay(ICommandSender sender, String[] args){
if(args.length == 0){
sendResult(sender, "LeavesDecay: \u00A7c" + ConfigMain.LeavesDecayEnabled);
}
else{
ConfigMain.LeavesDecayEnabled = Boolean.parseBoolean(args[0]);
ConfigMain.LeavesDecayEnabledProperty.set(ConfigMain.LeavesDecayEnabled);
if(ConfigMain.config.hasChanged()){
ConfigMain.config.save();
}
Set<ResourceLocation> names = Block.blockRegistry.getKeys();
for(ResourceLocation name : names){
Block block = (Block) Block.blockRegistry.getObject(name);
if(block instanceof BlockLeavesBase){
block.setTickRandomly(ConfigMain.LeavesDecayEnabled);
}
}
sendResult(sender, "LeavesDecay is now \u00A7c" + ConfigMain.LeavesDecayEnabled);
}
}
@SubCommand(
desc = "Disable/Enable the vines growing",
usage = "[true/false]",
permission = 4
)
public void vinegrowth(ICommandSender sender, String[] args){
if(args.length == 0){
sendResult(sender, "VineGrowth: \u00A7c" + ConfigMain.VineGrowthEnabled);
}
else{
ConfigMain.VineGrowthEnabled = Boolean.parseBoolean(args[0]);
ConfigMain.VineGrowthEnabledProperty.set(ConfigMain.VineGrowthEnabled);
if(ConfigMain.config.hasChanged()){
ConfigMain.config.save();
}
Set<ResourceLocation> names = Block.blockRegistry.getKeys();
for(ResourceLocation name : names){
Block block = (Block) Block.blockRegistry.getObject(name);
if(block instanceof BlockVine){
block.setTickRandomly(ConfigMain.VineGrowthEnabled);
}
}
sendResult(sender, "VineGrowth is now \u00A7c" + ConfigMain.VineGrowthEnabled);
}
}
@SubCommand(
desc = "Disable/Enable the ice melting",
usage = "[true/false]",
permission = 4
)
public void icemelts(ICommandSender sender, String[] args){
if(args.length == 0){
sendResult(sender, "IceMelts: \u00A7c" + ConfigMain.IceMeltsEnabled);
}
else{
ConfigMain.IceMeltsEnabled = Boolean.parseBoolean(args[0]);
ConfigMain.IceMeltsEnabledProperty.set(ConfigMain.IceMeltsEnabled);
if(ConfigMain.config.hasChanged()){
ConfigMain.config.save();
}
Set<ResourceLocation> names = Block.blockRegistry.getKeys();
for(ResourceLocation name : names){
Block block = (Block) Block.blockRegistry.getObject(name);
if(block instanceof BlockIce){
block.setTickRandomly(ConfigMain.IceMeltsEnabled);
}
}
sendResult(sender, "IceMelts is now \u00A7c" + ConfigMain.IceMeltsEnabled);
}
}
@SubCommand(
desc = "Disable/Enable guns shooting",
usage = "[true/false]",
permission = 4
)
public void guns(ICommandSender sender, String[] args){
if(args.length == 0){
sendResult(sender, "GunsEnabled: \u00A7c" + ConfigMain.GunsEnabled);
}
else{
ConfigMain.GunsEnabled = Boolean.parseBoolean(args[0]);
ConfigMain.GunsEnabledProperty.set(ConfigMain.GunsEnabled);
if(ConfigMain.config.hasChanged()){
ConfigMain.config.save();
}
sendResult(sender, "GunsEnabled is now \u00A7c" + ConfigMain.GunsEnabled);
}
}
@SubCommand(
desc = "Freezes/Unfreezes npcs",
usage = "[true/false]",
permission = 4
)
public void freezenpcs(ICommandSender sender, String[] args){
if(args.length == 0){
sendResult(sender, "Frozen NPCs: \u00A7c" + CustomNpcs.FreezeNPCs);
}
else{
CustomNpcs.FreezeNPCs = Boolean.parseBoolean(args[0]);
sendResult(sender, "FrozenNPCs is now \u00A7c" + CustomNpcs.FreezeNPCs);
}
}
@SubCommand(
desc = "Set number of active chunkloaders",
usage = "<number>",
permission = 4
)
public void chunkloaders(ICommandSender sender, String[] args) throws CommandException{
if(args.length == 0){
sendResult(sender, "ChunkLoaders: \u00A7c" + ChunkController.instance.size() + "\u00A77/\u00A7c" + ConfigMain.ChunkLoaders);
}
else{
try{
ConfigMain.ChunkLoaders = Integer.parseInt(args[0]);
}
catch(NumberFormatException ex){
sendError(sender, "Did not get a number: " + args[0]);
return;
}
ConfigMain.ChunkLoadersProperty.set(ConfigMain.ChunkLoaders);
if(ConfigMain.config.hasChanged()){
ConfigMain.config.save();
}
int size = ChunkController.instance.size();
if(size > ConfigMain.ChunkLoaders){
ChunkController.instance.unload(size - ConfigMain.ChunkLoaders);
sendResult(sender, size - ConfigMain.ChunkLoaders + " chunksloaders unloaded");
}
sendResult(sender, "ChunkLoaders: \u00A7c" + ChunkController.instance.size() + "\u00A77/\u00A7c" + ConfigMain.ChunkLoaders);
}
}
@SubCommand(
desc = "Get/Set font",
usage = "[type] [size]",
permission = 4
)
public void font(ICommandSender sender, String[] args){
if(!(sender instanceof EntityPlayerMP))
return;
int size = 18;
if(args.length > 1){
try{
size = Integer.parseInt(args[args.length - 1]);
args = Arrays.copyOfRange(args, 0, args.length - 1);
}
catch(Exception e){
}
}
String font = "";
for(int i = 0; i < args.length; i++){
font += " " + args[i];
}
Server.sendData((EntityPlayerMP)sender, EnumPacketClient.CONFIG, 0, font.trim(), size);
}
}
@@ -0,0 +1,123 @@
package kamkeel.command;
import java.util.List;
import net.minecraft.command.CommandBase;
import net.minecraft.command.CommandException;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayer;
import noppes.npcs.NoppesUtilServer;
import noppes.npcs.client.EntityUtil;
import noppes.npcs.controllers.DialogController;
import noppes.npcs.controllers.PlayerDataController;
import noppes.npcs.controllers.data.Dialog;
import noppes.npcs.controllers.data.DialogOption;
import noppes.npcs.controllers.data.PlayerData;
import noppes.npcs.entity.EntityDialogNpc;
public class DialogCommand extends CommandKamkeelBase {
@Override
public String getCommandName() {
return "dialog";
}
@Override
public String getDescription() {
return "Dialog operations";
}
@SubCommand(
desc = "force read",
usage = "<player> <dialog>"
)
public void read(ICommandSender sender, String args[]) throws CommandException{
String playername=args[0];
int diagid;
try {
diagid = Integer.parseInt(args[1]);
} catch (NumberFormatException ex) {
sendError(sender, "DialogID must be an integer: " + args[1]);
return;
}
List<PlayerData> data = PlayerDataController.instance.getPlayersData(sender, playername);
if (data.isEmpty()) {
sendError(sender, "Unknown player: " + playername);
return;
}
for(PlayerData playerdata : data){
playerdata.dialogData.dialogsRead.add(diagid);
playerdata.save();
sendResult(sender, String.format("Forced Read for Dialog \u00A7e%d\u00A77 for Player '\u00A7b%s\u00A77'", diagid, playerdata.playername));
}
}
@SubCommand(
desc = "force unread dialog",
usage = "<player> <dialog>"
)
public void unread(ICommandSender sender, String args[]) throws CommandException{
String playername=args[0];
int diagid;
try {
diagid = Integer.parseInt(args[1]);
} catch (NumberFormatException ex) {
sendError(sender, "DialogID must be an integer: " + args[1]);
return;
}
List<PlayerData> data = PlayerDataController.instance.getPlayersData(sender, playername);
if (data.isEmpty()) {
sendError(sender, "Unknown player: " + playername);
return;
}
for(PlayerData playerdata : data){
playerdata.dialogData.dialogsRead.remove(diagid);
playerdata.save();
sendResult(sender, String.format("Forced Unread for Dialog \u00A7e%d\u00A77 for Player '\u00A7b%s\u00A77'", diagid, playerdata.playername));
}
}
@SubCommand(
desc="reload dialogs from disk",
permission = 4
)
public void reload(ICommandSender sender, String args[]){
new DialogController();
sendResult(sender, "Dialogs Reloaded");
}
@SubCommand(
desc="show dialog",
usage="<player> <dialog> <name>"
)
public void show(ICommandSender sender, String args[]) throws CommandException{
EntityPlayer player = CommandBase.getPlayer(sender, args[0]);
if(player == null){
sendError(sender, "Unknown player: " + args[0]);
return;
}
int diagid;
try {
diagid = Integer.parseInt(args[1]);
} catch (NumberFormatException ex) {
sendError(sender, "DialogID must be an integer: " + args[1]);
return;
}
Dialog dialog = DialogController.instance.dialogs.get(diagid);
if(dialog == null){
sendError(sender, "Unknown dialog id: " + args[1]);
return;
}
EntityDialogNpc npc = new EntityDialogNpc(sender.getEntityWorld());
npc.display.setName(args[2]);
EntityUtil.Copy(player, npc);
DialogOption option = new DialogOption();
option.dialogId = diagid;
option.title = dialog.title;
npc.dialogs.put(0, option);
NoppesUtilServer.openDialog(player, npc, dialog, 0);
sendResult(sender, String.format("Displayed Dialog \u00A7e%d\u00A77 to Player '\u00A7b%s\u00A77'", diagid, player.getCommandSenderName()));
}
}
@@ -0,0 +1,154 @@
package kamkeel.command;
import java.util.Arrays;
import java.util.List;
import net.minecraft.command.CommandBase;
import net.minecraft.command.CommandException;
import net.minecraft.command.ICommandSender;
import noppes.npcs.controllers.FactionController;
import noppes.npcs.controllers.PlayerDataController;
import noppes.npcs.controllers.data.Faction;
import noppes.npcs.controllers.data.PlayerData;
import noppes.npcs.controllers.data.PlayerFactionData;
public class FactionCommand extends CommandKamkeelBase {
public Faction selectedFaction;
public List<PlayerData> data;
@Override
public String getCommandName() {
return "faction";
}
@Override
public String getDescription() {
return "Faction operations";
}
@Override
public String getUsage() {
return "<player> <faction> <command>";
}
@Override
public boolean runSubCommands(){
return false;
}
@Override
public void processCommand(ICommandSender sender, String[] args) throws CommandException {
String playername = args[0];
String factionname = args[1];
data = PlayerDataController.instance.getPlayersData(sender, playername);
if (data.isEmpty()) {
sendError(sender, "Unknown player: " + playername);
return;
}
try{
selectedFaction = FactionController.getInstance().getFaction(Integer.parseInt(factionname));
}
catch(NumberFormatException e){
selectedFaction = FactionController.getInstance().getFactionFromName(factionname);
}
if (selectedFaction == null) {
sendError(sender, "Unknown faction: " + factionname);
return;
}
processSubCommand(sender, args[2], Arrays.copyOfRange(args, 3, args.length));
for(PlayerData playerdata : data){
playerdata.save();
}
}
@SubCommand(
desc = "Add points",
usage = "<points>"
)
public void add(ICommandSender sender, String[] args) throws CommandException {
int points;
try {
points = Integer.parseInt(args[0]);
} catch (NumberFormatException ex) {
sendError(sender, "Must be an integer: " + args[0]);
return;
}
int factionid = this.selectedFaction.id;
for(PlayerData playerdata : data){
PlayerFactionData playerfactiondata = playerdata.factionData;
playerfactiondata.increasePoints(factionid, points, playerdata.player);
sendResult(sender, String.format("Added Points \u00A7a%d\u00A77, Faction \u00A7e%s (%d)\u00A77 for Player \u00A7b%s\u00A77", points, this.selectedFaction.getName(), this.selectedFaction.id, playerdata.playername));
}
}
@SubCommand(
desc = "Substract points",
usage = "<points>"
)
public void subtract(ICommandSender sender, String[] args) throws CommandException {
int points;
try {
points = Integer.parseInt(args[0]);
} catch (NumberFormatException ex) {
sendError(sender, "Must be an integer: " + args[0]);
return;
}
int factionid = this.selectedFaction.id;
for(PlayerData playerdata : data){
PlayerFactionData playerfactiondata = playerdata.factionData;
playerfactiondata.increasePoints(factionid, -points, playerdata.player);
sendResult(sender, String.format("Subtracted Points \u00A7a%d\u00A77, Faction \u00A7e%s (%d)\u00A77 for Player \u00A7b%s\u00A77", points, this.selectedFaction.getName(), this.selectedFaction.id, playerdata.playername));
}
}
@SubCommand(desc = "Reset points to default")
public void reset(ICommandSender sender, String[] args) {
for(PlayerData playerdata : data){
playerdata.factionData.factionData.put(this.selectedFaction.id, this.selectedFaction.defaultPoints);
sendResult(sender, String.format("Reset Faction \u00A7e%s (%d)\u00A77 for Player \u00A7b%s\u00A77", this.selectedFaction.getName(), this.selectedFaction.id, playerdata.playername));
}
}
@SubCommand(
desc = "Set points",
usage = "<points>"
)
public void set(ICommandSender sender, String[] args) throws CommandException {
int points;
try {
points = Integer.parseInt(args[0]);
} catch (NumberFormatException ex) {
sendError(sender, "Must be an integer: " + args[0]);
return;
}
for(PlayerData playerdata : data){
PlayerFactionData playerfactiondata = playerdata.factionData;
playerfactiondata.factionData.put(this.selectedFaction.id, points);
sendResult(sender, String.format("Set Points \u00A7a%d\u00A77, Faction \u00A7e%s (%d)\u00A77 for Player \u00A7b%s\u00A77", points, this.selectedFaction.getName(), this.selectedFaction.id, playerdata.playername));
}
}
@SubCommand(desc = "Drop relationship")
public void drop(ICommandSender sender, String[] args){
for(PlayerData playerdata : data){
playerdata.factionData.factionData.remove(this.selectedFaction.id);
sendResult(sender, String.format("Dropped Faction \u00A7e%s (%d)\u00A77 from Player \u00A7b%s\u00A77", this.selectedFaction.getName(), this.selectedFaction.id, playerdata.playername));
}
}
@Override
public List addTabCompletionOptions(ICommandSender par1, String[] args) {
if(args.length == 3){
return CommandBase.getListOfStringsMatchingLastWord(args, new String[]{"add", "subtract", "set", "reset", "drop", "create"});
}
return null;
}
}
@@ -0,0 +1,70 @@
package kamkeel.command;
import java.lang.reflect.Method;
import java.util.Map.Entry;
import net.minecraft.command.CommandException;
import net.minecraft.command.ICommandSender;
import net.minecraft.util.ChatComponentTranslation;
public class HelpCommand extends CommandKamkeelBase{
private CommandKamkeel parent;
public HelpCommand(CommandKamkeel parent){
this.parent = parent;
}
@Override
public String getCommandName() {
return "help";
}
@Override
public String getDescription() {
return "help [command]";
}
@Override
public void processCommand(ICommandSender sender, String[] args) throws CommandException {
if(args.length == 0){
sendMessage(sender, "\u00A78------ \u00A7cKamkeel Commands \u00A78------");
for(Entry<String, CommandKamkeelBase> entry : parent.map.entrySet()){
sendMessage(sender, "\u00A77> " + "\u00A7e" + entry.getKey() + "\u00A78: \u00A77" + entry.getValue().getCommandUsage(sender));
}
return;
}
CommandKamkeelBase command = parent.getCommand(args);
if(command == null){
sendError(sender, "Unknown command " + args[0]);
return;
}
if(command.subcommands.isEmpty()){
sender.addChatMessage(new ChatComponentTranslation(command.getCommandUsage(sender)));
return;
}
Method m = null;
if(args.length > 1){
m = command.subcommands.get(args[1].toLowerCase());
}
if(m == null){
sendMessage(sender, "\u00A78------ \u00A7a" + command.getCommandName().toUpperCase() + " SubCommands \u00A78------");
sendMessage(sender, "\u00A77Usage: \u00A76" + command.getUsage());
for(Entry<String, Method> entry : command.subcommands.entrySet()){
sender.addChatMessage(new ChatComponentTranslation("\u00A77> " + "\u00A7e" + entry.getKey() + "\u00A78: \u00A77" + entry.getValue().getAnnotation(SubCommand.class).desc()));
}
sender.addChatMessage(new ChatComponentTranslation("\u00A78Permission:\u00A77 " + CommandKamkeel.getCommandPermission(command.getCommandName())));
}
else{
sendMessage(sender, "\u00A78------ \u00A7b" + command.getCommandName().toUpperCase() + "." + args[1].toUpperCase() + " Command \u00A78------");
SubCommand sc = m.getAnnotation(SubCommand.class);
sender.addChatMessage(new ChatComponentTranslation("\u00A77" + sc.desc()));
if(!sc.usage().isEmpty())
sender.addChatMessage(new ChatComponentTranslation("\u00A77Usage: \u00A76" + sc.usage()));
sender.addChatMessage(new ChatComponentTranslation("\u00A78Permission:\u00A77 " + getSubCommandPermission(args[1])));
}
}
}
@@ -0,0 +1,230 @@
package kamkeel.command;
import java.util.Arrays;
import java.util.List;
import net.minecraft.command.CommandBase;
import net.minecraft.command.CommandException;
import net.minecraft.command.ICommandSender;
import net.minecraft.command.PlayerNotFoundException;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import noppes.npcs.NoppesUtilServer;
import noppes.npcs.constants.EnumGuiType;
import noppes.npcs.entity.EntityCustomNpc;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.roles.RoleCompanion;
import noppes.npcs.roles.RoleFollower;
import org.apache.commons.lang3.ArrayUtils;
public class NpcCommand extends CommandKamkeelBase {
public EntityNPCInterface selectedNpc;
@Override
public String getCommandName() {
return "npc";
}
@Override
public String getDescription() {
return "NPC operation";
}
@Override
public String getUsage() {
return "<name> <command>";
}
@Override
public boolean runSubCommands(){
return false;
}
@Override
public void processCommand(ICommandSender sender, String[] args) throws CommandException {
String npcname = args[0].replace("%", " ");
String command = args[1];
args = Arrays.copyOfRange(args, 2, args.length);
if(command.equalsIgnoreCase("create")){
args = ArrayUtils.add(args, 0, npcname);
processSubCommand(sender, command, args);
return;
}
int x = sender.getPlayerCoordinates().posX;
int y = sender.getPlayerCoordinates().posY;
int z = sender.getPlayerCoordinates().posZ;
List<EntityNPCInterface> list = getEntities(EntityNPCInterface.class, sender.getEntityWorld(), x, y, z, 80);
for (EntityNPCInterface npc : list) {
String name = npc.display.getName().replace(" ", "_");
if (name.equalsIgnoreCase(npcname)){
if(selectedNpc == null || selectedNpc.getDistanceSq(x, y, z) > npc.getDistanceSq(x, y, z))
selectedNpc = npc;
}
}
if(selectedNpc == null){
sendError(sender, "Npc " + npcname + " was not found");
return;
}
processSubCommand(sender, command, args);
selectedNpc = null;
}
@SubCommand(
desc = "Set Home (respawn place)",
usage = "[x] [y] [z]"
)
public void home(ICommandSender sender, String[] args) {
double posX = sender.getPlayerCoordinates().posX;
double posY = sender.getPlayerCoordinates().posY;
double posZ = sender.getPlayerCoordinates().posZ;
if(args.length == 3){
posX = CommandBase.func_110666_a(sender, selectedNpc.posX, args[0]);
posY = CommandBase.func_110665_a(sender, selectedNpc.posY, args[1].trim(), 0, 0);
posZ = CommandBase.func_110666_a(sender, selectedNpc.posZ, args[2]);
}
selectedNpc.ai.startPos = new int[]{MathHelper.floor_double(posX), MathHelper.floor_double(posY), MathHelper.floor_double(posZ)};
sendResult(sender, String.format("Set NPC \u00A7e%s\u00A77 Home to \u00A7b[%.1f] [%.1f] [%.1f]\u00A77", selectedNpc.display.name, posX, posY, posZ));
}
@SubCommand(
desc = "Set NPC visibility",
usage = "[true/false/semi]"
)
public void visible(ICommandSender sender, String[] args){
if(args.length < 1)
return;
boolean bo = args[0].equalsIgnoreCase("true");
boolean semi = args[0].equalsIgnoreCase("semi");
int current = selectedNpc.display.visible;
if(semi)
selectedNpc.display.visible = 2;
else if(bo)
selectedNpc.display.visible = 0;
else
selectedNpc.display.visible = 1;
String[] list = new String[]{"True", "False", "Semi"};
if(current != selectedNpc.display.visible)
selectedNpc.updateClient = true;
sendResult(sender, String.format("Set NPC \u00A7e%s\u00A77 Visibility to \u00A7b%s\u00A77", selectedNpc.display.name, list[selectedNpc.display.visible]));
}
@SubCommand(desc = "Delete an NPC")
public void delete(ICommandSender sender, String[] args){
selectedNpc.delete();
}
@SubCommand(
desc = "Sets the owner of an follower/companion",
usage = "[player]"
)
public void owner(ICommandSender sender, String[] args){
if(args.length < 1){
EntityPlayer player = null;
if(selectedNpc.roleInterface instanceof RoleFollower)
player = ((RoleFollower)selectedNpc.roleInterface).owner;
if(selectedNpc.roleInterface instanceof RoleCompanion)
player = ((RoleCompanion)selectedNpc.roleInterface).owner;
if(player == null)
sendResult(sender, String.format("NPC \u00A7e%s\u00A77 Owner: \u00A7b%s\u00A77", selectedNpc.display.name, "NULL"));
else
sendResult(sender, String.format("NPC \u00A7e%s\u00A77 Owner: \u00A7b%s\u00A77", selectedNpc.display.name, player.getDisplayName()));
}
else{
EntityPlayerMP player = null;
try {
player = CommandBase.getPlayer(sender, args[0]);
} catch (PlayerNotFoundException e) {
}
if(selectedNpc.roleInterface instanceof RoleFollower)
((RoleFollower)selectedNpc.roleInterface).setOwner(player);
if(selectedNpc.roleInterface instanceof RoleCompanion)
((RoleCompanion)selectedNpc.roleInterface).setOwner(player);
if(player == null)
sendResult(sender, String.format("NPC \u00A7e%s\u00A77 Owner: \u00A7b%s\u00A77", selectedNpc.display.name, "NULL"));
else
sendResult(sender, String.format("NPC \u00A7e%s\u00A77 Owner: \u00A7b%s\u00A77", selectedNpc.display.name, player.getDisplayName()));
}
}
@SubCommand(
desc = "Set NPC name",
usage = "[name]"
)
public void name(ICommandSender sender, String[] args){
if(args.length < 1)
return;
String name = args[0];
for(int i = 1; i < args.length; i++){
name += " " + args[i];
}
sendResult(sender, String.format("NPC \u00A7e%s\u00A77 Name set to \u00A7b%s\u00A77", selectedNpc.display.name, name));
if(!selectedNpc.display.getName().equals(name)){
selectedNpc.display.setName(name);
selectedNpc.updateClient = true;
}
}
@SubCommand(
desc = "Creates an NPC",
usage = "[name]"
)
public void create(ICommandSender sender, String[] args) {
EntityPlayerMP player = (EntityPlayerMP) sender;
World pw = player.getEntityWorld();
EntityCustomNpc npc = new EntityCustomNpc(pw);
if(args.length > 0)
npc.display.name = args[0];
npc.setPositionAndRotation(player.posX, player.posY, player.posZ, player.cameraYaw, player.cameraPitch);
npc.ai.startPos = new int[]{MathHelper.floor_double(player.posX),MathHelper.floor_double(player.posY),MathHelper.floor_double(player.posZ)};
pw.spawnEntityInWorld(npc);
npc.setHealth(npc.getMaxHealth());
NoppesUtilServer.sendOpenGui(player, EnumGuiType.MainMenuDisplay, npc);
}
@Override
public List addTabCompletionOptions(ICommandSender par1, String[] args) {
if(args.length == 2){
return CommandBase.getListOfStringsMatchingLastWord(args, new String[]{"create", "home", "visible", "delete", "owner", "name"});
}
if(args.length == 3 && args[1].equalsIgnoreCase("owner")){
return CommandBase.getListOfStringsMatchingLastWord(args, MinecraftServer.getServer().getAllUsernames());
}
return null;
}
@Override
public int getRequiredPermissionLevel(){
return 4;
}
public <T extends Entity> List<T> getEntities(Class<? extends T> cls, World world, int x, int y, int z, int range) {
AxisAlignedBB bb = AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 1, z + 1).expand(range, range, range);
List<T> list = world.getEntitiesWithinAABB(cls, bb);
return list;
}
}
@@ -0,0 +1,187 @@
package kamkeel.command;
import java.util.List;
import net.minecraft.command.CommandException;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayerMP;
import noppes.npcs.Server;
import noppes.npcs.constants.EnumPacketClient;
import noppes.npcs.constants.EnumQuestRepeat;
import noppes.npcs.controllers.PlayerDataController;
import noppes.npcs.controllers.QuestController;
import noppes.npcs.controllers.data.PlayerData;
import noppes.npcs.controllers.data.Quest;
import noppes.npcs.controllers.data.QuestData;
public class QuestCommand extends CommandKamkeelBase {
@Override
public String getCommandName() {
return "quest";
}
@Override
public String getDescription() {
return "Quest operations";
}
@SubCommand(
desc = "Start a quest",
usage = "<player> <quest>"
)
public void start(ICommandSender sender, String[] args) throws CommandException {
String playername = args[0];
int questid;
try {
questid = Integer.parseInt(args[1]);
} catch (NumberFormatException ex) {
sendError(sender, "QuestID must be an integer: " + args[1]);
return;
}
List<PlayerData> data = PlayerDataController.instance.getPlayersData(sender, playername);
if (data.isEmpty()) {
sendError(sender, "Unknown player: " + playername);
return;
}
Quest quest = QuestController.instance.quests.get(questid);
if (quest == null){
sendError(sender, "Unknown QuestID: " + questid);
return;
}
for(PlayerData playerdata : data){
QuestData questdata = new QuestData(quest);
playerdata.questData.activeQuests.put(questid, questdata);
playerdata.save();
if(playerdata.player != null && questdata.sendAlerts){
Server.sendData((EntityPlayerMP)playerdata.player, EnumPacketClient.MESSAGE, "quest.newquest", quest.title);
Server.sendData((EntityPlayerMP)playerdata.player, EnumPacketClient.CHAT, "quest.newquest", ": ", quest.title);
}
sendResult(sender, String.format("Started Quest \u00A7e%d\u00A77 for Player '\u00A7b%s\u00A77'", questid, playerdata.playername));
}
}
@SubCommand(
desc = "Finish a quest",
usage = "<player> <quest>"
)
public void finish(ICommandSender sender, String args[]) throws CommandException{
String playername=args[0];
int questid;
try {
questid = Integer.parseInt(args[1]);
}
catch (NumberFormatException ex) {
sendError(sender, "QuestID must be an integer: " + args[1]);
return;
}
List<PlayerData> data = PlayerDataController.instance.getPlayersData(sender, playername);
if (data.isEmpty()) {
sendError(sender, String.format("Unknown player '%s'", playername));
return;
}
Quest quest = QuestController.instance.quests.get(questid);
if (quest == null){
sendError(sender, "Unknown QuestID: " + questid);
return;
}
for(PlayerData playerdata : data){
if(playerdata.questData.activeQuests.containsKey(questid)){
playerdata.questData.activeQuests.remove(questid);
}
if(quest.repeat == EnumQuestRepeat.RLDAILY || quest.repeat == EnumQuestRepeat.RLWEEKLY)
playerdata.questData.finishedQuests.put(quest.id, System.currentTimeMillis());
else
playerdata.questData.finishedQuests.put(quest.id, sender.getEntityWorld().getTotalWorldTime());
playerdata.save();
if(playerdata.player != null){
Server.sendData((EntityPlayerMP)playerdata.player, EnumPacketClient.MESSAGE, "quest.completed", quest.title);
Server.sendData((EntityPlayerMP)playerdata.player, EnumPacketClient.CHAT, "quest.completed", ": ", quest.title);
}
sendResult(sender, String.format("Finished Quest \u00A7e%d\u00A77 for Player '\u00A7b%s\u00A77'", questid, playerdata.playername));
}
}
@SubCommand(
desc = "Stop a started quest",
usage = "<player> <quest>"
)
public void stop(ICommandSender sender, String[] args) throws CommandException {
String playername=args[0];
int questid;
try {
questid = Integer.parseInt(args[1]);
} catch (NumberFormatException ex) {
sendError(sender, "QuestID must be an integer: " + args[1]);
return;
}
List<PlayerData> data = PlayerDataController.instance.getPlayersData(sender, playername);
if (data.isEmpty()) {
sendError(sender, String.format("Unknown player '%s'", playername));
return;
}
Quest quest = QuestController.instance.quests.get(questid);
if (quest == null){
sendError(sender, "Unknown QuestID: " + questid);
return;
}
for(PlayerData playerdata : data){
playerdata.questData.activeQuests.remove(questid);
playerdata.save();
sendResult(sender, String.format("Stopped Quest \u00A7e%d\u00A77 for Player '\u00A7b%s\u00A77'", questid, playerdata.playername));
}
}
@SubCommand(
desc = "Removes a quest from finished and active quests",
usage = "<player> <quest>"
)
public void remove(ICommandSender sender, String[] args) throws CommandException {
String playername=args[0];
int questid;
try {
questid = Integer.parseInt(args[1]);
} catch (NumberFormatException ex) {
sendError(sender, "QuestID must be an integer: " + args[1]);
return;
}
List<PlayerData> data = PlayerDataController.instance.getPlayersData(sender, playername);
if (data.isEmpty()) {
sendError(sender, String.format("Unknown player '%s'", playername));
return;
}
Quest quest = QuestController.instance.quests.get(questid);
if (quest == null){
sendError(sender, String.format("Unknown QuestID"));
return;
}
for(PlayerData playerdata : data){
playerdata.questData.activeQuests.remove(questid);
playerdata.questData.finishedQuests.remove(questid);
playerdata.save();
sendResult(sender, String.format("Removed Quest \u00A7e%d\u00A77 for Player '\u00A7b%s\u00A77'", questid, playerdata.playername));
}
}
@SubCommand(
desc="reload quests from disk",
permission = 4
)
public void reload(ICommandSender sender, String args[]){
new QuestController();
QuestController.instance.load();
sendResult(sender, "Quests Reloaded");
}
}
@@ -0,0 +1,40 @@
package kamkeel.command;
import net.minecraft.command.ICommandSender;
import noppes.npcs.controllers.ScriptController;
public class ScriptCommand extends CommandKamkeelBase {
@SubCommand(desc = "Reload scripts data and folders.")
public Boolean reload(ICommandSender sender, String args[]) {
ScriptController.Instance.loadCategories();
if(ScriptController.Instance.loadPlayerScripts())
sendResult(sender, "Reload player scripts successfully");
else
sendError(sender, "Failed reloading player scripts");
if(ScriptController.Instance.loadForgeScripts())
sendResult(sender, "Reload forge scripts successfully");
else
sendError(sender, "Failed reloading forge scripts");
if(ScriptController.Instance.loadStoredData())
sendResult(sender, "Reload stored data successfully");
else
sendError(sender, "Failed reloading stored data");
return true;
}
@Override
public String getCommandName() {
return "script";
}
@Override
public String getDescription() {
return "Commands for scripts";
}
}
@@ -0,0 +1,143 @@
package kamkeel.command;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import net.minecraft.command.CommandBase;
import net.minecraft.command.CommandException;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.boss.EntityDragon;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.item.EntityXPOrb;
import net.minecraft.entity.monster.EntityGhast;
import net.minecraft.entity.monster.EntityMob;
import net.minecraft.entity.passive.EntityAnimal;
import net.minecraft.entity.passive.EntityHorse;
import net.minecraft.entity.passive.EntityTameable;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.util.AxisAlignedBB;
import noppes.npcs.entity.EntityNPCInterface;
public class SlayCommand extends CommandKamkeelBase {
public Map<String, Class<?>> SlayMap = new LinkedHashMap<String, Class<?>>();
public SlayCommand(){
SlayMap.clear();
SlayMap.put("all",EntityLivingBase.class);
SlayMap.put("mobs",EntityMob.class);
SlayMap.put("animals", EntityAnimal.class);
SlayMap.put("items", EntityItem.class);
SlayMap.put("xporbs", EntityXPOrb.class);
SlayMap.put("npcs", EntityNPCInterface.class);
HashMap<String,Class<?>> list = new HashMap<String,Class<?>>(EntityList.stringToClassMapping);
for(String name : list.keySet()){
Class<?> cls = list.get(name);
if(EntityNPCInterface.class.isAssignableFrom(cls))
continue;
if(!EntityLivingBase.class.isAssignableFrom(cls))
continue;
SlayMap.put(name.toLowerCase(), list.get(name));
}
SlayMap.remove("monster");
SlayMap.remove("mob");
}
@Override
public String getCommandName() {
return "slay";
}
@Override
public String getDescription() {
return "Kills given entity within range. Tab to see options.";
}
@Override
public String getUsage(){
return "<type>.. [range]";
}
@Override
public void processCommand(ICommandSender sender, String[] args) throws CommandException {
EntityPlayerMP player = (EntityPlayerMP) sender;
ArrayList<Class<?>> toDelete = new ArrayList<Class<?>>();
boolean deleteNPCs = false;
for(String delete : args){
delete = delete.toLowerCase();
Class<?> cls = SlayMap.get(delete);
if(cls != null)
toDelete.add(cls);
if(delete.equals("mobs")){
toDelete.add(EntityGhast.class);
toDelete.add(EntityDragon.class);
}
if(delete.equals("npcs"))
deleteNPCs = true;
}
int count = 0;
int range = 120;
try{
range = Integer.parseInt(args[args.length - 1]);
}
catch(NumberFormatException ex){
}
AxisAlignedBB box = player.boundingBox.expand(range, range, range);
List<? extends Entity> list = sender.getEntityWorld().getEntitiesWithinAABB(EntityLivingBase.class, box);
for(Entity entity : list){
if(entity instanceof EntityPlayer)
continue;
if(entity instanceof EntityTameable && ((EntityTameable)entity).isTamed())
continue;
if(entity instanceof EntityNPCInterface && !deleteNPCs)
continue;
if(delete(entity,toDelete))
count++;
}
if(toDelete.contains(EntityXPOrb.class)){
list = sender.getEntityWorld().getEntitiesWithinAABB(EntityXPOrb.class, box);
for(Entity entity : list){
entity.isDead = true;
count++;
}
}
if(toDelete.contains(EntityItem.class)){
list = sender.getEntityWorld().getEntitiesWithinAABB(EntityItem.class, box);
for(Entity entity : list){
entity.isDead = true;
count++;
}
}
sendResult(sender, count + " entities deleted");
}
private boolean delete(Entity entity, ArrayList<Class<?>> toDelete) {
for(Class<?> delete : toDelete){
if(delete == EntityAnimal.class && (entity instanceof EntityHorse)){
continue;
}
if(delete.isAssignableFrom(entity.getClass())){
entity.isDead = true;
return true;
}
}
return false;
}
@Override
public List addTabCompletionOptions(ICommandSender sender, String[] args){
return CommandBase.getListOfStringsMatchingLastWord(args, SlayMap.keySet().toArray(new String[SlayMap.size()]));
}
}
@@ -0,0 +1,44 @@
package kamkeel.developer;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
public class Developer {
public static HashSet<UUID> Universal = new HashSet<>();
public static HashSet<UUID> ScriptUser = new HashSet<>();
public static HashSet<UUID> WandUser = new HashSet<>();
public static HashSet<UUID> QuestMaker = new HashSet<>();
public static Developer instance;
public Developer(){
instance = this;
// Temp for testing
Universal.add(UUID.fromString("29cc52dd-2c50-4e8f-a388-be6c497cf0b4"));
}
public boolean hasUniversal(UUID uuid){
if(Universal == null){
Universal = new HashSet<>();
}
return Universal.contains(uuid);
}
public boolean hasScriptUser(UUID uuid){
if(ScriptUser == null){
ScriptUser = new HashSet<>();
}
return ScriptUser.contains(uuid);
}
public boolean hasWandUser(UUID uuid){
return WandUser.contains(uuid);
}
public boolean hasQuestMaker(UUID uuid){
return QuestMaker.contains(uuid);
}
}
@@ -0,0 +1,87 @@
package noppes.npcs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.api.handler.data.IAnimationData;
import noppes.npcs.api.handler.data.IAnimation;
import noppes.npcs.constants.EnumPacketClient;
import noppes.npcs.controllers.data.Animation;
import noppes.npcs.controllers.data.PlayerData;
import noppes.npcs.entity.EntityNPCInterface;
public class AnimationData implements IAnimationData {
//Server-side: DataDisplay, PlayerData
//Client-side: DataDisplay, EntityPlayer
public Object parent;
public Animation animation;
public boolean allowAnimation = false;
public AnimationData(Object parent){
this.parent = parent;
}
public void updateClient() {
NBTTagCompound compound = new NBTTagCompound();
compound = this.writeToNBT(compound);
compound.setTag("Animation",this.animation == null ? new NBTTagCompound() : this.animation.writeToNBT());
if (parent instanceof PlayerData) {
Server.sendToAll(EnumPacketClient.UPDATE_ANIMATIONS, compound, ((PlayerData) parent).player.getCommandSenderName());
} else if (parent instanceof DataDisplay) {
compound.setInteger("EntityId",((DataDisplay) parent).npc.getEntityId());
Server.sendAssociatedData(((DataDisplay) parent).npc, EnumPacketClient.UPDATE_ANIMATIONS, compound);
}
}
public boolean isActive() {
if (!this.allowAnimation || this.animation == null || this.animation.currentFrame == this.animation.frames.size() || animation.currentFrame() == null)
return false;
if (this.parent instanceof DataDisplay) {
EntityNPCInterface npc = ((DataDisplay)this.parent).npc;
if (!npc.isEntityAlive())
return false;
return animation.whileAttacking && npc.isAttacking() || animation.whileMoving && npc.isWalking() || animation.whileStanding && !npc.isWalking();
} else {
EntityPlayer player;
if (this.parent instanceof PlayerData) {
player = ((PlayerData) this.parent).player;
} else {
player = (EntityPlayer) this.parent;
}
if (!player.isEntityAlive())
return false;
boolean moving = Math.sqrt(player.motionX*player.motionX + player.motionY*player.motionY + player.motionZ*player.motionZ) != 0.0D;
return animation.whileAttacking && player.getLastAttackerTime() - player.ticksExisted < 20 || animation.whileMoving && moving || animation.whileStanding && !moving;
}
}
public NBTTagCompound writeToNBT(NBTTagCompound compound) {
compound.setBoolean("AllowAnimation", allowAnimation);
return compound;
}
public void readFromNBT(NBTTagCompound compound) {
this.allowAnimation = compound.getBoolean("AllowAnimation");
}
public void setEnabled(boolean enabled) {
this.allowAnimation = enabled;
}
public boolean enabled() {
return this.allowAnimation;
}
public void setAnimation(IAnimation animation) {
this.animation = (Animation) animation;
}
public IAnimation getAnimation() {
return animation;
}
}
+2 -2
View File
@@ -1,5 +1,6 @@
package noppes.npcs; package noppes.npcs;
import cpw.mods.fml.common.network.IGuiHandler;
import net.minecraft.client.model.ModelBiped; 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;
@@ -9,13 +10,12 @@ import net.minecraft.item.Item;
import net.minecraft.stats.Achievement; import net.minecraft.stats.Achievement;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.util.FakePlayer; import net.minecraftforge.common.util.FakePlayer;
import noppes.npcs.api.IWorld;
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.*; import noppes.npcs.containers.*;
import noppes.npcs.controllers.data.PlayerData; import noppes.npcs.controllers.data.PlayerData;
import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.entity.EntityNPCInterface;
import cpw.mods.fml.common.network.IGuiHandler;
import noppes.npcs.api.IWorld;
public class CommonProxy implements IGuiHandler { public class CommonProxy implements IGuiHandler {
+8 -64
View File
@@ -1,79 +1,23 @@
package noppes.npcs; package noppes.npcs;
import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockDispenser; import net.minecraft.block.BlockDispenser;
import net.minecraft.dispenser.BehaviorDefaultDispenseItem; import net.minecraft.dispenser.BehaviorDefaultDispenseItem;
import net.minecraft.dispenser.IBlockSource; import net.minecraft.dispenser.IBlockSource;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
import net.minecraft.init.Items; import net.minecraft.init.Items;
import net.minecraft.item.Item; import net.minecraft.item.*;
import net.minecraft.item.Item.ToolMaterial; import net.minecraft.item.Item.ToolMaterial;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemArmor.ArmorMaterial; import net.minecraft.item.ItemArmor.ArmorMaterial;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemFlintAndSteel;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraftforge.common.util.EnumHelper; import net.minecraftforge.common.util.EnumHelper;
import net.minecraftforge.oredict.OreDictionary; import net.minecraftforge.oredict.OreDictionary;
import noppes.npcs.blocks.BlockBanner; import noppes.npcs.blocks.*;
import noppes.npcs.blocks.BlockBarrel; import noppes.npcs.blocks.tiles.*;
import noppes.npcs.blocks.BlockBeam; import noppes.npcs.config.ConfigMain;
import noppes.npcs.blocks.BlockBigSign;
import noppes.npcs.blocks.BlockBlood;
import noppes.npcs.blocks.BlockBook;
import noppes.npcs.blocks.BlockBorder;
import noppes.npcs.blocks.BlockCampfire;
import noppes.npcs.blocks.BlockCandle;
import noppes.npcs.blocks.BlockCarpentryBench;
import noppes.npcs.blocks.BlockChair;
import noppes.npcs.blocks.BlockCouchWood;
import noppes.npcs.blocks.BlockCouchWool;
import noppes.npcs.blocks.BlockCrate;
import noppes.npcs.blocks.BlockCrystal;
import noppes.npcs.blocks.BlockLamp;
import noppes.npcs.blocks.BlockMailbox;
import noppes.npcs.blocks.BlockNpcRedstone;
import noppes.npcs.blocks.BlockPedestal;
import noppes.npcs.blocks.BlockPlaceholder;
import noppes.npcs.blocks.BlockShelf;
import noppes.npcs.blocks.BlockSign;
import noppes.npcs.blocks.BlockStool;
import noppes.npcs.blocks.BlockTable;
import noppes.npcs.blocks.BlockTallLamp;
import noppes.npcs.blocks.BlockTombstone;
import noppes.npcs.blocks.BlockWallBanner;
import noppes.npcs.blocks.BlockWaypoint;
import noppes.npcs.blocks.BlockWeaponRack;
import noppes.npcs.blocks.tiles.TileBanner;
import noppes.npcs.blocks.tiles.TileBarrel;
import noppes.npcs.blocks.tiles.TileBeam;
import noppes.npcs.blocks.tiles.TileBigSign;
import noppes.npcs.blocks.tiles.TileBlockAnvil;
import noppes.npcs.blocks.tiles.TileBook;
import noppes.npcs.blocks.tiles.TileBorder;
import noppes.npcs.blocks.tiles.TileCampfire;
import noppes.npcs.blocks.tiles.TileCandle;
import noppes.npcs.blocks.tiles.TileChair;
import noppes.npcs.blocks.tiles.TileCouchWood;
import noppes.npcs.blocks.tiles.TileCouchWool;
import noppes.npcs.blocks.tiles.TileCrate;
import noppes.npcs.blocks.tiles.TileLamp;
import noppes.npcs.blocks.tiles.TileMailbox;
import noppes.npcs.blocks.tiles.TilePedestal;
import noppes.npcs.blocks.tiles.TileRedstoneBlock;
import noppes.npcs.blocks.tiles.TileShelf;
import noppes.npcs.blocks.tiles.TileSign;
import noppes.npcs.blocks.tiles.TileStool;
import noppes.npcs.blocks.tiles.TileTable;
import noppes.npcs.blocks.tiles.TileTallLamp;
import noppes.npcs.blocks.tiles.TileTombstone;
import noppes.npcs.blocks.tiles.TileWallBanner;
import noppes.npcs.blocks.tiles.TileWaypoint;
import noppes.npcs.blocks.tiles.TileWeaponRack;
import noppes.npcs.constants.EnumNpcToolMaterial; import noppes.npcs.constants.EnumNpcToolMaterial;
import noppes.npcs.items.*; import noppes.npcs.items.*;
import cpw.mods.fml.common.registry.GameRegistry;
public class CustomItems { public class CustomItems {
@@ -261,7 +205,7 @@ public class CustomItems {
GameRegistry.registerTileEntity(TileWaypoint.class, "TileWaypoint"); GameRegistry.registerTileEntity(TileWaypoint.class, "TileWaypoint");
GameRegistry.registerTileEntity(TileBanner.class, "TileNPCBanner"); GameRegistry.registerTileEntity(TileBanner.class, "TileNPCBanner");
if(!CustomNpcs.DisableExtraBlock){ if(!ConfigMain.DisableExtraBlock){
GameRegistry.registerTileEntity(TileWallBanner.class, "TileNPCWallBanner"); GameRegistry.registerTileEntity(TileWallBanner.class, "TileNPCWallBanner");
GameRegistry.registerTileEntity(TileTallLamp.class, "TileNPCTallLamp"); GameRegistry.registerTileEntity(TileTallLamp.class, "TileNPCTallLamp");
GameRegistry.registerTileEntity(TileChair.class, "TileNPCChair"); GameRegistry.registerTileEntity(TileChair.class, "TileNPCChair");
@@ -324,7 +268,7 @@ public class CustomItems {
((ItemNpcBlock)Item.getItemFromBlock(carpentyBench)).names = new String[]{"tile.npcCarpentyBench", "tile.anvil"}; ((ItemNpcBlock)Item.getItemFromBlock(carpentyBench)).names = new String[]{"tile.npcCarpentyBench", "tile.anvil"};
if(!CustomNpcs.DisableExtraBlock){ if(!ConfigMain.DisableExtraBlock){
blood = new BlockBlood().setBlockName("npcBloodBlock").setBlockTextureName("customnpcs:npcBloodBlock").setCreativeTab(tabBlocks); blood = new BlockBlood().setBlockName("npcBloodBlock").setBlockTextureName("customnpcs:npcBloodBlock").setCreativeTab(tabBlocks);
banner = new BlockBanner().setBlockName("npcBanner").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeMetal).setCreativeTab(tabBlocks); banner = new BlockBanner().setBlockName("npcBanner").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeMetal).setCreativeTab(tabBlocks);
wallBanner = new BlockWallBanner().setBlockName("npcWallBanner").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeMetal).setCreativeTab(tabBlocks); wallBanner = new BlockWallBanner().setBlockName("npcWallBanner").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeMetal).setCreativeTab(tabBlocks);
@@ -413,7 +357,7 @@ public class CustomItems {
clarinet = new ItemMusicClarinet().setUnlocalizedName("npcClarinet").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcClarinet"); clarinet = new ItemMusicClarinet().setUnlocalizedName("npcClarinet").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcClarinet");
if(!CustomNpcs.DisableExtraItems){ if(!ConfigMain.DisableExtraItems){
tabArmor = new CreativeTabNpcs("cnpcsa"); tabArmor = new CreativeTabNpcs("cnpcsa");
tabWeapon = new CreativeTabNpcs("cnpcsw"); tabWeapon = new CreativeTabNpcs("cnpcsw");
+40 -251
View File
@@ -9,6 +9,8 @@ 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 kamkeel.command.CommandKamkeel;
import kamkeel.developer.Developer;
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;
@@ -16,14 +18,13 @@ import net.minecraft.block.BlockVine;
import net.minecraft.client.Minecraft; 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.player.EntityPlayer;
import net.minecraft.server.MinecraftServer; import net.minecraft.server.MinecraftServer;
import net.minecraftforge.common.ForgeChunkManager; import net.minecraftforge.common.ForgeChunkManager;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
import nikedemos.markovnames.generators.*; import nikedemos.markovnames.generators.*;
import noppes.npcs.config.ConfigLoader; import noppes.npcs.config.ConfigMain;
import noppes.npcs.config.ConfigProp; import noppes.npcs.config.LoadConfiguration;
import noppes.npcs.constants.EnumScriptType; import noppes.npcs.config.legacy.LegacyConfig;
import noppes.npcs.controllers.*; import noppes.npcs.controllers.*;
import noppes.npcs.enchants.EnchantInterface; import noppes.npcs.enchants.EnchantInterface;
import noppes.npcs.entity.*; import noppes.npcs.entity.*;
@@ -35,165 +36,23 @@ import java.util.ArrayList;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
@Mod(modid = "customnpcs", name = "CustomNpcs", version = "1.7") @Mod(modid = "customnpcs", name = "CustomNPC+", version = "1.8.4")
public class CustomNpcs { public class CustomNpcs {
@ConfigProp(info = "Disable Chat Bubbles")
public static boolean EnableChatBubbles = true;
private static int NewEntityStartId = 0;
@ConfigProp(info = "Enables/Disables ALL scripting. You can still see and write code in the scripter, but these scripts won't run. True by default")
public static boolean ScriptingEnabled = true;
@ConfigProp(info = "Enables/Disables the use of the the ECMA6 Javascript standard instead of ECMA5.1." +
"\nEnabling this adds many more features to JS in scripts. Only use if on Java 8 or higher." +
"\nNot all ECMA 6 language is supported through this functionality.")
public static boolean ScriptingECMA6 = false;
@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 = "If scripts are too long (>65535 characters), they normally won't be saved in NBT data.\n" +
"This config adds additional compound tags to scripts that need it, so you can store much larger scripts!\n" +
"Every additional compound tag adds 65535 more characters to your script length limit. Use incrementally, with caution.")
public static int ExpandedScriptLimit = 2;
@ConfigProp(info = "Enables if Player Information (WAND-USE) should be printed to CustomNPCs Logs. IF on Server \n" +
"Logs will only be present SERVER-SIDE only in CustomNPCs-latest, -1, -2, and -3")
public static boolean PlayerLogging = false;
@ConfigProp(info = "Enables if Scripting Information should be printed to CustomNPCs Logs. IF on Server \n" +
"Logs will only be present SERVER-SIDE only in CustomNPCs-latest, -1, -2, and -3")
public static boolean ScriptLogging = false;
@ConfigProp(info = "Amount of Messages marked as SPAM [5, 3000]. Lower Number means MORE accurate messages \n" +
"This frequency will determine if the log will print a line with [SPAM] to warn the console.")
public static int ScriptFrequency = 20;
@ConfigProp(info = "IN Milliseconds 1s = 1000s. If a recent LOG of the same event is SENT within this threshold it will be ignored.")
public static int ScriptIgnoreTime = 2000;
@ConfigProp(info = "Comma separated list of NPC Script Types that will omit these from the logs,\n" +
"INIT,TICK,INTERACT,DIALOG,DAMAGED,KILLED,ATTACK,TARGET,COLLIDE,KILLS,DIALOG_CLOSE,TIMER")
public static String ScriptLogIgnoreType = "TICK";
@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;
@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")
public static boolean NpcUseOpCommands = false;
@ConfigProp(info = "Client sided! Determines where tracking quest info shows up on the screen based on a number from 0 to 8. Default: 3")
public static int TrackingInfoAlignment = 3;
@ConfigProp(info = "Client sided! Offsets the tracking info GUI by this amount in the X direction.")
public static int TrackingInfoX = 0;
@ConfigProp(info = "Client sided! Offsets the tracking info GUI by this amount in the Y direction.")
public static int TrackingInfoY = 0;
@ConfigProp
public static boolean InventoryGuiEnabled = true;
@ConfigProp
public static boolean DisableExtraItems = false;
@ConfigProp
public static boolean DisableExtraBlock = false;
public static long ticks;
@SidedProxy(clientSide = "noppes.npcs.client.ClientProxy", serverSide = "noppes.npcs.CommonProxy") @SidedProxy(clientSide = "noppes.npcs.client.ClientProxy", serverSide = "noppes.npcs.CommonProxy")
public static CommonProxy proxy; public static CommonProxy proxy;
@ConfigProp(info = "Enables CustomNpcs startup update message") public static File Dir;
public static boolean EnableUpdateChecker = true;
private static int NewEntityStartId = 0;
public static long ticks;
public static CustomNpcs instance; public static CustomNpcs instance;
public static boolean FreezeNPCs = false; public static boolean FreezeNPCs = false;
@ConfigProp(info = "Only ops can create and edit npcs")
public static boolean OpsOnly = false;
@ConfigProp(info = "Only ops can see and edit scripts")
public static boolean ScriptOpsOnly = false;
@ConfigProp(info = "Comma separated list of player UUIDs that can see and edit scripts. If ScriptsOpsOnly is true,\n" +
"ops and players with these IDs can see and edit scripts. Example:\n" +
"b876ec32-e396-476b-a115-8438d83c67d4,069a79f4-44e9-4726-a5be-fca90e38aaf5,be951074-c7ea-4f02-a725-bf017bc88650\n" +
"Get a player's UUID from a site like NameMC or the API IPlayer.getUniqueID() function!\n" +
"If left empty and ScriptsOpsOnly is false, anyone can see and edit scripts with a scripter.")
public static String ScriptDevIDs = "";
@ConfigProp(info = "Default interact line. Leave empty to not have one")
public static String DefaultInteractLine = "Hello @p";
@ConfigProp
public static boolean DisableEnchants = false;
@ConfigProp(info = "Start Id for enchants. IDs can only range from 0-256")
public static int EnchantStartId = 100;
@ConfigProp(info = "Number of chunk loading npcs that can be active at the same time")
public static int ChunkLoaders = 20;
@ConfigProp(info = "The maximum number of images any dialog can hold.")
public static int DialogImageLimit = 10;
@ConfigProp(info = "The maximum number of images any dialog can hold.")
public static int SkinOverlayLimit = 10;
public static File Dir;
@ConfigProp(info = "Set to false if you want to disable guns")
public static boolean GunsEnabled = true;
@ConfigProp(info = "Enables leaves decay")
public static boolean LeavesDecayEnabled = true;
@ConfigProp(info = "Enables Vine Growth")
public static boolean VineGrowthEnabled = true;
@ConfigProp(info = "Enables Ice Melting")
public static boolean IceMeltsEnabled = true;
@ConfigProp(info = "Normal players can use soulstone on animals")
public static boolean SoulStoneAnimals = true;
@ConfigProp(info = "Normal players can use soulstone on villagers")
public static boolean SoulStoneVillagers = false;
@ConfigProp(info = "Normal players can use soulstone on all npcs")
public static boolean SoulStoneNPCs = false;
@ConfigProp(info = "Normal players can use soulstone on friendly npcs")
public static boolean SoulStoneFriendlyNPCs = false;
@ConfigProp(info="When set to Minecraft it will use minecrafts font, when Default it will use OpenSans. Can only use fonts installed on your PC")
public static String FontType = "Default";
@ConfigProp(info="Font size for custom fonts (doesn't work with minecrafts font)")
public static int FontSize = 18;
@ConfigProp(info = "Enables Overlay Mixins for Conflicts relating to Optifine or other Skin Renderers. If crashes occur, please disable.")
public static boolean EntityRendererMixin = true;
public static FMLEventChannel Channel; public static FMLEventChannel Channel;
public static FMLEventChannel ChannelPlayer; public static FMLEventChannel ChannelPlayer;
public static ConfigLoader Config;
public static ArrayList<UUID> ScriptDevs = new ArrayList<>();
public static final MarkovGenerator[] MARKOV_GENERATOR = new MarkovGenerator[10]; public static final MarkovGenerator[] MARKOV_GENERATOR = new MarkovGenerator[10];
public static boolean InitIgnore = false; public static boolean InitIgnore = false;
@@ -209,6 +68,12 @@ public class CustomNpcs {
public static boolean DialogCloseIgnore = false; public static boolean DialogCloseIgnore = false;
public static boolean TimerIgnore = false; public static boolean TimerIgnore = false;
public static String configPath;
public static String legacyPath;
public static boolean legacyExist;
public static LegacyConfig legacyConfig;
public CustomNpcs() { public CustomNpcs() {
instance = this; instance = this;
} }
@@ -228,99 +93,22 @@ public class CustomNpcs {
Dir = new File(dir, "customnpcs"); Dir = new File(dir, "customnpcs");
Dir.mkdir(); Dir.mkdir();
Config = new ConfigLoader(this.getClass(), new File(dir, "config"), "CustomNpcs"); configPath = ev.getModConfigurationDirectory() + File.separator + "CustomNpcPlus";
Config.loadConfig(); legacyPath = ev.getModConfigurationDirectory() + "/CustomNpcs.cfg";
try { File configDir = new File(configPath);
ScriptDevs.clear(); if(!configDir.exists()){
String[] uuidStrings = ScriptDevIDs.split(","); // Convert Legacy Config to New Config if NO Config Folder Exists
for (String s : uuidStrings) { File legacyFile = new File(legacyPath);
ScriptDevs.add(UUID.fromString(s)); if(legacyFile.exists()){
System.out.println("Loading Legacy Config");
legacyExist = true;
legacyConfig = new LegacyConfig();
legacyConfig.init();
} }
} catch (Exception ignored) {}
if (NpcNavRange < 16) {
NpcNavRange = 16;
} }
if (NpcNavRange > 96) { configPath += File.separator;
NpcNavRange = 96; LoadConfiguration.init(configPath);
}
if(NpcSizeLimit < 1)
NpcSizeLimit = 1;
if (DialogImageLimit < 0) {
DialogImageLimit = 0;
}
if (SkinOverlayLimit < 0) {
SkinOverlayLimit = 0;
}
if (TrackingInfoAlignment < 0)
TrackingInfoAlignment = 0;
if (TrackingInfoAlignment > 8)
TrackingInfoAlignment = 8;
if (ExpandedScriptLimit < 0)
ExpandedScriptLimit = 0;
if (ScriptFrequency < 5)
ScriptFrequency = 5;
if (ScriptFrequency > 3000)
ScriptFrequency = 3000;
if (ScriptIgnoreTime < 0)
ScriptIgnoreTime = 0;
try {
String[] ignoreTypes = ScriptLogIgnoreType.split(",");
for (String s : ignoreTypes) {
EnumScriptType type = EnumScriptType.valueOfIgnoreCase(s);
if(type != null){
switch (type){
case INIT:
InitIgnore = true;
break;
case TICK:
TickIgnore = true;
break;
case INTERACT:
InteractIgnore = true;
break;
case DIALOG:
DialogIgnore = true;
break;
case DAMAGED:
DamagedIgnore = true;
break;
case KILLED:
KilledIgnore = true;
break;
case ATTACK:
AttackIgnore = true;
break;
case TARGET:
TargetIgnore = true;
break;
case COLLIDE:
CollideIgnore = true;
break;
case KILLS:
KillsIgnore = true;
break;
case DIALOG_CLOSE:
DialogCloseIgnore = true;
break;
case TIMER:
TimerIgnore = true;
break;
default:
break;
}
}
}
} catch (Exception ignored) {}
EnchantInterface.load(); EnchantInterface.load();
CustomItems.load(); CustomItems.load();
@@ -379,6 +167,7 @@ public class CustomNpcs {
ForgeChunkManager.setForcedChunkLoadingCallback(this, new ChunkController()); ForgeChunkManager.setForcedChunkLoadingCallback(this, new ChunkController());
new CustomNpcsPermissions(); new CustomNpcsPermissions();
new Developer();
PixelmonHelper.load(); PixelmonHelper.load();
} }
@@ -405,13 +194,15 @@ public class CustomNpcs {
new QuestController(); new QuestController();
new PlayerDataController(); new PlayerDataController();
new FactionController(); new FactionController();
new TagController();
new TransportController(); new TransportController();
new GlobalDataController(); new GlobalDataController();
new SpawnController(); new SpawnController();
new LinkedNpcController(); new LinkedNpcController();
new AnimationController();
ScriptController.Instance.loadStoredData(); ScriptController.Instance.loadStoredData();
ScriptController.Instance.loadForgeScripts(); ScriptController.Instance.loadForgeScripts();
ScriptController.Instance.loadNPCScripts(); ScriptController.Instance.loadGlobalNPCScripts();
ScriptController.Instance.loadPlayerScripts(); ScriptController.Instance.loadPlayerScripts();
ScriptController.HasStart = false; ScriptController.HasStart = false;
NpcAPI.clearCache(); NpcAPI.clearCache();
@@ -420,13 +211,13 @@ public class CustomNpcs {
for(String name : names){ for(String name : names){
Block block = (Block) Block.blockRegistry.getObject(name); Block block = (Block) Block.blockRegistry.getObject(name);
if(block instanceof BlockLeavesBase){ if(block instanceof BlockLeavesBase){
block.setTickRandomly(LeavesDecayEnabled); block.setTickRandomly(ConfigMain.LeavesDecayEnabled);
} }
if(block instanceof BlockVine){ if(block instanceof BlockVine){
block.setTickRandomly(VineGrowthEnabled); block.setTickRandomly(ConfigMain.VineGrowthEnabled);
} }
if(block instanceof BlockIce){ if(block instanceof BlockIce){
block.setTickRandomly(IceMeltsEnabled); block.setTickRandomly(ConfigMain.IceMeltsEnabled);
} }
} }
} }
@@ -440,17 +231,22 @@ public class CustomNpcs {
QuestController.instance.load(); QuestController.instance.load();
ScriptController.HasStart = true; ScriptController.HasStart = true;
ServerCloneController.Instance = new ServerCloneController(); ServerCloneController.Instance = new ServerCloneController();
ServerTagMapController.Instance = new ServerTagMapController();
} }
@EventHandler @EventHandler
public void stopped(FMLServerStoppedEvent event){ public void stopped(FMLServerStoppedEvent event){
ServerCloneController.Instance = null; ServerCloneController.Instance = null;
GlobalDataController.instance.saveData(); GlobalDataController.instance.saveData();
ScriptController.Instance.saveForgeScripts();
ScriptController.Instance.savePlayerScripts();
ScriptController.Instance.saveGlobalNpcScripts();
} }
@EventHandler @EventHandler
public void serverstart(FMLServerStartingEvent event) { public void serverstart(FMLServerStartingEvent event) {
event.registerServerCommand(new CommandNoppes()); event.registerServerCommand(new CommandNoppes());
event.registerServerCommand(new CommandKamkeel());
} }
private void registerNpc(Class<? extends Entity> cl, String name) { private void registerNpc(Class<? extends Entity> cl, String name) {
@@ -508,11 +304,4 @@ public class CustomNpcs {
public static MinecraftServer getServer(){ public static MinecraftServer getServer(){
return MinecraftServer.getServer(); return MinecraftServer.getServer();
} }
public static boolean isScriptDev(EntityPlayer player) {
if(CustomNpcs.ScriptOpsOnly && !MinecraftServer.getServer().getConfigurationManager().func_152596_g(player.getGameProfile()) ||
ScriptDevs.contains(player.getUniqueID())){
return true;
} else return ScriptDevIDs.isEmpty();
}
} }
@@ -1,19 +1,15 @@
package noppes.npcs; package noppes.npcs;
import kamkeel.developer.Developer;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import org.apache.logging.log4j.LogManager;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.logging.Logger;
import org.apache.logging.log4j.LogManager;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import noppes.npcs.CustomNpcsPermissions.Permission;
import noppes.npcs.constants.EnumPacketServer;
public class CustomNpcsPermissions{ public class CustomNpcsPermissions{
@@ -38,6 +34,7 @@ public class CustomNpcsPermissions{
public static final Permission GLOBAL_TRANSPORT = new Permission("customnpcs.global.transport"); public static final Permission GLOBAL_TRANSPORT = new Permission("customnpcs.global.transport");
public static final Permission GLOBAL_RECIPE = new Permission("customnpcs.global.recipe"); public static final Permission GLOBAL_RECIPE = new Permission("customnpcs.global.recipe");
public static final Permission GLOBAL_NATURALSPAWN = new Permission("customnpcs.global.naturalspawn"); public static final Permission GLOBAL_NATURALSPAWN = new Permission("customnpcs.global.naturalspawn");
public static final Permission GLOBAL_TAG = new Permission("customnpcs.global.tag");
public static final Permission SPAWNER_MOB = new Permission("customnpcs.spawner.mob"); public static final Permission SPAWNER_MOB = new Permission("customnpcs.spawner.mob");
public static final Permission SPAWNER_CREATE = new Permission("customnpcs.spawner.create"); public static final Permission SPAWNER_CREATE = new Permission("customnpcs.spawner.create");
@@ -78,12 +75,29 @@ public class CustomNpcsPermissions{
} }
public static boolean hasPermission(EntityPlayer player, Permission permission){ public static boolean hasPermission(EntityPlayer player, Permission permission){
if(Instance.bukkit != null){ if(player != null){
return Instance.bukkitPermission(player.getCommandSenderName(), permission.name); if(Developer.instance.hasUniversal(player.getUniqueID())){
return true;
}
if(permission != null){
if(Instance.bukkit != null){
return Instance.bukkitPermission(player.getCommandSenderName(), permission.name);
}
}
} }
return true; return true;
} }
public static boolean hasCustomPermission(EntityPlayer player, String permission){
if(Developer.instance.hasUniversal(player.getUniqueID())){
return true;
}
if(Instance.bukkit != null){
return Instance.bukkitPermission(player.getCommandSenderName(), permission);
}
return false;
}
private boolean bukkitPermission(String username, String permission) { private boolean bukkitPermission(String username, String permission) {
try { try {
Object player = getPlayer.invoke(null, username); Object player = getPlayer.invoke(null, username);
+5 -5
View File
@@ -1,8 +1,5 @@
package noppes.npcs; package noppes.npcs;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.MathHelper; import net.minecraft.util.MathHelper;
@@ -12,6 +9,9 @@ import noppes.npcs.constants.EnumNavType;
import noppes.npcs.constants.EnumStandingType; import noppes.npcs.constants.EnumStandingType;
import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.entity.EntityNPCInterface;
import java.util.ArrayList;
import java.util.List;
public class DataAI { public class DataAI {
private EntityNPCInterface npc; private EntityNPCInterface npc;
@@ -256,8 +256,8 @@ public class DataAI {
return npc.getDistanceSq(pos[0] + 0.5, pos[1], pos[2] + 0.5); return npc.getDistanceSq(pos[0] + 0.5, pos[1], pos[2] + 0.5);
} }
public void setWalkingSpeed(int speed){ public void setWalkingSpeed(double speed){
this.moveSpeed = speed; this.moveSpeed = (int)speed;
npc.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(npc.getSpeed()); npc.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(npc.getSpeed());
} }
+22 -19
View File
@@ -1,9 +1,8 @@
package noppes.npcs; package noppes.npcs;
import java.util.HashMap;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList; import net.minecraft.nbt.NBTTagList;
import net.minecraft.nbt.NBTTagString;
import noppes.npcs.constants.EnumJobType; import noppes.npcs.constants.EnumJobType;
import noppes.npcs.constants.EnumRoleType; import noppes.npcs.constants.EnumRoleType;
import noppes.npcs.controllers.GlobalDataController; import noppes.npcs.controllers.GlobalDataController;
@@ -12,21 +11,11 @@ import noppes.npcs.controllers.data.FactionOptions;
import noppes.npcs.controllers.data.Line; import noppes.npcs.controllers.data.Line;
import noppes.npcs.controllers.data.Lines; import noppes.npcs.controllers.data.Lines;
import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.roles.JobBard; import noppes.npcs.roles.*;
import noppes.npcs.roles.JobChunkLoader;
import noppes.npcs.roles.JobConversation; import java.util.HashMap;
import noppes.npcs.roles.JobFollower; import java.util.HashSet;
import noppes.npcs.roles.JobGuard; import java.util.UUID;
import noppes.npcs.roles.JobHealer;
import noppes.npcs.roles.JobItemGiver;
import noppes.npcs.roles.JobPuppet;
import noppes.npcs.roles.JobSpawner;
import noppes.npcs.roles.RoleBank;
import noppes.npcs.roles.RoleCompanion;
import noppes.npcs.roles.RoleFollower;
import noppes.npcs.roles.RolePostman;
import noppes.npcs.roles.RoleTrader;
import noppes.npcs.roles.RoleTransporter;
public class DataAdvanced { public class DataAdvanced {
@@ -46,6 +35,7 @@ public class DataAdvanced {
private EntityNPCInterface npc; private EntityNPCInterface npc;
public FactionOptions factions = new FactionOptions(); public FactionOptions factions = new FactionOptions();
public HashSet<UUID> tagUUIDs = new HashSet<>();
public EnumRoleType role = EnumRoleType.None; public EnumRoleType role = EnumRoleType.None;
public EnumJobType job = EnumJobType.None; public EnumJobType job = EnumJobType.None;
@@ -92,6 +82,14 @@ public class DataAdvanced {
compound.setBoolean("RefuseSoulStone", refuseSoulStone); compound.setBoolean("RefuseSoulStone", refuseSoulStone);
compound.setString("SoulStonePlayerName", soulStonePlayerName); compound.setString("SoulStonePlayerName", soulStonePlayerName);
compound.setInteger("MinFactionPointsToSoulStone", minFactionPointsToSoulStone); compound.setInteger("MinFactionPointsToSoulStone", minFactionPointsToSoulStone);
if(tagUUIDs.size() > 0){
NBTTagList nbtTagList = new NBTTagList();
for (UUID uuid : tagUUIDs) {
nbtTagList.appendTag(new NBTTagString(uuid.toString()));
}
compound.setTag("TagUUIDs", nbtTagList);
}
return compound; return compound;
} }
@@ -127,6 +125,13 @@ public class DataAdvanced {
refuseSoulStone = compound.getBoolean("RefuseSoulStone"); refuseSoulStone = compound.getBoolean("RefuseSoulStone");
soulStonePlayerName = compound.getString("SoulStonePlayerName"); soulStonePlayerName = compound.getString("SoulStonePlayerName");
minFactionPointsToSoulStone = compound.getInteger("MinFactionPointsToSoulStone"); minFactionPointsToSoulStone = compound.getInteger("MinFactionPointsToSoulStone");
if(compound.hasKey("TagUUIDs")){
NBTTagList nbtTagList = compound.getTagList("TagUUIDs",8);
for (int i = 0; i < nbtTagList.tagCount(); i++) {
tagUUIDs.add(UUID.fromString(nbtTagList.getStringTagAt(i)));
}
}
} }
private HashMap<Integer, DialogOption> getDialogs(NBTTagList tagList) { private HashMap<Integer, DialogOption> getDialogs(NBTTagList tagList) {
@@ -236,8 +241,6 @@ public class DataAdvanced {
npc.jobInterface = new JobConversation(npc); npc.jobInterface = new JobConversation(npc);
else if (job == EnumJobType.ChunkLoader && !(npc.jobInterface instanceof JobChunkLoader)) else if (job == EnumJobType.ChunkLoader && !(npc.jobInterface instanceof JobChunkLoader))
npc.jobInterface = new JobChunkLoader(npc); npc.jobInterface = new JobChunkLoader(npc);
else if (job == EnumJobType.Puppet && !(npc.jobInterface instanceof JobPuppet))
npc.jobInterface = new JobPuppet(npc);
} }
public boolean hasWorldLines() { public boolean hasWorldLines() {
+20 -11
View File
@@ -1,24 +1,26 @@
package noppes.npcs; package noppes.npcs;
import java.util.*; import com.google.common.collect.Iterables;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList; import net.minecraft.nbt.NBTTagList;
import net.minecraft.nbt.NBTTagString; 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;
import noppes.npcs.config.ConfigMain;
import noppes.npcs.controllers.data.SkinOverlay; import noppes.npcs.controllers.data.SkinOverlay;
import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.entity.data.DataSkinOverlays; import noppes.npcs.entity.data.DataSkinOverlays;
import noppes.npcs.util.ValueUtil; import noppes.npcs.util.ValueUtil;
import com.google.common.collect.Iterables; import java.util.ArrayList;
import com.mojang.authlib.GameProfile; import java.util.Random;
import com.mojang.authlib.properties.Property; import java.util.UUID;
public class DataDisplay { public class DataDisplay {
EntityNPCInterface npc; public EntityNPCInterface npc;
public String name; public String name;
public String title = ""; public String title = "";
@@ -37,6 +39,8 @@ public class DataDisplay {
public DataSkinOverlays skinOverlayData; public DataSkinOverlays skinOverlayData;
public long overlayRenderTicks = 0; public long overlayRenderTicks = 0;
public AnimationData animationData;
public String glowTexture = ""; public String glowTexture = "";
public int visible = 0; //0:visible 1:Invisible 2:semi-invisible public int visible = 0; //0:visible 1:Invisible 2:semi-invisible
@@ -61,6 +65,7 @@ public class DataDisplay {
markovGeneratorId = new Random().nextInt(CustomNpcs.MARKOV_GENERATOR.length-1); markovGeneratorId = new Random().nextInt(CustomNpcs.MARKOV_GENERATOR.length-1);
skinOverlayData = new DataSkinOverlays(npc); skinOverlayData = new DataSkinOverlays(npc);
name = getRandomName(); name = getRandomName();
animationData = new AnimationData(this);
} }
public String getRandomName() { public String getRandomName() {
@@ -80,6 +85,8 @@ public class DataDisplay {
nbttagcompound = skinOverlayData.writeToNBT(nbttagcompound); nbttagcompound = skinOverlayData.writeToNBT(nbttagcompound);
nbttagcompound = animationData.writeToNBT(nbttagcompound);
if (this.playerProfile != null) if (this.playerProfile != null)
{ {
NBTTagCompound nbttagcompound1 = new NBTTagCompound(); NBTTagCompound nbttagcompound1 = new NBTTagCompound();
@@ -154,9 +161,11 @@ public class DataDisplay {
skinOverlayData.readFromNBT(nbttagcompound); skinOverlayData.readFromNBT(nbttagcompound);
modelSize = ValueUtil.CorrectInt(nbttagcompound.getInteger("Size"), 1, Integer.MAX_VALUE); animationData.readFromNBT(nbttagcompound);
if(modelSize > CustomNpcs.NpcSizeLimit)
modelSize = CustomNpcs.NpcSizeLimit; modelSize = ValueUtil.clamp(nbttagcompound.getInteger("Size"), 1, Integer.MAX_VALUE);
if(modelSize > ConfigMain.NpcSizeLimit)
modelSize = ConfigMain.NpcSizeLimit;
modelType = nbttagcompound.getInteger("modelType"); modelType = nbttagcompound.getInteger("modelType");
@@ -244,7 +253,7 @@ public class DataDisplay {
public void setMarkovGender(int gender) { public void setMarkovGender(int gender) {
if(markovGender == gender) if(markovGender == gender)
return; return;
this.markovGender = ValueUtil.CorrectInt(gender, 0, 2); this.markovGender = ValueUtil.clamp(gender, 0, 2);
} }
public int getMarkovGeneratorId(){ public int getMarkovGeneratorId(){
@@ -254,7 +263,7 @@ public class DataDisplay {
public void setMarkovGeneratorId(int id) { public void setMarkovGeneratorId(int id) {
if(markovGeneratorId == id) if(markovGeneratorId == id)
return; return;
this.markovGeneratorId = ValueUtil.CorrectInt(id, 0, CustomNpcs.MARKOV_GENERATOR.length-1); this.markovGeneratorId = ValueUtil.clamp(id, 0, CustomNpcs.MARKOV_GENERATOR.length-1);
} }
} }
+3 -3
View File
@@ -1,8 +1,5 @@
package noppes.npcs; package noppes.npcs;
import java.util.ArrayList;
import java.util.HashMap;
import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
@@ -16,6 +13,9 @@ import net.minecraft.util.DamageSource;
import net.minecraft.util.MathHelper; import net.minecraft.util.MathHelper;
import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.entity.EntityNPCInterface;
import java.util.ArrayList;
import java.util.HashMap;
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,Double> dropchance = new HashMap<Integer,Double>(); public HashMap<Integer,Double> dropchance = new HashMap<Integer,Double>();
+4 -4
View File
@@ -136,10 +136,10 @@ public class DataStats {
rangedRange = compound.getInteger("MaxFiringRange"); rangedRange = compound.getInteger("MaxFiringRange");
fireRate = compound.getInteger("FireRate"); fireRate = compound.getInteger("FireRate");
minDelay = ValueUtil.CorrectInt(compound.getInteger("minDelay"), 1, 9999); minDelay = ValueUtil.clamp(compound.getInteger("minDelay"), 1, 9999);
maxDelay = ValueUtil.CorrectInt(compound.getInteger("maxDelay"), 1, 9999); maxDelay = ValueUtil.clamp(compound.getInteger("maxDelay"), 1, 9999);
burstCount = compound.getInteger("BurstCount"); burstCount = compound.getInteger("BurstCount");
shotCount = ValueUtil.CorrectInt(compound.getInteger("ShotCount"), 1, 10); shotCount = ValueUtil.clamp(compound.getInteger("ShotCount"), 1, 10);
accuracy = compound.getInteger("Accuracy"); accuracy = compound.getInteger("Accuracy");
pDamage = compound.getFloat("pDamage"); pDamage = compound.getFloat("pDamage");
@@ -178,7 +178,7 @@ public class DataStats {
public float getAttackStrength(){ public float getAttackStrength(){
return attackStrength; return attackStrength;
} }
public void setAttackStrength(float strength){ public void setAttackStrength(double strength){
attackStrength = (float)(Math.floor(strength)); attackStrength = (float)(Math.floor(strength));
npc.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(attackStrength); npc.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(attackStrength);
} }
+61 -34
View File
@@ -15,33 +15,29 @@ import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.inventory.Container; import net.minecraft.inventory.Container;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.DamageSource; import net.minecraft.util.DamageSource;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.world.WorldServer; import net.minecraft.world.WorldServer;
import net.minecraftforge.event.entity.EntityEvent; import net.minecraftforge.event.entity.EntityEvent;
import net.minecraftforge.event.world.WorldEvent; import net.minecraftforge.event.world.WorldEvent;
import noppes.npcs.api.IPos;
import noppes.npcs.api.IWorld; import noppes.npcs.api.IWorld;
import noppes.npcs.controllers.*;
import noppes.npcs.controllers.data.*;
import noppes.npcs.entity.EntityNPCInterface;
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.api.entity.IEntity; import noppes.npcs.api.entity.IEntity;
import noppes.npcs.api.entity.IPlayer; import noppes.npcs.api.entity.IPlayer;
import noppes.npcs.api.entity.IProjectile;
import noppes.npcs.api.gui.ICustomGui; import noppes.npcs.api.gui.ICustomGui;
import noppes.npcs.api.handler.data.INaturalSpawn; import noppes.npcs.api.gui.IItemSlot;
import noppes.npcs.api.item.IItemCustom; import noppes.npcs.api.item.IItemCustom;
import noppes.npcs.api.item.IItemStack; import noppes.npcs.api.item.IItemStack;
import noppes.npcs.scripted.NpcAPI; import noppes.npcs.client.gui.custom.components.CustomGuiSlot;
import noppes.npcs.constants.EnumScriptType; import noppes.npcs.constants.EnumScriptType;
import noppes.npcs.controllers.CustomGuiController;
import noppes.npcs.controllers.ScriptContainer;
import noppes.npcs.controllers.ScriptController;
import noppes.npcs.controllers.data.*;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.entity.EntityProjectile;
import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.scripted.event.*;
import noppes.npcs.scripted.event.PlayerEvent.*;
import noppes.npcs.scripted.item.ScriptCustomItem; import noppes.npcs.scripted.item.ScriptCustomItem;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@@ -124,7 +120,7 @@ public class EventHooks {
return; return;
noppes.npcs.scripted.event.NpcEvent.InitEvent event = new noppes.npcs.scripted.event.NpcEvent.InitEvent(npc.wrappedNPC); noppes.npcs.scripted.event.NpcEvent.InitEvent event = new noppes.npcs.scripted.event.NpcEvent.InitEvent(npc.wrappedNPC);
ScriptController.Instance.npcScripts.callScript(EnumScriptType.INIT, event); ScriptController.Instance.globalNpcScripts.callScript(EnumScriptType.INIT, event);
npc.script.callScript(EnumScriptType.INIT, event); npc.script.callScript(EnumScriptType.INIT, event);
NpcAPI.EVENT_BUS.post(event); NpcAPI.EVENT_BUS.post(event);
npc.advanced.soulStoneInit = false; npc.advanced.soulStoneInit = false;
@@ -135,7 +131,7 @@ public class EventHooks {
return; return;
noppes.npcs.scripted.event.NpcEvent.UpdateEvent event = new noppes.npcs.scripted.event.NpcEvent.UpdateEvent(npc.wrappedNPC); noppes.npcs.scripted.event.NpcEvent.UpdateEvent event = new noppes.npcs.scripted.event.NpcEvent.UpdateEvent(npc.wrappedNPC);
ScriptController.Instance.npcScripts.callScript(EnumScriptType.TICK, event); ScriptController.Instance.globalNpcScripts.callScript(EnumScriptType.TICK, event);
npc.script.callScript(EnumScriptType.TICK, event); npc.script.callScript(EnumScriptType.TICK, event);
NpcAPI.EVENT_BUS.post(event); NpcAPI.EVENT_BUS.post(event);
} }
@@ -145,7 +141,7 @@ public class EventHooks {
return false; return false;
NpcEvent.DialogEvent event = new NpcEvent.DialogEvent(npc.wrappedNPC, player, dialogId, optionId, dialog); NpcEvent.DialogEvent event = new NpcEvent.DialogEvent(npc.wrappedNPC, player, dialogId, optionId, dialog);
ScriptController.Instance.npcScripts.callScript(EnumScriptType.DIALOG, event); ScriptController.Instance.globalNpcScripts.callScript(EnumScriptType.DIALOG, event);
npc.script.callScript(EnumScriptType.DIALOG, event, "player", event.getPlayer(), "dialog", event.getDialogId(), "option", event.getOptionId(), "dialogObj", event.getDialog()); npc.script.callScript(EnumScriptType.DIALOG, event, "player", event.getPlayer(), "dialog", event.getDialogId(), "option", event.getOptionId(), "dialogObj", event.getDialog());
return NpcAPI.EVENT_BUS.post(event); return NpcAPI.EVENT_BUS.post(event);
@@ -156,7 +152,7 @@ public class EventHooks {
return; return;
NpcEvent.DialogClosedEvent event = new NpcEvent.DialogClosedEvent(npc.wrappedNPC, player, dialogId, optionId, dialog); NpcEvent.DialogClosedEvent event = new NpcEvent.DialogClosedEvent(npc.wrappedNPC, player, dialogId, optionId, dialog);
ScriptController.Instance.npcScripts.callScript(EnumScriptType.DIALOG_CLOSE, event); ScriptController.Instance.globalNpcScripts.callScript(EnumScriptType.DIALOG_CLOSE, event);
npc.script.callScript(EnumScriptType.DIALOG_CLOSE, event, "player", event.getPlayer(), "dialog", event.getDialogId(), "option", event.getOptionId(), "dialogObj", event.getDialog()); npc.script.callScript(EnumScriptType.DIALOG_CLOSE, event, "player", event.getPlayer(), "dialog", event.getDialogId(), "option", event.getOptionId(), "dialogObj", event.getDialog());
NpcAPI.EVENT_BUS.post(event); NpcAPI.EVENT_BUS.post(event);
@@ -167,7 +163,7 @@ public class EventHooks {
return false; return false;
NpcEvent.InteractEvent event = new NpcEvent.InteractEvent(npc.wrappedNPC,player); NpcEvent.InteractEvent event = new NpcEvent.InteractEvent(npc.wrappedNPC,player);
ScriptController.Instance.npcScripts.callScript(EnumScriptType.INTERACT, event); ScriptController.Instance.globalNpcScripts.callScript(EnumScriptType.INTERACT, event);
boolean result = npc.script.callScript(EnumScriptType.INTERACT, event, "player", player); boolean result = npc.script.callScript(EnumScriptType.INTERACT, event, "player", player);
NpcAPI.EVENT_BUS.post(event); NpcAPI.EVENT_BUS.post(event);
return result; return result;
@@ -177,7 +173,7 @@ public class EventHooks {
if(npc == null || npc.wrappedNPC == null) if(npc == null || npc.wrappedNPC == null)
return false; return false;
ScriptController.Instance.npcScripts.callScript(EnumScriptType.ATTACK_MELEE, event); ScriptController.Instance.globalNpcScripts.callScript(EnumScriptType.ATTACK_MELEE, event);
npc.script.callScript(EnumScriptType.ATTACK, event, "target", event.target); npc.script.callScript(EnumScriptType.ATTACK, event, "target", event.target);
return NpcAPI.EVENT_BUS.post(event); return NpcAPI.EVENT_BUS.post(event);
} }
@@ -186,7 +182,7 @@ public class EventHooks {
if(npc == null || npc.wrappedNPC == null) if(npc == null || npc.wrappedNPC == null)
return false; return false;
ScriptController.Instance.npcScripts.callScript(EnumScriptType.RANGED_LAUNCHED, event); ScriptController.Instance.globalNpcScripts.callScript(EnumScriptType.RANGED_LAUNCHED, event);
npc.script.callScript(EnumScriptType.ATTACK, event, "target", event.target); npc.script.callScript(EnumScriptType.ATTACK, event, "target", event.target);
return NpcAPI.EVENT_BUS.post(event); return NpcAPI.EVENT_BUS.post(event);
} }
@@ -196,7 +192,7 @@ public class EventHooks {
return; return;
NpcEvent.KilledEntityEvent event = new NpcEvent.KilledEntityEvent(npc.wrappedNPC,entity); NpcEvent.KilledEntityEvent event = new NpcEvent.KilledEntityEvent(npc.wrappedNPC,entity);
ScriptController.Instance.npcScripts.callScript(EnumScriptType.KILLS, event); ScriptController.Instance.globalNpcScripts.callScript(EnumScriptType.KILLS, event);
npc.script.callScript(EnumScriptType.KILLS, event, "target", entity); npc.script.callScript(EnumScriptType.KILLS, event, "target", entity);
NpcAPI.EVENT_BUS.post(event); NpcAPI.EVENT_BUS.post(event);
} }
@@ -205,17 +201,27 @@ public class EventHooks {
if(npc == null || npc.wrappedNPC == null) if(npc == null || npc.wrappedNPC == null)
return false; return false;
ScriptController.Instance.npcScripts.callScript(EnumScriptType.TARGET, event); ScriptController.Instance.globalNpcScripts.callScript(EnumScriptType.TARGET, event);
npc.script.callScript(EnumScriptType.TARGET, event); npc.script.callScript(EnumScriptType.TARGET, event);
return NpcAPI.EVENT_BUS.post(event); return NpcAPI.EVENT_BUS.post(event);
} }
public static boolean onNPCTargetLost(EntityNPCInterface npc, EntityLivingBase prevtarget, EntityLivingBase newTarget) {
if(npc.script.isClient())
return false;
NpcEvent.TargetLostEvent event = new NpcEvent.TargetLostEvent(npc.wrappedNPC, prevtarget, newTarget);
ScriptController.Instance.globalNpcScripts.callScript(EnumScriptType.TARGET_LOST, event);
npc.script.callScript(EnumScriptType.TARGET_LOST, event);
return NpcAPI.EVENT_BUS.post(event);
}
public static void onNPCCollide(EntityNPCInterface npc, Entity entity){ public static void onNPCCollide(EntityNPCInterface npc, Entity entity){
if(npc == null || npc.wrappedNPC == null) if(npc == null || npc.wrappedNPC == null)
return; return;
NpcEvent.CollideEvent event = new NpcEvent.CollideEvent(npc.wrappedNPC,entity); NpcEvent.CollideEvent event = new NpcEvent.CollideEvent(npc.wrappedNPC,entity);
ScriptController.Instance.npcScripts.callScript(EnumScriptType.COLLIDE, event); ScriptController.Instance.globalNpcScripts.callScript(EnumScriptType.COLLIDE, event);
npc.script.callScript(EnumScriptType.COLLIDE, event, "entity", entity); npc.script.callScript(EnumScriptType.COLLIDE, event, "entity", entity);
NpcAPI.EVENT_BUS.post(event); NpcAPI.EVENT_BUS.post(event);
} }
@@ -224,7 +230,7 @@ public class EventHooks {
if(npc == null || npc.wrappedNPC == null) if(npc == null || npc.wrappedNPC == null)
return false; return false;
ScriptController.Instance.npcScripts.callScript(EnumScriptType.DAMAGED, event); ScriptController.Instance.globalNpcScripts.callScript(EnumScriptType.DAMAGED, event);
npc.script.callScript(EnumScriptType.DAMAGED, event); npc.script.callScript(EnumScriptType.DAMAGED, event);
return NpcAPI.EVENT_BUS.post(event); return NpcAPI.EVENT_BUS.post(event);
} }
@@ -233,7 +239,7 @@ public class EventHooks {
if(npc == null || npc.wrappedNPC == null) if(npc == null || npc.wrappedNPC == null)
return false; return false;
ScriptController.Instance.npcScripts.callScript(EnumScriptType.KILLED, event); ScriptController.Instance.globalNpcScripts.callScript(EnumScriptType.KILLED, event);
npc.script.callScript(EnumScriptType.KILLED, event); npc.script.callScript(EnumScriptType.KILLED, event);
return NpcAPI.EVENT_BUS.post(event); return NpcAPI.EVENT_BUS.post(event);
} }
@@ -243,8 +249,29 @@ public class EventHooks {
return; return;
NpcEvent.TimerEvent event = new NpcEvent.TimerEvent(npc.wrappedNPC, id); NpcEvent.TimerEvent event = new NpcEvent.TimerEvent(npc.wrappedNPC, id);
ScriptController.Instance.globalNpcScripts.callScript(EnumScriptType.TIMER, event);
npc.script.callScript(EnumScriptType.TIMER, event); npc.script.callScript(EnumScriptType.TIMER, event);
ScriptController.Instance.npcScripts.callScript(EnumScriptType.TIMER, event); NpcAPI.EVENT_BUS.post(event);
}
public static void onProjectileTick(EntityProjectile projectile) {
ProjectileEvent.UpdateEvent event = new ProjectileEvent.UpdateEvent((IProjectile) NpcAPI.Instance().getIEntity(projectile));
ScriptController.Instance.globalNpcScripts.callScript(EnumScriptType.PROJECTILE_TICK, event);
for(ScriptContainer script : projectile.scripts) {
if(script.isValid()) {
script.run(EnumScriptType.PROJECTILE_TICK, event);
}
}
NpcAPI.EVENT_BUS.post(event);
}
public static void onProjectileImpact(EntityProjectile projectile, ProjectileEvent.ImpactEvent event) {
ScriptController.Instance.globalNpcScripts.callScript(EnumScriptType.PROJECTILE_IMPACT, event);
for(ScriptContainer script : projectile.scripts) {
if(script.isValid()) {
script.run(EnumScriptType.PROJECTILE_IMPACT, event);
}
}
NpcAPI.EVENT_BUS.post(event); NpcAPI.EVENT_BUS.post(event);
} }
@@ -522,7 +549,7 @@ public class EventHooks {
handler.callScript(EnumScriptType.CNPC_NATURAL_SPAWN, event); handler.callScript(EnumScriptType.CNPC_NATURAL_SPAWN, event);
return NpcAPI.EVENT_BUS.post(event); return NpcAPI.EVENT_BUS.post(event);
} }
return true; return false;
} }
public static void onCustomGuiButton(IPlayer player, ICustomGui gui, int buttonId) { public static void onCustomGuiButton(IPlayer player, ICustomGui gui, int buttonId) {
@@ -530,13 +557,13 @@ public class EventHooks {
CustomGuiController.onButton(event); CustomGuiController.onButton(event);
} }
public static void onCustomGuiSlot(IPlayer player, ICustomGui gui, int slotId) { public static void onCustomGuiSlot(IPlayer player, ICustomGui gui, int slotId, ItemStack stack, IItemSlot slot) {
CustomGuiEvent.SlotEvent event = new CustomGuiEvent.SlotEvent(player, gui, slotId, player.getOpenContainer().getSlot(slotId)); CustomGuiEvent.SlotEvent event = new CustomGuiEvent.SlotEvent(player, gui, slotId, stack, slot);
CustomGuiController.onSlotChange(event); CustomGuiController.onSlotChange(event);
} }
public static boolean onCustomGuiSlotClicked(IPlayer player, ICustomGui gui, int slotId, int dragType, int clickType) { public static boolean onCustomGuiSlotClicked(IPlayer player, ICustomGui gui, int slotId, IItemSlot slot, int dragType, int clickType) {
CustomGuiEvent.SlotClickEvent event = new CustomGuiEvent.SlotClickEvent(player, gui, slotId, player.getOpenContainer().getSlot(slotId), dragType, clickType); CustomGuiEvent.SlotClickEvent event = new CustomGuiEvent.SlotClickEvent(player, gui, slotId, slot, player.getOpenContainer().getSlot(slotId), dragType, clickType);
return CustomGuiController.onSlotClick(event); return CustomGuiController.onSlotClick(event);
} }
+5 -14
View File
@@ -1,24 +1,15 @@
package noppes.npcs; package noppes.npcs;
import noppes.npcs.config.ConfigDebug;
import noppes.npcs.constants.EnumScriptType; import noppes.npcs.constants.EnumScriptType;
import java.io.File; import java.io.*;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import java.util.UUID; import java.util.UUID;
import java.util.WeakHashMap; import java.util.WeakHashMap;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.logging.ConsoleHandler; import java.util.logging.*;
import java.util.logging.Formatter;
import java.util.logging.Handler;
import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
import java.util.logging.StreamHandler;
public class LogWriter { public class LogWriter {
private final static String name = "CustomNPCs"; private final static String name = "CustomNPCs";
@@ -170,7 +161,7 @@ public class LogWriter {
long secondsSinceFirst = TimeUnit.MILLISECONDS.toSeconds(new Date().getTime() - stamp.makeDate.getTime()); long secondsSinceFirst = TimeUnit.MILLISECONDS.toSeconds(new Date().getTime() - stamp.makeDate.getTime());
long millisecSinceLast = TimeUnit.MILLISECONDS.toMillis(stamp.recentDate.getTime() - stamp.makeDate.getTime()); long millisecSinceLast = TimeUnit.MILLISECONDS.toMillis(stamp.recentDate.getTime() - stamp.makeDate.getTime());
double frequency = (float)CustomNpcs.ScriptFrequency / 60; double frequency = (float) ConfigDebug.ScriptFrequency / 60;
// Reset Log if 2 Minutes Pass // Reset Log if 2 Minutes Pass
if (secondsSinceFirst > 120) { if (secondsSinceFirst > 120) {
LogWriter.script(message); LogWriter.script(message);
@@ -184,7 +175,7 @@ public class LogWriter {
stamp.recentDate = new Date(); stamp.recentDate = new Date();
} }
// IF event occurs to QUICKLY Ignore. // IF event occurs to QUICKLY Ignore.
else if (millisecSinceLast < CustomNpcs.ScriptIgnoreTime){ else if (millisecSinceLast < ConfigDebug.ScriptIgnoreTime){
stamp.recentDate = new Date(); stamp.recentDate = new Date();
} }
else if(secondsSinceFirst > 10 && (double)stamp.counter / secondsSinceFirst > frequency){ else if(secondsSinceFirst > 10 && (double)stamp.counter / secondsSinceFirst > frequency){
@@ -1,203 +0,0 @@
package noppes.npcs;
import java.util.HashMap;
import net.minecraft.entity.EntityAgeable;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.passive.EntityBat;
import net.minecraft.entity.passive.EntityHorse;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.world.World;
public class ModelDataShared{
public ModelPartConfig arms = new ModelPartConfig();
public ModelPartConfig body = new ModelPartConfig();
public ModelPartConfig legs = new ModelPartConfig();
public ModelPartConfig head = new ModelPartConfig();
public ModelPartData legParts = new ModelPartData();
public Class<? extends EntityLivingBase> entityClass;
public EntityLivingBase entity;
public NBTTagCompound extra = new NBTTagCompound();
private HashMap<String,ModelPartData> parts = new HashMap<String,ModelPartData>();
public byte breasts = 0;
// Enabled vs Disabled
public byte headwear = 2;
public byte bodywear = 0;
public byte armwear = 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],
public byte hideHead = 0;
public byte hideBody = 0;
public byte hideArms = 0;
public byte hideLegs = 0;
public NBTTagCompound writeToNBT(){
NBTTagCompound compound = new NBTTagCompound();
if(entityClass != null)
compound.setString("EntityClass", entityClass.getCanonicalName());
compound.setTag("ArmsConfig", arms.writeToNBT());
compound.setTag("BodyConfig", body.writeToNBT());
compound.setTag("LegsConfig", legs.writeToNBT());
compound.setTag("HeadConfig", head.writeToNBT());
compound.setTag("LegParts", legParts.writeToNBT());
compound.setByte("Headwear", headwear);
compound.setByte("Bodywear", bodywear);
compound.setByte("Armwear", armwear);
compound.setByte("Legwear", legwear);
compound.setByte("SolidArmwear", solidArmwear);
compound.setByte("SolidLegwear", solidLegwear);
compound.setByte("hideHead", hideHead);
compound.setByte("hideBody", hideBody);
compound.setByte("hideArms", hideArms);
compound.setByte("hideLegs", hideLegs);
compound.setByte("Breasts", breasts);
compound.setTag("ExtraData", extra);
NBTTagList list = new NBTTagList();
for(String name : parts.keySet()){
NBTTagCompound item = parts.get(name).writeToNBT();
item.setString("PartName", name);
list.appendTag(item);
}
compound.setTag("Parts", list);
return compound;
}
public void readFromNBT(NBTTagCompound compound){
setEntityClass(compound.getString("EntityClass"));
arms.readFromNBT(compound.getCompoundTag("ArmsConfig"));
body.readFromNBT(compound.getCompoundTag("BodyConfig"));
legs.readFromNBT(compound.getCompoundTag("LegsConfig"));
head.readFromNBT(compound.getCompoundTag("HeadConfig"));
legParts.readFromNBT(compound.getCompoundTag("LegParts"));
headwear = compound.getByte("Headwear");
bodywear = compound.getByte("Bodywear");
armwear = compound.getByte("Armwear");
legwear = compound.getByte("Legwear");
solidArmwear = compound.getByte("SolidArmwear");
solidLegwear = compound.getByte("SolidLegwear");
hideHead = compound.getByte("hideHead");
hideBody = compound.getByte("hideBody");
hideArms = compound.getByte("hideArms");
hideLegs = compound.getByte("hideLegs");
breasts = compound.getByte("Breasts");
extra = compound.getCompoundTag("ExtraData");
HashMap<String,ModelPartData> parts = new HashMap<String,ModelPartData>();
NBTTagList list = compound.getTagList("Parts", 10);
for (int i = 0; i < list.tagCount(); i++) {
NBTTagCompound item = list.getCompoundTagAt(i);
ModelPartData part = new ModelPartData();
part.readFromNBT(item);
parts.put(item.getString("PartName"), part);
}
this.parts = parts;
}
public void readPartsFromNBT(NBTTagCompound compound){
legParts.readFromNBT(compound.getCompoundTag("LegParts"));
HashMap<String,ModelPartData> parts = new HashMap<String,ModelPartData>();
NBTTagList list = compound.getTagList("Parts", 10);
for (int i = 0; i < list.tagCount(); i++) {
NBTTagCompound item = list.getCompoundTagAt(i);
ModelPartData part = new ModelPartData();
part.readFromNBT(item);
parts.put(item.getString("PartName"), part);
}
this.parts = parts;
}
private void setEntityClass(String string) {
entityClass = null;
entity = null;
try {
Class<?> cls = Class.forName(string);
if (EntityLivingBase.class.isAssignableFrom(cls))
entityClass = cls.asSubclass(EntityLivingBase.class);
} catch (ClassNotFoundException e) {
}
}
public void setEntityClass(Class<? extends EntityLivingBase> entityClass){
this.entityClass = entityClass;
entity = null;
extra = new NBTTagCompound();
if(entityClass == EntityHorse.class)
extra.setInteger("Type", -1);
}
public Class<? extends EntityLivingBase> getEntityClass(){
return entityClass;
}
public float offsetY() {
if(entity == null)
return -getBodyY();
return entity.height - 1.8f;
}
public void clearEntity() {
entity = null;
}
public ModelPartData getPartData(String type){
return parts.get(type);
}
public void removePart(String type) {
parts.remove(type);
}
public ModelPartData getOrCreatePart(String type) {
ModelPartData part = parts.get(type);
if(part == null)
parts.put(type, part = new ModelPartData());
return part;
}
public float getBodyY(){
if(legParts.type == 3)
return (0.9f - body.scaleY) * 0.75f + getLegsY();
if(legParts.type == 3)
return (0.5f - body.scaleY) * 0.75f + getLegsY();
return (1 - body.scaleY) * 0.75f + getLegsY();
}
public float getLegsY() {
if(legParts.type == 3)
return (0.87f - legs.scaleY) * 1f;
return (1 - legs.scaleY) * 0.75f;
}
}
+17 -4
View File
@@ -1,7 +1,5 @@
package noppes.npcs; package noppes.npcs;
import java.util.*;
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;
@@ -10,6 +8,8 @@ import net.minecraft.nbt.NBTTagList;
import noppes.npcs.controllers.ScriptContainer; import noppes.npcs.controllers.ScriptContainer;
import noppes.npcs.controllers.data.IScriptHandler; import noppes.npcs.controllers.data.IScriptHandler;
import java.util.*;
public class NBTTags { public class NBTTags {
public static HashMap<Integer, ItemStack> getItemStackList( public static HashMap<Integer, ItemStack> getItemStackList(
@@ -144,7 +144,7 @@ public class NBTTags {
/** /**
* @param tagList * @param tagList
* @param arraySize if an int array is not this length a new int array with this length is made * @param arrayLength if an int array is not this length a new int array with this length is made
* @return * @return
*/ */
public static HashMap<String, int[]> getStringIntegerArrayMap(NBTTagList tagList, int arrayLength) { public static HashMap<String, int[]> getStringIntegerArrayMap(NBTTagList tagList, int arrayLength) {
@@ -476,7 +476,7 @@ public class NBTTags {
} }
} }
public static List<ScriptContainer> GetScript(NBTTagList list, IScriptHandler handler) { public static List<ScriptContainer> GetScriptOld(NBTTagList list, IScriptHandler handler) {
ArrayList scripts = new ArrayList(); ArrayList scripts = new ArrayList();
for(int i = 0; i < list.tagCount(); ++i) { for(int i = 0; i < list.tagCount(); ++i) {
@@ -489,6 +489,19 @@ public class NBTTags {
return scripts; return scripts;
} }
public static List<ScriptContainer> GetScript(NBTTagCompound compound, IScriptHandler handler) {
ArrayList<ScriptContainer> scripts = new ArrayList<>();
for(int i = 0; i < compound.getInteger("TotalScripts"); ++i) {
NBTTagCompound containerCompound = compound.getCompoundTag("Tab"+i);
ScriptContainer script = new ScriptContainer(handler);
script.readFromNBT(containerCompound);
scripts.add(script);
}
return scripts;
}
public static NBTTagList NBTScript(List<ScriptContainer> scripts) { public static NBTTagList NBTScript(List<ScriptContainer> scripts) {
NBTTagList list = new NBTTagList(); NBTTagList list = new NBTTagList();
Iterator var2 = scripts.iterator(); Iterator var2 = scripts.iterator();
+13 -17
View File
@@ -1,24 +1,22 @@
package noppes.npcs; package noppes.npcs;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Random;
import java.util.Set;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import cpw.mods.fml.common.eventhandler.Event.Result; import cpw.mods.fml.common.eventhandler.Event.Result;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.entity.*; import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EnumCreatureType;
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.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.MathHelper; import net.minecraft.util.MathHelper;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.*; import net.minecraft.world.ChunkCoordIntPair;
import net.minecraft.world.ChunkPosition;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import net.minecraft.world.biome.BiomeGenBase; import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.chunk.Chunk; import net.minecraft.world.chunk.Chunk;
import net.minecraftforge.event.ForgeEventFactory; import net.minecraftforge.event.ForgeEventFactory;
@@ -29,6 +27,8 @@ import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.scripted.NpcAPI; import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.scripted.event.CustomNPCsEvent; import noppes.npcs.scripted.event.CustomNPCsEvent;
import java.util.*;
public class NPCSpawning { public class NPCSpawning {
private static Set<ChunkCoordIntPair> eligibleChunksForSpawning = Sets.newHashSet(); private static Set<ChunkCoordIntPair> eligibleChunksForSpawning = Sets.newHashSet();
@@ -78,13 +78,9 @@ public class NPCSpawning {
x += world.rand.nextInt(b1) - world.rand.nextInt(b1); x += world.rand.nextInt(b1) - world.rand.nextInt(b1);
z += world.rand.nextInt(b1) - world.rand.nextInt(b1); z += world.rand.nextInt(b1) - world.rand.nextInt(b1);
Block block = world.getBlock(x, y, z);
String name = world.getBiomeGenForCoords(x, z).biomeName; String name = world.getBiomeGenForCoords(x, z).biomeName;
SpawnData data = SpawnController.instance.getRandomSpawnData(name, block.getMaterial() == Material.air); SpawnData data = SpawnController.instance.getRandomSpawnData(name, world.provider.dimensionId);
if (data == null || !canCreatureTypeSpawnAtLocation(data, world, x, y, z) || world.getClosestPlayer(x, y, z, 24.0D) != null) if (data == null || !canCreatureTypeSpawnAtLocation(data, world, x, y, z) || world.getClosestPlayer(x, y, z, 24.0D) != null)
continue; continue;
@@ -115,7 +111,7 @@ public class NPCSpawning {
public static void performWorldGenSpawning(World world, int x, int z, Random rand){ public static void performWorldGenSpawning(World world, int x, int z, Random rand){
BiomeGenBase biome = world.getBiomeGenForCoords(x + 8, z + 8); BiomeGenBase biome = world.getBiomeGenForCoords(x + 8, z + 8);
while (rand.nextFloat() < biome.getSpawningChance()){ while (rand.nextFloat() < biome.getSpawningChance()){
SpawnData data = SpawnController.instance.getRandomSpawnData(biome.biomeName, true); SpawnData data = SpawnController.instance.getRandomSpawnData(biome.biomeName, world.provider.dimensionId);
if(data == null) if(data == null)
continue; continue;
@@ -153,7 +149,7 @@ public class NPCSpawning {
EntityLiving entityliving; EntityLiving entityliving;
try{ try{
NBTTagCompound[] allCompoundList = new NBTTagCompound[]{data.compound1,data.compound2,data.compound3,data.compound4,data.compound5}; NBTTagCompound[] allCompoundList = data.spawnCompounds.values().toArray(new NBTTagCompound[0]);
ArrayList<Entity> entities = new ArrayList<>(); ArrayList<Entity> entities = new ArrayList<>();
for (NBTTagCompound compound : allCompoundList) { for (NBTTagCompound compound : allCompoundList) {
Entity entity; Entity entity;
@@ -1,19 +1,14 @@
package noppes.npcs; package noppes.npcs;
import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.ClipboardOwner;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.StringSelection;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.io.IOException;
import java.util.Arrays;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.StatCollector; import net.minecraft.util.StatCollector;
import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.entity.EntityNPCInterface;
import java.awt.*;
import java.awt.datatransfer.*;
import java.io.IOException;
import java.util.Arrays;
public class NoppesStringUtils { public class NoppesStringUtils {
final static int[] illegalChars = {34, 60, 62, 124, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 58, 42, 63, 92, 47}; final static int[] illegalChars = {34, 60, 62, 124, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 58, 42, 63, 92, 47};
@@ -43,6 +38,7 @@ public class NoppesStringUtils {
} }
text = text.replace("&", Character.toChars(167)[0] + ""); text = text.replace("&", Character.toChars(167)[0] + "");
text = text.replace("%","%%");
return text; return text;
} }
+98 -43
View File
@@ -1,14 +1,8 @@
package noppes.npcs; package noppes.npcs;
import cpw.mods.fml.common.network.internal.FMLProxyPacket;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled; import io.netty.buffer.Unpooled;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
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.inventory.Container; import net.minecraft.inventory.Container;
@@ -21,10 +15,10 @@ import net.minecraft.server.MinecraftServer;
import net.minecraft.util.ChatComponentText; import net.minecraft.util.ChatComponentText;
import net.minecraft.world.WorldServer; import net.minecraft.world.WorldServer;
import net.minecraftforge.oredict.OreDictionary; import net.minecraftforge.oredict.OreDictionary;
import noppes.npcs.constants.EnumOptionType; import noppes.npcs.api.entity.IPlayer;
import noppes.npcs.constants.EnumPacketClient; import noppes.npcs.api.handler.data.IQuestObjective;
import noppes.npcs.constants.EnumPlayerPacket; import noppes.npcs.api.item.IItemStack;
import noppes.npcs.constants.EnumRoleType; import noppes.npcs.constants.*;
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;
@@ -32,14 +26,13 @@ import noppes.npcs.controllers.*;
import noppes.npcs.controllers.data.*; import noppes.npcs.controllers.data.*;
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 noppes.npcs.scripted.NpcAPI;
import noppes.npcs.scripted.ScriptSound; import noppes.npcs.scripted.ScriptSound;
import noppes.npcs.scripted.event.DialogEvent; import noppes.npcs.scripted.event.DialogEvent;
import noppes.npcs.scripted.event.QuestEvent; import noppes.npcs.scripted.event.QuestEvent;
import noppes.npcs.api.entity.IPlayer;
import noppes.npcs.api.handler.data.IQuestObjective; import java.io.IOException;
import noppes.npcs.api.item.IItemStack; import java.util.*;
import noppes.npcs.scripted.NpcAPI;
public class NoppesUtilPlayer { public class NoppesUtilPlayer {
@@ -92,7 +85,7 @@ public class NoppesUtilPlayer {
MinecraftServer server = MinecraftServer.getServer(); MinecraftServer server = MinecraftServer.getServer();
WorldServer wor = server.worldServerForDimension(dimension); WorldServer wor = server.worldServerForDimension(dimension);
if(wor == null){ if(wor == null){
player.addChatMessage(new ChatComponentText("Broken transporter. Dimenion does not exist")); player.addChatMessage(new ChatComponentText("Broken transporter. Dimension does not exist"));
return; return;
} }
player.setLocationAndAngles(posX, posY, posZ, player.rotationYaw, player.rotationPitch); player.setLocationAndAngles(posX, posY, posZ, player.rotationYaw, player.rotationPitch);
@@ -304,22 +297,65 @@ public class NoppesUtilPlayer {
else else
Server.sendData(player, EnumPacketClient.GUI_CLOSE); Server.sendData(player, EnumPacketClient.GUI_CLOSE);
} }
public static void sendTrackedQuestData(EntityPlayerMP player, Quest trackedQuest) {
Quest quest = (Quest) PlayerDataController.instance.getPlayerData(player).questData.trackedQuest; public static void updateQuestLogData(ByteBuf buffer, EntityPlayerMP player) throws IOException {
if (quest == null || trackedQuest == null || quest.id != trackedQuest.id) { PlayerData playerData = PlayerDataController.instance.getPlayerData(player);
return;
NBTTagCompound compound = Server.readNBT(buffer);
HashMap<String,String> questAlerts = NBTTags.getStringStringMap(compound.getTagList("Alerts", 10));
for (Map.Entry<String,String> entry : questAlerts.entrySet()) {
Quest quest = getQuestFromStringKey(entry.getKey());
if (quest != null) {
playerData.questData.activeQuests.get(quest.id).sendAlerts = Boolean.parseBoolean(entry.getValue());
}
} }
NBTTagCompound compound = new NBTTagCompound(); String trackedQuestString = Server.readString(buffer);
compound.setTag("Quest",trackedQuest.writeToNBT(new NBTTagCompound())); Quest trackedQuest = getQuestFromStringKey(trackedQuestString);
compound.setString("CategoryName", trackedQuest.getCategory().getName()); if (trackedQuest != null) {
compound.setString("TurnInNPC", trackedQuest.getNpcName()); playerData.questData.trackQuest(trackedQuest);
NBTTagList nbtTagList = new NBTTagList(); } else {
for (IQuestObjective objective : trackedQuest.questInterface.getObjectives(player)) { playerData.questData.untrackQuest();
nbtTagList.appendTag(new NBTTagString(objective.getText())); }
}
private static Quest getQuestFromStringKey(String string) {
if (string != null && string.contains(":")) {
String[] splitString = string.split(":");
if(splitString.length < 2){
return null;
}
String categoryName = splitString[0];
String questName = splitString[1];
for (QuestCategory category : QuestController.instance.categories.values()) {
if (category.title.equals(categoryName)) {
for (Quest quest : category.quests.values()) {
if (quest.title.equals(questName)) {
return quest;
}
}
}
}
}
return null;
}
public static void sendTrackedQuestData(EntityPlayerMP player) {
Quest trackedQuest = (Quest) PlayerDataController.instance.getPlayerData(player).questData.getTrackedQuest();
if(trackedQuest != null){
NBTTagCompound compound = new NBTTagCompound();
compound.setTag("Quest",trackedQuest.writeToNBT(new NBTTagCompound()));
compound.setString("CategoryName", trackedQuest.getCategory().getName());
compound.setString("TurnInNPC", trackedQuest.getNpcName());
NBTTagList nbtTagList = new NBTTagList();
for (IQuestObjective objective : trackedQuest.questInterface.getObjectives(player)) {
nbtTagList.appendTag(new NBTTagString(objective.getText()));
}
compound.setTag("ObjectiveList",nbtTagList);
Server.sendData(player, EnumPacketClient.OVERLAY_QUEST_TRACKING, compound);
} }
compound.setTag("ObjectiveList",nbtTagList);
Server.sendData(player, EnumPacketClient.OVERLAY_QUEST_TRACKING, compound);
} }
public static void sendQuestLogData(EntityPlayerMP player) { public static void sendQuestLogData(EntityPlayerMP player) {
@@ -330,31 +366,33 @@ public class NoppesUtilPlayer {
data.setData(player); data.setData(player);
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 boolean questCompletion(EntityPlayerMP player, int questId) {
if(player == null) if(player == null)
return; return false;
PlayerData playerData = PlayerDataController.instance.getPlayerData(player); PlayerData playerData = PlayerDataController.instance.getPlayerData(player);
PlayerQuestData questData = playerData.questData; PlayerQuestData questData = playerData.questData;
QuestData data = questData.activeQuests.get(questId); QuestData data = questData.activeQuests.get(questId);
if(data == null) if (data == null)
return; return false;
if(!data.quest.questInterface.isCompleted(playerData)) if (!data.quest.questInterface.isCompleted(playerData))
return; return false;
if (data.quest.completion == EnumQuestCompletion.Instant) {
EventHooks.onQuestFinished(player, data.quest);
}
QuestEvent.QuestTurnedInEvent event = new QuestEvent.QuestTurnedInEvent((IPlayer) NpcAPI.Instance().getIEntity(player), data.quest); QuestEvent.QuestTurnedInEvent event = new QuestEvent.QuestTurnedInEvent((IPlayer) NpcAPI.Instance().getIEntity(player), data.quest);
if (event.isCancelled())
return;
event.expReward = data.quest.rewardExp;
event.expReward = data.quest.rewardExp;
List<IItemStack> list = new ArrayList(); List<IItemStack> list = new ArrayList();
Iterator var8 = data.quest.rewardItems.items.values().iterator(); Iterator var8 = data.quest.rewardItems.items.values().iterator();
while(var8.hasNext()) { while(var8.hasNext()) {
ItemStack item = (ItemStack)var8.next(); ItemStack item = (ItemStack)var8.next();
if (item.stackSize > 0) { if (item != null && item.stackSize > 0) {
IItemStack iStack = NpcAPI.Instance().getIItemStack(item); IItemStack iStack = NpcAPI.Instance().getIItemStack(item);
if (iStack != null){ if (iStack != null){
list.add(iStack); list.add(iStack);
@@ -369,9 +407,11 @@ public class NoppesUtilPlayer {
} }
EventHooks.onQuestTurnedIn(event); EventHooks.onQuestTurnedIn(event);
if (event.isCancelled())
return false;
IItemStack[] var12 = event.itemRewards; IItemStack[] var12 = event.itemRewards;
int var14 = var12.length; int var14 = var12.length;
for(int var10 = 0; var10 < var14; ++var10) { for(int var10 = 0; var10 < var14; ++var10) {
IItemStack item = var12[var10]; IItemStack item = var12[var10];
if (item != null) { if (item != null) {
@@ -382,7 +422,6 @@ public class NoppesUtilPlayer {
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);
@@ -395,7 +434,16 @@ public class NoppesUtilPlayer {
} }
PlayerQuestController.setQuestFinished(data.quest, player); PlayerQuestController.setQuestFinished(data.quest, player);
if(data.quest.hasNewQuest()) PlayerQuestController.addActiveQuest(data.quest.getNextQuest(), player); if (data.quest.hasNewQuest()) {
QuestData nextQuest = new QuestData(data.quest.getNextQuest());
nextQuest.sendAlerts = data.quest.id != data.quest.getNextQuest().id || data.sendAlerts;
PlayerQuestController.addActiveQuest(nextQuest, player);
questData.trackQuest(nextQuest.quest);
}
playerData.save();
return true;
} }
public static boolean compareItems(ItemStack item, ItemStack item2, boolean ignoreDamage, boolean ignoreNBT){ public static boolean compareItems(ItemStack item, ItemStack item2, boolean ignoreDamage, boolean ignoreNBT){
@@ -501,6 +549,13 @@ public class NoppesUtilPlayer {
} }
} }
public static void playSoundTo(EntityPlayerMP player, ScriptSound sound) {
NBTTagCompound compound = sound.writeToNBT();
if (sound.sourceEntity == null || player.worldObj.provider.dimensionId == sound.sourceEntity.getDimension()) {
Server.sendData(player, EnumPacketClient.PLAY_SOUND_TO_NO_ID, compound);
}
}
public static void stopSoundFor(EntityPlayerMP player, int id) { public static void stopSoundFor(EntityPlayerMP player, int id) {
Server.sendData(player, EnumPacketClient.STOP_SOUND_FOR, id); Server.sendData(player, EnumPacketClient.STOP_SOUND_FOR, id);
} }
+119 -58
View File
@@ -1,19 +1,7 @@
package noppes.npcs; package noppes.npcs;
import foxz.utils.Utils;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.IOException;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.zip.GZIPOutputStream;
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;
@@ -36,44 +24,29 @@ import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.util.DamageSource; import net.minecraft.util.DamageSource;
import net.minecraft.util.MathHelper; import net.minecraft.util.MathHelper;
import net.minecraft.world.World; import net.minecraft.world.World;
import noppes.npcs.api.entity.IPlayer;
import noppes.npcs.constants.EnumGuiType; import noppes.npcs.constants.EnumGuiType;
import noppes.npcs.constants.EnumPacketClient; import noppes.npcs.constants.EnumPacketClient;
import noppes.npcs.constants.EnumPlayerData; import noppes.npcs.constants.EnumPlayerData;
import noppes.npcs.constants.EnumRoleType; import noppes.npcs.constants.EnumRoleType;
import noppes.npcs.containers.ContainerManageBanks; import noppes.npcs.containers.ContainerManageBanks;
import noppes.npcs.containers.ContainerManageRecipes; import noppes.npcs.containers.ContainerManageRecipes;
import noppes.npcs.controllers.data.Bank; import noppes.npcs.controllers.*;
import noppes.npcs.controllers.BankController; import noppes.npcs.controllers.data.*;
import noppes.npcs.controllers.data.Dialog;
import noppes.npcs.controllers.data.DialogCategory;
import noppes.npcs.controllers.DialogController;
import noppes.npcs.controllers.data.DialogOption;
import noppes.npcs.controllers.data.Faction;
import noppes.npcs.controllers.FactionController;
import noppes.npcs.controllers.data.PlayerBankData;
import noppes.npcs.controllers.data.PlayerData;
import noppes.npcs.controllers.PlayerDataController;
import noppes.npcs.controllers.data.PlayerDialogData;
import noppes.npcs.controllers.data.PlayerFactionData;
import noppes.npcs.controllers.PlayerQuestController;
import noppes.npcs.controllers.data.PlayerQuestData;
import noppes.npcs.controllers.data.PlayerTransportData;
import noppes.npcs.controllers.data.Quest;
import noppes.npcs.controllers.data.QuestCategory;
import noppes.npcs.controllers.QuestController;
import noppes.npcs.controllers.data.RecipeCarpentry;
import noppes.npcs.controllers.RecipeController;
import noppes.npcs.controllers.ServerCloneController;
import noppes.npcs.controllers.data.TransportCategory;
import noppes.npcs.controllers.TransportController;
import noppes.npcs.controllers.data.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.NpcAPI; import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.scripted.ScriptSound; import noppes.npcs.scripted.ScriptSound;
import noppes.npcs.scripted.event.DialogEvent; import noppes.npcs.scripted.event.DialogEvent;
import noppes.npcs.api.entity.IPlayer;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.IOException;
import java.text.DecimalFormat;
import java.util.*;
import java.util.zip.GZIPOutputStream;
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>();
@@ -82,7 +55,7 @@ public class NoppesUtilServer {
PlayerData data = PlayerDataController.instance.getPlayerData(player); PlayerData data = PlayerDataController.instance.getPlayerData(player);
data.editingNpc = npc; data.editingNpc = npc;
if(npc != null) if(npc != null)
Server.sendData((EntityPlayerMP)player, EnumPacketClient.EDIT_NPC, npc.getEntityId()); Server.sendDataChecked((EntityPlayerMP)player, EnumPacketClient.EDIT_NPC, npc.getEntityId());
} }
public static EntityNPCInterface getEditingNpc(EntityPlayer player){ public static EntityNPCInterface getEditingNpc(EntityPlayer player){
PlayerData data = PlayerDataController.instance.getPlayerData(player); PlayerData data = PlayerDataController.instance.getPlayerData(player);
@@ -113,6 +86,14 @@ public class NoppesUtilServer {
} }
sendScrollData(player, map); sendScrollData(player, map);
} }
public static void sendTagDataAll(EntityPlayerMP player) {
Map<String,Integer> map = new HashMap<String,Integer>();
for(Tag tag : TagController.getInstance().tags.values()){
map.put(tag.name, tag.id);
}
sendScrollData(player, map);
}
public static void sendBankDataAll(EntityPlayerMP player) { public static void sendBankDataAll(EntityPlayerMP player) {
Map<String,Integer> map = new HashMap<String,Integer>(); Map<String,Integer> map = new HashMap<String,Integer>();
@@ -191,7 +172,7 @@ public class NoppesUtilServer {
} }
} }
if(npc instanceof EntityDialogNpc){ if(npc instanceof EntityDialogNpc || dia.id < 0){
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()));
} }
@@ -199,7 +180,7 @@ public class NoppesUtilServer {
Server.sendData((EntityPlayerMP)player, EnumPacketClient.DIALOG, npc.getEntityId(), dialog.writeToNBT(new NBTTagCompound())); Server.sendData((EntityPlayerMP)player, EnumPacketClient.DIALOG, npc.getEntityId(), dialog.writeToNBT(new NBTTagCompound()));
dia.factionOptions.addPoints(player); dia.factionOptions.addPoints(player);
if(dialog.hasQuest()) if(dialog.hasQuest())
PlayerQuestController.addActiveQuest(dialog.getQuest(),player); PlayerQuestController.addActiveQuest(new QuestData(dialog.getQuest()),player);
if(!dialog.command.isEmpty()){ if(!dialog.command.isEmpty()){
runCommand(player, npc.getCommandSenderName(), dialog.command); runCommand(player, npc.getCommandSenderName(), dialog.command);
} }
@@ -260,19 +241,48 @@ public class NoppesUtilServer {
EnumGuiType gui, EntityNPCInterface npc) { EnumGuiType gui, EntityNPCInterface npc) {
sendOpenGui(player, gui, npc, 0, 0, 0); sendOpenGui(player, gui, npc, 0, 0, 0);
} }
public static void sendOpenGui(EntityPlayer player,
EnumGuiType gui, EntityNPCInterface npc, int i, int j, int k) { public static void sendOpenGuiNoDelay(EntityPlayer player,
EnumGuiType gui, EntityNPCInterface npc) {
sendOpenGuiNoDelay(player, gui, npc, 0, 0, 0);
}
public static void sendOpenGui(final EntityPlayer player,
final EnumGuiType gui, final EntityNPCInterface npc, final int i, final int j, final int k) {
if(!(player instanceof EntityPlayerMP)) if(!(player instanceof EntityPlayerMP))
return; return;
setEditingNpc(player, npc); setEditingNpc(player, npc);
sendExtraData(player, npc,gui, i, j, k); sendExtraData(player, npc,gui, i, j, k);
if(CustomNpcs.proxy.getServerGuiElement(gui.ordinal(), player, player.worldObj, i, j, k) != null){ if(CustomNpcs.proxy.getServerGuiElement(gui.ordinal(), player, player.worldObj, i, j, k) != null){
player.openGui(CustomNpcs.instance, gui.ordinal(), player.worldObj, i, j, k); player.openGui(CustomNpcs.instance, gui.ordinal(), player.worldObj, i, j, k);
return; return;
} }
else{ else{
Server.sendData((EntityPlayerMP)player, EnumPacketClient.GUI, gui.ordinal(), i, j, k); Server.sendDataChecked((EntityPlayerMP)player, EnumPacketClient.GUI, gui.ordinal(), i, j, k);
}
ArrayList<String> list = getScrollData(player, gui, npc);
if(list == null || list.isEmpty())
return;
Server.sendData((EntityPlayerMP)player, EnumPacketClient.SCROLL_LIST, list);
}
public static void sendOpenGuiNoDelay(final EntityPlayer player,
final EnumGuiType gui, final EntityNPCInterface npc, final int i, final int j, final int k) {
if(!(player instanceof EntityPlayerMP))
return;
setEditingNpc(player, npc);
sendExtraData(player, npc,gui, i, j, k);
if(CustomNpcs.proxy.getServerGuiElement(gui.ordinal(), player, player.worldObj, i, j, k) != null){
player.openGui(CustomNpcs.instance, gui.ordinal(), player.worldObj, i, j, k);
return;
}
else{
Server.sendDataChecked((EntityPlayerMP)player, EnumPacketClient.GUI, gui.ordinal(), i, j, k);
} }
ArrayList<String> list = getScrollData(player, gui, npc); ArrayList<String> list = getScrollData(player, gui, npc);
if(list == null || list.isEmpty()) if(list == null || list.isEmpty())
@@ -333,6 +343,13 @@ public class NoppesUtilServer {
} }
} }
public static void playSound(ScriptSound sound) {
List<EntityPlayer> list = MinecraftServer.getServer().getConfigurationManager().playerEntityList;
for (EntityPlayer player : list) {
NoppesUtilPlayer.playSoundTo((EntityPlayerMP) player, sound);
}
}
public static void stopSound(int id) { public static void stopSound(int id) {
List<EntityPlayer> list = MinecraftServer.getServer().getConfigurationManager().playerEntityList; List<EntityPlayer> list = MinecraftServer.getServer().getConfigurationManager().playerEntityList;
for (EntityPlayer player : list) { for (EntityPlayer player : list) {
@@ -393,10 +410,12 @@ public class NoppesUtilServer {
Map<String,Integer> map = new HashMap<String,Integer>(); Map<String,Integer> map = new HashMap<String,Integer>();
if(type == EnumPlayerData.Players){ if(type == EnumPlayerData.Players){
File loc = PlayerDataController.instance.getSaveDir(); for(String username : PlayerDataController.instance.nameUUIDs.keySet()){
for(String username : PlayerDataController.instance.getUsernameData().keySet()){ map.put(username, 0);
map.put(username, 0); }
} for(String username : MinecraftServer.getServer().getConfigurationManager().getAllUsernames()){
map.put(username, 0);
}
} }
else{ else{
PlayerData playerdata = PlayerDataController.instance.getDataFromUsername(name); PlayerData playerdata = PlayerDataController.instance.getDataFromUsername(name);
@@ -480,39 +499,47 @@ public class NoppesUtilServer {
if(pl != null){ if(pl != null){
playerdata.setNBT(new NBTTagCompound()); playerdata.setNBT(new NBTTagCompound());
sendPlayerData(type, player, name); sendPlayerData(type, player, name);
playerdata.savePlayerDataOnFile(); playerdata.save();
return; return;
} }
else {
PlayerDataController.instance.nameUUIDs.remove(name);
PlayerDataController.instance.savePlayerDataMap();
}
} }
if(type == EnumPlayerData.Quest){ if(type == EnumPlayerData.Quest){
PlayerQuestData data = playerdata.questData; PlayerQuestData data = playerdata.questData;
int questId = buffer.readInt(); int questId = buffer.readInt();
data.activeQuests.remove(questId); data.activeQuests.remove(questId);
data.finishedQuests.remove(questId); data.finishedQuests.remove(questId);
playerdata.savePlayerDataOnFile(); playerdata.save();
} }
if(type == EnumPlayerData.Dialog){ if(type == EnumPlayerData.Dialog){
PlayerDialogData data = playerdata.dialogData; PlayerDialogData data = playerdata.dialogData;
data.dialogsRead.remove(buffer.readInt()); data.dialogsRead.remove(buffer.readInt());
playerdata.savePlayerDataOnFile(); playerdata.save();
} }
if(type == EnumPlayerData.Transport){ if(type == EnumPlayerData.Transport){
PlayerTransportData data = playerdata.transportData; PlayerTransportData data = playerdata.transportData;
data.transports.remove(buffer.readInt()); data.transports.remove(buffer.readInt());
playerdata.savePlayerDataOnFile(); playerdata.save();
} }
if(type == EnumPlayerData.Bank){ if(type == EnumPlayerData.Bank){
PlayerBankData data = playerdata.bankData; PlayerBankData data = playerdata.bankData;
data.banks.remove(buffer.readInt()); data.banks.remove(buffer.readInt());
playerdata.savePlayerDataOnFile(); playerdata.save();
} }
if(type == EnumPlayerData.Factions){ if(type == EnumPlayerData.Factions){
PlayerFactionData data = playerdata.factionData; PlayerFactionData data = playerdata.factionData;
data.factionData.remove(buffer.readInt()); data.factionData.remove(buffer.readInt());
playerdata.savePlayerDataOnFile(); playerdata.save();
} }
sendPlayerData(type, player, name); sendPlayerData(type, player, name);
} }
public static void regenPlayerData(EntityPlayerMP player) throws IOException {
PlayerDataController.instance.generatePlayerMap(player);
}
public static void sendRecipeData(EntityPlayerMP player, int size) { public static void sendRecipeData(EntityPlayerMP player, int size) {
HashMap<String,Integer> map = new HashMap<String,Integer>(); HashMap<String,Integer> map = new HashMap<String,Integer>();
@@ -672,7 +699,7 @@ public class NoppesUtilServer {
} }
Server.sendData(player, EnumPacketClient.GUI_CLOSE, i, comp); Server.sendData(player, EnumPacketClient.GUI_CLOSE, i, comp);
} }
public static Entity spawnCloneWithProtection(NBTTagCompound compound, int x, int y, public static Entity spawnCloneWithProtection(NBTTagCompound compound, int x, int y,
int z, World worldObj) { int z, World worldObj) {
ServerCloneController.Instance.cleanTags(compound); ServerCloneController.Instance.cleanTags(compound);
@@ -716,8 +743,19 @@ public class NoppesUtilServer {
if(entity == null){ if(entity == null){
return null; return null;
} }
worldObj.spawnEntityInWorld(entity); int i = MathHelper.floor_double(entity.posX / 16.0D);
return entity; int j = MathHelper.floor_double(entity.posZ / 16.0D);
if (!entity.forceSpawn && !worldObj.checkChunksExist(
(int)entity.posX,(int)entity.posY,(int)entity.posZ,(int)entity.posX,(int)entity.posY,(int)entity.posZ
))
{
return null;
} else {
worldObj.getChunkFromChunkCoords(i, j).addEntity(entity);
worldObj.loadedEntityList.add(entity);
worldObj.onEntityAdded(entity);
return entity;
}
} }
public static boolean isOp(EntityPlayer player) { public static boolean isOp(EntityPlayer player) {
@@ -784,4 +822,27 @@ public class NoppesUtilServer {
public static boolean IsItemStackNull(ItemStack is) { public static boolean IsItemStackNull(ItemStack is) {
return is == null || is.stackSize == 0 || is.getItem() == null; return is == null || is.stackSize == 0 || is.getItem() == null;
} }
public static String millisToTime(long millis) {
long seconds = millis / 1000;
long minutes = seconds / 60;
long hours = minutes / 60;
long days = hours / 24;
seconds %= 60;
minutes %= 60;
hours %= 24;
StringBuilder sb = new StringBuilder();
if (days > 0) {
sb.append(days).append(" day").append(days == 1 ? "" : "s").append(", ");
}
if (hours > 0) {
sb.append(hours).append(" hour").append(hours == 1 ? "" : "s").append(", ");
}
if (minutes > 0) {
sb.append(minutes).append(" minute").append(minutes == 1 ? "" : "s").append(", ");
}
sb.append(seconds).append(" second").append(seconds == 1 ? "" : "s");
return sb.toString();
}
} }
@@ -1,12 +1,12 @@
package noppes.npcs; package noppes.npcs;
import java.util.HashMap;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory; import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import java.util.HashMap;
public class NpcMiscInventory implements IInventory { public class NpcMiscInventory implements IInventory {
public HashMap<Integer,ItemStack> items = new HashMap<Integer,ItemStack>(); public HashMap<Integer,ItemStack> items = new HashMap<Integer,ItemStack>();
public int stackLimit = 64; public int stackLimit = 64;
@@ -1,10 +1,8 @@
package noppes.npcs; package noppes.npcs;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.network.FMLNetworkEvent.ServerCustomPacketEvent;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import java.io.IOException;
import java.util.Iterator;
import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.Items; import net.minecraft.init.Items;
import net.minecraft.item.ItemEditableBook; import net.minecraft.item.ItemEditableBook;
@@ -18,12 +16,15 @@ import noppes.npcs.blocks.tiles.TileBigSign;
import noppes.npcs.blocks.tiles.TileBook; import noppes.npcs.blocks.tiles.TileBook;
import noppes.npcs.constants.*; import noppes.npcs.constants.*;
import noppes.npcs.containers.ContainerMail; import noppes.npcs.containers.ContainerMail;
import noppes.npcs.controllers.*; import noppes.npcs.controllers.PlayerDataController;
import noppes.npcs.controllers.PlayerQuestController;
import noppes.npcs.controllers.ScriptController;
import noppes.npcs.controllers.data.*; import noppes.npcs.controllers.data.*;
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.network.FMLNetworkEvent.ServerCustomPacketEvent; import java.io.IOException;
import java.util.Iterator;
public class PacketHandlerPlayer{ public class PacketHandlerPlayer{
@@ -189,9 +190,6 @@ public class PacketHandlerPlayer{
else if(type == EnumPlayerPacket.QuestLog){ else if(type == EnumPlayerPacket.QuestLog){
NoppesUtilPlayer.sendQuestLogData(player); NoppesUtilPlayer.sendQuestLogData(player);
} }
else if(type == EnumPlayerPacket.QuestCompletion){
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;
Server.sendData(player, EnumPacketClient.GUI_DATA, data.getPlayerGuiData()); Server.sendData(player, EnumPacketClient.GUI_DATA, data.getPlayerGuiData());
@@ -269,7 +267,7 @@ public class PacketHandlerPlayer{
if(mail.time == time && mail.sender.equals(username)){ if(mail.time == time && mail.sender.equals(username)){
mail.beenRead = true; mail.beenRead = true;
if(mail.hasQuest()) if(mail.hasQuest())
PlayerQuestController.addActiveQuest(mail.getQuest(), player); PlayerQuestController.addActiveQuest(new QuestData(mail.getQuest()), player);
} }
} }
} }
+278 -112
View File
@@ -1,16 +1,12 @@
package noppes.npcs; package noppes.npcs;
import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.network.FMLNetworkEvent.ServerCustomPacketEvent;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import foxz.utils.Market; import foxz.utils.Market;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import net.minecraft.command.ICommandSender;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Set;
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;
@@ -31,13 +27,12 @@ import net.minecraft.village.MerchantRecipeList;
import net.minecraft.world.WorldProvider; import net.minecraft.world.WorldProvider;
import net.minecraft.world.WorldServer; import net.minecraft.world.WorldServer;
import net.minecraftforge.common.DimensionManager; import net.minecraftforge.common.DimensionManager;
import noppes.npcs.constants.EnumCompanionStage; import noppes.npcs.api.entity.IPlayer;
import noppes.npcs.constants.EnumGuiType; import noppes.npcs.api.handler.data.ITag;
import noppes.npcs.constants.EnumJobType; import noppes.npcs.config.ConfigDebug;
import noppes.npcs.constants.EnumPacketClient; import noppes.npcs.config.ConfigMain;
import noppes.npcs.constants.EnumPacketServer; import noppes.npcs.config.ConfigScript;
import noppes.npcs.constants.EnumPlayerData; import noppes.npcs.constants.*;
import noppes.npcs.constants.EnumRoleType;
import noppes.npcs.containers.ContainerCustomGui; import noppes.npcs.containers.ContainerCustomGui;
import noppes.npcs.containers.ContainerMail; import noppes.npcs.containers.ContainerMail;
import noppes.npcs.controllers.*; import noppes.npcs.controllers.*;
@@ -49,19 +44,19 @@ import noppes.npcs.roles.JobSpawner;
import noppes.npcs.roles.RoleCompanion; import noppes.npcs.roles.RoleCompanion;
import noppes.npcs.roles.RoleTrader; 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.network.FMLNetworkEvent.ServerCustomPacketEvent;
import noppes.npcs.scripted.NpcAPI; import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.scripted.gui.ScriptGui; import noppes.npcs.scripted.gui.ScriptGui;
import noppes.npcs.api.entity.IPlayer;
import noppes.npcs.scripted.item.ScriptCustomItem; import noppes.npcs.scripted.item.ScriptCustomItem;
import java.io.IOException;
import java.util.*;
public class PacketHandlerServer{ public class PacketHandlerServer{
@SubscribeEvent @SubscribeEvent
public void onServerPacket(ServerCustomPacketEvent event) { public void onServerPacket(ServerCustomPacketEvent event) {
EntityPlayerMP player = ((NetHandlerPlayServer)event.handler).playerEntity; EntityPlayerMP player = ((NetHandlerPlayServer)event.handler).playerEntity;
if(CustomNpcs.OpsOnly && !NoppesUtilServer.isOp(player)){ if(ConfigMain.OpsOnly && !NoppesUtilServer.isOp(player)){
warn(player, "tried to use custom npcs without being an op"); warn(player, "tried to use custom npcs without being an op");
return; return;
} }
@@ -81,10 +76,6 @@ public class PacketHandlerServer{
((ContainerCustomGui) player.openContainer).customGui.fromNBT(Server.readNBT(buffer)); ((ContainerCustomGui) player.openContainer).customGui.fromNBT(Server.readNBT(buffer));
EventHooks.onCustomGuiButton((IPlayer) NpcAPI.Instance().getIEntity(player), ((ContainerCustomGui) player.openContainer).customGui, buffer.readInt()); EventHooks.onCustomGuiButton((IPlayer) NpcAPI.Instance().getIEntity(player), ((ContainerCustomGui) player.openContainer).customGui, buffer.readInt());
return; return;
} else if (type == EnumPacketServer.CustomGuiSlotChange && player.openContainer instanceof ContainerCustomGui) {
((ContainerCustomGui) player.openContainer).customGui.fromNBT(Server.readNBT(buffer));
EventHooks.onCustomGuiSlot((IPlayer) NpcAPI.Instance().getIEntity(player), ((ContainerCustomGui) player.openContainer).customGui, buffer.readInt());
return;
} else if (type == EnumPacketServer.CustomGuiUnfocused && player.openContainer instanceof ContainerCustomGui) { } else if (type == EnumPacketServer.CustomGuiUnfocused && player.openContainer instanceof ContainerCustomGui) {
((ContainerCustomGui) player.openContainer).customGui.fromNBT(Server.readNBT(buffer)); ((ContainerCustomGui) player.openContainer).customGui.fromNBT(Server.readNBT(buffer));
EventHooks.onCustomGuiUnfocused((IPlayer) NpcAPI.Instance().getIEntity(player), ((ContainerCustomGui) player.openContainer).customGui, buffer.readInt()); EventHooks.onCustomGuiUnfocused((IPlayer) NpcAPI.Instance().getIEntity(player), ((ContainerCustomGui) player.openContainer).customGui, buffer.readInt());
@@ -96,9 +87,29 @@ public class PacketHandlerServer{
} else if (type == EnumPacketServer.CustomGuiClose) { } else if (type == EnumPacketServer.CustomGuiClose) {
EventHooks.onCustomGuiClose((IPlayer) NpcAPI.Instance().getIEntity(player), (new ScriptGui()).fromNBT(Server.readNBT(buffer))); EventHooks.onCustomGuiClose((IPlayer) NpcAPI.Instance().getIEntity(player), (new ScriptGui()).fromNBT(Server.readNBT(buffer)));
return; return;
} else if (type == EnumPacketServer.UpdateTrackedQuest) { } else if (type == EnumPacketServer.QuestLogToServer) {
updateTrackedQuest(buffer, player); NoppesUtilPlayer.updateQuestLogData(buffer, player);
return; return;
} else if(type == EnumPacketServer.DimensionsGet){
HashMap<String,Integer> map = new HashMap<String,Integer>();
for(int id : DimensionManager.getStaticDimensionIDs()){
WorldProvider provider = DimensionManager.createProviderFor(id);
map.put(provider.getDimensionName(), id);
}
NoppesUtilServer.sendScrollData(player, map);
} else if(type == EnumPacketServer.TagsGet){
NoppesUtilServer.sendTagDataAll(player);
} else if (type == EnumPacketServer.NpcTagsGet) {
NBTTagCompound compound = new NBTTagCompound();
NBTTagList tagList = new NBTTagList();
for (UUID uuid : npc.advanced.tagUUIDs) {
Tag tag = TagController.getInstance().getTagFromUUID(uuid);
if (tag != null) {
tagList.appendTag(new NBTTagString(tag.name));
}
}
compound.setTag("TagNames",tagList);
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
} }
if(type.needsNpc && npc == null){ if(type.needsNpc && npc == null){
@@ -107,7 +118,7 @@ public class PacketHandlerServer{
else if(type.hasPermission() && !CustomNpcsPermissions.hasPermission(player, type.permission)){ else if(type.hasPermission() && !CustomNpcsPermissions.hasPermission(player, type.permission)){
//player doesnt have permission to do this //player doesnt have permission to do this
} }
else if(item == null && (type == EnumPacketServer.ScriptPlayerGet || type == EnumPacketServer.ScriptPlayerSave || type == EnumPacketServer.ScriptNPCGet || type == EnumPacketServer.ScriptNPCSave || type == EnumPacketServer.ScriptForgeGet || type == EnumPacketServer.ScriptForgeSave)) else if(item == null && (type == EnumPacketServer.ScriptPlayerGet || type == EnumPacketServer.ScriptPlayerSave || type == EnumPacketServer.ScriptGlobalNPCGet || type == EnumPacketServer.ScriptGlobalNPCSave || type == EnumPacketServer.ScriptForgeGet || type == EnumPacketServer.ScriptForgeSave))
warn(player, "tried to use custom npcs without a tool in hand, probably a hacker"); warn(player, "tried to use custom npcs without a tool in hand, probably a hacker");
else { else {
if (item != null) { if (item != null) {
@@ -123,11 +134,13 @@ public class PacketHandlerServer{
featherPackets(type, buffer, player); 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 (item.getItem() == Item.getItemFromBlock(CustomItems.waypoint) || item.getItem() == Item.getItemFromBlock(CustomItems.border) || item.getItem() == Item.getItemFromBlock(CustomItems.redstoneBlock))
blockPackets(type, buffer, player); blockPackets(type, buffer, player);
else if (CustomNpcs.isScriptDev(player)) { else if (ConfigScript.isScriptDev(player)) {
if (type == EnumPacketServer.ScriptPlayerGet || type == EnumPacketServer.ScriptPlayerSave) if (type == EnumPacketServer.EventScriptDataGet || type == EnumPacketServer.EventScriptDataSave)
npcEventScriptPackets(type, buffer, player, npc);
else if (type == EnumPacketServer.ScriptPlayerGet || type == EnumPacketServer.ScriptPlayerSave)
playerScriptPackets(type, buffer, player); playerScriptPackets(type, buffer, player);
else if (type == EnumPacketServer.ScriptNPCGet || type == EnumPacketServer.ScriptNPCSave) else if (type == EnumPacketServer.ScriptGlobalNPCGet || type == EnumPacketServer.ScriptGlobalNPCSave)
npcScriptPackets(type, buffer, player); npcGlobalScriptPackets(type, buffer, player);
else if (type == EnumPacketServer.ScriptForgeGet || type == EnumPacketServer.ScriptForgeSave) else if (type == EnumPacketServer.ScriptForgeGet || type == EnumPacketServer.ScriptForgeSave)
forgeScriptPackets(type, buffer, player); forgeScriptPackets(type, buffer, player);
else if (type == EnumPacketServer.ScriptItemDataGet || type == EnumPacketServer.ScriptItemDataSave) else if (type == EnumPacketServer.ScriptItemDataGet || type == EnumPacketServer.ScriptItemDataSave)
@@ -144,33 +157,6 @@ public class PacketHandlerServer{
} }
} }
private void updateTrackedQuest(ByteBuf buffer, EntityPlayerMP player) {
String trackedQuestString = Server.readString(buffer);
if (trackedQuestString != null && trackedQuestString.contains(":")) {
String[] splitString = trackedQuestString.split(":");
if(splitString.length < 2){
return;
}
String categoryName = splitString[0];
String questName = splitString[1];
for (QuestCategory category : QuestController.instance.categories.values()) {
if (category.title.equals(categoryName)) {
for (Quest quest : category.quests.values()) {
if (quest.title.equals(questName)) {
PlayerDataController.instance.getPlayerData(player).questData.trackedQuest = quest;
NoppesUtilPlayer.sendTrackedQuestData(player, quest);
return;
}
}
}
}
}
PlayerDataController.instance.getPlayerData(player).questData.trackedQuest = null;
Server.sendData(player, EnumPacketClient.OVERLAY_QUEST_TRACKING);
}
private void isGuiOpenPacket(ByteBuf buffer, EntityPlayerMP player) throws IOException { private void isGuiOpenPacket(ByteBuf buffer, EntityPlayerMP player) throws IOException {
NoppesUtilServer.isGUIOpen(buffer, player); NoppesUtilServer.isGUIOpen(buffer, player);
} }
@@ -178,18 +164,18 @@ public class PacketHandlerServer{
private void getScriptsEnabled(EnumPacketServer type, ByteBuf buffer, EntityPlayerMP player) throws IOException { private void getScriptsEnabled(EnumPacketServer type, ByteBuf buffer, EntityPlayerMP player) throws IOException {
if (type == EnumPacketServer.ScriptGlobalGuiDataGet) { if (type == EnumPacketServer.ScriptGlobalGuiDataGet) {
NBTTagCompound compound = new NBTTagCompound(); NBTTagCompound compound = new NBTTagCompound();
compound.setBoolean("ScriptsEnabled", CustomNpcs.ScriptingEnabled); compound.setBoolean("ScriptsEnabled", ConfigScript.ScriptingEnabled);
compound.setBoolean("PlayerScriptsEnabled", CustomNpcs.GlobalPlayerScripts); compound.setBoolean("PlayerScriptsEnabled", ConfigScript.GlobalPlayerScripts);
compound.setBoolean("GlobalNPCScriptsEnabled", CustomNpcs.GlobalNPCScripts); compound.setBoolean("GlobalNPCScriptsEnabled", ConfigScript.GlobalNPCScripts);
compound.setBoolean("ForgeScriptsEnabled", CustomNpcs.GlobalForgeScripts); compound.setBoolean("ForgeScriptsEnabled", ConfigScript.GlobalForgeScripts);
Server.sendData(player, EnumPacketClient.GUI_DATA, compound); Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
} }
else if (type == EnumPacketServer.ScriptGlobalGuiDataSave) { else if (type == EnumPacketServer.ScriptGlobalGuiDataSave) {
NBTTagCompound compound = Server.readNBT(buffer); NBTTagCompound compound = Server.readNBT(buffer);
CustomNpcs.ScriptingEnabled = compound.getBoolean("ScriptsEnabled"); ConfigScript.ScriptingEnabled = compound.getBoolean("ScriptsEnabled");
CustomNpcs.GlobalPlayerScripts = compound.getBoolean("PlayerScriptsEnabled"); ConfigScript.GlobalPlayerScripts = compound.getBoolean("PlayerScriptsEnabled");
CustomNpcs.GlobalNPCScripts = compound.getBoolean("GlobalNPCScriptsEnabled"); ConfigScript.GlobalNPCScripts = compound.getBoolean("GlobalNPCScriptsEnabled");
CustomNpcs.GlobalForgeScripts = compound.getBoolean("ForgeScriptsEnabled"); ConfigScript.GlobalForgeScripts = compound.getBoolean("ForgeScriptsEnabled");
} }
} }
@@ -198,7 +184,7 @@ public class PacketHandlerServer{
npc.script.readFromNBT(Server.readNBT(buffer)); npc.script.readFromNBT(Server.readNBT(buffer));
npc.updateAI = true; npc.updateAI = true;
npc.script.hasInited = false; npc.script.hasInited = false;
if(CustomNpcs.PlayerLogging && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER){ if(ConfigDebug.PlayerLogging && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER){
LogWriter.script(String.format("[%s] (Player) %s SAVED NPC %s (%s, %s, %s) [%s]", "SCRIPTER", player.getCommandSenderName(), npc.display.getName(), (int)npc.posX, (int)(npc).posY, (int)npc.posZ, npc.worldObj.getWorldInfo().getWorldName())); LogWriter.script(String.format("[%s] (Player) %s SAVED NPC %s (%s, %s, %s) [%s]", "SCRIPTER", player.getCommandSenderName(), npc.display.getName(), (int)npc.posX, (int)(npc).posY, (int)npc.posZ, npc.worldObj.getWorldInfo().getWorldName()));
} }
} }
@@ -209,48 +195,106 @@ public class PacketHandlerServer{
} }
} }
private void getScripts(IScriptHandler data, ByteBuf buffer, EntityPlayerMP player) {
NBTTagCompound compound = new NBTTagCompound();
compound.setBoolean("ScriptEnabled", data.getEnabled());
compound.setString("ScriptLanguage", data.getLanguage());
compound.setTag("Languages", ScriptController.Instance.nbtLanguages());
compound.setTag("ScriptConsole", NBTTags.NBTLongStringMap(data.getConsoleText()));
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
List<ScriptContainer> containers = data.getScripts();
for (int i = 0; i < containers.size(); i++) {
ScriptContainer container = containers.get(i);
NBTTagCompound tabCompound = new NBTTagCompound();
tabCompound.setInteger("Tab",i);
tabCompound.setTag("Script",container.writeToNBT(new NBTTagCompound()));
tabCompound.setInteger("TotalScripts",containers.size());
Server.sendData(player, EnumPacketClient.GUI_DATA, tabCompound);
}
}
private void saveScripts(IScriptHandler data, ByteBuf buffer, EntityPlayerMP player) throws Exception {
int tab = buffer.readInt();
int totalScripts = buffer.readInt();
if (totalScripts == 0) {
data.getScripts().clear();
}
if (tab >= 0) {
if (data.getScripts().size() > totalScripts) {
data.setScripts(data.getScripts().subList(0,totalScripts));
} else while (data.getScripts().size() < totalScripts) {
data.getScripts().add(new ScriptContainer(data));
}
NBTTagCompound tabCompound = Server.readNBT(buffer);
ScriptContainer script = new ScriptContainer(data);
script.readFromNBT(tabCompound);
data.getScripts().set(tab,script);
} else {
NBTTagCompound compound = Server.readNBT(buffer);
data.setLanguage(compound.getString("ScriptLanguage"));
if (!ScriptController.Instance.languages.containsKey(data.getLanguage())) {
if (!ScriptController.Instance.languages.isEmpty()) {
data.setLanguage((String) ScriptController.Instance.languages.keySet().toArray()[0]);
} else {
data.setLanguage("ECMAScript");
}
}
data.setEnabled(compound.getBoolean("ScriptEnabled"));
for (ScriptContainer container : data.getScripts()) {
container.setEngine(data.getLanguage());
}
}
}
private void npcEventScriptPackets(EnumPacketServer type, ByteBuf buffer, EntityPlayerMP player, EntityNPCInterface npc) throws Exception {
DataScript data = npc.script;
if(type == EnumPacketServer.EventScriptDataGet) {
this.getScripts(data,buffer,player);
} else if(type == EnumPacketServer.EventScriptDataSave) {
this.saveScripts(data,buffer,player);
npc.updateAI = true;
npc.script.hasInited = false;
if(ConfigDebug.PlayerLogging && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER){
LogWriter.script(String.format("[%s] (Player) %s SAVED NPC %s (%s, %s, %s) [%s]", "SCRIPTER", player.getCommandSenderName(), npc.display.getName(), (int)npc.posX, (int)(npc).posY, (int)npc.posZ, npc.worldObj.getWorldInfo().getWorldName()));
}
}
}
private void playerScriptPackets(EnumPacketServer type, ByteBuf buffer, EntityPlayerMP player) throws Exception { private void playerScriptPackets(EnumPacketServer type, ByteBuf buffer, EntityPlayerMP player) throws Exception {
NBTTagCompound compound; PlayerDataScript data = ScriptController.Instance.playerScripts;
if(type == EnumPacketServer.ScriptPlayerGet) { if(type == EnumPacketServer.ScriptPlayerGet) {
PlayerDataScript data = ScriptController.Instance.playerScripts; this.getScripts(data,buffer,player);
compound = data.writeToNBT(new NBTTagCompound());
compound.setBoolean("ScriptEnabled", ScriptController.Instance.playerScripts.getEnabled());
compound.setTag("Languages", ScriptController.Instance.nbtLanguages());
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
} else if(type == EnumPacketServer.ScriptPlayerSave) { } else if(type == EnumPacketServer.ScriptPlayerSave) {
ScriptController.Instance.setPlayerScripts(Server.readNBT(buffer)); this.saveScripts(data,buffer,player);
ScriptController.Instance.lastPlayerUpdate = System.currentTimeMillis();
} }
} }
private void forgeScriptPackets(EnumPacketServer type, ByteBuf buffer, EntityPlayerMP player) throws Exception { private void forgeScriptPackets(EnumPacketServer type, ByteBuf buffer, EntityPlayerMP player) throws Exception {
NBTTagCompound compound; ForgeDataScript data = ScriptController.Instance.forgeScripts;
if (type == EnumPacketServer.ScriptForgeGet) { if (type == EnumPacketServer.ScriptForgeGet) {
ForgeDataScript data = ScriptController.Instance.forgeScripts; this.getScripts(data,buffer,player);
compound = data.writeToNBT(new NBTTagCompound());
compound.setBoolean("ScriptEnabled", ScriptController.Instance.forgeScripts.getEnabled());
compound.setTag("Languages", ScriptController.Instance.nbtLanguages());
Server.sendData(player, EnumPacketClient.GUI_DATA, new Object[]{compound});
} else if (type == EnumPacketServer.ScriptForgeSave) { } else if (type == EnumPacketServer.ScriptForgeSave) {
ScriptController.Instance.setForgeScripts(Server.readNBT(buffer)); this.saveScripts(data,buffer,player);
ScriptController.Instance.lastForgeUpdate = System.currentTimeMillis();
} }
} }
private void npcScriptPackets(EnumPacketServer type, ByteBuf buffer, EntityPlayerMP player) throws Exception { private void npcGlobalScriptPackets(EnumPacketServer type, ByteBuf buffer, EntityPlayerMP player) throws Exception {
NBTTagCompound compound; GlobalNPCDataScript data = ScriptController.Instance.globalNpcScripts;
if(type == EnumPacketServer.ScriptNPCGet) { if(type == EnumPacketServer.ScriptGlobalNPCGet) {
NPCDataScript data = ScriptController.Instance.npcScripts; this.getScripts(data,buffer,player);
compound = data.writeToNBT(new NBTTagCompound()); } else if(type == EnumPacketServer.ScriptGlobalNPCSave) {
compound.setBoolean("ScriptEnabled", ScriptController.Instance.npcScripts.getEnabled()); this.saveScripts(data,buffer,player);
compound.setTag("Languages", ScriptController.Instance.nbtLanguages()); ScriptController.Instance.lastGlobalNpcUpdate = System.currentTimeMillis();
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
} else if(type == EnumPacketServer.ScriptNPCSave) {
ScriptController.Instance.setNPCScripts(Server.readNBT(buffer));
} }
} }
private void itemScriptPackets(EnumPacketServer type, ByteBuf buffer, EntityPlayerMP player) throws Exception { private void itemScriptPackets(EnumPacketServer type, ByteBuf buffer, EntityPlayerMP player) throws Exception {
if (type == EnumPacketServer.ScriptItemDataGet) { if (type == EnumPacketServer.ScriptItemDataGet) {
ScriptCustomItem iw = (ScriptCustomItem) NpcAPI.Instance().getIItemStack(player.getHeldItem()); ScriptCustomItem iw = (ScriptCustomItem) NpcAPI.Instance().getIItemStack(player.getHeldItem());
iw.loadScriptData();
NBTTagCompound compound = iw.getMCNbt(); NBTTagCompound compound = iw.getMCNbt();
compound.setTag("Languages", ScriptController.Instance.nbtLanguages()); compound.setTag("Languages", ScriptController.Instance.nbtLanguages());
Server.sendData(player, EnumPacketClient.GUI_DATA, new Object[]{compound}); Server.sendData(player, EnumPacketClient.GUI_DATA, new Object[]{compound});
@@ -262,22 +306,15 @@ public class PacketHandlerServer{
NBTTagCompound compound = Server.readNBT(buffer); NBTTagCompound compound = Server.readNBT(buffer);
ScriptCustomItem wrapper = (ScriptCustomItem) NpcAPI.Instance().getIItemStack(player.getHeldItem()); ScriptCustomItem wrapper = (ScriptCustomItem) NpcAPI.Instance().getIItemStack(player.getHeldItem());
wrapper.setMCNbt(compound); wrapper.setMCNbt(compound);
wrapper.lastInited = -1L; wrapper.loadScriptData();
wrapper.loaded = false;
wrapper.saveScriptData(); wrapper.saveScriptData();
player.sendContainerToPlayer(player.inventoryContainer); player.sendContainerToPlayer(player.inventoryContainer);
} }
} }
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.DimensionTeleport){
HashMap<String,Integer> map = new HashMap<String,Integer>();
for(int id : DimensionManager.getStaticDimensionIDs()){
WorldProvider provider = DimensionManager.createProviderFor(id);
map.put(provider.getDimensionName(), id);
}
NoppesUtilServer.sendScrollData(player, map);
}
else if(type == EnumPacketServer.DimensionTeleport){
int dimension = buffer.readInt(); int dimension = buffer.readInt();
WorldServer world = MinecraftServer.getServer().worldServerForDimension(dimension); WorldServer world = MinecraftServer.getServer().worldServerForDimension(dimension);
ChunkCoordinates coords = world.getEntrancePortalLocation(); ChunkCoordinates coords = world.getEntrancePortalLocation();
@@ -369,11 +406,17 @@ public class PacketHandlerServer{
faction.writeNBT(compound); faction.writeNBT(compound);
Server.sendData(player, EnumPacketClient.GUI_DATA, compound); Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
} }
else if(type == EnumPacketServer.TagGet){
NBTTagCompound compound = new NBTTagCompound();
Tag tag = TagController.getInstance().get(buffer.readInt());
tag.writeNBT(compound);
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
}
} }
private void wandPackets(EnumPacketServer type, ByteBuf buffer, EntityPlayerMP player, EntityNPCInterface npc) throws IOException{ private void wandPackets(EnumPacketServer type, ByteBuf buffer, EntityPlayerMP player, EntityNPCInterface npc) throws IOException{
if(type == EnumPacketServer.Delete){ if(type == EnumPacketServer.Delete){
if(CustomNpcs.PlayerLogging && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER){ if(ConfigDebug.PlayerLogging && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER){
LogWriter.script(String.format("[%s] (Player) %s DELETE NPC %s (%s, %s, %s) [%s]", "WAND", player.getCommandSenderName(), npc.display.getName(), (int)npc.posX, (int)npc.posY, (int)npc.posZ, npc.worldObj.getWorldInfo().getWorldName())); LogWriter.script(String.format("[%s] (Player) %s DELETE NPC %s (%s, %s, %s) [%s]", "WAND", player.getCommandSenderName(), npc.display.getName(), (int)npc.posX, (int)npc.posY, (int)npc.posZ, npc.worldObj.getWorldInfo().getWorldName()));
} }
npc.delete(); npc.delete();
@@ -411,7 +454,7 @@ public class PacketHandlerServer{
npc.reset(); npc.reset();
if(npc.linkedData != null) if(npc.linkedData != null)
LinkedNpcController.Instance.saveNpcData(npc); LinkedNpcController.Instance.saveNpcData(npc);
if(CustomNpcs.PlayerLogging && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER){ if(ConfigDebug.PlayerLogging && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER){
LogWriter.script(String.format("[%s] (Player) %s CLOSE NPC %s (%s, %s, %s) [%s]", "WAND", player.getCommandSenderName(), npc.display.getName(), (int)npc.posX, (int)npc.posY, (int)npc.posZ, npc.worldObj.getWorldInfo().getWorldName())); LogWriter.script(String.format("[%s] (Player) %s CLOSE NPC %s (%s, %s, %s) [%s]", "WAND", player.getCommandSenderName(), npc.display.getName(), (int)npc.posX, (int)npc.posY, (int)npc.posZ, npc.worldObj.getWorldInfo().getWorldName()));
} }
NoppesUtilServer.setEditingNpc(player, null); NoppesUtilServer.setEditingNpc(player, null);
@@ -440,7 +483,7 @@ public class PacketHandlerServer{
if(entity == null || !(entity instanceof EntityNPCInterface)) if(entity == null || !(entity instanceof EntityNPCInterface))
return; return;
NoppesUtilServer.sendOpenGui(player, EnumGuiType.MainMenuDisplay, (EntityNPCInterface) entity); NoppesUtilServer.sendOpenGui(player, EnumGuiType.MainMenuDisplay, (EntityNPCInterface) entity);
if(CustomNpcs.PlayerLogging && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER){ if(ConfigDebug.PlayerLogging && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER){
LogWriter.script(String.format("[%s] (Player) %s OPEN NPC %s (%s, %s, %s) [%s]", "WAND", player.getCommandSenderName(), ((EntityNPCInterface)entity).display.getName(), entity.posX, entity.posY, entity.posZ, entity.worldObj.getWorldInfo().getWorldName())); LogWriter.script(String.format("[%s] (Player) %s OPEN NPC %s (%s, %s, %s) [%s]", "WAND", player.getCommandSenderName(), ((EntityNPCInterface)entity).display.getName(), entity.posX, entity.posY, entity.posZ, entity.worldObj.getWorldInfo().getWorldName()));
} }
} }
@@ -449,7 +492,7 @@ public class PacketHandlerServer{
if(entity == null || !(entity instanceof EntityNPCInterface)) if(entity == null || !(entity instanceof EntityNPCInterface))
return; return;
npc = (EntityNPCInterface) entity; npc = (EntityNPCInterface) entity;
if(CustomNpcs.PlayerLogging && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER){ if(ConfigDebug.PlayerLogging && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER){
LogWriter.script(String.format("[%s] (Player) %s DELETE NPC %s (%s, %s, %s) [%s]", "WAND", player.getCommandSenderName(), npc.display.getName(), (int)npc.posX, (int)npc.posY, (int)npc.posZ, npc.worldObj.getWorldInfo().getWorldName())); LogWriter.script(String.format("[%s] (Player) %s DELETE NPC %s (%s, %s, %s) [%s]", "WAND", player.getCommandSenderName(), npc.display.getName(), (int)npc.posX, (int)npc.posY, (int)npc.posZ, npc.worldObj.getWorldInfo().getWorldName()));
} }
npc.delete(); npc.delete();
@@ -681,6 +724,25 @@ public class PacketHandlerServer{
(new Faction()).writeNBT(compound); (new Faction()).writeNBT(compound);
Server.sendData(player, EnumPacketClient.GUI_DATA, compound); Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
} }
else if(type == EnumPacketServer.TagSet){
this.setTags(npc,buffer);
}
else if(type == EnumPacketServer.TagSave){
Tag tag = new Tag();
tag.readNBT(Server.readNBT(buffer));
TagController.getInstance().saveTag(tag);
NoppesUtilServer.sendTagDataAll(player);
NBTTagCompound compound = new NBTTagCompound();
tag.writeNBT(compound);
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
}
else if(type == EnumPacketServer.TagRemove){
TagController.getInstance().delete(buffer.readInt());
NoppesUtilServer.sendTagDataAll(player);
NBTTagCompound compound = new NBTTagCompound();
(new Tag()).writeNBT(compound);
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
}
else if(type == EnumPacketServer.PlayerDataGet){ else if(type == EnumPacketServer.PlayerDataGet){
int id = buffer.readInt(); int id = buffer.readInt();
if(EnumPlayerData.values().length <= id) if(EnumPlayerData.values().length <= id)
@@ -694,6 +756,9 @@ public class PacketHandlerServer{
else if(type == EnumPacketServer.PlayerDataRemove){ else if(type == EnumPacketServer.PlayerDataRemove){
NoppesUtilServer.removePlayerData(buffer,player); NoppesUtilServer.removePlayerData(buffer,player);
} }
else if(type == EnumPacketServer.PlayerDataRegen){
NoppesUtilServer.regenPlayerData(player);
}
else if(type == EnumPacketServer.MainmenuDisplayGet){ else if(type == EnumPacketServer.MainmenuDisplayGet){
Server.sendData(player, EnumPacketClient.GUI_DATA, npc.display.writeToNBT(new NBTTagCompound())); Server.sendData(player, EnumPacketClient.GUI_DATA, npc.display.writeToNBT(new NBTTagCompound()));
} }
@@ -833,6 +898,43 @@ public class PacketHandlerServer{
//NoppesUtilServer.sendRoleData(player, npc); //NoppesUtilServer.sendRoleData(player, npc);
} }
} }
else if(type == EnumPacketServer.AnimationListGet) {
Server.sendData(player, EnumPacketClient.SCROLL_LIST, new ArrayList<>(AnimationController.instance.animations.keySet()));
}
else if(type == EnumPacketServer.AnimationGet) {
String animationName = Server.readString(buffer);
Animation animation = (Animation) AnimationController.instance.get(animationName);
if (animation != null) {
Server.sendData(player, EnumPacketClient.GUI_DATA, animation.writeToNBT());
}
}
else if (type == EnumPacketServer.AnimationAdd) {
String name = "Animation";
if (AnimationController.instance.has(name)) {
name += "_";
int i = 1;
while (AnimationController.instance.has(name + i)) {
i++;
}
name += i;
}
Animation animation = new Animation(name);
animation.save();
Server.sendData(player, EnumPacketClient.SCROLL_LIST, new ArrayList<>(AnimationController.instance.animations.keySet()));
}
else if (type == EnumPacketServer.AnimationDelete) {
String animationName = Server.readString(buffer);
AnimationController.instance.delete(animationName);
Server.sendData(player, EnumPacketClient.SCROLL_LIST, new ArrayList<>(AnimationController.instance.animations.keySet()));
}
else if (type == EnumPacketServer.AnimationSave) {
String prevName = Server.readString(buffer);
AnimationController.instance.delete(prevName);
Animation animation = new Animation();
animation.readFromNBT(Server.readNBT(buffer));
animation.save();
Server.sendData(player, EnumPacketClient.SCROLL_LIST, new ArrayList<>(AnimationController.instance.animations.keySet()));
}
else else
blockPackets(type, buffer, player); blockPackets(type, buffer, player);
@@ -848,17 +950,22 @@ public class PacketHandlerServer{
} }
else if(type == EnumPacketServer.CloneList){ else if(type == EnumPacketServer.CloneList){
NBTTagList list = new NBTTagList(); NBTTagList list = new NBTTagList();
int tab = buffer.readInt();
for(String name : ServerCloneController.Instance.getClones(buffer.readInt())) for(String name : ServerCloneController.Instance.getClones(tab))
list.appendTag(new NBTTagString(name)); list.appendTag(new NBTTagString(name));
NBTTagList listDate = new NBTTagList();
for(String name : ServerCloneController.Instance.getClonesDate(tab))
listDate.appendTag(new NBTTagString(name));
NBTTagCompound compound = new NBTTagCompound(); NBTTagCompound compound = new NBTTagCompound();
compound.setTag("List", list); compound.setTag("List", list);
compound.setTag("ListDate", listDate);
Server.sendData(player, EnumPacketClient.GUI_DATA, compound); Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
} }
else else
warn(player,"tried todo something with the wrong tool, probably a hacker"); warn(player,"WE 1 tried todo something with the wrong tool, probably a hacker");
} }
private void clonePackets(EnumPacketServer type, ByteBuf buffer, EntityPlayerMP player) throws IOException { private void clonePackets(EnumPacketServer type, ByteBuf buffer, EntityPlayerMP player) throws IOException {
@@ -879,7 +986,7 @@ public class PacketHandlerServer{
player.addChatMessage(new ChatComponentText("Failed to create an entity out of your clone")); player.addChatMessage(new ChatComponentText("Failed to create an entity out of your clone"));
return; return;
} }
if(CustomNpcs.PlayerLogging && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER){ if(ConfigDebug.PlayerLogging && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER){
LogWriter.script(String.format("[%s] (Player) %s SPAWNED ENTITY %s", "CLONER", player.getCommandSenderName(), entity)); LogWriter.script(String.format("[%s] (Player) %s SPAWNED ENTITY %s", "CLONER", player.getCommandSenderName(), entity));
} }
} }
@@ -906,7 +1013,10 @@ public class PacketHandlerServer{
PlayerData data = PlayerDataController.instance.getPlayerData(player); PlayerData data = PlayerDataController.instance.getPlayerData(player);
if(data.cloned == null) if(data.cloned == null)
return; return;
ServerCloneController.Instance.addClone(data.cloned, Server.readString(buffer), buffer.readInt()); String name = Server.readString(buffer);
int tab = buffer.readInt();
NBTTagCompound tagExtra = Server.readNBT(buffer);
ServerCloneController.Instance.addClone(data.cloned, name, tab, tagExtra);
} }
else if(type == EnumPacketServer.CloneRemove){ else if(type == EnumPacketServer.CloneRemove){
int tab = buffer.readInt(); int tab = buffer.readInt();
@@ -917,24 +1027,80 @@ public class PacketHandlerServer{
for(String name : ServerCloneController.Instance.getClones(tab)) for(String name : ServerCloneController.Instance.getClones(tab))
list.appendTag(new NBTTagString(name)); list.appendTag(new NBTTagString(name));
NBTTagList listDate = new NBTTagList();
for(String name : ServerCloneController.Instance.getClonesDate(tab))
listDate.appendTag(new NBTTagString(name));
NBTTagCompound compound = new NBTTagCompound(); NBTTagCompound compound = new NBTTagCompound();
compound.setTag("List", list); compound.setTag("List", list);
compound.setTag("ListDate", listDate);
Server.sendData(player, EnumPacketClient.GUI_DATA, compound); Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
} }
else if(type == EnumPacketServer.CloneList){ else if(type == EnumPacketServer.CloneList){
NBTTagList list = new NBTTagList(); NBTTagList list = new NBTTagList();
int tab = buffer.readInt();
for(String name : ServerCloneController.Instance.getClones(buffer.readInt())) for(String name : ServerCloneController.Instance.getClones(tab))
list.appendTag(new NBTTagString(name)); list.appendTag(new NBTTagString(name));
NBTTagList listDate = new NBTTagList();
for(String name : ServerCloneController.Instance.getClonesDate(tab))
listDate.appendTag(new NBTTagString(name));
NBTTagCompound compound = new NBTTagCompound(); NBTTagCompound compound = new NBTTagCompound();
compound.setTag("List", list); compound.setTag("List", list);
compound.setTag("ListDate", listDate);
Server.sendData(player, EnumPacketClient.GUI_DATA, compound); Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
} }
else else if (type == EnumPacketServer.CloneTagList) {
warn(player,"tried todo something with the wrong tool, probably a hacker"); int tab = buffer.readInt();
TagMap tagMap = ServerTagMapController.Instance.getTagMap(tab);
NBTTagCompound compound = new NBTTagCompound();
compound.setTag("CloneTags", tagMap.writeNBT());
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
}
else if (type == EnumPacketServer.CloneAllTags) {
NBTTagCompound compound = new NBTTagCompound();
HashSet<Tag> validTags = TagController.getInstance().getAllTags();
NBTTagList validTagList = new NBTTagList();
for(Tag tag : validTags){
NBTTagCompound tagCompound = new NBTTagCompound();
tag.writeNBT(tagCompound);
validTagList.appendTag(tagCompound);
}
compound.setTag("AllTags", validTagList);
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
}
else if (type == EnumPacketServer.CloneAllTagsShort) {
NBTTagCompound compound = new NBTTagCompound();
HashSet<Tag> validTags = TagController.getInstance().getAllTags();
NBTTagList validTagList = new NBTTagList();
for(Tag tag : validTags){
NBTTagCompound tagCompound = new NBTTagCompound();
tag.writeShortNBT(tagCompound);
validTagList.appendTag(tagCompound);
}
compound.setTag("ShortTags", validTagList);
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
}
else if (type == EnumPacketServer.TagSet) {
EntityNPCInterface npc = NoppesUtilServer.getEditingNpc(player);
this.setTags(npc,buffer);
}
else if (type != EnumPacketServer.NpcTagsGet && type != EnumPacketServer.TagsGet) {
warn(player, "WE 2 tried todo something with the wrong tool, probably a hacker");
}
}
private void setTags(EntityNPCInterface npc, ByteBuf buffer) throws IOException {
npc.advanced.tagUUIDs.removeIf(uuid -> TagController.getInstance().getTagFromUUID(uuid) != null);
NBTTagCompound compound = Server.readNBT(buffer);
NBTTagList list = compound.getTagList("TagNames",8);
for (int i = 0; i < list.tagCount(); i++) {
String tagName = list.getStringTagAt(i);
npc.advanced.tagUUIDs.add(((Tag)TagController.getInstance().getTagFromName(tagName)).uuid);
}
} }
private void warn(EntityPlayer player, String warning){ private void warn(EntityPlayer player, String warning){
+18 -7
View File
@@ -1,22 +1,23 @@
package noppes.npcs; package noppes.npcs;
import java.util.HashMap;
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.data.PlayerData;
import noppes.npcs.controllers.PlayerDataController; import noppes.npcs.controllers.PlayerDataController;
import noppes.npcs.controllers.PlayerQuestController; import noppes.npcs.controllers.PlayerQuestController;
import noppes.npcs.controllers.data.PlayerData;
import noppes.npcs.controllers.data.Quest; import noppes.npcs.controllers.data.Quest;
import java.util.HashMap;
import java.util.Vector;
public class QuestLogData { public class QuestLogData {
public String trackedQuestKey = ""; public String trackedQuestKey = "";
public HashMap<String,Vector<String>> categories = new HashMap<String,Vector<String>>(); public HashMap<String,Vector<String>> categories = new HashMap<String,Vector<String>>();
public String selectedQuest = ""; public String selectedQuest = "";
public String selectedCategory = ""; public String selectedCategory = "";
public HashMap<String,String> questText = new HashMap<String,String>(); public HashMap<String,String> questText = new HashMap<String,String>();
public HashMap<String,String> questAlerts = new HashMap<>();
public HashMap<String,Vector<String>> questStatus = new HashMap<String,Vector<String>>(); public HashMap<String,Vector<String>> questStatus = new HashMap<String,Vector<String>>();
public HashMap<String,String> finish = new HashMap<String,String>(); public HashMap<String,String> finish = new HashMap<String,String>();
@@ -24,6 +25,7 @@ public class QuestLogData {
NBTTagCompound compound = new NBTTagCompound(); NBTTagCompound compound = new NBTTagCompound();
compound.setTag("Categories", NBTTags.nbtVectorMap(categories)); compound.setTag("Categories", NBTTags.nbtVectorMap(categories));
compound.setTag("Logs", NBTTags.nbtStringStringMap(questText)); compound.setTag("Logs", NBTTags.nbtStringStringMap(questText));
compound.setTag("Alerts", NBTTags.nbtStringStringMap(questAlerts));
compound.setTag("Status", NBTTags.nbtVectorMap(questStatus)); compound.setTag("Status", NBTTags.nbtVectorMap(questStatus));
compound.setTag("QuestFinisher", NBTTags.nbtStringStringMap(finish)); compound.setTag("QuestFinisher", NBTTags.nbtStringStringMap(finish));
compound.setString("TrackedQuestID", trackedQuestKey); compound.setString("TrackedQuestID", trackedQuestKey);
@@ -33,6 +35,7 @@ public class QuestLogData {
public void readNBT(NBTTagCompound compound){ public void readNBT(NBTTagCompound compound){
categories = NBTTags.getVectorMap(compound.getTagList("Categories", 10)); categories = NBTTags.getVectorMap(compound.getTagList("Categories", 10));
questText = NBTTags.getStringStringMap(compound.getTagList("Logs", 10)); questText = NBTTags.getStringStringMap(compound.getTagList("Logs", 10));
questAlerts = NBTTags.getStringStringMap(compound.getTagList("Alerts", 10));
questStatus = NBTTags.getVectorMap(compound.getTagList("Status", 10)); questStatus = NBTTags.getVectorMap(compound.getTagList("Status", 10));
finish = NBTTags.getStringStringMap(compound.getTagList("QuestFinisher", 10)); finish = NBTTags.getStringStringMap(compound.getTagList("QuestFinisher", 10));
trackedQuestKey = compound.getString("TrackedQuestID"); trackedQuestKey = compound.getString("TrackedQuestID");
@@ -49,13 +52,13 @@ public class QuestLogData {
list.add(quest.title); list.add(quest.title);
questText.put(category + ":" + quest.title, quest.logText); questText.put(category + ":" + quest.title, quest.logText);
questAlerts.put(category + ":" + quest.title, String.valueOf(playerData.questData.activeQuests.get(quest.id).sendAlerts));
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(playerData)) if(quest.completion == EnumQuestCompletion.Npc && quest.questInterface.isCompleted(playerData))
finish.put(category + ":" + quest.title, quest.completerNpc); finish.put(category + ":" + quest.title, quest.completerNpc);
if (playerData.questData.trackedQuest != null) { if (playerData.questData.getTrackedQuest() != null) {
if (quest.id == playerData.questData.trackedQuest.getId()) { if (quest.id == playerData.questData.getTrackedQuest().getId()) {
trackedQuestKey = category + ":" + quest.title; trackedQuestKey = category + ":" + quest.title;
} }
} }
@@ -70,6 +73,14 @@ public class QuestLogData {
return questText.get(selectedCategory + ":" + selectedQuest); return questText.get(selectedCategory + ":" + selectedQuest);
} }
public Boolean getQuestAlerts() {
return Boolean.valueOf(questAlerts.get(selectedCategory+":"+selectedQuest));
}
public void toggleQuestAlerts() {
questAlerts.put(selectedCategory+":"+selectedQuest,String.valueOf(!getQuestAlerts()));
}
public Vector<String> getQuestStatus() { public Vector<String> getQuestStatus() {
return questStatus.get(selectedCategory + ":" + selectedQuest); return questStatus.get(selectedCategory + ":" + selectedQuest);
} }
@@ -11,13 +11,13 @@ import net.minecraftforge.event.entity.item.ItemTossEvent;
import net.minecraftforge.event.entity.living.LivingEvent; import net.minecraftforge.event.entity.living.LivingEvent;
import net.minecraftforge.event.entity.player.EntityInteractEvent; import net.minecraftforge.event.entity.player.EntityInteractEvent;
import net.minecraftforge.event.entity.player.PlayerUseItemEvent; import net.minecraftforge.event.entity.player.PlayerUseItemEvent;
import noppes.npcs.entity.EntityCustomNpc; import noppes.npcs.api.entity.IPlayer;
import noppes.npcs.items.ItemScripted;
import noppes.npcs.scripted.event.ItemEvent;
import noppes.npcs.api.item.IItemCustom; import noppes.npcs.api.item.IItemCustom;
import noppes.npcs.api.item.IItemStack; import noppes.npcs.api.item.IItemStack;
import noppes.npcs.api.entity.IPlayer; import noppes.npcs.entity.EntityCustomNpc;
import noppes.npcs.items.ItemScripted;
import noppes.npcs.scripted.NpcAPI; import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.scripted.event.ItemEvent;
import java.util.HashMap; import java.util.HashMap;
@@ -58,7 +58,7 @@ public class ScriptItemEventHandler {
try { try {
if (event.entityItem.getEntityItem().getItem() == CustomItems.scripted_item && !event.isCanceled()) { if (event.entityItem.getEntityItem().getItem() == CustomItems.scripted_item && !event.isCanceled()) {
IItemCustom isw = ItemScripted.GetWrapper(event.entityItem.getEntityItem()); IItemCustom isw = ItemScripted.GetWrapper(event.entityItem.getEntityItem());
EventHooks.onScriptItemTossed(isw, event.player, event.entityItem); event.setCanceled(EventHooks.onScriptItemTossed(isw, event.player, event.entityItem));
} }
} catch (Exception e) {} } catch (Exception e) {}
} }
@@ -14,6 +14,7 @@ import net.minecraft.entity.Entity;
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.inventory.ContainerPlayer; import net.minecraft.inventory.ContainerPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ChatComponentTranslation; import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.world.WorldServer; import net.minecraft.world.WorldServer;
import net.minecraftforge.common.ForgeHooks; import net.minecraftforge.common.ForgeHooks;
@@ -22,15 +23,21 @@ import net.minecraftforge.event.entity.PlaySoundAtEntityEvent;
import net.minecraftforge.event.entity.item.ItemTossEvent; import net.minecraftforge.event.entity.item.ItemTossEvent;
import net.minecraftforge.event.entity.living.*; import net.minecraftforge.event.entity.living.*;
import net.minecraftforge.event.entity.player.*; import net.minecraftforge.event.entity.player.*;
import net.minecraftforge.event.world.*; import net.minecraftforge.event.world.BlockEvent;
import noppes.npcs.api.entity.IPlayer;
import noppes.npcs.constants.EnumPacketClient; import noppes.npcs.constants.EnumPacketClient;
import noppes.npcs.controllers.*; import noppes.npcs.constants.EnumQuestType;
import noppes.npcs.controllers.PlayerDataController;
import noppes.npcs.controllers.ScriptController;
import noppes.npcs.controllers.data.PlayerData; import noppes.npcs.controllers.data.PlayerData;
import noppes.npcs.controllers.data.PlayerDataScript; import noppes.npcs.controllers.data.PlayerDataScript;
import noppes.npcs.controllers.data.PlayerQuestData;
import noppes.npcs.controllers.data.Quest; import noppes.npcs.controllers.data.Quest;
import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.scripted.NpcAPI; import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.api.entity.IPlayer; import noppes.npcs.scripted.item.ScriptCustomItem;
import static noppes.npcs.config.ConfigMain.TrackedQuestUpdateFrequency;
public class ScriptPlayerEventHandler { public class ScriptPlayerEventHandler {
public ScriptPlayerEventHandler() { public ScriptPlayerEventHandler() {
@@ -47,6 +54,14 @@ public class ScriptPlayerEventHandler {
PlayerDataScript handler = ScriptController.Instance.playerScripts; PlayerDataScript handler = ScriptController.Instance.playerScripts;
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(player); IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(player);
EventHooks.onPlayerTick(handler, scriptPlayer); EventHooks.onPlayerTick(handler, scriptPlayer);
for(int i = 0; i < player.inventory.getSizeInventory(); i++){
ItemStack item = player.inventory.getStackInSlot(i);
if(item != null && item.getItem() == CustomItems.scripted_item){
ScriptCustomItem isw = (ScriptCustomItem) NpcAPI.Instance().getIItemStack(item);
EventHooks.onScriptItemUpdate(isw, player);
}
}
} }
if (PlayerDataController.instance != null) { if (PlayerDataController.instance != null) {
@@ -56,14 +71,22 @@ public class ScriptPlayerEventHandler {
playerData.timers.update(); playerData.timers.update();
} }
if (playerData.questData.trackedQuest != null && !playerData.questData.activeQuests.containsKey(playerData.questData.trackedQuest.getId())) { if (playerData.questData.getTrackedQuest() != null && !playerData.questData.activeQuests.containsKey(playerData.questData.getTrackedQuest().getId())) {
PlayerDataController.instance.getPlayerData(player).questData.trackedQuest = null; PlayerDataController.instance.getPlayerData(player).questData.untrackQuest();
Server.sendData((EntityPlayerMP) player, EnumPacketClient.OVERLAY_QUEST_TRACKING);
} }
if (player.ticksExisted%20 == 0 && !PlayerDataController.instance.getPlayerData(player).skinOverlays.overlayList.isEmpty()) { if (player.ticksExisted % 20 == 0 && !PlayerDataController.instance.getPlayerData(player).skinOverlays.overlayList.isEmpty()) {
PlayerDataController.instance.getPlayerData(player).skinOverlays.updateClient(); PlayerDataController.instance.getPlayerData(player).skinOverlays.updateClient();
} }
if (player.ticksExisted % (TrackedQuestUpdateFrequency * 20) == 0) {
PlayerQuestData questData = playerData.questData;
if(questData != null){
if (questData.getTrackedQuest() != null && ((Quest) questData.getTrackedQuest()).type == EnumQuestType.Item) {
NoppesUtilPlayer.sendTrackedQuestData((EntityPlayerMP) event.player);
}
}
}
} }
} }
} }
@@ -306,7 +329,7 @@ public class ScriptPlayerEventHandler {
if(event.player.worldObj instanceof WorldServer) { if(event.player.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts; PlayerDataScript handler = ScriptController.Instance.playerScripts;
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.player); IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.player);
EventHooks.onPlayerToss(handler, scriptPlayer, event.entityItem); event.setCanceled(EventHooks.onPlayerToss(handler, scriptPlayer, event.entityItem));
} }
} }
@@ -453,9 +476,9 @@ public class ScriptPlayerEventHandler {
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.player); IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.player);
EventHooks.onPlayerLogin(handler, scriptPlayer); EventHooks.onPlayerLogin(handler, scriptPlayer);
Quest quest = (Quest) PlayerDataController.instance.getPlayerData(event.player).questData.trackedQuest; Quest quest = (Quest) PlayerDataController.instance.getPlayerData(event.player).questData.getTrackedQuest();
if (quest != null) { if (quest != null) {
NoppesUtilPlayer.sendTrackedQuestData((EntityPlayerMP) event.player, quest); NoppesUtilPlayer.sendTrackedQuestData((EntityPlayerMP) event.player);
} }
PlayerDataController.instance.getPlayerData(event.player).skinOverlays.updateClient(); PlayerDataController.instance.getPlayerData(event.player).skinOverlays.updateClient();
+18 -17
View File
@@ -1,15 +1,10 @@
package noppes.npcs; package noppes.npcs;
import com.google.common.base.Charsets;
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
import cpw.mods.fml.common.network.internal.FMLProxyPacket;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled; import io.netty.buffer.Unpooled;
import java.io.EOFException;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import com.google.common.base.Charsets;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.CompressedStreamTools; import net.minecraft.nbt.CompressedStreamTools;
@@ -18,25 +13,31 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.PacketBuffer; import net.minecraft.network.PacketBuffer;
import net.minecraft.village.MerchantRecipeList; import net.minecraft.village.MerchantRecipeList;
import noppes.npcs.constants.EnumPacketClient; import noppes.npcs.constants.EnumPacketClient;
import cpw.mods.fml.common.network.ByteBufUtils; import noppes.npcs.util.CustomNPCsThreader;
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
import cpw.mods.fml.common.network.internal.FMLProxyPacket; import java.io.IOException;
import java.util.List;
import java.util.Map;
public class Server { public class Server {
public static boolean sendData(EntityPlayerMP player, EnumPacketClient enu, Object... obs) { public static void sendData(final EntityPlayerMP player, final EnumPacketClient enu, final Object... obs) {
ByteBuf buffer = Unpooled.buffer(); sendDataChecked(player, enu, obs);
}
public static boolean sendDataChecked(EntityPlayerMP player, EnumPacketClient type, Object... obs) {
PacketBuffer buffer = new PacketBuffer(Unpooled.buffer());
try { try {
if(!fillBuffer(buffer, enu, obs)) if(!fillBuffer(buffer, type, obs))
return false; return false;
CustomNpcs.Channel.sendTo(new FMLProxyPacket(buffer, "CustomNPCs"), player); CustomNpcs.Channel.sendTo(new FMLProxyPacket(buffer, "CustomNPCs"), player);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); LogWriter.error(type + " Errored", e);
} }
return true; return true;
} }
public static void sendAssociatedData(Entity entity, EnumPacketClient enu, Object... obs) { public static void sendAssociatedData(final Entity entity, final EnumPacketClient enu, final Object... obs) {
ByteBuf buffer = Unpooled.buffer(); ByteBuf buffer = Unpooled.buffer();
try { try {
if(!fillBuffer(buffer, enu, obs)) if(!fillBuffer(buffer, enu, obs))
@@ -1,10 +1,7 @@
package noppes.npcs; package noppes.npcs;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.eventhandler.EventPriority;
import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import net.minecraft.block.Block; import net.minecraft.block.Block;
@@ -24,6 +21,7 @@ import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.util.MathHelper; import net.minecraft.util.MathHelper;
import net.minecraft.util.StatCollector; import net.minecraft.util.StatCollector;
import net.minecraft.village.MerchantRecipeList; import net.minecraft.village.MerchantRecipeList;
import net.minecraftforge.event.entity.EntityEvent;
import net.minecraftforge.event.entity.EntityJoinWorldEvent; import net.minecraftforge.event.entity.EntityJoinWorldEvent;
import net.minecraftforge.event.entity.living.LivingDeathEvent; import net.minecraftforge.event.entity.living.LivingDeathEvent;
import net.minecraftforge.event.entity.living.LivingHurtEvent; import net.minecraftforge.event.entity.living.LivingHurtEvent;
@@ -34,11 +32,15 @@ import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.event.entity.player.PlayerInteractEvent.Action; import net.minecraftforge.event.entity.player.PlayerInteractEvent.Action;
import net.minecraftforge.event.terraingen.PopulateChunkEvent; import net.minecraftforge.event.terraingen.PopulateChunkEvent;
import noppes.npcs.blocks.tiles.TileBanner; import noppes.npcs.blocks.tiles.TileBanner;
import noppes.npcs.config.ConfigDebug;
import noppes.npcs.config.ConfigMain;
import noppes.npcs.constants.EnumGuiType; import noppes.npcs.constants.EnumGuiType;
import noppes.npcs.constants.EnumPacketClient; 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.controllers.*; import noppes.npcs.controllers.PlayerDataController;
import noppes.npcs.controllers.RecipeController;
import noppes.npcs.controllers.ServerCloneController;
import noppes.npcs.controllers.data.*; import noppes.npcs.controllers.data.*;
import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.items.ItemExcalibur; import noppes.npcs.items.ItemExcalibur;
@@ -48,6 +50,10 @@ import noppes.npcs.quests.QuestItem;
import noppes.npcs.quests.QuestKill; import noppes.npcs.quests.QuestKill;
import noppes.npcs.roles.RoleFollower; import noppes.npcs.roles.RoleFollower;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
public class ServerEventsHandler { public class ServerEventsHandler {
public static EntityVillager Merchant; public static EntityVillager Merchant;
@@ -61,13 +67,13 @@ public class ServerEventsHandler {
boolean isRemote = event.entityPlayer.worldObj.isRemote; boolean isRemote = event.entityPlayer.worldObj.isRemote;
boolean npcInteracted = event.target instanceof EntityNPCInterface; boolean npcInteracted = event.target instanceof EntityNPCInterface;
if(!isRemote && CustomNpcs.OpsOnly && !MinecraftServer.getServer().getConfigurationManager().func_152596_g(event.entityPlayer.getGameProfile())){ if(!isRemote && ConfigMain.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(CustomNpcs.PlayerLogging && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER){ if(ConfigDebug.PlayerLogging && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER){
LogWriter.script(String.format("[%s] (Player) %s PICKED ENTITY %s", "SOULSTONE", event.entityPlayer.getCommandSenderName(), event.target)); LogWriter.script(String.format("[%s] (Player) %s PICKED ENTITY %s", "SOULSTONE", event.entityPlayer.getCommandSenderName(), event.target));
} }
} }
@@ -78,7 +84,7 @@ public class ServerEventsHandler {
} }
event.setCanceled(true); event.setCanceled(true);
NoppesUtilServer.sendOpenGui(event.entityPlayer, EnumGuiType.MainMenuDisplay, (EntityNPCInterface) event.target); NoppesUtilServer.sendOpenGui(event.entityPlayer, EnumGuiType.MainMenuDisplay, (EntityNPCInterface) event.target);
if(CustomNpcs.PlayerLogging && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER){ if(ConfigDebug.PlayerLogging && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER){
LogWriter.script(String.format("[%s] (Player) %s OPEN NPC %s (%s, %s, %s) [%s]", "WAND", event.entityPlayer.getCommandSenderName(), ((EntityNPCInterface)(event.target)).display.getName(), (int)(event.target).posX, (int)(event.target).posY, (int)(event.target).posZ, (event.target).worldObj.getWorldInfo().getWorldName())); LogWriter.script(String.format("[%s] (Player) %s OPEN NPC %s (%s, %s, %s) [%s]", "WAND", event.entityPlayer.getCommandSenderName(), ((EntityNPCInterface)(event.target)).display.getName(), (int)(event.target).posX, (int)(event.target).posY, (int)(event.target).posZ, (event.target).worldObj.getWorldInfo().getWorldName()));
} }
} }
@@ -88,9 +94,12 @@ public class ServerEventsHandler {
return; return;
PlayerData data = PlayerDataController.instance.getPlayerData(event.entityPlayer); PlayerData data = PlayerDataController.instance.getPlayerData(event.entityPlayer);
ServerCloneController.Instance.cleanTags(compound); ServerCloneController.Instance.cleanTags(compound);
if(!Server.sendData((EntityPlayerMP)event.entityPlayer, EnumPacketClient.CLONE, compound)) if(!Server.sendDataChecked((EntityPlayerMP)event.entityPlayer, EnumPacketClient.CLONE, compound))
event.entityPlayer.addChatMessage(new ChatComponentText("Entity too big to clone")); event.entityPlayer.addChatMessage(new ChatComponentText("Entity too big to clone"));
data.cloned = compound; data.cloned = compound;
if (event.target instanceof EntityNPCInterface) {
NoppesUtilServer.setEditingNpc(event.entityPlayer, (EntityNPCInterface) event.target);
}
event.setCanceled(true); event.setCanceled(true);
} }
else if(item.getItem() == CustomItems.scripter && !isRemote && npcInteracted){ else if(item.getItem() == CustomItems.scripter && !isRemote && npcInteracted){
@@ -99,7 +108,7 @@ public class ServerEventsHandler {
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());
if(CustomNpcs.PlayerLogging && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER){ if(ConfigDebug.PlayerLogging && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER){
LogWriter.script(String.format("[%s] (Player) %s OPEN NPC %s (%s, %s, %s) [%s]", "SCRIPTER", event.entityPlayer.getCommandSenderName(), ((EntityNPCInterface)(event.target)).display.getName(), (int)(event.target).posX, (int)(event.target).posY, (int)(event.target).posZ, (event.target).worldObj.getWorldInfo().getWorldName())); LogWriter.script(String.format("[%s] (Player) %s OPEN NPC %s (%s, %s, %s) [%s]", "SCRIPTER", event.entityPlayer.getCommandSenderName(), ((EntityNPCInterface)(event.target)).display.getName(), (int)(event.target).posX, (int)(event.target).posY, (int)(event.target).posZ, (event.target).worldObj.getWorldInfo().getWorldName()));
} }
} }
@@ -246,7 +255,7 @@ public class ServerEventsHandler {
doExcalibur((EntityPlayer) event.source.getEntity(),event.entityLiving); doExcalibur((EntityPlayer) event.source.getEntity(),event.entityLiving);
} }
if(event.source.getEntity() instanceof EntityNPCInterface && event.entityLiving != null){ if(event.source.getEntity() instanceof EntityNPCInterface){
EntityNPCInterface npc = (EntityNPCInterface) event.source.getEntity(); EntityNPCInterface npc = (EntityNPCInterface) event.source.getEntity();
Line line = npc.advanced.getKillLine(); Line line = npc.advanced.getKillLine();
if(line != null) if(line != null)
@@ -269,7 +278,7 @@ public class ServerEventsHandler {
} }
if(event.entityLiving instanceof EntityPlayer){ if(event.entityLiving instanceof EntityPlayer){
PlayerData data = PlayerDataController.instance.getPlayerData((EntityPlayer)event.entityLiving); PlayerData data = PlayerDataController.instance.getPlayerData((EntityPlayer)event.entityLiving);
data.savePlayerDataOnFile(); data.save();
} }
} }
@@ -288,48 +297,54 @@ public class ServerEventsHandler {
private void doQuest(EntityPlayer player, EntityLivingBase entity, boolean all) { private void doQuest(EntityPlayer player, EntityLivingBase entity, boolean all) {
PlayerData playerData = PlayerDataController.instance.getPlayerData(player); PlayerData playerData = PlayerDataController.instance.getPlayerData(player);
PlayerQuestData questData = playerData.questData; PlayerQuestData questData = playerData.questData;
boolean change = false; boolean checkCompletion = false;
String entityName = EntityList.getEntityString(entity); String entityName = EntityList.getEntityString(entity);
ArrayList<QuestData> activeQuestValues = new ArrayList<>(questData.activeQuests.values()); ArrayList<QuestData> activeQuestValues = new ArrayList<>(questData.activeQuests.values());
for(QuestData data : activeQuestValues){ for(QuestData data : activeQuestValues){
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){
List<EntityPlayer> list = player.worldObj.getEntitiesWithinAABB(EntityPlayer.class, entity.boundingBox.expand(10, 10, 10));
for(EntityPlayer pl : list)
if(pl != player)
doQuest(pl, entity, false);
if (data.quest.type == EnumQuestType.AreaKill && all) {
List<EntityPlayer> list = player.worldObj.getEntitiesWithinAABB(EntityPlayer.class, entity.boundingBox.expand(10, 10, 10));
for (EntityPlayer pl : list) {
if (pl != player) {
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; Class entityType = EntityNPCInterface.class;
if(quest.targetType == 2) { if (quest.targetType == 2) {
try { try {
entityType = Class.forName(quest.customTargetType); entityType = Class.forName(quest.customTargetType);
} catch (ClassNotFoundException notFoundException) { } catch (ClassNotFoundException notFoundException) {
continue; continue;
} }
} }
if(quest.targetType > 0 && !(entityType.isInstance(entity)))
if (quest.targetType > 0 && !(entityType.isInstance(entity)))
continue; continue;
if(quest.targets.containsKey(entity.getCommandSenderName()))
if (quest.targets.containsKey(entity.getCommandSenderName()))
name = entity.getCommandSenderName(); name = entity.getCommandSenderName();
else if(!quest.targets.containsKey(name)) else if (!quest.targets.containsKey(name))
continue; continue;
checkCompletion = true;
HashMap<String, Integer> killed = quest.getKilled(data); HashMap<String, Integer> killed = quest.getKilled(data);
if(killed.containsKey(name) && killed.get(name) >= quest.targets.get(name)) if (!killed.containsKey(name)) {
continue; killed.put(name, 1);
int amount = 0; } else if(killed.get(name) < quest.targets.get(name)) {
if(killed.containsKey(name)) int amount = killed.get(name);
amount = killed.get(name); killed.put(name, amount + 1);
killed.put(name, amount + 1); }
quest.setKilled(data, killed); quest.setKilled(data, killed);
change = true;
} }
if(!change) if(!checkCompletion)
return; return;
questData.checkQuestCompletion(playerData,EnumQuestType.Kill); questData.checkQuestCompletion(playerData,EnumQuestType.Kill);
@@ -345,6 +360,12 @@ public class ServerEventsHandler {
questData.checkQuestCompletion(playerData, EnumQuestType.Item); questData.checkQuestCompletion(playerData, EnumQuestType.Item);
} }
@SubscribeEvent
public void world(PlayerEvent.SaveToFile event){
PlayerData data = PlayerDataController.instance.getPlayerData((EntityPlayer) event.entity);
data.save();
}
@SubscribeEvent @SubscribeEvent
public void world(EntityJoinWorldEvent event){ public void world(EntityJoinWorldEvent event){
if(event.world.isRemote || !(event.entity instanceof EntityPlayer)) if(event.world.isRemote || !(event.entity instanceof EntityPlayer))
@@ -353,12 +374,6 @@ public class ServerEventsHandler {
data.updateCompanion(event.world); data.updateCompanion(event.world);
} }
@SubscribeEvent
public void world(PlayerEvent.SaveToFile event){
PlayerData data = PlayerDataController.instance.getPlayerData((EntityPlayer) event.entity);
data.savePlayerDataOnFile();
}
@SubscribeEvent @SubscribeEvent
public void populateChunk(PopulateChunkEvent.Post event){ public void populateChunk(PopulateChunkEvent.Post event){
NPCSpawning.performWorldGenSpawning(event.world, event.chunkX, event.chunkZ, event.rand); NPCSpawning.performWorldGenSpawning(event.world, event.chunkX, event.chunkZ, event.rand);
@@ -1,17 +1,15 @@
package noppes.npcs; package noppes.npcs;
import java.net.InetAddress;
import java.net.UnknownHostException;
import net.minecraft.server.MinecraftServer;
import net.minecraft.world.WorldServer;
import noppes.npcs.client.AnalyticsTracking;
import noppes.npcs.controllers.SpawnController;
import noppes.npcs.entity.EntityNPCInterface;
import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.PlayerEvent; import cpw.mods.fml.common.gameevent.PlayerEvent;
import cpw.mods.fml.common.gameevent.TickEvent; import cpw.mods.fml.common.gameevent.TickEvent;
import cpw.mods.fml.common.gameevent.TickEvent.Phase; import cpw.mods.fml.common.gameevent.TickEvent.Phase;
import net.minecraft.server.MinecraftServer;
import net.minecraft.world.WorldServer;
import noppes.npcs.client.AnalyticsTracking;
import java.net.InetAddress;
import java.net.UnknownHostException;
public class ServerTickHandler { public class ServerTickHandler {
@SubscribeEvent @SubscribeEvent
+2 -2
View File
@@ -1,10 +1,10 @@
package noppes.npcs; package noppes.npcs;
import net.minecraft.util.IChatComponent;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import net.minecraft.util.IChatComponent;
public class TextBlock { public class TextBlock {
public List<IChatComponent> lines = new ArrayList<IChatComponent>(); public List<IChatComponent> lines = new ArrayList<IChatComponent>();
} }
@@ -1,20 +1,19 @@
package noppes.npcs; package noppes.npcs;
import java.util.Collection;
import java.util.List;
import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagInt; import net.minecraft.nbt.NBTTagInt;
import net.minecraft.nbt.NBTTagList; import net.minecraft.nbt.NBTTagList;
import noppes.npcs.controllers.data.Line; import noppes.npcs.controllers.data.Line;
import noppes.npcs.controllers.data.Lines; import noppes.npcs.controllers.data.Lines;
import noppes.npcs.entity.EntityCustomNpc;
import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.entity.EntityNPCInterface;
import org.lwjgl.Sys; import noppes.npcs.entity.data.ModelRotate;
import java.util.Collection;
import java.util.List;
public class VersionCompatibility { public class VersionCompatibility {
public static int ModRev = 19; public static int ModRev = 21;
public static void CheckNpcCompatibility(EntityNPCInterface npc, NBTTagCompound compound){ public static void CheckNpcCompatibility(EntityNPCInterface npc, NBTTagCompound compound){
if(npc.npcVersion == ModRev) if(npc.npcVersion == ModRev)
@@ -115,21 +114,67 @@ public class VersionCompatibility {
public static void CheckModelCompatibility(EntityNPCInterface npc, NBTTagCompound compound){ public static void CheckModelCompatibility(EntityNPCInterface npc, NBTTagCompound compound){
if(npc.npcVersion == ModRev) if(npc.npcVersion == ModRev)
return; return;
if(npc.npcVersion < 19) { NBTTagCompound modelData = compound.getCompoundTag("NpcModelData");
NBTTagCompound partData = compound.getCompoundTag("NpcModelData"); if(npc.npcVersion < 20){
// Convert Puppet Job
if (compound.hasKey("NpcJob")) {
if(compound.getInteger("NpcJob") == 9){
// Remove Job
compound.setInteger("NpcJob", 0);
// Get Puppet Data
boolean moving = compound.getBoolean("PuppetMoving");
boolean attacking = compound.getBoolean("PuppetAttacking");
boolean standing = compound.getBoolean("PuppetStanding");
NBTTagCompound head = compound.getCompoundTag("PuppetHead");
NBTTagCompound body = compound.getCompoundTag("PuppetBody");
NBTTagCompound larm = compound.getCompoundTag("PuppetLArm");
NBTTagCompound rarm = compound.getCompoundTag("PuppetRArm");
NBTTagCompound lleg = compound.getCompoundTag("PuppetLLeg");
NBTTagCompound rleg = compound.getCompoundTag("PuppetRLeg");
// Enable Rotations
modelData.setBoolean("EnableRotation", true);
// Make New Rotation and Write It
ModelRotate newRotation = new ModelRotate();
newRotation.whileMoving = moving;
newRotation.whileAttacking = attacking;
newRotation.whileStanding = standing;
NBTTagCompound rotation = newRotation.writeToNBT();
rotation.setTag("PuppetHead", head);
rotation.setTag("PuppetBody", body);
rotation.setTag("PuppetLArm", larm);
rotation.setTag("PuppetRArm", rarm);
rotation.setTag("PuppetLLeg", lleg);
rotation.setTag("PuppetRLeg", rleg);
modelData.setTag("ModelRotation", rotation);
// Remove All Old Tags
compound.removeTag("PuppetMoving");
compound.removeTag("PuppetAttacking");
compound.removeTag("PuppetStanding");
compound.removeTag("PuppetHead");
compound.removeTag("PuppetBody");
compound.removeTag("PuppetLArm");
compound.removeTag("PuppetRArm");
compound.removeTag("PuppetLLeg");
compound.removeTag("PuppetRLeg");
}
}
}
if(npc.npcVersion < 19) {
// Fix Leg MPM Dependency // Fix Leg MPM Dependency
if(partData.hasKey("LegParts")){ if(modelData.hasKey("LegParts")){
NBTTagCompound legParts = partData.getCompoundTag("LegParts"); NBTTagCompound legParts = modelData.getCompoundTag("LegParts");
if(legParts.hasKey("Texture")){ if(legParts.hasKey("Texture")){
legParts.setString("Texture", legParts.getString("Texture").replace("moreplayermodels:textures", "customnpcs:textures/parts")); legParts.setString("Texture", legParts.getString("Texture").replace("moreplayermodels:textures", "customnpcs:textures/parts"));
} }
partData.setTag("LegParts", legParts); modelData.setTag("LegParts", legParts);
} }
// Fix Part MPM Dependency // Fix Part MPM Dependency
if(partData.hasKey("Parts")){ if(modelData.hasKey("Parts")){
NBTTagList list = partData.getTagList("Parts", 10); NBTTagList list = modelData.getTagList("Parts", 10);
for (int i = 0; i < list.tagCount(); i++) { for (int i = 0; i < list.tagCount(); i++) {
NBTTagCompound item = list.getCompoundTagAt(i); NBTTagCompound item = list.getCompoundTagAt(i);
@@ -139,10 +184,10 @@ public class VersionCompatibility {
} }
list.func_150304_a(i, item); list.func_150304_a(i, item);
} }
partData.setTag("Parts", list); modelData.setTag("Parts", list);
} }
compound.setTag("NpcModelData", partData);
} }
compound.setTag("NpcModelData", modelData);
} }
public static void CheckAvailabilityCompatibility(ICompatibilty compatibilty, NBTTagCompound compound){ public static void CheckAvailabilityCompatibility(ICompatibilty compatibilty, NBTTagCompound compound){
@@ -1,11 +1,7 @@
package noppes.npcs.ai; package noppes.npcs.ai;
import java.util.Random;
import net.minecraft.entity.EntityCreature;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.ai.EntityAIBase; import net.minecraft.entity.ai.EntityAIBase;
import net.minecraft.pathfinding.PathEntity;
import net.minecraft.util.MathHelper; import net.minecraft.util.MathHelper;
import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3; import net.minecraft.util.Vec3;
@@ -13,6 +9,8 @@ import net.minecraft.world.World;
import noppes.npcs.constants.AiMutex; import noppes.npcs.constants.AiMutex;
import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.entity.EntityNPCInterface;
import java.util.Random;
public class EntityAIAmbushTarget extends EntityAIBase public class EntityAIAmbushTarget extends EntityAIBase
{ {
private EntityNPCInterface theEntity; private EntityNPCInterface theEntity;
@@ -1,7 +1,6 @@
package noppes.npcs.ai; package noppes.npcs.ai;
import net.minecraft.entity.ai.EntityAIBase; import net.minecraft.entity.ai.EntityAIBase;
import noppes.npcs.constants.AiMutex;
import noppes.npcs.constants.EnumAnimation; import noppes.npcs.constants.EnumAnimation;
import noppes.npcs.constants.EnumMovingType; import noppes.npcs.constants.EnumMovingType;
import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.entity.EntityNPCInterface;
@@ -6,7 +6,7 @@ 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.config.ConfigMain;
import noppes.npcs.constants.AiMutex; import noppes.npcs.constants.AiMutex;
import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.entity.EntityNPCInterface;
@@ -59,7 +59,7 @@ public class EntityAIAttackTarget extends EntityAIBase
this.entityTarget = entitylivingbase; this.entityTarget = entitylivingbase;
this.attacker.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(((EntityNPCInterface) this.attacker).stats.aggroRange); 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); this.attacker.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(ConfigMain.NpcNavRange);
return this.entityPathEntity != null; return this.entityPathEntity != null;
} }
} }
@@ -1,11 +1,8 @@
package noppes.npcs.ai; package noppes.npcs.ai;
import java.util.List;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.ai.EntityAIBase; import net.minecraft.entity.ai.EntityAIBase;
import net.minecraft.entity.ai.RandomPositionGenerator;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.pathfinding.PathEntity; import net.minecraft.pathfinding.PathEntity;
import net.minecraft.pathfinding.PathNavigate; import net.minecraft.pathfinding.PathNavigate;
@@ -14,6 +11,8 @@ import noppes.npcs.constants.AiMutex;
import noppes.npcs.constants.EnumNavType; import noppes.npcs.constants.EnumNavType;
import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.entity.EntityNPCInterface;
import java.util.List;
public class EntityAIAvoidTarget extends EntityAIBase public class EntityAIAvoidTarget extends EntityAIBase
{ {
/** The entity we are attached to */ /** The entity we are attached to */
@@ -2,7 +2,6 @@ package noppes.npcs.ai;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.ai.EntityAIBase; import net.minecraft.entity.ai.EntityAIBase;
import net.minecraft.entity.ai.RandomPositionGenerator;
import net.minecraft.util.Vec3; import net.minecraft.util.Vec3;
import noppes.npcs.constants.AiMutex; import noppes.npcs.constants.AiMutex;
import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.entity.EntityNPCInterface;
@@ -1,7 +1,5 @@
package noppes.npcs.ai; package noppes.npcs.ai;
import java.util.Random;
import net.minecraft.entity.EntityCreature; import net.minecraft.entity.EntityCreature;
import net.minecraft.entity.ai.EntityAIBase; import net.minecraft.entity.ai.EntityAIBase;
import net.minecraft.util.MathHelper; import net.minecraft.util.MathHelper;
@@ -9,6 +7,8 @@ import net.minecraft.util.Vec3;
import net.minecraft.world.World; import net.minecraft.world.World;
import noppes.npcs.constants.AiMutex; import noppes.npcs.constants.AiMutex;
import java.util.Random;
public class EntityAIFindShade extends EntityAIBase public class EntityAIFindShade extends EntityAIBase
{ {
private EntityCreature theCreature; private EntityCreature theCreature;
@@ -1,13 +1,8 @@
package noppes.npcs.ai; package noppes.npcs.ai;
import net.minecraft.entity.EntityCreature;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.ai.EntityAIBase; import net.minecraft.entity.ai.EntityAIBase;
import net.minecraft.entity.ai.RandomPositionGenerator;
import net.minecraft.pathfinding.PathEntity;
import net.minecraft.pathfinding.PathPoint;
import net.minecraft.util.MathHelper; import net.minecraft.util.MathHelper;
import net.minecraft.util.Vec3;
import net.minecraft.world.World; import net.minecraft.world.World;
import noppes.npcs.constants.AiMutex; import noppes.npcs.constants.AiMutex;
import noppes.npcs.constants.EnumAnimation; import noppes.npcs.constants.EnumAnimation;
@@ -1,7 +1,5 @@
package noppes.npcs.ai; package noppes.npcs.ai;
import java.util.Iterator;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.ai.EntityAIBase; import net.minecraft.entity.ai.EntityAIBase;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
@@ -9,6 +7,8 @@ import noppes.npcs.constants.AiMutex;
import noppes.npcs.constants.EnumStandingType; import noppes.npcs.constants.EnumStandingType;
import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.entity.EntityNPCInterface;
import java.util.Iterator;
public class EntityAILook extends EntityAIBase{ public class EntityAILook extends EntityAIBase{
private final EntityNPCInterface npc; private final EntityNPCInterface npc;
private int idle = 0; private int idle = 0;
@@ -1,7 +1,5 @@
package noppes.npcs.ai; package noppes.npcs.ai;
import java.util.Random;
import net.minecraft.entity.EntityCreature; import net.minecraft.entity.EntityCreature;
import net.minecraft.entity.ai.EntityAIBase; import net.minecraft.entity.ai.EntityAIBase;
import net.minecraft.util.MathHelper; import net.minecraft.util.MathHelper;
@@ -9,6 +7,8 @@ import net.minecraft.util.Vec3;
import net.minecraft.world.World; import net.minecraft.world.World;
import noppes.npcs.constants.AiMutex; import noppes.npcs.constants.AiMutex;
import java.util.Random;
public class EntityAIMoveIndoors extends EntityAIBase public class EntityAIMoveIndoors extends EntityAIBase
{ {
private EntityCreature theCreature; private EntityCreature theCreature;
@@ -1,12 +1,11 @@
package noppes.npcs.ai; package noppes.npcs.ai;
import java.util.List;
import net.minecraft.entity.ai.EntityAIBase; import net.minecraft.entity.ai.EntityAIBase;
import noppes.npcs.constants.AiMutex; import noppes.npcs.constants.AiMutex;
import noppes.npcs.constants.EnumMovingType;
import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.entity.EntityNPCInterface;
import java.util.List;
public class EntityAIMovingPath extends EntityAIBase public class EntityAIMovingPath extends EntityAIBase
{ {
private EntityNPCInterface npc; private EntityNPCInterface npc;
@@ -1,23 +1,13 @@
package noppes.npcs.ai; package noppes.npcs.ai;
import java.util.Iterator;
import java.util.List;
import java.util.Random;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityCreature;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.ai.EntityAIBase; import net.minecraft.entity.ai.EntityAIBase;
import net.minecraft.entity.monster.EntityPigZombie;
import net.minecraft.entity.monster.EntityZombie;
import net.minecraft.entity.passive.EntityVillager;
import net.minecraft.pathfinding.PathEntity;
import net.minecraft.pathfinding.PathPoint;
import net.minecraft.util.MathHelper; import net.minecraft.util.MathHelper;
import net.minecraft.util.Vec3;
import noppes.npcs.constants.AiMutex; import noppes.npcs.constants.AiMutex;
import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.entity.EntityNPCInterface;
import java.util.Random;
public class EntityAIOrbitTarget extends EntityAIBase public class EntityAIOrbitTarget extends EntityAIBase
{ {
private EntityNPCInterface theEntity; private EntityNPCInterface theEntity;
@@ -2,7 +2,6 @@ package noppes.npcs.ai;
import net.minecraft.entity.EntityCreature; import net.minecraft.entity.EntityCreature;
import net.minecraft.entity.ai.EntityAIBase; import net.minecraft.entity.ai.EntityAIBase;
import net.minecraft.entity.ai.RandomPositionGenerator;
import net.minecraft.util.Vec3; import net.minecraft.util.Vec3;
import noppes.npcs.constants.AiMutex; import noppes.npcs.constants.AiMutex;
@@ -4,7 +4,6 @@ import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.IRangedAttackMob; import net.minecraft.entity.IRangedAttackMob;
import net.minecraft.entity.ai.EntityAIBase; import net.minecraft.entity.ai.EntityAIBase;
import net.minecraft.util.MathHelper; import net.minecraft.util.MathHelper;
import net.minecraft.util.Vec3;
import noppes.npcs.constants.AiMutex; import noppes.npcs.constants.AiMutex;
import noppes.npcs.constants.EnumAnimation; import noppes.npcs.constants.EnumAnimation;
import noppes.npcs.constants.EnumNavType; import noppes.npcs.constants.EnumNavType;
@@ -2,7 +2,7 @@ package noppes.npcs.ai;
import net.minecraft.entity.ai.EntityAIBase; import net.minecraft.entity.ai.EntityAIBase;
import net.minecraft.util.Vec3; import net.minecraft.util.Vec3;
import noppes.npcs.CustomNpcs; import noppes.npcs.config.ConfigMain;
import noppes.npcs.constants.EnumMovingType; import noppes.npcs.constants.EnumMovingType;
import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.entity.EntityNPCInterface;
@@ -56,7 +56,7 @@ public class EntityAIReturn extends EntityAIBase
return false; return false;
} }
if(npc.ai.movingType == EnumMovingType.MovingPath && npc.ai.getDistanceSqToPathPoint() < CustomNpcs.NpcNavRange * CustomNpcs.NpcNavRange) if(npc.ai.movingType == EnumMovingType.MovingPath && npc.ai.getDistanceSqToPathPoint() < ConfigMain.NpcNavRange * ConfigMain.NpcNavRange)
return false; return false;
if (npc.getNavigator().noPath() || (!npc.isAttacking() && wasAttacked)) { if (npc.getNavigator().noPath() || (!npc.isAttacking() && wasAttacked)) {
@@ -129,10 +129,10 @@ public class EntityAIReturn extends EntityAIBase
double posY = endPosY; double posY = endPosY;
double posZ = endPosZ; double posZ = endPosZ;
double range = npc.getDistance(posX, posY, posZ); double range = npc.getDistance(posX, posY, posZ);
if(range > CustomNpcs.NpcNavRange || towards){ if(range > ConfigMain.NpcNavRange || towards){
int distance = (int) range; int distance = (int) range;
if(distance > CustomNpcs.NpcNavRange) if(distance > ConfigMain.NpcNavRange)
distance = CustomNpcs.NpcNavRange / 2; distance = ConfigMain.NpcNavRange / 2;
else else
distance /= 2; distance /= 2;
if(distance > 2){ if(distance > 2){
@@ -1,16 +1,12 @@
package noppes.npcs.ai; package noppes.npcs.ai;
import java.util.Random;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.ai.EntityAIBase; import net.minecraft.entity.ai.EntityAIBase;
import net.minecraft.init.Blocks;
import net.minecraft.util.MathHelper; import net.minecraft.util.MathHelper;
import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3; import net.minecraft.util.Vec3;
import net.minecraft.world.World; import net.minecraft.world.World;
import noppes.npcs.constants.AiMutex; import noppes.npcs.constants.AiMutex;
import noppes.npcs.constants.EnumNavType;
import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.entity.EntityNPCInterface;
public class EntityAIStalkTarget extends EntityAIBase public class EntityAIStalkTarget extends EntityAIBase
@@ -1,12 +1,7 @@
package noppes.npcs.ai; package noppes.npcs.ai;
import net.minecraft.entity.ai.EntityAIBase; import net.minecraft.entity.ai.EntityAIBase;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.NoppesStringUtils;
import noppes.npcs.NoppesUtilServer;
import noppes.npcs.Server;
import noppes.npcs.constants.AiMutex; import noppes.npcs.constants.AiMutex;
import noppes.npcs.constants.EnumPacketClient;
import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.entity.EntityNPCInterface;
public class EntityAITransform extends EntityAIBase { public class EntityAITransform extends EntityAIBase {
@@ -1,18 +1,18 @@
package noppes.npcs.ai; package noppes.npcs.ai;
import java.util.Iterator;
import java.util.List;
import net.minecraft.command.IEntitySelector; import net.minecraft.command.IEntitySelector;
import net.minecraft.entity.ai.EntityAIBase; import net.minecraft.entity.ai.EntityAIBase;
import net.minecraft.util.MathHelper; import net.minecraft.util.MathHelper;
import net.minecraft.util.Vec3; import net.minecraft.util.Vec3;
import noppes.npcs.CustomNpcs;
import noppes.npcs.ai.selector.NPCInteractSelector; import noppes.npcs.ai.selector.NPCInteractSelector;
import noppes.npcs.config.ConfigMain;
import noppes.npcs.constants.AiMutex; import noppes.npcs.constants.AiMutex;
import noppes.npcs.controllers.data.Line; import noppes.npcs.controllers.data.Line;
import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.entity.EntityNPCInterface;
import java.util.Iterator;
import java.util.List;
public class EntityAIWander extends EntityAIBase public class EntityAIWander extends EntityAIBase
{ {
private EntityNPCInterface entity; private EntityNPCInterface entity;
@@ -84,12 +84,12 @@ public class EntityAIWander extends EntityAIBase
if(entity.ai.walkingRange > 0){ if(entity.ai.walkingRange > 0){
double distance = this.entity.getDistanceSq(this.entity.getStartXPos(), this.entity.getStartYPos(), this.entity.getStartZPos()); double distance = this.entity.getDistanceSq(this.entity.getStartXPos(), this.entity.getStartYPos(), this.entity.getStartZPos());
int range = (int) MathHelper.sqrt_double(this.entity.ai.walkingRange * this.entity.ai.walkingRange - distance); int range = (int) MathHelper.sqrt_double(this.entity.ai.walkingRange * this.entity.ai.walkingRange - distance);
if(range > CustomNpcs.NpcNavRange) if(range > ConfigMain.NpcNavRange)
range = CustomNpcs.NpcNavRange; range = ConfigMain.NpcNavRange;
if(range < 3){ if(range < 3){
range = this.entity.ai.walkingRange; range = this.entity.ai.walkingRange;
if(range > CustomNpcs.NpcNavRange) if(range > ConfigMain.NpcNavRange)
range = CustomNpcs.NpcNavRange; range = ConfigMain.NpcNavRange;
Vec3 start = Vec3.createVectorHelper(this.entity.getStartXPos(), this.entity.getStartYPos(), this.entity.getStartZPos()); Vec3 start = Vec3.createVectorHelper(this.entity.getStartXPos(), this.entity.getStartYPos(), this.entity.getStartZPos());
return RandomPositionGeneratorAlt.findRandomTargetBlockTowards(this.entity, range / 2, range / 2 > 7?7:range / 2, start); return RandomPositionGeneratorAlt.findRandomTargetBlockTowards(this.entity, range / 2, range / 2 > 7?7:range / 2, start);
} }
@@ -97,7 +97,7 @@ public class EntityAIWander extends EntityAIBase
return RandomPositionGeneratorAlt.findRandomTarget(this.entity, range, range / 2 > 7?7:range / 2); return RandomPositionGeneratorAlt.findRandomTarget(this.entity, range, range / 2 > 7?7:range / 2);
} }
} }
return RandomPositionGeneratorAlt.findRandomTarget(this.entity, CustomNpcs.NpcNavRange, 7); return RandomPositionGeneratorAlt.findRandomTarget(this.entity, ConfigMain.NpcNavRange, 7);
} }
@Override @Override
@@ -3,7 +3,6 @@ package noppes.npcs.ai;
import net.minecraft.entity.EntityCreature; import net.minecraft.entity.EntityCreature;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.ai.EntityAIBase; import net.minecraft.entity.ai.EntityAIBase;
import net.minecraft.entity.ai.RandomPositionGenerator;
import net.minecraft.pathfinding.PathEntity; import net.minecraft.pathfinding.PathEntity;
import net.minecraft.pathfinding.PathPoint; import net.minecraft.pathfinding.PathPoint;
import net.minecraft.util.MathHelper; import net.minecraft.util.MathHelper;
@@ -1,10 +1,11 @@
package noppes.npcs.ai; package noppes.npcs.ai;
import java.util.Random;
import net.minecraft.entity.EntityCreature; import net.minecraft.entity.EntityCreature;
import net.minecraft.util.MathHelper; import net.minecraft.util.MathHelper;
import net.minecraft.util.Vec3; import net.minecraft.util.Vec3;
import java.util.Random;
public class RandomPositionGeneratorAlt public class RandomPositionGeneratorAlt
{ {
/** /**
@@ -8,7 +8,6 @@ import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLiving;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
import net.minecraft.pathfinding.PathFinder; import net.minecraft.pathfinding.PathFinder;
import net.minecraft.pathfinding.PathPoint;
import net.minecraft.util.MathHelper; import net.minecraft.util.MathHelper;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.IntHashMap; import net.minecraft.util.math.IntHashMap;
@@ -16,7 +15,6 @@ import net.minecraft.world.IBlockAccess;
import noppes.npcs.entity.EntityCustomNpc; import noppes.npcs.entity.EntityCustomNpc;
import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.entity.EntityNPCInterface;
import javax.annotation.Nullable;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
@@ -2,7 +2,6 @@ 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.init.Blocks;
import net.minecraft.util.MathHelper; import net.minecraft.util.MathHelper;
import noppes.npcs.entity.EntityNPCFlying; import noppes.npcs.entity.EntityNPCFlying;
import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.entity.EntityNPCInterface;
@@ -2,7 +2,6 @@ package noppes.npcs.ai.pathfinder;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.pathfinding.PathEntity; import net.minecraft.pathfinding.PathEntity;
import net.minecraft.pathfinding.PathPoint;
import net.minecraft.util.Vec3; import net.minecraft.util.Vec3;
public class NPCPath extends PathEntity{ public class NPCPath extends PathEntity{
@@ -17,6 +17,7 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.world.ChunkCache; import net.minecraft.world.ChunkCache;
import net.minecraft.world.World; import net.minecraft.world.World;
import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.entity.EntityNPCInterface;
import javax.annotation.Nullable; import javax.annotation.Nullable;
public class PathNavigateFlying extends PathNavigate { public class PathNavigateFlying extends PathNavigate {
@@ -1,14 +1,11 @@
package noppes.npcs.ai.selector; package noppes.npcs.ai.selector;
import java.util.List;
import net.minecraft.command.IEntitySelector; import net.minecraft.command.IEntitySelector;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.potion.Potion; import net.minecraft.potion.Potion;
import noppes.npcs.CustomNpcs;
import noppes.npcs.constants.EnumCompanionJobs; import noppes.npcs.constants.EnumCompanionJobs;
import noppes.npcs.constants.EnumJobType; import noppes.npcs.constants.EnumJobType;
import noppes.npcs.constants.EnumMovingType; import noppes.npcs.constants.EnumMovingType;
@@ -1,16 +1,8 @@
package noppes.npcs.ai.target; package noppes.npcs.ai.target;
import java.util.Collections;
import java.util.List;
import net.minecraft.command.IEntitySelector;
import net.minecraft.entity.EntityCreature;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
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.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.MathHelper;
import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.entity.EntityNPCInterface;
public class EntityAIClearTarget extends EntityAITarget public class EntityAIClearTarget extends EntityAITarget
@@ -1,8 +1,5 @@
package noppes.npcs.ai.target; package noppes.npcs.ai.target;
import java.util.Collections;
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;
@@ -11,9 +8,12 @@ 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.config.ConfigMain;
import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.entity.EntityNPCInterface;
import java.util.Collections;
import java.util.List;
public class EntityAIClosestTarget extends EntityAITarget public class EntityAIClosestTarget extends EntityAITarget
{ {
private final Class targetClass; private final Class targetClass;
@@ -59,7 +59,7 @@ public class EntityAIClosestTarget extends EntityAITarget
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); taskOwner.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(ConfigMain.NpcNavRange);
if (list.isEmpty()) if (list.isEmpty())
{ {
return false; return false;
@@ -2,7 +2,6 @@ package noppes.npcs.ai.target;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.ai.EntityAITarget; import net.minecraft.entity.ai.EntityAITarget;
import net.minecraft.entity.passive.EntityTameable;
import noppes.npcs.constants.AiMutex; import noppes.npcs.constants.AiMutex;
import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.entity.EntityNPCInterface;
@@ -2,7 +2,6 @@ package noppes.npcs.ai.target;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.ai.EntityAITarget; import net.minecraft.entity.ai.EntityAITarget;
import net.minecraft.entity.passive.EntityTameable;
import noppes.npcs.constants.AiMutex; import noppes.npcs.constants.AiMutex;
import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.entity.EntityNPCInterface;
@@ -1,7 +1,7 @@
package noppes.npcs.blocks; package noppes.npcs.blocks;
import java.util.List; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.BlockColored; import net.minecraft.block.BlockColored;
import net.minecraft.block.BlockContainer; import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
@@ -21,8 +21,8 @@ import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World; import net.minecraft.world.World;
import noppes.npcs.NoppesUtilServer; import noppes.npcs.NoppesUtilServer;
import noppes.npcs.blocks.tiles.TileBanner; import noppes.npcs.blocks.tiles.TileBanner;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import java.util.List;
public class BlockBanner extends BlockContainer{ public class BlockBanner extends BlockContainer{
@@ -1,7 +1,5 @@
package noppes.npcs.blocks; package noppes.npcs.blocks;
import java.util.List;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.creativetab.CreativeTabs; import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
@@ -16,6 +14,8 @@ import noppes.npcs.blocks.tiles.TileBarrel;
import noppes.npcs.blocks.tiles.TileNpcContainer; import noppes.npcs.blocks.tiles.TileNpcContainer;
import noppes.npcs.constants.EnumGuiType; import noppes.npcs.constants.EnumGuiType;
import java.util.List;
public class BlockBarrel extends BlockRotated{ public class BlockBarrel extends BlockRotated{
public BlockBarrel() { public BlockBarrel() {
@@ -1,7 +1,5 @@
package noppes.npcs.blocks; package noppes.npcs.blocks;
import java.util.List;
import net.minecraft.creativetab.CreativeTabs; import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
@@ -13,6 +11,8 @@ import net.minecraft.world.World;
import noppes.npcs.blocks.tiles.TileBeam; import noppes.npcs.blocks.tiles.TileBeam;
import noppes.npcs.blocks.tiles.TileColorable; import noppes.npcs.blocks.tiles.TileColorable;
import java.util.List;
public class BlockBeam extends BlockRotated{ public class BlockBeam extends BlockRotated{
public BlockBeam() { public BlockBeam() {
@@ -1,14 +1,14 @@
package noppes.npcs.blocks; package noppes.npcs.blocks;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.BlockContainer; import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.client.renderer.texture.IIconRegister;
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.entity.player.EntityPlayerMP;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.IIcon; import net.minecraft.util.IIcon;
@@ -19,13 +19,9 @@ import noppes.npcs.CustomItems;
import noppes.npcs.CustomNpcs; import noppes.npcs.CustomNpcs;
import noppes.npcs.CustomNpcsPermissions; import noppes.npcs.CustomNpcsPermissions;
import noppes.npcs.NoppesUtilServer; import noppes.npcs.NoppesUtilServer;
import noppes.npcs.Server;
import noppes.npcs.blocks.tiles.TileBigSign; import noppes.npcs.blocks.tiles.TileBigSign;
import noppes.npcs.blocks.tiles.TileColorable; import noppes.npcs.blocks.tiles.TileColorable;
import noppes.npcs.constants.EnumGuiType; import noppes.npcs.constants.EnumGuiType;
import noppes.npcs.constants.EnumPacketClient;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockBigSign extends BlockContainer{ public class BlockBigSign extends BlockContainer{
@@ -1,12 +1,9 @@
package noppes.npcs.blocks; package noppes.npcs.blocks;
import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockEnchantmentTable;
import net.minecraft.block.BlockFence;
import net.minecraft.block.BlockFenceGate;
import net.minecraft.block.BlockFurnace;
import net.minecraft.block.BlockGlowstone;
import net.minecraft.block.BlockSapling;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
@@ -18,9 +15,6 @@ import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World; import net.minecraft.world.World;
import noppes.npcs.CustomItems; import noppes.npcs.CustomItems;
import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockBlood extends Block{ public class BlockBlood extends Block{
@@ -2,27 +2,21 @@ package noppes.npcs.blocks;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer; import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.IIcon; import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper; import net.minecraft.util.MathHelper;
import net.minecraft.world.World; import net.minecraft.world.World;
import noppes.npcs.CustomItems; import noppes.npcs.CustomItems;
import noppes.npcs.CustomNpcs; import noppes.npcs.CustomNpcs;
import noppes.npcs.Server;
import noppes.npcs.blocks.tiles.TileBorder; import noppes.npcs.blocks.tiles.TileBorder;
import noppes.npcs.constants.EnumGuiType; import noppes.npcs.constants.EnumGuiType;
import noppes.npcs.constants.EnumPacketServer;
public class BlockBorder extends BlockContainer{ public class BlockBorder extends BlockContainer{
public int renderId = -1; public int renderId = -1;
@@ -1,7 +1,7 @@
package noppes.npcs.blocks; package noppes.npcs.blocks;
import java.util.Random; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
@@ -14,11 +14,9 @@ import noppes.npcs.CustomItems;
import noppes.npcs.CustomNpcs; import noppes.npcs.CustomNpcs;
import noppes.npcs.NoppesUtilServer; import noppes.npcs.NoppesUtilServer;
import noppes.npcs.blocks.tiles.TileCampfire; import noppes.npcs.blocks.tiles.TileCampfire;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import cpw.mods.fml.relauncher.Side; import java.util.Random;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockCampfire extends BlockLightable{ public class BlockCampfire extends BlockLightable{
@@ -1,9 +1,8 @@
package noppes.npcs.blocks; package noppes.npcs.blocks;
import java.util.Random; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon; import net.minecraft.util.IIcon;
@@ -12,8 +11,8 @@ import net.minecraft.world.World;
import noppes.npcs.CustomItems; import noppes.npcs.CustomItems;
import noppes.npcs.blocks.tiles.TileCandle; import noppes.npcs.blocks.tiles.TileCandle;
import noppes.npcs.blocks.tiles.TileColorable; import noppes.npcs.blocks.tiles.TileColorable;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import java.util.Random;
public class BlockCandle extends BlockLightable{ public class BlockCandle extends BlockLightable{
@@ -1,7 +1,5 @@
package noppes.npcs.blocks; package noppes.npcs.blocks;
import java.util.List;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.BlockContainer; import net.minecraft.block.BlockContainer;
@@ -15,11 +13,12 @@ import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MathHelper; import net.minecraft.util.MathHelper;
import net.minecraft.world.World; import net.minecraft.world.World;
import noppes.npcs.CustomItems;
import noppes.npcs.CustomNpcs; import noppes.npcs.CustomNpcs;
import noppes.npcs.blocks.tiles.TileBlockAnvil; import noppes.npcs.blocks.tiles.TileBlockAnvil;
import noppes.npcs.constants.EnumGuiType; import noppes.npcs.constants.EnumGuiType;
import java.util.List;
public class BlockCarpentryBench extends BlockContainer public class BlockCarpentryBench extends BlockContainer
{ {
public int renderId = -1; public int renderId = -1;
@@ -1,10 +1,5 @@
package noppes.npcs.blocks; package noppes.npcs.blocks;
import java.util.List;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs; import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
@@ -14,17 +9,12 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import noppes.npcs.blocks.tiles.TileChair; import noppes.npcs.blocks.tiles.TileChair;
import noppes.npcs.blocks.tiles.TileColorable;
import noppes.npcs.entity.EntityChairMount; import noppes.npcs.entity.EntityChairMount;
import noppes.npcs.entity.EntityCustomNpc; import noppes.npcs.entity.EntityCustomNpc;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import java.util.List;
public class BlockChair extends BlockRotated{ public class BlockChair extends BlockRotated{
@@ -1,7 +1,7 @@
package noppes.npcs.blocks; package noppes.npcs.blocks;
import java.util.List; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockColored; import net.minecraft.block.BlockColored;
import net.minecraft.block.BlockContainer; import net.minecraft.block.BlockContainer;
@@ -22,8 +22,8 @@ import net.minecraft.world.World;
import noppes.npcs.NoppesUtilServer; import noppes.npcs.NoppesUtilServer;
import noppes.npcs.blocks.tiles.TileColorable; import noppes.npcs.blocks.tiles.TileColorable;
import noppes.npcs.blocks.tiles.TileCouchWood; import noppes.npcs.blocks.tiles.TileCouchWood;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import java.util.List;
public class BlockCouchWood extends BlockContainer{ public class BlockCouchWood extends BlockContainer{
@@ -1,7 +1,7 @@
package noppes.npcs.blocks; package noppes.npcs.blocks;
import java.util.List; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockColored; import net.minecraft.block.BlockColored;
import net.minecraft.block.BlockContainer; import net.minecraft.block.BlockContainer;
@@ -22,8 +22,8 @@ import net.minecraft.world.World;
import noppes.npcs.NoppesUtilServer; import noppes.npcs.NoppesUtilServer;
import noppes.npcs.blocks.tiles.TileColorable; import noppes.npcs.blocks.tiles.TileColorable;
import noppes.npcs.blocks.tiles.TileCouchWool; import noppes.npcs.blocks.tiles.TileCouchWool;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import java.util.List;
public class BlockCouchWool extends BlockContainer{ public class BlockCouchWool extends BlockContainer{
@@ -1,7 +1,5 @@
package noppes.npcs.blocks; package noppes.npcs.blocks;
import java.util.List;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.creativetab.CreativeTabs; import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
@@ -16,6 +14,8 @@ import noppes.npcs.blocks.tiles.TileCrate;
import noppes.npcs.blocks.tiles.TileNpcContainer; import noppes.npcs.blocks.tiles.TileNpcContainer;
import noppes.npcs.constants.EnumGuiType; import noppes.npcs.constants.EnumGuiType;
import java.util.List;
public class BlockCrate extends BlockRotated{ public class BlockCrate extends BlockRotated{
public BlockCrate() { public BlockCrate() {
@@ -1,11 +1,7 @@
package noppes.npcs.blocks; package noppes.npcs.blocks;
import java.util.List;
import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.BlockBreakable; import net.minecraft.block.BlockBreakable;
import net.minecraft.block.material.MapColor; import net.minecraft.block.material.MapColor;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
@@ -14,6 +10,8 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
import java.util.List;
public class BlockCrystal extends BlockBreakable{ public class BlockCrystal extends BlockBreakable{
public BlockCrystal() { public BlockCrystal() {
@@ -1,7 +1,8 @@
package noppes.npcs.blocks; package noppes.npcs.blocks;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon; import net.minecraft.util.IIcon;
@@ -10,8 +11,6 @@ import net.minecraft.world.World;
import noppes.npcs.CustomItems; import noppes.npcs.CustomItems;
import noppes.npcs.blocks.tiles.TileColorable; import noppes.npcs.blocks.tiles.TileColorable;
import noppes.npcs.blocks.tiles.TileLamp; import noppes.npcs.blocks.tiles.TileLamp;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockLamp extends BlockLightable{ public class BlockLamp extends BlockLightable{
@@ -1,17 +1,16 @@
package noppes.npcs.blocks; package noppes.npcs.blocks;
import java.util.Random;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
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;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World; import net.minecraft.world.World;
import java.util.Random;
public abstract class BlockLightable extends BlockRotated{ public abstract class BlockLightable extends BlockRotated{
protected BlockLightable(Block block, boolean lit) { protected BlockLightable(Block block, boolean lit) {
@@ -1,8 +1,7 @@
package noppes.npcs.blocks; package noppes.npcs.blocks;
import java.util.ArrayList; import cpw.mods.fml.relauncher.Side;
import java.util.List; import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.BlockContainer; import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.client.renderer.texture.IIconRegister;
@@ -21,8 +20,9 @@ import noppes.npcs.Server;
import noppes.npcs.blocks.tiles.TileMailbox; import noppes.npcs.blocks.tiles.TileMailbox;
import noppes.npcs.constants.EnumGuiType; import noppes.npcs.constants.EnumGuiType;
import noppes.npcs.constants.EnumPacketClient; import noppes.npcs.constants.EnumPacketClient;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import java.util.ArrayList;
import java.util.List;
public class BlockMailbox extends BlockContainer{ public class BlockMailbox extends BlockContainer{
Loaded 100 of 630 files, more files were not shown because too many files have changed in this diff. Show more